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