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 # -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,DEPEND,OBJ}
9 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
10 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
11 # -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
12 # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
13 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
14 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
15 # -DDB_FROM_SRC use the user/group databases in src/etc instead of
16 # the system database when installing.
17 # -DNO_CTF do not run the DTrace CTF conversion tools on built objects
18 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
19 # LOCAL_MTREE="list of mtree files" to process to allow local directories
20 # to be created before files are installed
21 # TARGET="machine" to crossbuild world for a different machine type
22 # TARGET_ARCH= may be required when a TARGET supports multiple endians
25 # The intended user-driven targets are:
26 # buildworld - rebuild *everything*, including glue to help do upgrades
27 # installworld- install everything built by "buildworld"
28 # doxygen - build API documentation of the kernel
29 # update - convenient way to update your source tree (eg: cvsup/cvs)
31 # Standard targets (not defined here) are documented in the makefiles in
32 # /usr/share/mk. These include:
33 # obj depend all install clean cleandepend cleanobj
35 # You are supposed to define both of these when calling Makefile.inc1
36 # directly. However, some old scripts don't. Cope for the moment, but
37 # issue a new warning for a transition period.
38 .if defined(TARGET) && !defined(TARGET_ARCH)
39 .warning "You must pass both TARGET and TARGET_ARCH to Makefile.inc1. Setting TARGET_ARCH=${TARGET}."
42 .if !defined(TARGET) || !defined(TARGET_ARCH)
43 .error "Both TARGET and TARGET_ARCH must be defined."
47 .include <bsd.arch.inc.mk>
48 .include <bsd.compiler.mk>
50 # We must do share/info early so that installation of info `dir'
51 # entries works correctly. Do it first since it is less likely to
52 # grow dependencies on include and lib than vice versa.
54 # We must do lib/ and libexec/ before bin/, because if installworld
55 # installs a new /bin/sh, the 'make' command will *immediately*
56 # use that new version. And the new (dynamically-linked) /bin/sh
57 # will expect to find appropriate libraries in /lib and /libexec.
59 SUBDIR= share/info lib libexec
61 .if ${MK_GAMES} != "no"
64 .if ${MK_CDDL} != "no"
68 .if ${MK_KERBEROS} != "no"
71 .if ${MK_RESCUE} != "no"
75 .if ${MK_CRYPT} != "no"
78 .if !defined(NO_SHARE)
81 SUBDIR+=sys usr.bin usr.sbin
82 .if ${MK_OFED} != "no"
86 # We must do etc/ last for install/distribute to work.
90 # These are last, since it is nice to at least get the base system
91 # rebuilt before you do them.
92 .for _DIR in ${LOCAL_DIRS}
93 .if exists(${.CURDIR}/${_DIR}/Makefile)
98 .if defined(SUBDIR_OVERRIDE)
99 SUBDIR= ${SUBDIR_OVERRIDE}
105 .if defined(NO_CLEANDIR)
106 CLEANDIR= clean cleandepend
112 CVSFLAGS?= -A -P -d -I!
118 SUPFLAGS+= -h ${SUPHOST}
121 MAKEOBJDIRPREFIX?= /usr/obj
122 .if !defined(OSRELDATE)
123 .if exists(/usr/include/osreldate.h)
124 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
125 /usr/include/osreldate.h
131 .if !defined(VERSION)
133 VERSION+= ${OSRELDATE}
136 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
137 .if ${TARGET} == ${TARGET_ARCH}
140 _t= ${TARGET_ARCH}/${TARGET}
143 .if empty(KNOWN_ARCHES:M${_t})
144 .error Unknown target ${TARGET_ARCH}:${TARGET}.
148 .if ${TARGET} == ${MACHINE}
149 TARGET_CPUTYPE?=${CPUTYPE}
154 .if !empty(TARGET_CPUTYPE)
155 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
157 _TARGET_CPUTYPE=dummy
159 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
160 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
161 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
162 .error CPUTYPE global should be set with ?=.
165 BUILD_ARCH!= uname -p
166 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
167 .error To cross-build, set TARGET_ARCH.
170 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
171 OBJTREE= ${MAKEOBJDIRPREFIX}
173 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
175 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
176 # /usr/games added for fortune which depend on strfile
177 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games
178 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
179 STRICTTMPPATH= ${BPATH}:${XPATH}
180 TMPPATH= ${STRICTTMPPATH}:${PATH}
183 # Avoid running mktemp(1) unless actually needed.
184 # It may not be functional, e.g., due to new ABI
185 # when in the middle of installing over this system.
187 .if make(distributeworld) || make(installworld)
188 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
192 # Building a world goes through the following stages
194 # 1. legacy stage [BMAKE]
195 # This stage is responsible for creating compatibility
196 # shims that are needed by the bootstrap-tools,
197 # build-tools and cross-tools stages.
198 # 1. bootstrap-tools stage [BMAKE]
199 # This stage is responsible for creating programs that
200 # are needed for backward compatibility reasons. They
201 # are not built as cross-tools.
202 # 2. build-tools stage [TMAKE]
203 # This stage is responsible for creating the object
204 # tree and building any tools that are needed during
206 # 3. cross-tools stage [XMAKE]
207 # This stage is responsible for creating any tools that
208 # are needed for cross-builds. A cross-compiler is one
210 # 4. world stage [WMAKE]
211 # This stage actually builds the world.
212 # 5. install stage (optional) [IMAKE]
213 # This stage installs a previously built world.
218 # Common environment for world related stages
219 CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
220 MACHINE_ARCH=${TARGET_ARCH} \
222 CPUTYPE=${TARGET_CPUTYPE}
223 .if ${OSRELDATE} < 700044
224 CROSSENV+= AR=gnu-ar RANLIB=gnu-ranlib
226 .if ${MK_GROFF} != "no"
227 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
228 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
229 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
232 # bootstrap-tools stage
233 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
234 PATH=${BPATH}:${PATH} \
235 WORLDTMP=${WORLDTMP} \
236 VERSION="${VERSION}" \
237 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
238 COMPILER_TYPE=${COMPILER_TYPE}
239 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
240 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
242 BOOTSTRAPPING=${OSRELDATE} \
244 -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
245 -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \
246 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD
249 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
250 ${BMAKEENV} ${MAKE} -f Makefile.inc1 \
251 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
253 BOOTSTRAPPING=${OSRELDATE} \
256 -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD
259 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
260 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
264 WMAKEENV= ${CROSSENV} \
265 _SHLIBDIRPREFIX=${WORLDTMP} \
267 VERSION="${VERSION}" \
268 INSTALL="sh ${.CURDIR}/tools/install.sh" \
270 .if ${MK_CDDL} == "no"
273 .if ${CC:T:Mgcc} == "gcc"
274 WMAKE_COMPILER_TYPE= gcc
275 .elif ${CC:T:Mclang} == "clang"
276 WMAKE_COMPILER_TYPE= clang
277 .elif ${MK_CLANG_IS_CC} == "no"
278 WMAKE_COMPILER_TYPE= gcc
280 WMAKE_COMPILER_TYPE= clang
282 WMAKEENV+= COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
283 WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP}
285 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
287 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
289 .if ${TARGET_ARCH} == "amd64"
290 .if empty(TARGET_CPUTYPE)
291 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
293 LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
295 LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
296 MACHINE_CPU="i686 mmx sse sse2"
299 LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32"
301 .elif ${TARGET_ARCH} == "powerpc64"
302 .if empty(TARGET_CPUTYPE)
303 LIB32CPUFLAGS= -mcpu=powerpc
305 LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
307 LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
309 LD="${LD} -m elf32ppc"
313 LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
314 -isystem ${LIB32TMP}/usr/include/ \
315 -L${LIB32TMP}/usr/lib32 \
316 -B${LIB32TMP}/usr/lib32
318 # Yes, the flags are redundant.
319 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
320 _SHLIBDIRPREFIX=${LIB32TMP} \
321 _LDSCRIPTROOT=${LIB32TMP} \
322 VERSION="${VERSION}" \
323 INSTALL="sh ${.CURDIR}/tools/install.sh" \
326 SHLIBDIR=/usr/lib32 \
327 COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
329 CC="${CC} ${LIB32FLAGS}" \
330 CXX="${CXX} ${LIB32FLAGS}" \
331 DESTDIR=${LIB32TMP} \
338 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
339 -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_INFO -DWITHOUT_HTML
340 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} -DNO_INCS \
344 IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*}
345 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
346 ${IMAKE_INSTALL} ${IMAKE_MTREE}
347 .if empty(.MAKEFLAGS:M-n)
348 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
349 LD_LIBRARY_PATH=${INSTALLTMP} \
350 PATH_LOCALE=${INSTALLTMP}/locale
351 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
353 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
355 .if defined(DB_FROM_SRC)
356 IMAKE_INSTALL= INSTALL="install -N ${.CURDIR}/etc"
357 IMAKE_MTREE= MTREE_CMD="nmtree -N ${.CURDIR}/etc"
361 KMAKEENV= ${WMAKEENV}
362 KMAKE= ${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME}
367 # Attempt to rebuild the entire system, with reasonable chance of
368 # success, regardless of how old your existing system is.
371 .if ${.CURDIR:C/[^,]//g} != ""
372 # The m4 build of sendmail files doesn't like it if ',' is used
373 # anywhere in the path of it's files.
375 @echo "*** Error: path to source tree contains a comma ','"
380 @echo "--------------------------------------------------------------"
381 @echo ">>> Rebuilding the temporary build tree"
382 @echo "--------------------------------------------------------------"
383 .if !defined(NO_CLEAN)
385 .if defined(LIB32TMP)
389 rm -rf ${WORLDTMP}/legacy/usr/include
390 # XXX - These three can depend on any header file.
391 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
392 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
393 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
397 mkdir -p ${WORLDTMP}/${_dir}
399 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
400 -p ${WORLDTMP}/legacy/usr >/dev/null
401 .if ${MK_GROFF} != "no"
402 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
403 -p ${WORLDTMP}/legacy/usr >/dev/null
405 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
406 -p ${WORLDTMP}/usr >/dev/null
407 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
408 -p ${WORLDTMP}/usr/include >/dev/null
409 ln -sf ${.CURDIR}/sys ${WORLDTMP}
410 .if ${MK_BIND_LIBS} != "no"
411 mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
412 -p ${WORLDTMP}/usr/include >/dev/null
414 .for _mtree in ${LOCAL_MTREE}
415 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
419 @echo "--------------------------------------------------------------"
420 @echo ">>> stage 1.1: legacy release compatibility shims"
421 @echo "--------------------------------------------------------------"
422 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
425 @echo "--------------------------------------------------------------"
426 @echo ">>> stage 1.2: bootstrap tools"
427 @echo "--------------------------------------------------------------"
428 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
430 .if !defined(NO_CLEAN)
432 @echo "--------------------------------------------------------------"
433 @echo ">>> stage 2.1: cleaning up the object tree"
434 @echo "--------------------------------------------------------------"
435 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
436 .if defined(LIB32TMP)
437 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/}
442 @echo "--------------------------------------------------------------"
443 @echo ">>> stage 2.2: rebuilding the object tree"
444 @echo "--------------------------------------------------------------"
445 ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj
448 @echo "--------------------------------------------------------------"
449 @echo ">>> stage 2.3: build tools"
450 @echo "--------------------------------------------------------------"
451 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
454 @echo "--------------------------------------------------------------"
455 @echo ">>> stage 3: cross tools"
456 @echo "--------------------------------------------------------------"
457 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
460 @echo "--------------------------------------------------------------"
461 @echo ">>> stage 4.1: building includes"
462 @echo "--------------------------------------------------------------"
463 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
466 @echo "--------------------------------------------------------------"
467 @echo ">>> stage 4.2: building libraries"
468 @echo "--------------------------------------------------------------"
469 ${_+_}cd ${.CURDIR}; \
470 ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
471 -DWITHOUT_MAN -DWITHOUT_PROFILE libraries
474 @echo "--------------------------------------------------------------"
475 @echo ">>> stage 4.3: make dependencies"
476 @echo "--------------------------------------------------------------"
477 ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend
480 @echo "--------------------------------------------------------------"
481 @echo ">>> stage 4.4: building everything"
482 @echo "--------------------------------------------------------------"
483 ${_+_}cd ${.CURDIR}; ${WMAKE} par-all
484 .if defined(LIB32TMP)
487 @echo "--------------------------------------------------------------"
488 @echo ">>> stage 5.1: building 32 bit shim libraries"
489 @echo "--------------------------------------------------------------"
490 mkdir -p ${LIB32TMP}/usr/include
491 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
492 -p ${LIB32TMP}/usr >/dev/null
493 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
494 -p ${LIB32TMP}/usr/include >/dev/null
496 ln -sf ${.CURDIR}/sys ${WORLDTMP}
497 .if ${MK_KERBEROS} != "no"
498 .for _t in obj depend all
499 cd ${.CURDIR}/kerberos5/tools; \
500 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
501 DIRPRFX=kerberos5/tools/ ${_t}
504 .for _t in obj includes
505 cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
506 cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
507 .if ${MK_CDDL} != "no"
508 cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
510 cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
511 .if ${MK_CRYPT} != "no"
512 cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
514 .if ${MK_KERBEROS} != "no"
515 cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
518 .for _dir in usr.bin/lex/lib
519 cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
521 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
522 cd ${.CURDIR}/${_dir}; \
523 MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
524 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF \
525 -DEARLY_BUILD build-tools
528 ${LIB32WMAKE} -f Makefile.inc1 libraries
529 .for _t in obj depend all
530 cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
531 DIRPRFX=libexec/rtld-elf/ ${_t}
532 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
533 DIRPRFX=usr.bin/ldd ${_t}
536 distribute32 install32:
537 cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
538 .if ${MK_CDDL} != "no"
539 cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
541 cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
542 .if ${MK_CRYPT} != "no"
543 cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
545 .if ${MK_KERBEROS} != "no"
546 cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
548 cd ${.CURDIR}/libexec/rtld-elf; \
549 PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
550 cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//}
554 .if !defined(SUBDIR_OVERRIDE)
555 WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools
557 WMAKE_TGTS+= _cleanobj _obj _build-tools
558 .if !defined(SUBDIR_OVERRIDE)
559 WMAKE_TGTS+= _cross-tools
561 WMAKE_TGTS+= _includes _libraries _depend everything
562 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
566 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
567 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
570 @echo "--------------------------------------------------------------"
571 @echo ">>> World build started on `LC_ALL=C date`"
572 @echo "--------------------------------------------------------------"
576 @echo "--------------------------------------------------------------"
577 @echo ">>> World build completed on `LC_ALL=C date`"
578 @echo "--------------------------------------------------------------"
581 # We need to have this as a target because the indirection between Makefile
582 # and Makefile.inc1 causes the correct PATH to be used, rather than a
583 # modification of the current environment's PATH. In addition, we need
584 # to quote multiword values.
590 @echo Entering world for ${TARGET_ARCH}:${TARGET}
591 @cd ${.CURDIR} && env ${WMAKEENV} sh || true
593 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
594 toolchain: ${TOOLCHAIN_TGTS}
595 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
600 # Checks to be sure system is ready for installworld/installkernel.
606 # Require DESTDIR to be set if installing for a different architecture or
607 # using the user/group database in the source tree.
609 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
611 .if !make(distributeworld)
612 installcheck: installcheck_DESTDIR
613 installcheck_DESTDIR:
614 .if !defined(DESTDIR) || empty(DESTDIR)
615 @echo "ERROR: Please set DESTDIR!"; \
621 .if !defined(DB_FROM_SRC)
623 # Check for missing UIDs/GIDs.
625 CHECK_UIDS= auditdistd
627 .if ${MK_SENDMAIL} != "no"
633 CHECK_GIDS+= proxy authpf
636 .for uid in ${CHECK_UIDS}
637 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
638 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
642 .for gid in ${CHECK_GIDS}
643 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
644 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
651 # Required install tools to be saved in a scratch dir for safety.
653 .if ${MK_INFO} != "no"
654 _install-info= install-info
656 .if ${MK_ZONEINFO} != "no"
657 _zoneinfo= zic tzsetup
660 .if exists(/usr/sbin/nmtree)
661 _nmtree_itools= nmtree
664 ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
665 date echo egrep find grep ${_install-info} \
666 ln lockf make mkdir mtree ${_nmtree_itools} mv pwd_mkdb \
667 rm sed sh sysctl test true uname wc ${_zoneinfo}
672 # Distributes everything compiled by a `buildworld'.
676 # Installs everything compiled by a 'buildworld'.
679 # Non-base distributions produced by the base system
680 EXTRA_DISTRIBUTIONS= doc
681 .if ${MK_GAMES} != "no"
682 EXTRA_DISTRIBUTIONS+= games
684 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
685 EXTRA_DISTRIBUTIONS+= lib32
688 distributeworld installworld: installcheck installcheck_UGID
689 mkdir -p ${INSTALLTMP}
690 progs=$$(for prog in ${ITOOLS}; do \
691 if progpath=`which $$prog`; then \
694 echo "Required tool $$prog not found in PATH." >&2; \
698 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
699 while read line; do \
701 if [ "$$2 $$3" != "not found" ]; then \
704 echo "Required library $$1 not found." >&2; \
708 cp $$libs $$progs ${INSTALLTMP}
709 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
710 .if make(distributeworld)
711 .for dist in ${EXTRA_DISTRIBUTIONS}
712 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
713 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
714 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
715 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
716 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
717 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
718 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
720 -mkdir ${DESTDIR}/${DISTDIR}/base
721 ${_+_}cd ${.CURDIR}; ${IMAKE} distrib-dirs \
722 LOCAL_MTREE=${LOCAL_MTREE} DESTDIR=${DESTDIR}/${DISTDIR}/base
724 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
725 ${IMAKEENV} rm -rf ${INSTALLTMP}
726 .if make(distributeworld)
727 .for dist in ${EXTRA_DISTRIBUTIONS}
728 find ${DESTDIR}/${DISTDIR}/${dist} -empty -delete
733 .for dist in base ${EXTRA_DISTRIBUTIONS}
734 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
735 tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz .
741 # If you have a build server, you can NFS mount the source and obj directories
742 # and do a 'make reinstall' on the *client* to install new binaries from the
743 # most recent server build.
746 @echo "--------------------------------------------------------------"
747 @echo ">>> Making hierarchy"
748 @echo "--------------------------------------------------------------"
749 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
750 LOCAL_MTREE=${LOCAL_MTREE} hierarchy
752 @echo "--------------------------------------------------------------"
753 @echo ">>> Installing everything"
754 @echo "--------------------------------------------------------------"
755 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
756 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
757 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
761 @echo "--------------------------------------------------------------"
762 @echo ">>> Distributing everything"
763 @echo "--------------------------------------------------------------"
764 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
765 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
766 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
770 distrib-dirs distribution:
771 cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
772 ${IMAKE_INSTALL} ${IMAKE_MTREE} ${.TARGET}
775 # buildkernel and installkernel
777 # Which kernels to build and/or install is specified by setting
778 # KERNCONF. If not defined a GENERIC kernel is built/installed.
779 # Only the existing (depending TARGET) config files are used
780 # for building kernels and only the first of these is designated
781 # as the one being installed.
783 # Note that we have to use TARGET instead of TARGET_ARCH when
784 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
785 # be set to cross-build, we have to make sure TARGET is set
788 .if defined(KERNFAST)
793 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
794 .if !defined(KERNCONF) && ${KERNFAST} != "1"
798 .if !defined(KERNCONF) && defined(KERNEL)
802 .if ${TARGET_ARCH} == "powerpc64"
808 INSTKERNNAME?= kernel
810 KERNSRCDIR?= ${.CURDIR}/sys
811 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
812 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
813 KERNCONFDIR?= ${KRNLCONFDIR}
817 .for _kernel in ${KERNCONF}
818 .if exists(${KERNCONFDIR}/${_kernel})
819 BUILDKERNELS+= ${_kernel}
820 .if empty(INSTALLKERNEL)
821 INSTALLKERNEL= ${_kernel}
829 # Builds all kernels defined by BUILDKERNELS.
832 .if empty(BUILDKERNELS)
833 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
836 .if defined(KERNWARN)
837 @echo "--------------------------------------------------------------"
838 @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
839 @echo "--------------------------------------------------------------"
843 .for _kernel in ${BUILDKERNELS}
844 @echo "--------------------------------------------------------------"
845 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
846 @echo "--------------------------------------------------------------"
847 @echo "===> ${_kernel}"
848 mkdir -p ${KRNLOBJDIR}
849 .if !defined(NO_KERNELCONFIG)
851 @echo "--------------------------------------------------------------"
852 @echo ">>> stage 1: configuring the kernel"
853 @echo "--------------------------------------------------------------"
856 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
857 ${KERNCONFDIR}/${_kernel}
859 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
861 @echo "--------------------------------------------------------------"
862 @echo ">>> stage 2.1: cleaning up the object tree"
863 @echo "--------------------------------------------------------------"
864 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
866 .if !defined(NO_KERNELOBJ)
868 @echo "--------------------------------------------------------------"
869 @echo ">>> stage 2.2: rebuilding the object tree"
870 @echo "--------------------------------------------------------------"
871 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
874 @echo "--------------------------------------------------------------"
875 @echo ">>> stage 2.3: build tools"
876 @echo "--------------------------------------------------------------"
877 cd ${KRNLOBJDIR}/${_kernel}; \
878 PATH=${BPATH}:${PATH} \
879 MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
880 ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD \
881 -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
882 # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
883 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
884 .for target in obj depend all
885 cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
886 PATH=${BPATH}:${PATH} \
887 MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
888 ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD ${target}
891 .if !defined(NO_KERNELDEPEND)
893 @echo "--------------------------------------------------------------"
894 @echo ">>> stage 3.1: making dependencies"
895 @echo "--------------------------------------------------------------"
896 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
899 @echo "--------------------------------------------------------------"
900 @echo ">>> stage 3.2: building everything"
901 @echo "--------------------------------------------------------------"
902 cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
903 @echo "--------------------------------------------------------------"
904 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
905 @echo "--------------------------------------------------------------"
909 # installkernel, etc.
911 # Install the kernel defined by INSTALLKERNEL
913 installkernel installkernel.debug \
914 reinstallkernel reinstallkernel.debug: installcheck
915 .if empty(INSTALLKERNEL)
916 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
919 @echo "--------------------------------------------------------------"
920 @echo ">>> Installing kernel ${INSTALLKERNEL}"
921 @echo "--------------------------------------------------------------"
922 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
923 ${CROSSENV} PATH=${TMPPATH} \
924 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
926 distributekernel distributekernel.debug:
927 .if empty(INSTALLKERNEL)
928 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
931 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
932 ${CROSSENV} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
933 DESTDIR=${DESTDIR}/${DISTDIR}/kernel \
934 ${.TARGET:S/distributekernel/install/}
935 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
936 cd ${KRNLOBJDIR}/${_kernel}; \
937 ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
938 KERNEL=${INSTKERNNAME}.${_kernel} \
939 DESTDIR=${DESTDIR}/${DISTDIR}/kernel.${_kernel} \
940 ${.TARGET:S/distributekernel/install/}
944 cd ${DESTDIR}/${DISTDIR}/kernel; \
945 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz .
946 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
947 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
948 tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz .
954 # Build the API documentation with doxygen
957 @if [ ! -x `/usr/bin/which doxygen` ]; then \
958 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
961 cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all
966 # Update the source tree(s), by running cvsup/cvs/svn to update to the
970 .if defined(SUP_UPDATE)
971 @echo "--------------------------------------------------------------"
972 @echo ">>> Running ${SUP}"
973 @echo "--------------------------------------------------------------"
974 @echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!"
975 @echo "!! Update methods with ${SUP} are deprecated."
976 @echo "!! Please see http://www.freebsd.org/handbook/svn.html"
977 @echo "!! and convert your update method to SVN_UPDATE or"
978 @echo "!! freebsd-update(8)."
979 @echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!"
982 @${SUP} ${SUPFLAGS} ${SUPFILE}
984 .if defined(SUPFILE1)
985 @${SUP} ${SUPFLAGS} ${SUPFILE1}
987 .if defined(SUPFILE2)
988 @${SUP} ${SUPFLAGS} ${SUPFILE2}
990 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
991 @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
993 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
994 @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
997 .if defined(CVS_UPDATE)
999 if [ -d CVS ] ; then \
1000 echo "--------------------------------------------------------------" ; \
1001 echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT} ; \
1002 echo "--------------------------------------------------------------" ; \
1003 echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!" ; \
1004 echo "!! Update methods with CVS are deprecated." ; \
1005 echo "!! Please see http://www.freebsd.org/handbook/svn.html" ; \
1006 echo "!! and convert your update method to SVN_UPDATE or" ; \
1007 echo "!! freebsd-update(8)." ; \
1008 echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!" ; \
1010 echo ${CVS} -R -q update ${CVSFLAGS} ; \
1011 ${CVS} -R -q update ${CVSFLAGS} ; \
1014 .if defined(SVN_UPDATE)
1016 if [ -d .svn ] ; then \
1017 echo "--------------------------------------------------------------" ; \
1018 echo ">>> Updating ${.CURDIR} using Subversion" ; \
1019 echo "--------------------------------------------------------------" ; \
1020 echo ${SVN} update ${SVNFLAGS} ; \
1021 ${SVN} update ${SVNFLAGS} ; \
1026 # ------------------------------------------------------------------------
1028 # From here onwards are utility targets used by the 'make world' and
1029 # related targets. If your 'world' breaks, you may like to try to fix
1030 # the problem and manually run the following targets to attempt to
1031 # complete the build. Beware, this is *not* guaranteed to work, you
1032 # need to have a pretty good grip on the current state of the system
1033 # to attempt to manually finish it. If in doubt, 'make world' again.
1037 # legacy: Build compatibility shims for the next three targets
1040 .if ${BOOTSTRAPPING} < 600034 && ${BOOTSTRAPPING} != 0
1041 @echo "ERROR: Source upgrades from versions prior to 6.0 not supported."; \
1044 .for _tool in tools/build
1045 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1046 cd ${.CURDIR}/${_tool}; \
1047 ${MAKE} DIRPRFX=${_tool}/ obj; \
1048 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1049 ${MAKE} DIRPRFX=${_tool}/ depend; \
1050 ${MAKE} DIRPRFX=${_tool}/ all; \
1051 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1055 # bootstrap-tools: Build tools needed for compatibility
1057 .if ${MK_GAMES} != "no"
1058 _strfile= games/fortune/strfile
1061 .if ${MK_CXX} != "no"
1062 _gperf= gnu/usr.bin/gperf
1065 .if ${MK_GROFF} != "no"
1066 _groff= gnu/usr.bin/groff
1069 .if ${BOOTSTRAPPING} >= 700044 && ${BOOTSTRAPPING} < 800022
1073 .if ${BOOTSTRAPPING} < 800013
1074 _mklocale= usr.bin/mklocale
1077 .if ${BOOTSTRAPPING} < 900002
1081 .if ${BOOTSTRAPPING} < 900006
1085 .if ${BOOTSTRAPPING} < 900006 || ${BOOTSTRAPPING} >= 1000013
1090 .if ${BOOTSTRAPPING} < 1000026
1091 _nmtree= lib/libnetbsd \
1095 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1099 .if ${MK_BSNMP} != "no" && \
1100 (${BOOTSTRAPPING} < 700018 || !exists(/usr/sbin/gensnmptree))
1101 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1104 .if ${MK_RESCUE} != "no" && \
1105 ${BOOTSTRAPPING} < 700026
1106 _crunchgen= usr.sbin/crunch/crunchgen
1109 .if ${MK_CLANG} != "no"
1111 lib/clang/libllvmsupport \
1112 lib/clang/libllvmtablegen \
1113 usr.bin/clang/tblgen \
1114 usr.bin/clang/clang-tblgen
1117 .if ${MK_CDDL} != "no" && \
1118 ${BOOTSTRAPPING} < 800038 && \
1119 !(${BOOTSTRAPPING} >= 700112 && ${BOOTSTRAPPING} < 799999)
1120 _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
1121 lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
1124 .if ${MK_FDT} != "no"
1125 _dtc= gnu/usr.bin/dtc
1128 # Please document (add comment) why something is in 'bootstrap-tools'.
1129 # Try to bound the building of the bootstrap-tool to just the
1130 # FreeBSD versions that need the tool built at this stage of the build.
1142 usr.bin/makewhatis \
1154 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1155 cd ${.CURDIR}/${_tool}; \
1156 ${MAKE} DIRPRFX=${_tool}/ obj; \
1157 ${MAKE} DIRPRFX=${_tool}/ depend; \
1158 ${MAKE} DIRPRFX=${_tool}/ all; \
1159 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1163 # build-tools: Build special purpose build tools
1165 .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
1166 _aicasm= sys/modules/aic7xxx/aicasm
1169 .if !defined(NO_SHARE)
1170 _share= share/syscons/scrnmaps
1173 .if ${MK_GCC} != "no" && (${MK_CLANG_IS_CC} == "no" || ${TARGET} == "pc98")
1174 _gcc_tools= gnu/usr.bin/cc/cc_tools
1177 .if ${MK_KERBEROS} != "no"
1178 _kerberos5_tools= kerberos5/tools
1181 .if ${MK_RESCUE} != "no"
1182 _rescue= rescue/rescue
1190 lib/ncurses/ncurses \
1191 lib/ncurses/ncursesw \
1196 usr.sbin/sysinstall \
1197 usr.bin/mkesdb_static \
1198 usr.bin/mkcsmapper_static
1199 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1200 cd ${.CURDIR}/${_tool}; \
1201 ${MAKE} DIRPRFX=${_tool}/ obj; \
1202 ${MAKE} DIRPRFX=${_tool}/ build-tools
1207 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1208 cd ${.CURDIR}/${_tool}; \
1209 ${MAKE} DIRPRFX=${_tool}/ obj; \
1210 ${MAKE} DIRPRFX=${_tool}/ depend; \
1211 ${MAKE} DIRPRFX=${_tool}/ all
1215 # cross-tools: Build cross-building tools
1217 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035
1218 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1219 _btxld= usr.sbin/btxld
1222 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1223 .if ${MK_RESCUE} != "no" || defined(RELEASEDIR)
1224 _crunchide= usr.sbin/crunch/crunchide
1226 .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR)
1227 _kgzip= usr.sbin/kgzip
1231 .if ${MK_BINUTILS} != "no"
1232 _binutils= gnu/usr.bin/binutils
1235 .if ${MK_CLANG} != "no" && (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang")
1236 _clang= usr.bin/clang
1237 _clang_libs= lib/clang
1240 .if ${MK_GCC} != "no" && (${MK_CLANG_IS_CC} == "no" || ${TARGET} == "pc98")
1250 usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
1254 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1255 cd ${.CURDIR}/${_tool}; \
1256 ${MAKE} DIRPRFX=${_tool}/ obj; \
1257 ${MAKE} DIRPRFX=${_tool}/ depend; \
1258 ${MAKE} DIRPRFX=${_tool}/ all; \
1259 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1263 # hierarchy - ensure that all the needed directories are present
1266 cd ${.CURDIR}/etc; ${MAKE} LOCAL_MTREE=${LOCAL_MTREE} distrib-dirs
1269 # libraries - build all libraries, and install them under ${DESTDIR}.
1271 # The list of libraries with dependents (${_prebuild_libs}) and their
1272 # interdependencies (__L) are built automatically by the
1273 # ${.CURDIR}/tools/make_libdeps.sh script.
1277 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1278 ${MAKE} -f Makefile.inc1 _startup_libs; \
1279 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1280 ${MAKE} -f Makefile.inc1 _generic_libs;
1283 # static libgcc.a prerequisite for shared libc
1285 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1287 # These dependencies are not automatically generated:
1289 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1290 # all shared libraries for ELF.
1292 _startup_libs= gnu/lib/csu
1293 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
1294 _startup_libs+= lib/csu/${MACHINE_ARCH}-elf
1295 .elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
1296 _startup_libs+= lib/csu/${MACHINE_ARCH}
1298 _startup_libs+= lib/csu/${MACHINE_CPUARCH}
1300 _startup_libs+= gnu/lib/libgcc
1301 _startup_libs+= lib/libcompiler_rt
1302 _startup_libs+= lib/libc
1303 .if ${MK_LIBCPLUSPLUS} != "no"
1304 _startup_libs+= lib/libcxxrt
1307 gnu/lib/libgcc__L: lib/libc__L
1308 .if ${MK_LIBCPLUSPLUS} != "no"
1309 lib/libcxxrt__L: gnu/lib/libgcc__L
1312 _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libhdb} \
1313 ${_kerberos5_lib_libheimntlm} \
1314 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1315 ${_kerberos5_lib_libroken} \
1316 lib/libbz2 lib/libcom_err lib/libcrypt \
1318 ${_lib_libgssapi} ${_lib_libipx} \
1319 lib/libkiconv lib/libkvm lib/liblzma lib/libmd \
1320 lib/ncurses/ncurses lib/ncurses/ncursesw \
1321 lib/libopie lib/libpam ${_lib_libthr} \
1322 lib/libradius lib/libsbuf lib/libtacplus \
1323 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1324 ${_cddl_lib_libzfs_core} \
1325 lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
1326 ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
1327 ${_secure_lib_libssl}
1329 .if ${MK_LIBTHR} != "no"
1330 _lib_libthr= lib/libthr
1333 .if ${MK_OFED} != "no"
1334 _ofed_lib= contrib/ofed/usr.lib/
1337 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1339 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1341 .if ${MK_CDDL} != "no"
1342 _cddl_lib_libumem= cddl/lib/libumem
1343 _cddl_lib_libnvpair= cddl/lib/libnvpair
1344 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1346 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1349 .if ${MK_CRYPT} != "no"
1350 .if ${MK_OPENSSL} != "no"
1351 _secure_lib_libcrypto= secure/lib/libcrypto
1352 _secure_lib_libssl= secure/lib/libssl
1353 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1354 .if ${MK_OPENSSH} != "no"
1355 _secure_lib_libssh= secure/lib/libssh
1356 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1357 .if ${MK_KERBEROS_SUPPORT} != "no"
1358 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1359 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1360 lib/libmd__L kerberos5/lib/libroken__L
1364 _secure_lib= secure/lib
1367 .if ${MK_KERBEROS} != "no"
1368 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1369 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1370 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L
1371 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L
1372 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1373 secure/lib/libcrypto__L kerberos5/lib/libroken__L
1374 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1375 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1376 kerberos5/lib/libroken__L
1377 kerberos5/lib/libroken__L: lib/libcrypt__L
1380 .if ${MK_GSSAPI} != "no"
1381 _lib_libgssapi= lib/libgssapi
1384 .if ${MK_IPX} != "no"
1385 _lib_libipx= lib/libipx
1388 .if ${MK_KERBEROS} != "no"
1389 _kerberos5_lib= kerberos5/lib
1390 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1391 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
1392 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1393 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1394 _kerberos5_lib_libroken= kerberos5/lib/libroken
1395 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1398 .if ${MK_NIS} != "no"
1399 _lib_libypclnt= lib/libypclnt
1402 .if ${MK_OPENSSL} == "no"
1403 lib/libradius__L: lib/libmd__L
1406 .for _lib in ${_prereq_libs}
1408 .if exists(${.CURDIR}/${_lib})
1409 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1410 cd ${.CURDIR}/${_lib}; \
1411 ${MAKE} DIRPRFX=${_lib}/ obj; \
1412 ${MAKE} DIRPRFX=${_lib}/ depend; \
1413 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \
1414 ${MAKE} -DWITHOUT_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
1418 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
1420 .if exists(${.CURDIR}/${_lib})
1421 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
1422 cd ${.CURDIR}/${_lib}; \
1423 ${MAKE} DIRPRFX=${_lib}/ obj; \
1424 ${MAKE} DIRPRFX=${_lib}/ depend; \
1425 ${MAKE} DIRPRFX=${_lib}/ all; \
1426 ${MAKE} DIRPRFX=${_lib}/ install
1430 # libpam is special: we need to build static PAM modules before
1431 # static PAM library, and dynamic PAM library before dynamic PAM
1433 lib/libpam__L: .PHONY
1434 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
1435 cd ${.CURDIR}/lib/libpam; \
1436 ${MAKE} DIRPRFX=lib/libpam/ obj; \
1437 ${MAKE} DIRPRFX=lib/libpam/ depend; \
1438 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
1439 ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
1441 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1442 _startup_libs: ${_startup_libs:S/$/__L/}
1443 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1444 _generic_libs: ${_generic_libs:S/$/__L/}
1446 .for __target in all clean cleandepend cleandir depend includes obj
1447 .for entry in ${SUBDIR}
1448 ${entry}.${__target}__D: .PHONY
1449 ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
1450 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
1451 edir=${entry}.${MACHINE_ARCH}; \
1452 cd ${.CURDIR}/$${edir}; \
1454 ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \
1456 cd ${.CURDIR}/$${edir}; \
1458 ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
1460 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
1463 .include <bsd.subdir.mk>
1465 .if make(check-old) || make(check-old-dirs) || \
1466 make(check-old-files) || make(check-old-libs) || \
1467 make(delete-old) || make(delete-old-dirs) || \
1468 make(delete-old-files) || make(delete-old-libs)
1471 # check for / delete old files section
1474 .include "ObsoleteFiles.inc"
1476 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1477 else you can not start such an application. Consult UPDATING for more \
1478 information regarding how to cope with the removal/revision bump of a \
1481 .if !defined(BATCH_DELETE_OLD_FILES)
1488 @echo ">>> Removing old files (only deletes safe to delete libs)"
1489 # Ask for every old file if the user really wants to remove it.
1490 # It's annoying, but better safe than sorry.
1491 # NB: We cannot pass the list of OLD_FILES as a parameter because the
1492 # argument list will get too long. Using .for/.endfor make "loops" will make
1493 # the Makefile parser segfault.
1495 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1496 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1497 while read file; do \
1498 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1499 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1500 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1503 # Remove catpages without corresponding manpages.
1505 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1506 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1507 while read catpage; do \
1509 if [ ! -e "$${manpage}" ]; then \
1510 rm ${RM_I} $${catpage} <&3; \
1513 @echo ">>> Old files removed"
1516 @echo ">>> Checking for old files"
1517 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1518 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1519 while read file; do \
1520 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1521 echo "${DESTDIR}/$${file}"; \
1524 # Check for catpages without corresponding manpages.
1525 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1526 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1527 while read catpage; do \
1529 if [ ! -e "$${manpage}" ]; then \
1535 @echo ">>> Removing old libraries"
1536 @echo "${OLD_LIBS_MESSAGE}" | fmt
1538 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1539 -V OLD_LIBS | xargs -n1 | \
1540 while read file; do \
1541 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1542 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1543 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1546 @echo ">>> Old libraries removed"
1549 @echo ">>> Checking for old libraries"
1550 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1551 -V OLD_LIBS | xargs -n1 | \
1552 while read file; do \
1553 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1554 echo "${DESTDIR}/$${file}"; \
1559 @echo ">>> Removing old directories"
1560 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1561 -V OLD_DIRS | xargs -n1 | \
1562 while read dir; do \
1563 if [ -d "${DESTDIR}/$${dir}" ]; then \
1564 rmdir -v "${DESTDIR}/$${dir}" || true; \
1565 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1566 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1569 @echo ">>> Old directories removed"
1572 @echo ">>> Checking for old directories"
1573 @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1574 -V OLD_DIRS | xargs -n1 | \
1575 while read dir; do \
1576 if [ -d "${DESTDIR}/$${dir}" ]; then \
1577 echo "${DESTDIR}/$${dir}"; \
1578 elif [ -L "${DESTDIR}/$${dir}" ]; then \
1579 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
1583 delete-old: delete-old-files delete-old-dirs
1584 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1586 check-old: check-old-files check-old-libs check-old-dirs
1587 @echo "To remove old files and directories run '${MAKE} delete-old'."
1588 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
1593 # showconfig - show build configuration.
1596 @${MAKE} -n -f bsd.own.mk -V dummy -dg1 | grep ^MK_ | sort
1598 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
1599 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
1601 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
1602 .if exists(${KERNCONFDIR}/${KERNCONF})
1603 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
1604 ${KERNCONFDIR}/${KERNCONF}
1610 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
1611 DTBOUTPUTPATH= ${.CURDIR}
1615 # Build 'standalone' Device Tree Blob
1618 @if [ "${FDT_DTS_FILE}" = "" ]; then \
1619 echo "ERROR: FDT_DTS_FILE must be specified!"; \
1622 if [ ! -f ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE} ]; then \
1623 echo "ERROR: Specified DTS file (${FDT_DTS_FILE}) does not \
1627 if [ "${DTBOUTPUTPATH}" = "${.CURDIR}" ]; then \
1628 echo "WARNING: DTB will be placed in the current working \
1633 ${DTBOUTPUTPATH}/`echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb -b 0 \
1634 -p 1024 ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE}
1638 .if defined(XDEV) && defined(XDEV_ARCH)
1640 .if ${XDEV} == ${MACHINE} && ${XDEV_ARCH} == ${MACHINE_ARCH}
1641 XDEV_CPUTYPE?=${CPUTYPE}
1643 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
1646 NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \
1647 -DWITHOUT_MAN -DWITHOUT_NLS -DWITHOUT_PROFILE \
1648 -DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_WARNS \
1649 TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH} \
1650 CPUTYPE=${XDEV_CPUTYPE}
1652 XDDIR=${XDEV_ARCH}-freebsd
1654 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR}
1656 _SHLIBDIRPREFIX=${XDTP} \
1657 TOOLS_PREFIX=${XDTP}
1659 MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH}
1661 CDTMP= ${MAKEOBJDIRPREFIX}/${XDEV}/${.CURDIR}/tmp
1662 CDMAKE=${CDENV} ${MAKE} ${NOFUN}
1663 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDTP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
1664 XDDESTDIR=${DESTDIR}${XDTP}
1666 OSREL!= uname -r | sed -e 's/[-(].*//'
1669 .ORDER: xdev-build xdev-install
1670 xdev: xdev-build xdev-install
1672 .ORDER: _xb-build-tools _xb-cross-tools
1673 xdev-build: _xb-build-tools _xb-cross-tools
1676 ${_+_}@cd ${.CURDIR}; \
1677 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
1681 gnu/usr.bin/binutils \
1684 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
1685 cd ${.CURDIR}/${_tool}; \
1686 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
1687 ${CDMAKE} DIRPRFX=${_tool}/ depend; \
1688 ${CDMAKE} DIRPRFX=${_tool}/ all
1692 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
1693 mkdir -p ${XDDESTDIR}
1694 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1695 -p ${XDDESTDIR} >/dev/null
1696 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1697 -p ${XDDESTDIR}/usr >/dev/null
1698 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1699 -p ${XDDESTDIR}/usr/include >/dev/null
1701 .ORDER: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1702 xdev-install: _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links
1705 @echo "_xi-cross-tools"
1707 gnu/usr.bin/binutils \
1710 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
1711 cd ${.CURDIR}/${_tool}; \
1712 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
1716 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \
1717 DESTDIR=${XDDESTDIR}
1720 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
1721 DESTDIR=${XDDESTDIR}
1724 ${_+_}cd ${XDDESTDIR}/usr/bin; \
1726 ln -sf ../../${XDTP}/usr/bin/$$i \
1727 ../../../../usr/bin/${XDDIR}-$$i; \
1728 ln -sf ../../${XDTP}/usr/bin/$$i \
1729 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \