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,OBJ}
11 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
12 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
13 # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
14 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
15 # -DNO_ROOT install without using root privilege
16 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
17 # -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects
18 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
19 # LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list
20 # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
21 # LOCAL_MTREE="list of mtree files" to process to allow local directories
22 # to be created before files are installed
23 # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
25 # LOCAL_XTOOL_DIRS="list of dirs" to add additional dirs to the
27 # METALOG="path to metadata log" to write permission and ownership
28 # when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
29 # TARGET="machine" to crossbuild world for a different machine type
30 # TARGET_ARCH= may be required when a TARGET supports multiple endians
31 # BUILDENV_SHELL= shell to launch for the buildenv target (def:${SHELL})
32 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
33 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
34 # SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
35 # All libraries and includes, and some build tools will still build.
38 # The intended user-driven targets are:
39 # buildworld - rebuild *everything*, including glue to help do upgrades
40 # installworld- install everything built by "buildworld"
41 # checkworld - run test suite on installed world
42 # doxygen - build API documentation of the kernel
43 # update - convenient way to update your source tree (eg: svn/svnup)
45 # Standard targets (not defined here) are documented in the makefiles in
46 # /usr/share/mk. These include:
47 # obj depend all install clean cleandepend cleanobj
49 .if !defined(TARGET) || !defined(TARGET_ARCH)
50 .error "Both TARGET and TARGET_ARCH must be defined."
54 LOCALBASE?= /usr/local
56 # Cross toolchain changes must be in effect before bsd.compiler.mk
57 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
58 .if defined(CROSS_TOOLCHAIN)
59 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
60 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
62 .if defined(CROSS_TOOLCHAIN_PREFIX)
63 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
66 XCOMPILERS= CC CXX CPP
67 .for COMPILER in ${XCOMPILERS}
68 .if defined(CROSS_COMPILER_PREFIX)
69 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
71 X${COMPILER}?= ${${COMPILER}}
74 # If a full path to an external cross compiler is given, don't build
76 .if ${XCC:N${CCACHE_BIN}:M/*}
77 MK_CLANG_BOOTSTRAP= no
81 # Pull in compiler metadata from buildworld/toolchain if possible to avoid
82 # running CC from bsd.compiler.mk.
83 .if make(installworld) || make(install) || make(distributeworld) || \
85 .-include "${OBJTOP}/compiler-metadata.mk"
88 # Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early. Pull it from the
89 # tree to be friendlier to foreign OS builds. It's safe to do so unconditionally
90 # here since we will always have the right make, unlike in src/Makefile
91 .include "share/mk/bsd.compiler.mk"
92 .include "share/mk/src.opts.mk"
94 # Check if there is a local compiler that can satisfy as an external compiler.
95 # Which compiler is expected to be used?
96 .if ${MK_CLANG_BOOTSTRAP} == "yes"
97 WANT_COMPILER_TYPE= clang
98 .elif ${MK_GCC_BOOTSTRAP} == "yes"
99 WANT_COMPILER_TYPE= gcc
103 .if !defined(WANT_COMPILER_FREEBSD_VERSION)
104 .if ${WANT_COMPILER_TYPE} == "clang"
105 WANT_COMPILER_FREEBSD_VERSION_FILE= lib/clang/freebsd_cc_version.h
106 WANT_COMPILER_FREEBSD_VERSION!= \
107 awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
108 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
109 WANT_COMPILER_VERSION_FILE= lib/clang/include/clang/Basic/Version.inc
110 WANT_COMPILER_VERSION!= \
111 awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
112 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
113 .elif ${WANT_COMPILER_TYPE} == "gcc"
114 WANT_COMPILER_FREEBSD_VERSION_FILE= gnu/usr.bin/cc/cc_tools/freebsd-native.h
115 WANT_COMPILER_FREEBSD_VERSION!= \
116 awk '$$2 == "FBSD_CC_VER" {printf("%d\n", $$3)}' \
117 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
118 WANT_COMPILER_VERSION_FILE= contrib/gcc/BASE-VER
119 WANT_COMPILER_VERSION!= \
120 awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3}' \
121 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
123 .export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION
124 .endif # !defined(WANT_COMPILER_FREEBSD_VERSION)
125 # It needs to be the same revision as we would build for the bootstrap.
126 # If the expected vs CC is different then we can't skip.
127 # GCC cannot be used for cross-arch yet. For clang we pass -target later if
128 # TARGET_ARCH!=MACHINE_ARCH.
129 .if ${MK_SYSTEM_COMPILER} == "yes" && \
130 (${MK_CLANG_BOOTSTRAP} == "yes" || ${MK_GCC_BOOTSTRAP} == "yes") && \
131 !make(showconfig) && !make(xdev*) && \
132 ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE} && \
133 (${COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \
134 ${COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \
135 ${COMPILER_FREEBSD_VERSION} == ${WANT_COMPILER_FREEBSD_VERSION}
136 # Everything matches, disable the bootstrap compiler.
137 MK_CLANG_BOOTSTRAP= no
139 USING_SYSTEM_COMPILER= yes
140 .endif # ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE}
141 USING_SYSTEM_COMPILER?= no
142 TEST_SYSTEM_COMPILER_VARS= \
143 USING_SYSTEM_COMPILER MK_SYSTEM_COMPILER \
144 MK_CROSS_COMPILER MK_CLANG_BOOTSTRAP MK_GCC_BOOTSTRAP \
145 WANT_COMPILER_TYPE WANT_COMPILER_VERSION WANT_COMPILER_VERSION_FILE \
146 WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \
147 CC COMPILER_TYPE COMPILER_FEATURES COMPILER_VERSION \
148 COMPILER_FREEBSD_VERSION \
149 X_COMPILER_TYPE X_COMPILER_FEATURES X_COMPILER_VERSION \
150 X_COMPILER_FREEBSD_VERSION \
151 LINKER_TYPE LINKER_FEATURES LINKER_VERSION \
152 X_LINKER_TYPE X_LINKER_FEATURES X_LINKER_VERSION
153 test-system-compiler: .PHONY
154 .for v in ${TEST_SYSTEM_COMPILER_VARS}
155 ${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}"
157 .if ${USING_SYSTEM_COMPILER} == "yes" && \
158 (make(buildworld) || make(buildkernel) || make(kernel-toolchain) || \
159 make(toolchain) || make(_cross-tools))
160 .info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler.
163 # For installworld need to ensure that the looked-up compiler metadata is
164 # passed along rather than trying to run cc from the restricted
166 .if ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
167 .if !defined(X_COMPILER_TYPE)
168 CROSSENV+= COMPILER_VERSION=${COMPILER_VERSION} \
169 COMPILER_TYPE=${COMPILER_TYPE} \
170 COMPILER_FEATURES="${COMPILER_FEATURES}" \
171 COMPILER_FREEBSD_VERSION=${COMPILER_FREEBSD_VERSION}
173 CROSSENV+= COMPILER_VERSION=${X_COMPILER_VERSION} \
174 COMPILER_FEATURES="${X_COMPILER_FEATURES}" \
175 COMPILER_TYPE=${X_COMPILER_TYPE} \
176 COMPILER_FREEBSD_VERSION=${X_COMPILER_FREEBSD_VERSION}
179 # Store some compiler metadata for use in installworld where we don't
180 # want to invoke CC at all.
181 _COMPILER_METADATA_VARS= COMPILER_VERSION \
184 COMPILER_FREEBSD_VERSION \
188 compiler-metadata.mk: .PHONY .META
190 @echo ".info Using cached compiler metadata from build at $$(hostname) on $$(date)" \
192 .for v in ${_COMPILER_METADATA_VARS}
193 @echo "${v}=${${v}}" >> ${.TARGET}
195 @echo ".export ${_COMPILER_METADATA_VARS}" >> ${.TARGET}
197 # Handle external binutils.
198 .if defined(CROSS_TOOLCHAIN_PREFIX)
199 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
201 # If we do not have a bootstrap binutils (because the in-tree one does not
202 # support the target architecture), provide a default cross-binutils prefix.
203 # This allows riscv64 builds, for example, to automatically use the
204 # riscv64-binutils port or package.
205 .if !make(showconfig)
206 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
207 ${MK_LLD_BOOTSTRAP} == "no" && \
208 !defined(CROSS_BINUTILS_PREFIX)
209 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
210 .if !exists(${CROSS_BINUTILS_PREFIX})
211 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
215 XBINUTILS= AS AR LD NM OBJCOPY RANLIB SIZE STRINGS
216 .for BINUTIL in ${XBINUTILS}
217 .if defined(CROSS_BINUTILS_PREFIX) && \
218 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
219 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
221 X${BINUTIL}?= ${${BINUTIL}}
226 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
227 # keep the users system reasonably usable. For static->dynamic root upgrades,
228 # we don't want to install a dynamic binary without rtld and the needed
229 # libraries. More commonly, for dynamic root, we don't want to install a
230 # binary that requires a newer library version that hasn't been installed yet.
231 # This ordering is not a guarantee though. The only guarantee of a working
232 # system here would require fine-grained ordering of all components based
233 # on their dependencies.
234 .if !empty(SUBDIR_OVERRIDE)
235 SUBDIR= ${SUBDIR_OVERRIDE}
238 .if !defined(NO_ROOT) && (make(installworld) || make(install))
239 # Ensure libraries are installed before progressing.
243 .if ${MK_CDDL} != "no"
247 .if ${MK_KERBEROS} != "no"
250 .if ${MK_RESCUE} != "no"
254 .if ${MK_CRYPT} != "no"
257 .if !defined(NO_SHARE)
260 .if ${MK_BOOT} != "no"
263 SUBDIR+=sys usr.bin usr.sbin
264 .if ${MK_TESTS} != "no"
267 .if ${MK_OFED} != "no"
271 # Local directories are built in parallel with the base system directories.
272 # Users may insert a .WAIT directive at the beginning or elsewhere within
273 # the LOCAL_DIRS and LOCAL_LIB_DIRS lists as needed.
274 .for _DIR in ${LOCAL_DIRS}
275 .if ${_DIR} == ".WAIT" || exists(${.CURDIR}/${_DIR}/Makefile)
279 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
280 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
281 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
282 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
283 _REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
285 .for _DIR in ${LOCAL_LIB_DIRS}
286 .if ${_DIR} == ".WAIT" || (empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
291 # We must do etc/ last as it hooks into building the man whatis file
292 # by calling 'makedb' in share/man. This is only relevant for
293 # install/distribute so they build the whatis file after every manpage is
295 .if make(installworld) || make(install)
300 .endif # !empty(SUBDIR_OVERRIDE)
303 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
306 .if defined(NO_CLEANDIR)
307 CLEANDIR= clean cleandepend
312 .if defined(WORLDFAST)
317 .if ${MK_META_MODE} == "yes"
318 # If filemon is used then we can rely on the build being incremental-safe.
319 # The .meta files will also track the build command and rebuild should
321 .if empty(.MAKE.MODE:Mnofilemon)
325 .if defined(NO_OBJWALK) || ${MK_AUTO_OBJ} == "yes"
329 .if !defined(NO_OBJWALK)
334 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
336 .if empty(SHELL:M*csh*)
337 BUILDENV_SHELL?=${SHELL}
339 BUILDENV_SHELL?=/bin/sh
342 .if !defined(SVN) || empty(SVN)
343 . for _P in /usr/bin /usr/local/bin
344 . for _S in svn svnlite
345 . if exists(${_P}/${_S})
352 .if !defined(VCS_REVISION) && empty(VCS_REVISION)
353 _VCS_REVISION?= $$(eval ${SVNVERSION_CMD} ${SRCDIR})
354 . if !empty(_VCS_REVISION)
355 VCS_REVISION= $$(echo r${_VCS_REVISION})
359 .if !defined(OSRELDATE)
360 .if exists(/usr/include/osreldate.h)
361 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
362 /usr/include/osreldate.h
369 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
370 .if !defined(_REVISION)
371 _REVISION!= ${MAKE} -C ${SRCDIR}/release MK_AUTO_OBJ=no -V REVISION
374 .if !defined(_BRANCH)
375 _BRANCH!= ${MAKE} -C ${SRCDIR}/release MK_AUTO_OBJ=no -V BRANCH
378 .if !defined(SRCRELDATE)
379 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
380 ${SRCDIR}/sys/sys/param.h
383 .if !defined(VERSION)
384 VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
388 .if !defined(PKG_VERSION)
389 .if ${_BRANCH:MSTABLE*} || ${_BRANCH:MCURRENT*} || ${_BRANCH:MALPHA*}
390 TIMENOW= %Y%m%d%H%M%S
391 EXTRA_REVISION= .s${TIMENOW:gmtime}
394 EXTRA_REVISION= _${_BRANCH:C/.*-p([0-9]+$)/\1/}
396 PKG_VERSION= ${_REVISION}${EXTRA_REVISION}
399 KNOWN_ARCHES?= aarch64/arm64 \
423 .if ${TARGET} == ${TARGET_ARCH}
426 _t= ${TARGET_ARCH}/${TARGET}
429 .if empty(KNOWN_ARCHES:M${_t})
430 .error Unknown target ${TARGET_ARCH}:${TARGET}.
434 .if ${TARGET} == ${MACHINE}
435 TARGET_CPUTYPE?=${CPUTYPE}
440 .if !empty(TARGET_CPUTYPE)
441 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
443 _TARGET_CPUTYPE=dummy
445 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} -f /dev/null \
446 -m ${.CURDIR}/share/mk MK_AUTO_OBJ=no -V CPUTYPE
447 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
448 .error CPUTYPE global should be set with ?=.
451 BUILD_ARCH!= uname -p
452 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
453 .error To cross-build, set TARGET_ARCH.
456 WORLDTMP?= ${OBJTOP}/tmp
457 BPATH= ${CCACHE_WRAPPER_PATH_PFX}${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
458 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
459 STRICTTMPPATH= ${BPATH}:${XPATH}
460 TMPPATH= ${STRICTTMPPATH}:${PATH}
463 # Avoid running mktemp(1) unless actually needed.
464 # It may not be functional, e.g., due to new ABI
465 # when in the middle of installing over this system.
467 .if make(distributeworld) || make(installworld) || make(stageworld)
468 INSTALLTMP!= mktemp -d -u -t install
471 .if make(stagekernel) || make(distributekernel)
477 # Building a world goes through the following stages
479 # 1. legacy stage [BMAKE]
480 # This stage is responsible for creating compatibility
481 # shims that are needed by the bootstrap-tools,
482 # build-tools and cross-tools stages. These are generally
483 # APIs that tools from one of those three stages need to
484 # build that aren't present on the host.
485 # 1. bootstrap-tools stage [BMAKE]
486 # This stage is responsible for creating programs that
487 # are needed for backward compatibility reasons. They
488 # are not built as cross-tools.
489 # 2. build-tools stage [TMAKE]
490 # This stage is responsible for creating the object
491 # tree and building any tools that are needed during
492 # the build process. Some programs are listed during
493 # this phase because they build binaries to generate
494 # files needed to build these programs. This stage also
495 # builds the 'build-tools' target rather than 'all'.
496 # 3. cross-tools stage [XMAKE]
497 # This stage is responsible for creating any tools that
498 # are needed for building the system. A cross-compiler is one
499 # of them. This differs from build tools in two ways:
500 # 1. the 'all' target is built rather than 'build-tools'
501 # 2. these tools are installed into TMPPATH for stage 4.
502 # 4. world stage [WMAKE]
503 # This stage actually builds the world.
504 # 5. install stage (optional) [IMAKE]
505 # This stage installs a previously built world.
509 # Keep these in sync -- see below for special case exception
510 MINIMUM_SUPPORTED_OSREL?= 900044
511 MINIMUM_SUPPORTED_REL?= 9.1
513 # Common environment for world related stages
515 MACHINE_ARCH=${TARGET_ARCH} \
517 CPUTYPE=${TARGET_CPUTYPE}
518 .if ${MK_META_MODE} != "no"
519 # Don't rebuild build-tools targets during normal build.
520 CROSSENV+= BUILD_TOOLS_META=.NOMETA
522 .if defined(TARGET_CFLAGS)
523 CROSSENV+= ${TARGET_CFLAGS}
526 # bootstrap-tools stage
527 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
528 TOOLS_PREFIX=${WORLDTMP} \
529 PATH=${BPATH}:${PATH} \
530 WORLDTMP=${WORLDTMP} \
531 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
532 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
534 OBJTOP='${WORLDTMP}/obj-tools' \
535 OBJROOT='$${OBJTOP}/' \
537 BOOTSTRAPPING=${OSRELDATE} \
538 BWPHASE=${.TARGET:C,^_,,} \
540 MK_HTML=no NO_LINT=yes MK_MAN=no \
541 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
542 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
543 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
544 MK_LLDB=no MK_TESTS=no \
545 MK_LLD=${MK_LLD_BOOTSTRAP} \
549 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
554 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
555 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
557 BOOTSTRAPPING=${OSRELDATE} \
558 BWPHASE=${.TARGET:C,^_,,} \
561 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
562 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
563 MK_LLDB=no MK_TESTS=no
566 # TOOLS_PREFIX set in BMAKE
568 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
569 MK_GDB=no MK_LLD_IS_LD=${MK_LLD_BOOTSTRAP} MK_TESTS=no
572 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
573 PATH=${BPATH}:${PATH} \
575 KTMAKE= TOOLS_PREFIX=${WORLDTMP} \
576 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
578 OBJTOP='${WORLDTMP}/obj-kernel-tools' \
579 OBJROOT='$${OBJTOP}/' \
581 BOOTSTRAPPING=${OSRELDATE} \
583 MK_HTML=no -DNO_LINT MK_MAN=no \
584 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
585 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
588 WMAKEENV= ${CROSSENV} \
589 INSTALL="sh ${.CURDIR}/tools/install.sh" \
594 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
596 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
599 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
600 CPP="${XCPP} ${XCFLAGS}" \
601 AS="${XAS}" AR="${XAR}" LD="${XLD}" LLVM_LINK="${XLLVM_LINK}" \
602 NM=${XNM} OBJCOPY="${XOBJCOPY}" \
603 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
606 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
607 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
608 # directory, but the compiler will look in the right place for its
609 # tools so we don't need to tell it where to look.
610 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
614 # The internal bootstrap compiler has a default sysroot set by TOOLS_PREFIX
615 # and target set by TARGET/TARGET_ARCH. However, there are several needs to
616 # always pass an explicit --sysroot and -target.
617 # - External compiler needs sysroot and target flags.
618 # - External ld needs sysroot.
619 # - To be clear about the use of a sysroot when using the internal compiler.
620 # - Easier debugging.
621 # - Allowing WITH_SYSTEM_COMPILER+WITH_META_MODE to work together due to
622 # the flip-flopping build command when sometimes using external and
623 # sometimes using internal.
624 # - Allow using lld which has no support for default paths.
625 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
626 BFLAGS+= -B${WORLDTMP}/usr/bin
628 .if ${TARGET} == "arm"
629 .if ${TARGET_ARCH:Marmv[67]*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
630 TARGET_ABI= gnueabihf
635 .if ${WANT_COMPILER_TYPE} == gcc || \
636 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
637 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
638 # won't set header path and -L is used to ensure the base library path
639 # is added before the port PREFIX library path.
640 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
641 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
642 # combined with --sysroot.
643 XCFLAGS+= -B${WORLDTMP}/usr/lib
644 # Force using libc++ for external GCC.
645 .if defined(X_COMPILER_TYPE) && \
646 ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
647 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
650 .elif ${WANT_COMPILER_TYPE} == clang || \
651 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang)
652 MACHINE_ABI?= unknown
653 MACHINE_TRIPLE?=${MACHINE_ARCH:S/amd64/x86_64/:C/hf$//:S/mipsn32/mips64/}-${MACHINE_ABI}-freebsd12.0
655 TARGET_TRIPLE?= ${TARGET_ARCH:S/amd64/x86_64/:C/hf$//:S/mipsn32/mips64/}-${TARGET_ABI}-freebsd12.0
656 XCFLAGS+= -target ${TARGET_TRIPLE}
658 XCFLAGS+= --sysroot=${WORLDTMP}
664 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
665 ${TARGET_ARCH} == "powerpc64" || ${TARGET_ARCH:Mmips64*} != "")
667 .include "Makefile.libcompat"
668 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH:Marmv[67]*} != ""
670 .include "Makefile.libcompat"
673 # META_MODE normally ignores host file changes since every build updates
674 # timestamps (see NO_META_IGNORE_HOST in sys.mk). There are known times
675 # when the ABI breaks though that we want to force rebuilding WORLDTMP
676 # to get updated host tools.
677 .if ${MK_META_MODE} == "yes" && defined(NO_CLEAN) && \
678 !defined(NO_META_IGNORE_HOST) && !defined(NO_META_IGNORE_HOST_HEADERS) && \
680 # r318736 - ino64 major ABI breakage
681 META_MODE_BAD_ABI_VERS+= 1200031
683 .if !defined(OBJDIR_HOST_OSRELDATE)
684 .if exists(${OBJTOP}/host-osreldate.h)
685 OBJDIR_HOST_OSRELDATE!= \
686 awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
687 ${OBJTOP}/host-osreldate.h
688 .elif exists(${WORLDTMP}/usr/include/osreldate.h)
689 OBJDIR_HOST_OSRELDATE= 0
691 .export OBJDIR_HOST_OSRELDATE
694 # Note that this logic is the opposite of normal BOOTSTRAP handling. We want
695 # to compare the WORLDTMP's OSRELDATE to the host's OSRELDATE. If the WORLDTMP
696 # is older than the ABI-breakage OSRELDATE of the HOST then we rebuild.
697 .if defined(OBJDIR_HOST_OSRELDATE)
698 .for _ver in ${META_MODE_BAD_ABI_VERS}
699 .if ${OSRELDATE} >= ${_ver} && ${OBJDIR_HOST_OSRELDATE} < ${_ver}
700 _meta_mode_need_rebuild= ${_ver}
703 .if defined(_meta_mode_need_rebuild)
704 .info META_MODE: Rebuilding host tools due to ABI breakage in __FreeBSD_version ${_meta_mode_need_rebuild}.
705 NO_META_IGNORE_HOST_HEADERS= 1
706 .export NO_META_IGNORE_HOST_HEADERS
707 .endif # defined(_meta_mode_need_rebuild)
708 .endif # defined(OBJDIR_HOST_OSRELDATE)
709 .endif # ${MK_META_MODE} == "yes" && defined(NO_CLEAN) ...
710 # This is only used for META_MODE+filemon to track what the oldest
711 # __FreeBSD_version is in WORLDTMP. This purposely does NOT have
712 # a make dependency on /usr/include/osreldate.h as the file should
713 # only be copied when it is missing or meta mode determines it has changed.
714 # Since host files are normally ignored without NO_META_IGNORE_HOST
715 # the file will never be updated unless that flag is specified. This
716 # allows tracking the oldest osreldate to force rebuilds via
717 # META_MODE_BADABI_REVS above.
718 host-osreldate.h: # DO NOT ADD /usr/include/osreldate.h here
719 @cp -f /usr/include/osreldate.h ${.TARGET}
721 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
722 BWPHASE=${.TARGET:C,^_,,} \
725 IMAKEENV= ${CROSSENV}
726 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
727 ${IMAKE_INSTALL} ${IMAKE_MTREE}
728 .if empty(.MAKEFLAGS:M-n)
729 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
730 LD_LIBRARY_PATH=${INSTALLTMP} \
731 PATH_LOCALE=${INSTALLTMP}/locale
732 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
734 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
736 .if defined(DB_FROM_SRC)
737 INSTALLFLAGS+= -N ${.CURDIR}/etc
738 MTREEFLAGS+= -N ${.CURDIR}/etc
740 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
741 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
743 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
744 METALOG:= ${METALOG:C,//+,/,g}
745 IMAKE+= -DNO_ROOT METALOG=${METALOG}
746 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
749 .if defined(BUILD_PKGS)
750 INSTALLFLAGS+= -h sha256
752 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
753 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
754 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
758 KMAKEENV= ${WMAKEENV:NSYSROOT=*}
759 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
764 # Attempt to rebuild the entire system, with reasonable chance of
765 # success, regardless of how old your existing system is.
767 _sanity_check: .PHONY .MAKE
768 .if ${.CURDIR:C/[^,]//g} != ""
769 # The m4 build of sendmail files doesn't like it if ',' is used
770 # anywhere in the path of it's files.
772 @echo "*** Error: path to source tree contains a comma ','"
775 .elif ${.CURDIR:M*\:*} != ""
776 # Using ':' leaks into PATH and breaks finding cross-tools.
778 @echo "*** Error: path to source tree contains a colon ':'"
783 # Our current approach to dependency tracking cannot cope with certain source
784 # tree changes, particularly with respect to removing source files and
785 # replacing generated files. Handle these cases here in an ad-hoc fashion.
786 _cleanobj_fast_depend_hack: .PHONY
787 # Syscall stubs rewritten in C
788 # Date SVN Rev Syscalls
789 # 20160829 r305012 ptrace
790 # 20170624 r320278 fstat fstatat fstatfs getdirentries getfsstat statfs
791 .for f in fstat fstatat fstatfs getdirentries getfsstat ptrace statfs
792 .if exists(${OBJTOP}/lib/libc/.depend.${f}.o)
793 @if egrep -qw '${f}\.[sS]' \
794 ${OBJTOP}/lib/libc/.depend.${f}.o; then \
795 echo Removing stale dependencies for ${f} syscall wrappers; \
796 rm -f ${OBJTOP}/lib/libc/.depend.${f}.* \
797 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \
801 # 20170607 remove stale dependencies for utimens* wrappers removed in r319663
802 .for f in futimens utimensat
803 .if exists(${OBJTOP}/lib/libc/.depend.${f}.o)
804 @if egrep -q '/${f}.c' \
805 ${OBJTOP}/lib/libc/.depend.${f}.o; then \
806 echo Removing stale dependencies for ${f} syscall wrappers; \
807 rm -f ${OBJTOP}/lib/libc/.depend.${f}.* \
808 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \
812 # 20170523 remove stale generated asm files for functions which are no longer
813 # syscalls after r302092 (pipe) and r318736 (others)
814 .for f in getdents lstat mknod pipe stat
815 .if exists(${OBJTOP}/lib/libc/${f}.s) || \
816 exists(${OBJTOP}/lib/libc/${f}.S)
817 @echo Removing stale generated ${f} syscall files
818 @rm -f ${OBJTOP}/lib/libc/${f}.* \
819 ${OBJTOP}/lib/libc/.depend.${f}.* \
820 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/${f}.*} \
821 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}
827 @echo "--------------------------------------------------------------"
828 @echo ">>> Rebuilding the temporary build tree"
829 @echo "--------------------------------------------------------------"
830 .if !defined(NO_CLEAN)
833 .if exists(${WORLDTMP})
834 @echo ">>> Deleting stale files in build tree..."
835 ${_+_}cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \
836 delete-old delete-old-libs >/dev/null
838 rm -rf ${WORLDTMP}/legacy/usr/include
839 .if ${USING_SYSTEM_COMPILER} == "yes"
841 if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \
842 inum=$$(stat -f %i ${WORLDTMP}/usr/bin/${cc}); \
843 find ${WORLDTMP}/usr/bin -inum $${inum} -delete; \
846 .endif # ${USING_SYSTEM_COMPILER} == "yes"
847 .endif # !defined(NO_CLEAN)
848 @mkdir -p ${WORLDTMP}
849 @touch ${WORLDTMP}/${.TARGET}
852 lib lib/casper usr legacy/bin legacy/usr
853 mkdir -p ${WORLDTMP}/${_dir}
855 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
856 -p ${WORLDTMP}/legacy/usr >/dev/null
857 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
858 -p ${WORLDTMP}/legacy/usr/include >/dev/null
859 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
860 -p ${WORLDTMP}/usr >/dev/null
861 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
862 -p ${WORLDTMP}/usr/include >/dev/null
863 ln -sf ${.CURDIR}/sys ${WORLDTMP}
864 .if ${MK_DEBUG_FILES} != "no"
865 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
866 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
867 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
868 -p ${WORLDTMP}/usr/lib >/dev/null
870 .for _mtree in ${LOCAL_MTREE}
871 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
875 @echo "--------------------------------------------------------------"
876 @echo ">>> stage 1.1: legacy release compatibility shims"
877 @echo "--------------------------------------------------------------"
878 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
881 @echo "--------------------------------------------------------------"
882 @echo ">>> stage 1.2: bootstrap tools"
883 @echo "--------------------------------------------------------------"
884 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
886 .if !defined(NO_CLEAN)
888 @echo "--------------------------------------------------------------"
889 @echo ">>> stage 2.1: cleaning up the object tree"
890 @echo "--------------------------------------------------------------"
891 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
892 .if defined(LIBCOMPAT)
893 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
896 ${_+_}cd ${.CURDIR}; ${WMAKE} _cleanobj_fast_depend_hack
897 .endif # !defined(NO_CLEAN)
900 @echo "--------------------------------------------------------------"
901 @echo ">>> stage 2.2: rebuilding the object tree"
902 @echo "--------------------------------------------------------------"
903 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
906 @echo "--------------------------------------------------------------"
907 @echo ">>> stage 2.3: build tools"
908 @echo "--------------------------------------------------------------"
909 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
912 @echo "--------------------------------------------------------------"
913 @echo ">>> stage 3: cross tools"
914 @echo "--------------------------------------------------------------"
915 @rm -f ${OBJTOP}/compiler-metadata.mk
916 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
917 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
920 @echo "--------------------------------------------------------------"
921 @echo ">>> stage 3.1: recording build metadata"
922 @echo "--------------------------------------------------------------"
923 ${_+_}cd ${.CURDIR}; ${WMAKE} compiler-metadata.mk
924 ${_+_}cd ${.CURDIR}; ${WMAKE} host-osreldate.h
927 @echo "--------------------------------------------------------------"
928 @echo ">>> stage 4.1: building includes"
929 @echo "--------------------------------------------------------------"
930 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
931 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
932 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
933 MK_INCLUDES=yes includes
934 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
935 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
939 @echo "--------------------------------------------------------------"
940 @echo ">>> stage 4.2: building libraries"
941 @echo "--------------------------------------------------------------"
942 ${_+_}cd ${.CURDIR}; \
943 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
944 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
947 @echo "--------------------------------------------------------------"
948 @echo ">>> stage 4.3: building everything"
949 @echo "--------------------------------------------------------------"
950 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
953 .if !defined(WORLDFAST)
954 WMAKE_TGTS+= _sanity_check _worldtmp _legacy
955 .if empty(SUBDIR_OVERRIDE)
956 WMAKE_TGTS+= _bootstrap-tools
958 WMAKE_TGTS+= _cleanobj
959 .if !defined(NO_OBJWALK)
962 WMAKE_TGTS+= _build-tools _cross-tools
963 WMAKE_TGTS+= _build-metadata
964 WMAKE_TGTS+= _includes
966 .if !defined(NO_LIBS)
967 WMAKE_TGTS+= _libraries
969 WMAKE_TGTS+= everything
970 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
971 WMAKE_TGTS+= build${libcompat}
974 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
975 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
977 buildworld_prologue: .PHONY
978 @echo "--------------------------------------------------------------"
979 @echo ">>> World build started on `LC_ALL=C date`"
980 @echo "--------------------------------------------------------------"
982 buildworld_epilogue: .PHONY
984 @echo "--------------------------------------------------------------"
985 @echo ">>> World build completed on `LC_ALL=C date`"
986 @echo "--------------------------------------------------------------"
989 # We need to have this as a target because the indirection between Makefile
990 # and Makefile.inc1 causes the correct PATH to be used, rather than a
991 # modification of the current environment's PATH. In addition, we need
992 # to quote multiword values.
995 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
997 .if ${.TARGETS:Mbuildenv}
998 .if ${.MAKEFLAGS:M-j}
999 .error The buildenv target is incompatible with -j
1002 BUILDENV_DIR?= ${.CURDIR}
1004 # Note: make will report any errors the shell reports. This can
1005 # be odd if the last command in an interactive shell generates an
1006 # error or is terminated by SIGINT. These reported errors look bad,
1007 # but are harmless. Allowing them also allows BUIDLENV_SHELL to
1008 # be a complex command whose status will be returned to the caller.
1009 # Some scripts in tools rely on this behavior to report build errors.
1012 @echo Entering world for ${TARGET_ARCH}:${TARGET}
1013 .if ${BUILDENV_SHELL:M*zsh*}
1014 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
1016 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL}
1018 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
1019 toolchain: ${TOOLCHAIN_TGTS} .PHONY
1020 KERNEL_TOOLCHAIN_TGTS= ${TOOLCHAIN_TGTS:N_obj:N_cleanobj:N_includes:N_libraries}
1021 .if make(kernel-toolchain)
1022 .ORDER: ${KERNEL_TOOLCHAIN_TGTS}
1024 kernel-toolchain: ${KERNEL_TOOLCHAIN_TGTS} .PHONY
1029 # Checks to be sure system is ready for installworld/installkernel.
1031 installcheck: _installcheck_world _installcheck_kernel .PHONY
1032 _installcheck_world: .PHONY
1033 _installcheck_kernel: .PHONY
1036 # Require DESTDIR to be set if installing for a different architecture or
1037 # using the user/group database in the source tree.
1039 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
1040 defined(DB_FROM_SRC)
1041 .if !make(distributeworld)
1042 _installcheck_world: __installcheck_DESTDIR
1043 _installcheck_kernel: __installcheck_DESTDIR
1044 __installcheck_DESTDIR: .PHONY
1045 .if !defined(DESTDIR) || empty(DESTDIR)
1046 @echo "ERROR: Please set DESTDIR!"; \
1052 .if !defined(DB_FROM_SRC)
1054 # Check for missing UIDs/GIDs.
1056 CHECK_UIDS= auditdistd
1058 .if ${MK_SENDMAIL} != "no"
1062 .if ${MK_PF} != "no"
1064 CHECK_GIDS+= proxy authpf
1066 .if ${MK_UNBOUND} != "no"
1067 CHECK_UIDS+= unbound
1068 CHECK_GIDS+= unbound
1070 _installcheck_world: __installcheck_UGID
1071 __installcheck_UGID: .PHONY
1072 .for uid in ${CHECK_UIDS}
1073 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
1074 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
1078 .for gid in ${CHECK_GIDS}
1079 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
1080 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
1086 # If installing over the running system (DESTDIR is / or unset) and the install
1087 # includes rescue, try running rescue from the objdir as a sanity check. If
1088 # rescue is not functional (e.g., because it depends on a system call not
1089 # supported by the currently running kernel), abort the installation.
1091 .if !make(distributeworld) && ${MK_RESCUE} != "no" && \
1092 (empty(DESTDIR) || ${DESTDIR} == "/") && empty(BYPASS_INSTALLCHECK_SH)
1093 _installcheck_world: __installcheck_sh_check
1094 __installcheck_sh_check: .PHONY
1095 @if [ "`${OBJTOP}/rescue/rescue/rescue sh -c 'echo OK'`" != \
1097 echo "rescue/sh check failed, installation aborted" >&2; \
1103 # Required install tools to be saved in a scratch dir for safety.
1105 .if ${MK_ZONEINFO} != "no"
1106 _zoneinfo= zic tzsetup
1109 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
1110 date echo egrep find grep id install ${_install-info} \
1111 ln make mkdir mtree mv pwd_mkdb \
1112 rm sed services_mkdb sh sort strip sysctl test true uname wc ${_zoneinfo} \
1115 # Needed for share/man
1116 .if ${MK_MAN_UTILS} != "no"
1123 # Distributes everything compiled by a `buildworld'.
1127 # Installs everything compiled by a 'buildworld'.
1130 # Non-base distributions produced by the base system
1131 EXTRA_DISTRIBUTIONS= doc
1132 .if defined(LIBCOMPAT)
1133 EXTRA_DISTRIBUTIONS+= lib${libcompat}
1135 .if ${MK_TESTS} != "no"
1136 EXTRA_DISTRIBUTIONS+= tests
1139 DEBUG_DISTRIBUTIONS=
1140 .if ${MK_DEBUG_FILES} != "no"
1141 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
1144 MTREE_MAGIC?= mtree 2.0
1146 distributeworld installworld stageworld: _installcheck_world .PHONY
1147 mkdir -p ${INSTALLTMP}
1148 progs=$$(for prog in ${ITOOLS}; do \
1149 if progpath=`which $$prog`; then \
1152 echo "Required tool $$prog not found in PATH." >&2; \
1156 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
1157 while read line; do \
1159 if [ "$$2 $$3" != "not found" ]; then \
1162 echo "Required library $$1 not found." >&2; \
1166 cp $$libs $$progs ${INSTALLTMP}
1167 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
1168 .if defined(NO_ROOT)
1169 -mkdir -p ${METALOG:H}
1170 echo "#${MTREE_MAGIC}" > ${METALOG}
1172 .if make(distributeworld)
1173 .for dist in ${EXTRA_DISTRIBUTIONS}
1174 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
1175 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1176 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
1177 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1178 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1179 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1180 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
1181 .if ${MK_DEBUG_FILES} != "no"
1182 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1183 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
1185 .if defined(LIBCOMPAT)
1186 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1187 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1188 .if ${MK_DEBUG_FILES} != "no"
1189 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1190 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
1193 .if ${MK_TESTS} != "no" && ${dist} == "tests"
1194 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
1195 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1196 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
1197 .if ${MK_DEBUG_FILES} != "no"
1198 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1199 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
1202 .if defined(NO_ROOT)
1203 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1204 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1205 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1206 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1207 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1208 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1209 .if defined(LIBCOMPAT)
1210 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
1211 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1215 -mkdir ${DESTDIR}/${DISTDIR}/base
1216 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1217 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1218 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1219 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1221 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1222 ${IMAKEENV} rm -rf ${INSTALLTMP}
1223 .if make(distributeworld)
1224 .for dist in ${EXTRA_DISTRIBUTIONS}
1225 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete
1227 .if defined(NO_ROOT)
1228 .for dist in base ${EXTRA_DISTRIBUTIONS}
1229 @# For each file that exists in this dist, print the corresponding
1230 @# line from the METALOG. This relies on the fact that
1231 @# a line containing only the filename will sort immediately before
1232 @# the relevant mtree line.
1233 cd ${DESTDIR}/${DISTDIR}; \
1234 find ./${dist} | sort -u ${METALOG} - | \
1235 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1236 ${DESTDIR}/${DISTDIR}/${dist}.meta
1238 .for dist in ${DEBUG_DISTRIBUTIONS}
1239 @# For each file that exists in this dist, print the corresponding
1240 @# line from the METALOG. This relies on the fact that
1241 @# a line containing only the filename will sort immediately before
1242 @# the relevant mtree line.
1243 cd ${DESTDIR}/${DISTDIR}; \
1244 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1245 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1246 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1251 packageworld: .PHONY
1252 .for dist in base ${EXTRA_DISTRIBUTIONS}
1253 .if defined(NO_ROOT)
1254 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1255 tar cvf - --exclude usr/lib/debug \
1256 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1257 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1259 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1260 tar cvf - --exclude usr/lib/debug . | \
1261 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1265 .for dist in ${DEBUG_DISTRIBUTIONS}
1266 . if defined(NO_ROOT)
1267 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1268 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1269 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1271 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1272 tar cvLf - usr/lib/debug | \
1273 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1280 # If you have a build server, you can NFS mount the source and obj directories
1281 # and do a 'make reinstall' on the *client* to install new binaries from the
1282 # most recent server build.
1284 restage reinstall: .MAKE .PHONY
1285 @echo "--------------------------------------------------------------"
1286 @echo ">>> Making hierarchy"
1287 @echo "--------------------------------------------------------------"
1288 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1289 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1291 @echo "--------------------------------------------------------------"
1292 @echo ">>> Making distribution"
1293 @echo "--------------------------------------------------------------"
1294 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1295 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
1298 @echo "--------------------------------------------------------------"
1299 @echo ">>> Installing everything"
1300 @echo "--------------------------------------------------------------"
1301 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1302 .if defined(LIBCOMPAT)
1303 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1306 redistribute: .MAKE .PHONY
1307 @echo "--------------------------------------------------------------"
1308 @echo ">>> Distributing everything"
1309 @echo "--------------------------------------------------------------"
1310 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1311 .if defined(LIBCOMPAT)
1312 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1313 DISTRIBUTION=lib${libcompat}
1316 distrib-dirs distribution: .MAKE .PHONY
1317 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1318 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1319 .if make(distribution)
1320 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1321 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1322 METALOG=${METALOG} MK_TESTS=no installconfig
1326 # buildkernel and installkernel
1328 # Which kernels to build and/or install is specified by setting
1329 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1330 # Only the existing (depending TARGET) config files are used
1331 # for building kernels and only the first of these is designated
1332 # as the one being installed.
1334 # Note that we have to use TARGET instead of TARGET_ARCH when
1335 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1336 # be set to cross-build, we have to make sure TARGET is set
1339 .if defined(KERNFAST)
1343 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1344 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1345 KERNCONF=${KERNFAST}
1348 .if ${TARGET_ARCH} == "powerpc64"
1349 KERNCONF?= GENERIC64
1353 INSTKERNNAME?= kernel
1355 KERNSRCDIR?= ${.CURDIR}/sys
1356 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1357 KRNLOBJDIR= ${OBJTOP}${KERNSRCDIR:C,^${.CURDIR},,}
1358 KERNCONFDIR?= ${KRNLCONFDIR}
1362 .if defined(NO_INSTALLKERNEL)
1363 # All of the BUILDKERNELS loops start at index 1.
1364 BUILDKERNELS+= dummy
1366 .for _kernel in ${KERNCONF}
1367 .if exists(${KERNCONFDIR}/${_kernel})
1368 BUILDKERNELS+= ${_kernel}
1369 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1370 INSTALLKERNEL= ${_kernel}
1373 .if make(buildkernel)
1374 .error Missing KERNCONF ${KERNCONFDIR}/${_kernel}
1379 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1384 # Builds all kernels defined by BUILDKERNELS.
1386 buildkernel: .MAKE .PHONY
1387 .if empty(BUILDKERNELS:Ndummy)
1388 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1392 .for _kernel in ${BUILDKERNELS:Ndummy}
1393 @echo "--------------------------------------------------------------"
1394 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1395 @echo "--------------------------------------------------------------"
1396 @echo "===> ${_kernel}"
1397 mkdir -p ${KRNLOBJDIR}
1398 .if !defined(NO_KERNELCONFIG)
1400 @echo "--------------------------------------------------------------"
1401 @echo ">>> stage 1: configuring the kernel"
1402 @echo "--------------------------------------------------------------"
1403 cd ${KRNLCONFDIR}; \
1405 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1406 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1408 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1410 @echo "--------------------------------------------------------------"
1411 @echo ">>> stage 2.1: cleaning up the object tree"
1412 @echo "--------------------------------------------------------------"
1413 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1415 .if !defined(NO_KERNELOBJ)
1417 @echo "--------------------------------------------------------------"
1418 @echo ">>> stage 2.2: rebuilding the object tree"
1419 @echo "--------------------------------------------------------------"
1420 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1423 @echo "--------------------------------------------------------------"
1424 @echo ">>> stage 2.3: build tools"
1425 @echo "--------------------------------------------------------------"
1426 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1428 @echo "--------------------------------------------------------------"
1429 @echo ">>> stage 3.1: building everything"
1430 @echo "--------------------------------------------------------------"
1431 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1432 @echo "--------------------------------------------------------------"
1433 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1434 @echo "--------------------------------------------------------------"
1437 NO_INSTALLEXTRAKERNELS?= yes
1440 # installkernel, etc.
1442 # Install the kernel defined by INSTALLKERNEL
1444 installkernel installkernel.debug \
1445 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1446 .if !defined(NO_INSTALLKERNEL)
1447 .if empty(INSTALLKERNEL)
1448 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1451 @echo "--------------------------------------------------------------"
1452 @echo ">>> Installing kernel ${INSTALLKERNEL} on $$(LC_ALL=C date)"
1453 @echo "--------------------------------------------------------------"
1454 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1455 ${CROSSENV} PATH=${TMPPATH} \
1456 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1457 @echo "--------------------------------------------------------------"
1458 @echo ">>> Installing kernel ${INSTALLKERNEL} completed on $$(LC_ALL=C date)"
1459 @echo "--------------------------------------------------------------"
1461 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1462 .for _kernel in ${BUILDKERNELS:[2..-1]}
1463 @echo "--------------------------------------------------------------"
1464 @echo ">>> Installing kernel ${_kernel} $$(LC_ALL=C date)"
1465 @echo "--------------------------------------------------------------"
1466 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
1467 ${CROSSENV} PATH=${TMPPATH} \
1468 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1469 @echo "--------------------------------------------------------------"
1470 @echo ">>> Installing kernel ${_kernel} completed on $$(LC_ALL=C date)"
1471 @echo "--------------------------------------------------------------"
1475 distributekernel distributekernel.debug: .PHONY
1476 .if !defined(NO_INSTALLKERNEL)
1477 .if empty(INSTALLKERNEL)
1478 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1481 mkdir -p ${DESTDIR}/${DISTDIR}
1482 .if defined(NO_ROOT)
1483 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1485 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1486 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1487 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1488 DESTDIR=${INSTALL_DDIR}/kernel \
1489 ${.TARGET:S/distributekernel/install/}
1490 .if defined(NO_ROOT)
1491 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1492 ${DESTDIR}/${DISTDIR}/kernel.meta
1495 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1496 .for _kernel in ${BUILDKERNELS:[2..-1]}
1497 .if defined(NO_ROOT)
1498 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1500 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
1501 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1502 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1503 KERNEL=${INSTKERNNAME}.${_kernel} \
1504 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1505 ${.TARGET:S/distributekernel/install/}
1506 .if defined(NO_ROOT)
1507 @sed -e "s|^./kernel.${_kernel}|.|" \
1508 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1509 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1514 packagekernel: .PHONY
1515 .if defined(NO_ROOT)
1516 .if !defined(NO_INSTALLKERNEL)
1517 cd ${DESTDIR}/${DISTDIR}/kernel; \
1518 tar cvf - --exclude '*.debug' \
1519 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1520 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1522 .if ${MK_DEBUG_FILES} != "no"
1523 cd ${DESTDIR}/${DISTDIR}/kernel; \
1524 tar cvf - --include '*/*/*.debug' \
1525 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1526 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1528 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1529 .for _kernel in ${BUILDKERNELS:[2..-1]}
1530 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1531 tar cvf - --exclude '*.debug' \
1532 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1533 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1534 .if ${MK_DEBUG_FILES} != "no"
1535 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1536 tar cvf - --include '*/*/*.debug' \
1537 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1538 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1543 .if !defined(NO_INSTALLKERNEL)
1544 cd ${DESTDIR}/${DISTDIR}/kernel; \
1545 tar cvf - --exclude '*.debug' . | \
1546 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1548 .if ${MK_DEBUG_FILES} != "no"
1549 cd ${DESTDIR}/${DISTDIR}/kernel; \
1550 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1551 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1553 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1554 .for _kernel in ${BUILDKERNELS:[2..-1]}
1555 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1556 tar cvf - --exclude '*.debug' . | \
1557 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1558 .if ${MK_DEBUG_FILES} != "no"
1559 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1560 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1561 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1568 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1570 PORTSDIR?= /usr/ports
1571 WSTAGEDIR?= ${OBJTOP}/worldstage
1572 KSTAGEDIR?= ${OBJTOP}/kernelstage
1573 REPODIR?= ${OBJROOT}repo
1574 PKGSIGNKEY?= # empty
1576 .ORDER: stage-packages create-packages
1577 .ORDER: create-packages create-world-packages
1578 .ORDER: create-packages create-kernel-packages
1579 .ORDER: create-packages sign-packages
1581 _pkgbootstrap: .PHONY
1582 .if !exists(${LOCALBASE}/sbin/pkg)
1583 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1587 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1590 rm -rf /tmp/ports.${TARGET} || :
1591 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
1592 PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \
1593 WSTAGEDIR=${WSTAGEDIR} \
1594 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1596 real-packages: stage-packages create-packages sign-packages .PHONY
1598 stage-packages-world: .PHONY
1599 @mkdir -p ${WSTAGEDIR}
1600 ${_+_}@cd ${.CURDIR}; \
1601 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT stageworld
1603 stage-packages-kernel: .PHONY
1604 @mkdir -p ${KSTAGEDIR}
1605 ${_+_}@cd ${.CURDIR}; \
1606 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT stagekernel
1608 stage-packages: .PHONY stage-packages-world stage-packages-kernel
1611 @mkdir -p ${REPODIR}
1613 create-packages-world: _pkgbootstrap _repodir .PHONY
1614 ${_+_}@cd ${.CURDIR}; \
1615 ${MAKE} -f Makefile.inc1 \
1616 DESTDIR=${WSTAGEDIR} \
1617 PKG_VERSION=${PKG_VERSION} create-world-packages
1619 create-packages-kernel: _pkgbootstrap _repodir .PHONY
1620 ${_+_}@cd ${.CURDIR}; \
1621 ${MAKE} -f Makefile.inc1 \
1622 DESTDIR=${KSTAGEDIR} \
1623 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1624 create-kernel-packages
1626 create-packages: .PHONY create-packages-world create-packages-kernel
1628 create-world-packages: _pkgbootstrap .PHONY
1629 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1630 @cd ${WSTAGEDIR} ; \
1631 env -i LC_COLLATE=C sort ${WSTAGEDIR}/METALOG | \
1632 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk
1633 @for plist in ${WSTAGEDIR}/*.plist; do \
1634 plist=$${plist##*/} ; \
1635 pkgname=$${plist%.plist} ; \
1636 echo "_PKGS+= $${pkgname}" ; \
1637 done > ${WSTAGEDIR}/packages.mk
1638 ${_+_}@cd ${.CURDIR}; \
1639 ${MAKE} -f Makefile.inc1 create-world-packages-jobs \
1642 .if make(create-world-packages-jobs)
1643 .include "${WSTAGEDIR}/packages.mk"
1646 create-world-packages-jobs: .PHONY
1647 .for pkgname in ${_PKGS}
1648 create-world-packages-jobs: create-world-package-${pkgname}
1649 create-world-package-${pkgname}: .PHONY
1650 @sh ${SRCDIR}/release/packages/generate-ucl.sh -o ${pkgname} \
1651 -s ${SRCDIR} -u ${WSTAGEDIR}/${pkgname}.ucl
1653 /^name/ { printf("===> Creating %s-", $$2); next } \
1654 /^version/ { print $$2; next } \
1655 ' ${WSTAGEDIR}/${pkgname}.ucl
1656 @if [ "${pkgname}" == "runtime" ]; then \
1657 sed -i '' -e "s/%VCS_REVISION%/${VCS_REVISION}/" ${WSTAGEDIR}/${pkgname}.ucl ; \
1659 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1660 create -M ${WSTAGEDIR}/${pkgname}.ucl \
1661 -p ${WSTAGEDIR}/${pkgname}.plist \
1663 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1666 create-kernel-packages: .PHONY
1667 _default_flavor= -default
1668 .if exists(${KSTAGEDIR}/kernel.meta)
1669 . if ${MK_DEBUG_FILES} != "no"
1672 . for flavor in "" ${_debug}
1673 create-kernel-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}
1674 create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY
1675 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1676 env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.meta | \
1677 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1678 -v kernel=yes -v _kernconf=${INSTALLKERNEL} ; \
1679 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1680 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1681 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1682 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1683 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1684 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1685 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1686 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1687 -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \
1688 ${SRCDIR}/release/packages/kernel.ucl \
1689 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1691 /name/ { printf("===> Creating %s-", $$2); next } \
1692 /version/ {print $$2; next } ' \
1693 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1694 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1695 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1696 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1697 -r ${KSTAGEDIR}/${DISTDIR} \
1698 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1701 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1702 . for _kernel in ${BUILDKERNELS:[2..-1]}
1703 . if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1704 . if ${MK_DEBUG_FILES} != "no"
1707 . for flavor in "" ${_debug}
1708 create-kernel-packages: create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}
1709 create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}: _pkgbootstrap .PHONY
1710 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1711 env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.${_kernel}.meta | \
1712 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1713 -v kernel=yes -v _kernconf=${_kernel} ; \
1714 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1715 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1716 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1717 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1718 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1719 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1720 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1721 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1722 -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \
1723 ${SRCDIR}/release/packages/kernel.ucl \
1724 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1726 /name/ { printf("===> Creating %s-", $$2); next } \
1727 /version/ {print $$2; next } ' \
1728 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1729 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1730 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1731 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1732 -r ${KSTAGEDIR}/kernel.${_kernel} \
1733 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1739 sign-packages: _pkgbootstrap .PHONY
1740 @[ -L "${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1741 unlink ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1742 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1743 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1744 ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1746 cd ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI); \
1747 ln -s ${PKG_VERSION} latest
1753 # Run test suite on installed world.
1756 @if [ ! -x "${LOCALBASE}/bin/kyua" ]; then \
1757 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1760 ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile
1766 # Build the API documentation with doxygen
1769 @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \
1770 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1773 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1778 # Update the source tree(s), by running svn/svnup to update to the
1782 .if defined(SVN_UPDATE)
1783 @echo "--------------------------------------------------------------"
1784 @echo ">>> Updating ${.CURDIR} using Subversion"
1785 @echo "--------------------------------------------------------------"
1786 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1790 # ------------------------------------------------------------------------
1792 # From here onwards are utility targets used by the 'make world' and
1793 # related targets. If your 'world' breaks, you may like to try to fix
1794 # the problem and manually run the following targets to attempt to
1795 # complete the build. Beware, this is *not* guaranteed to work, you
1796 # need to have a pretty good grip on the current state of the system
1797 # to attempt to manually finish it. If in doubt, 'make world' again.
1801 # legacy: Build compatibility shims for the next three targets. This is a
1802 # minimal set of tools and shims necessary to compensate for older systems
1803 # which don't have the APIs required by the targets built in bootstrap-tools,
1804 # build-tools or cross-tools.
1807 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1808 # r296685 fix cross-endian objcopy
1809 # r310724 fixed PR 215350, a crash in libdwarf with objects built by GCC 6.2.
1810 .if ${BOOTSTRAPPING} < 1200020
1811 _elftoolchain_libs= lib/libelf lib/libdwarf
1815 # Temporary special case for automatically detecting the clang compiler issue
1816 # Note: 9.x didn't have FreeBSD_version bumps often enough, so you may need to
1817 # set BOOTSTRAPPING to 0 if you're stable/9 tree post-dates r286035 but is before
1818 # the version bump in r296219 (from July 29, 2015 -> Feb 29, 2016).
1819 .if ${BOOTSTRAPPING} != 0 && \
1820 ${WANT_COMPILER_TYPE} == "clang" && ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} < 30601
1821 .if ${BOOTSTRAPPING} > 10000000 && ${BOOTSTRAPPING} < 1002501
1822 @echo "ERROR: Source upgrades from stable/10 prior to r286033 are not supported."; false
1823 .elif ${BOOTSTRAPPING} > 9000000 && ${BOOTSTRAPPING} < 903509
1824 @echo "ERROR: Source upgrades from stable/9 prior to r286035 are not supported."; false
1827 .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
1828 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
1832 .for _tool in tools/build ${_elftoolchain_libs}
1833 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1834 cd ${.CURDIR}/${_tool}; \
1835 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
1836 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy includes; \
1837 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
1838 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
1839 DESTDIR=${WORLDTMP}/legacy install
1843 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1844 # are built to build other binaries in the system. However, the focus of these
1845 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1846 # libraries, augmented by -legacy.
1848 _bt= _bootstrap-tools
1850 .if ${MK_GAMES} != "no"
1851 _strfile= usr.bin/fortune/strfile
1854 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1855 _gperf= gnu/usr.bin/gperf
1858 .if ${MK_VT} != "no"
1859 _vtfontcvt= usr.bin/vtfontcvt
1862 .if ${BOOTSTRAPPING} < 1000033
1866 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1867 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1870 # r245440 mtree -N support added
1871 # r313404 requires sha384.h for libnetbsd, added to libmd in r292782
1872 .if ${BOOTSTRAPPING} < 1100093
1873 _nmtree= lib/libmd \
1877 ${_bt}-lib/libnetbsd: ${_bt}-lib/libmd
1878 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1881 # r246097: log addition login.conf.db, passwd, pwd.db, and spwd.db with cat -l
1882 .if ${BOOTSTRAPPING} < 1000027
1886 # r277259 crunchide: Correct 64-bit section header offset
1887 # r281674 crunchide: always include both 32- and 64-bit ELF support
1888 .if ${BOOTSTRAPPING} < 1100078
1889 _crunchide= usr.sbin/crunch/crunchide
1892 # r285986 crunchen: use STRIPBIN rather than STRIP
1893 # 1100113: Support MK_AUTO_OBJ
1894 # 1200006: META_MODE fixes
1895 .if ${BOOTSTRAPPING} < 1100078 || \
1896 (${MK_AUTO_OBJ} == "yes" && ${BOOTSTRAPPING} < 1100114) || \
1897 (${MK_META_MODE} == "yes" && ${BOOTSTRAPPING} < 1200006)
1898 _crunchgen= usr.sbin/crunch/crunchgen
1901 # r296926 -P keymap search path, MFC to stable/10 in r298297
1902 .if ${BOOTSTRAPPING} < 1003501 || \
1903 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
1904 _kbdcontrol= usr.sbin/kbdcontrol
1910 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1912 .if ${MK_BSNMP} != "no"
1913 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1916 # We need to build tblgen when we're building clang or lld, either as
1917 # bootstrap tools, or as the part of the normal build.
1918 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
1919 ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no"
1921 lib/clang/libllvmminimal \
1922 usr.bin/clang/llvm-tblgen \
1923 usr.bin/clang/clang-tblgen
1925 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal
1926 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal
1929 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1932 .if ${MK_GPL_DTC} != "no"
1933 _dtc= gnu/usr.bin/dtc
1936 .if ${MK_KERBEROS} != "no"
1937 _kerberos5_bootstrap_tools= \
1938 kerberos5/tools/make-roken \
1939 kerberos5/lib/libroken \
1940 kerberos5/lib/libvers \
1941 kerberos5/tools/asn1_compile \
1942 kerberos5/tools/slc \
1945 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1948 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
1950 bootstrap-tools: .PHONY
1952 # Please document (add comment) why something is in 'bootstrap-tools'.
1953 # Try to bound the building of the bootstrap-tool to just the
1954 # FreeBSD versions that need the tool built at this stage of the build.
1957 ${_kerberos5_bootstrap_tools} \
1978 ${_bt}-${_tool}: .PHONY .MAKE
1979 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1980 cd ${.CURDIR}/${_tool}; \
1981 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
1982 ${MAKE} DIRPRFX=${_tool}/ all; \
1983 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy install
1985 bootstrap-tools: ${_bt}-${_tool}
1989 # build-tools: Build special purpose build tools
1991 .if !defined(NO_SHARE) && ${MK_SYSCONS} != "no"
1992 _share= share/syscons/scrnmaps
1995 .if ${MK_GCC} != "no"
1996 _gcc_tools= gnu/usr.bin/cc/cc_tools
1999 .if ${MK_RESCUE} != "no"
2000 # rescue includes programs that have build-tools targets
2001 _rescue=rescue/rescue
2004 .if ${MK_TCSH} != "no"
2007 .if ${MK_FILE} != "no"
2008 _libmagic=lib/libmagic
2011 # kernel-toolchain skips _cleanobj, so handle cleaning up previous
2012 # build-tools directories if needed.
2013 .if !defined(NO_CLEAN) && make(kernel-toolchain)
2014 _bt_clean= ${CLEANDIR}
2020 ${LOCAL_TOOL_DIRS} \
2021 lib/ncurses/ncurses \
2022 lib/ncurses/ncursesw \
2027 usr.bin/mkesdb_static \
2028 usr.bin/mkcsmapper_static \
2029 usr.bin/vi/catalog \
2031 build-tools_${_tool}: .PHONY
2032 ${_+_}@${ECHODIR} "===> ${_tool} (${_bt_clean:D${_bt_clean},}obj,build-tools)"; \
2033 cd ${.CURDIR}/${_tool}; \
2034 if [ -n "${_bt_clean}" ]; then ${MAKE} DIRPRFX=${_tool}/ ${_bt_clean}; fi; \
2035 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2036 ${MAKE} DIRPRFX=${_tool}/ build-tools
2037 build-tools: build-tools_${_tool}
2041 # kernel-tools: Build kernel-building tools
2043 kernel-tools: .PHONY
2044 mkdir -p ${WORLDTMP}/usr
2045 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2046 -p ${WORLDTMP}/usr >/dev/null
2049 # cross-tools: All the tools needed to build the rest of the system after
2050 # we get done with the earlier stages. It is the last set of tools needed
2051 # to begin building the target binaries.
2053 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
2054 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
2055 _btxld= usr.sbin/btxld
2059 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
2060 # resulting from missing bug fixes or ELF Toolchain updates.
2061 .if ${MK_CDDL} != "no"
2062 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
2063 cddl/usr.bin/ctfmerge
2066 # If we're given an XAS, don't build binutils.
2067 .if ${XAS:M/*} == ""
2068 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
2069 _binutils= gnu/usr.bin/binutils
2071 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
2072 _elftctools= lib/libelftc \
2078 # These are not required by the build, but can be useful for developers who
2079 # cross-build on a FreeBSD 10 host:
2080 _elftctools+= usr.bin/addr2line
2082 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
2083 # If cross-building with an external binutils we still need to build strip for
2084 # the target (for at least crunchide).
2085 _elftctools= lib/libelftc \
2090 .if ${MK_CLANG_BOOTSTRAP} != "no"
2091 _clang= usr.bin/clang
2093 .if ${MK_LLD_BOOTSTRAP} != "no"
2094 _lld= usr.bin/clang/lld
2096 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no"
2097 _clang_libs= lib/clang
2099 .if ${MK_GCC_BOOTSTRAP} != "no"
2100 _gcc= gnu/usr.bin/cc
2102 .if ${MK_USB} != "no"
2103 _usb_tools= stand/usb/tools
2106 cross-tools: .MAKE .PHONY
2108 ${LOCAL_XTOOL_DIRS} \
2118 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2119 cd ${.CURDIR}/${_tool}; \
2120 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2121 ${MAKE} DIRPRFX=${_tool}/ all; \
2122 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP} install
2126 # native-xtools is the current target for qemu-user cross builds of ports
2127 # via poudriere and the imgact_binmisc kernel module.
2128 # This target merely builds a toolchan/sysroot, then builds the tools it wants
2129 # with the options it wants in a special MAKEOBJDIRPREFIX, using the toolchain
2130 # already built. It then installs the static tools to NXBDESTDIR for Poudriere
2133 NXBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/nxb/
2134 NXBOBJTOP= ${NXBOBJROOT}${NXB_TARGET}.${NXB_TARGET_ARCH}
2137 .error NXTP variable should be an absolute path
2139 NXBDESTDIR?= ${DESTDIR}${NXTP}
2141 # This is the list of tools to be built/installed as static and where
2142 # appropriate to build for the given TARGET.TARGET_ARCH.
2204 SUBDIR_DEPEND_usr.bin/clang= lib/clang
2205 .if ${MK_CLANG} != "no"
2207 NXBDIRS+= usr.bin/clang
2209 .if ${MK_GCC} != "no"
2210 NXBDIRS+= gnu/usr.bin/cc
2212 .if ${MK_BINUTILS} != "no"
2213 NXBDIRS+= gnu/usr.bin/binutils
2215 # XXX: native-xtools passes along ${NXBDIRS} in SUBDIR_OVERRIDE that needs
2216 # to be evaluated after NXBDIRS is set.
2217 .if make(install) && !empty(SUBDIR_OVERRIDE)
2218 SUBDIR= ${SUBDIR_OVERRIDE}
2222 OBJTOP=${NXBOBJTOP:Q} \
2223 OBJROOT=${NXBOBJROOT:Q} \
2229 MK_CLANG_EXTRAS=no \
2247 .if make(native-xtools*) && \
2248 (!defined(NXB_TARGET) || !defined(NXB_TARGET_ARCH))
2249 .error Missing NXB_TARGET / NXB_TARGET_ARCH
2251 # For 'toolchain' we want to produce native binaries that themselves generate
2253 NXBTMAKE= ${NXBMAKEENV} ${MAKE} ${NXBMAKEARGS:N-DNO_PIC:N-DNO_SHARED} \
2254 TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH}
2255 # For 'everything' we want to produce native binaries (hence -target to
2256 # be MACHINE) that themselves generate TARGET.TARGET_ARCH binaries.
2257 # TARGET/TARGET_ARCH are still passed along from user.
2259 # Use the toolchain we create as an external toolchain.
2260 .if ${USING_SYSTEM_COMPILER} == "yes" || ${XCC:N${CCACHE_BIN}:M/*}
2261 NXBMAKE+= XCC="${XCC}" \
2265 NXBMAKE+= XCC="${NXBOBJTOP}/tmp/usr/bin/cc" \
2266 XCXX="${NXBOBJTOP}/tmp/usr/bin/c++" \
2267 XCPP="${NXBOBJTOP}/tmp/usr/bin/cpp"
2269 NXBMAKE+= ${NXBMAKEENV} ${MAKE} -f Makefile.inc1 ${NXBMAKEARGS} \
2270 TARGET=${NXB_TARGET} TARGET_ARCH=${NXB_TARGET_ARCH} \
2271 TARGET_TRIPLE=${MACHINE_TRIPLE:Q}
2272 # NXBDIRS is improperly based on MACHINE rather than NXB_TARGET. Need to
2273 # invoke a sub-make to reevaluate MK_GCC, etc, for NXBDIRS.
2274 NXBMAKE+= SUBDIR_OVERRIDE='$${NXBDIRS:M*}'
2275 # Need to avoid the -isystem logic when using clang as an external toolchain
2276 # even if the TARGET being built for wants GCC.
2277 NXBMAKE+= WANT_COMPILER_TYPE='$${X_COMPILER_TYPE}'
2278 native-xtools: .PHONY
2279 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _cleanobj MK_GCC=yes
2280 # Build the bootstrap/host/cross tools that produce native binaries
2281 # Pass along MK_GCC=yes to ensure GCC-needed build tools are built.
2282 # We don't quite know what the NXB_TARGET wants so just build it.
2283 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} kernel-toolchain MK_GCC=yes
2284 # Populate includes/libraries sysroot that produce native binaries.
2285 # This is split out from 'toolchain' above mostly so that target LLVM
2286 # libraries have a proper LLVM_DEFAULT_TARGET_TRIPLE without
2287 # polluting the cross-compiler build. The LLVM/GCC libs are skipped
2288 # here to avoid the problem but are kept in 'toolchain' so that
2289 # needed build tools are built.
2290 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes MK_CLANG=no MK_GCC=no
2291 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries MK_CLANG=no MK_GCC=no
2292 # Clean out improper TARGET=MACHINE files
2293 ${_+_}cd ${.CURDIR}/gnu/usr.bin/cc/cc_tools; ${NXBTMAKE} cleandir
2294 .if !defined(NO_OBJWALK)
2295 ${_+_}cd ${.CURDIR}; ${NXBMAKE} _obj
2297 ${_+_}cd ${.CURDIR}; ${NXBMAKE} everything
2298 @echo ">> native-xtools done. Use 'make native-xtools-install' to install to a given DESTDIR"
2300 native-xtools-install: .PHONY
2301 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
2302 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2303 -p ${NXBDESTDIR}/usr >/dev/null
2304 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2305 -p ${NXBDESTDIR}/usr/include >/dev/null
2306 ${_+_}cd ${.CURDIR}; ${NXBMAKE} \
2307 DESTDIR=${NXBDESTDIR} \
2312 # hierarchy - ensure that all the needed directories are present
2314 hierarchy hier: .MAKE .PHONY
2315 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
2318 # libraries - build all libraries, and install them under ${DESTDIR}.
2320 # The list of libraries with dependents (${_prebuild_libs}) and their
2321 # interdependencies (__L) are built automatically by the
2322 # ${.CURDIR}/tools/make_libdeps.sh script.
2324 libraries: .MAKE .PHONY
2325 ${_+_}cd ${.CURDIR}; \
2326 ${MAKE} -f Makefile.inc1 _prereq_libs; \
2327 ${MAKE} -f Makefile.inc1 _startup_libs; \
2328 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
2329 ${MAKE} -f Makefile.inc1 _generic_libs
2332 # static libgcc.a prerequisite for shared libc
2334 _prereq_libs= lib/libcompiler_rt
2335 .if ${MK_SSP} != "no"
2336 _prereq_libs+= gnu/lib/libssp/libssp_nonshared
2339 # These dependencies are not automatically generated:
2341 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
2342 # all shared libraries for ELF.
2344 _startup_libs= gnu/lib/csu
2345 _startup_libs+= lib/csu
2346 _startup_libs+= lib/libcompiler_rt
2347 _startup_libs+= lib/libc
2348 _startup_libs+= lib/libc_nonshared
2349 .if ${MK_LIBCPLUSPLUS} != "no"
2350 _startup_libs+= lib/libcxxrt
2353 .if ${MK_LLVM_LIBUNWIND} != "no"
2354 _prereq_libs+= lib/libgcc_eh lib/libgcc_s
2355 _startup_libs+= lib/libgcc_eh lib/libgcc_s
2357 lib/libgcc_s__L: lib/libc__L
2358 lib/libgcc_s__L: lib/libc_nonshared__L
2359 .if ${MK_LIBCPLUSPLUS} != "no"
2360 lib/libcxxrt__L: lib/libgcc_s__L
2363 .else # MK_LLVM_LIBUNWIND == no
2365 _prereq_libs+= gnu/lib/libgcc
2366 _startup_libs+= gnu/lib/libgcc
2368 gnu/lib/libgcc__L: lib/libc__L
2369 gnu/lib/libgcc__L: lib/libc_nonshared__L
2370 .if ${MK_LIBCPLUSPLUS} != "no"
2371 lib/libcxxrt__L: gnu/lib/libgcc__L
2375 _prebuild_libs= ${_kerberos5_lib_libasn1} \
2376 ${_kerberos5_lib_libhdb} \
2377 ${_kerberos5_lib_libheimbase} \
2378 ${_kerberos5_lib_libheimntlm} \
2380 ${_kerberos5_lib_libheimipcc} \
2381 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
2382 ${_kerberos5_lib_libroken} \
2383 ${_kerberos5_lib_libwind} \
2384 lib/libbz2 ${_libcom_err} lib/libcrypt \
2385 lib/libelf lib/libexpat \
2388 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
2390 lib/ncurses/ncurses lib/ncurses/ncursesw \
2391 lib/libopie lib/libpam/libpam ${_lib_libthr} \
2392 ${_lib_libradius} lib/libsbuf lib/libtacplus \
2394 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
2395 ${_cddl_lib_libuutil} \
2396 ${_cddl_lib_libavl} \
2397 ${_cddl_lib_libzfs_core} \
2398 ${_cddl_lib_libctf} \
2399 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
2400 ${_secure_lib_libcrypto} ${_lib_libldns} \
2401 ${_secure_lib_libssh} ${_secure_lib_libssl}
2403 .if ${MK_GNUCXX} != "no"
2404 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
2405 gnu/lib/libstdc++__L: lib/msun__L
2406 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
2409 .if ${MK_DIALOG} != "no"
2410 _prebuild_libs+= gnu/lib/libdialog
2411 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2414 .if ${MK_LIBCPLUSPLUS} != "no"
2415 _prebuild_libs+= lib/libc++
2418 lib/libgeom__L: lib/libexpat__L
2419 lib/libkvm__L: lib/libelf__L
2421 .if ${MK_LIBTHR} != "no"
2422 _lib_libthr= lib/libthr
2425 .if ${MK_RADIUS_SUPPORT} != "no"
2426 _lib_libradius= lib/libradius
2429 .if ${MK_OFED} != "no"
2431 # The OFED libraries are built in four steps
2432 # as reflected below, due to interdependencies.
2434 # NOTE: Depending on contrib/ofed/include is only needed for
2435 # the lib32 compat build.
2438 contrib/ofed/include \
2439 contrib/ofed/usr.lib/0 \
2440 contrib/ofed/usr.lib/1 \
2441 contrib/ofed/usr.lib/2 \
2442 contrib/ofed/usr.lib/3
2444 contrib/ofed/usr.lib/0__L: contrib/ofed/include__L lib/libthr__L
2445 contrib/ofed/usr.lib/1__L: contrib/ofed/usr.lib/0__L
2446 contrib/ofed/usr.lib/2__L: contrib/ofed/usr.lib/1__L
2447 contrib/ofed/usr.lib/3__L: contrib/ofed/usr.lib/2__L
2450 .if ${MK_CASPER} != "no"
2451 _lib_casper= lib/libcasper
2454 lib/libpjdlog__L: lib/libutil__L
2455 lib/libcasper__L: lib/libnv__L
2456 lib/liblzma__L: lib/libthr__L
2458 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
2459 .if ${MK_IPFILTER} != "no"
2460 _generic_libs+= sbin/ipf/libipf
2462 .for _DIR in ${LOCAL_LIB_DIRS}
2463 .if ${_DIR} == ".WAIT" || (empty(_generic_libs:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
2464 _generic_libs+= ${_DIR}
2468 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2470 .if ${MK_CDDL} != "no"
2471 _cddl_lib_libumem= cddl/lib/libumem
2472 _cddl_lib_libnvpair= cddl/lib/libnvpair
2473 _cddl_lib_libavl= cddl/lib/libavl
2474 _cddl_lib_libuutil= cddl/lib/libuutil
2475 .if ${MK_ZFS} != "no"
2476 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2477 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2479 _cddl_lib_libctf= cddl/lib/libctf
2481 cddl/lib/libctf__L: lib/libz__L
2483 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
2484 # on select architectures though (see cddl/lib/Makefile)
2485 .if ${MACHINE_CPUARCH} != "sparc64"
2486 _prebuild_libs+= lib/libprocstat lib/libproc lib/librtld_db
2487 lib/libprocstat__L: lib/libelf__L lib/libkvm__L lib/libutil__L
2488 lib/libproc__L: lib/libprocstat__L
2489 lib/librtld_db__L: lib/libprocstat__L
2492 .if ${MK_CRYPT} != "no"
2493 .if ${MK_OPENSSL} != "no"
2494 _secure_lib_libcrypto= secure/lib/libcrypto
2495 _secure_lib_libssl= secure/lib/libssl
2496 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2497 .if ${MK_LDNS} != "no"
2498 _lib_libldns= lib/libldns
2499 lib/libldns__L: secure/lib/libcrypto__L
2501 .if ${MK_OPENSSH} != "no"
2502 _secure_lib_libssh= secure/lib/libssh
2503 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2504 .if ${MK_LDNS} != "no"
2505 secure/lib/libssh__L: lib/libldns__L
2507 .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no"
2508 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2509 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2510 lib/libmd__L kerberos5/lib/libroken__L
2514 _secure_lib= secure/lib
2517 .if ${MK_KERBEROS} != "no"
2518 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2519 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2520 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2521 kerberos5/lib/libwind__L lib/libsqlite3__L
2522 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2523 kerberos5/lib/libroken__L lib/libcom_err__L
2524 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2525 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2526 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2527 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2528 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2529 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2530 kerberos5/lib/libroken__L: lib/libcrypt__L
2531 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2532 kerberos5/lib/libheimbase__L: lib/libthr__L
2533 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2536 lib/libsqlite3__L: lib/libthr__L
2538 .if ${MK_GSSAPI} != "no"
2539 _lib_libgssapi= lib/libgssapi
2542 .if ${MK_KERBEROS} != "no"
2543 _kerberos5_lib= kerberos5/lib
2544 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2545 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2546 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2547 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2548 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2549 _kerberos5_lib_libroken= kerberos5/lib/libroken
2550 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2551 _libsqlite3= lib/libsqlite3
2552 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2553 _kerberos5_lib_libwind= kerberos5/lib/libwind
2554 _libcom_err= lib/libcom_err
2557 .if ${MK_NIS} != "no"
2558 _lib_libypclnt= lib/libypclnt
2561 .if ${MK_OPENSSL} == "no"
2562 lib/libradius__L: lib/libmd__L
2566 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2567 .if ${MK_CXX} != "no"
2568 .if ${MK_LIBCPLUSPLUS} != "no"
2569 lib/libproc__L: lib/libcxxrt__L
2570 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2571 lib/libproc__L: gnu/lib/libsupc++__L
2575 .for _lib in ${_prereq_libs}
2576 ${_lib}__PL: .PHONY .MAKE
2577 .if exists(${.CURDIR}/${_lib})
2578 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2579 cd ${.CURDIR}/${_lib}; \
2580 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
2581 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2582 DIRPRFX=${_lib}/ all; \
2583 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2584 DIRPRFX=${_lib}/ install
2588 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
2589 ${_lib}__L: .PHONY .MAKE
2590 .if exists(${.CURDIR}/${_lib})
2591 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2592 cd ${.CURDIR}/${_lib}; \
2593 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
2594 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2595 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2599 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2600 _startup_libs: ${_startup_libs:S/$/__L/}
2601 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2602 _generic_libs: ${_generic_libs:S/$/__L/}
2604 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2605 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2606 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2607 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2608 # parallel. This is safe for the world stage of buildworld though since it has
2609 # already built libraries in a proper order and installed includes into
2610 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2611 # avoid trashing a system if it crashes mid-install.
2612 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2616 .include <bsd.subdir.mk>
2618 .if make(check-old) || make(check-old-dirs) || \
2619 make(check-old-files) || make(check-old-libs) || \
2620 make(delete-old) || make(delete-old-dirs) || \
2621 make(delete-old-files) || make(delete-old-libs)
2624 # check for / delete old files section
2627 .include "ObsoleteFiles.inc"
2629 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2630 else you can not start such an application. Consult UPDATING for more \
2631 information regarding how to cope with the removal/revision bump of a \
2634 .if !defined(BATCH_DELETE_OLD_FILES)
2640 delete-old-files: .PHONY
2641 @echo ">>> Removing old files (only deletes safe to delete libs)"
2642 # Ask for every old file if the user really wants to remove it.
2643 # It's annoying, but better safe than sorry.
2644 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2645 # argument list will get too long. Using .for/.endfor make "loops" will make
2646 # the Makefile parser segfault.
2649 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2650 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2651 while read file; do \
2652 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2653 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2654 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2656 for ext in debug symbols; do \
2657 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2658 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2659 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2664 # Remove catpages without corresponding manpages.
2666 find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \
2667 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2668 while read catpage; do \
2670 if [ ! -e "$${manpage}" ]; then \
2671 rm ${RM_I} $${catpage} <&3; \
2674 @echo ">>> Old files removed"
2676 check-old-files: .PHONY
2677 @echo ">>> Checking for old files"
2679 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2680 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2681 while read file; do \
2682 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2683 echo "${DESTDIR}/$${file}"; \
2685 for ext in debug symbols; do \
2686 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2687 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2691 # Check for catpages without corresponding manpages.
2692 @find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \
2693 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2694 while read catpage; do \
2696 if [ ! -e "$${manpage}" ]; then \
2701 delete-old-libs: .PHONY
2702 @echo ">>> Removing old libraries"
2703 @echo "${OLD_LIBS_MESSAGE}" | fmt
2706 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2707 -V OLD_LIBS | xargs -n1 | \
2708 while read file; do \
2709 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2710 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2711 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2713 for ext in debug symbols; do \
2714 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2715 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2716 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2721 @echo ">>> Old libraries removed"
2723 check-old-libs: .PHONY
2724 @echo ">>> Checking for old libraries"
2726 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2727 -V OLD_LIBS | xargs -n1 | \
2728 while read file; do \
2729 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2730 echo "${DESTDIR}/$${file}"; \
2732 for ext in debug symbols; do \
2733 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2734 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2739 delete-old-dirs: .PHONY
2740 @echo ">>> Removing old directories"
2742 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2743 -V OLD_DIRS | xargs -n1 | sort -r | \
2744 while read dir; do \
2745 if [ -d "${DESTDIR}/$${dir}" ]; then \
2746 rmdir -v "${DESTDIR}/$${dir}" || true; \
2747 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2748 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2750 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2751 rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \
2752 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2753 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2756 @echo ">>> Old directories removed"
2758 check-old-dirs: .PHONY
2759 @echo ">>> Checking for old directories"
2761 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2762 -V OLD_DIRS | xargs -n1 | \
2763 while read dir; do \
2764 if [ -d "${DESTDIR}/$${dir}" ]; then \
2765 echo "${DESTDIR}/$${dir}"; \
2766 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2767 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2769 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2770 echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \
2771 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2772 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2776 delete-old: delete-old-files delete-old-dirs .PHONY
2777 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2779 check-old: check-old-files check-old-libs check-old-dirs .PHONY
2780 @echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
2781 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2786 # showconfig - show build configuration.
2789 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes; \
2790 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes) 2>&1 | grep ^MK_ | sort -u
2792 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2793 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2795 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2796 .if exists(${KERNCONFDIR}/${KERNCONF})
2797 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2798 '${KERNCONFDIR}/${KERNCONF}' ; echo
2804 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2805 DTBOUTPUTPATH= ${.CURDIR}
2809 # Build 'standalone' Device Tree Blob
2812 @PATH=${TMPPATH} MACHINE=${TARGET} \
2813 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2814 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2819 # In the following, the first 'rm' in a series will usually remove all
2820 # files and directories. If it does not, then there are probably some
2821 # files with file flags set, so this unsets them and tries the 'rm' a
2822 # second time. There are situations where this target will be cleaning
2823 # some directories via more than one method, but that duplication is
2824 # needed to correctly handle all the possible situations. Removing all
2825 # files without file flags set in the first 'rm' instance saves time,
2826 # because 'chflags' will need to operate on fewer files afterwards.
2828 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2829 # created by bsd.obj.mk, except that we don't want to .include that file
2830 # in this makefile. We don't do a cleandir walk if MK_AUTO_OBJ is yes
2831 # since it is not possible for files to land in the wrong place.
2833 .if make(cleanworld)
2834 BW_CANONICALOBJDIR:=${OBJTOP}/
2835 .elif make(cleanuniverse)
2836 BW_CANONICALOBJDIR:=${OBJROOT}
2837 .if ${MK_UNIFIED_OBJDIR} == "no"
2838 .error ${.TARGETS} only supported with WITH_UNIFIED_OBJDIR enabled.
2841 cleanworld cleanuniverse: .PHONY
2842 .if !empty(BW_CANONICALOBJDIR) && exists(${BW_CANONICALOBJDIR}) && \
2843 ${.CURDIR:tA} != ${BW_CANONICALOBJDIR:tA}
2844 -rm -rf ${BW_CANONICALOBJDIR}*
2845 -chflags -R 0 ${BW_CANONICALOBJDIR}
2846 rm -rf ${BW_CANONICALOBJDIR}*
2848 .if make(cleanworld) && ${MK_AUTO_OBJ} == "no" && \
2849 (empty(BW_CANONICALOBJDIR) || ${.CURDIR:tA} == ${BW_CANONICALOBJDIR:tA})
2850 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2851 # To be safe in this case, fall back to a 'make cleandir'
2852 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2856 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2857 XDEV_CPUTYPE?=${CPUTYPE}
2859 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2862 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2863 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2864 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2865 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2866 CPUTYPE=${XDEV_CPUTYPE}
2868 XDDIR=${TARGET_ARCH}-freebsd
2871 .error XDTP variable should be an absolute path
2874 CDBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/xdev/
2875 CDBOBJTOP= ${CDBOBJROOT}${XDDIR}
2877 INSTALL="sh ${.CURDIR}/tools/install.sh"
2879 TOOLS_PREFIX=${XDTP}
2881 OBJTOP=${CDBOBJTOP:Q} \
2882 OBJROOT=${CDBOBJROOT:Q}
2883 CD2MAKEARGS= ${CDMAKEARGS}
2885 .if ${WANT_COMPILER_TYPE} == gcc || \
2886 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
2887 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
2888 # won't set header path and -L is used to ensure the base library path
2889 # is added before the port PREFIX library path.
2890 CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib
2891 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
2892 # combined with --sysroot.
2893 CD2CFLAGS+= -B${XDDESTDIR}/usr/lib
2894 # Force using libc++ for external GCC.
2895 .if defined(X_COMPILER_TYPE) && \
2896 ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
2897 CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \
2901 CD2CFLAGS+= --sysroot=${XDDESTDIR}/
2902 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \
2903 CPP="${CPP} ${CD2CFLAGS}" \
2904 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2906 CDTMP= ${OBJTOP}/${XDDIR}/tmp
2907 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${CDMAKEARGS} ${NOFUN}
2908 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} \
2909 ${MAKE} ${CD2MAKEARGS} ${NOFUN}
2910 .if ${MK_META_MODE} != "no"
2911 # Don't rebuild build-tools targets during normal build.
2912 CD2MAKE+= BUILD_TOOLS_META=.NOMETA
2914 XDDESTDIR=${DESTDIR}${XDTP}
2916 .ORDER: xdev-build xdev-install xdev-links
2917 xdev: xdev-build xdev-install .PHONY
2919 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2920 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
2922 _xb-worldtmp: .PHONY
2923 mkdir -p ${CDTMP}/usr
2924 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2925 -p ${CDTMP}/usr >/dev/null
2927 _xb-bootstrap-tools: .PHONY
2932 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2933 cd ${.CURDIR}/${_tool}; \
2934 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
2935 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2936 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2939 _xb-build-tools: .PHONY
2940 ${_+_}@cd ${.CURDIR}; \
2941 ${CDBENV} ${MAKE} ${CDMAKEARGS} -f Makefile.inc1 ${NOFUN} build-tools
2952 _xb-cross-tools: .PHONY
2953 .for _tool in ${XDEVDIRS}
2954 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2955 cd ${.CURDIR}/${_tool}; \
2956 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
2957 ${CDMAKE} DIRPRFX=${_tool}/ all
2961 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2962 mkdir -p ${XDDESTDIR}
2963 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2964 -p ${XDDESTDIR} >/dev/null
2965 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2966 -p ${XDDESTDIR}/usr >/dev/null
2967 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2968 -p ${XDDESTDIR}/usr/include >/dev/null
2969 .if defined(LIBCOMPAT)
2970 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2971 -p ${XDDESTDIR}/usr >/dev/null
2973 .if ${MK_TESTS} != "no"
2974 mkdir -p ${XDDESTDIR}${TESTSBASE}
2975 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2976 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2979 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2980 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
2982 _xi-cross-tools: .PHONY
2983 @echo "_xi-cross-tools"
2984 .for _tool in ${XDEVDIRS}
2985 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2986 cd ${.CURDIR}/${_tool}; \
2987 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2990 _xi-includes: .PHONY
2991 .if !defined(NO_OBJWALK)
2992 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 _obj \
2993 DESTDIR=${XDDESTDIR}
2995 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2996 DESTDIR=${XDDESTDIR}
2998 _xi-libraries: .PHONY
2999 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
3000 DESTDIR=${XDDESTDIR}
3003 ${_+_}cd ${XDDESTDIR}/usr/bin; \
3004 mkdir -p ../../../../usr/bin; \
3006 ln -sf ../../${XDTP}/usr/bin/$$i \
3007 ../../../../usr/bin/${XDDIR}-$$i; \
3008 ln -sf ../../${XDTP}/usr/bin/$$i \
3009 ../../../../usr/bin/${XDDIR}${_REVISION}-$$i; \