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