]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - Makefile.inc1
Change the current working directory to be inside the jail created by
[FreeBSD/releng/7.2.git] / Makefile.inc1
1 #
2 # $FreeBSD$
3 #
4 # Make command line options:
5 #       -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6 #       -DNO_CLEAN do not clean at all
7 #       -DNO_SHARE do not go into share subdir
8 #       -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
9 #       -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
10 #       -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
11 #       -DNO_PORTSUPDATE do not update ports in ${MAKE} update
12 #       -DNO_DOCUPDATE do not update doc in ${MAKE} update
13 #       -DNO_CTF do not run the DTrace CTF conversion tools on built objects
14 #       LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
15 #       TARGET="machine" to crossbuild world for a different machine type
16
17 #
18 # The intended user-driven targets are:
19 # buildworld  - rebuild *everything*, including glue to help do upgrades
20 # installworld- install everything built by "buildworld"
21 # doxygen     - build API documentation of the kernel
22 # update      - convenient way to update your source tree (eg: cvsup/cvs)
23 #
24 # Standard targets (not defined here) are documented in the makefiles in
25 # /usr/share/mk.  These include:
26 #               obj depend all install clean cleandepend cleanobj
27
28 .include <bsd.own.mk>
29
30 # We must do share/info early so that installation of info `dir'
31 # entries works correctly.  Do it first since it is less likely to
32 # grow dependencies on include and lib than vice versa.
33 #
34 # We must do lib/ and libexec/ before bin/, because if installworld
35 # installs a new /bin/sh, the 'make' command will *immediately*
36 # use that new version.  And the new (dynamically-linked) /bin/sh
37 # will expect to find appropriate libraries in /lib and /libexec.
38 #
39 SUBDIR= share/info lib libexec
40 SUBDIR+=bin
41 .if ${MK_GAMES} != "no"
42 SUBDIR+=games
43 .endif
44 .if ${MK_CDDL} != "no"
45 SUBDIR+=cddl
46 .else
47 NO_CTF=1
48 .endif
49 SUBDIR+=gnu include
50 .if ${MK_KERBEROS} != "no"
51 SUBDIR+=kerberos5
52 .endif
53 .if ${MK_RESCUE} != "no"
54 SUBDIR+=rescue
55 .endif
56 SUBDIR+=sbin
57 .if ${MK_CRYPT} != "no"
58 SUBDIR+=secure
59 .endif
60 .if !defined(NO_SHARE)
61 SUBDIR+=share
62 .endif
63 SUBDIR+=sys usr.bin usr.sbin
64 #
65 # We must do etc/ last for install/distribute to work.
66 #
67 SUBDIR+=etc
68
69 # These are last, since it is nice to at least get the base system
70 # rebuilt before you do them.
71 .for _DIR in ${LOCAL_DIRS}
72 .if exists(${.CURDIR}/${_DIR}/Makefile)
73 SUBDIR+= ${_DIR}
74 .endif
75 .endfor
76
77 .if defined(SUBDIR_OVERRIDE)
78 SUBDIR=         ${SUBDIR_OVERRIDE}
79 .endif
80
81 .if defined(NOCLEAN)
82 NO_CLEAN=       ${NOCLEAN}
83 .endif
84 .if defined(NO_CLEANDIR)
85 CLEANDIR=       clean cleandepend
86 .else
87 CLEANDIR=       cleandir
88 .endif
89
90 CVS?=           cvs
91 CVSFLAGS?=      -r RELENG_7_2 -P -d -I!
92 SUP?=           /usr/bin/csup
93 SUPFLAGS?=      -g -L 2
94 .if defined(SUPHOST)
95 SUPFLAGS+=      -h ${SUPHOST}
96 .endif
97
98 MAKEOBJDIRPREFIX?=      /usr/obj
99 .if !defined(OSRELDATE)
100 .if exists(/usr/include/osreldate.h)
101 OSRELDATE!=     awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
102                 /usr/include/osreldate.h
103 .else
104 OSRELDATE=      0
105 .endif
106 .endif
107
108 .if !defined(VERSION)
109 VERSION!=       uname -srp
110 VERSION+=       ${OSRELDATE}
111 .endif
112
113 # Guess machine architecture from machine type, and vice versa.
114 .if !defined(TARGET_ARCH) && defined(TARGET)
115 TARGET_ARCH=    ${TARGET:S/pc98/i386/:S/sun4v/sparc64/}
116 .elif !defined(TARGET) && defined(TARGET_ARCH) && \
117     ${TARGET_ARCH} != ${MACHINE_ARCH}
118 TARGET=         ${TARGET_ARCH}
119 .endif
120 # Otherwise, default to current machine type and architecture.
121 TARGET?=        ${MACHINE}
122 TARGET_ARCH?=   ${MACHINE_ARCH}
123
124 KNOWN_ARCHES?=  amd64 arm i386 i386/pc98 ia64 powerpc sparc64 sparc64/sun4v
125 .if ${TARGET} == ${TARGET_ARCH}
126 _t=             ${TARGET}
127 .else
128 _t=             ${TARGET_ARCH}/${TARGET}
129 .endif
130 .for _t in ${_t}
131 .if empty(KNOWN_ARCHES:M${_t})
132 .error Unknown target ${TARGET_ARCH}:${TARGET}.
133 .endif
134 .endfor
135
136 .if ${TARGET} == ${MACHINE}
137 TARGET_CPUTYPE?=${CPUTYPE}
138 .else
139 TARGET_CPUTYPE?=
140 .endif
141
142 .if !empty(TARGET_CPUTYPE)
143 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
144 .else
145 _TARGET_CPUTYPE=dummy
146 .endif
147 _CPUTYPE!=      MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
148                 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
149 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
150 .error CPUTYPE global should be set with ?=.
151 .endif
152 .if make(buildworld)
153 BUILD_ARCH!=    uname -p
154 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
155 .error To cross-build, set TARGET_ARCH.
156 .endif
157 .endif
158 .if ${MACHINE} == ${TARGET} && !defined(CROSS_BUILD_TESTING)
159 OBJTREE=        ${MAKEOBJDIRPREFIX}
160 .else
161 OBJTREE=        ${MAKEOBJDIRPREFIX}/${TARGET}
162 .endif
163 WORLDTMP=       ${OBJTREE}${.CURDIR}/tmp
164 # /usr/games added for fortune which depend on strfile
165 BPATH=          ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
166 XPATH=          ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
167 STRICTTMPPATH=  ${BPATH}:${XPATH}
168 TMPPATH=        ${STRICTTMPPATH}:${PATH}
169
170 INSTALLTMP!=    /usr/bin/mktemp -d -u -t install
171
172 #
173 # Building a world goes through the following stages
174 #
175 # 1. legacy stage [BMAKE]
176 #       This stage is responsible for creating compatibility
177 #       shims that are needed by the bootstrap-tools,
178 #       build-tools and cross-tools stages.
179 # 1. bootstrap-tools stage [BMAKE]
180 #       This stage is responsible for creating programs that
181 #       are needed for backward compatibility reasons. They
182 #       are not built as cross-tools.
183 # 2. build-tools stage [TMAKE]
184 #       This stage is responsible for creating the object
185 #       tree and building any tools that are needed during
186 #       the build process.
187 # 3. cross-tools stage [XMAKE]
188 #       This stage is responsible for creating any tools that
189 #       are needed for cross-builds. A cross-compiler is one
190 #       of them.
191 # 4. world stage [WMAKE]
192 #       This stage actually builds the world.
193 # 5. install stage (optional) [IMAKE]
194 #       This stage installs a previously built world.
195 #
196
197 BOOTSTRAPPING?= 0
198
199 # Common environment for world related stages
200 CROSSENV=       MAKEOBJDIRPREFIX=${OBJTREE} \
201                 MACHINE_ARCH=${TARGET_ARCH} \
202                 MACHINE=${TARGET} \
203                 CPUTYPE=${TARGET_CPUTYPE} \
204                 GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
205                 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
206                 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
207
208 # bootstrap-tools stage
209 BMAKEENV=       INSTALL="sh ${.CURDIR}/tools/install.sh" \
210                 PATH=${BPATH}:${PATH} \
211                 WORLDTMP=${WORLDTMP} \
212                 VERSION="${VERSION}" \
213                 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
214 BMAKE=          MAKEOBJDIRPREFIX=${WORLDTMP} \
215                 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
216                 DESTDIR= \
217                 BOOTSTRAPPING=${OSRELDATE} \
218                 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
219                 -DWITHOUT_NLS -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
220                 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF
221
222 # build-tools stage
223 TMAKE=          MAKEOBJDIRPREFIX=${OBJTREE} \
224                 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
225                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
226                 DESTDIR= \
227                 BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS \
228                 -DNO_WARNS -DNO_CTF
229
230 # cross-tools stage
231 XMAKE=          TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
232                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
233                 -DWITHOUT_GDB
234
235 # world stage
236 WMAKEENV=       ${CROSSENV} \
237                 _SHLIBDIRPREFIX=${WORLDTMP} \
238                 VERSION="${VERSION}" \
239                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
240                 PATH=${TMPPATH}
241 .if ${MK_CDDL} == "no" || defined(NO_CTF)
242 WMAKEENV+=      NO_CTF=1
243 .endif
244 WMAKE=          ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
245
246 .if ${TARGET_ARCH} == "amd64"
247 # 32 bit world
248 LIB32TMP=       ${OBJTREE}${.CURDIR}/lib32
249
250 .if empty(TARGET_CPUTYPE)
251 LIB32CPUFLAGS=  -march=i686 -mmmx -msse -msse2
252 .else
253 LIB32CPUFLAGS=  -march=${TARGET_CPUTYPE}
254 .endif
255 LIB32FLAGS=     -m32 ${LIB32CPUFLAGS} -mfancy-math-387 -DCOMPAT_32BIT \
256                 -iprefix ${LIB32TMP}/usr/ \
257                 -L${LIB32TMP}/usr/lib32 \
258                 -B${LIB32TMP}/usr/lib32
259
260 # Yes, the flags are redundant.
261 LIB32WMAKEENV=  MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
262                 _SHLIBDIRPREFIX=${LIB32TMP} \
263                 VERSION="${VERSION}" \
264                 MACHINE=i386 \
265                 MACHINE_ARCH=i386 \
266                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
267                 PATH=${TMPPATH} \
268                 CC="${CC} ${LIB32FLAGS}" \
269                 CXX="${CXX} ${LIB32FLAGS}" \
270                 OBJC="${OBJC} ${LIB32FLAGS}" \
271                 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
272                 AS="${AS} --32" \
273                 LIBDIR=/usr/lib32 \
274                 SHLIBDIR=/usr/lib32
275
276 LIB32WMAKE=     ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \
277                 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_INFO \
278                 -DWITHOUT_HTML -DNO_CTF DESTDIR=${LIB32TMP}
279 LIB32IMAKE=     ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS
280 .endif
281
282 # install stage
283 .if empty(.MAKEFLAGS:M-n)
284 IMAKEENV=       ${CROSSENV} \
285                 PATH=${STRICTTMPPATH}:${INSTALLTMP}
286 .else
287 IMAKEENV=       ${CROSSENV} \
288                 PATH=${TMPPATH}:${INSTALLTMP}
289 .endif
290 IMAKE=          ${IMAKEENV} ${MAKE} -f Makefile.inc1
291
292 # kernel stage
293 KMAKEENV=       ${WMAKEENV}
294 KMAKE=          ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
295
296 #
297 # buildworld
298 #
299 # Attempt to rebuild the entire system, with reasonable chance of
300 # success, regardless of how old your existing system is.
301 #
302 _worldtmp:
303 .if ${.CURDIR:C/[^,]//g} != ""
304 #       The m4 build of sendmail files doesn't like it if ',' is used
305 #       anywhere in the path of it's files.
306         @echo
307         @echo "*** Error: path to source tree contains a comma ','"
308         @echo
309         false
310 .endif
311         @echo
312         @echo "--------------------------------------------------------------"
313         @echo ">>> Rebuilding the temporary build tree"
314         @echo "--------------------------------------------------------------"
315 .if !defined(NO_CLEAN)
316         rm -rf ${WORLDTMP}
317 .if ${TARGET_ARCH} == "amd64"
318         rm -rf ${LIB32TMP}
319 .endif
320 .else
321         rm -rf ${WORLDTMP}/legacy/usr/include
322 #       XXX - These three can depend on any header file.
323         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
324         rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
325         rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
326 .endif
327 .for _dir in \
328     usr/bin usr/games usr/include/sys usr/lib \
329     usr/libexec usr/sbin usr/share/dict \
330     usr/share/groff_font/devX100 \
331     usr/share/groff_font/devX100-12 \
332     usr/share/groff_font/devX75 \
333     usr/share/groff_font/devX75-12 \
334     usr/share/groff_font/devascii \
335     usr/share/groff_font/devcp1047 \
336     usr/share/groff_font/devdvi \
337     usr/share/groff_font/devhtml \
338     usr/share/groff_font/devkoi8-r \
339     usr/share/groff_font/devlatin1 \
340     usr/share/groff_font/devlbp \
341     usr/share/groff_font/devlj4 \
342     usr/share/groff_font/devps \
343     usr/share/groff_font/devutf8 \
344     usr/share/tmac/mdoc usr/share/tmac/mm
345         mkdir -p ${WORLDTMP}/legacy/${_dir}
346 .endfor
347 .for _dir in \
348     lib usr/bin usr/include usr/lib/compat/aout usr/libdata/ldscripts \
349     usr/libexec usr/sbin usr/share/misc
350         mkdir -p ${WORLDTMP}/${_dir}
351 .endfor
352         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
353             -p ${WORLDTMP}/usr/include >/dev/null
354         ln -sf ${.CURDIR}/sys ${WORLDTMP}
355 .if ${MK_BIND_LIBS} != "no"
356         mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
357             -p ${WORLDTMP}/usr/include >/dev/null
358 .endif
359 _legacy:
360         @echo
361         @echo "--------------------------------------------------------------"
362         @echo ">>> stage 1.1: legacy release compatibility shims"
363         @echo "--------------------------------------------------------------"
364         ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
365 _bootstrap-tools:
366         @echo
367         @echo "--------------------------------------------------------------"
368         @echo ">>> stage 1.2: bootstrap tools"
369         @echo "--------------------------------------------------------------"
370         ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
371 _cleanobj:
372 .if !defined(NO_CLEAN)
373         @echo
374         @echo "--------------------------------------------------------------"
375         @echo ">>> stage 2.1: cleaning up the object tree"
376         @echo "--------------------------------------------------------------"
377         ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
378 .if ${TARGET_ARCH} == "amd64"
379         ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
380 .endif
381 .endif
382 _obj:
383         @echo
384         @echo "--------------------------------------------------------------"
385         @echo ">>> stage 2.2: rebuilding the object tree"
386         @echo "--------------------------------------------------------------"
387         ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
388 _build-tools:
389         @echo
390         @echo "--------------------------------------------------------------"
391         @echo ">>> stage 2.3: build tools"
392         @echo "--------------------------------------------------------------"
393         ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
394 _cross-tools:
395         @echo
396         @echo "--------------------------------------------------------------"
397         @echo ">>> stage 3: cross tools"
398         @echo "--------------------------------------------------------------"
399         ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
400 _includes:
401         @echo
402         @echo "--------------------------------------------------------------"
403         @echo ">>> stage 4.1: building includes"
404         @echo "--------------------------------------------------------------"
405         ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
406 _libraries:
407         @echo
408         @echo "--------------------------------------------------------------"
409         @echo ">>> stage 4.2: building libraries"
410         @echo "--------------------------------------------------------------"
411         ${_+_}cd ${.CURDIR}; \
412             ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
413             -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE libraries
414 _depend:
415         @echo
416         @echo "--------------------------------------------------------------"
417         @echo ">>> stage 4.3: make dependencies"
418         @echo "--------------------------------------------------------------"
419         ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
420 everything:
421         @echo
422         @echo "--------------------------------------------------------------"
423         @echo ">>> stage 4.4: building everything"
424         @echo "--------------------------------------------------------------"
425         ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
426 .if ${TARGET_ARCH} == "amd64"
427 build32:
428         @echo
429         @echo "--------------------------------------------------------------"
430         @echo ">>> stage 5.1: building 32 bit shim libraries"
431         @echo "--------------------------------------------------------------"
432 .for _dir in \
433     usr/include usr/lib32 usr/share/misc
434         mkdir -p ${LIB32TMP}/${_dir}
435 .endfor
436         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
437             -p ${LIB32TMP}/usr/include >/dev/null
438         mkdir -p ${WORLDTMP}
439         ln -sf ${.CURDIR}/sys ${WORLDTMP}
440 .if ${MK_KERBEROS} != "no"
441 .for _t in obj depend all
442         cd ${.CURDIR}/kerberos5/tools; \
443             MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= ${_t}
444 .endfor
445 .endif
446 .for _t in obj includes
447         cd ${.CURDIR}/include; ${LIB32WMAKE} ${_t}
448         cd ${.CURDIR}/lib; ${LIB32WMAKE} ${_t}
449 .if ${MK_CDDL} != "no"
450         cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} ${_t}
451 .endif
452         cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} ${_t}
453 .if ${MK_CRYPT} != "no"
454         cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} ${_t}
455 .endif
456 .if ${MK_KERBEROS} != "no"
457         cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} ${_t}
458 .endif
459 .endfor
460 .for _dir in usr.bin/lex/lib
461         cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} obj
462 .endfor
463 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
464         cd ${.CURDIR}/${_dir}; \
465             MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} DESTDIR= build-tools
466 .endfor
467         cd ${.CURDIR}; \
468             ${LIB32WMAKE} -f Makefile.inc1 libraries
469 .for _t in obj depend all
470         cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} ${_t}
471         cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} ${_t}
472 .endfor
473
474 distribute32 install32:
475 .if make(distribute32)
476         mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32   # XXX add to mtree
477         mkdir -p ${DISTDIR}/${DISTRIBUTION}/usr/lib32/dtrace    # XXX add to mtree
478 .else
479         mkdir -p ${DESTDIR}/usr/lib32                   # XXX add to mtree
480         mkdir -p ${DESTDIR}/usr/lib32/dtrace            # XXX add to mtree
481 .endif
482         cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
483 .if ${MK_CDDL} != "no"
484         cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
485 .endif
486         cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
487 .if ${MK_CRYPT} != "no"
488         cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
489 .endif
490 .if ${MK_KERBEROS} != "no"
491         cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
492 .endif
493         cd ${.CURDIR}/libexec/rtld-elf; \
494             PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
495         cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
496 .endif
497
498 WMAKE_TGTS=
499 .if !defined(SUBDIR_OVERRIDE)
500 WMAKE_TGTS+=    _worldtmp _legacy _bootstrap-tools
501 .endif
502 WMAKE_TGTS+=    _cleanobj _obj _build-tools
503 .if !defined(SUBDIR_OVERRIDE)
504 WMAKE_TGTS+=    _cross-tools
505 .endif
506 WMAKE_TGTS+=    _includes _libraries _depend everything
507 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
508 WMAKE_TGTS+=    build32
509 .endif
510
511 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
512 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
513
514 buildworld_prologue:
515         @echo "--------------------------------------------------------------"
516         @echo ">>> World build started on `LC_ALL=C date`"
517         @echo "--------------------------------------------------------------"
518
519 buildworld_epilogue:
520         @echo
521         @echo "--------------------------------------------------------------"
522         @echo ">>> World build completed on `LC_ALL=C date`"
523         @echo "--------------------------------------------------------------"
524
525 #
526 # We need to have this as a target because the indirection between Makefile
527 # and Makefile.inc1 causes the correct PATH to be used, rather than a
528 # modification of the current environment's PATH.  In addition, we need
529 # to quote multiword values.
530 #
531 buildenvvars:
532         @echo ${WMAKEENV:Q}
533
534 buildenv:
535         @echo Entering world for ${TARGET_ARCH}:${TARGET}
536         @cd ${.CURDIR} && env ${WMAKEENV} sh || true
537
538 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
539 toolchain: ${TOOLCHAIN_TGTS}
540 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
541
542 #
543 # installcheck
544 #
545 # Checks to be sure system is ready for installworld/installkernel.
546 #
547 installcheck:
548
549 #
550 # Require DESTDIR to be set if installing for a different architecture.
551 #
552 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE}
553 .if !make(distributeworld)
554 installcheck: installcheck_DESTDIR
555 installcheck_DESTDIR:
556 .if !defined(DESTDIR) || empty(DESTDIR)
557         @echo "ERROR: Please set DESTDIR!"; \
558         false
559 .endif
560 .endif
561 .endif
562
563 #
564 # Check for missing UIDs/GIDs.
565 #
566 CHECK_UIDS=
567 CHECK_GIDS=     audit
568 .if ${MK_SENDMAIL} != "no"
569 CHECK_UIDS+=    smmsp
570 CHECK_GIDS+=    smmsp
571 .endif
572 .if ${MK_PF} != "no"
573 CHECK_UIDS+=    proxy
574 CHECK_GIDS+=    proxy authpf
575 .endif
576 installcheck: installcheck_UGID
577 installcheck_UGID:
578 .for uid in ${CHECK_UIDS}
579         @if ! `id -u ${uid} >/dev/null 2>&1`; then \
580                 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
581                 false; \
582         fi
583 .endfor
584 .for gid in ${CHECK_GIDS}
585         @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
586                 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
587                 false; \
588         fi
589 .endfor
590
591 #
592 # distributeworld
593 #
594 # Distributes everything compiled by a `buildworld'.
595 #
596 # installworld
597 #
598 # Installs everything compiled by a 'buildworld'.
599 #
600 .if ${MK_INFO} != "no"
601 _install-info=  install-info
602 .endif
603
604 distributeworld installworld: installcheck
605         mkdir -p ${INSTALLTMP}
606         for prog in [ awk cap_mkdb cat chflags chmod chown \
607             date echo egrep find grep ${_install-info} \
608             ln lockf make mkdir mtree mv pwd_mkdb rm sed sh sysctl \
609             test true uname wc zic; do \
610                 cp `which $$prog` ${INSTALLTMP}; \
611         done
612         ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
613         rm -rf ${INSTALLTMP}
614
615 #
616 # reinstall
617 #
618 # If you have a build server, you can NFS mount the source and obj directories
619 # and do a 'make reinstall' on the *client* to install new binaries from the
620 # most recent server build.
621 #
622 reinstall:
623         @echo "--------------------------------------------------------------"
624         @echo ">>> Making hierarchy"
625         @echo "--------------------------------------------------------------"
626         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
627         @echo
628         @echo "--------------------------------------------------------------"
629         @echo ">>> Installing everything"
630         @echo "--------------------------------------------------------------"
631         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
632 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
633         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
634 .endif
635
636 redistribute:
637         @echo "--------------------------------------------------------------"
638         @echo ">>> Distributing everything"
639         @echo "--------------------------------------------------------------"
640         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
641 .if ${TARGET_ARCH} == "amd64" && ${MK_LIB32} != "no"
642         ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
643             DISTRIBUTION=lib32
644 .endif
645
646 distrib-dirs distribution:
647         cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} ${.TARGET}
648
649 #
650 # buildkernel and installkernel
651 #
652 # Which kernels to build and/or install is specified by setting
653 # KERNCONF. If not defined a GENERIC kernel is built/installed.
654 # Only the existing (depending TARGET) config files are used
655 # for building kernels and only the first of these is designated
656 # as the one being installed.
657 #
658 # Note that we have to use TARGET instead of TARGET_ARCH when
659 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
660 # be set to cross-build, we have to make sure TARGET is set
661 # properly.
662
663 .if !defined(KERNCONF) && defined(KERNEL)
664 KERNCONF=       ${KERNEL}
665 KERNWARN=
666 .else
667 KERNCONF?=      GENERIC
668 .endif
669 INSTKERNNAME?=  kernel
670
671 KERNSRCDIR?=    ${.CURDIR}/sys
672 KRNLCONFDIR=    ${KERNSRCDIR}/${TARGET}/conf
673 KRNLOBJDIR=     ${OBJTREE}${KERNSRCDIR}
674 KERNCONFDIR?=   ${KRNLCONFDIR}
675
676 BUILDKERNELS=
677 INSTALLKERNEL=
678 .for _kernel in ${KERNCONF}
679 .if exists(${KERNCONFDIR}/${_kernel})
680 BUILDKERNELS+=  ${_kernel}
681 .if empty(INSTALLKERNEL)
682 INSTALLKERNEL= ${_kernel}
683 .endif
684 .endif
685 .endfor
686
687 #
688 # buildkernel
689 #
690 # Builds all kernels defined by BUILDKERNELS.
691 #
692 buildkernel:
693 .if empty(BUILDKERNELS)
694         @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
695         false
696 .endif
697 .if defined(KERNWARN)
698         @echo "--------------------------------------------------------------"
699         @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
700         @echo "--------------------------------------------------------------"
701         @sleep 3
702 .endif
703         @echo
704 .for _kernel in ${BUILDKERNELS}
705         @echo "--------------------------------------------------------------"
706         @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
707         @echo "--------------------------------------------------------------"
708         @echo "===> ${_kernel}"
709         mkdir -p ${KRNLOBJDIR}
710 .if !defined(NO_KERNELCONFIG)
711         @echo
712         @echo "--------------------------------------------------------------"
713         @echo ">>> stage 1: configuring the kernel"
714         @echo "--------------------------------------------------------------"
715         cd ${KRNLCONFDIR}; \
716                 PATH=${TMPPATH} \
717                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
718                         ${KERNCONFDIR}/${_kernel}
719 .endif
720 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
721         @echo
722         @echo "--------------------------------------------------------------"
723         @echo ">>> stage 2.1: cleaning up the object tree"
724         @echo "--------------------------------------------------------------"
725         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
726 .endif
727         @echo
728         @echo "--------------------------------------------------------------"
729         @echo ">>> stage 2.2: rebuilding the object tree"
730         @echo "--------------------------------------------------------------"
731         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
732         @echo
733         @echo "--------------------------------------------------------------"
734         @echo ">>> stage 2.3: build tools"
735         @echo "--------------------------------------------------------------"
736         cd ${KRNLOBJDIR}/${_kernel}; \
737             MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
738             ${MAKE} -DNO_CPU_CFLAGS -DNO_CTF \
739             -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
740 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
741 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
742 .for target in obj depend all
743         cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
744             MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
745             ${MAKE} -DNO_CPU_CFLAGS -DNO_CTF ${target}
746 .endfor
747 .endif
748 .if !defined(NO_KERNELDEPEND)
749         @echo
750         @echo "--------------------------------------------------------------"
751         @echo ">>> stage 3.1: making dependencies"
752         @echo "--------------------------------------------------------------"
753         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
754 .endif
755         @echo
756         @echo "--------------------------------------------------------------"
757         @echo ">>> stage 3.2: building everything"
758         @echo "--------------------------------------------------------------"
759         cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
760         @echo "--------------------------------------------------------------"
761         @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
762         @echo "--------------------------------------------------------------"
763 .endfor
764
765 #
766 # installkernel, etc.
767 #
768 # Install the kernel defined by INSTALLKERNEL
769 #
770 installkernel installkernel.debug \
771 reinstallkernel reinstallkernel.debug: installcheck
772 .if empty(INSTALLKERNEL)
773         @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
774         false
775 .endif
776         @echo "--------------------------------------------------------------"
777         @echo ">>> Installing kernel"
778         @echo "--------------------------------------------------------------"
779         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
780             ${CROSSENV} PATH=${TMPPATH} \
781             ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
782
783 #
784 # doxygen
785 #
786 # Build the API documentation with doxygen
787 #
788 doxygen:
789         @if [ ! -x `/usr/bin/which doxygen` ]; then \
790                 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
791                 exit 1; \
792         fi
793         cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
794
795 #
796 # update
797 #
798 # Update the source tree, by running cvsup and/or running cvs to update to the
799 # latest copy.
800 #
801 update:
802 .if defined(SUP_UPDATE)
803         @echo "--------------------------------------------------------------"
804         @echo ">>> Running ${SUP}"
805         @echo "--------------------------------------------------------------"
806 .if defined(SUPFILE)
807         @${SUP} ${SUPFLAGS} ${SUPFILE}
808 .endif
809 .if defined(SUPFILE1)
810         @${SUP} ${SUPFLAGS} ${SUPFILE1}
811 .endif
812 .if defined(SUPFILE2)
813         @${SUP} ${SUPFLAGS} ${SUPFILE2}
814 .endif
815 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
816         @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
817 .endif
818 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
819         @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
820 .endif
821 .endif
822 .if defined(CVS_UPDATE)
823         @echo "--------------------------------------------------------------"
824         @echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
825         @echo "--------------------------------------------------------------"
826         cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
827 .endif
828
829 #
830 # ------------------------------------------------------------------------
831 #
832 # From here onwards are utility targets used by the 'make world' and
833 # related targets.  If your 'world' breaks, you may like to try to fix
834 # the problem and manually run the following targets to attempt to
835 # complete the build.  Beware, this is *not* guaranteed to work, you
836 # need to have a pretty good grip on the current state of the system
837 # to attempt to manually finish it.  If in doubt, 'make world' again.
838 #
839
840 #
841 # legacy: Build compatibility shims for the next three targets
842 #
843 legacy:
844 .if ${BOOTSTRAPPING} < 503000
845         @echo "ERROR: Source upgrades from versions prior to 5.3 not supported."; \
846         false
847 .endif
848 .for _tool in tools/build
849         ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
850             cd ${.CURDIR}/${_tool}; \
851             ${MAKE} DIRPRFX=${_tool}/ obj; \
852             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
853             ${MAKE} DIRPRFX=${_tool}/ depend; \
854             ${MAKE} DIRPRFX=${_tool}/ all; \
855             ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
856 .endfor
857
858 #
859 # bootstrap-tools: Build tools needed for compatibility
860 #
861 .if ${MK_GAMES} != "no"
862 _strfile=       games/fortune/strfile
863 .endif
864
865 .if ${MK_CXX} != "no"
866 _gperf=         gnu/usr.bin/gperf
867 .if ${BOOTSTRAPPING} < 700004
868 _groff=         gnu/usr.bin/groff
869 .else
870 _groff=         gnu/usr.bin/groff/tmac
871 .endif
872 .endif
873
874 .if ${BOOTSTRAPPING} < 600029
875 _texinfo=       gnu/usr.bin/texinfo
876 .endif
877
878 .if ${BOOTSTRAPPING} < 600015
879 _cap_mkdb=      usr.bin/cap_mkdb
880 .endif
881
882 .if ${BOOTSTRAPPING} < 600018
883 _colldef=       usr.bin/colldef
884 .endif
885
886 .if ${BOOTSTRAPPING} < 600017
887 _gencat=        usr.bin/gencat
888 .endif
889
890 .if ${BOOTSTRAPPING} < 600016
891 _mklocale=      usr.bin/mklocale
892 .endif
893
894 .if ${BOOTSTRAPPING} < 700018
895 _gensnmptree=   usr.sbin/bsnmpd/gensnmptree
896 .endif
897
898 .if ${MK_RESCUE} != "no" && \
899     ${BOOTSTRAPPING} < 700026
900 _crunchgen=     usr.sbin/crunch/crunchgen
901 .endif
902
903 .if ${BOOTSTRAPPING} < 600020
904 _pwd_mkdb=      usr.sbin/pwd_mkdb
905 .endif
906
907 #.if ${MK_CDDL} != "no"
908 #_dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
909 #    lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
910 #.endif
911
912 bootstrap-tools:
913 .for _tool in \
914     ${_dtrace_tools} \
915     ${_strfile} \
916     ${_gperf} \
917     ${_groff} \
918     ${_texinfo} \
919     ${_cap_mkdb} \
920     ${_colldef} \
921     ${_gencat} \
922     usr.bin/lorder \
923     usr.bin/makewhatis \
924     ${_mklocale} \
925     usr.bin/rpcgen \
926     usr.bin/xinstall \
927     ${_gensnmptree} \
928     usr.sbin/config \
929     ${_crunchgen} \
930     ${_pwd_mkdb}
931         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
932                 cd ${.CURDIR}/${_tool}; \
933                 ${MAKE} DIRPRFX=${_tool}/ obj; \
934                 ${MAKE} DIRPRFX=${_tool}/ depend; \
935                 ${MAKE} DIRPRFX=${_tool}/ all; \
936                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
937 .endfor
938
939 #
940 # build-tools: Build special purpose build tools
941 #
942 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
943 _aicasm= sys/modules/aic7xxx/aicasm
944 .endif
945
946 .if !defined(NO_SHARE)
947 _share= share/syscons/scrnmaps
948 .endif
949
950 .if ${MK_KERBEROS} != "no"
951 _kerberos5_tools= kerberos5/tools
952 .endif
953
954 .if ${MK_RESCUE} != "no"
955 _rescue= rescue/rescue
956 .endif
957
958 build-tools:
959 .for _tool in \
960     bin/csh \
961     bin/sh \
962     ${_rescue} \
963     lib/ncurses/ncurses \
964     lib/ncurses/ncursesw \
965     ${_share} \
966     ${_aicasm} \
967     usr.bin/awk \
968     lib/libmagic \
969     usr.sbin/sysinstall
970         ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
971                 cd ${.CURDIR}/${_tool}; \
972                 ${MAKE} DIRPRFX=${_tool}/ obj; \
973                 ${MAKE} DIRPRFX=${_tool}/ build-tools
974 .endfor
975 .for _tool in \
976     gnu/usr.bin/cc/cc_tools \
977     ${_kerberos5_tools}
978         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
979                 cd ${.CURDIR}/${_tool}; \
980                 ${MAKE} DIRPRFX=${_tool}/ obj; \
981                 ${MAKE} DIRPRFX=${_tool}/ depend; \
982                 ${MAKE} DIRPRFX=${_tool}/ all
983 .endfor
984
985 #
986 # cross-tools: Build cross-building tools
987 #
988 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
989 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
990 _btxld=         usr.sbin/btxld
991 .endif
992 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
993 _crunchide=     usr.sbin/crunch/crunchide
994 .endif
995 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
996 _kgzip=         usr.sbin/kgzip
997 .endif
998 .endif
999
1000 cross-tools:
1001 .for _tool in \
1002     gnu/usr.bin/binutils \
1003     gnu/usr.bin/cc \
1004     usr.bin/sed \
1005     usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1006     ${_btxld} \
1007     ${_crunchide} \
1008     ${_kgzip}
1009         ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1010                 cd ${.CURDIR}/${_tool}; \
1011                 ${MAKE} DIRPRFX=${_tool}/ obj; \
1012                 ${MAKE} DIRPRFX=${_tool}/ depend; \
1013                 ${MAKE} DIRPRFX=${_tool}/ all; \
1014                 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1015 .endfor
1016
1017 #
1018 # hierarchy - ensure that all the needed directories are present
1019 #
1020 hierarchy:
1021         cd ${.CURDIR}/etc;              ${MAKE} distrib-dirs
1022
1023 #
1024 # libraries - build all libraries, and install them under ${DESTDIR}.
1025 #
1026 # The list of libraries with dependents (${_prebuild_libs}) and their
1027 # interdependencies (__L) are built automatically by the
1028 # ${.CURDIR}/tools/make_libdeps.sh script.
1029 #
1030 libraries:
1031         cd ${.CURDIR}; \
1032             ${MAKE} -f Makefile.inc1 _prereq_libs; \
1033             ${MAKE} -f Makefile.inc1 _startup_libs; \
1034             ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1035             ${MAKE} -f Makefile.inc1 _generic_libs;
1036
1037 #
1038 # static libgcc.a prerequisite for shared libc
1039 #
1040 _prereq_libs= gnu/lib/libgcc
1041
1042 # These dependencies are not automatically generated:
1043 #
1044 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1045 # all shared libraries for ELF.
1046 #
1047 _startup_libs=  gnu/lib/csu
1048 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1049 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1050 .else
1051 _startup_libs+= lib/csu/${MACHINE_ARCH}
1052 .endif
1053 _startup_libs+= gnu/lib/libgcc
1054 _startup_libs+= lib/libc
1055
1056 gnu/lib/libgcc__L: lib/libc__L
1057
1058 _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libkrb5} \
1059                 ${_kerberos5_lib_libroken} \
1060                 lib/libbz2 lib/libcom_err lib/libcrypt lib/libexpat \
1061                 ${_lib_libgssapi} ${_lib_libipx} \
1062                 lib/libkiconv lib/libkvm lib/libmd \
1063                 lib/ncurses/ncurses lib/ncurses/ncursesw \
1064                 lib/libopie lib/libpam ${_default_thread_lib} \
1065                 lib/libradius lib/libsbuf lib/libtacplus lib/libutil \
1066                 ${_lib_libypclnt} lib/libz lib/msun \
1067                 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1068                 ${_secure_lib_libssl} lib/libdwarf lib/libproc
1069
1070 .if ${MK_LIBTHR} != "no" && ${MK_LIBKSE} != "no"
1071 _default_thread_lib=    lib/${DEFAULT_THREAD_LIB}
1072 .elif ${MK_LIBTHR} != "no"
1073 _default_thread_lib=    lib/libthr
1074 .elif ${MK_LIBKSE} != "no"
1075 _default_thread_lib=    lib/libkse
1076 .endif
1077
1078 _generic_libs=  ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
1079
1080 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1081
1082 .if ${MK_CDDL} != "no"
1083 _cddl_lib= cddl/lib
1084 .endif
1085
1086 .if ${MK_CRYPT} != "no"
1087 .if ${MK_OPENSSL} != "no"
1088 _secure_lib_libcrypto= secure/lib/libcrypto
1089 _secure_lib_libssl= secure/lib/libssl
1090 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1091 .if ${MK_OPENSSH} != "no"
1092 _secure_lib_libssh= secure/lib/libssh
1093 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1094 .if ${MK_KERBEROS} != "no"
1095 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1096     kerberos5/lib/libasn1__L lib/libcom_err__L lib/libmd__L \
1097     kerberos5/lib/libroken__L
1098 .endif
1099 .endif
1100 .endif
1101 _secure_lib=    secure/lib
1102 .endif
1103
1104 .if ${MK_IPX} != "no"
1105 _lib_libipx=    lib/libipx
1106 .endif
1107
1108 .if ${MK_KERBEROS} != "no"
1109 _kerberos5_lib= kerberos5/lib
1110 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1111 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1112 _kerberos5_lib_libroken= kerberos5/lib/libroken
1113 _lib_libgssapi= lib/libgssapi
1114 .endif
1115
1116 .if ${MK_NIS} != "no"
1117 _lib_libypclnt= lib/libypclnt
1118 .endif
1119
1120 .if ${MK_OPENSSL} == "no"
1121 lib/libradius__L: lib/libmd__L
1122 .endif
1123
1124 .for _lib in ${_prereq_libs}
1125 ${_lib}__PL: .PHONY
1126 .if exists(${.CURDIR}/${_lib})
1127         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1128                 cd ${.CURDIR}/${_lib}; \
1129                 ${MAKE} DIRPRFX=${_lib}/ obj; \
1130                 ${MAKE} DIRPRFX=${_lib}/ depend; \
1131                 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1132                 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1133 .endif
1134 .endfor
1135
1136 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1137 ${_lib}__L: .PHONY
1138 .if exists(${.CURDIR}/${_lib})
1139         ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1140                 cd ${.CURDIR}/${_lib}; \
1141                 ${MAKE} DIRPRFX=${_lib}/ obj; \
1142                 ${MAKE} DIRPRFX=${_lib}/ depend; \
1143                 ${MAKE} DIRPRFX=${_lib}/ all; \
1144                 ${MAKE} DIRPRFX=${_lib}/ install
1145 .endif
1146 .endfor
1147
1148 # libpam is special: we need to build static PAM modules before
1149 # static PAM library, and dynamic PAM library before dynamic PAM
1150 # modules.
1151 lib/libpam__L: .PHONY
1152         ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1153                 cd ${.CURDIR}/lib/libpam; \
1154                 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1155                 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1156                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1157                 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1158
1159 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1160 _startup_libs: ${_startup_libs:S/$/__L/}
1161 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1162 _generic_libs: ${_generic_libs:S/$/__L/}
1163
1164 .for __target in all clean cleandepend cleandir depend includes obj
1165 .for entry in ${SUBDIR}
1166 ${entry}.${__target}__D: .PHONY
1167         ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1168                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1169                 edir=${entry}.${MACHINE_ARCH}; \
1170                 cd ${.CURDIR}/$${edir}; \
1171         else \
1172                 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1173                 edir=${entry}; \
1174                 cd ${.CURDIR}/$${edir}; \
1175         fi; \
1176         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1177 .endfor
1178 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1179 .endfor
1180
1181 .include <bsd.subdir.mk>
1182
1183 .if make(check-old) || make(check-old-dirs) || \
1184     make(check-old-files) || make(check-old-libs) || \
1185     make(delete-old) || make(delete-old-dirs) || \
1186     make(delete-old-files) || make(delete-old-libs)
1187
1188 #
1189 # check for / delete old files section
1190 #
1191
1192 .include "ObsoleteFiles.inc"
1193
1194 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1195 else you can not start such an application. Consult UPDATING for more \
1196 information regarding how to cope with the removal/revision bump of a \
1197 specific library."
1198
1199 .if !defined(BATCH_DELETE_OLD_FILES)
1200 RM_I=-i
1201 .else
1202 RM_I=-v
1203 .endif
1204
1205 delete-old-files:
1206         @echo ">>> Removing old files (only deletes safe to delete libs)"
1207 # Ask for every old file if the user really wants to remove it.
1208 # It's annoying, but better safe than sorry.
1209         @for file in ${OLD_FILES}; do \
1210                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1211                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1212                         rm ${RM_I} "${DESTDIR}/$${file}"; \
1213                 fi; \
1214         done
1215 # Remove catpages without corresponding manpages.
1216         @3<&0; \
1217         find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1218         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1219         while read catpage; do \
1220                 read manpage; \
1221                 if [ ! -e "$${manpage}" ]; then \
1222                         rm ${RM_I} $${catpage} <&3 ; \
1223                 fi; \
1224         done
1225         @echo ">>> Old files removed"
1226
1227 check-old-files:
1228         @echo ">>> Checking for old files"
1229         @for file in ${OLD_FILES}; do \
1230                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1231                         echo "${DESTDIR}/$${file}"; \
1232                 fi; \
1233         done
1234 # Check for catpages without corresponding manpages.
1235         @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1236         sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1237         while read catpage; do \
1238                 read manpage; \
1239                 if [ ! -e "$${manpage}" ]; then \
1240                         echo $${catpage} ; \
1241                 fi; \
1242         done
1243
1244 delete-old-libs:
1245         @echo ">>> Removing old libraries"
1246         @echo "${OLD_LIBS_MESSAGE}" | fmt
1247         @for file in ${OLD_LIBS}; do \
1248                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1249                         chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1250                         rm ${RM_I} "${DESTDIR}/$${file}"; \
1251                 fi; \
1252         done
1253         @echo ">>> Old libraries removed"
1254
1255 check-old-libs:
1256         @echo ">>> Checking for old libraries"
1257         @for file in ${OLD_LIBS}; do \
1258                 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1259                         echo "${DESTDIR}/$${file}"; \
1260                 fi; \
1261         done
1262
1263 delete-old-dirs:
1264         @echo ">>> Removing old directories"
1265         @for dir in ${OLD_DIRS}; do \
1266                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1267                         rmdir -v "${DESTDIR}/$${dir}" || true; \
1268                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1269                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1270                 fi; \
1271         done
1272         @echo ">>> Old directories removed"
1273
1274 check-old-dirs:
1275         @echo ">>> Checking for old directories"
1276         @for dir in ${OLD_DIRS}; do \
1277                 if [ -d "${DESTDIR}/$${dir}" ]; then \
1278                         echo "${DESTDIR}/$${dir}"; \
1279                 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1280                         echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1281                 fi; \
1282         done
1283
1284 delete-old: delete-old-files delete-old-dirs
1285         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1286
1287 check-old: check-old-files check-old-libs check-old-dirs
1288         @echo "To remove old files and directories run '${MAKE} delete-old'."
1289         @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1290
1291 .endif
1292
1293 #
1294 # showconfig - show build configuration.
1295 #
1296 showconfig:
1297         @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort