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