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 # doxygen - build API documentation of the kernel
41 # update - convenient way to update your source tree (eg: svn/svnup)
43 # Standard targets (not defined here) are documented in the makefiles in
44 # /usr/share/mk. These include:
45 # obj depend all install clean cleandepend cleanobj
47 .if !defined(TARGET) || !defined(TARGET_ARCH)
48 .error "Both TARGET and TARGET_ARCH must be defined."
51 LOCALBASE?= /usr/local
53 # Cross toolchain changes must be in effect before bsd.compiler.mk
54 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
55 .if defined(CROSS_TOOLCHAIN)
56 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
57 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
59 .include <bsd.compiler.mk> # don't depend on src.opts.mk doing it
60 .include "share/mk/src.opts.mk"
62 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
63 # keep the users system reasonably usable. For static->dynamic root upgrades,
64 # we don't want to install a dynamic binary without rtld and the needed
65 # libraries. More commonly, for dynamic root, we don't want to install a
66 # binary that requires a newer library version that hasn't been installed yet.
67 # This ordering is not a guarantee though. The only guarantee of a working
68 # system here would require fine-grained ordering of all components based
69 # on their dependencies.
71 .if !empty(SUBDIR_OVERRIDE)
72 SUBDIR= ${SUBDIR_OVERRIDE}
75 .if !defined(NO_ROOT) && (make(installworld) || make(install))
76 # Ensure libraries are installed before progressing.
80 .if ${MK_CDDL} != "no"
84 .if ${MK_KERBEROS} != "no"
87 .if ${MK_RESCUE} != "no"
91 .if ${MK_CRYPT} != "no"
94 .if !defined(NO_SHARE)
97 SUBDIR+=sys usr.bin usr.sbin
98 .if ${MK_TESTS} != "no"
101 .if ${MK_OFED} != "no"
105 # Local directories are last, since it is nice to at least get the base
106 # system rebuilt before you do them.
107 .for _DIR in ${LOCAL_DIRS}
108 .if exists(${.CURDIR}/${_DIR}/Makefile)
112 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
113 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
114 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
115 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
116 _REDUNDENT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
118 .for _DIR in ${LOCAL_LIB_DIRS}
119 .if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
122 .warning ${_DIR} not added to SUBDIR list. See UPDATING 20141121.
126 # We must do etc/ last as it hooks into building the man whatis file
127 # by calling 'makedb' in share/man. This is only relevant for
128 # install/distribute so they build the whatis file after every manpage is
130 .if make(installworld) || make(install)
135 .endif # !empty(SUBDIR_OVERRIDE)
138 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
141 .if defined(NO_CLEANDIR)
142 CLEANDIR= clean cleandepend
148 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
150 .if empty(SHELL:M*csh*)
151 BUILDENV_SHELL?=${SHELL}
153 BUILDENV_SHELL?=/bin/sh
156 SVN?= /usr/local/bin/svn
159 MAKEOBJDIRPREFIX?= /usr/obj
160 .if !defined(OSRELDATE)
161 .if exists(/usr/include/osreldate.h)
162 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
163 /usr/include/osreldate.h
170 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
171 .if !defined(VERSION) && !make(showconfig)
172 REVISION!= ${MAKE} -C ${SRCDIR}/release -V REVISION
173 BRANCH!= ${MAKE} -C ${SRCDIR}/release -V BRANCH
174 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
175 ${SRCDIR}/sys/sys/param.h
176 VERSION= FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
180 .if !defined(PKG_VERSION)
181 REVISION!= ${MAKE} -C ${SRCDIR}/release -V REVISION
182 BRANCH!= ${MAKE} -C ${SRCDIR}/release -V BRANCH
183 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
184 ${SRCDIR}/sys/sys/param.h
185 .if ${BRANCH:MSTABLE*} || ${BRANCH:MCURRENT*}
186 TIMENOW= %Y%m%d%H%M%S
187 EXTRA_REVISION= .s${TIMENOW:gmtime}
190 EXTRA_REVISION= _${BRANCH:C/.*-p([0-9]+$)/\1/}
192 PKG_VERSION= ${REVISION}${EXTRA_REVISION}
195 KNOWN_ARCHES?= aarch64/arm64 \
214 .if ${TARGET} == ${TARGET_ARCH}
217 _t= ${TARGET_ARCH}/${TARGET}
220 .if empty(KNOWN_ARCHES:M${_t})
221 .error Unknown target ${TARGET_ARCH}:${TARGET}.
225 .if ${TARGET} == ${MACHINE}
226 TARGET_CPUTYPE?=${CPUTYPE}
231 .if !empty(TARGET_CPUTYPE)
232 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
234 _TARGET_CPUTYPE=dummy
236 # Skip for showconfig as it is just wasted time and may invoke auto.obj.mk.
237 .if !make(showconfig)
238 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
239 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
240 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
241 .error CPUTYPE global should be set with ?=.
245 BUILD_ARCH!= uname -p
246 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
247 .error To cross-build, set TARGET_ARCH.
250 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
251 OBJTREE= ${MAKEOBJDIRPREFIX}
253 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
255 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
256 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
257 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
258 STRICTTMPPATH= ${BPATH}:${XPATH}
259 TMPPATH= ${STRICTTMPPATH}:${PATH}
262 # Avoid running mktemp(1) unless actually needed.
263 # It may not be functional, e.g., due to new ABI
264 # when in the middle of installing over this system.
266 .if make(distributeworld) || make(installworld) || make(stageworld)
267 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
270 .if make(stagekernel) || make(distributekernel)
276 # Building a world goes through the following stages
278 # 1. legacy stage [BMAKE]
279 # This stage is responsible for creating compatibility
280 # shims that are needed by the bootstrap-tools,
281 # build-tools and cross-tools stages. These are generally
282 # APIs that tools from one of those three stages need to
283 # build that aren't present on the host.
284 # 1. bootstrap-tools stage [BMAKE]
285 # This stage is responsible for creating programs that
286 # are needed for backward compatibility reasons. They
287 # are not built as cross-tools.
288 # 2. build-tools stage [TMAKE]
289 # This stage is responsible for creating the object
290 # tree and building any tools that are needed during
291 # the build process. Some programs are listed during
292 # this phase because they build binaries to generate
293 # files needed to build these programs. This stage also
294 # builds the 'build-tools' target rather than 'all'.
295 # 3. cross-tools stage [XMAKE]
296 # This stage is responsible for creating any tools that
297 # are needed for building the system. A cross-compiler is one
298 # of them. This differs from build tools in two ways:
299 # 1. the 'all' target is built rather than 'build-tools'
300 # 2. these tools are installed into TMPPATH for stage 4.
301 # 4. world stage [WMAKE]
302 # This stage actually builds the world.
303 # 5. install stage (optional) [IMAKE]
304 # This stage installs a previously built world.
309 # Common environment for world related stages
310 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
311 MACHINE_ARCH=${TARGET_ARCH} \
313 CPUTYPE=${TARGET_CPUTYPE}
314 .if ${MK_GROFF} != "no"
315 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
316 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
317 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
319 .if defined(TARGET_CFLAGS)
320 CROSSENV+= ${TARGET_CFLAGS}
323 # bootstrap-tools stage
324 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
325 PATH=${BPATH}:${PATH} \
326 WORLDTMP=${WORLDTMP} \
327 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
328 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
330 BOOTSTRAPPING=${OSRELDATE} \
332 MK_HTML=no NO_LINT=yes MK_MAN=no \
333 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
334 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
335 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
336 MK_LLDB=no MK_TESTS=no \
339 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
340 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
344 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
345 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
346 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
348 BOOTSTRAPPING=${OSRELDATE} \
351 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
352 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
353 MK_LLDB=no MK_TESTS=no
356 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
357 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
358 MK_GDB=no MK_TESTS=no
361 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
362 PATH=${BPATH}:${PATH} \
364 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
365 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
367 BOOTSTRAPPING=${OSRELDATE} \
369 MK_HTML=no -DNO_LINT MK_MAN=no \
370 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
371 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
374 WMAKEENV= ${CROSSENV} \
376 INSTALL="sh ${.CURDIR}/tools/install.sh" \
380 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
382 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
385 .if defined(CROSS_TOOLCHAIN_PREFIX)
386 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
387 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
390 # If we do not have a bootstrap binutils (because the in-tree one does not
391 # support the target architecture), provide a default cross-binutils prefix.
392 # This allows aarch64 builds, for example, to automatically use the
393 # aarch64-binutils port or package.
394 .if !make(showconfig)
395 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
396 !defined(CROSS_BINUTILS_PREFIX)
397 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
398 .if !exists(${CROSS_BINUTILS_PREFIX})
399 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
404 XCOMPILERS= CC CXX CPP
405 .for COMPILER in ${XCOMPILERS}
406 .if defined(CROSS_COMPILER_PREFIX)
407 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
409 X${COMPILER}?= ${${COMPILER}}
412 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
413 .for BINUTIL in ${XBINUTILS}
414 .if defined(CROSS_BINUTILS_PREFIX) && \
415 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
416 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
418 X${BINUTIL}?= ${${BINUTIL}}
421 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
422 DEPFLAGS="${DEPFLAGS}" \
423 CPP="${XCPP} ${XCFLAGS}" \
424 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
425 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
426 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
429 .if ${XCC:N${CCACHE_BIN}:M/*}
430 .if defined(CROSS_BINUTILS_PREFIX)
431 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
432 # directory, but the compiler will look in the right place for it's
433 # tools so we don't need to tell it where to look.
434 .if exists(${CROSS_BINUTILS_PREFIX})
435 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
438 BFLAGS+= -B${WORLDTMP}/usr/bin
440 .if ${TARGET} == "arm"
441 .if ${TARGET_ARCH:M*hf*} != ""
442 TARGET_ABI= gnueabihf
447 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
448 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
449 XCXXFLAGS+= -I${WORLDTMP}/usr/include/c++/v1 -std=gnu++11 -L${WORLDTMP}/../lib/libc++
450 # XXX: DEPFLAGS is a workaround for not properly passing CXXFLAGS to sub-makes
451 # due to CXX="${XCXX} ${XCXXFLAGS}". bsd.dep.mk does use CXXFLAGS when
452 # building C++ files so this can come out if passing CXXFLAGS down is fixed.
453 DEPFLAGS+= -I${WORLDTMP}/usr/include/c++/v1
456 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
457 XCFLAGS+= -target ${TARGET_TRIPLE}
459 XCFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
460 XCXXFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
462 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
463 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
465 XCXXFLAGS+= ${BFLAGS}
469 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
471 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
473 LIB32_OBJTREE= ${OBJTREE}${.CURDIR}/world32
474 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
476 .if ${TARGET_ARCH} == "amd64"
477 .if empty(TARGET_CPUTYPE)
478 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
480 LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
482 LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
483 MACHINE_CPU="i686 mmx sse sse2"
486 LD="${XLD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
487 OBJCOPY="${XOBJCOPY}"
489 .elif ${TARGET_ARCH} == "powerpc64"
490 .if empty(TARGET_CPUTYPE)
491 LIB32CPUFLAGS= -mcpu=powerpc
493 LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
495 LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
497 LD="${XLD} -m elf32ppc_fbsd" \
498 OBJCOPY="${XOBJCOPY}"
502 LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
503 -isystem ${LIB32TMP}/usr/include/ \
504 -L${LIB32TMP}/usr/lib32 \
505 -B${LIB32TMP}/usr/lib32
506 .if ${XCC:N${CCACHE_BIN}:M/*}
507 LIB32FLAGS+= --sysroot=${WORLDTMP}
510 # Yes, the flags are redundant.
511 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${LIB32_OBJTREE} \
512 _LDSCRIPTROOT=${LIB32TMP} \
513 INSTALL="sh ${.CURDIR}/tools/install.sh" \
516 SHLIBDIR=/usr/lib32 \
517 DTRACE="${DTRACE} -32"
518 LIB32WMAKEFLAGS+= CC="${XCC} ${LIB32FLAGS}" \
519 CXX="${XCXX} ${LIB32FLAGS}" \
520 DESTDIR=${LIB32TMP} \
528 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
530 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \
531 MK_TOOLCHAIN=no ${IMAKE_INSTALL}
534 IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*}
535 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
536 ${IMAKE_INSTALL} ${IMAKE_MTREE}
537 .if empty(.MAKEFLAGS:M-n)
538 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
539 LD_LIBRARY_PATH=${INSTALLTMP} \
540 PATH_LOCALE=${INSTALLTMP}/locale
541 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
543 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
545 .if defined(DB_FROM_SRC)
546 INSTALLFLAGS+= -N ${.CURDIR}/etc
547 MTREEFLAGS+= -N ${.CURDIR}/etc
549 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
550 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
552 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
553 IMAKE+= -DNO_ROOT METALOG=${METALOG}
554 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
557 .if defined(BUILD_PKGS)
558 INSTALLFLAGS+= -h sha256
560 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
561 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
562 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
566 KMAKEENV= ${WMAKEENV}
567 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
572 # Attempt to rebuild the entire system, with reasonable chance of
573 # success, regardless of how old your existing system is.
576 .if ${.CURDIR:C/[^,]//g} != ""
577 # The m4 build of sendmail files doesn't like it if ',' is used
578 # anywhere in the path of it's files.
580 @echo "*** Error: path to source tree contains a comma ','"
585 @echo "--------------------------------------------------------------"
586 @echo ">>> Rebuilding the temporary build tree"
587 @echo "--------------------------------------------------------------"
588 .if !defined(NO_CLEAN)
590 .if defined(LIB32TMP)
594 rm -rf ${WORLDTMP}/legacy/usr/include
595 # XXX - These can depend on any header file.
596 rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c
597 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
600 lib usr legacy/bin legacy/usr
601 mkdir -p ${WORLDTMP}/${_dir}
603 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
604 -p ${WORLDTMP}/legacy/usr >/dev/null
605 .if ${MK_GROFF} != "no"
606 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
607 -p ${WORLDTMP}/legacy/usr >/dev/null
609 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
610 -p ${WORLDTMP}/usr >/dev/null
611 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
612 -p ${WORLDTMP}/usr/include >/dev/null
613 ln -sf ${.CURDIR}/sys ${WORLDTMP}
614 .if ${MK_DEBUG_FILES} != "no"
615 # We could instead disable debug files for these build stages
616 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
617 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
618 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
619 -p ${WORLDTMP}/usr/lib >/dev/null
621 .if ${MK_LIB32} != "no"
622 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
623 -p ${WORLDTMP}/usr >/dev/null
624 .if ${MK_DEBUG_FILES} != "no"
625 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
626 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
627 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
628 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
631 .if ${MK_TESTS} != "no"
632 mkdir -p ${WORLDTMP}${TESTSBASE}
633 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
634 -p ${WORLDTMP}${TESTSBASE} >/dev/null
635 .if ${MK_DEBUG_FILES} != "no"
636 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
637 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
638 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
641 .for _mtree in ${LOCAL_MTREE}
642 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
646 @echo "--------------------------------------------------------------"
647 @echo ">>> stage 1.1: legacy release compatibility shims"
648 @echo "--------------------------------------------------------------"
649 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
652 @echo "--------------------------------------------------------------"
653 @echo ">>> stage 1.2: bootstrap tools"
654 @echo "--------------------------------------------------------------"
655 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
657 .if !defined(NO_CLEAN)
659 @echo "--------------------------------------------------------------"
660 @echo ">>> stage 2.1: cleaning up the object tree"
661 @echo "--------------------------------------------------------------"
662 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
663 .if defined(LIB32TMP)
664 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR}
669 @echo "--------------------------------------------------------------"
670 @echo ">>> stage 2.2: rebuilding the object tree"
671 @echo "--------------------------------------------------------------"
672 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
675 @echo "--------------------------------------------------------------"
676 @echo ">>> stage 2.3: build tools"
677 @echo "--------------------------------------------------------------"
678 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
681 @echo "--------------------------------------------------------------"
682 @echo ">>> stage 3: cross tools"
683 @echo "--------------------------------------------------------------"
684 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
685 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
688 @echo "--------------------------------------------------------------"
689 @echo ">>> stage 4.1: building includes"
690 @echo "--------------------------------------------------------------"
691 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
692 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
693 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
695 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
696 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks includes
700 @echo "--------------------------------------------------------------"
701 @echo ">>> stage 4.2: building libraries"
702 @echo "--------------------------------------------------------------"
703 ${_+_}cd ${.CURDIR}; \
704 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
705 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
708 @echo "--------------------------------------------------------------"
709 @echo ">>> stage 4.3: make dependencies"
710 @echo "--------------------------------------------------------------"
711 ${_+_}cd ${.CURDIR}; ${WMAKE} depend
714 @echo "--------------------------------------------------------------"
715 @echo ">>> stage 4.4: building everything"
716 @echo "--------------------------------------------------------------"
717 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
718 .if defined(LIB32TMP)
721 @echo "--------------------------------------------------------------"
722 @echo ">>> stage 5.1: building 32 bit shim libraries"
723 @echo "--------------------------------------------------------------"
724 mkdir -p ${LIB32TMP}/usr/include
725 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
726 -p ${LIB32TMP}/usr >/dev/null
727 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
728 -p ${LIB32TMP}/usr/include >/dev/null
729 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
730 -p ${LIB32TMP}/usr >/dev/null
731 .if ${MK_DEBUG_FILES} != "no"
732 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
733 -p ${LIB32TMP}/usr/lib >/dev/null
734 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
735 -p ${LIB32TMP}/usr/lib/debug/usr >/dev/null
738 ln -sf ${.CURDIR}/sys ${WORLDTMP}
739 .for _t in obj includes
740 ${_+_}cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
741 ${_+_}cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
742 .if ${MK_CDDL} != "no"
743 ${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
745 ${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
746 .if ${MK_CRYPT} != "no"
747 ${_+_}cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
749 .if ${MK_KERBEROS} != "no"
750 ${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
753 .for _dir in usr.bin/lex/lib
754 ${_+_}cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
756 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
757 ${_+_}cd ${.CURDIR}/${_dir}; \
758 WORLDTMP=${WORLDTMP} \
759 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
760 MAKEOBJDIRPREFIX=${LIB32_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \
761 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
764 ${_+_}cd ${.CURDIR}; \
765 ${LIB32WMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
766 .for _t in obj depend all
767 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
768 -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t}
769 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
770 DIRPRFX=usr.bin/ldd ${_t}
773 distribute32 install32: .MAKE .PHONY
774 ${_+_}cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
775 .if ${MK_CDDL} != "no"
776 ${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
778 ${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
779 .if ${MK_CRYPT} != "no"
780 ${_+_}cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
782 .if ${MK_KERBEROS} != "no"
783 ${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
785 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \
786 PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
787 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} \
792 WMAKE_TGTS+= _worldtmp _legacy
793 .if empty(SUBDIR_OVERRIDE)
794 WMAKE_TGTS+= _bootstrap-tools
796 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
797 WMAKE_TGTS+= _includes _libraries _depend everything
798 .if defined(LIB32TMP) && ${MK_LIB32} != "no" && empty(SUBDIR_OVERRIDE)
802 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
803 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
806 @echo "--------------------------------------------------------------"
807 @echo ">>> World build started on `LC_ALL=C date`"
808 @echo "--------------------------------------------------------------"
812 @echo "--------------------------------------------------------------"
813 @echo ">>> World build completed on `LC_ALL=C date`"
814 @echo "--------------------------------------------------------------"
817 # We need to have this as a target because the indirection between Makefile
818 # and Makefile.inc1 causes the correct PATH to be used, rather than a
819 # modification of the current environment's PATH. In addition, we need
820 # to quote multiword values.
823 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
825 .if ${.TARGETS:Mbuildenv}
826 .if ${.MAKEFLAGS:M-j}
827 .error The buildenv target is incompatible with -j
830 BUILDENV_DIR?= ${.CURDIR}
832 @echo Entering world for ${TARGET_ARCH}:${TARGET}
833 .if ${BUILDENV_SHELL:M*zsh*}
834 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
836 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
839 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
840 toolchain: ${TOOLCHAIN_TGTS}
841 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
846 # Checks to be sure system is ready for installworld/installkernel.
848 installcheck: _installcheck_world _installcheck_kernel
850 _installcheck_kernel:
853 # Require DESTDIR to be set if installing for a different architecture or
854 # using the user/group database in the source tree.
856 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
858 .if !make(distributeworld)
859 _installcheck_world: __installcheck_DESTDIR
860 _installcheck_kernel: __installcheck_DESTDIR
861 __installcheck_DESTDIR:
862 .if !defined(DESTDIR) || empty(DESTDIR)
863 @echo "ERROR: Please set DESTDIR!"; \
869 .if !defined(DB_FROM_SRC)
871 # Check for missing UIDs/GIDs.
873 CHECK_UIDS= auditdistd
875 .if ${MK_SENDMAIL} != "no"
881 CHECK_GIDS+= proxy authpf
883 .if ${MK_UNBOUND} != "no"
887 _installcheck_world: __installcheck_UGID
889 .for uid in ${CHECK_UIDS}
890 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
891 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
895 .for gid in ${CHECK_GIDS}
896 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
897 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
904 # Required install tools to be saved in a scratch dir for safety.
906 .if ${MK_ZONEINFO} != "no"
907 _zoneinfo= zic tzsetup
910 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
911 date echo egrep find grep id install ${_install-info} \
912 ln make mkdir mtree mv pwd_mkdb \
913 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
916 # Needed for share/man
917 .if ${MK_MAN} != "no"
924 # Distributes everything compiled by a `buildworld'.
928 # Installs everything compiled by a 'buildworld'.
931 # Non-base distributions produced by the base system
932 EXTRA_DISTRIBUTIONS= doc
933 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
934 EXTRA_DISTRIBUTIONS+= lib32
936 .if ${MK_TESTS} != "no"
937 EXTRA_DISTRIBUTIONS+= tests
941 .if ${MK_DEBUG_FILES} != "no"
942 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
945 MTREE_MAGIC?= mtree 2.0
947 distributeworld installworld stageworld: _installcheck_world
948 mkdir -p ${INSTALLTMP}
949 progs=$$(for prog in ${ITOOLS}; do \
950 if progpath=`which $$prog`; then \
953 echo "Required tool $$prog not found in PATH." >&2; \
957 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
958 while read line; do \
960 if [ "$$2 $$3" != "not found" ]; then \
963 echo "Required library $$1 not found." >&2; \
967 cp $$libs $$progs ${INSTALLTMP}
968 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
970 echo "#${MTREE_MAGIC}" > ${METALOG}
972 .if make(distributeworld)
973 .for dist in ${EXTRA_DISTRIBUTIONS}
974 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
975 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
976 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
977 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
978 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
979 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
980 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
981 .if ${MK_DEBUG_FILES} != "no"
982 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
983 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
985 .if ${MK_LIB32} != "no"
986 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
987 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
988 .if ${MK_DEBUG_FILES} != "no"
989 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
990 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
993 .if ${MK_TESTS} != "no" && ${dist} == "tests"
994 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
995 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
996 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
997 .if ${MK_DEBUG_FILES} != "no"
998 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
999 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
1002 .if defined(NO_ROOT)
1003 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1004 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1005 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1006 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1007 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1008 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1009 .if ${MK_LIB32} != "no"
1010 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib32.dist | \
1011 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1015 -mkdir ${DESTDIR}/${DISTDIR}/base
1016 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1017 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1018 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1019 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1021 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1022 ${IMAKEENV} rm -rf ${INSTALLTMP}
1023 .if make(distributeworld)
1024 .for dist in ${EXTRA_DISTRIBUTIONS}
1025 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
1027 .if defined(NO_ROOT)
1028 .for dist in base ${EXTRA_DISTRIBUTIONS}
1029 @# For each file that exists in this dist, print the corresponding
1030 @# line from the METALOG. This relies on the fact that
1031 @# a line containing only the filename will sort immediatly before
1032 @# the relevant mtree line.
1033 cd ${DESTDIR}/${DISTDIR}; \
1034 find ./${dist} | sort -u ${METALOG} - | \
1035 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1036 ${DESTDIR}/${DISTDIR}/${dist}.meta
1038 .for dist in ${DEBUG_DISTRIBUTIONS}
1039 @# For each file that exists in this dist, print the corresponding
1040 @# line from the METALOG. This relies on the fact that
1041 @# a line containing only the filename will sort immediatly before
1042 @# the relevant mtree line.
1043 cd ${DESTDIR}/${DISTDIR}; \
1044 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1045 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1046 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1052 .for dist in base ${EXTRA_DISTRIBUTIONS}
1053 .if defined(NO_ROOT)
1054 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1055 tar cvf - --exclude usr/lib/debug \
1056 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1057 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1059 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1060 tar cvf - --exclude usr/lib/debug . | \
1061 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1065 .for dist in ${DEBUG_DISTRIBUTIONS}
1066 . if defined(NO_ROOT)
1067 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1068 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1069 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1071 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1072 tar cvLf - usr/lib/debug | \
1073 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1080 # If you have a build server, you can NFS mount the source and obj directories
1081 # and do a 'make reinstall' on the *client* to install new binaries from the
1082 # most recent server build.
1084 reinstall: .MAKE .PHONY
1085 @echo "--------------------------------------------------------------"
1086 @echo ">>> Making hierarchy"
1087 @echo "--------------------------------------------------------------"
1088 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1089 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1091 @echo "--------------------------------------------------------------"
1092 @echo ">>> Installing everything"
1093 @echo "--------------------------------------------------------------"
1094 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1095 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
1096 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
1099 restage: .MAKE .PHONY
1100 @echo "--------------------------------------------------------------"
1101 @echo ">>> Making hierarchy"
1102 @echo "--------------------------------------------------------------"
1103 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1104 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy distribution
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 redistribute: .MAKE .PHONY
1115 @echo "--------------------------------------------------------------"
1116 @echo ">>> Distributing everything"
1117 @echo "--------------------------------------------------------------"
1118 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1119 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
1120 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
1124 distrib-dirs: .MAKE .PHONY
1125 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1126 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1128 distribution: distrib-dirs .MAKE .PHONY
1129 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1130 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1131 METALOG=${METALOG} installconfig
1134 # buildkernel and installkernel
1136 # Which kernels to build and/or install is specified by setting
1137 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1138 # Only the existing (depending TARGET) config files are used
1139 # for building kernels and only the first of these is designated
1140 # as the one being installed.
1142 # Note that we have to use TARGET instead of TARGET_ARCH when
1143 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1144 # be set to cross-build, we have to make sure TARGET is set
1147 .if defined(KERNFAST)
1152 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1153 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1154 KERNCONF=${KERNFAST}
1157 .if ${TARGET_ARCH} == "powerpc64"
1158 KERNCONF?= GENERIC64
1162 INSTKERNNAME?= kernel
1164 KERNSRCDIR?= ${.CURDIR}/sys
1165 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1166 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1167 KERNCONFDIR?= ${KRNLCONFDIR}
1171 .if defined(NO_INSTALLKERNEL)
1172 # All of the BUILDKERNELS loops start at index 1.
1173 BUILDKERNELS+= dummy
1175 .for _kernel in ${KERNCONF}
1176 .if exists(${KERNCONFDIR}/${_kernel})
1177 BUILDKERNELS+= ${_kernel}
1178 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1179 INSTALLKERNEL= ${_kernel}
1184 ${WMAKE_TGTS:N_worldtmp:Nbuild32} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1189 # Builds all kernels defined by BUILDKERNELS.
1191 buildkernel: .MAKE .PHONY
1192 .if empty(BUILDKERNELS:Ndummy)
1193 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1197 .for _kernel in ${BUILDKERNELS:Ndummy}
1198 @echo "--------------------------------------------------------------"
1199 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1200 @echo "--------------------------------------------------------------"
1201 @echo "===> ${_kernel}"
1202 mkdir -p ${KRNLOBJDIR}
1203 .if !defined(NO_KERNELCONFIG)
1205 @echo "--------------------------------------------------------------"
1206 @echo ">>> stage 1: configuring the kernel"
1207 @echo "--------------------------------------------------------------"
1208 cd ${KRNLCONFDIR}; \
1210 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1211 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1213 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1215 @echo "--------------------------------------------------------------"
1216 @echo ">>> stage 2.1: cleaning up the object tree"
1217 @echo "--------------------------------------------------------------"
1218 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1220 .if !defined(NO_KERNELOBJ)
1222 @echo "--------------------------------------------------------------"
1223 @echo ">>> stage 2.2: rebuilding the object tree"
1224 @echo "--------------------------------------------------------------"
1225 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1228 @echo "--------------------------------------------------------------"
1229 @echo ">>> stage 2.3: build tools"
1230 @echo "--------------------------------------------------------------"
1231 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1232 .if !defined(NO_KERNELDEPEND)
1234 @echo "--------------------------------------------------------------"
1235 @echo ">>> stage 3.1: making dependencies"
1236 @echo "--------------------------------------------------------------"
1237 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
1240 @echo "--------------------------------------------------------------"
1241 @echo ">>> stage 3.2: building everything"
1242 @echo "--------------------------------------------------------------"
1243 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1244 @echo "--------------------------------------------------------------"
1245 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1246 @echo "--------------------------------------------------------------"
1250 # installkernel, etc.
1252 # Install the kernel defined by INSTALLKERNEL
1254 installkernel installkernel.debug \
1255 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1256 .if !defined(NO_INSTALLKERNEL)
1257 .if empty(INSTALLKERNEL)
1258 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1261 @echo "--------------------------------------------------------------"
1262 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1263 @echo "--------------------------------------------------------------"
1264 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1265 ${CROSSENV} PATH=${TMPPATH} \
1266 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1268 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1269 .for _kernel in ${BUILDKERNELS:[2..-1]}
1270 @echo "--------------------------------------------------------------"
1271 @echo ">>> Installing kernel ${_kernel}"
1272 @echo "--------------------------------------------------------------"
1273 cd ${KRNLOBJDIR}/${_kernel}; \
1274 ${CROSSENV} PATH=${TMPPATH} \
1275 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1279 distributekernel distributekernel.debug:
1280 .if !defined(NO_INSTALLKERNEL)
1281 .if empty(INSTALLKERNEL)
1282 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1285 mkdir -p ${DESTDIR}/${DISTDIR}
1286 .if defined(NO_ROOT)
1287 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1289 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1290 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1291 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1292 DESTDIR=${INSTALL_DDIR}/kernel \
1293 ${.TARGET:S/distributekernel/install/}
1294 .if defined(NO_ROOT)
1295 sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1296 ${DESTDIR}/${DISTDIR}/kernel.meta
1299 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1300 .for _kernel in ${BUILDKERNELS:[2..-1]}
1301 .if defined(NO_ROOT)
1302 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1304 cd ${KRNLOBJDIR}/${_kernel}; \
1305 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1306 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1307 KERNEL=${INSTKERNNAME}.${_kernel} \
1308 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1309 ${.TARGET:S/distributekernel/install/}
1310 .if defined(NO_ROOT)
1311 sed -e "s|^./kernel.${_kernel}|.|" \
1312 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1313 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1319 .if defined(NO_ROOT)
1320 .if !defined(NO_INSTALLKERNEL)
1321 cd ${DESTDIR}/${DISTDIR}/kernel; \
1322 tar cvf - --exclude '*.debug' \
1323 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1324 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1326 cd ${DESTDIR}/${DISTDIR}/kernel; \
1327 tar cvf - --include '*/*/*.debug' \
1328 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1329 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1330 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1331 .for _kernel in ${BUILDKERNELS:[2..-1]}
1332 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1333 tar cvf - --exclude '*.debug' \
1334 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1335 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1336 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1337 tar cvf - --include '*/*/*.debug' \
1338 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1339 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1343 .if !defined(NO_INSTALLKERNEL)
1344 cd ${DESTDIR}/${DISTDIR}/kernel; \
1345 tar cvf - --exclude '*.debug' . | \
1346 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1348 cd ${DESTDIR}/${DISTDIR}/kernel; \
1349 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1350 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1351 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1352 .for _kernel in ${BUILDKERNELS:[2..-1]}
1353 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1354 tar cvf - --exclude '*.debug' . | \
1355 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1356 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1357 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1358 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1364 ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1366 WSTAGEDIR= ${MAKEOBJDIRPREFIX}${.CURDIR}/worldstage
1367 KSTAGEDIR= ${MAKEOBJDIRPREFIX}${.CURDIR}/kernelstage
1368 REPODIR= ${MAKEOBJDIRPREFIX}${.CURDIR}/repo
1369 PKGSIGNKEY?= # empty
1372 .if !exists(${LOCALBASE}/sbin/pkg)
1373 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1376 packages: _pkgbootstrap
1377 @mkdir -p ${WSTAGEDIR} ${KSTAGEDIR} ${REPODIR}
1378 ${_+_}@cd ${.CURDIR}; \
1379 ${MAKE} DESTDIR=${DESTDIR:U${WSTAGEDIR}} -DNO_ROOT -B stageworld ; \
1380 ${MAKE} DESTDIR=${DESTDIR:U${KSTAGEDIR}} -DNO_ROOT -B stagekernel ; \
1381 ${MAKE} DESTDIR=${DESTDIR:U${WSTAGEDIR}} \
1382 PKG_VERSION=${PKG_VERSION} create-world-packages ; \
1383 ${MAKE} DESTDIR=${DESTDIR:U${KSTAGEDIR}} \
1384 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1385 create-kernel-packages
1387 create-world-packages: _pkgbootstrap
1388 @rm -f ${DESTDIR}/*.plist 2>/dev/null || :
1390 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1392 @for plist in ${DESTDIR}/*.plist; do \
1393 plist=$${plist##*/} ; \
1394 test -f ${SRCDIR}/release/packages/$${plist%.plist}.ucl || \
1395 ( echo "Unkown package FreeBSD-$${plist%.plist}" ; false ) ; \
1397 @cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1398 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1399 for plist in ${DESTDIR}/*.plist; do \
1400 plist=$${plist##*/} ; \
1401 pkgname=$${plist%.plist} ; \
1402 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1403 -e "s/%PKGNAME%/$${pkgname}/" \
1404 -e "s/%COMMENT%/Generic comment for $${pkgname}/" \
1405 -e "s/%DESC%/Generic description for $${pkgname}/" \
1406 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1407 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1408 ${SRCDIR}/release/packages/$${pkgname}.ucl \
1409 > ${DESTDIR}/$${pkgname}.ucl ; \
1411 /^name/ { printf("===> Creating %s-", $$2); next } \
1412 /^version/ { print $$2; next } \
1413 ' ${DESTDIR}/$${pkgname}.ucl ; \
1414 pkg -o ABI_FILE=${DESTDIR}/bin/sh \
1415 create -M ${DESTDIR}/$${pkgname}.ucl \
1416 -p ${DESTDIR}/$${pkgname}.plist \
1418 -o ${REPODIR}/$$(pkg -o ABI_FILE=${DESTDIR}/bin/sh config ABI)/latest ; \
1421 create-kernel-packages: _pkgbootstrap
1422 .if exists(${DESTDIR}/kernel.meta)
1423 .for flavor in release debug
1424 @cd ${DESTDIR}/${DISTDIR} ; \
1425 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1427 ${DESTDIR}/kernel.meta ; \
1428 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1429 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1430 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1431 -e "s/%PKGNAME%/kernel-${flavor}/" \
1432 -e "s/%COMMENT%/FreeBSD ${INSTKERNNAME} kernel ${flavor}/" \
1433 -e "s/%DESC%/FreeBSD ${INSTKERNNAME} kernel ${flavor}/" \
1434 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1435 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1436 ${SRCDIR}/release/packages/kernel.ucl \
1437 > ${DESTDIR}/${DISTDIR}/kernel-${flavor}.ucl ; \
1439 /name/ { printf("===> Creating %s-", $$2); next } \
1440 /version/ {print $$2; next } ' \
1441 ${DESTDIR}/${DISTDIR}/kernel-${flavor}.ucl ; \
1442 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh \
1443 create -M ${DESTDIR}/${DISTDIR}/kernel-${flavor}.ucl \
1444 -p ${DESTDIR}/${DISTDIR}/kernel-${flavor}.plist \
1445 -r ${DESTDIR}/${DISTDIR} \
1446 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest
1449 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1450 .for _kernel in ${BUILDKERNELS:[2..-1]}
1451 .if exists(${DESTDIR}/kernel.${_kernel}.meta)
1452 .for flavor in release debug
1453 @cd ${DESTDIR}/kernel.${_kernel} ; \
1454 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1455 -v kernel=yes -v _kernconf=${_kernel} \
1456 ${DESTDIR}/kernel.${_kernel}.meta ; \
1457 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1458 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1459 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1460 -e "s/%PKGNAME%/kernel-${_kernel:tl}-${flavor}/" \
1461 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1462 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1463 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1464 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1465 ${SRCDIR}/release/packages/kernel.ucl \
1466 > ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}-${flavor}.ucl ; \
1468 /name/ { printf("===> Creating %s-", $$2); next } \
1469 /version/ {print $$2; next } ' \
1470 ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}-${flavor}.ucl ; \
1471 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh \
1472 create -M ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}-${flavor}.ucl \
1473 -p ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}-${flavor}.plist \
1474 -r ${DESTDIR}/kernel.${_kernel} \
1475 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest
1481 signpackages: _pkgbootstrap
1482 @pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh repo ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI) ${PKGSIGNKEY}
1487 # Build the API documentation with doxygen
1490 @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1491 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1494 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1499 # Update the source tree(s), by running svn/svnup to update to the
1503 .if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1504 @echo "--------------------------------------------------------------"
1505 @echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1506 @echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1507 @echo "--------------------------------------------------------------"
1510 .if defined(SVN_UPDATE)
1511 @echo "--------------------------------------------------------------"
1512 @echo ">>> Updating ${.CURDIR} using Subversion"
1513 @echo "--------------------------------------------------------------"
1514 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1518 # ------------------------------------------------------------------------
1520 # From here onwards are utility targets used by the 'make world' and
1521 # related targets. If your 'world' breaks, you may like to try to fix
1522 # the problem and manually run the following targets to attempt to
1523 # complete the build. Beware, this is *not* guaranteed to work, you
1524 # need to have a pretty good grip on the current state of the system
1525 # to attempt to manually finish it. If in doubt, 'make world' again.
1529 # legacy: Build compatibility shims for the next three targets. This is a
1530 # minimal set of tools and shims necessary to compensate for older systems
1531 # which don't have the APIs required by the targets built in bootstrap-tools,
1532 # build-tools or cross-tools.
1535 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1536 .if ${BOOTSTRAPPING} < 1100006
1537 _elftoolchain_libs= lib/libelf lib/libdwarf
1541 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1542 @echo "ERROR: Source upgrades from versions prior to 8.0 are not supported."; \
1545 .for _tool in tools/build ${_elftoolchain_libs}
1546 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1547 cd ${.CURDIR}/${_tool}; \
1548 ${MAKE} DIRPRFX=${_tool}/ obj; \
1549 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1550 ${MAKE} DIRPRFX=${_tool}/ depend; \
1551 ${MAKE} DIRPRFX=${_tool}/ all; \
1552 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1556 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1557 # are built to build other binaries in the system. However, the focus of these
1558 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1559 # libraries, augmented by -legacy.
1561 _bt= _bootstrap-tools
1563 .if ${MK_GAMES} != "no"
1564 _strfile= usr.bin/fortune/strfile
1567 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1568 _gperf= gnu/usr.bin/gperf
1571 .if ${MK_GROFF} != "no"
1572 _groff= gnu/usr.bin/groff \
1576 .if ${MK_VT} != "no"
1577 _vtfontcvt= usr.bin/vtfontcvt
1580 .if ${BOOTSTRAPPING} < 900002
1584 .if ${BOOTSTRAPPING} < 1000033
1585 _libopenbsd= lib/libopenbsd
1589 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1590 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1593 .if ${BOOTSTRAPPING} < 1000026
1594 _nmtree= lib/libnetbsd \
1597 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1600 .if ${BOOTSTRAPPING} < 1000027
1604 # r277259 crunchide: Correct 64-bit section header offset
1605 # r281674 crunchide: always include both 32- and 64-bit ELF support
1606 # r285986 crunchen: use STRIPBIN rather than STRIP
1607 .if ${BOOTSTRAPPING} < 1100078
1608 _crunch= usr.sbin/crunch
1611 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1618 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1620 .if ${MK_BSNMP} != "no"
1621 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1624 # We need to build tblgen when we're building clang either as
1625 # the bootstrap compiler, or as the part of the normal build.
1626 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1628 lib/clang/libllvmsupport \
1629 lib/clang/libllvmtablegen \
1630 usr.bin/clang/tblgen \
1631 usr.bin/clang/clang-tblgen
1633 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1634 ${_bt}-usr.bin/clang/tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1637 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1640 .if ${MK_GPL_DTC} != "no"
1641 _dtc= gnu/usr.bin/dtc
1644 .if ${MK_KERBEROS} != "no"
1645 _kerberos5_bootstrap_tools= \
1646 kerberos5/tools/make-roken \
1647 kerberos5/lib/libroken \
1648 kerberos5/lib/libvers \
1649 kerberos5/tools/asn1_compile \
1650 kerberos5/tools/slc \
1653 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1656 .if ${MK_MANDOCDB} != "no"
1657 _libopenbsd?= lib/libopenbsd
1658 _makewhatis= lib/libsqlite3 \
1660 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1662 _makewhatis=usr.bin/makewhatis
1665 bootstrap-tools: .PHONY
1667 # Please document (add comment) why something is in 'bootstrap-tools'.
1668 # Try to bound the building of the bootstrap-tool to just the
1669 # FreeBSD versions that need the tool built at this stage of the build.
1672 ${_kerberos5_bootstrap_tools} \
1694 ${_bt}-${_tool}: .PHONY .MAKE
1695 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1696 cd ${.CURDIR}/${_tool}; \
1697 ${MAKE} DIRPRFX=${_tool}/ obj; \
1698 ${MAKE} DIRPRFX=${_tool}/ depend; \
1699 ${MAKE} DIRPRFX=${_tool}/ all; \
1700 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1702 bootstrap-tools: ${_bt}-${_tool}
1706 # build-tools: Build special purpose build tools
1708 .if !defined(NO_SHARE)
1709 _share= share/syscons/scrnmaps
1712 .if ${MK_GCC} != "no"
1713 _gcc_tools= gnu/usr.bin/cc/cc_tools
1716 .if ${MK_RESCUE} != "no"
1717 # rescue includes programs that have build-tools targets
1718 _rescue=rescue/rescue
1724 ${LOCAL_TOOL_DIRS} \
1725 lib/ncurses/ncurses \
1726 lib/ncurses/ncursesw \
1731 usr.bin/mkesdb_static \
1732 usr.bin/mkcsmapper_static \
1734 build-tools_${_tool}: .PHONY
1735 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1736 cd ${.CURDIR}/${_tool}; \
1737 ${MAKE} DIRPRFX=${_tool}/ obj; \
1738 ${MAKE} DIRPRFX=${_tool}/ build-tools
1739 build-tools: build-tools_${_tool}
1743 build-tools_${_tool}: .PHONY
1744 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1745 cd ${.CURDIR}/${_tool}; \
1746 ${MAKE} DIRPRFX=${_tool}/ obj; \
1747 ${MAKE} DIRPRFX=${_tool}/ depend; \
1748 ${MAKE} DIRPRFX=${_tool}/ all
1749 build-tools: build-tools_${_tool}
1753 # kernel-tools: Build kernel-building tools
1756 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1757 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1758 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1761 # cross-tools: All the tools needed to build the rest of the system after
1762 # we get done with the earlier stages. It is the last set of tools needed
1763 # to begin building the target binaries.
1765 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1766 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1767 _btxld= usr.sbin/btxld
1771 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1772 # resulting from missing bug fixes or ELF Toolchain updates.
1773 .if ${MK_CDDL} != "no"
1774 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1775 cddl/usr.bin/ctfmerge
1778 # If we're given an XAS, don't build binutils.
1779 .if ${XAS:M/*} == ""
1780 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1781 _binutils= gnu/usr.bin/binutils
1783 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1784 _elftctools= lib/libelftc \
1789 # These are not required by the build, but can be useful for developers who
1790 # cross-build on a FreeBSD 10 host:
1791 _elftctools+= usr.bin/addr2line
1793 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1794 # If cross-building with an external binutils we still need to build strip for
1795 # the target (for at least crunchide).
1796 _elftctools= lib/libelftc \
1800 # If an full path to an external cross compiler is given, don't build
1802 .if ${XCC:N${CCACHE_BIN}:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1803 .if ${MK_CLANG_BOOTSTRAP} != "no"
1804 _clang= usr.bin/clang
1805 _clang_libs= lib/clang
1807 .if ${MK_GCC_BOOTSTRAP} != "no"
1811 .if ${MK_USB} != "no"
1812 _usb_tools= sys/boot/usb/tools
1815 cross-tools: .MAKE .PHONY
1826 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1827 cd ${.CURDIR}/${_tool}; \
1828 ${MAKE} DIRPRFX=${_tool}/ obj; \
1829 ${MAKE} DIRPRFX=${_tool}/ depend; \
1830 ${MAKE} DIRPRFX=${_tool}/ all; \
1831 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1834 NXBDESTDIR= ${OBJTREE}/nxb-bin
1835 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1836 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1837 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1838 NXBMAKE= ${NXBENV} ${MAKE} \
1839 TBLGEN=${NXBDESTDIR}/usr/bin/tblgen \
1840 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1841 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1842 MK_GDB=no MK_TESTS=no \
1844 MK_HTML=no NO_LINT=yes MK_MAN=no \
1845 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1846 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1847 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1848 MK_LLDB=no MK_DEBUG_FILES=no
1850 # native-xtools is the current target for qemu-user cross builds of ports
1851 # via poudriere and the imgact_binmisc kernel module.
1852 # For non-clang enabled targets that are still using the in tree gcc
1853 # we must build a gperf binary for one instance of its Makefiles. On
1854 # clang-enabled systems, the gperf binary is obsolete.
1855 native-xtools: .PHONY
1856 .if ${MK_GCC_BOOTSTRAP} != "no"
1857 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1858 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,depend,all,install)"; \
1859 cd ${.CURDIR}/${_gperf}; \
1860 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1861 ${NXBMAKE} DIRPRFX=${_gperf}/ depend; \
1862 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1863 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1865 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1866 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1867 -p ${NXBDESTDIR}/usr >/dev/null
1868 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1869 -p ${NXBDESTDIR}/usr/include >/dev/null
1870 .if ${MK_DEBUG_FILES} != "no"
1871 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1872 -p ${NXBDESTDIR}/usr/lib >/dev/null
1933 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1934 cd ${.CURDIR}/${_tool}; \
1935 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1936 ${NXBMAKE} DIRPRFX=${_tool}/ depend; \
1937 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1938 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1942 # hierarchy - ensure that all the needed directories are present
1944 hierarchy hier: .MAKE .PHONY
1945 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1948 # libraries - build all libraries, and install them under ${DESTDIR}.
1950 # The list of libraries with dependents (${_prebuild_libs}) and their
1951 # interdependencies (__L) are built automatically by the
1952 # ${.CURDIR}/tools/make_libdeps.sh script.
1954 libraries: .MAKE .PHONY
1955 ${_+_}cd ${.CURDIR}; \
1956 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1957 ${MAKE} -f Makefile.inc1 _startup_libs; \
1958 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1959 ${MAKE} -f Makefile.inc1 _generic_libs
1962 # static libgcc.a prerequisite for shared libc
1964 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1966 # These dependencies are not automatically generated:
1968 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1969 # all shared libraries for ELF.
1971 _startup_libs= gnu/lib/csu
1972 _startup_libs+= lib/csu
1973 _startup_libs+= gnu/lib/libgcc
1974 _startup_libs+= lib/libcompiler_rt
1975 _startup_libs+= lib/libc
1976 _startup_libs+= lib/libc_nonshared
1977 .if ${MK_LIBCPLUSPLUS} != "no"
1978 _startup_libs+= lib/libcxxrt
1981 gnu/lib/libgcc__L: lib/libc__L
1982 gnu/lib/libgcc__L: lib/libc_nonshared__L
1983 .if ${MK_LIBCPLUSPLUS} != "no"
1984 lib/libcxxrt__L: gnu/lib/libgcc__L
1987 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1988 ${_kerberos5_lib_libhdb} \
1989 ${_kerberos5_lib_libheimbase} \
1990 ${_kerberos5_lib_libheimntlm} \
1992 ${_kerberos5_lib_libheimipcc} \
1993 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1994 ${_kerberos5_lib_libroken} \
1995 ${_kerberos5_lib_libwind} \
1996 lib/libbz2 ${_libcom_err} lib/libcrypt \
1997 lib/libelf lib/libexpat \
2000 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
2001 ${_lib_libcapsicum} \
2002 lib/ncurses/ncurses lib/ncurses/ncursesw \
2003 lib/libopie lib/libpam ${_lib_libthr} \
2004 ${_lib_libradius} lib/libsbuf lib/libtacplus \
2006 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
2007 ${_cddl_lib_libuutil} \
2008 ${_cddl_lib_libavl} \
2009 ${_cddl_lib_libzfs_core} \
2010 ${_cddl_lib_libctf} \
2011 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
2012 ${_secure_lib_libcrypto} ${_lib_libldns} \
2013 ${_secure_lib_libssh} ${_secure_lib_libssl} \
2015 .if ${MK_GNUCXX} != "no"
2016 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
2017 gnu/lib/libstdc++__L: lib/msun__L
2018 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
2021 .if ${MK_LIBCPLUSPLUS} != "no"
2022 _prebuild_libs+= lib/libc++
2025 lib/libgeom__L: lib/libexpat__L
2026 lib/libkvm__L: lib/libelf__L
2028 .if ${MK_LIBTHR} != "no"
2029 _lib_libthr= lib/libthr
2032 .if ${MK_RADIUS_SUPPORT} != "no"
2033 _lib_libradius= lib/libradius
2036 .if ${MK_OFED} != "no"
2037 _ofed_lib= contrib/ofed/usr.lib/
2040 .if ${MK_CASPER} != "no"
2041 _lib_libcapsicum=lib/libcapsicum
2044 lib/libcapsicum__L: lib/libnv__L
2045 lib/libpjdlog__L: lib/libutil__L
2046 lib/liblzma__L: lib/libthr__L
2048 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
2049 .for _DIR in ${LOCAL_LIB_DIRS}
2050 .if exists(${.CURDIR}/${_DIR}/Makefile)
2051 _generic_libs+= ${_DIR}
2055 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2057 .if ${MK_CDDL} != "no"
2058 _cddl_lib_libumem= cddl/lib/libumem
2059 _cddl_lib_libnvpair= cddl/lib/libnvpair
2060 _cddl_lib_libavl= cddl/lib/libavl
2061 _cddl_lib_libuutil= cddl/lib/libuutil
2062 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2063 _cddl_lib_libctf= cddl/lib/libctf
2065 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2066 cddl/lib/libzfs__L: lib/libgeom__L
2067 cddl/lib/libctf__L: lib/libz__L
2069 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
2070 # on select architectures though (see cddl/lib/Makefile)
2071 .if ${MACHINE_CPUARCH} != "sparc64"
2072 _prebuild_libs+= lib/libproc lib/librtld_db
2075 .if ${MK_CRYPT} != "no"
2076 .if ${MK_OPENSSL} != "no"
2077 _secure_lib_libcrypto= secure/lib/libcrypto
2078 _secure_lib_libssl= secure/lib/libssl
2079 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2080 .if ${MK_LDNS} != "no"
2081 _lib_libldns= lib/libldns
2082 lib/libldns__L: secure/lib/libcrypto__L
2084 .if ${MK_OPENSSH} != "no"
2085 _secure_lib_libssh= secure/lib/libssh
2086 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2087 .if ${MK_LDNS} != "no"
2088 secure/lib/libssh__L: lib/libldns__L
2090 .if ${MK_KERBEROS_SUPPORT} != "no"
2091 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2092 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2093 lib/libmd__L kerberos5/lib/libroken__L
2097 _secure_lib= secure/lib
2100 .if ${MK_KERBEROS} != "no"
2101 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2102 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2103 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2104 kerberos5/lib/libwind__L lib/libsqlite3__L
2105 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2106 kerberos5/lib/libroken__L lib/libcom_err__L
2107 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2108 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2109 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2110 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2111 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2112 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2113 kerberos5/lib/libroken__L: lib/libcrypt__L
2114 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2115 kerberos5/lib/libheimbase__L: lib/libthr__L
2116 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2119 lib/libsqlite3__L: lib/libthr__L
2121 .if ${MK_GSSAPI} != "no"
2122 _lib_libgssapi= lib/libgssapi
2125 .if ${MK_KERBEROS} != "no"
2126 _kerberos5_lib= kerberos5/lib
2127 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2128 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2129 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2130 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2131 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2132 _kerberos5_lib_libroken= kerberos5/lib/libroken
2133 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2134 _libsqlite3= lib/libsqlite3
2135 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2136 _kerberos5_lib_libwind= kerberos5/lib/libwind
2137 _libcom_err= lib/libcom_err
2140 .if ${MK_NIS} != "no"
2141 _lib_libypclnt= lib/libypclnt
2144 .if ${MK_OPENSSL} == "no"
2145 lib/libradius__L: lib/libmd__L
2149 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2150 .if ${MK_CXX} != "no"
2151 .if ${MK_LIBCPLUSPLUS} != "no"
2152 lib/libproc__L: lib/libcxxrt__L
2153 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2154 lib/libproc__L: gnu/lib/libsupc++__L
2158 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2160 .for _lib in ${_prereq_libs}
2161 ${_lib}__PL: .PHONY .MAKE
2162 .if exists(${.CURDIR}/${_lib})
2163 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2164 cd ${.CURDIR}/${_lib}; \
2165 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2166 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; \
2167 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2168 DIRPRFX=${_lib}/ all; \
2169 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2170 DIRPRFX=${_lib}/ install
2174 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
2175 ${_lib}__L: .PHONY .MAKE
2176 .if exists(${.CURDIR}/${_lib})
2177 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2178 cd ${.CURDIR}/${_lib}; \
2179 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2180 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; \
2181 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2182 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2186 # libpam is special: we need to build static PAM modules before
2187 # static PAM library, and dynamic PAM library before dynamic PAM
2189 lib/libpam__L: .PHONY .MAKE
2190 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
2191 cd ${.CURDIR}/lib/libpam; \
2192 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj; \
2193 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ depend; \
2194 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2195 -D_NO_LIBPAM_SO_YET all; \
2196 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2197 -D_NO_LIBPAM_SO_YET install
2199 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2200 _startup_libs: ${_startup_libs:S/$/__L/}
2201 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2202 _generic_libs: ${_generic_libs:S/$/__L/}
2204 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2205 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2206 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2207 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2208 # parallel. This is safe for the world stage of buildworld though since it has
2209 # already built libraries in a proper order and installed includes into
2210 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2211 # avoid trashing a system if it crashes mid-install.
2212 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2216 .include <bsd.subdir.mk>
2218 .if make(check-old) || make(check-old-dirs) || \
2219 make(check-old-files) || make(check-old-libs) || \
2220 make(delete-old) || make(delete-old-dirs) || \
2221 make(delete-old-files) || make(delete-old-libs)
2224 # check for / delete old files section
2227 .include "ObsoleteFiles.inc"
2229 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2230 else you can not start such an application. Consult UPDATING for more \
2231 information regarding how to cope with the removal/revision bump of a \
2234 .if !defined(BATCH_DELETE_OLD_FILES)
2241 @echo ">>> Removing old files (only deletes safe to delete libs)"
2242 # Ask for every old file if the user really wants to remove it.
2243 # It's annoying, but better safe than sorry.
2244 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2245 # argument list will get too long. Using .for/.endfor make "loops" will make
2246 # the Makefile parser segfault.
2249 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2250 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2251 while read file; do \
2252 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2253 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2254 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2256 for ext in debug symbols; do \
2257 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2258 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2259 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2264 # Remove catpages without corresponding manpages.
2266 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2267 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2268 while read catpage; do \
2270 if [ ! -e "$${manpage}" ]; then \
2271 rm ${RM_I} $${catpage} <&3; \
2274 @echo ">>> Old files removed"
2277 @echo ">>> Checking for old files"
2279 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2280 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2281 while read file; do \
2282 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2283 echo "${DESTDIR}/$${file}"; \
2285 for ext in debug symbols; do \
2286 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2287 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2291 # Check for catpages without corresponding manpages.
2292 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2293 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2294 while read catpage; do \
2296 if [ ! -e "$${manpage}" ]; then \
2302 @echo ">>> Removing old libraries"
2303 @echo "${OLD_LIBS_MESSAGE}" | fmt
2306 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2307 -V OLD_LIBS | xargs -n1 | \
2308 while read file; do \
2309 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2310 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2311 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2313 for ext in debug symbols; do \
2314 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2315 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2316 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2321 @echo ">>> Old libraries removed"
2324 @echo ">>> Checking for old libraries"
2326 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2327 -V OLD_LIBS | xargs -n1 | \
2328 while read file; do \
2329 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2330 echo "${DESTDIR}/$${file}"; \
2332 for ext in debug symbols; do \
2333 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2334 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2340 @echo ">>> Removing old directories"
2342 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2343 -V OLD_DIRS | xargs -n1 | sort -r | \
2344 while read dir; do \
2345 if [ -d "${DESTDIR}/$${dir}" ]; then \
2346 rmdir -v "${DESTDIR}/$${dir}" || true; \
2347 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2348 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2351 @echo ">>> Old directories removed"
2354 @echo ">>> Checking for old directories"
2356 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2357 -V OLD_DIRS | xargs -n1 | \
2358 while read dir; do \
2359 if [ -d "${DESTDIR}/$${dir}" ]; then \
2360 echo "${DESTDIR}/$${dir}"; \
2361 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2362 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2366 delete-old: delete-old-files delete-old-dirs
2367 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2369 check-old: check-old-files check-old-libs check-old-dirs
2370 @echo "To remove old files and directories run '${MAKE} delete-old'."
2371 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2376 # showconfig - show build configuration.
2379 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2380 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2382 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2383 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2385 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2386 .if exists(${KERNCONFDIR}/${KERNCONF})
2387 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2388 '${KERNCONFDIR}/${KERNCONF}' ; echo
2394 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2395 DTBOUTPUTPATH= ${.CURDIR}
2399 # Build 'standalone' Device Tree Blob
2402 @PATH=${TMPPATH} MACHINE=${TARGET} \
2403 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2404 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2409 # In the following, the first 'rm' in a series will usually remove all
2410 # files and directories. If it does not, then there are probably some
2411 # files with file flags set, so this unsets them and tries the 'rm' a
2412 # second time. There are situations where this target will be cleaning
2413 # some directories via more than one method, but that duplication is
2414 # needed to correctly handle all the possible situations. Removing all
2415 # files without file flags set in the first 'rm' instance saves time,
2416 # because 'chflags' will need to operate on fewer files afterwards.
2418 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2419 # created by bsd.obj.mk, except that we don't want to .include that file
2422 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2424 .if exists(${BW_CANONICALOBJDIR}/)
2425 -rm -rf ${BW_CANONICALOBJDIR}/*
2426 -chflags -R 0 ${BW_CANONICALOBJDIR}
2427 rm -rf ${BW_CANONICALOBJDIR}/*
2429 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2430 # To be safe in this case, fall back to a 'make cleandir'
2431 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2434 .if defined(TARGET) && defined(TARGET_ARCH)
2436 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2437 XDEV_CPUTYPE?=${CPUTYPE}
2439 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2442 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2443 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2444 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2445 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2446 CPUTYPE=${XDEV_CPUTYPE}
2448 XDDIR=${TARGET_ARCH}-freebsd
2451 .error XDTP variable should be an absolute path
2454 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2455 INSTALL="sh ${.CURDIR}/tools/install.sh"
2457 TOOLS_PREFIX=${XDTP}
2458 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2459 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2460 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2461 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2462 CPP="${CPP} ${CD2CFLAGS}" \
2463 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2465 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2466 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2467 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2468 XDDESTDIR=${DESTDIR}/${XDTP}
2470 OSREL!= uname -r | sed -e 's/[-(].*//'
2473 .ORDER: xdev-build xdev-install xdev-links
2474 xdev: xdev-build xdev-install
2476 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2477 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2479 _xb-worldtmp: .PHONY
2480 mkdir -p ${CDTMP}/usr
2481 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2482 -p ${CDTMP}/usr >/dev/null
2484 _xb-bootstrap-tools: .PHONY
2488 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
2489 cd ${.CURDIR}/${_tool}; \
2490 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2491 ${CDMAKE} DIRPRFX=${_tool}/ depend; \
2492 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2493 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2496 _xb-build-tools: .PHONY
2497 ${_+_}@cd ${.CURDIR}; \
2498 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2500 _xb-cross-tools: .PHONY
2508 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
2509 cd ${.CURDIR}/${_tool}; \
2510 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2511 ${CDMAKE} DIRPRFX=${_tool}/ depend; \
2512 ${CDMAKE} DIRPRFX=${_tool}/ all
2516 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2517 mkdir -p ${XDDESTDIR}
2518 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2519 -p ${XDDESTDIR} >/dev/null
2520 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2521 -p ${XDDESTDIR}/usr >/dev/null
2522 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2523 -p ${XDDESTDIR}/usr/include >/dev/null
2524 .if ${MK_LIB32} != "no"
2525 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
2526 -p ${XDDESTDIR}/usr >/dev/null
2528 .if ${MK_TESTS} != "no"
2529 mkdir -p ${XDDESTDIR}${TESTSBASE}
2530 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2531 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2534 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2535 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2537 _xi-cross-tools: .PHONY
2538 @echo "_xi-cross-tools"
2546 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2547 cd ${.CURDIR}/${_tool}; \
2548 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2551 _xi-includes: .PHONY
2552 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2553 DESTDIR=${XDDESTDIR}
2555 _xi-libraries: .PHONY
2556 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2557 DESTDIR=${XDDESTDIR}
2560 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2561 mkdir -p ../../../../usr/bin; \
2563 ln -sf ../../${XDTP}/usr/bin/$$i \
2564 ../../../../usr/bin/${XDDIR}-$$i; \
2565 ln -sf ../../${XDTP}/usr/bin/$$i \
2566 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2569 xdev xdev-build xdev-install xdev-links:
2570 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"