4 # Make command line options:
5 # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6 # -DNO_CLEAN do not clean at all
7 # -DDB_FROM_SRC use the user/group databases in src/etc instead of
8 # the system database when installing.
9 # -DNO_SHARE do not go into share subdir
10 # -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,DEPEND,OBJ}
11 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
12 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
13 # -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
14 # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
15 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
16 # -DNO_ROOT install without using root privilege
17 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
18 # -DNO_CTF do not run the DTrace CTF conversion tools on built objects
19 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
20 # LOCAL_MTREE="list of mtree files" to process to allow local directories
21 # to be created before files are installed
22 # METALOG="path to metadata log" to write permission and ownership
23 # when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
24 # TARGET="machine" to crossbuild world for a different machine type
25 # TARGET_ARCH= may be required when a TARGET supports multiple endians
28 # The intended user-driven targets are:
29 # buildworld - rebuild *everything*, including glue to help do upgrades
30 # installworld- install everything built by "buildworld"
31 # doxygen - build API documentation of the kernel
32 # update - convenient way to update your source tree (eg: cvsup/cvs)
34 # Standard targets (not defined here) are documented in the makefiles in
35 # /usr/share/mk. These include:
36 # obj depend all install clean cleandepend cleanobj
38 # You are supposed to define both of these when calling Makefile.inc1
39 # directly. However, some old scripts don't. Cope for the moment, but
40 # issue a new warning for a transition period.
41 .if defined(TARGET) && !defined(TARGET_ARCH)
42 .warning "You must pass both TARGET and TARGET_ARCH to Makefile.inc1. Setting TARGET_ARCH=${TARGET}."
45 .if !defined(TARGET) || !defined(TARGET_ARCH)
46 .error "Both TARGET and TARGET_ARCH must be defined."
50 .include <bsd.arch.inc.mk>
51 .include <bsd.compiler.mk>
53 # We must do share/info early so that installation of info `dir'
54 # entries works correctly. Do it first since it is less likely to
55 # grow dependencies on include and lib than vice versa.
57 # We must do lib/ and libexec/ before bin/, because if installworld
58 # installs a new /bin/sh, the 'make' command will *immediately*
59 # use that new version. And the new (dynamically-linked) /bin/sh
60 # will expect to find appropriate libraries in /lib and /libexec.
62 SUBDIR= share/info lib libexec
64 .if ${MK_GAMES} != "no"
67 .if ${MK_CDDL} != "no"
71 .if ${MK_KERBEROS} != "no"
74 .if ${MK_RESCUE} != "no"
78 .if ${MK_CRYPT} != "no"
81 .if !defined(NO_SHARE)
84 SUBDIR+=sys usr.bin usr.sbin
85 .if ${MK_OFED} != "no"
89 # We must do etc/ last for install/distribute to work.
93 # These are last, since it is nice to at least get the base system
94 # rebuilt before you do them.
95 .for _DIR in ${LOCAL_DIRS}
96 .if exists(${.CURDIR}/${_DIR}/Makefile)
101 .if defined(SUBDIR_OVERRIDE)
102 SUBDIR= ${SUBDIR_OVERRIDE}
108 .if defined(NO_CLEANDIR)
109 CLEANDIR= clean cleandepend
115 CVSFLAGS?= -A -P -d -I!
121 SUPFLAGS+= -h ${SUPHOST}
124 MAKEOBJDIRPREFIX?= /usr/obj
125 .if !defined(OSRELDATE)
126 .if exists(/usr/include/osreldate.h)
127 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
128 /usr/include/osreldate.h
134 .if !defined(VERSION)
136 VERSION+= ${OSRELDATE}
139 KNOWN_ARCHES?= amd64 arm armeb/arm i386 i386/pc98 ia64 mipsel/mips mipseb/mips mips64el/mips mips64eb/mips mipsn32el/mips mipsn32eb/mips powerpc powerpc64/powerpc sparc64
140 .if ${TARGET} == ${TARGET_ARCH}
143 _t= ${TARGET_ARCH}/${TARGET}
146 .if empty(KNOWN_ARCHES:M${_t})
147 .error Unknown target ${TARGET_ARCH}:${TARGET}.
151 .if ${TARGET} == ${MACHINE}
152 TARGET_CPUTYPE?=${CPUTYPE}
157 .if !empty(TARGET_CPUTYPE)
158 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
160 _TARGET_CPUTYPE=dummy
162 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
163 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
164 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
165 .error CPUTYPE global should be set with ?=.
168 BUILD_ARCH!= uname -p
169 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
170 .error To cross-build, set TARGET_ARCH.
173 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
174 OBJTREE= ${MAKEOBJDIRPREFIX}
176 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
178 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
179 # /usr/games added for fortune which depend on strfile
180 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games:${WORLDTMP}/legacy/bin
181 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
182 STRICTTMPPATH= ${BPATH}:${XPATH}
183 TMPPATH= ${STRICTTMPPATH}:${PATH}
186 # Avoid running mktemp(1) unless actually needed.
187 # It may not be functional, e.g., due to new ABI
188 # when in the middle of installing over this system.
190 .if make(distributeworld) || make(installworld)
191 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
195 # Building a world goes through the following stages
197 # 1. legacy stage [BMAKE]
198 # This stage is responsible for creating compatibility
199 # shims that are needed by the bootstrap-tools,
200 # build-tools and cross-tools stages.
201 # 1. bootstrap-tools stage [BMAKE]
202 # This stage is responsible for creating programs that
203 # are needed for backward compatibility reasons. They
204 # are not built as cross-tools.
205 # 2. build-tools stage [TMAKE]
206 # This stage is responsible for creating the object
207 # tree and building any tools that are needed during
209 # 3. cross-tools stage [XMAKE]
210 # This stage is responsible for creating any tools that
211 # are needed for cross-builds. A cross-compiler is one
213 # 4. world stage [WMAKE]
214 # This stage actually builds the world.
215 # 5. install stage (optional) [IMAKE]
216 # This stage installs a previously built world.
221 # Common environment for world related stages
222 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
223 MACHINE_ARCH=${TARGET_ARCH} \
225 CPUTYPE=${TARGET_CPUTYPE}
226 .if ${OSRELDATE} < 700044
227 CROSSENV+= AR=gnu-ar RANLIB=gnu-ranlib
229 .if ${MK_GROFF} != "no"
230 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
231 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
232 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
235 # bootstrap-tools stage
236 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
237 PATH=${BPATH}:${PATH} \
238 WORLDTMP=${WORLDTMP} \
239 VERSION="${VERSION}" \
240 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
241 COMPILER_TYPE=${COMPILER_TYPE}
242 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
243 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
245 BOOTSTRAPPING=${OSRELDATE} \
247 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
248 -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
249 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD
252 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
253 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
254 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
256 BOOTSTRAPPING=${OSRELDATE} \
259 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD
262 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
263 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
267 WMAKEENV= ${CROSSENV} \
268 _SHLIBDIRPREFIX=${WORLDTMP} \
270 VERSION="${VERSION}" \
271 INSTALL="sh ${.CURDIR}/tools/install.sh" \
273 .if ${MK_CDDL} == "no"
276 .if ${CC:T:Mgcc} == "gcc"
277 WMAKE_COMPILER_TYPE= gcc
278 .elif ${CC:T:Mclang} == "clang"
279 WMAKE_COMPILER_TYPE= clang
280 .elif ${MK_CLANG_IS_CC} == "no"
281 WMAKE_COMPILER_TYPE= gcc
283 WMAKE_COMPILER_TYPE= clang
285 WMAKEENV+= COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
286 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
288 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
290 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
292 .if ${TARGET_ARCH} == "amd64"
293 .if empty(TARGET_CPUTYPE)
294 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
296 LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
298 LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
299 MACHINE_CPU="i686 mmx sse sse2"
302 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32"
304 .elif ${TARGET_ARCH} == "powerpc64"
305 .if empty(TARGET_CPUTYPE)
306 LIB32CPUFLAGS= -mcpu=powerpc
308 LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
310 LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
312 LD="${LD} -m elf32ppc"
316 LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
317 -isystem ${LIB32TMP}/usr/include/ \
318 -L${LIB32TMP}/usr/lib32 \
319 -B${LIB32TMP}/usr/lib32
321 # Yes, the flags are redundant.
322 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
323 _SHLIBDIRPREFIX=${LIB32TMP} \
324 _LDSCRIPTROOT=${LIB32TMP} \
325 VERSION="${VERSION}" \
326 INSTALL="sh ${.CURDIR}/tools/install.sh" \
329 SHLIBDIR=/usr/lib32 \
330 COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
332 CC="${CC} ${LIB32FLAGS}" \
333 CXX="${CXX} ${LIB32FLAGS}" \
334 DESTDIR=${LIB32TMP} \
341 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
342 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_INFO -DWITHOUT_HTML
343 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} -DNO_INCS \
347 IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*}
348 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
349 ${IMAKE_INSTALL} ${IMAKE_MTREE}
350 .if empty(.MAKEFLAGS:M-n)
351 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
352 LD_LIBRARY_PATH=${INSTALLTMP} \
353 PATH_LOCALE=${INSTALLTMP}/locale
354 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
356 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
358 .if defined(DB_FROM_SRC)
359 INSTALLFLAGS+= -N ${.CURDIR}/etc
360 MTREEFLAGS+= -N ${.CURDIR}/etc
363 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
364 IMAKE+= -DNO_ROOT METALOG=${METALOG}
365 INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
366 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR:S://:/:g:C:/$::}
369 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
370 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
371 IMAKE_MTREE= MTREE_CMD="nmtree ${MTREEFLAGS}"
375 KMAKEENV= ${WMAKEENV}
376 KMAKE= ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
381 # Attempt to rebuild the entire system, with reasonable chance of
382 # success, regardless of how old your existing system is.
385 .if ${.CURDIR:C/[^,]//g} != ""
386 # The m4 build of sendmail files doesn't like it if ',' is used
387 # anywhere in the path of it's files.
389 @echo "*** Error: path to source tree contains a comma ','"
394 @echo "--------------------------------------------------------------"
395 @echo ">>> Rebuilding the temporary build tree"
396 @echo "--------------------------------------------------------------"
397 .if !defined(NO_CLEAN)
399 .if defined(LIB32TMP)
403 rm -rf ${WORLDTMP}/legacy/usr/include
404 # XXX - These three can depend on any header file.
405 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
406 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
407 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
410 lib usr legacy/bin legacy/usr
411 mkdir -p ${WORLDTMP}/${_dir}
413 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
414 -p ${WORLDTMP}/legacy/usr >/dev/null
415 .if ${MK_GROFF} != "no"
416 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
417 -p ${WORLDTMP}/legacy/usr >/dev/null
419 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
420 -p ${WORLDTMP}/usr >/dev/null
421 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
422 -p ${WORLDTMP}/usr/include >/dev/null
423 ln -sf ${.CURDIR}/sys ${WORLDTMP}
424 .if ${MK_BIND_LIBS} != "no"
425 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
426 -p ${WORLDTMP}/usr/include >/dev/null
428 .for _mtree in ${LOCAL_MTREE}
429 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
433 @echo "--------------------------------------------------------------"
434 @echo ">>> stage 1.1: legacy release compatibility shims"
435 @echo "--------------------------------------------------------------"
436 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
439 @echo "--------------------------------------------------------------"
440 @echo ">>> stage 1.2: bootstrap tools"
441 @echo "--------------------------------------------------------------"
442 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
444 .if !defined(NO_CLEAN)
446 @echo "--------------------------------------------------------------"
447 @echo ">>> stage 2.1: cleaning up the object tree"
448 @echo "--------------------------------------------------------------"
449 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
450 .if defined(LIB32TMP)
451 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
456 @echo "--------------------------------------------------------------"
457 @echo ">>> stage 2.2: rebuilding the object tree"
458 @echo "--------------------------------------------------------------"
459 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
462 @echo "--------------------------------------------------------------"
463 @echo ">>> stage 2.3: build tools"
464 @echo "--------------------------------------------------------------"
465 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
468 @echo "--------------------------------------------------------------"
469 @echo ">>> stage 3: cross tools"
470 @echo "--------------------------------------------------------------"
471 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
474 @echo "--------------------------------------------------------------"
475 @echo ">>> stage 4.1: building includes"
476 @echo "--------------------------------------------------------------"
477 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
480 @echo "--------------------------------------------------------------"
481 @echo ">>> stage 4.2: building libraries"
482 @echo "--------------------------------------------------------------"
483 ${_+_}cd ${.CURDIR}; \
484 ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
485 -DWITHOUT_MAN -DWITHOUT_PROFILE libraries
488 @echo "--------------------------------------------------------------"
489 @echo ">>> stage 4.3: make dependencies"
490 @echo "--------------------------------------------------------------"
491 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
494 @echo "--------------------------------------------------------------"
495 @echo ">>> stage 4.4: building everything"
496 @echo "--------------------------------------------------------------"
497 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
498 .if defined(LIB32TMP)
501 @echo "--------------------------------------------------------------"
502 @echo ">>> stage 5.1: building 32 bit shim libraries"
503 @echo "--------------------------------------------------------------"
504 mkdir -p ${LIB32TMP}/usr/include
505 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
506 -p ${LIB32TMP}/usr >/dev/null
507 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
508 -p ${LIB32TMP}/usr/include >/dev/null
510 ln -sf ${.CURDIR}/sys ${WORLDTMP}
511 .if ${MK_KERBEROS} != "no"
512 .for _t in obj depend all
513 cd ${.CURDIR}/kerberos5/tools; \
514 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
515 DIRPRFX=kerberos5/tools/ ${_t}
518 .for _t in obj includes
519 cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
520 cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
521 .if ${MK_CDDL} != "no"
522 cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
524 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
525 .if ${MK_CRYPT} != "no"
526 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
528 .if ${MK_KERBEROS} != "no"
529 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
532 .for _dir in usr.bin/lex/lib
533 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
535 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
536 cd ${.CURDIR}/${_dir}; \
537 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
538 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF \
539 -DEARLY_BUILD build-tools
542 ${LIB32WMAKE} -f Makefile.inc1 libraries
543 .for _t in obj depend all
544 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
545 DIRPRFX=libexec/rtld-elf/ ${_t}
546 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
547 DIRPRFX=usr.bin/ldd ${_t}
550 distribute32 install32:
551 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
552 .if ${MK_CDDL} != "no"
553 cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
555 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
556 .if ${MK_CRYPT} != "no"
557 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
559 .if ${MK_KERBEROS} != "no"
560 cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
562 cd ${.CURDIR}/libexec/rtld-elf; \
563 PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
564 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
568 .if !defined(SUBDIR_OVERRIDE)
569 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
571 WMAKE_TGTS+= _cleanobj _obj _build-tools
572 .if !defined(SUBDIR_OVERRIDE)
573 WMAKE_TGTS+= _cross-tools
575 WMAKE_TGTS+= _includes _libraries _depend everything
576 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
580 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
581 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
584 @echo "--------------------------------------------------------------"
585 @echo ">>> World build started on `LC_ALL=C date`"
586 @echo "--------------------------------------------------------------"
590 @echo "--------------------------------------------------------------"
591 @echo ">>> World build completed on `LC_ALL=C date`"
592 @echo "--------------------------------------------------------------"
595 # We need to have this as a target because the indirection between Makefile
596 # and Makefile.inc1 causes the correct PATH to be used, rather than a
597 # modification of the current environment's PATH. In addition, we need
598 # to quote multiword values.
604 @echo Entering world for ${TARGET_ARCH}:${TARGET}
605 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
607 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
608 toolchain: ${TOOLCHAIN_TGTS}
609 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
614 # Checks to be sure system is ready for installworld/installkernel.
620 # Require DESTDIR to be set if installing for a different architecture or
621 # using the user/group database in the source tree.
623 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
625 .if !make(distributeworld)
626 installcheck: installcheck_DESTDIR
627 installcheck_DESTDIR:
628 .if !defined(DESTDIR) || empty(DESTDIR)
629 @echo "ERROR: Please set DESTDIR!"; \
635 .if !defined(DB_FROM_SRC)
637 # Check for missing UIDs/GIDs.
639 CHECK_UIDS= auditdistd
641 .if ${MK_SENDMAIL} != "no"
647 CHECK_GIDS+= proxy authpf
650 .for uid in ${CHECK_UIDS}
651 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
652 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
656 .for gid in ${CHECK_GIDS}
657 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
658 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
665 # Required install tools to be saved in a scratch dir for safety.
667 .if ${MK_INFO} != "no"
668 _install-info= install-info
670 .if ${MK_ZONEINFO} != "no"
671 _zoneinfo= zic tzsetup
674 .if exists(/usr/sbin/nmtree)
675 _nmtree_itools= nmtree
678 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
679 date echo egrep find grep id install ${_install-info} \
680 ln lockf make mkdir mtree ${_nmtree_itools} mv pwd_mkdb \
681 rm sed sh sysctl test true uname wc ${_zoneinfo}
686 # Distributes everything compiled by a `buildworld'.
690 # Installs everything compiled by a 'buildworld'.
693 # Non-base distributions produced by the base system
694 EXTRA_DISTRIBUTIONS= doc
695 .if ${MK_GAMES} != "no"
696 EXTRA_DISTRIBUTIONS+= games
698 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
699 EXTRA_DISTRIBUTIONS+= lib32
702 MTREE_MAGIC?= mtree 2.0
704 distributeworld installworld: installcheck installcheck_UGID
705 mkdir -p ${INSTALLTMP}
706 progs=$$(for prog in ${ITOOLS}; do \
707 if progpath=`which $$prog`; then \
710 echo "Required tool $$prog not found in PATH." >&2; \
714 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
715 while read line; do \
717 if [ "$$2 $$3" != "not found" ]; then \
720 echo "Required library $$1 not found." >&2; \
724 cp $$libs $$progs ${INSTALLTMP}
725 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
727 echo "#${MTREE_MAGIC}" > ${METALOG}
729 .if make(distributeworld)
730 .for dist in ${EXTRA_DISTRIBUTIONS}
731 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
732 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
733 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
734 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
735 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
736 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
737 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
739 ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
740 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
741 ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
742 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
743 ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
744 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
747 -mkdir ${DESTDIR}/${DISTDIR}/base
748 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
749 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
750 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
751 LOCAL_MTREE=${LOCAL_MTREE} distrib-dirs
753 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
754 ${IMAKEENV} rm -rf ${INSTALLTMP}
755 .if make(distributeworld)
756 .for dist in ${EXTRA_DISTRIBUTIONS}
757 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
760 .for dist in base ${EXTRA_DISTRIBUTIONS}
761 @# For each file that exists in this dist, print the corresponding
762 @# line from the METALOG. This relies on the fact that
763 @# a line containing only the filename will sort immediatly before
764 @# the relevant mtree line.
765 cd ${DESTDIR}/${DISTDIR}; \
766 find ./${dist} | sort -u ${METALOG} - | \
767 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
768 ${DESTDIR}/${DISTDIR}/${dist}.meta
774 .for dist in base ${EXTRA_DISTRIBUTIONS}
776 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
777 tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
778 @${DESTDIR}/${DISTDIR}/${dist}.meta
780 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
781 tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz .
788 # If you have a build server, you can NFS mount the source and obj directories
789 # and do a 'make reinstall' on the *client* to install new binaries from the
790 # most recent server build.
793 @echo "--------------------------------------------------------------"
794 @echo ">>> Making hierarchy"
795 @echo "--------------------------------------------------------------"
796 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
797 LOCAL_MTREE=${LOCAL_MTREE} hierarchy
799 @echo "--------------------------------------------------------------"
800 @echo ">>> Installing everything"
801 @echo "--------------------------------------------------------------"
802 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
803 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
804 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
808 @echo "--------------------------------------------------------------"
809 @echo ">>> Distributing everything"
810 @echo "--------------------------------------------------------------"
811 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
812 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
813 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
817 distrib-dirs distribution:
818 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
819 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
822 # buildkernel and installkernel
824 # Which kernels to build and/or install is specified by setting
825 # KERNCONF. If not defined a GENERIC kernel is built/installed.
826 # Only the existing (depending TARGET) config files are used
827 # for building kernels and only the first of these is designated
828 # as the one being installed.
830 # Note that we have to use TARGET instead of TARGET_ARCH when
831 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
832 # be set to cross-build, we have to make sure TARGET is set
835 .if defined(KERNFAST)
840 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
841 .if !defined(KERNCONF) && ${KERNFAST} != "1"
845 .if !defined(KERNCONF) && defined(KERNEL)
849 .if ${TARGET_ARCH} == "powerpc64"
855 INSTKERNNAME?= kernel
857 KERNSRCDIR?= ${.CURDIR}/sys
858 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
859 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
860 KERNCONFDIR?= ${KRNLCONFDIR}
864 .for _kernel in ${KERNCONF}
865 .if exists(${KERNCONFDIR}/${_kernel})
866 BUILDKERNELS+= ${_kernel}
867 .if empty(INSTALLKERNEL)
868 INSTALLKERNEL= ${_kernel}
876 # Builds all kernels defined by BUILDKERNELS.
879 .if empty(BUILDKERNELS)
880 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
883 .if defined(KERNWARN)
884 @echo "--------------------------------------------------------------"
885 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
886 @echo "--------------------------------------------------------------"
890 .for _kernel in ${BUILDKERNELS}
891 @echo "--------------------------------------------------------------"
892 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
893 @echo "--------------------------------------------------------------"
894 @echo "===> ${_kernel}"
895 mkdir -p ${KRNLOBJDIR}
896 .if !defined(NO_KERNELCONFIG)
898 @echo "--------------------------------------------------------------"
899 @echo ">>> stage 1: configuring the kernel"
900 @echo "--------------------------------------------------------------"
903 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
904 ${KERNCONFDIR}/${_kernel}
906 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
908 @echo "--------------------------------------------------------------"
909 @echo ">>> stage 2.1: cleaning up the object tree"
910 @echo "--------------------------------------------------------------"
911 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
913 .if !defined(NO_KERNELOBJ)
915 @echo "--------------------------------------------------------------"
916 @echo ">>> stage 2.2: rebuilding the object tree"
917 @echo "--------------------------------------------------------------"
918 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
921 @echo "--------------------------------------------------------------"
922 @echo ">>> stage 2.3: build tools"
923 @echo "--------------------------------------------------------------"
924 cd ${KRNLOBJDIR}/${_kernel}; \
925 PATH=${BPATH}:${PATH} \
926 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
927 ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD \
928 -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
929 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
930 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
931 .for target in obj depend all
932 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
933 PATH=${BPATH}:${PATH} \
934 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
935 ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD ${target}
938 .if !defined(NO_KERNELDEPEND)
940 @echo "--------------------------------------------------------------"
941 @echo ">>> stage 3.1: making dependencies"
942 @echo "--------------------------------------------------------------"
943 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
946 @echo "--------------------------------------------------------------"
947 @echo ">>> stage 3.2: building everything"
948 @echo "--------------------------------------------------------------"
949 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
950 @echo "--------------------------------------------------------------"
951 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
952 @echo "--------------------------------------------------------------"
956 # installkernel, etc.
958 # Install the kernel defined by INSTALLKERNEL
960 installkernel installkernel.debug \
961 reinstallkernel reinstallkernel.debug: installcheck
962 .if empty(INSTALLKERNEL)
963 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
966 @echo "--------------------------------------------------------------"
967 @echo ">>> Installing kernel ${INSTALLKERNEL}"
968 @echo "--------------------------------------------------------------"
969 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
970 ${CROSSENV} PATH=${TMPPATH} \
971 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
973 distributekernel distributekernel.debug:
974 .if empty(INSTALLKERNEL)
975 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
978 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
979 ${CROSSENV} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
980 DESTDIR=${DESTDIR}/${DISTDIR}/kernel \
981 ${.TARGET:S/distributekernel/install/}
982 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
983 cd ${KRNLOBJDIR}/${_kernel}; \
984 ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
985 KERNEL=${INSTKERNNAME}.${_kernel} \
986 DESTDIR=${DESTDIR}/${DISTDIR}/kernel.${_kernel} \
987 ${.TARGET:S/distributekernel/install/}
991 cd ${DESTDIR}/${DISTDIR}/kernel; \
992 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz .
993 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
994 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
995 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz .
1001 # Build the API documentation with doxygen
1004 @if [ ! -x `/usr/bin/which doxygen` ]; then \
1005 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1008 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
1013 # Update the source tree(s), by running cvsup/cvs/svn to update to the
1017 .if defined(SUP_UPDATE)
1018 @echo "--------------------------------------------------------------"
1019 @echo ">>> Running ${SUP}"
1020 @echo "--------------------------------------------------------------"
1021 @echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!"
1022 @echo "!! Update methods with ${SUP} are deprecated."
1023 @echo "!! Please see http://www.freebsd.org/handbook/svn.html"
1024 @echo "!! and convert your update method to SVN_UPDATE or"
1025 @echo "!! freebsd-update(8)."
1026 @echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!"
1028 .if defined(SUPFILE)
1029 @${SUP} ${SUPFLAGS} ${SUPFILE}
1031 .if defined(SUPFILE1)
1032 @${SUP} ${SUPFLAGS} ${SUPFILE1}
1034 .if defined(SUPFILE2)
1035 @${SUP} ${SUPFLAGS} ${SUPFILE2}
1037 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
1038 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
1040 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
1041 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
1044 .if defined(CVS_UPDATE)
1046 if [ -d CVS ] ; then \
1047 echo "--------------------------------------------------------------" ; \
1048 echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT} ; \
1049 echo "--------------------------------------------------------------" ; \
1050 echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!" ; \
1051 echo "!! Update methods with CVS are deprecated." ; \
1052 echo "!! Please see http://www.freebsd.org/handbook/svn.html" ; \
1053 echo "!! and convert your update method to SVN_UPDATE or" ; \
1054 echo "!! freebsd-update(8)." ; \
1055 echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!" ; \
1057 echo ${CVS} -R -q update ${CVSFLAGS} ; \
1058 ${CVS} -R -q update ${CVSFLAGS} ; \
1061 .if defined(SVN_UPDATE)
1063 if [ -d .svn ] ; then \
1064 echo "--------------------------------------------------------------" ; \
1065 echo ">>> Updating ${.CURDIR} using Subversion" ; \
1066 echo "--------------------------------------------------------------" ; \
1067 echo ${SVN} update ${SVNFLAGS} ; \
1068 ${SVN} update ${SVNFLAGS} ; \
1073 # ------------------------------------------------------------------------
1075 # From here onwards are utility targets used by the 'make world' and
1076 # related targets. If your 'world' breaks, you may like to try to fix
1077 # the problem and manually run the following targets to attempt to
1078 # complete the build. Beware, this is *not* guaranteed to work, you
1079 # need to have a pretty good grip on the current state of the system
1080 # to attempt to manually finish it. If in doubt, 'make world' again.
1084 # legacy: Build compatibility shims for the next three targets
1087 .if ${BOOTSTRAPPING} < 600034 && ${BOOTSTRAPPING} != 0
1088 @echo "ERROR: Source upgrades from versions prior to 6.0 not supported."; \
1091 .for _tool in tools/build
1092 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1093 cd ${.CURDIR}/${_tool}; \
1094 ${MAKE} DIRPRFX=${_tool}/ obj; \
1095 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1096 ${MAKE} DIRPRFX=${_tool}/ depend; \
1097 ${MAKE} DIRPRFX=${_tool}/ all; \
1098 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1102 # bootstrap-tools: Build tools needed for compatibility
1104 .if ${MK_GAMES} != "no"
1105 _strfile= games/fortune/strfile
1108 .if ${MK_CXX} != "no"
1109 _gperf= gnu/usr.bin/gperf
1112 .if ${MK_GROFF} != "no"
1113 _groff= gnu/usr.bin/groff
1116 .if ${BOOTSTRAPPING} >= 700044 && ${BOOTSTRAPPING} < 800022
1120 .if ${BOOTSTRAPPING} < 800013
1121 _mklocale= usr.bin/mklocale
1124 .if ${BOOTSTRAPPING} < 900002
1128 .if ${BOOTSTRAPPING} < 900006
1132 .if ${BOOTSTRAPPING} < 900006 || ${BOOTSTRAPPING} >= 1000013
1137 .if ${BOOTSTRAPPING} < 1000026
1138 _nmtree= lib/libnetbsd \
1142 .if ${BOOTSTRAPPING} < 1000027
1146 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1150 .if ${MK_BSNMP} != "no" && \
1151 (${BOOTSTRAPPING} < 700018 || !exists(/usr/sbin/gensnmptree))
1152 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1155 .if ${MK_RESCUE} != "no" && \
1156 ${BOOTSTRAPPING} < 700026
1157 _crunchgen= usr.sbin/crunch/crunchgen
1160 .if ${MK_CLANG} != "no"
1162 lib/clang/libllvmsupport \
1163 lib/clang/libllvmtablegen \
1164 usr.bin/clang/tblgen \
1165 usr.bin/clang/clang-tblgen
1168 .if ${MK_CDDL} != "no" && \
1169 ((${BOOTSTRAPPING} < 1000034 && \
1170 !(${BOOTSTRAPPING} >= 901505 && ${BOOTSTRAPPING} < 999999)) \
1171 || (${MACHINE} != ${TARGET} || ${MACHINE_ARCH} != ${TARGET_ARCH}))
1172 _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
1173 lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
1176 .if ${MK_FDT} != "no"
1177 _dtc= gnu/usr.bin/dtc
1180 # Please document (add comment) why something is in 'bootstrap-tools'.
1181 # Try to bound the building of the bootstrap-tool to just the
1182 # FreeBSD versions that need the tool built at this stage of the build.
1195 usr.bin/makewhatis \
1207 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1208 cd ${.CURDIR}/${_tool}; \
1209 ${MAKE} DIRPRFX=${_tool}/ obj; \
1210 ${MAKE} DIRPRFX=${_tool}/ depend; \
1211 ${MAKE} DIRPRFX=${_tool}/ all; \
1212 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1216 # build-tools: Build special purpose build tools
1218 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
1219 _aicasm= sys/modules/aic7xxx/aicasm
1222 .if !defined(NO_SHARE)
1223 _share= share/syscons/scrnmaps
1226 .if ${MK_GCC} != "no" && (${MK_CLANG_IS_CC} == "no" || ${TARGET} == "pc98")
1227 _gcc_tools= gnu/usr.bin/cc/cc_tools
1230 .if ${MK_KERBEROS} != "no"
1231 _kerberos5_tools= kerberos5/tools
1234 .if ${MK_RESCUE} != "no"
1235 _rescue= rescue/rescue
1243 lib/ncurses/ncurses \
1244 lib/ncurses/ncursesw \
1249 usr.sbin/sysinstall \
1250 usr.bin/mkesdb_static \
1251 usr.bin/mkcsmapper_static
1252 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1253 cd ${.CURDIR}/${_tool}; \
1254 ${MAKE} DIRPRFX=${_tool}/ obj; \
1255 ${MAKE} DIRPRFX=${_tool}/ build-tools
1260 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1261 cd ${.CURDIR}/${_tool}; \
1262 ${MAKE} DIRPRFX=${_tool}/ obj; \
1263 ${MAKE} DIRPRFX=${_tool}/ depend; \
1264 ${MAKE} DIRPRFX=${_tool}/ all
1268 # cross-tools: Build cross-building tools
1270 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035
1271 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1272 _btxld= usr.sbin/btxld
1275 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1276 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1277 _crunchide= usr.sbin/crunch/crunchide
1279 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1280 _kgzip= usr.sbin/kgzip
1284 .if ${MK_BINUTILS} != "no"
1285 _binutils= gnu/usr.bin/binutils
1288 .if ${MK_CLANG} != "no" && (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang")
1289 _clang= usr.bin/clang
1290 _clang_libs= lib/clang
1293 .if ${MK_GCC} != "no" && (${MK_CLANG_IS_CC} == "no" || ${TARGET} == "pc98")
1303 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1307 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1308 cd ${.CURDIR}/${_tool}; \
1309 ${MAKE} DIRPRFX=${_tool}/ obj; \
1310 ${MAKE} DIRPRFX=${_tool}/ depend; \
1311 ${MAKE} DIRPRFX=${_tool}/ all; \
1312 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1316 # hierarchy - ensure that all the needed directories are present
1319 .if defined(NO_ROOT)
1320 cd ${.CURDIR}/etc; ${MAKE} LOCAL_MTREE=${LOCAL_MTREE} \
1321 -DNO_ROOT METALOG=${METALOG} distrib-dirs
1323 cd ${.CURDIR}/etc; ${MAKE} LOCAL_MTREE=${LOCAL_MTREE} distrib-dirs
1327 # libraries - build all libraries, and install them under ${DESTDIR}.
1329 # The list of libraries with dependents (${_prebuild_libs}) and their
1330 # interdependencies (__L) are built automatically by the
1331 # ${.CURDIR}/tools/make_libdeps.sh script.
1335 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1336 ${MAKE} -f Makefile.inc1 _startup_libs; \
1337 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1338 ${MAKE} -f Makefile.inc1 _generic_libs;
1341 # static libgcc.a prerequisite for shared libc
1343 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1345 # These dependencies are not automatically generated:
1347 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1348 # all shared libraries for ELF.
1350 _startup_libs= gnu/lib/csu
1351 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1352 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1353 .elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
1354 _startup_libs+= lib/csu/${MACHINE_ARCH}
1356 _startup_libs+= lib/csu/${MACHINE_CPUARCH}
1358 _startup_libs+= gnu/lib/libgcc
1359 _startup_libs+= lib/libcompiler_rt
1360 _startup_libs+= lib/libc
1361 .if ${MK_LIBCPLUSPLUS} != "no"
1362 _startup_libs+= lib/libcxxrt
1365 gnu/lib/libgcc__L: lib/libc__L
1366 .if ${MK_LIBCPLUSPLUS} != "no"
1367 lib/libcxxrt__L: gnu/lib/libgcc__L
1370 _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libhdb} \
1371 ${_kerberos5_lib_libheimntlm} \
1372 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1373 ${_kerberos5_lib_libroken} \
1374 lib/libbz2 lib/libcom_err lib/libcrypt \
1375 lib/libelf lib/libexpat \
1376 ${_lib_libgssapi} ${_lib_libipx} \
1377 lib/libkiconv lib/libkvm lib/liblzma lib/libmd \
1378 lib/ncurses/ncurses lib/ncurses/ncursesw \
1379 lib/libopie lib/libpam ${_lib_libthr} \
1380 lib/libradius lib/libsbuf lib/libtacplus \
1381 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1382 ${_cddl_lib_libzfs_core} \
1383 lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
1384 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1385 ${_secure_lib_libssl}
1387 .if ${MK_LIBTHR} != "no"
1388 _lib_libthr= lib/libthr
1391 .if ${MK_OFED} != "no"
1392 _ofed_lib= contrib/ofed/usr.lib/
1395 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1397 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1399 .if ${MK_CDDL} != "no"
1400 _cddl_lib_libumem= cddl/lib/libumem
1401 _cddl_lib_libnvpair= cddl/lib/libnvpair
1402 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1404 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1407 .if ${MK_CRYPT} != "no"
1408 .if ${MK_OPENSSL} != "no"
1409 _secure_lib_libcrypto= secure/lib/libcrypto
1410 _secure_lib_libssl= secure/lib/libssl
1411 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1412 .if ${MK_OPENSSH} != "no"
1413 _secure_lib_libssh= secure/lib/libssh
1414 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1415 .if ${MK_KERBEROS_SUPPORT} != "no"
1416 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1417 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1418 lib/libmd__L kerberos5/lib/libroken__L
1422 _secure_lib= secure/lib
1425 .if ${MK_KERBEROS} != "no"
1426 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1427 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1428 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L
1429 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L
1430 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1431 secure/lib/libcrypto__L kerberos5/lib/libroken__L
1432 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1433 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1434 kerberos5/lib/libroken__L
1435 kerberos5/lib/libroken__L: lib/libcrypt__L
1438 .if ${MK_GSSAPI} != "no"
1439 _lib_libgssapi= lib/libgssapi
1442 .if ${MK_IPX} != "no"
1443 _lib_libipx= lib/libipx
1446 .if ${MK_KERBEROS} != "no"
1447 _kerberos5_lib= kerberos5/lib
1448 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1449 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
1450 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1451 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1452 _kerberos5_lib_libroken= kerberos5/lib/libroken
1453 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1456 .if ${MK_NIS} != "no"
1457 _lib_libypclnt= lib/libypclnt
1460 .if ${MK_OPENSSL} == "no"
1461 lib/libradius__L: lib/libmd__L
1464 .for _lib in ${_prereq_libs}
1466 .if exists(${.CURDIR}/${_lib})
1467 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1468 cd ${.CURDIR}/${_lib}; \
1469 ${MAKE} DIRPRFX=${_lib}/ obj; \
1470 ${MAKE} DIRPRFX=${_lib}/ depend; \
1471 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1472 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1476 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1478 .if exists(${.CURDIR}/${_lib})
1479 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1480 cd ${.CURDIR}/${_lib}; \
1481 ${MAKE} DIRPRFX=${_lib}/ obj; \
1482 ${MAKE} DIRPRFX=${_lib}/ depend; \
1483 ${MAKE} DIRPRFX=${_lib}/ all; \
1484 ${MAKE} DIRPRFX=${_lib}/ install
1488 # libpam is special: we need to build static PAM modules before
1489 # static PAM library, and dynamic PAM library before dynamic PAM
1491 lib/libpam__L: .PHONY
1492 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1493 cd ${.CURDIR}/lib/libpam; \
1494 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1495 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1496 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1497 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1499 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1500 _startup_libs: ${_startup_libs:S/$/__L/}
1501 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1502 _generic_libs: ${_generic_libs:S/$/__L/}
1504 .for __target in all clean cleandepend cleandir depend includes obj
1505 .for entry in ${SUBDIR}
1506 ${entry}.${__target}__D: .PHONY
1507 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1508 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1509 edir=${entry}.${MACHINE_ARCH}; \
1510 cd ${.CURDIR}/$${edir}; \
1512 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1514 cd ${.CURDIR}/$${edir}; \
1516 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1518 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1521 .include <bsd.subdir.mk>
1523 .if make(check-old) || make(check-old-dirs) || \
1524 make(check-old-files) || make(check-old-libs) || \
1525 make(delete-old) || make(delete-old-dirs) || \
1526 make(delete-old-files) || make(delete-old-libs)
1529 # check for / delete old files section
1532 .include "ObsoleteFiles.inc"
1534 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1535 else you can not start such an application. Consult UPDATING for more \
1536 information regarding how to cope with the removal/revision bump of a \
1539 .if !defined(BATCH_DELETE_OLD_FILES)
1546 @echo ">>> Removing old files (only deletes safe to delete libs)"
1547 # Ask for every old file if the user really wants to remove it.
1548 # It's annoying, but better safe than sorry.
1549 # NB: We cannot pass the list of OLD_FILES as a parameter because the
1550 # argument list will get too long. Using .for/.endfor make "loops" will make
1551 # the Makefile parser segfault.
1553 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1554 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1555 while read file; do \
1556 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1557 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1558 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1561 # Remove catpages without corresponding manpages.
1563 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1564 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1565 while read catpage; do \
1567 if [ ! -e "$${manpage}" ]; then \
1568 rm ${RM_I} $${catpage} <&3; \
1571 @echo ">>> Old files removed"
1574 @echo ">>> Checking for old files"
1575 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1576 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1577 while read file; do \
1578 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1579 echo "${DESTDIR}/$${file}"; \
1582 # Check for catpages without corresponding manpages.
1583 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1584 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1585 while read catpage; do \
1587 if [ ! -e "$${manpage}" ]; then \
1593 @echo ">>> Removing old libraries"
1594 @echo "${OLD_LIBS_MESSAGE}" | fmt
1596 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1597 -V OLD_LIBS | xargs -n1 | \
1598 while read file; do \
1599 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1600 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1601 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1604 @echo ">>> Old libraries removed"
1607 @echo ">>> Checking for old libraries"
1608 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1609 -V OLD_LIBS | xargs -n1 | \
1610 while read file; do \
1611 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1612 echo "${DESTDIR}/$${file}"; \
1617 @echo ">>> Removing old directories"
1618 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1619 -V OLD_DIRS | xargs -n1 | \
1620 while read dir; do \
1621 if [ -d "${DESTDIR}/$${dir}" ]; then \
1622 rmdir -v "${DESTDIR}/$${dir}" || true; \
1623 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1624 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1627 @echo ">>> Old directories removed"
1630 @echo ">>> Checking for old directories"
1631 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1632 -V OLD_DIRS | xargs -n1 | \
1633 while read dir; do \
1634 if [ -d "${DESTDIR}/$${dir}" ]; then \
1635 echo "${DESTDIR}/$${dir}"; \
1636 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1637 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1641 delete-old: delete-old-files delete-old-dirs
1642 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1644 check-old: check-old-files check-old-libs check-old-dirs
1645 @echo "To remove old files and directories run '${MAKE} delete-old'."
1646 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1651 # showconfig - show build configuration.
1654 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort
1656 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
1657 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
1659 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
1660 .if exists(${KERNCONFDIR}/${KERNCONF})
1661 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
1662 ${KERNCONFDIR}/${KERNCONF} ; echo
1668 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
1669 DTBOUTPUTPATH= ${.CURDIR}
1673 # Build 'standalone' Device Tree Blob
1676 @if [ "${FDT_DTS_FILE}" = "" ]; then \
1677 echo "ERROR: FDT_DTS_FILE must be specified!"; \
1680 if [ ! -f ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE} ]; then \
1681 echo "ERROR: Specified DTS file (${FDT_DTS_FILE}) does not \
1685 if [ "${DTBOUTPUTPATH}" = "${.CURDIR}" ]; then \
1686 echo "WARNING: DTB will be placed in the current working \
1691 ${DTBOUTPUTPATH}/`echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb -b 0 \
1692 -p 1024 ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE}
1696 .if defined(XDEV) && defined(XDEV_ARCH)
1698 .if ${XDEV} == ${MACHINE} && ${XDEV_ARCH} == ${MACHINE_ARCH}
1699 XDEV_CPUTYPE?=${CPUTYPE}
1701 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
1704 NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
1705 -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE \
1706 -DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_WARNS \
1707 TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH} \
1708 CPUTYPE=${XDEV_CPUTYPE}
1710 XDDIR=${XDEV_ARCH}-freebsd
1712 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
1713 INSTALL="sh ${.CURDIR}/tools/install.sh"
1715 _SHLIBDIRPREFIX=${XDTP} \
1716 TOOLS_PREFIX=${XDTP}
1718 MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH}
1720 CDTMP= ${MAKEOBJDIRPREFIX}/${XDEV}/${.CURDIR}/tmp
1721 CDMAKE=${CDENV} ${MAKE} ${NOFUN}
1722 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDTP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1723 XDDESTDIR=${DESTDIR}${XDTP}
1725 OSREL!= uname -r | sed -e 's/[-(].*//'
1728 .ORDER: xdev-build xdev-install
1729 xdev: xdev-build xdev-install
1731 .ORDER: _xb-build-tools _xb-cross-tools
1732 xdev-build: _xb-build-tools _xb-cross-tools
1735 ${_+_}@cd ${.CURDIR}; \
1736 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1740 gnu/usr.bin/binutils \
1743 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1744 cd ${.CURDIR}/${_tool}; \
1745 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
1746 ${CDMAKE} DIRPRFX=${_tool}/ depend; \
1747 ${CDMAKE} DIRPRFX=${_tool}/ all
1751 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1752 mkdir -p ${XDDESTDIR}
1753 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1754 -p ${XDDESTDIR} >/dev/null
1755 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1756 -p ${XDDESTDIR}/usr >/dev/null
1757 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1758 -p ${XDDESTDIR}/usr/include >/dev/null
1760 .ORDER: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1761 xdev-install: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1764 @echo "_xi-cross-tools"
1766 gnu/usr.bin/binutils \
1769 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
1770 cd ${.CURDIR}/${_tool}; \
1771 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
1775 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
1776 DESTDIR=${XDDESTDIR}
1779 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
1780 DESTDIR=${XDDESTDIR}
1783 ${_+_}cd ${XDDESTDIR}/usr/bin; \
1785 ln -sf ../../${XDTP}/usr/bin/$$i \
1786 ../../../../usr/bin/${XDDIR}-$$i; \
1787 ln -sf ../../${XDTP}/usr/bin/$$i \
1788 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \