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 # -DWITHOUT_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_ITOOLS="list of tools" to add additional tools to the ITOOLS list
21 # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
22 # LOCAL_MTREE="list of mtree files" to process to allow local directories
23 # to be created before files are installed
24 # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
26 # METALOG="path to metadata log" to write permission and ownership
27 # when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
28 # TARGET="machine" to crossbuild world for a different machine type
29 # TARGET_ARCH= may be required when a TARGET supports multiple endians
30 # BUILDENV_SHELL= shell to launch for the buildenv target (def:${SHELL})
31 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
32 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
33 # SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
34 # All libraries and includes, and some build tools will still build.
37 # The intended user-driven targets are:
38 # buildworld - rebuild *everything*, including glue to help do upgrades
39 # installworld- install everything built by "buildworld"
40 # checkworld - run test suite on installed world
41 # doxygen - build API documentation of the kernel
42 # update - convenient way to update your source tree (eg: svn/svnup)
44 # Standard targets (not defined here) are documented in the makefiles in
45 # /usr/share/mk. These include:
46 # obj depend all install clean cleandepend cleanobj
48 .if !defined(TARGET) || !defined(TARGET_ARCH)
49 .error "Both TARGET and TARGET_ARCH must be defined."
52 LOCALBASE?= /usr/local
54 # Cross toolchain changes must be in effect before bsd.compiler.mk
55 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
56 .if defined(CROSS_TOOLCHAIN)
57 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
58 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
60 .include <bsd.compiler.mk> # don't depend on src.opts.mk doing it
61 .include "share/mk/src.opts.mk"
63 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
64 # keep the users system reasonably usable. For static->dynamic root upgrades,
65 # we don't want to install a dynamic binary without rtld and the needed
66 # libraries. More commonly, for dynamic root, we don't want to install a
67 # binary that requires a newer library version that hasn't been installed yet.
68 # This ordering is not a guarantee though. The only guarantee of a working
69 # system here would require fine-grained ordering of all components based
70 # on their dependencies.
72 .if !empty(SUBDIR_OVERRIDE)
73 SUBDIR= ${SUBDIR_OVERRIDE}
76 .if !defined(NO_ROOT) && (make(installworld) || make(install))
77 # Ensure libraries are installed before progressing.
81 .if ${MK_CDDL} != "no"
85 .if ${MK_KERBEROS} != "no"
88 .if ${MK_RESCUE} != "no"
92 .if ${MK_CRYPT} != "no"
95 .if !defined(NO_SHARE)
98 SUBDIR+=sys usr.bin usr.sbin
99 .if ${MK_TESTS} != "no"
102 .if ${MK_OFED} != "no"
106 # Local directories are last, since it is nice to at least get the base
107 # system rebuilt before you do them.
108 .for _DIR in ${LOCAL_DIRS}
109 .if exists(${.CURDIR}/${_DIR}/Makefile)
113 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
114 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
115 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
116 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
117 _REDUNDENT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
119 .for _DIR in ${LOCAL_LIB_DIRS}
120 .if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
123 .warning ${_DIR} not added to SUBDIR list. See UPDATING 20141121.
127 # We must do etc/ last as it hooks into building the man whatis file
128 # by calling 'makedb' in share/man. This is only relevant for
129 # install/distribute so they build the whatis file after every manpage is
131 .if make(installworld) || make(install)
136 .endif # !empty(SUBDIR_OVERRIDE)
139 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
142 .if defined(NO_CLEANDIR)
143 CLEANDIR= clean cleandepend
148 # FAST_DEPEND can skip depend tree-walks.
149 .if ${MK_FAST_DEPEND} == "yes"
153 # Ensure shell checks later have a value.
154 .if defined(NO_DEPEND)
159 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
161 .if empty(SHELL:M*csh*)
162 BUILDENV_SHELL?=${SHELL}
164 BUILDENV_SHELL?=/bin/sh
167 SVN?= /usr/local/bin/svn
170 MAKEOBJDIRPREFIX?= /usr/obj
171 .if !defined(OSRELDATE)
172 .if exists(/usr/include/osreldate.h)
173 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
174 /usr/include/osreldate.h
181 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
182 .if !defined(VERSION) && !make(showconfig)
183 REVISION!= ${MAKE} -C ${SRCDIR}/release -V REVISION
184 BRANCH!= ${MAKE} -C ${SRCDIR}/release -V BRANCH
185 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
186 ${SRCDIR}/sys/sys/param.h
187 VERSION= FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
191 .if !defined(PKG_VERSION)
192 REVISION!= ${MAKE} -C ${SRCDIR}/release -V REVISION
193 BRANCH!= ${MAKE} -C ${SRCDIR}/release -V BRANCH
194 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
195 ${SRCDIR}/sys/sys/param.h
196 .if ${BRANCH:MSTABLE*} || ${BRANCH:MCURRENT*}
197 TIMENOW= %Y%m%d%H%M%S
198 EXTRA_REVISION= .s${TIMENOW:gmtime}
201 EXTRA_REVISION= _${BRANCH:C/.*-p([0-9]+$)/\1/}
203 PKG_VERSION= ${REVISION}${EXTRA_REVISION}
206 KNOWN_ARCHES?= aarch64/arm64 \
225 .if ${TARGET} == ${TARGET_ARCH}
228 _t= ${TARGET_ARCH}/${TARGET}
231 .if empty(KNOWN_ARCHES:M${_t})
232 .error Unknown target ${TARGET_ARCH}:${TARGET}.
236 .if ${TARGET} == ${MACHINE}
237 TARGET_CPUTYPE?=${CPUTYPE}
242 .if !empty(TARGET_CPUTYPE)
243 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
245 _TARGET_CPUTYPE=dummy
247 # Skip for showconfig as it is just wasted time and may invoke auto.obj.mk.
248 .if !make(showconfig)
249 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
250 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
251 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
252 .error CPUTYPE global should be set with ?=.
256 BUILD_ARCH!= uname -p
257 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
258 .error To cross-build, set TARGET_ARCH.
261 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
262 OBJTREE= ${MAKEOBJDIRPREFIX}
264 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
266 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
267 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
268 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
269 STRICTTMPPATH= ${BPATH}:${XPATH}
270 TMPPATH= ${STRICTTMPPATH}:${PATH}
273 # Avoid running mktemp(1) unless actually needed.
274 # It may not be functional, e.g., due to new ABI
275 # when in the middle of installing over this system.
277 .if make(distributeworld) || make(installworld) || make(stageworld)
278 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
281 .if make(stagekernel) || make(distributekernel)
287 # Building a world goes through the following stages
289 # 1. legacy stage [BMAKE]
290 # This stage is responsible for creating compatibility
291 # shims that are needed by the bootstrap-tools,
292 # build-tools and cross-tools stages. These are generally
293 # APIs that tools from one of those three stages need to
294 # build that aren't present on the host.
295 # 1. bootstrap-tools stage [BMAKE]
296 # This stage is responsible for creating programs that
297 # are needed for backward compatibility reasons. They
298 # are not built as cross-tools.
299 # 2. build-tools stage [TMAKE]
300 # This stage is responsible for creating the object
301 # tree and building any tools that are needed during
302 # the build process. Some programs are listed during
303 # this phase because they build binaries to generate
304 # files needed to build these programs. This stage also
305 # builds the 'build-tools' target rather than 'all'.
306 # 3. cross-tools stage [XMAKE]
307 # This stage is responsible for creating any tools that
308 # are needed for building the system. A cross-compiler is one
309 # of them. This differs from build tools in two ways:
310 # 1. the 'all' target is built rather than 'build-tools'
311 # 2. these tools are installed into TMPPATH for stage 4.
312 # 4. world stage [WMAKE]
313 # This stage actually builds the world.
314 # 5. install stage (optional) [IMAKE]
315 # This stage installs a previously built world.
320 # Common environment for world related stages
321 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
322 MACHINE_ARCH=${TARGET_ARCH} \
324 CPUTYPE=${TARGET_CPUTYPE}
325 .if ${MK_GROFF} != "no"
326 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
327 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
328 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
330 .if defined(TARGET_CFLAGS)
331 CROSSENV+= ${TARGET_CFLAGS}
334 # bootstrap-tools stage
335 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
336 PATH=${BPATH}:${PATH} \
337 WORLDTMP=${WORLDTMP} \
338 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
339 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
341 BOOTSTRAPPING=${OSRELDATE} \
343 MK_HTML=no NO_LINT=yes MK_MAN=no \
344 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
345 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
346 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
347 MK_LLDB=no MK_TESTS=no \
350 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
351 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
355 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
356 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
357 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
359 BOOTSTRAPPING=${OSRELDATE} \
362 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
363 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
364 MK_LLDB=no MK_TESTS=no
367 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
368 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
369 MK_GDB=no MK_TESTS=no
372 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
373 PATH=${BPATH}:${PATH} \
375 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
376 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
378 BOOTSTRAPPING=${OSRELDATE} \
380 MK_HTML=no -DNO_LINT MK_MAN=no \
381 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
382 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
385 WMAKEENV= ${CROSSENV} \
387 INSTALL="sh ${.CURDIR}/tools/install.sh" \
391 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
393 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
396 .if defined(CROSS_TOOLCHAIN_PREFIX)
397 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
398 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
401 # If we do not have a bootstrap binutils (because the in-tree one does not
402 # support the target architecture), provide a default cross-binutils prefix.
403 # This allows aarch64 builds, for example, to automatically use the
404 # aarch64-binutils port or package.
405 .if !make(showconfig)
406 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
407 !defined(CROSS_BINUTILS_PREFIX)
408 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
409 .if !exists(${CROSS_BINUTILS_PREFIX})
410 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
415 XCOMPILERS= CC CXX CPP
416 .for COMPILER in ${XCOMPILERS}
417 .if defined(CROSS_COMPILER_PREFIX)
418 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
420 X${COMPILER}?= ${${COMPILER}}
423 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
424 .for BINUTIL in ${XBINUTILS}
425 .if defined(CROSS_BINUTILS_PREFIX) && \
426 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
427 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
429 X${BINUTIL}?= ${${BINUTIL}}
432 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
433 DEPFLAGS="${DEPFLAGS}" \
434 CPP="${XCPP} ${XCFLAGS}" \
435 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
436 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
437 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
440 .if ${XCC:N${CCACHE_BIN}:M/*}
441 .if defined(CROSS_BINUTILS_PREFIX)
442 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
443 # directory, but the compiler will look in the right place for it's
444 # tools so we don't need to tell it where to look.
445 .if exists(${CROSS_BINUTILS_PREFIX})
446 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
449 BFLAGS+= -B${WORLDTMP}/usr/bin
451 .if ${TARGET} == "arm"
452 .if ${TARGET_ARCH:M*hf*} != ""
453 TARGET_ABI= gnueabihf
458 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
459 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
460 XCXXFLAGS+= -I${WORLDTMP}/usr/include/c++/v1 -std=gnu++11 -L${WORLDTMP}/../lib/libc++
461 # XXX: DEPFLAGS is a workaround for not properly passing CXXFLAGS to sub-makes
462 # due to CXX="${XCXX} ${XCXXFLAGS}". bsd.dep.mk does use CXXFLAGS when
463 # building C++ files so this can come out if passing CXXFLAGS down is fixed.
464 DEPFLAGS+= -I${WORLDTMP}/usr/include/c++/v1
467 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
468 XCFLAGS+= -target ${TARGET_TRIPLE}
470 XCFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
471 XCXXFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
473 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
474 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
476 XCXXFLAGS+= ${BFLAGS}
480 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
482 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
484 LIB32_OBJTREE= ${OBJTREE}${.CURDIR}/world32
485 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
487 .if ${TARGET_ARCH} == "amd64"
488 .if empty(TARGET_CPUTYPE)
489 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
491 LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
493 LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
494 MACHINE_CPU="i686 mmx sse sse2"
497 LD="${XLD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
498 OBJCOPY="${XOBJCOPY}"
500 .elif ${TARGET_ARCH} == "powerpc64"
501 .if empty(TARGET_CPUTYPE)
502 LIB32CPUFLAGS= -mcpu=powerpc
504 LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
506 LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
508 LD="${XLD} -m elf32ppc_fbsd" \
509 OBJCOPY="${XOBJCOPY}"
513 LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
514 -isystem ${LIB32TMP}/usr/include/ \
515 -L${LIB32TMP}/usr/lib32 \
516 -B${LIB32TMP}/usr/lib32
517 .if ${XCC:N${CCACHE_BIN}:M/*}
518 LIB32FLAGS+= --sysroot=${WORLDTMP}
521 # Yes, the flags are redundant.
522 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${LIB32_OBJTREE} \
523 _LDSCRIPTROOT=${LIB32TMP} \
524 INSTALL="sh ${.CURDIR}/tools/install.sh" \
527 SHLIBDIR=/usr/lib32 \
528 DTRACE="${DTRACE} -32"
529 LIB32WMAKEFLAGS+= CC="${XCC} ${LIB32FLAGS}" \
530 CXX="${XCXX} ${LIB32FLAGS}" \
531 DESTDIR=${LIB32TMP} \
539 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
541 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \
542 MK_TOOLCHAIN=no ${IMAKE_INSTALL}
545 IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*}
546 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
547 ${IMAKE_INSTALL} ${IMAKE_MTREE}
548 .if empty(.MAKEFLAGS:M-n)
549 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
550 LD_LIBRARY_PATH=${INSTALLTMP} \
551 PATH_LOCALE=${INSTALLTMP}/locale
552 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
554 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
556 .if defined(DB_FROM_SRC)
557 INSTALLFLAGS+= -N ${.CURDIR}/etc
558 MTREEFLAGS+= -N ${.CURDIR}/etc
560 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
561 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
563 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
564 IMAKE+= -DNO_ROOT METALOG=${METALOG}
565 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
568 .if defined(BUILD_PKGS)
569 INSTALLFLAGS+= -h sha256
571 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
572 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
573 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
577 KMAKEENV= ${WMAKEENV}
578 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
583 # Attempt to rebuild the entire system, with reasonable chance of
584 # success, regardless of how old your existing system is.
587 .if ${.CURDIR:C/[^,]//g} != ""
588 # The m4 build of sendmail files doesn't like it if ',' is used
589 # anywhere in the path of it's files.
591 @echo "*** Error: path to source tree contains a comma ','"
596 @echo "--------------------------------------------------------------"
597 @echo ">>> Rebuilding the temporary build tree"
598 @echo "--------------------------------------------------------------"
599 .if !defined(NO_CLEAN)
601 .if defined(LIB32TMP)
605 rm -rf ${WORLDTMP}/legacy/usr/include
606 # XXX - These can depend on any header file.
607 rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c
608 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
611 lib lib/casper usr legacy/bin legacy/usr
612 mkdir -p ${WORLDTMP}/${_dir}
614 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
615 -p ${WORLDTMP}/legacy/usr >/dev/null
616 .if ${MK_GROFF} != "no"
617 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
618 -p ${WORLDTMP}/legacy/usr >/dev/null
620 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
621 -p ${WORLDTMP}/usr >/dev/null
622 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
623 -p ${WORLDTMP}/usr/include >/dev/null
624 ln -sf ${.CURDIR}/sys ${WORLDTMP}
625 .if ${MK_DEBUG_FILES} != "no"
626 # We could instead disable debug files for these build stages
627 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
628 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
629 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
630 -p ${WORLDTMP}/usr/lib >/dev/null
632 .if ${MK_LIB32} != "no"
633 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
634 -p ${WORLDTMP}/usr >/dev/null
635 .if ${MK_DEBUG_FILES} != "no"
636 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
637 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
638 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
639 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
642 .if ${MK_TESTS} != "no"
643 mkdir -p ${WORLDTMP}${TESTSBASE}
644 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
645 -p ${WORLDTMP}${TESTSBASE} >/dev/null
646 .if ${MK_DEBUG_FILES} != "no"
647 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
648 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
649 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
652 .for _mtree in ${LOCAL_MTREE}
653 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
657 @echo "--------------------------------------------------------------"
658 @echo ">>> stage 1.1: legacy release compatibility shims"
659 @echo "--------------------------------------------------------------"
660 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
663 @echo "--------------------------------------------------------------"
664 @echo ">>> stage 1.2: bootstrap tools"
665 @echo "--------------------------------------------------------------"
666 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
668 .if !defined(NO_CLEAN)
670 @echo "--------------------------------------------------------------"
671 @echo ">>> stage 2.1: cleaning up the object tree"
672 @echo "--------------------------------------------------------------"
673 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
674 .if defined(LIB32TMP)
675 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR}
680 @echo "--------------------------------------------------------------"
681 @echo ">>> stage 2.2: rebuilding the object tree"
682 @echo "--------------------------------------------------------------"
683 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
686 @echo "--------------------------------------------------------------"
687 @echo ">>> stage 2.3: build tools"
688 @echo "--------------------------------------------------------------"
689 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
692 @echo "--------------------------------------------------------------"
693 @echo ">>> stage 3: cross tools"
694 @echo "--------------------------------------------------------------"
695 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
696 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
699 @echo "--------------------------------------------------------------"
700 @echo ">>> stage 4.1: building includes"
701 @echo "--------------------------------------------------------------"
702 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
703 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
704 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
706 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
707 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks includes
711 @echo "--------------------------------------------------------------"
712 @echo ">>> stage 4.2: building libraries"
713 @echo "--------------------------------------------------------------"
714 ${_+_}cd ${.CURDIR}; \
715 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
716 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
719 @echo "--------------------------------------------------------------"
720 @echo ">>> stage 4.3: make dependencies"
721 @echo "--------------------------------------------------------------"
722 ${_+_}cd ${.CURDIR}; ${WMAKE} depend
725 @echo "--------------------------------------------------------------"
726 @echo ">>> stage 4.4: building everything"
727 @echo "--------------------------------------------------------------"
728 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
729 .if defined(LIB32TMP)
732 @echo "--------------------------------------------------------------"
733 @echo ">>> stage 5.1: building 32 bit shim libraries"
734 @echo "--------------------------------------------------------------"
735 mkdir -p ${LIB32TMP}/usr/include
736 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
737 -p ${LIB32TMP}/usr >/dev/null
738 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
739 -p ${LIB32TMP}/usr/include >/dev/null
740 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
741 -p ${LIB32TMP}/usr >/dev/null
742 .if ${MK_DEBUG_FILES} != "no"
743 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
744 -p ${LIB32TMP}/usr/lib >/dev/null
745 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
746 -p ${LIB32TMP}/usr/lib/debug/usr >/dev/null
749 ln -sf ${.CURDIR}/sys ${WORLDTMP}
750 .for _t in obj includes
751 ${_+_}cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
752 ${_+_}cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
753 .if ${MK_CDDL} != "no"
754 ${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
756 ${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
757 .if ${MK_CRYPT} != "no"
758 ${_+_}cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
760 .if ${MK_KERBEROS} != "no"
761 ${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
764 .for _dir in usr.bin/lex/lib
765 ${_+_}cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
767 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
768 ${_+_}cd ${.CURDIR}/${_dir}; \
769 WORLDTMP=${WORLDTMP} \
770 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
771 MAKEOBJDIRPREFIX=${LIB32_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \
772 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
775 ${_+_}cd ${.CURDIR}; \
776 ${LIB32WMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
777 .for _t in obj depend all
778 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
779 -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t}
780 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
781 DIRPRFX=usr.bin/ldd ${_t}
784 distribute32 install32: .MAKE .PHONY
785 ${_+_}cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
786 .if ${MK_CDDL} != "no"
787 ${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
789 ${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
790 .if ${MK_CRYPT} != "no"
791 ${_+_}cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
793 .if ${MK_KERBEROS} != "no"
794 ${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
796 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \
797 PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
798 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} \
803 WMAKE_TGTS+= _worldtmp _legacy
804 .if empty(SUBDIR_OVERRIDE)
805 WMAKE_TGTS+= _bootstrap-tools
807 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
808 WMAKE_TGTS+= _includes _libraries
809 .if !defined(NO_DEPEND)
812 WMAKE_TGTS+= everything
813 .if defined(LIB32TMP) && ${MK_LIB32} != "no" && empty(SUBDIR_OVERRIDE)
817 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
818 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
821 @echo "--------------------------------------------------------------"
822 @echo ">>> World build started on `LC_ALL=C date`"
823 @echo "--------------------------------------------------------------"
827 @echo "--------------------------------------------------------------"
828 @echo ">>> World build completed on `LC_ALL=C date`"
829 @echo "--------------------------------------------------------------"
832 # We need to have this as a target because the indirection between Makefile
833 # and Makefile.inc1 causes the correct PATH to be used, rather than a
834 # modification of the current environment's PATH. In addition, we need
835 # to quote multiword values.
838 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
840 .if ${.TARGETS:Mbuildenv}
841 .if ${.MAKEFLAGS:M-j}
842 .error The buildenv target is incompatible with -j
845 BUILDENV_DIR?= ${.CURDIR}
847 @echo Entering world for ${TARGET_ARCH}:${TARGET}
848 .if ${BUILDENV_SHELL:M*zsh*}
849 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
851 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
854 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
855 toolchain: ${TOOLCHAIN_TGTS}
856 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
861 # Checks to be sure system is ready for installworld/installkernel.
863 installcheck: _installcheck_world _installcheck_kernel
865 _installcheck_kernel:
868 # Require DESTDIR to be set if installing for a different architecture or
869 # using the user/group database in the source tree.
871 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
873 .if !make(distributeworld)
874 _installcheck_world: __installcheck_DESTDIR
875 _installcheck_kernel: __installcheck_DESTDIR
876 __installcheck_DESTDIR:
877 .if !defined(DESTDIR) || empty(DESTDIR)
878 @echo "ERROR: Please set DESTDIR!"; \
884 .if !defined(DB_FROM_SRC)
886 # Check for missing UIDs/GIDs.
888 CHECK_UIDS= auditdistd
890 .if ${MK_SENDMAIL} != "no"
896 CHECK_GIDS+= proxy authpf
898 .if ${MK_UNBOUND} != "no"
902 _installcheck_world: __installcheck_UGID
904 .for uid in ${CHECK_UIDS}
905 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
906 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
910 .for gid in ${CHECK_GIDS}
911 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
912 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
919 # Required install tools to be saved in a scratch dir for safety.
921 .if ${MK_ZONEINFO} != "no"
922 _zoneinfo= zic tzsetup
925 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
926 date echo egrep find grep id install ${_install-info} \
927 ln make mkdir mtree mv pwd_mkdb \
928 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
931 # Needed for share/man
932 .if ${MK_MAN} != "no"
939 # Distributes everything compiled by a `buildworld'.
943 # Installs everything compiled by a 'buildworld'.
946 # Non-base distributions produced by the base system
947 EXTRA_DISTRIBUTIONS= doc
948 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
949 EXTRA_DISTRIBUTIONS+= lib32
951 .if ${MK_TESTS} != "no"
952 EXTRA_DISTRIBUTIONS+= tests
956 .if ${MK_DEBUG_FILES} != "no"
957 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
960 MTREE_MAGIC?= mtree 2.0
962 distributeworld installworld stageworld: _installcheck_world
963 mkdir -p ${INSTALLTMP}
964 progs=$$(for prog in ${ITOOLS}; do \
965 if progpath=`which $$prog`; then \
968 echo "Required tool $$prog not found in PATH." >&2; \
972 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
973 while read line; do \
975 if [ "$$2 $$3" != "not found" ]; then \
978 echo "Required library $$1 not found." >&2; \
982 cp $$libs $$progs ${INSTALLTMP}
983 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
985 echo "#${MTREE_MAGIC}" > ${METALOG}
987 .if make(distributeworld)
988 .for dist in ${EXTRA_DISTRIBUTIONS}
989 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
990 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
991 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
992 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
993 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
994 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
995 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
996 .if ${MK_DEBUG_FILES} != "no"
997 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
998 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
1000 .if ${MK_LIB32} != "no"
1001 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
1002 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1003 .if ${MK_DEBUG_FILES} != "no"
1004 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
1005 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
1008 .if ${MK_TESTS} != "no" && ${dist} == "tests"
1009 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
1010 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1011 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
1012 .if ${MK_DEBUG_FILES} != "no"
1013 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1014 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
1017 .if defined(NO_ROOT)
1018 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1019 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1020 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1021 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1022 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1023 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1024 .if ${MK_LIB32} != "no"
1025 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib32.dist | \
1026 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1030 -mkdir ${DESTDIR}/${DISTDIR}/base
1031 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1032 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1033 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1034 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1036 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1037 ${IMAKEENV} rm -rf ${INSTALLTMP}
1038 .if make(distributeworld)
1039 .for dist in ${EXTRA_DISTRIBUTIONS}
1040 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
1042 .if defined(NO_ROOT)
1043 .for dist in base ${EXTRA_DISTRIBUTIONS}
1044 @# For each file that exists in this dist, print the corresponding
1045 @# line from the METALOG. This relies on the fact that
1046 @# a line containing only the filename will sort immediatly before
1047 @# the relevant mtree line.
1048 cd ${DESTDIR}/${DISTDIR}; \
1049 find ./${dist} | sort -u ${METALOG} - | \
1050 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1051 ${DESTDIR}/${DISTDIR}/${dist}.meta
1053 .for dist in ${DEBUG_DISTRIBUTIONS}
1054 @# For each file that exists in this dist, print the corresponding
1055 @# line from the METALOG. This relies on the fact that
1056 @# a line containing only the filename will sort immediatly before
1057 @# the relevant mtree line.
1058 cd ${DESTDIR}/${DISTDIR}; \
1059 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1060 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1061 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1067 .for dist in base ${EXTRA_DISTRIBUTIONS}
1068 .if defined(NO_ROOT)
1069 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1070 tar cvf - --exclude usr/lib/debug \
1071 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1072 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1074 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1075 tar cvf - --exclude usr/lib/debug . | \
1076 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1080 .for dist in ${DEBUG_DISTRIBUTIONS}
1081 . if defined(NO_ROOT)
1082 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1083 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1084 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1086 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1087 tar cvLf - usr/lib/debug | \
1088 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1095 # If you have a build server, you can NFS mount the source and obj directories
1096 # and do a 'make reinstall' on the *client* to install new binaries from the
1097 # most recent server build.
1099 reinstall: .MAKE .PHONY
1100 @echo "--------------------------------------------------------------"
1101 @echo ">>> Making hierarchy"
1102 @echo "--------------------------------------------------------------"
1103 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1104 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1106 @echo "--------------------------------------------------------------"
1107 @echo ">>> Installing everything"
1108 @echo "--------------------------------------------------------------"
1109 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1110 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
1111 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
1114 restage: .MAKE .PHONY
1115 @echo "--------------------------------------------------------------"
1116 @echo ">>> Making hierarchy"
1117 @echo "--------------------------------------------------------------"
1118 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1119 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy distribution
1121 @echo "--------------------------------------------------------------"
1122 @echo ">>> Installing everything"
1123 @echo "--------------------------------------------------------------"
1124 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1125 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
1126 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
1129 redistribute: .MAKE .PHONY
1130 @echo "--------------------------------------------------------------"
1131 @echo ">>> Distributing everything"
1132 @echo "--------------------------------------------------------------"
1133 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1134 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
1135 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
1139 distrib-dirs distribution: .MAKE .PHONY
1140 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1141 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1142 .if make(distribution)
1143 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1144 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1145 METALOG=${METALOG} MK_TESTS=no installconfig
1149 # buildkernel and installkernel
1151 # Which kernels to build and/or install is specified by setting
1152 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1153 # Only the existing (depending TARGET) config files are used
1154 # for building kernels and only the first of these is designated
1155 # as the one being installed.
1157 # Note that we have to use TARGET instead of TARGET_ARCH when
1158 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1159 # be set to cross-build, we have to make sure TARGET is set
1162 .if defined(KERNFAST)
1167 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1168 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1169 KERNCONF=${KERNFAST}
1172 .if ${TARGET_ARCH} == "powerpc64"
1173 KERNCONF?= GENERIC64
1177 INSTKERNNAME?= kernel
1179 KERNSRCDIR?= ${.CURDIR}/sys
1180 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1181 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1182 KERNCONFDIR?= ${KRNLCONFDIR}
1186 .if defined(NO_INSTALLKERNEL)
1187 # All of the BUILDKERNELS loops start at index 1.
1188 BUILDKERNELS+= dummy
1190 .for _kernel in ${KERNCONF}
1191 .if exists(${KERNCONFDIR}/${_kernel})
1192 BUILDKERNELS+= ${_kernel}
1193 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1194 INSTALLKERNEL= ${_kernel}
1199 ${WMAKE_TGTS:N_worldtmp:Nbuild32} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1204 # Builds all kernels defined by BUILDKERNELS.
1206 buildkernel: .MAKE .PHONY
1207 .if empty(BUILDKERNELS:Ndummy)
1208 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1212 .for _kernel in ${BUILDKERNELS:Ndummy}
1213 @echo "--------------------------------------------------------------"
1214 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1215 @echo "--------------------------------------------------------------"
1216 @echo "===> ${_kernel}"
1217 mkdir -p ${KRNLOBJDIR}
1218 .if !defined(NO_KERNELCONFIG)
1220 @echo "--------------------------------------------------------------"
1221 @echo ">>> stage 1: configuring the kernel"
1222 @echo "--------------------------------------------------------------"
1223 cd ${KRNLCONFDIR}; \
1225 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1226 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1228 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1230 @echo "--------------------------------------------------------------"
1231 @echo ">>> stage 2.1: cleaning up the object tree"
1232 @echo "--------------------------------------------------------------"
1233 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1235 .if !defined(NO_KERNELOBJ)
1237 @echo "--------------------------------------------------------------"
1238 @echo ">>> stage 2.2: rebuilding the object tree"
1239 @echo "--------------------------------------------------------------"
1240 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1243 @echo "--------------------------------------------------------------"
1244 @echo ">>> stage 2.3: build tools"
1245 @echo "--------------------------------------------------------------"
1246 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1247 .if !defined(NO_KERNELDEPEND)
1249 @echo "--------------------------------------------------------------"
1250 @echo ">>> stage 3.1: making dependencies"
1251 @echo "--------------------------------------------------------------"
1252 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
1255 @echo "--------------------------------------------------------------"
1256 @echo ">>> stage 3.2: building everything"
1257 @echo "--------------------------------------------------------------"
1258 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1259 @echo "--------------------------------------------------------------"
1260 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1261 @echo "--------------------------------------------------------------"
1265 # installkernel, etc.
1267 # Install the kernel defined by INSTALLKERNEL
1269 installkernel installkernel.debug \
1270 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1271 .if !defined(NO_INSTALLKERNEL)
1272 .if empty(INSTALLKERNEL)
1273 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1276 @echo "--------------------------------------------------------------"
1277 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1278 @echo "--------------------------------------------------------------"
1279 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1280 ${CROSSENV} PATH=${TMPPATH} \
1281 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1283 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1284 .for _kernel in ${BUILDKERNELS:[2..-1]}
1285 @echo "--------------------------------------------------------------"
1286 @echo ">>> Installing kernel ${_kernel}"
1287 @echo "--------------------------------------------------------------"
1288 cd ${KRNLOBJDIR}/${_kernel}; \
1289 ${CROSSENV} PATH=${TMPPATH} \
1290 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1294 distributekernel distributekernel.debug:
1295 .if !defined(NO_INSTALLKERNEL)
1296 .if empty(INSTALLKERNEL)
1297 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1300 mkdir -p ${DESTDIR}/${DISTDIR}
1301 .if defined(NO_ROOT)
1302 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1304 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1305 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1306 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1307 DESTDIR=${INSTALL_DDIR}/kernel \
1308 ${.TARGET:S/distributekernel/install/}
1309 .if defined(NO_ROOT)
1310 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1311 ${DESTDIR}/${DISTDIR}/kernel.meta
1314 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1315 .for _kernel in ${BUILDKERNELS:[2..-1]}
1316 .if defined(NO_ROOT)
1317 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1319 cd ${KRNLOBJDIR}/${_kernel}; \
1320 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1321 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1322 KERNEL=${INSTKERNNAME}.${_kernel} \
1323 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1324 ${.TARGET:S/distributekernel/install/}
1325 .if defined(NO_ROOT)
1326 @sed -e "s|^./kernel.${_kernel}|.|" \
1327 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1328 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1334 .if defined(NO_ROOT)
1335 .if !defined(NO_INSTALLKERNEL)
1336 cd ${DESTDIR}/${DISTDIR}/kernel; \
1337 tar cvf - --exclude '*.debug' \
1338 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1339 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1341 cd ${DESTDIR}/${DISTDIR}/kernel; \
1342 tar cvf - --include '*/*/*.debug' \
1343 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1344 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1345 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1346 .for _kernel in ${BUILDKERNELS:[2..-1]}
1347 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1348 tar cvf - --exclude '*.debug' \
1349 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1350 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1351 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1352 tar cvf - --include '*/*/*.debug' \
1353 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1354 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1358 .if !defined(NO_INSTALLKERNEL)
1359 cd ${DESTDIR}/${DISTDIR}/kernel; \
1360 tar cvf - --exclude '*.debug' . | \
1361 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1363 cd ${DESTDIR}/${DISTDIR}/kernel; \
1364 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1365 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1366 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1367 .for _kernel in ${BUILDKERNELS:[2..-1]}
1368 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1369 tar cvf - --exclude '*.debug' . | \
1370 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1371 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1372 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1373 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1379 ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1381 PORTSDIR?= /usr/ports
1382 WSTAGEDIR= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/worldstage
1383 KSTAGEDIR= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/kernelstage
1384 REPODIR= ${MAKEOBJDIRPREFIX}${.CURDIR}/repo
1385 PKGSIGNKEY?= # empty
1388 .if !exists(${LOCALBASE}/sbin/pkg)
1389 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1393 ${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1396 rm -rf /tmp/ports.${TARGET} || :
1397 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${REVISION} \
1398 PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} WSTAGEDIR=${WSTAGEDIR} \
1399 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1401 real-packages: stage-packages create-packages sign-packages
1404 @mkdir -p ${WSTAGEDIR} ${KSTAGEDIR}
1405 ${_+_}@cd ${.CURDIR}; \
1406 ${MAKE} DESTDIR=${DESTDIR:U${WSTAGEDIR}} -DNO_ROOT -B stageworld ; \
1407 ${MAKE} DESTDIR=${DESTDIR:U${KSTAGEDIR}} -DNO_ROOT -B stagekernel
1409 create-packages: _pkgbootstrap
1410 @mkdir -p ${REPODIR}
1411 ${_+_}@cd ${.CURDIR}; \
1412 ${MAKE} DESTDIR=${DESTDIR:U${WSTAGEDIR}} \
1413 PKG_VERSION=${PKG_VERSION} create-world-packages ; \
1414 ${MAKE} DESTDIR=${DESTDIR:U${KSTAGEDIR}} \
1415 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1416 create-kernel-packages
1418 create-world-packages: _pkgbootstrap
1419 @rm -f ${DESTDIR}/*.plist 2>/dev/null || :
1421 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1423 @for plist in ${DESTDIR}/*.plist; do \
1424 plist=$${plist##*/} ; \
1425 pkgname=$${plist%.plist} ; \
1426 sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \
1427 -s ${SRCDIR} -u ${DESTDIR}/$${pkgname}.ucl ; \
1429 @for plist in ${DESTDIR}/*.plist; do \
1430 plist=$${plist##*/} ; \
1431 pkgname=$${plist%.plist} ; \
1433 /^name/ { printf("===> Creating %s-", $$2); next } \
1434 /^version/ { print $$2; next } \
1435 ' ${DESTDIR}/$${pkgname}.ucl ; \
1436 pkg -o ABI_FILE=${DESTDIR}/bin/sh \
1437 create -M ${DESTDIR}/$${pkgname}.ucl \
1438 -p ${DESTDIR}/$${pkgname}.plist \
1440 -o ${REPODIR}/$$(pkg -o ABI_FILE=${DESTDIR}/bin/sh config ABI)/${PKG_VERSION} ; \
1443 create-kernel-packages: _pkgbootstrap
1444 .if exists(${DESTDIR}/kernel.meta)
1445 .for flavor in release debug
1446 @cd ${DESTDIR}/${DISTDIR} ; \
1447 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1448 -v kernel=yes -v _kernconf=${INSTALLKERNEL} \
1449 ${DESTDIR}/kernel.meta ; \
1450 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1451 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1452 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1453 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}-${flavor}/" \
1454 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1455 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1456 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1457 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1458 ${SRCDIR}/release/packages/kernel.ucl \
1459 > ${DESTDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}-${flavor}.ucl ; \
1461 /name/ { printf("===> Creating %s-", $$2); next } \
1462 /version/ {print $$2; next } ' \
1463 ${DESTDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}-${flavor}.ucl ; \
1464 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh \
1465 create -M ${DESTDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}-${flavor}.ucl \
1466 -p ${DESTDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}-${flavor}.plist \
1467 -r ${DESTDIR}/${DISTDIR} \
1468 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1471 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1472 .for _kernel in ${BUILDKERNELS:[2..-1]}
1473 .if exists(${DESTDIR}/kernel.${_kernel}.meta)
1474 .for flavor in release debug
1475 @cd ${DESTDIR}/kernel.${_kernel} ; \
1476 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1477 -v kernel=yes -v _kernconf=${_kernel} \
1478 ${DESTDIR}/kernel.${_kernel}.meta ; \
1479 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1480 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1481 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1482 -e "s/%PKGNAME%/kernel-${_kernel:tl}-${flavor}/" \
1483 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1484 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1485 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1486 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1487 ${SRCDIR}/release/packages/kernel.ucl \
1488 > ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}-${flavor}.ucl ; \
1490 /name/ { printf("===> Creating %s-", $$2); next } \
1491 /version/ {print $$2; next } ' \
1492 ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}-${flavor}.ucl ; \
1493 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh \
1494 create -M ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}-${flavor}.ucl \
1495 -p ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}-${flavor}.plist \
1496 -r ${DESTDIR}/kernel.${_kernel} \
1497 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1503 sign-packages: _pkgbootstrap
1504 @[ -L "${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1505 unlink ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1506 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1507 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1508 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1510 ln -s ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1511 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest
1517 # Run test suite on installed world.
1520 @if [ ! -x ${LOCALBASE}/bin/kyua ]; then \
1521 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1524 ${_+_}${LOCALBASE}/bin/kyua test -k ${TESTSBASE}/Kyuafile
1530 # Build the API documentation with doxygen
1533 @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1534 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1537 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1542 # Update the source tree(s), by running svn/svnup to update to the
1546 .if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1547 @echo "--------------------------------------------------------------"
1548 @echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1549 @echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1550 @echo "--------------------------------------------------------------"
1553 .if defined(SVN_UPDATE)
1554 @echo "--------------------------------------------------------------"
1555 @echo ">>> Updating ${.CURDIR} using Subversion"
1556 @echo "--------------------------------------------------------------"
1557 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1561 # ------------------------------------------------------------------------
1563 # From here onwards are utility targets used by the 'make world' and
1564 # related targets. If your 'world' breaks, you may like to try to fix
1565 # the problem and manually run the following targets to attempt to
1566 # complete the build. Beware, this is *not* guaranteed to work, you
1567 # need to have a pretty good grip on the current state of the system
1568 # to attempt to manually finish it. If in doubt, 'make world' again.
1572 # legacy: Build compatibility shims for the next three targets. This is a
1573 # minimal set of tools and shims necessary to compensate for older systems
1574 # which don't have the APIs required by the targets built in bootstrap-tools,
1575 # build-tools or cross-tools.
1578 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1579 .if ${BOOTSTRAPPING} < 1100006
1580 _elftoolchain_libs= lib/libelf lib/libdwarf
1584 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1585 @echo "ERROR: Source upgrades from versions prior to 8.0 are not supported."; \
1588 .for _tool in tools/build ${_elftoolchain_libs}
1589 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1590 cd ${.CURDIR}/${_tool}; \
1591 ${MAKE} DIRPRFX=${_tool}/ obj; \
1592 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1593 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1594 ${MAKE} DIRPRFX=${_tool}/ all; \
1595 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1599 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1600 # are built to build other binaries in the system. However, the focus of these
1601 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1602 # libraries, augmented by -legacy.
1604 _bt= _bootstrap-tools
1606 .if ${MK_GAMES} != "no"
1607 _strfile= usr.bin/fortune/strfile
1610 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1611 _gperf= gnu/usr.bin/gperf
1614 .if ${MK_GROFF} != "no"
1615 _groff= gnu/usr.bin/groff \
1619 .if ${MK_VT} != "no"
1620 _vtfontcvt= usr.bin/vtfontcvt
1623 .if ${BOOTSTRAPPING} < 900002
1627 .if ${BOOTSTRAPPING} < 1000033
1628 _libopenbsd= lib/libopenbsd
1632 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1633 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1636 .if ${BOOTSTRAPPING} < 1000026
1637 _nmtree= lib/libnetbsd \
1640 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1643 .if ${BOOTSTRAPPING} < 1000027
1647 # r277259 crunchide: Correct 64-bit section header offset
1648 # r281674 crunchide: always include both 32- and 64-bit ELF support
1649 # r285986 crunchen: use STRIPBIN rather than STRIP
1650 .if ${BOOTSTRAPPING} < 1100078
1651 _crunch= usr.sbin/crunch
1654 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1661 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1663 .if ${MK_BSNMP} != "no"
1664 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1667 # We need to build tblgen when we're building clang either as
1668 # the bootstrap compiler, or as the part of the normal build.
1669 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1671 lib/clang/libllvmsupport \
1672 lib/clang/libllvmtablegen \
1673 usr.bin/clang/tblgen \
1674 usr.bin/clang/clang-tblgen
1676 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1677 ${_bt}-usr.bin/clang/tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1680 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1683 .if ${MK_GPL_DTC} != "no"
1684 _dtc= gnu/usr.bin/dtc
1687 .if ${MK_KERBEROS} != "no"
1688 _kerberos5_bootstrap_tools= \
1689 kerberos5/tools/make-roken \
1690 kerberos5/lib/libroken \
1691 kerberos5/lib/libvers \
1692 kerberos5/tools/asn1_compile \
1693 kerberos5/tools/slc \
1696 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1699 .if ${MK_MANDOCDB} != "no"
1700 _libopenbsd?= lib/libopenbsd
1701 _makewhatis= lib/libsqlite3 \
1703 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1705 _makewhatis=usr.bin/makewhatis
1708 bootstrap-tools: .PHONY
1710 # Please document (add comment) why something is in 'bootstrap-tools'.
1711 # Try to bound the building of the bootstrap-tool to just the
1712 # FreeBSD versions that need the tool built at this stage of the build.
1715 ${_kerberos5_bootstrap_tools} \
1737 ${_bt}-${_tool}: .PHONY .MAKE
1738 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1739 cd ${.CURDIR}/${_tool}; \
1740 ${MAKE} DIRPRFX=${_tool}/ obj; \
1741 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1742 ${MAKE} DIRPRFX=${_tool}/ all; \
1743 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1745 bootstrap-tools: ${_bt}-${_tool}
1749 # build-tools: Build special purpose build tools
1751 .if !defined(NO_SHARE)
1752 _share= share/syscons/scrnmaps
1755 .if ${MK_GCC} != "no"
1756 _gcc_tools= gnu/usr.bin/cc/cc_tools
1759 .if ${MK_RESCUE} != "no"
1760 # rescue includes programs that have build-tools targets
1761 _rescue=rescue/rescue
1767 ${LOCAL_TOOL_DIRS} \
1768 lib/ncurses/ncurses \
1769 lib/ncurses/ncursesw \
1774 usr.bin/mkesdb_static \
1775 usr.bin/mkcsmapper_static \
1777 build-tools_${_tool}: .PHONY
1778 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1779 cd ${.CURDIR}/${_tool}; \
1780 ${MAKE} DIRPRFX=${_tool}/ obj; \
1781 ${MAKE} DIRPRFX=${_tool}/ build-tools
1782 build-tools: build-tools_${_tool}
1786 build-tools_${_tool}: .PHONY
1787 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1788 cd ${.CURDIR}/${_tool}; \
1789 ${MAKE} DIRPRFX=${_tool}/ obj; \
1790 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1791 ${MAKE} DIRPRFX=${_tool}/ all
1792 build-tools: build-tools_${_tool}
1796 # kernel-tools: Build kernel-building tools
1799 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1800 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1801 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1804 # cross-tools: All the tools needed to build the rest of the system after
1805 # we get done with the earlier stages. It is the last set of tools needed
1806 # to begin building the target binaries.
1808 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1809 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1810 _btxld= usr.sbin/btxld
1814 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1815 # resulting from missing bug fixes or ELF Toolchain updates.
1816 .if ${MK_CDDL} != "no"
1817 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1818 cddl/usr.bin/ctfmerge
1821 # If we're given an XAS, don't build binutils.
1822 .if ${XAS:M/*} == ""
1823 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1824 _binutils= gnu/usr.bin/binutils
1826 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1827 _elftctools= lib/libelftc \
1833 # These are not required by the build, but can be useful for developers who
1834 # cross-build on a FreeBSD 10 host:
1835 _elftctools+= usr.bin/addr2line
1837 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1838 # If cross-building with an external binutils we still need to build strip for
1839 # the target (for at least crunchide).
1840 _elftctools= lib/libelftc \
1845 # If an full path to an external cross compiler is given, don't build
1847 .if ${XCC:N${CCACHE_BIN}:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1848 .if ${MK_CLANG_BOOTSTRAP} != "no"
1849 _clang= usr.bin/clang
1850 _clang_libs= lib/clang
1852 .if ${MK_GCC_BOOTSTRAP} != "no"
1856 .if ${MK_USB} != "no"
1857 _usb_tools= sys/boot/usb/tools
1860 cross-tools: .MAKE .PHONY
1871 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1872 cd ${.CURDIR}/${_tool}; \
1873 ${MAKE} DIRPRFX=${_tool}/ obj; \
1874 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1875 ${MAKE} DIRPRFX=${_tool}/ all; \
1876 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1879 NXBDESTDIR= ${OBJTREE}/nxb-bin
1880 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1881 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1882 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1883 NXBMAKE= ${NXBENV} ${MAKE} \
1884 TBLGEN=${NXBDESTDIR}/usr/bin/tblgen \
1885 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1886 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1887 MK_GDB=no MK_TESTS=no \
1889 MK_HTML=no NO_LINT=yes MK_MAN=no \
1890 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1891 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1892 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1893 MK_LLDB=no MK_DEBUG_FILES=no
1895 # native-xtools is the current target for qemu-user cross builds of ports
1896 # via poudriere and the imgact_binmisc kernel module.
1897 # For non-clang enabled targets that are still using the in tree gcc
1898 # we must build a gperf binary for one instance of its Makefiles. On
1899 # clang-enabled systems, the gperf binary is obsolete.
1900 native-xtools: .PHONY
1901 .if ${MK_GCC_BOOTSTRAP} != "no"
1902 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1903 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,depend,all,install)"; \
1904 cd ${.CURDIR}/${_gperf}; \
1905 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1906 if [ -z "${NO_DEPEND}" ]; then ${NXBMAKE} DIRPRFX=${_gperf}/ depend; fi; \
1907 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1908 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1910 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1911 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1912 -p ${NXBDESTDIR}/usr >/dev/null
1913 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1914 -p ${NXBDESTDIR}/usr/include >/dev/null
1915 .if ${MK_DEBUG_FILES} != "no"
1916 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1917 -p ${NXBDESTDIR}/usr/lib >/dev/null
1978 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1979 cd ${.CURDIR}/${_tool}; \
1980 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1981 if [ -z "${NO_DEPEND}" ]; then ${NXBMAKE} DIRPRFX=${_tool}/ depend; fi; \
1982 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1983 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1987 # hierarchy - ensure that all the needed directories are present
1989 hierarchy hier: .MAKE .PHONY
1990 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1993 # libraries - build all libraries, and install them under ${DESTDIR}.
1995 # The list of libraries with dependents (${_prebuild_libs}) and their
1996 # interdependencies (__L) are built automatically by the
1997 # ${.CURDIR}/tools/make_libdeps.sh script.
1999 libraries: .MAKE .PHONY
2000 ${_+_}cd ${.CURDIR}; \
2001 ${MAKE} -f Makefile.inc1 _prereq_libs; \
2002 ${MAKE} -f Makefile.inc1 _startup_libs; \
2003 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
2004 ${MAKE} -f Makefile.inc1 _generic_libs
2007 # static libgcc.a prerequisite for shared libc
2009 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
2011 # These dependencies are not automatically generated:
2013 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
2014 # all shared libraries for ELF.
2016 _startup_libs= gnu/lib/csu
2017 _startup_libs+= lib/csu
2018 _startup_libs+= gnu/lib/libgcc
2019 _startup_libs+= lib/libcompiler_rt
2020 _startup_libs+= lib/libc
2021 _startup_libs+= lib/libc_nonshared
2022 .if ${MK_LIBCPLUSPLUS} != "no"
2023 _startup_libs+= lib/libcxxrt
2026 gnu/lib/libgcc__L: lib/libc__L
2027 gnu/lib/libgcc__L: lib/libc_nonshared__L
2028 .if ${MK_LIBCPLUSPLUS} != "no"
2029 lib/libcxxrt__L: gnu/lib/libgcc__L
2032 _prebuild_libs= ${_kerberos5_lib_libasn1} \
2033 ${_kerberos5_lib_libhdb} \
2034 ${_kerberos5_lib_libheimbase} \
2035 ${_kerberos5_lib_libheimntlm} \
2037 ${_kerberos5_lib_libheimipcc} \
2038 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
2039 ${_kerberos5_lib_libroken} \
2040 ${_kerberos5_lib_libwind} \
2041 lib/libbz2 ${_libcom_err} lib/libcrypt \
2042 lib/libelf lib/libexpat \
2045 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
2047 lib/ncurses/ncurses lib/ncurses/ncursesw \
2048 lib/libopie lib/libpam ${_lib_libthr} \
2049 ${_lib_libradius} lib/libsbuf lib/libtacplus \
2051 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
2052 ${_cddl_lib_libuutil} \
2053 ${_cddl_lib_libavl} \
2054 ${_cddl_lib_libzfs_core} \
2055 ${_cddl_lib_libctf} \
2056 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
2057 ${_secure_lib_libcrypto} ${_lib_libldns} \
2058 ${_secure_lib_libssh} ${_secure_lib_libssl} \
2060 .if ${MK_GNUCXX} != "no"
2061 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
2062 gnu/lib/libstdc++__L: lib/msun__L
2063 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
2066 .if ${MK_LIBCPLUSPLUS} != "no"
2067 _prebuild_libs+= lib/libc++
2070 lib/libgeom__L: lib/libexpat__L
2071 lib/libkvm__L: lib/libelf__L
2073 .if ${MK_LIBTHR} != "no"
2074 _lib_libthr= lib/libthr
2077 .if ${MK_RADIUS_SUPPORT} != "no"
2078 _lib_libradius= lib/libradius
2081 .if ${MK_OFED} != "no"
2082 _ofed_lib= contrib/ofed/usr.lib/
2085 .if ${MK_CASPER} != "no"
2086 _lib_casper= lib/libcasper
2089 lib/libpjdlog__L: lib/libutil__L
2090 lib/libcasper__L: lib/libnv__L
2091 lib/liblzma__L: lib/libthr__L
2093 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
2094 .for _DIR in ${LOCAL_LIB_DIRS}
2095 .if exists(${.CURDIR}/${_DIR}/Makefile)
2096 _generic_libs+= ${_DIR}
2100 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2102 .if ${MK_CDDL} != "no"
2103 _cddl_lib_libumem= cddl/lib/libumem
2104 _cddl_lib_libnvpair= cddl/lib/libnvpair
2105 _cddl_lib_libavl= cddl/lib/libavl
2106 _cddl_lib_libuutil= cddl/lib/libuutil
2107 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2108 _cddl_lib_libctf= cddl/lib/libctf
2110 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2111 cddl/lib/libzfs__L: lib/libgeom__L
2112 cddl/lib/libctf__L: lib/libz__L
2114 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
2115 # on select architectures though (see cddl/lib/Makefile)
2116 .if ${MACHINE_CPUARCH} != "sparc64"
2117 _prebuild_libs+= lib/libproc lib/librtld_db
2120 .if ${MK_CRYPT} != "no"
2121 .if ${MK_OPENSSL} != "no"
2122 _secure_lib_libcrypto= secure/lib/libcrypto
2123 _secure_lib_libssl= secure/lib/libssl
2124 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2125 .if ${MK_LDNS} != "no"
2126 _lib_libldns= lib/libldns
2127 lib/libldns__L: secure/lib/libcrypto__L
2129 .if ${MK_OPENSSH} != "no"
2130 _secure_lib_libssh= secure/lib/libssh
2131 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2132 .if ${MK_LDNS} != "no"
2133 secure/lib/libssh__L: lib/libldns__L
2135 .if ${MK_KERBEROS_SUPPORT} != "no"
2136 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2137 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2138 lib/libmd__L kerberos5/lib/libroken__L
2142 _secure_lib= secure/lib
2145 .if ${MK_KERBEROS} != "no"
2146 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2147 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2148 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2149 kerberos5/lib/libwind__L lib/libsqlite3__L
2150 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2151 kerberos5/lib/libroken__L lib/libcom_err__L
2152 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2153 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2154 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2155 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2156 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2157 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2158 kerberos5/lib/libroken__L: lib/libcrypt__L
2159 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2160 kerberos5/lib/libheimbase__L: lib/libthr__L
2161 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2164 lib/libsqlite3__L: lib/libthr__L
2166 .if ${MK_GSSAPI} != "no"
2167 _lib_libgssapi= lib/libgssapi
2170 .if ${MK_KERBEROS} != "no"
2171 _kerberos5_lib= kerberos5/lib
2172 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2173 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2174 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2175 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2176 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2177 _kerberos5_lib_libroken= kerberos5/lib/libroken
2178 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2179 _libsqlite3= lib/libsqlite3
2180 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2181 _kerberos5_lib_libwind= kerberos5/lib/libwind
2182 _libcom_err= lib/libcom_err
2185 .if ${MK_NIS} != "no"
2186 _lib_libypclnt= lib/libypclnt
2189 .if ${MK_OPENSSL} == "no"
2190 lib/libradius__L: lib/libmd__L
2194 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2195 .if ${MK_CXX} != "no"
2196 .if ${MK_LIBCPLUSPLUS} != "no"
2197 lib/libproc__L: lib/libcxxrt__L
2198 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2199 lib/libproc__L: gnu/lib/libsupc++__L
2203 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2205 .for _lib in ${_prereq_libs}
2206 ${_lib}__PL: .PHONY .MAKE
2207 .if exists(${.CURDIR}/${_lib})
2208 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2209 cd ${.CURDIR}/${_lib}; \
2210 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2211 if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; fi; \
2212 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2213 DIRPRFX=${_lib}/ all; \
2214 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2215 DIRPRFX=${_lib}/ install
2219 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
2220 ${_lib}__L: .PHONY .MAKE
2221 .if exists(${.CURDIR}/${_lib})
2222 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2223 cd ${.CURDIR}/${_lib}; \
2224 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2225 if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; fi; \
2226 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2227 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2231 # libpam is special: we need to build static PAM modules before
2232 # static PAM library, and dynamic PAM library before dynamic PAM
2234 lib/libpam__L: .PHONY .MAKE
2235 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
2236 cd ${.CURDIR}/lib/libpam; \
2237 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj; \
2238 if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ depend; fi; \
2239 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2240 -D_NO_LIBPAM_SO_YET all; \
2241 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2242 -D_NO_LIBPAM_SO_YET install
2244 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2245 _startup_libs: ${_startup_libs:S/$/__L/}
2246 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2247 _generic_libs: ${_generic_libs:S/$/__L/}
2249 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2250 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2251 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2252 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2253 # parallel. This is safe for the world stage of buildworld though since it has
2254 # already built libraries in a proper order and installed includes into
2255 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2256 # avoid trashing a system if it crashes mid-install.
2257 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2261 .include <bsd.subdir.mk>
2263 .if make(check-old) || make(check-old-dirs) || \
2264 make(check-old-files) || make(check-old-libs) || \
2265 make(delete-old) || make(delete-old-dirs) || \
2266 make(delete-old-files) || make(delete-old-libs)
2269 # check for / delete old files section
2272 .include "ObsoleteFiles.inc"
2274 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2275 else you can not start such an application. Consult UPDATING for more \
2276 information regarding how to cope with the removal/revision bump of a \
2279 .if !defined(BATCH_DELETE_OLD_FILES)
2286 @echo ">>> Removing old files (only deletes safe to delete libs)"
2287 # Ask for every old file if the user really wants to remove it.
2288 # It's annoying, but better safe than sorry.
2289 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2290 # argument list will get too long. Using .for/.endfor make "loops" will make
2291 # the Makefile parser segfault.
2294 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2295 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2296 while read file; do \
2297 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2298 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2299 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2301 for ext in debug symbols; do \
2302 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2303 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2304 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2309 # Remove catpages without corresponding manpages.
2311 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2312 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2313 while read catpage; do \
2315 if [ ! -e "$${manpage}" ]; then \
2316 rm ${RM_I} $${catpage} <&3; \
2319 @echo ">>> Old files removed"
2322 @echo ">>> Checking for old files"
2324 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2325 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2326 while read file; do \
2327 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2328 echo "${DESTDIR}/$${file}"; \
2330 for ext in debug symbols; do \
2331 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2332 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2336 # Check for catpages without corresponding manpages.
2337 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2338 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2339 while read catpage; do \
2341 if [ ! -e "$${manpage}" ]; then \
2347 @echo ">>> Removing old libraries"
2348 @echo "${OLD_LIBS_MESSAGE}" | fmt
2351 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2352 -V OLD_LIBS | xargs -n1 | \
2353 while read file; do \
2354 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2355 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2356 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2358 for ext in debug symbols; do \
2359 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2360 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2361 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2366 @echo ">>> Old libraries removed"
2369 @echo ">>> Checking for old libraries"
2371 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2372 -V OLD_LIBS | xargs -n1 | \
2373 while read file; do \
2374 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2375 echo "${DESTDIR}/$${file}"; \
2377 for ext in debug symbols; do \
2378 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2379 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2385 @echo ">>> Removing old directories"
2387 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2388 -V OLD_DIRS | xargs -n1 | sort -r | \
2389 while read dir; do \
2390 if [ -d "${DESTDIR}/$${dir}" ]; then \
2391 rmdir -v "${DESTDIR}/$${dir}" || true; \
2392 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2393 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2396 @echo ">>> Old directories removed"
2399 @echo ">>> Checking for old directories"
2401 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2402 -V OLD_DIRS | xargs -n1 | \
2403 while read dir; do \
2404 if [ -d "${DESTDIR}/$${dir}" ]; then \
2405 echo "${DESTDIR}/$${dir}"; \
2406 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2407 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2411 delete-old: delete-old-files delete-old-dirs
2412 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2414 check-old: check-old-files check-old-libs check-old-dirs
2415 @echo "To remove old files and directories run '${MAKE} delete-old'."
2416 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2421 # showconfig - show build configuration.
2424 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2425 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2427 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2428 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2430 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2431 .if exists(${KERNCONFDIR}/${KERNCONF})
2432 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2433 '${KERNCONFDIR}/${KERNCONF}' ; echo
2439 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2440 DTBOUTPUTPATH= ${.CURDIR}
2444 # Build 'standalone' Device Tree Blob
2447 @PATH=${TMPPATH} MACHINE=${TARGET} \
2448 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2449 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2454 # In the following, the first 'rm' in a series will usually remove all
2455 # files and directories. If it does not, then there are probably some
2456 # files with file flags set, so this unsets them and tries the 'rm' a
2457 # second time. There are situations where this target will be cleaning
2458 # some directories via more than one method, but that duplication is
2459 # needed to correctly handle all the possible situations. Removing all
2460 # files without file flags set in the first 'rm' instance saves time,
2461 # because 'chflags' will need to operate on fewer files afterwards.
2463 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2464 # created by bsd.obj.mk, except that we don't want to .include that file
2467 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2469 .if exists(${BW_CANONICALOBJDIR}/)
2470 -rm -rf ${BW_CANONICALOBJDIR}/*
2471 -chflags -R 0 ${BW_CANONICALOBJDIR}
2472 rm -rf ${BW_CANONICALOBJDIR}/*
2474 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2475 # To be safe in this case, fall back to a 'make cleandir'
2476 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2479 .if defined(TARGET) && defined(TARGET_ARCH)
2481 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2482 XDEV_CPUTYPE?=${CPUTYPE}
2484 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2487 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2488 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2489 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2490 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2491 CPUTYPE=${XDEV_CPUTYPE}
2493 XDDIR=${TARGET_ARCH}-freebsd
2496 .error XDTP variable should be an absolute path
2499 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2500 INSTALL="sh ${.CURDIR}/tools/install.sh"
2502 TOOLS_PREFIX=${XDTP}
2503 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2504 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2505 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2506 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2507 CPP="${CPP} ${CD2CFLAGS}" \
2508 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2510 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2511 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2512 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2513 XDDESTDIR=${DESTDIR}/${XDTP}
2515 OSREL!= uname -r | sed -e 's/[-(].*//'
2518 .ORDER: xdev-build xdev-install xdev-links
2519 xdev: xdev-build xdev-install
2521 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2522 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2524 _xb-worldtmp: .PHONY
2525 mkdir -p ${CDTMP}/usr
2526 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2527 -p ${CDTMP}/usr >/dev/null
2529 _xb-bootstrap-tools: .PHONY
2533 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
2534 cd ${.CURDIR}/${_tool}; \
2535 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2536 if [ -z "${NO_DEPEND}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ depend; fi; \
2537 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2538 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2541 _xb-build-tools: .PHONY
2542 ${_+_}@cd ${.CURDIR}; \
2543 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2545 _xb-cross-tools: .PHONY
2553 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
2554 cd ${.CURDIR}/${_tool}; \
2555 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2556 if [ -z "${NO_DEPEND}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ depend; fi; \
2557 ${CDMAKE} DIRPRFX=${_tool}/ all
2561 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2562 mkdir -p ${XDDESTDIR}
2563 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2564 -p ${XDDESTDIR} >/dev/null
2565 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2566 -p ${XDDESTDIR}/usr >/dev/null
2567 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2568 -p ${XDDESTDIR}/usr/include >/dev/null
2569 .if ${MK_LIB32} != "no"
2570 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
2571 -p ${XDDESTDIR}/usr >/dev/null
2573 .if ${MK_TESTS} != "no"
2574 mkdir -p ${XDDESTDIR}${TESTSBASE}
2575 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2576 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2579 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2580 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2582 _xi-cross-tools: .PHONY
2583 @echo "_xi-cross-tools"
2591 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2592 cd ${.CURDIR}/${_tool}; \
2593 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2596 _xi-includes: .PHONY
2597 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2598 DESTDIR=${XDDESTDIR}
2600 _xi-libraries: .PHONY
2601 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2602 DESTDIR=${XDDESTDIR}
2605 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2606 mkdir -p ../../../../usr/bin; \
2608 ln -sf ../../${XDTP}/usr/bin/$$i \
2609 ../../../../usr/bin/${XDDIR}-$$i; \
2610 ln -sf ../../${XDTP}/usr/bin/$$i \
2611 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2614 xdev xdev-build xdev-install xdev-links:
2615 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"