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