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."
53 .if make(showconfig) || make(test-system-*)
58 LOCALBASE?= /usr/local
60 .include "share/mk/src.tools.mk"
62 # Cross toolchain changes must be in effect before bsd.compiler.mk
63 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
64 .if defined(CROSS_TOOLCHAIN)
65 .if exists(${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk)
66 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
67 .elif exists(/usr/share/toolchains/${CROSS_TOOLCHAIN}.mk)
68 .include "/usr/share/toolchains/${CROSS_TOOLCHAIN}.mk"
69 .elif exists(${CROSS_TOOLCHAIN})
70 .include "${CROSS_TOOLCHAIN}"
72 .error CROSS_TOOLCHAIN ${CROSS_TOOLCHAIN} not found
74 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
76 .if defined(CROSS_TOOLCHAIN_PREFIX)
77 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
80 XCOMPILERS= CC CXX CPP
81 .for COMPILER in ${XCOMPILERS}
82 .if defined(CROSS_COMPILER_PREFIX)
83 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
85 X${COMPILER}?= ${${COMPILER}}
88 # If a full path to an external cross compiler is given, don't build
90 .if ${XCC:N${CCACHE_BIN}:M/*}
91 MK_CLANG_BOOTSTRAP= no
94 # Pull in compiler metadata from buildworld/toolchain if possible to avoid
95 # running CC from bsd.compiler.mk.
96 .if make(installworld) || make(install) || make(distributeworld) || \
98 .-include "${OBJTOP}/toolchain-metadata.mk"
99 .if !defined(_LOADED_TOOLCHAIN_METADATA)
100 .error A build is required first. You may have the wrong MAKEOBJDIRPREFIX set.
104 # Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early. Pull it from the
105 # tree to be friendlier to foreign OS builds. It's safe to do so unconditionally
106 # here since we will always have the right make, unlike in src/Makefile
107 # Don't include bsd.linker.mk yet until XBINUTILS is handled (after src.opts.mk)
108 _NO_INCLUDE_LINKERMK= t
109 # We also want the X_COMPILER* variables if we are using an external toolchain.
110 _WANT_TOOLCHAIN_CROSS_VARS= t
111 .include "share/mk/bsd.compiler.mk"
112 .undef _NO_INCLUDE_LINKERMK
113 .undef _WANT_TOOLCHAIN_CROSS_VARS
114 # src.opts.mk depends on COMPILER_FEATURES
115 .include "share/mk/src.opts.mk"
117 .if ${TARGET} == ${MACHINE}
118 TARGET_CPUTYPE?=${CPUTYPE}
122 .if !empty(TARGET_CPUTYPE)
123 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
125 _TARGET_CPUTYPE=dummy
127 .if ${TARGET} == "arm"
128 .if ${TARGET_ARCH:Marmv[67]*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
129 TARGET_ABI= gnueabihf
134 MACHINE_ABI?= unknown
135 MACHINE_TRIPLE?=${MACHINE_ARCH:S/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${MACHINE_ABI}-freebsd13.0
137 TARGET_TRIPLE?= ${TARGET_ARCH:S/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${TARGET_ABI}-freebsd13.0
138 KNOWN_ARCHES?= aarch64/arm64 \
159 .if ${TARGET} == ${TARGET_ARCH}
162 _t= ${TARGET_ARCH}/${TARGET}
165 .if empty(KNOWN_ARCHES:M${_t})
166 .error Unknown target ${TARGET_ARCH}:${TARGET}.
170 # If all targets are disabled for system llvm then don't expect it to work
172 .if !defined(TOOLS_PREFIX) && ${MK_LLVM_TARGET_ALL} == "no" && \
173 ${MACHINE} != ${TARGET} && ${MACHINE_ARCH} != ${TARGET_ARCH} && \
175 MK_SYSTEM_COMPILER= no
179 # Handle external binutils.
180 .if defined(CROSS_TOOLCHAIN_PREFIX)
181 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
183 XBINUTILS= AS AR LD NM OBJCOPY RANLIB SIZE STRINGS
184 .for BINUTIL in ${XBINUTILS}
185 .if defined(CROSS_BINUTILS_PREFIX) && \
186 exists(${CROSS_BINUTILS_PREFIX}/${${BINUTIL}})
187 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX:C,/*$,,}/${${BINUTIL}}
189 X${BINUTIL}?= ${${BINUTIL}}
193 # If a full path to an external linker is given, don't build lld.
198 # We also want the X_LINKER* variables if we are using an external toolchain.
199 _WANT_TOOLCHAIN_CROSS_VARS= t
200 .include "share/mk/bsd.linker.mk"
201 .undef _WANT_TOOLCHAIN_CROSS_VARS
203 # Begin WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD
205 # WITH_SYSTEM_COMPILER - Pull in needed values and make a decision.
207 # Check if there is a local compiler that can satisfy as an external compiler.
208 # Which compiler is expected to be used?
209 .if ${MK_CLANG_BOOTSTRAP} == "yes"
210 WANT_COMPILER_TYPE= clang
215 .if !defined(WANT_COMPILER_FREEBSD_VERSION) && !make(showconfig) && \
216 !make(test-system-linker)
217 .if ${WANT_COMPILER_TYPE} == "clang"
218 WANT_COMPILER_FREEBSD_VERSION_FILE= lib/clang/freebsd_cc_version.h
219 WANT_COMPILER_FREEBSD_VERSION!= \
220 awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
221 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
222 WANT_COMPILER_VERSION_FILE= lib/clang/include/clang/Basic/Version.inc
223 WANT_COMPILER_VERSION!= \
224 awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
225 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
227 .export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION
228 .endif # !defined(WANT_COMPILER_FREEBSD_VERSION)
230 # It needs to be the same revision as we would build for the bootstrap.
231 # If the expected vs CC is different then we can't skip.
232 # GCC cannot be used for cross-arch yet. For clang we pass -target later if
233 # TARGET_ARCH!=MACHINE_ARCH.
234 .if ${MK_SYSTEM_COMPILER} == "yes" && \
235 defined(WANT_COMPILER_FREEBSD_VERSION) && \
236 ${MK_CLANG_BOOTSTRAP} == "yes" && \
238 ${X_COMPILER_TYPE} == ${WANT_COMPILER_TYPE} && \
239 (${X_COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \
240 ${X_COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \
241 ${X_COMPILER_FREEBSD_VERSION} == ${WANT_COMPILER_FREEBSD_VERSION}
242 # Everything matches, disable the bootstrap compiler.
243 MK_CLANG_BOOTSTRAP= no
244 USING_SYSTEM_COMPILER= yes
245 .endif # ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE}
247 # WITH_SYSTEM_LD - Pull in needed values and make a decision.
249 # Check if there is a local linker that can satisfy as an external linker.
250 # Which linker is expected to be used?
251 .if ${MK_LLD_BOOTSTRAP} == "yes"
252 WANT_LINKER_TYPE= lld
253 .elif ${MK_BINUTILS_BOOTSTRAP} == "yes"
254 # Note that there's no support for bfd in WITH_SYSTEM_LINKER.
255 WANT_LINKER_TYPE= bfd
260 .if !defined(WANT_LINKER_FREEBSD_VERSION) && !make(showconfig) && \
261 !make(test-system-compiler)
262 .if ${WANT_LINKER_TYPE} == "lld"
263 WANT_LINKER_FREEBSD_VERSION_FILE= lib/clang/include/VCSVersion.inc
264 _WANT_LINKER_FREEBSD_VERSION!= \
265 awk '$$2 == "LLD_REVISION" {gsub(/"/, "", $$3); print $$3}' \
266 ${SRCDIR}/${WANT_LINKER_FREEBSD_VERSION_FILE} || echo unknown
267 WANT_LINKER_FREEBSD_VERSION=${_WANT_LINKER_FREEBSD_VERSION:C/.*-(.*)/\1/}
268 WANT_LINKER_VERSION_FILE= lib/clang/include/lld/Common/Version.inc
269 WANT_LINKER_VERSION!= \
270 awk '$$2 == "LLD_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
271 ${SRCDIR}/${WANT_LINKER_VERSION_FILE} || echo unknown
273 WANT_LINKER_FREEBSD_VERSION_FILE=
274 WANT_LINKER_FREEBSD_VERSION=
276 .export WANT_LINKER_FREEBSD_VERSION WANT_LINKER_VERSION
277 .endif # !defined(WANT_LINKER_FREEBSD_VERSION)
279 .if ${MK_SYSTEM_LINKER} == "yes" && \
280 defined(WANT_LINKER_FREEBSD_VERSION) && \
281 (${MK_LLD_BOOTSTRAP} == "yes") && \
283 ${X_LINKER_TYPE} == ${WANT_LINKER_TYPE} && \
284 ${X_LINKER_VERSION} == ${WANT_LINKER_VERSION} && \
285 ${X_LINKER_FREEBSD_VERSION} == ${WANT_LINKER_FREEBSD_VERSION}
286 # Everything matches, disable the bootstrap linker.
288 USING_SYSTEM_LINKER= yes
289 .endif # ${WANT_LINKER_TYPE} == ${LINKER_TYPE}
291 # WITH_SYSTEM_COMPILER / WITH_SYSTEM_LINKER - Handle defaults and debug.
292 USING_SYSTEM_COMPILER?= no
293 USING_SYSTEM_LINKER?= no
295 TEST_SYSTEM_COMPILER_VARS= \
296 USING_SYSTEM_COMPILER MK_SYSTEM_COMPILER \
297 MK_CROSS_COMPILER MK_CLANG_BOOTSTRAP \
298 WANT_COMPILER_TYPE WANT_COMPILER_VERSION WANT_COMPILER_VERSION_FILE \
299 WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \
300 CC COMPILER_TYPE COMPILER_FEATURES COMPILER_VERSION \
301 COMPILER_FREEBSD_VERSION \
302 XCC X_COMPILER_TYPE X_COMPILER_FEATURES X_COMPILER_VERSION \
303 X_COMPILER_FREEBSD_VERSION
304 TEST_SYSTEM_LINKER_VARS= \
305 USING_SYSTEM_LINKER MK_SYSTEM_LINKER \
306 MK_LLD_BOOTSTRAP MK_BINUTILS_BOOTSTRAP \
307 WANT_LINKER_TYPE WANT_LINKER_VERSION WANT_LINKER_VERSION_FILE \
308 WANT_LINKER_FREEBSD_VERSION WANT_LINKER_FREEBSD_VERSION_FILE \
309 LD LINKER_TYPE LINKER_FEATURES LINKER_VERSION \
310 LINKER_FREEBSD_VERSION \
311 XLD X_LINKER_TYPE X_LINKER_FEATURES X_LINKER_VERSION \
312 X_LINKER_FREEBSD_VERSION
314 .for _t in compiler linker
315 test-system-${_t}: .PHONY
316 .for v in ${TEST_SYSTEM_${_t:tu}_VARS}
317 ${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}"
320 .if (make(buildworld) || make(buildkernel) || make(kernel-toolchain) || \
321 make(toolchain) || make(_cross-tools))
322 .if ${USING_SYSTEM_COMPILER} == "yes"
323 .info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler.
324 .elif ${MK_CLANG_BOOTSTRAP} == "yes"
325 .info SYSTEM_COMPILER: libclang will be built for bootstrapping a cross-compiler.
327 .if ${USING_SYSTEM_LINKER} == "yes"
328 .info SYSTEM_LINKER: Determined that LD=${LD} matches the source tree. Not bootstrapping a cross-linker.
329 .elif ${MK_LLD_BOOTSTRAP} == "yes"
330 .info SYSTEM_LINKER: libclang will be built for bootstrapping a cross-linker.
334 # End WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD
336 # Store some compiler metadata for use in installworld where we don't
337 # want to invoke CC at all.
338 _TOOLCHAIN_METADATA_VARS= COMPILER_VERSION \
341 COMPILER_FREEBSD_VERSION \
342 COMPILER_RESOURCE_DIR \
346 LINKER_FREEBSD_VERSION
347 toolchain-metadata.mk: .PHONY .META
349 @echo ".info Using cached toolchain metadata from build at $$(hostname) on $$(date)" \
351 @echo "_LOADED_TOOLCHAIN_METADATA=t" >> ${.TARGET}
352 .for v in ${_TOOLCHAIN_METADATA_VARS}
353 @echo "${v}=${${v}}" >> ${.TARGET}
354 @echo "X_${v}=${X_${v}}" >> ${.TARGET}
356 @echo ".export ${_TOOLCHAIN_METADATA_VARS}" >> ${.TARGET}
357 @echo ".export ${_TOOLCHAIN_METADATA_VARS:C,^,X_,}" >> ${.TARGET}
360 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
361 # keep the users system reasonably usable. For static->dynamic root upgrades,
362 # we don't want to install a dynamic binary without rtld and the needed
363 # libraries. More commonly, for dynamic root, we don't want to install a
364 # binary that requires a newer library version that hasn't been installed yet.
365 # This ordering is not a guarantee though. The only guarantee of a working
366 # system here would require fine-grained ordering of all components based
367 # on their dependencies.
368 .if !empty(SUBDIR_OVERRIDE)
369 SUBDIR= ${SUBDIR_OVERRIDE}
372 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
373 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
374 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
375 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
376 _REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
378 .for _DIR in ${LOCAL_LIB_DIRS}
379 .if ${_DIR} == ".WAIT" || (empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
383 .if !defined(NO_ROOT) && (make(installworld) || make(install))
384 # Ensure libraries are installed before progressing.
388 .if ${MK_CDDL} != "no"
392 .if ${MK_KERBEROS} != "no"
395 .if ${MK_RESCUE} != "no"
399 .if ${MK_CRYPT} != "no"
402 .if !defined(NO_SHARE)
405 .if ${MK_BOOT} != "no"
408 SUBDIR+=sys usr.bin usr.sbin
409 .if ${MK_TESTS} != "no"
413 # Local directories are built in parallel with the base system directories.
414 # Users may insert a .WAIT directive at the beginning or elsewhere within
415 # the LOCAL_DIRS and LOCAL_LIB_DIRS lists as needed.
416 .for _DIR in ${LOCAL_DIRS}
417 .if ${_DIR} == ".WAIT" || exists(${.CURDIR}/${_DIR}/Makefile)
422 # We must do etc/ last as it hooks into building the man whatis file
423 # by calling 'makedb' in share/man. This is only relevant for
424 # install/distribute so they build the whatis file after every manpage is
426 .if make(installworld) || make(install)
431 .endif # !empty(SUBDIR_OVERRIDE)
434 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
437 .if defined(NO_CLEANDIR)
438 CLEANDIR= clean cleandepend
443 .if defined(WORLDFAST)
448 .if ${MK_META_MODE} == "yes"
449 # If filemon is used then we can rely on the build being incremental-safe.
450 # The .meta files will also track the build command and rebuild should
452 .if empty(.MAKE.MODE:Mnofilemon)
456 .if defined(NO_OBJWALK) || ${MK_AUTO_OBJ} == "yes"
460 .if !defined(NO_OBJWALK)
465 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
467 .if empty(SHELL:M*csh*)
468 BUILDENV_SHELL?=${SHELL}
470 BUILDENV_SHELL?=/bin/sh
473 .if !defined(_MKSHOWCONFIG)
474 .if !defined(SVN_CMD) || empty(SVN_CMD)
475 . for _P in /usr/bin /usr/local/bin
476 . for _S in svn svnlite
477 . if exists(${_P}/${_S})
485 .if !defined(VCS_REVISION) || empty(VCS_REVISION)
486 .if !defined(SVNVERSION_CMD) || empty(SVNVERSION_CMD)
487 . for _D in ${PATH:S,:, ,g}
488 . if exists(${_D}/svnversion)
489 SVNVERSION_CMD?=${_D}/svnversion
491 . if exists(${_D}/svnliteversion)
492 SVNVERSION_CMD?=${_D}/svnliteversion
496 _VCS_REVISION?= $$(eval ${SVNVERSION_CMD} ${SRCDIR})
497 . if !empty(_VCS_REVISION)
498 VCS_REVISION= $$(echo r${_VCS_REVISION})
503 .if !defined(OSRELDATE)
504 .if exists(/usr/include/osreldate.h)
505 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
506 /usr/include/osreldate.h
513 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
514 .if !defined(_REVISION)
515 _REVISION!= ${MAKE} -C ${SRCDIR}/release MK_AUTO_OBJ=no -V REVISION
518 .if !defined(_BRANCH)
519 _BRANCH!= ${MAKE} -C ${SRCDIR}/release MK_AUTO_OBJ=no -V BRANCH
522 .if !defined(SRCRELDATE)
523 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
524 ${SRCDIR}/sys/sys/param.h
527 .if !defined(VERSION)
528 VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
532 .if !defined(PKG_VERSION)
533 .if ${_BRANCH:MSTABLE*} || ${_BRANCH:MCURRENT*}
534 TIMENOW= %Y%m%d%H%M%S
535 EXTRA_REVISION= .s${TIMENOW:gmtime}
536 .elif ${_BRANCH:MALPHA*}
537 EXTRA_REVISION= _${_BRANCH:C/-ALPHA/.a/}
538 .elif ${_BRANCH:MBETA*}
539 EXTRA_REVISION= _${_BRANCH:C/-BETA/.b/}
540 .elif ${_BRANCH:MRC*}
541 EXTRA_REVISION= _${_BRANCH:C/-RC/.r/}
542 .elif ${_BRANCH:MPRERELEASE*}
543 EXTRA_REVISION= _${_BRANCH:C/-PRERELEASE/.p/}
544 .elif ${_BRANCH:M*-p*}
545 EXTRA_REVISION= _${_BRANCH:C/.*-p([0-9]+$)/\1/}
547 PKG_VERSION= ${_REVISION}${EXTRA_REVISION}
549 .endif # !defined(PKG_VERSION)
551 .if !defined(_MKSHOWCONFIG)
552 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} -f /dev/null \
553 -m ${.CURDIR}/share/mk MK_AUTO_OBJ=no -V CPUTYPE
554 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
555 .error CPUTYPE global should be set with ?=.
559 BUILD_ARCH!= uname -p
560 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
561 .error To cross-build, set TARGET_ARCH.
564 WORLDTMP?= ${OBJTOP}/tmp
565 BPATH= ${CCACHE_WRAPPER_PATH_PFX}${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin:${WORLDTMP}/legacy/usr/libexec
566 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
568 # When building we want to find the cross tools before the host tools in ${BPATH}.
569 # We also need to add UNIVERSE_TOOLCHAIN_PATH so that we can find the shared
570 # toolchain files (clang, lld, etc.) during make universe/tinderbox
571 STRICTTMPPATH= ${XPATH}:${BPATH}:${UNIVERSE_TOOLCHAIN_PATH}
572 # We should not be using tools from /usr/bin accidentally since this could cause
573 # the build to break on other systems that don't have that tool. For now we
574 # still allow using the old behaviour (inheriting $PATH) if
575 # BUILD_WITH_STRICT_TMPPATH is set to 0 but this will eventually be removed.
577 # Currently strict $PATH can cause build failures and does not work yet with
578 # USING_SYSTEM_LINKER/USING_SYSTEM_COMPILER. Once these issues have been
579 # resolved it will be turned on by default.
580 BUILD_WITH_STRICT_TMPPATH?=0
581 .if ${BUILD_WITH_STRICT_TMPPATH} != 0
582 TMPPATH= ${STRICTTMPPATH}
584 TMPPATH= ${STRICTTMPPATH}:${PATH}
588 # Avoid running mktemp(1) unless actually needed.
589 # It may not be functional, e.g., due to new ABI
590 # when in the middle of installing over this system.
592 .if make(distributeworld) || make(installworld) || make(stageworld)
593 .if ${BUILD_WITH_STRICT_TMPPATH} != 0
594 MKTEMP=${WORLDTMP}/legacy/usr/bin/mktemp
595 .if !exists(${MKTEMP})
596 .error "mktemp binary doesn't exist in expected location: ${MKTEMP}"
601 INSTALLTMP!= ${MKTEMP} -d -u -t install
604 .if make(stagekernel) || make(distributekernel)
610 # Building a world goes through the following stages
612 # 1. legacy stage [BMAKE]
613 # This stage is responsible for creating compatibility
614 # shims that are needed by the bootstrap-tools,
615 # build-tools and cross-tools stages. These are generally
616 # APIs that tools from one of those three stages need to
617 # build that aren't present on the host.
618 # 1. bootstrap-tools stage [BMAKE]
619 # This stage is responsible for creating programs that
620 # are needed for backward compatibility reasons. They
621 # are not built as cross-tools.
622 # 2. build-tools stage [TMAKE]
623 # This stage is responsible for creating the object
624 # tree and building any tools that are needed during
625 # the build process. Some programs are listed during
626 # this phase because they build binaries to generate
627 # files needed to build these programs. This stage also
628 # builds the 'build-tools' target rather than 'all'.
629 # 3. cross-tools stage [XMAKE]
630 # This stage is responsible for creating any tools that
631 # are needed for building the system. A cross-compiler is one
632 # of them. This differs from build tools in two ways:
633 # 1. the 'all' target is built rather than 'build-tools'
634 # 2. these tools are installed into TMPPATH for stage 4.
635 # 4. world stage [WMAKE]
636 # This stage actually builds the world.
637 # 5. install stage (optional) [IMAKE]
638 # This stage installs a previously built world.
643 MINIMUM_SUPPORTED_OSREL?= 1002501
644 MINIMUM_SUPPORTED_REL?= 10.3
646 # Common environment for world related stages
648 MACHINE_ARCH=${TARGET_ARCH} \
650 CPUTYPE=${TARGET_CPUTYPE}
651 .if ${MK_META_MODE} != "no"
652 # Don't rebuild build-tools targets during normal build.
653 CROSSENV+= BUILD_TOOLS_META=.NOMETA
655 .if defined(TARGET_CFLAGS)
656 CROSSENV+= ${TARGET_CFLAGS}
658 .if (${TARGET} != ${MACHINE} && !defined(WITH_LOCAL_MODULES)) || \
659 defined(WITHOUT_LOCAL_MODULES)
660 CROSSENV+= LOCAL_MODULES=
663 BOOTSTRAPPING_OSRELDATE?=${OSRELDATE}
665 # bootstrap-tools stage
666 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
667 TOOLS_PREFIX=${TOOLS_PREFIX_UNDEF:U${WORLDTMP}} \
668 PATH=${BPATH}:${PATH} \
669 WORLDTMP=${WORLDTMP} \
670 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
671 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
673 OBJTOP='${WORLDTMP}/obj-tools' \
674 OBJROOT='$${OBJTOP}/' \
676 BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
677 BWPHASE=${.TARGET:C,^_,,} \
679 MK_HTML=no NO_LINT=yes MK_MAN=no \
680 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
681 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
682 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
683 MK_LLDB=no MK_RETPOLINE=no MK_TESTS=no \
687 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
689 .if empty(.MAKEOVERRIDES:MMK_LLVM_TARGET_ALL)
690 BMAKE+= MK_LLVM_TARGET_ALL=no
695 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
696 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
698 BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
699 BWPHASE=${.TARGET:C,^_,,} \
702 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
703 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
704 MK_LLDB=no MK_RETPOLINE=no MK_TESTS=no
707 # TOOLS_PREFIX set in BMAKE
709 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
710 MK_CLANG_IS_CC=${MK_CLANG_BOOTSTRAP} \
711 MK_GDB=no MK_TESTS=no
714 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
715 PATH=${BPATH}:${PATH} \
718 TOOLS_PREFIX=${TOOLS_PREFIX_UNDEF:U${WORLDTMP}} \
719 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
721 OBJTOP='${WORLDTMP}/obj-kernel-tools' \
722 OBJROOT='$${OBJTOP}/' \
724 BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
726 MK_HTML=no -DNO_LINT MK_MAN=no \
727 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
728 -DNO_CPU_CFLAGS MK_RETPOLINE=no MK_WARNS=no MK_CTF=no
731 WMAKEENV= ${CROSSENV} \
732 INSTALL="sh ${.CURDIR}/tools/install.sh" \
737 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
739 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
742 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
743 CPP="${XCPP} ${XCFLAGS}" \
744 AS="${XAS}" AR="${XAR}" LD="${XLD}" LLVM_LINK="${XLLVM_LINK}" \
745 NM=${XNM} OBJCOPY="${XOBJCOPY}" \
746 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
749 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
750 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
751 # directory, but the compiler will look in the right place for its
752 # tools so we don't need to tell it where to look.
753 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
757 # The internal bootstrap compiler has a default sysroot set by TOOLS_PREFIX
758 # and target set by TARGET/TARGET_ARCH. However, there are several needs to
759 # always pass an explicit --sysroot and -target.
760 # - External compiler needs sysroot and target flags.
761 # - External ld needs sysroot.
762 # - To be clear about the use of a sysroot when using the internal compiler.
763 # - Easier debugging.
764 # - Allowing WITH_SYSTEM_COMPILER+WITH_META_MODE to work together due to
765 # the flip-flopping build command when sometimes using external and
766 # sometimes using internal.
767 # - Allow using lld which has no support for default paths.
768 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
769 BFLAGS+= -B${WORLDTMP}/usr/bin
771 .if ${WANT_COMPILER_TYPE} == gcc || \
772 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
773 .elif ${WANT_COMPILER_TYPE} == clang || \
774 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang)
775 XCFLAGS+= -target ${TARGET_TRIPLE}
777 XCFLAGS+= --sysroot=${WORLDTMP}
783 .if ${MK_LIB32} == "yes"
785 .include "Makefile.libcompat"
786 .elif ${MK_LIBSOFT} == "yes"
788 .include "Makefile.libcompat"
791 # META_MODE normally ignores host file changes since every build updates
792 # timestamps (see NO_META_IGNORE_HOST in sys.mk). There are known times
793 # when the ABI breaks though that we want to force rebuilding WORLDTMP
794 # to get updated host tools.
795 .if ${MK_META_MODE} == "yes" && defined(NO_CLEAN) && \
796 !defined(NO_META_IGNORE_HOST) && !defined(NO_META_IGNORE_HOST_HEADERS) && \
797 !defined(_MKSHOWCONFIG)
798 # r318736 - ino64 major ABI breakage
799 META_MODE_BAD_ABI_VERS+= 1200031
801 .if !defined(OBJDIR_HOST_OSRELDATE)
802 .if exists(${OBJTOP}/host-osreldate.h)
803 OBJDIR_HOST_OSRELDATE!= \
804 awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
805 ${OBJTOP}/host-osreldate.h
806 .elif exists(${WORLDTMP}/usr/include/osreldate.h)
807 OBJDIR_HOST_OSRELDATE= 0
809 .export OBJDIR_HOST_OSRELDATE
812 # Note that this logic is the opposite of normal BOOTSTRAP handling. We want
813 # to compare the WORLDTMP's OSRELDATE to the host's OSRELDATE. If the WORLDTMP
814 # is older than the ABI-breakage OSRELDATE of the HOST then we rebuild.
815 .if defined(OBJDIR_HOST_OSRELDATE)
816 .for _ver in ${META_MODE_BAD_ABI_VERS}
817 .if ${OSRELDATE} >= ${_ver} && ${OBJDIR_HOST_OSRELDATE} < ${_ver}
818 _meta_mode_need_rebuild= ${_ver}
821 .if defined(_meta_mode_need_rebuild)
822 .info META_MODE: Rebuilding host tools due to ABI breakage in __FreeBSD_version ${_meta_mode_need_rebuild}.
823 NO_META_IGNORE_HOST_HEADERS= 1
824 .export NO_META_IGNORE_HOST_HEADERS
825 .endif # defined(_meta_mode_need_rebuild)
826 .endif # defined(OBJDIR_HOST_OSRELDATE)
827 .endif # ${MK_META_MODE} == "yes" && defined(NO_CLEAN) ...
828 # This is only used for META_MODE+filemon to track what the oldest
829 # __FreeBSD_version is in WORLDTMP. This purposely does NOT have
830 # a make dependency on /usr/include/osreldate.h as the file should
831 # only be copied when it is missing or meta mode determines it has changed.
832 # Since host files are normally ignored without NO_META_IGNORE_HOST
833 # the file will never be updated unless that flag is specified. This
834 # allows tracking the oldest osreldate to force rebuilds via
835 # META_MODE_BADABI_REVS above.
836 host-osreldate.h: # DO NOT ADD /usr/include/osreldate.h here
837 @cp -f /usr/include/osreldate.h ${.TARGET}
839 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
840 BWPHASE=${.TARGET:C,^_,,} \
843 IMAKEENV= ${CROSSENV}
844 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
845 ${IMAKE_INSTALL} ${IMAKE_MTREE}
846 .if empty(.MAKEFLAGS:M-n)
847 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
848 LD_LIBRARY_PATH=${INSTALLTMP} \
849 PATH_LOCALE=${INSTALLTMP}/locale
850 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
852 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
855 # When generating install media, do not allow user and group information from
856 # the build host to affect the contents of the distribution.
857 .if make(distributeworld) || make(distrib-dirs) || make(distribution) || \
862 .if defined(DB_FROM_SRC)
863 INSTALLFLAGS+= -N ${.CURDIR}/etc
864 MTREEFLAGS+= -N ${.CURDIR}/etc
866 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
867 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
869 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
870 METALOG:= ${METALOG:C,//+,/,g}
871 IMAKE+= -DNO_ROOT METALOG=${METALOG}
872 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
875 .if defined(BUILD_PKGS)
876 INSTALLFLAGS+= -h sha256
878 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
879 IMAKE_INSTALL= INSTALL="${INSTALL_CMD} ${INSTALLFLAGS}"
880 IMAKE_MTREE= MTREE_CMD="${MTREE_CMD} ${MTREEFLAGS}"
883 DESTDIR_MTREEFLAGS= -deU
884 # When creating worldtmp we don't need to set the directories as owned by root
886 WORLDTMP_MTREEFLAGS= -deUW
888 # When building with -DNO_ROOT we shouldn't be changing the directories
889 # that are created by mtree to be owned by root/wheel.
890 DESTDIR_MTREEFLAGS+= -W
892 DISTR_MTREE= ${MTREE_CMD}
893 .if ${BUILD_WITH_STRICT_TMPPATH} != 0
894 DISTR_MTREE= ${WORLDTMP}/legacy/usr/sbin/mtree
896 WORLDTMP_MTREE= ${DISTR_MTREE} ${WORLDTMP_MTREEFLAGS}
897 DESTDIR_MTREE= ${DISTR_MTREE} ${DESTDIR_MTREEFLAGS}
900 KMAKEENV= ${WMAKEENV:NSYSROOT=*}
901 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
906 # Attempt to rebuild the entire system, with reasonable chance of
907 # success, regardless of how old your existing system is.
909 _sanity_check: .PHONY .MAKE
910 .if ${.CURDIR:C/[^,]//g} != ""
911 # The m4 build of sendmail files doesn't like it if ',' is used
912 # anywhere in the path of it's files.
914 @echo "*** Error: path to source tree contains a comma ','"
917 .elif ${.CURDIR:M*\:*} != ""
918 # Using ':' leaks into PATH and breaks finding cross-tools.
920 @echo "*** Error: path to source tree contains a colon ':'"
925 # Our current approach to dependency tracking cannot cope with certain source
926 # tree changes, particularly with respect to removing source files and
927 # replacing generated files. Handle these cases here in an ad-hoc fashion.
928 _cleanobj_fast_depend_hack: .PHONY
929 @echo ">>> Deleting stale dependencies...";
930 sh ${.CURDIR}/tools/build/depend-cleanup.sh ${OBJTOP}
931 # Date SVN Rev Syscalls/Changes
932 # Syscall stubs rewritten in C and obsolete MD assembly implementations
933 # 20191009 r353340 removal of opensolaris_atomic.S (also r353381)
934 .if ${MACHINE} != i386
935 .for f in opensolaris_atomic
936 @if [ -e "${OBJTOP}/cddl/lib/libzpool/.depend.${f}.o" ] && \
937 egrep -qw 'opensolaris_atomic\.S' ${OBJTOP}/cddl/lib/libzpool/.depend.${f}.o; then \
938 echo "Removing stale dependencies for opensolaris_atomic"; \
939 rm -f ${OBJTOP}/cddl/lib/libzpool/.depend.${f}.* \
940 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/cddl/lib/libzpool/.depend.${f}.*}; \
944 # 20190925 r352689 removal of obsolete i386 memchr.S
946 @if [ -e "${OBJTOP}/lib/libc/.depend.${f}.o" ] && \
947 egrep -qw 'i386/string/memchr\.S' ${OBJTOP}/lib/libc/.depend.${f}.o; then \
948 echo "Removing stale dependencies for memchr"; \
949 rm -f ${OBJTOP}/lib/libc/.depend.${f}.*; \
951 .if defined(_LIBCOMPAT)
952 @if [ -e "${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.o" ] && \
953 egrep -qw 'i386/string/memchr\.S' ${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.o; then \
954 echo "Removing stale dependencies for memchr"; \
955 rm -f ${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*; \
959 # 20190916 r352703 shm_open
961 @if [ -e "${OBJTOP}/lib/libc/.depend.${f}.o" ] && \
962 egrep -qw '${f}\.[sS]' ${OBJTOP}/lib/libc/.depend.${f}.o; then \
963 echo "Removing stale dependencies for ${f} syscall wrappers"; \
964 rm -f ${OBJTOP}/lib/libc/.depend.${f}.* \
965 ${_LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \
971 @echo "--------------------------------------------------------------"
972 @echo ">>> Rebuilding the temporary build tree"
973 @echo "--------------------------------------------------------------"
974 .if !defined(NO_CLEAN)
977 # Note: for delete-old we need to set $PATH to also include the host $PATH
978 # since otherwise a partial build with missing symlinks in ${WORLDTMP}/legacy/
979 # will fail to run due to missing binaries. $WMAKE sets PATH to only ${TMPPATH}
980 # so we remove that assingnment from $WMAKE and prepend the new $PATH
981 ${_+_}@if [ -e "${WORLDTMP}" ]; then \
982 echo ">>> Deleting stale files in build tree..."; \
983 cd ${.CURDIR}; env PATH=${TMPPATH}:${PATH} ${WMAKE:NPATH=*} \
984 _NO_INCLUDE_COMPILERMK=t -DBATCH_DELETE_OLD_FILES delete-old \
985 delete-old-libs >/dev/null; \
987 rm -rf ${WORLDTMP}/legacy/usr/include
988 .if ${USING_SYSTEM_COMPILER} == "yes"
990 if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \
991 inum=$$(stat -f %i ${WORLDTMP}/usr/bin/${cc}); \
992 find ${WORLDTMP}/usr/bin -inum $${inum} -delete; \
995 .endif # ${USING_SYSTEM_COMPILER} == "yes"
996 .if ${USING_SYSTEM_LINKER} == "yes"
997 @rm -f ${WORLDTMP}/usr/bin/ld ${WORLDTMP}/usr/bin/ld.lld
998 .endif # ${USING_SYSTEM_LINKER} == "yes"
999 .endif # !defined(NO_CLEAN)
1000 @mkdir -p ${WORLDTMP}
1001 @touch ${WORLDTMP}/${.TARGET}
1002 # We can't use mtree to create the worldtmp directories since it may not be
1003 # available on the target system (this happens e.g. when building on non-FreeBSD)
1004 cd ${.CURDIR}/tools/build; \
1005 ${MAKE} DIRPRFX=tools/build/ DESTDIR=${WORLDTMP}/legacy installdirs
1006 # In order to build without inheriting $PATH we need to add symlinks to the host
1007 # tools in $WORLDTMP for the tools that we don't build during bootstrap-tools
1008 cd ${.CURDIR}/tools/build; \
1009 ${MAKE} DIRPRFX=tools/build/ DESTDIR=${WORLDTMP}/legacy host-symlinks
1013 @echo "--------------------------------------------------------------"
1014 @echo ">>> stage 1.1: legacy release compatibility shims"
1015 @echo "--------------------------------------------------------------"
1016 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
1019 @echo "--------------------------------------------------------------"
1020 @echo ">>> stage 1.2: bootstrap tools"
1021 @echo "--------------------------------------------------------------"
1022 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
1023 mkdir -p ${WORLDTMP}/usr ${WORLDTMP}/lib/casper ${WORLDTMP}/lib/geom
1024 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1025 -p ${WORLDTMP}/usr >/dev/null
1026 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1027 -p ${WORLDTMP}/usr/include >/dev/null
1028 ln -sf ${.CURDIR}/sys ${WORLDTMP}
1029 .if ${MK_DEBUG_FILES} != "no"
1030 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1031 -p ${WORLDTMP}/usr/lib >/dev/null
1033 .for _mtree in ${LOCAL_MTREE}
1034 ${WORLDTMP_MTREE} -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
1037 .if !defined(NO_CLEAN)
1039 @echo "--------------------------------------------------------------"
1040 @echo ">>> stage 2.1: cleaning up the object tree"
1041 @echo "--------------------------------------------------------------"
1042 # Avoid including bsd.compiler.mk in clean and obj with _NO_INCLUDE_COMPILERMK
1043 # since the restricted $PATH might not contain a valid cc binary
1044 ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t ${CLEANDIR}
1045 .if defined(_LIBCOMPAT)
1046 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} _NO_INCLUDE_COMPILERMK=t -f Makefile.inc1 ${CLEANDIR}
1049 ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t _cleanobj_fast_depend_hack
1050 .endif # !defined(NO_CLEAN)
1053 @echo "--------------------------------------------------------------"
1054 @echo ">>> stage 2.2: rebuilding the object tree"
1055 @echo "--------------------------------------------------------------"
1056 ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t obj
1059 @echo "--------------------------------------------------------------"
1060 @echo ">>> stage 2.3: build tools"
1061 @echo "--------------------------------------------------------------"
1062 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
1065 @echo "--------------------------------------------------------------"
1066 @echo ">>> stage 3: cross tools"
1067 @echo "--------------------------------------------------------------"
1068 @rm -f ${OBJTOP}/toolchain-metadata.mk
1069 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
1070 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
1073 @echo "--------------------------------------------------------------"
1074 @echo ">>> stage 3.1: recording build metadata"
1075 @echo "--------------------------------------------------------------"
1076 ${_+_}cd ${.CURDIR}; ${WMAKE} toolchain-metadata.mk
1077 ${_+_}cd ${.CURDIR}; ${WMAKE} host-osreldate.h
1080 @echo "--------------------------------------------------------------"
1081 @echo ">>> stage 4.1: building includes"
1082 @echo "--------------------------------------------------------------"
1083 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
1084 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
1085 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
1086 MK_INCLUDES=yes includes
1087 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
1088 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
1092 @echo "--------------------------------------------------------------"
1093 @echo ">>> stage 4.2: building libraries"
1094 @echo "--------------------------------------------------------------"
1095 ${_+_}cd ${.CURDIR}; \
1096 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
1097 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS_SUPPORT} \
1101 @echo "--------------------------------------------------------------"
1102 @echo ">>> stage 4.4: building everything"
1103 @echo "--------------------------------------------------------------"
1104 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
1107 .if !defined(WORLDFAST)
1108 WMAKE_TGTS+= _sanity_check _worldtmp _legacy
1109 .if empty(SUBDIR_OVERRIDE)
1110 WMAKE_TGTS+= _bootstrap-tools
1112 WMAKE_TGTS+= _cleanobj
1113 .if !defined(NO_OBJWALK)
1116 WMAKE_TGTS+= _build-tools _cross-tools
1117 WMAKE_TGTS+= _build-metadata
1118 WMAKE_TGTS+= _includes
1120 .if !defined(NO_LIBS)
1121 WMAKE_TGTS+= _libraries
1123 .if defined(_LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
1124 WMAKE_TGTS+= build${libcompat}
1126 WMAKE_TGTS+= everything
1128 # record buildworld time in seconds
1129 .if make(buildworld)
1130 _BUILDWORLD_START!= date '+%s'
1131 .export _BUILDWORLD_START
1134 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
1135 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
1137 buildworld_prologue: .PHONY
1138 @echo "--------------------------------------------------------------"
1139 @echo ">>> World build started on `LC_ALL=C date`"
1140 @echo "--------------------------------------------------------------"
1142 buildworld_epilogue: .PHONY
1144 @echo "--------------------------------------------------------------"
1145 @echo ">>> World build completed on `LC_ALL=C date`"
1146 @seconds=$$(($$(date '+%s') - ${_BUILDWORLD_START})); \
1147 echo -n ">>> World built in $$seconds seconds, "; \
1148 echo "ncpu: $$(sysctl -n hw.ncpu)${.MAKE.JOBS:S/^/, make -j/}"
1149 @echo "--------------------------------------------------------------"
1152 # We need to have this as a target because the indirection between Makefile
1153 # and Makefile.inc1 causes the correct PATH to be used, rather than a
1154 # modification of the current environment's PATH. In addition, we need
1155 # to quote multiword values.
1157 buildenvvars: .PHONY
1158 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
1160 .if ${.TARGETS:Mbuildenv}
1161 .if ${.MAKEFLAGS:M-j}
1162 .error The buildenv target is incompatible with -j
1165 BUILDENV_DIR?= ${.CURDIR}
1167 # Note: make will report any errors the shell reports. This can
1168 # be odd if the last command in an interactive shell generates an
1169 # error or is terminated by SIGINT. These reported errors look bad,
1170 # but are harmless. Allowing them also allows BUIDLENV_SHELL to
1171 # be a complex command whose status will be returned to the caller.
1172 # Some scripts in tools rely on this behavior to report build errors.
1175 @echo Entering world for ${TARGET_ARCH}:${TARGET}
1176 .if ${BUILDENV_SHELL:M*zsh*}
1177 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
1179 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL}
1181 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
1182 toolchain: ${TOOLCHAIN_TGTS} .PHONY
1183 KERNEL_TOOLCHAIN_TGTS= ${TOOLCHAIN_TGTS:N_obj:N_cleanobj:N_includes:N_libraries}
1184 .if make(kernel-toolchain)
1185 .ORDER: ${KERNEL_TOOLCHAIN_TGTS}
1187 kernel-toolchain: ${KERNEL_TOOLCHAIN_TGTS} .PHONY
1192 # Checks to be sure system is ready for installworld/installkernel.
1194 installcheck: _installcheck_world _installcheck_kernel .PHONY
1195 _installcheck_world: .PHONY
1196 @echo "--------------------------------------------------------------"
1197 @echo ">>> Install check world"
1198 @echo "--------------------------------------------------------------"
1199 _installcheck_kernel: .PHONY
1200 @echo "--------------------------------------------------------------"
1201 @echo ">>> Install check kernel"
1202 @echo "--------------------------------------------------------------"
1205 # Require DESTDIR to be set if installing for a different architecture or
1206 # using the user/group database in the source tree.
1208 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
1209 defined(DB_FROM_SRC)
1210 .if !make(distributeworld)
1211 _installcheck_world: __installcheck_DESTDIR
1212 _installcheck_kernel: __installcheck_DESTDIR
1213 __installcheck_DESTDIR: .PHONY
1214 .if !defined(DESTDIR) || empty(DESTDIR)
1215 @echo "ERROR: Please set DESTDIR!"; \
1221 .if !defined(DB_FROM_SRC)
1223 # Check for missing UIDs/GIDs.
1225 CHECK_UIDS= auditdistd
1230 CHECK_GIDS+= proxy authpf
1233 CHECK_UIDS+= unbound
1234 CHECK_GIDS+= unbound
1235 _installcheck_world: __installcheck_UGID
1236 __installcheck_UGID: .PHONY
1237 .for uid in ${CHECK_UIDS}
1238 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
1239 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
1243 .for gid in ${CHECK_GIDS}
1244 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
1245 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
1251 # If installing over the running system (DESTDIR is / or unset) and the install
1252 # includes rescue, try running rescue from the objdir as a sanity check. If
1253 # rescue is not functional (e.g., because it depends on a system call not
1254 # supported by the currently running kernel), abort the installation.
1256 .if !make(distributeworld) && ${MK_RESCUE} != "no" && \
1257 (empty(DESTDIR) || ${DESTDIR} == "/") && empty(BYPASS_INSTALLCHECK_SH)
1258 _installcheck_world: __installcheck_sh_check
1259 __installcheck_sh_check: .PHONY
1260 @if [ "`${OBJTOP}/rescue/rescue/rescue sh -c 'echo OK'`" != \
1262 echo "rescue/sh check failed, installation aborted" >&2; \
1268 # Required install tools to be saved in a scratch dir for safety.
1270 .if ${MK_ZONEINFO} != "no"
1271 _zoneinfo= zic tzsetup
1274 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
1275 date echo egrep find grep id install ${_install-info} \
1276 ln make mkdir mtree mv pwd_mkdb \
1277 rm sed services_mkdb sh sort strip sysctl test true uname wc ${_zoneinfo} \
1280 # Needed for share/man
1281 .if ${MK_MAN_UTILS} != "no"
1288 # Distributes everything compiled by a `buildworld'.
1292 # Installs everything compiled by a 'buildworld'.
1295 # Non-base distributions produced by the base system
1296 EXTRA_DISTRIBUTIONS=
1297 .if defined(_LIBCOMPAT)
1298 EXTRA_DISTRIBUTIONS+= lib${libcompat}
1300 .if ${MK_TESTS} != "no"
1301 EXTRA_DISTRIBUTIONS+= tests
1304 DEBUG_DISTRIBUTIONS=
1305 .if ${MK_DEBUG_FILES} != "no"
1306 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,tests,,}
1309 MTREE_MAGIC?= mtree 2.0
1311 distributeworld installworld stageworld: _installcheck_world .PHONY
1312 mkdir -p ${INSTALLTMP}
1313 progs=$$(for prog in ${ITOOLS}; do \
1314 if progpath=`which $$prog`; then \
1317 echo "Required tool $$prog not found in PATH." >&2; \
1321 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
1322 while read line; do \
1324 if [ "$$2 $$3" != "not found" ]; then \
1327 echo "Required library $$1 not found." >&2; \
1331 cp $$libs $$progs ${INSTALLTMP}
1332 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
1333 .if defined(NO_ROOT)
1334 -mkdir -p ${METALOG:H}
1335 echo "#${MTREE_MAGIC}" > ${METALOG}
1337 .if make(distributeworld)
1338 .for dist in ${EXTRA_DISTRIBUTIONS}
1339 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
1340 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1341 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
1342 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1343 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1344 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1345 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
1346 .if ${MK_DEBUG_FILES} != "no"
1347 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1348 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
1350 .if defined(_LIBCOMPAT)
1351 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1352 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1353 .if ${MK_DEBUG_FILES} != "no"
1354 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1355 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
1358 .if ${MK_TESTS} != "no" && ${dist} == "tests"
1359 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
1360 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1361 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
1362 .if ${MK_DEBUG_FILES} != "no"
1363 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1364 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
1367 .if defined(NO_ROOT)
1368 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1369 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1370 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1371 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1372 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1373 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1374 .if defined(_LIBCOMPAT)
1375 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
1376 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1380 -mkdir ${DESTDIR}/${DISTDIR}/base
1381 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1382 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1383 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1384 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1385 ${INSTALL_SYMLINK} ${INSTALLFLAGS} usr/src/sys ${INSTALL_DDIR}/base/sys
1387 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1388 ${IMAKEENV} rm -rf ${INSTALLTMP}
1389 .if make(distributeworld)
1390 .for dist in ${EXTRA_DISTRIBUTIONS}
1391 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete
1393 .if defined(NO_ROOT)
1394 .for dist in base ${EXTRA_DISTRIBUTIONS}
1395 @# For each file that exists in this dist, print the corresponding
1396 @# line from the METALOG. This relies on the fact that
1397 @# a line containing only the filename will sort immediately before
1398 @# the relevant mtree line.
1399 cd ${DESTDIR}/${DISTDIR}; \
1400 find ./${dist} | sort -u ${METALOG} - | \
1401 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1402 ${DESTDIR}/${DISTDIR}/${dist}.meta
1404 .for dist in ${DEBUG_DISTRIBUTIONS}
1405 @# For each file that exists in this dist, print the corresponding
1406 @# line from the METALOG. This relies on the fact that
1407 @# a line containing only the filename will sort immediately before
1408 @# the relevant mtree line.
1409 cd ${DESTDIR}/${DISTDIR}; \
1410 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1411 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1412 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1417 packageworld: .PHONY
1418 .for dist in base ${EXTRA_DISTRIBUTIONS}
1419 .if defined(NO_ROOT)
1420 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1421 tar cvf - --exclude usr/lib/debug \
1422 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1423 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1425 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1426 tar cvf - --exclude usr/lib/debug . | \
1427 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1431 .for dist in ${DEBUG_DISTRIBUTIONS}
1432 . if defined(NO_ROOT)
1433 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1434 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1435 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1437 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1438 tar cvLf - usr/lib/debug | \
1439 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1444 ${_+_}cd ${.CURDIR}/tools/build/options; sh makeman > \
1445 ${.CURDIR}/share/man/man5/src.conf.5
1447 # We can't assume here that ${TMPPATH} will include ${PATH} or /usr/libexec
1448 # because we may be building with a STRICTTMPPATH, so we explicitly include
1449 # /usr/libexec here for flua. ${TMPPATH} still usefully includes anything else
1450 # we may need to function.
1451 _sysent_PATH= ${TMPPATH}:/usr/libexec
1452 _sysent_dirs= sys/kern
1453 _sysent_dirs+= sys/compat/freebsd32
1454 _sysent_dirs+= sys/compat/cloudabi32 \
1455 sys/compat/cloudabi64
1456 _sysent_dirs+= sys/amd64/linux \
1462 .for _dir in ${_sysent_dirs}
1463 @echo "${MAKE} -C ${.CURDIR}/${_dir} sysent"
1464 ${_+_}@env PATH=${_sysent_PATH} ${MAKE} -C ${.CURDIR}/${_dir} sysent
1470 # If you have a build server, you can NFS mount the source and obj directories
1471 # and do a 'make reinstall' on the *client* to install new binaries from the
1472 # most recent server build.
1474 restage reinstall: .MAKE .PHONY
1475 @echo "--------------------------------------------------------------"
1476 @echo ">>> Making hierarchy"
1477 @echo "--------------------------------------------------------------"
1478 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1479 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1481 @echo "--------------------------------------------------------------"
1482 @echo ">>> Making distribution"
1483 @echo "--------------------------------------------------------------"
1484 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1485 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
1488 @echo "--------------------------------------------------------------"
1489 @echo ">>> Installing everything started on `LC_ALL=C date`"
1490 @echo "--------------------------------------------------------------"
1491 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1492 .if defined(_LIBCOMPAT)
1493 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1495 @echo "--------------------------------------------------------------"
1496 @echo ">>> Installing everything completed on `LC_ALL=C date`"
1497 @echo "--------------------------------------------------------------"
1499 redistribute: .MAKE .PHONY
1500 @echo "--------------------------------------------------------------"
1501 @echo ">>> Distributing everything"
1502 @echo "--------------------------------------------------------------"
1503 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1504 .if defined(_LIBCOMPAT)
1505 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1506 DISTRIBUTION=lib${libcompat}
1509 distrib-dirs distribution: .MAKE .PHONY
1510 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1511 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1512 .if make(distribution)
1513 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1514 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1515 METALOG=${METALOG} MK_TESTS=no \
1516 MK_TESTS_SUPPORT=${MK_TESTS_SUPPORT} installconfig
1520 # buildkernel and installkernel
1522 # Which kernels to build and/or install is specified by setting
1523 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1524 # Only the existing (depending TARGET) config files are used
1525 # for building kernels and only the first of these is designated
1526 # as the one being installed.
1528 # Note that we have to use TARGET instead of TARGET_ARCH when
1529 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1530 # be set to cross-build, we have to make sure TARGET is set
1533 .if defined(KERNFAST)
1537 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1538 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1539 KERNCONF=${KERNFAST}
1542 .if ${TARGET_ARCH} == "powerpc64"
1543 KERNCONF?= GENERIC64
1547 INSTKERNNAME?= kernel
1549 KERNSRCDIR?= ${.CURDIR}/sys
1550 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1551 KRNLOBJDIR= ${OBJTOP}${KERNSRCDIR:C,^${.CURDIR},,}
1552 KERNCONFDIR?= ${KRNLCONFDIR}
1556 .if defined(NO_INSTALLKERNEL)
1557 # All of the BUILDKERNELS loops start at index 1.
1558 BUILDKERNELS+= dummy
1560 .for _kernel in ${KERNCONF}
1561 .if !defined(_MKSHOWCONFIG) && exists(${KERNCONFDIR}/${_kernel})
1562 BUILDKERNELS+= ${_kernel}
1563 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1564 INSTALLKERNEL= ${_kernel}
1567 .if make(buildkernel)
1568 .error Missing KERNCONF ${KERNCONFDIR}/${_kernel}
1573 _cleankernobj_fast_depend_hack: .PHONY
1574 # 20180320 remove stale generated assym.s after renaming to .inc in r331254
1575 @if [ -e "${OBJTOP}/sys/${KERNCONF}/assym.s" ]; then \
1576 echo "Removing stale generated assym files"; \
1577 rm -f ${OBJTOP}/sys/${KERNCONF}/assym.* \
1578 ${OBJTOP}/sys/${KERNCONF}/.depend.assym.*; \
1580 # 20191009 r353340 removal of opensolaris_atomic.S (also r353381)
1581 .if ${MACHINE} != i386
1582 .for f in opensolaris_atomic
1583 .for m in opensolaris zfs
1584 @if [ -e "${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o" ] && \
1585 grep -q ${f}.S "${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o"; then \
1586 echo "Removing stale dependencies for opensolaris_atomic"; \
1587 rm -f ${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.*; \
1593 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1595 # record kernel(s) build time in seconds
1596 .if make(buildkernel)
1597 _BUILDKERNEL_START!= date '+%s'
1603 # Builds all kernels defined by BUILDKERNELS.
1605 buildkernel: .MAKE .PHONY
1606 .if empty(BUILDKERNELS:Ndummy)
1607 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1611 .for _kernel in ${BUILDKERNELS:Ndummy}
1612 @echo "--------------------------------------------------------------"
1613 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1614 @echo "--------------------------------------------------------------"
1615 @echo "===> ${_kernel}"
1616 mkdir -p ${KRNLOBJDIR}
1617 .if !defined(NO_KERNELCONFIG)
1619 @echo "--------------------------------------------------------------"
1620 @echo ">>> stage 1: configuring the kernel"
1621 @echo "--------------------------------------------------------------"
1622 cd ${KRNLCONFDIR}; \
1624 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1625 -I '${KERNCONFDIR}' -I '${KRNLCONFDIR}' \
1626 '${KERNCONFDIR}/${_kernel}'
1628 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1630 @echo "--------------------------------------------------------------"
1631 @echo ">>> stage 2.1: cleaning up the object tree"
1632 @echo "--------------------------------------------------------------"
1633 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1635 ${_+_}cd ${.CURDIR}; ${WMAKE} _cleankernobj_fast_depend_hack
1637 .if !defined(NO_KERNELOBJ)
1639 @echo "--------------------------------------------------------------"
1640 @echo ">>> stage 2.2: rebuilding the object tree"
1641 @echo "--------------------------------------------------------------"
1642 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1645 @echo "--------------------------------------------------------------"
1646 @echo ">>> stage 2.3: build tools"
1647 @echo "--------------------------------------------------------------"
1648 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1650 @echo "--------------------------------------------------------------"
1651 @echo ">>> stage 3.1: building everything"
1652 @echo "--------------------------------------------------------------"
1653 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1654 @echo "--------------------------------------------------------------"
1655 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1656 @echo "--------------------------------------------------------------"
1659 @seconds=$$(($$(date '+%s') - ${_BUILDKERNEL_START})); \
1660 echo -n ">>> Kernel(s) ${BUILDKERNELS} built in $$seconds seconds, "; \
1661 echo "ncpu: $$(sysctl -n hw.ncpu)${.MAKE.JOBS:S/^/, make -j/}"
1662 @echo "--------------------------------------------------------------"
1664 NO_INSTALLEXTRAKERNELS?= yes
1667 # installkernel, etc.
1669 # Install the kernel defined by INSTALLKERNEL
1671 installkernel installkernel.debug \
1672 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1673 .if !defined(NO_INSTALLKERNEL)
1674 .if empty(INSTALLKERNEL)
1675 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1678 @echo "--------------------------------------------------------------"
1679 @echo ">>> Installing kernel ${INSTALLKERNEL} on $$(LC_ALL=C date)"
1680 @echo "--------------------------------------------------------------"
1681 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1682 ${CROSSENV} PATH=${TMPPATH} \
1683 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1684 @echo "--------------------------------------------------------------"
1685 @echo ">>> Installing kernel ${INSTALLKERNEL} completed on $$(LC_ALL=C date)"
1686 @echo "--------------------------------------------------------------"
1688 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1689 .for _kernel in ${BUILDKERNELS:[2..-1]}
1690 @echo "--------------------------------------------------------------"
1691 @echo ">>> Installing kernel ${_kernel} $$(LC_ALL=C date)"
1692 @echo "--------------------------------------------------------------"
1693 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
1694 ${CROSSENV} PATH=${TMPPATH} \
1695 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1696 @echo "--------------------------------------------------------------"
1697 @echo ">>> Installing kernel ${_kernel} completed on $$(LC_ALL=C date)"
1698 @echo "--------------------------------------------------------------"
1702 distributekernel distributekernel.debug: .PHONY
1703 .if !defined(NO_INSTALLKERNEL)
1704 .if empty(INSTALLKERNEL)
1705 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1708 mkdir -p ${DESTDIR}/${DISTDIR}
1709 .if defined(NO_ROOT)
1710 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1712 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1713 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1714 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1715 DESTDIR=${INSTALL_DDIR}/kernel \
1716 ${.TARGET:S/distributekernel/install/}
1717 .if defined(NO_ROOT)
1718 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1719 ${DESTDIR}/${DISTDIR}/kernel.meta
1722 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1723 .for _kernel in ${BUILDKERNELS:[2..-1]}
1724 .if defined(NO_ROOT)
1725 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1727 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
1728 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1729 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1730 KERNEL=${INSTKERNNAME}.${_kernel} \
1731 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1732 ${.TARGET:S/distributekernel/install/}
1733 .if defined(NO_ROOT)
1734 @sed -e "s|^./kernel.${_kernel}|.|" \
1735 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1736 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1741 packagekernel: .PHONY
1742 .if defined(NO_ROOT)
1743 .if !defined(NO_INSTALLKERNEL)
1744 cd ${DESTDIR}/${DISTDIR}/kernel; \
1745 tar cvf - --exclude '*.debug' \
1746 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1747 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1749 .if ${MK_DEBUG_FILES} != "no"
1750 cd ${DESTDIR}/${DISTDIR}/kernel; \
1751 tar cvf - --include '*/*/*.debug' \
1752 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1753 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1755 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1756 .for _kernel in ${BUILDKERNELS:[2..-1]}
1757 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1758 tar cvf - --exclude '*.debug' \
1759 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1760 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1761 .if ${MK_DEBUG_FILES} != "no"
1762 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1763 tar cvf - --include '*/*/*.debug' \
1764 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1765 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1770 .if !defined(NO_INSTALLKERNEL)
1771 cd ${DESTDIR}/${DISTDIR}/kernel; \
1772 tar cvf - --exclude '*.debug' . | \
1773 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1775 .if ${MK_DEBUG_FILES} != "no"
1776 cd ${DESTDIR}/${DISTDIR}/kernel; \
1777 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1778 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1780 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1781 .for _kernel in ${BUILDKERNELS:[2..-1]}
1782 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1783 tar cvf - --exclude '*.debug' . | \
1784 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1785 .if ${MK_DEBUG_FILES} != "no"
1786 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1787 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1788 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1795 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1797 PORTSDIR?= /usr/ports
1798 WSTAGEDIR?= ${OBJTOP}/worldstage
1799 KSTAGEDIR?= ${OBJTOP}/kernelstage
1800 REPODIR?= ${OBJROOT}repo
1802 PKGSIGNKEY?= # empty
1804 .ORDER: stage-packages create-packages
1805 .ORDER: create-packages create-world-packages
1806 .ORDER: create-packages create-kernel-packages
1807 .ORDER: create-packages sign-packages
1809 _pkgbootstrap: .PHONY
1810 .if make(*package*) && !exists(${LOCALBASE}/sbin/pkg)
1811 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1815 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1818 rm -rf /tmp/ports.${TARGET} || :
1819 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
1820 PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \
1821 WSTAGEDIR=${WSTAGEDIR} \
1822 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1824 real-packages: stage-packages create-packages sign-packages .PHONY
1826 stage-packages-world: .PHONY
1827 @mkdir -p ${WSTAGEDIR}
1828 ${_+_}@cd ${.CURDIR}; \
1829 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT stageworld
1831 stage-packages-kernel: .PHONY
1832 @mkdir -p ${KSTAGEDIR}
1833 ${_+_}@cd ${.CURDIR}; \
1834 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT stagekernel
1836 stage-packages: .PHONY stage-packages-world stage-packages-kernel
1839 @mkdir -p ${REPODIR}
1841 create-packages-world: _pkgbootstrap _repodir .PHONY
1842 ${_+_}@cd ${.CURDIR}; \
1843 ${MAKE} -f Makefile.inc1 \
1844 DESTDIR=${WSTAGEDIR} \
1845 PKG_VERSION=${PKG_VERSION} create-world-packages
1847 create-packages-kernel: _pkgbootstrap _repodir .PHONY
1848 ${_+_}@cd ${.CURDIR}; \
1849 ${MAKE} -f Makefile.inc1 \
1850 DESTDIR=${KSTAGEDIR} \
1851 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1852 create-kernel-packages
1854 create-packages: .PHONY create-packages-world create-packages-kernel
1856 create-world-packages: _pkgbootstrap .PHONY
1857 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1858 @cd ${WSTAGEDIR} ; \
1859 env -i LC_COLLATE=C sort ${WSTAGEDIR}/${DISTDIR}/METALOG | \
1860 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk
1861 @for plist in ${WSTAGEDIR}/*.plist; do \
1862 plist=$${plist##*/} ; \
1863 pkgname=$${plist%.plist} ; \
1864 echo "_PKGS+= $${pkgname}" ; \
1865 done > ${WSTAGEDIR}/packages.mk
1866 ${_+_}@cd ${.CURDIR}; \
1867 ${MAKE} -f Makefile.inc1 create-world-packages-jobs \
1870 .if make(create-world-packages-jobs)
1871 .include "${WSTAGEDIR}/packages.mk"
1874 .if make(create-world-packages-jobs) || make(create-kernel-packages*)
1875 PKG_ABI!=${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI
1878 create-world-packages-jobs: .PHONY
1879 .for pkgname in ${_PKGS}
1880 create-world-packages-jobs: create-world-package-${pkgname}
1881 create-world-package-${pkgname}: .PHONY
1882 @sh ${SRCDIR}/release/packages/generate-ucl.sh -o ${pkgname} \
1883 -s ${SRCDIR} -u ${WSTAGEDIR}/${pkgname}.ucl
1885 /^name/ { printf("===> Creating %s-", $$2); next } \
1886 /^version/ { print $$2; next } \
1887 ' ${WSTAGEDIR}/${pkgname}.ucl
1888 @if [ "${pkgname}" == "runtime" ]; then \
1889 sed -i '' -e "s/%VCS_REVISION%/${VCS_REVISION}/" ${WSTAGEDIR}/${pkgname}.ucl ; \
1891 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname -o ALLOW_BASE_SHLIBS=yes \
1892 create -f ${PKG_FORMAT} -M ${WSTAGEDIR}/${pkgname}.ucl \
1893 -p ${WSTAGEDIR}/${pkgname}.plist \
1895 -o ${REPODIR}/${PKG_ABI}/${PKG_VERSION}
1898 _default_flavor= -default
1899 .if make(*package*) && exists(${KSTAGEDIR}/kernel.meta)
1900 . if ${MK_DEBUG_FILES} != "no"
1903 create-kernel-packages: .PHONY
1904 . for flavor in "" ${_debug}
1905 create-kernel-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}
1906 create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY
1907 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1908 env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.meta | \
1909 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1910 -v kernel=yes -v _kernconf=${INSTALLKERNEL} ; \
1911 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1912 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1913 -e "s/%KERNELDIR%/kernel/" \
1914 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1915 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1916 -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \
1917 ${SRCDIR}/release/packages/kernel.ucl \
1918 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1920 /name/ { printf("===> Creating %s-", $$2); next } \
1921 /version/ {print $$2; next } ' \
1922 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1923 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname -o ALLOW_BASE_SHLIBS=yes \
1924 create -f ${PKG_FORMAT} \
1925 -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1926 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1927 -r ${KSTAGEDIR}/${DISTDIR} \
1928 -o ${REPODIR}/${PKG_ABI}/${PKG_VERSION}
1931 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1932 . for _kernel in ${BUILDKERNELS:[2..-1]}
1933 . if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1934 . if ${MK_DEBUG_FILES} != "no"
1937 . for flavor in "" ${_debug}
1938 create-kernel-packages: create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}
1939 create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}: _pkgbootstrap .PHONY
1940 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1941 env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.${_kernel}.meta | \
1942 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1943 -v kernel=yes -v _kernconf=${_kernel} ; \
1944 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1945 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1946 -e "s/%KERNELDIR%/kernel.${_kernel}/" \
1947 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1948 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1949 -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \
1950 ${SRCDIR}/release/packages/kernel.ucl \
1951 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1953 /name/ { printf("===> Creating %s-", $$2); next } \
1954 /version/ {print $$2; next } ' \
1955 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1956 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname -o ALLOW_BASE_SHLIBS=yes \
1957 create -f ${PKG_FORMAT} \
1958 -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1959 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1960 -r ${KSTAGEDIR}/kernel.${_kernel} \
1961 -o ${REPODIR}/${PKG_ABI}/${PKG_VERSION}
1967 sign-packages: _pkgbootstrap .PHONY
1968 printf "version = 2;\npacking_format = \"${PKG_FORMAT}\";\n" > ${WSTAGEDIR}/meta
1969 @[ -L "${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/latest" ] && \
1970 unlink ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/latest ; \
1971 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname repo \
1972 -m ${WSTAGEDIR}/meta \
1973 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/${PKG_VERSION} \
1974 ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/${PKG_VERSION} \
1976 cd ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI); \
1977 ln -s ${PKG_VERSION} latest
1983 # Run test suite on installed world.
1986 @if [ ! -x "${LOCALBASE}/bin/kyua" ] && [ ! -x "/usr/bin/kyua" ]; then \
1987 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1990 ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile
1996 # Build the API documentation with doxygen
1999 @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \
2000 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
2003 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
2008 # Update the source tree(s), by running svn/svnup to update to the
2012 .if defined(SVN_UPDATE)
2013 @echo "--------------------------------------------------------------"
2014 @echo ">>> Updating ${.CURDIR} using Subversion"
2015 @echo "--------------------------------------------------------------"
2016 @(cd ${.CURDIR}; ${SVN_CMD} update ${SVNFLAGS})
2020 # ------------------------------------------------------------------------
2022 # From here onwards are utility targets used by the 'make world' and
2023 # related targets. If your 'world' breaks, you may like to try to fix
2024 # the problem and manually run the following targets to attempt to
2025 # complete the build. Beware, this is *not* guaranteed to work, you
2026 # need to have a pretty good grip on the current state of the system
2027 # to attempt to manually finish it. If in doubt, 'make world' again.
2031 # legacy: Build compatibility shims for the next three targets. This is a
2032 # minimal set of tools and shims necessary to compensate for older systems
2033 # which don't have the APIs required by the targets built in bootstrap-tools,
2034 # build-tools or cross-tools.
2038 # libnv is a requirement for config(8), which is an unconditional
2040 _config_deps= lib/libnv
2043 .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
2044 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
2048 .for _tool in tools/build ${_config_deps}
2049 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
2050 cd ${.CURDIR}/${_tool}; \
2051 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2052 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy includes; \
2053 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
2054 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
2055 DESTDIR=${WORLDTMP}/legacy install
2059 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
2060 # are built to build other binaries in the system. However, the focus of these
2061 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
2062 # libraries, augmented by -legacy, in addition to the libraries built during
2065 _bt= _bootstrap-tools
2067 # We want to run the build with only ${WORLDTMP} in $PATH to ensure we don't
2068 # accidentally run tools that are incompatible but happen to be in $PATH.
2069 # This is especially important when building on Linux/MacOS where many of the
2070 # programs used during the build accept different flags or generate different
2071 # output. On those platforms we only symlink the tools known to be compatible
2072 # (e.g. basic utilities such as mkdir) into ${WORLDTMP} and build all others
2073 # from the FreeBSD sources during the bootstrap-tools stage.
2074 # We want to build without the user's $PATH starting in the bootstrap-tools
2075 # phase so the tools used in that phase (ln, cp, etc) must have already been
2076 # linked to $WORLDTMP. The tools are listed in the _host_tools_to_symlink
2077 # variable in tools/build/Makefile and are linked during the legacy phase.
2078 # Since they could be Linux or MacOS binaries, too we must only use flags that
2079 # are portable across operating systems.
2081 # If BOOTSTRAP_ALL_TOOLS is set we will build all the required tools from the
2082 # current source tree. Otherwise we create a symlink to the version found in
2083 # $PATH during the bootstrap-tools stage.
2084 .if defined(BOOTSTRAP_ALL_TOOLS)
2085 # BOOTSTRAPPING will be set on the command line so we can't override it here.
2086 # Instead set BOOTSTRAPPING_OSRELDATE so that the value 0 is set ${BSARGS}
2087 BOOTSTRAPPING_OSRELDATE:= 0
2090 .if ${MK_GAMES} != "no"
2091 _strfile= usr.bin/fortune/strfile
2094 .if ${MK_VT} != "no"
2095 _vtfontcvt= usr.bin/vtfontcvt
2098 # If we are not building the bootstrap because BOOTSTRAPPING is sufficient
2099 # we symlink the host version to $WORLDTMP instead. By doing this we can also
2100 # detect when a bootstrap tool is being used without the required MK_FOO.
2101 # If you add a new bootstrap tool where we could also use the host version,
2102 # please ensure that you also add a .else case where you add the tool to the
2103 # _bootstrap_tools_links variable.
2104 .if ${BOOTSTRAPPING} < 1000033
2107 # Note: lex needs m4 to build but m4 also depends on lex. However, lex can be
2108 # bootstrapped so we build lex first.
2109 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd ${_bt}-usr.bin/yacc ${_bt}-${_lex}
2110 _bt_m4_depend=${_bt}-${_m4}
2111 _bt_lex_depend=${_bt}-${_lex} ${_bt_m4_depend}
2113 _bootstrap_tools_links+=m4 lex
2116 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
2117 # r296685 fix cross-endian objcopy
2118 # r310724 fixed PR 215350, a crash in libdwarf with objects built by GCC 6.2.
2119 # r334881 added libdwarf constants used by ctfconvert.
2120 # r338478 fixed a crash in objcopy for mips64el objects
2121 # r339083 libelf: correct mips64el test to use ELF header
2122 # r348347 Add missing powerpc64 relocation support to libdwarf
2123 .if ${BOOTSTRAPPING} < 1300030
2124 _elftoolchain_libs= lib/libelf lib/libdwarf lib/libzstd
2125 ${_bt}-lib/libelf: ${_bt_m4_depend}
2126 ${_bt}-lib/libdwarf: ${_bt_m4_depend}
2129 # flua is required to regenerate syscall files. It first appeared during the
2130 # 13.0-CURRENT cycle, thus needs to be built on -older releases and stable
2132 .if ${BOOTSTRAPPING} < 1300059
2133 ${_bt}-libexec/flua: ${_bt}-lib/liblua
2134 _flua= lib/liblua libexec/flua
2137 # r245440 mtree -N support added
2138 # r313404 requires sha384.h for libnetbsd, added to libmd in r292782
2139 .if ${BOOTSTRAPPING} < 1100093
2140 _nmtree= lib/libmd \
2144 ${_bt}-lib/libnetbsd: ${_bt}-lib/libmd
2145 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
2147 _bootstrap_tools_links+=mtree
2150 # r246097: log addition login.conf.db, passwd, pwd.db, and spwd.db with cat -l
2151 .if ${BOOTSTRAPPING} < 1000027
2154 _bootstrap_tools_links+=cat
2157 # r277259 crunchide: Correct 64-bit section header offset
2158 # r281674 crunchide: always include both 32- and 64-bit ELF support
2159 .if ${BOOTSTRAPPING} < 1100078
2160 _crunchide= usr.sbin/crunch/crunchide
2162 _bootstrap_tools_links+=crunchide
2165 # r285986 crunchen: use STRIPBIN rather than STRIP
2166 # 1100113: Support MK_AUTO_OBJ
2167 # 1200006: META_MODE fixes
2168 .if ${BOOTSTRAPPING} < 1100078 || \
2169 (${MK_AUTO_OBJ} == "yes" && ${BOOTSTRAPPING} < 1100114) || \
2170 (${MK_META_MODE} == "yes" && ${BOOTSTRAPPING} < 1200006)
2171 _crunchgen= usr.sbin/crunch/crunchgen
2173 _bootstrap_tools_links+=crunchgen
2176 # r296926 -P keymap search path, MFC to stable/10 in r298297
2177 .if ${BOOTSTRAPPING} < 1003501 || \
2178 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
2179 _kbdcontrol= usr.sbin/kbdcontrol
2181 _bootstrap_tools_links+=kbdcontrol
2186 .if ${MK_BSNMP} != "no"
2187 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
2190 .if ${MK_LOCALES} != "no"
2191 _localedef= usr.bin/localedef
2194 # We need to build tblgen when we're building clang or lld, either as
2195 # bootstrap tools, or as the part of the normal build.
2196 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
2197 ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no"
2199 lib/clang/libllvmminimal \
2200 usr.bin/clang/llvm-tblgen \
2201 usr.bin/clang/clang-tblgen \
2202 usr.bin/clang/lldb-tblgen
2203 # XXX: lldb-tblgen is not needed, if top-level MK_LLDB=no
2205 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal
2206 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal
2207 ${_bt}-usr.bin/clang/lldb-tblgen: ${_bt}-lib/clang/libllvmminimal
2210 .if ${MK_LOCALES} != "no"
2211 _localedef= usr.bin/localedef
2214 .if ${MK_KERBEROS} != "no"
2215 _kerberos5_bootstrap_tools= \
2216 kerberos5/tools/make-roken \
2217 kerberos5/lib/libroken \
2218 kerberos5/lib/libvers \
2219 kerberos5/tools/asn1_compile \
2220 kerberos5/tools/slc \
2223 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
2224 .for _tool in ${_kerberos5_bootstrap_tools}
2225 ${_bt}-${_tool}: ${_bt}-usr.bin/yacc ${_bt_lex_depend}
2229 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
2231 # The tools listed in _basic_bootstrap_tools will generally not be
2232 # bootstrapped unless BOOTSTRAP_ALL_TOOL is set. However, when building on a
2233 # Linux or MacOS host the host versions are incompatible so we need to build
2234 # them from the source tree. Usually the link name will be the same as the subdir,
2235 # but some directories such as grep or test install multiple binaries. In that
2236 # case we use the _basic_bootstrap_tools_multilink variable which is a list of
2237 # subdirectory and comma-separated list of files.
2238 _basic_bootstrap_tools_multilink=usr.bin/grep grep,egrep,fgrep
2239 _basic_bootstrap_tools_multilink+=bin/test test,[
2240 # bootstrap tools needed by buildworld:
2241 _basic_bootstrap_tools=usr.bin/awk usr.bin/cut bin/expr usr.bin/gencat \
2242 usr.bin/join usr.bin/mktemp bin/rmdir usr.bin/sed usr.bin/sort \
2243 usr.bin/truncate usr.bin/tsort
2244 # file2c is required for building usr.sbin/config:
2245 _basic_bootstrap_tools+=usr.bin/file2c
2246 # uuencode/uudecode required for share/tabset
2247 _basic_bootstrap_tools+=usr.bin/uuencode usr.bin/uudecode
2248 # xargs is required by mkioctls
2249 _basic_bootstrap_tools+=usr.bin/xargs
2250 # cap_mkdb is required for share/termcap:
2251 _basic_bootstrap_tools+=usr.bin/cap_mkdb
2252 # ldd is required for installcheck (TODO: just always use /usr/bin/ldd instead?)
2253 _basic_bootstrap_tools+=usr.bin/ldd
2254 # services_mkdb/pwd_mkdb are required for installworld:
2255 _basic_bootstrap_tools+=usr.sbin/services_mkdb usr.sbin/pwd_mkdb
2256 # sysctl/chflags are required for installkernel:
2257 _basic_bootstrap_tools+=sbin/sysctl bin/chflags
2258 # mkfifo is used by sys/conf/newvers.sh
2259 _basic_bootstrap_tools+=usr.bin/mkfifo
2261 .if ${MK_BOOT} != "no"
2262 _basic_bootstrap_tools+=bin/dd
2263 # xz/unxz is used by EFI
2264 _basic_bootstrap_tools_multilink+=usr.bin/xz xz,unxz
2265 # md5 is used by boot/beri (and possibly others)
2266 _basic_bootstrap_tools+=sbin/md5
2267 .if defined(BOOTSTRAP_ALL_TOOLS)
2268 ${_bt}-sbin/md5: ${_bt}-lib/libmd
2272 .if ${MK_ZONEINFO} != "no"
2273 _basic_bootstrap_tools+=usr.sbin/zic usr.sbin/tzsetup
2276 .if defined(BOOTSTRAP_ALL_TOOLS)
2277 _other_bootstrap_tools+=${_basic_bootstrap_tools}
2278 .for _subdir _links in ${_basic_bootstrap_tools_multilink}
2279 _other_bootstrap_tools+=${_subdir}
2281 ${_bt}-usr.bin/awk: ${_bt_lex_depend} ${_bt}-usr.bin/yacc
2282 ${_bt}-bin/expr: ${_bt_lex_depend} ${_bt}-usr.bin/yacc
2283 # If we are bootstrapping file2c, we have to build it before config:
2284 ${_bt}-usr.sbin/config: ${_bt}-usr.bin/file2c ${_bt_lex_depend}
2285 # Note: no symlink to make/bmake in the !BOOTSTRAP_ALL_TOOLS case here since
2286 # the links to make/bmake make links will have already have been created in the
2287 # `make legacy` step. Not adding a link to make is important on non-FreeBSD
2288 # since "make" will usually point to GNU make there.
2289 _other_bootstrap_tools+=usr.bin/bmake
2291 # All tools in _basic_bootstrap_tools have the same name as the subdirectory
2292 # so we can use :T to get the name of the symlinks that we need to create.
2293 _bootstrap_tools_links+=${_basic_bootstrap_tools:T}
2294 .for _subdir _links in ${_basic_bootstrap_tools_multilink}
2295 _bootstrap_tools_links+=${_links:S/,/ /g}
2297 .endif # defined(BOOTSTRAP_ALL_TOOLS)
2299 # Link the tools that we need for building but don't need to bootstrap because
2300 # the host version is known to be compatible into ${WORLDTMP}/legacy
2301 # We do this before building any of the bootstrap tools in case they depend on
2302 # the presence of any of the links (e.g. as m4/lex/awk)
2303 ${_bt}-links: .PHONY
2305 .for _tool in ${_bootstrap_tools_links}
2306 ${_bt}-link-${_tool}: .PHONY .MAKE
2307 @if [ ! -e "${WORLDTMP}/legacy/bin/${_tool}" ]; then \
2308 source_path=`which ${_tool}`; \
2309 if [ ! -e "$${source_path}" ] ; then \
2310 echo "Cannot find host tool '${_tool}'"; false; \
2312 ln -sfnv "$${source_path}" "${WORLDTMP}/legacy/bin/${_tool}"; \
2314 ${_bt}-links: ${_bt}-link-${_tool}
2317 bootstrap-tools: ${_bt}-links .PHONY
2319 # Please document (add comment) why something is in 'bootstrap-tools'.
2320 # Try to bound the building of the bootstrap-tool to just the
2321 # FreeBSD versions that need the tool built at this stage of the build.
2324 ${_kerberos5_bootstrap_tools} \
2329 ${_elftoolchain_libs} \
2337 ${_other_bootstrap_tools} \
2347 ${_bt}-${_tool}: ${_bt}-links .PHONY .MAKE
2348 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2349 cd ${.CURDIR}/${_tool}; \
2350 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2351 if [ "${_tool}" = "usr.bin/lex" ]; then \
2352 ${MAKE} DIRPRFX=${_tool}/ bootstrap; \
2354 ${MAKE} DIRPRFX=${_tool}/ all; \
2355 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy install
2357 bootstrap-tools: ${_bt}-${_tool}
2361 # build-tools: Build special purpose build tools
2363 .if !defined(NO_SHARE) && ${MK_SYSCONS} != "no"
2364 _share= share/syscons/scrnmaps
2367 .if ${MK_RESCUE} != "no"
2368 # rescue includes programs that have build-tools targets
2369 _rescue=rescue/rescue
2372 .if ${MK_TCSH} != "no"
2375 .if ${MK_FILE} != "no"
2376 _libmagic=lib/libmagic
2379 .if ${MK_PMC} != "no" && \
2380 (${TARGET_ARCH} == "aarch64" || ${TARGET_ARCH} == "amd64" || \
2381 ${TARGET_ARCH} == "i386")
2382 _jevents=lib/libpmc/pmu-events
2385 # kernel-toolchain skips _cleanobj, so handle cleaning up previous
2386 # build-tools directories if needed.
2387 .if !defined(NO_CLEAN) && make(kernel-toolchain)
2388 _bt_clean= ${CLEANDIR}
2394 ${LOCAL_TOOL_DIRS} \
2396 lib/ncurses/ncurses \
2397 lib/ncurses/ncursesw \
2402 usr.bin/mkesdb_static \
2403 usr.bin/mkcsmapper_static \
2405 build-tools_${_tool}: .PHONY
2406 ${_+_}@${ECHODIR} "===> ${_tool} (${_bt_clean:D${_bt_clean},}obj,build-tools)"; \
2407 cd ${.CURDIR}/${_tool}; \
2408 if [ -n "${_bt_clean}" ]; then ${MAKE} DIRPRFX=${_tool}/ ${_bt_clean}; fi; \
2409 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2410 ${MAKE} DIRPRFX=${_tool}/ build-tools
2411 build-tools: build-tools_${_tool}
2415 # kernel-tools: Build kernel-building tools
2417 kernel-tools: .PHONY
2418 mkdir -p ${WORLDTMP}/usr
2419 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2420 -p ${WORLDTMP}/usr >/dev/null
2423 # cross-tools: All the tools needed to build the rest of the system after
2424 # we get done with the earlier stages. It is the last set of tools needed
2425 # to begin building the target binaries.
2427 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BUILD_WITH_STRICT_TMPPATH} != 0
2428 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
2429 _btxld= usr.sbin/btxld
2433 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
2434 # resulting from missing bug fixes or ELF Toolchain updates.
2435 .if ${MK_CDDL} != "no"
2436 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
2437 cddl/usr.bin/ctfmerge
2440 # If we're given an XAS, don't build binutils.
2441 .if ${XAS:M/*} == ""
2442 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
2443 _binutils= gnu/usr.bin/binutils
2445 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
2446 _elftctools= lib/libelftc \
2452 # These are not required by the build, but can be useful for developers who
2453 # cross-build on a FreeBSD 10 host:
2454 _elftctools+= usr.bin/addr2line
2456 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
2457 # If cross-building with an external binutils we still need to build strip for
2458 # the target (for at least crunchide).
2459 _elftctools= lib/libelftc \
2464 .if ${MK_CLANG_BOOTSTRAP} != "no"
2465 _clang= usr.bin/clang
2467 .if ${MK_LLD_BOOTSTRAP} != "no"
2468 _lld= usr.bin/clang/lld
2470 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no"
2471 _clang_libs= lib/clang
2473 .if ${MK_USB} != "no"
2474 _usb_tools= stand/usb/tools
2477 .if ${BUILD_WITH_STRICT_TMPPATH} != 0 || defined(BOOTSTRAP_ALL_TOOLS)
2481 cross-tools: .MAKE .PHONY
2483 ${LOCAL_XTOOL_DIRS} \
2493 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2494 cd ${.CURDIR}/${_tool}; \
2495 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2496 ${MAKE} DIRPRFX=${_tool}/ all; \
2497 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP} install
2501 # native-xtools is the current target for qemu-user cross builds of ports
2502 # via poudriere and the imgact_binmisc kernel module.
2503 # This target merely builds a toolchan/sysroot, then builds the tools it wants
2504 # with the options it wants in a special MAKEOBJDIRPREFIX, using the toolchain
2505 # already built. It then installs the static tools to NXBDESTDIR for Poudriere
2508 NXBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/nxb/
2509 NXBOBJTOP= ${NXBOBJROOT}${NXB_TARGET}.${NXB_TARGET_ARCH}
2512 .error NXTP variable should be an absolute path
2514 NXBDESTDIR?= ${DESTDIR}${NXTP}
2516 # This is the list of tools to be built/installed as static and where
2517 # appropriate to build for the given TARGET.TARGET_ARCH.
2581 SUBDIR_DEPEND_usr.bin/clang= lib/clang
2582 .if ${MK_CLANG} != "no"
2584 NXBDIRS+= usr.bin/clang
2586 .if ${MK_BINUTILS} != "no"
2587 NXBDIRS+= gnu/usr.bin/binutils
2589 # XXX: native-xtools passes along ${NXBDIRS} in SUBDIR_OVERRIDE that needs
2590 # to be evaluated after NXBDIRS is set.
2591 .if make(install) && !empty(SUBDIR_OVERRIDE)
2592 SUBDIR= ${SUBDIR_OVERRIDE}
2596 OBJTOP=${NXBOBJTOP:Q} \
2597 OBJROOT=${NXBOBJROOT:Q} \
2604 MK_CLANG_EXTRAS=no \
2623 .if make(native-xtools*) && \
2624 (!defined(NXB_TARGET) || !defined(NXB_TARGET_ARCH))
2625 .error Missing NXB_TARGET / NXB_TARGET_ARCH
2627 # For 'toolchain' we want to produce native binaries that themselves generate
2629 NXBTMAKE= ${NXBMAKEENV} ${MAKE} ${NXBMAKEARGS:N-DNO_PIC:N-DNO_SHARED} \
2630 TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH}
2631 # For 'everything' we want to produce native binaries (hence -target to
2632 # be MACHINE) that themselves generate TARGET.TARGET_ARCH binaries.
2633 # TARGET/TARGET_ARCH are still passed along from user.
2635 # Use the toolchain we create as an external toolchain.
2636 .if ${USING_SYSTEM_COMPILER} == "yes" || ${XCC:N${CCACHE_BIN}:M/*}
2637 NXBMAKE+= XCC="${XCC}" \
2641 NXBMAKE+= XCC="${NXBOBJTOP}/tmp/usr/bin/cc" \
2642 XCXX="${NXBOBJTOP}/tmp/usr/bin/c++" \
2643 XCPP="${NXBOBJTOP}/tmp/usr/bin/cpp"
2645 NXBMAKE+= ${NXBMAKEENV} ${MAKE} -f Makefile.inc1 ${NXBMAKEARGS} \
2646 MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} \
2647 TARGET=${NXB_TARGET} TARGET_ARCH=${NXB_TARGET_ARCH} \
2648 TARGET_TRIPLE=${MACHINE_TRIPLE:Q}
2649 # NXBDIRS is improperly based on MACHINE rather than NXB_TARGET. Need to
2650 # invoke a sub-make to reevaluate MK_CLANG, etc, for NXBDIRS.
2651 NXBMAKE+= SUBDIR_OVERRIDE='$${NXBDIRS:M*}'
2652 # Need to avoid the -isystem logic when using clang as an external toolchain
2653 # even if the TARGET being built for wants GCC.
2654 NXBMAKE+= WANT_COMPILER_TYPE='$${X_COMPILER_TYPE}'
2655 native-xtools: .PHONY
2656 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _cleanobj
2657 # Build the bootstrap/host/cross tools that produce native binaries
2658 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} kernel-toolchain
2659 # Populate includes/libraries sysroot that produce native binaries.
2660 # This is split out from 'toolchain' above mostly so that target LLVM
2661 # libraries have a proper LLVM_DEFAULT_TARGET_TRIPLE without
2662 # polluting the cross-compiler build. The LLVM/GCC libs are skipped
2663 # here to avoid the problem but are kept in 'toolchain' so that
2664 # needed build tools are built.
2665 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes MK_CLANG=no
2666 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries MK_CLANG=no
2667 .if !defined(NO_OBJWALK)
2668 ${_+_}cd ${.CURDIR}; ${NXBMAKE} _obj
2670 ${_+_}cd ${.CURDIR}; ${NXBMAKE} everything
2671 @echo ">> native-xtools done. Use 'make native-xtools-install' to install to a given DESTDIR"
2673 native-xtools-install: .PHONY
2674 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
2675 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2676 -p ${NXBDESTDIR}/usr >/dev/null
2677 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2678 -p ${NXBDESTDIR}/usr/include >/dev/null
2679 ${_+_}cd ${.CURDIR}; ${NXBMAKE} \
2680 DESTDIR=${NXBDESTDIR} \
2685 # hierarchy - ensure that all the needed directories are present
2687 hierarchy hier: .MAKE .PHONY
2688 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
2691 # libraries - build all libraries, and install them under ${DESTDIR}.
2693 # The list of libraries with dependents (${_prebuild_libs}) and their
2694 # interdependencies (__L) are built automatically by the
2695 # ${.CURDIR}/tools/make_libdeps.sh script.
2697 libraries: .MAKE .PHONY
2698 ${_+_}cd ${.CURDIR}; \
2699 ${MAKE} -f Makefile.inc1 _prereq_libs; \
2700 ${MAKE} -f Makefile.inc1 _startup_libs; \
2701 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
2702 ${MAKE} -f Makefile.inc1 _generic_libs
2705 # static libgcc.a prerequisite for shared libc
2707 _prereq_libs= lib/libcompiler_rt
2708 .if ${MK_SSP} != "no"
2709 _prereq_libs+= lib/libssp_nonshared
2712 # These dependencies are not automatically generated:
2714 # lib/csu and lib/libc must be built before
2715 # all shared libraries for ELF.
2717 _startup_libs= lib/csu
2718 _startup_libs+= lib/libc
2719 _startup_libs+= lib/libc_nonshared
2720 .if ${MK_LIBCPLUSPLUS} != "no"
2721 _startup_libs+= lib/libcxxrt
2724 _prereq_libs+= lib/libgcc_eh lib/libgcc_s
2725 _startup_libs+= lib/libgcc_eh lib/libgcc_s
2727 lib/libgcc_s__L: lib/libc__L
2728 lib/libgcc_s__L: lib/libc_nonshared__L
2729 .if ${MK_LIBCPLUSPLUS} != "no"
2730 lib/libcxxrt__L: lib/libgcc_s__L
2733 _prebuild_libs= ${_kerberos5_lib_libasn1} \
2734 ${_kerberos5_lib_libhdb} \
2735 ${_kerberos5_lib_libheimbase} \
2736 ${_kerberos5_lib_libheimntlm} \
2738 ${_kerberos5_lib_libheimipcc} \
2739 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
2740 ${_kerberos5_lib_libroken} \
2741 ${_kerberos5_lib_libwind} \
2742 lib/libbz2 ${_libcom_err} lib/libcrypt \
2743 lib/libelf lib/libexpat \
2746 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
2749 lib/ncurses/ncurses lib/ncurses/ncursesw \
2750 lib/libopie lib/libpam/libpam ${_lib_libthr} \
2751 ${_lib_libradius} lib/libsbuf lib/libtacplus \
2753 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
2754 ${_cddl_lib_libuutil} \
2755 ${_cddl_lib_libavl} \
2756 ${_cddl_lib_libzfs_core} ${_cddl_lib_libzfs} \
2757 ${_cddl_lib_libctf} \
2759 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
2760 ${_secure_lib_libcrypto} ${_secure_lib_libssl} \
2761 ${_lib_libldns} ${_secure_lib_libssh}
2763 .if ${MK_DIALOG} != "no"
2764 _prebuild_libs+= gnu/lib/libdialog
2765 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2768 .if ${MK_LIBCPLUSPLUS} != "no"
2769 _prebuild_libs+= lib/libc++
2772 lib/libgeom__L: lib/libexpat__L
2773 lib/libkvm__L: lib/libelf__L
2775 .if ${MK_LIBTHR} != "no"
2776 _lib_libthr= lib/libthr
2779 .if ${MK_RADIUS_SUPPORT} != "no"
2780 _lib_libradius= lib/libradius
2783 .if ${MK_OFED} != "no"
2785 lib/ofed/libibverbs \
2787 lib/ofed/libibumad \
2791 lib/ofed/libibmad__L: lib/ofed/libibumad__L
2792 lib/ofed/complib__L: lib/libthr__L
2793 lib/ofed/libmlx5__L: lib/ofed/libibverbs__L lib/libthr__L
2796 .if ${MK_CASPER} != "no"
2797 _lib_casper= lib/libcasper
2800 lib/libpjdlog__L: lib/libutil__L
2801 lib/libcasper__L: lib/libnv__L
2802 lib/liblzma__L: lib/libthr__L
2803 lib/libzstd__L: lib/libthr__L
2805 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib}
2806 .if ${MK_IPFILTER} != "no"
2807 _generic_libs+= sbin/ipf/libipf
2809 .for _DIR in ${LOCAL_LIB_DIRS}
2810 .if ${_DIR} == ".WAIT" || (empty(_generic_libs:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
2811 _generic_libs+= ${_DIR}
2815 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2817 .if ${MK_CDDL} != "no"
2818 _cddl_lib_libumem= cddl/lib/libumem
2819 _cddl_lib_libnvpair= cddl/lib/libnvpair
2820 _cddl_lib_libavl= cddl/lib/libavl
2821 _cddl_lib_libuutil= cddl/lib/libuutil
2822 .if ${MK_ZFS} != "no"
2823 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2824 _cddl_lib_libzfs= cddl/lib/libzfs
2826 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2828 cddl/lib/libzfs__L: cddl/lib/libzfs_core__L lib/msun__L lib/libutil__L
2829 cddl/lib/libzfs__L: lib/libthr__L lib/libmd__L lib/libz__L cddl/lib/libumem__L
2830 cddl/lib/libzfs__L: cddl/lib/libuutil__L cddl/lib/libavl__L lib/libgeom__L
2832 lib/libbe__L: cddl/lib/libzfs__L
2834 _cddl_lib_libctf= cddl/lib/libctf
2836 cddl/lib/libctf__L: lib/libz__L
2838 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db
2839 _prebuild_libs+= lib/libprocstat lib/libproc lib/librtld_db
2840 lib/libprocstat__L: lib/libelf__L lib/libkvm__L lib/libutil__L
2841 lib/libproc__L: lib/libprocstat__L
2842 lib/librtld_db__L: lib/libprocstat__L
2844 .if ${MK_CRYPT} != "no"
2845 .if ${MK_OPENSSL} != "no"
2846 _secure_lib_libcrypto= secure/lib/libcrypto
2847 _secure_lib_libssl= secure/lib/libssl
2848 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2849 secure/lib/libcrypto__L: lib/libthr__L
2850 .if ${MK_LDNS} != "no"
2851 _lib_libldns= lib/libldns
2852 lib/libldns__L: secure/lib/libssl__L
2854 .if ${MK_OPENSSH} != "no"
2855 _secure_lib_libssh= secure/lib/libssh
2856 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2857 .if ${MK_LDNS} != "no"
2858 secure/lib/libssh__L: lib/libldns__L
2860 .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no"
2861 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2862 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2863 lib/libmd__L kerberos5/lib/libroken__L
2867 _secure_lib= secure/lib
2870 .if ${MK_KERBEROS} != "no"
2871 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2872 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2873 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2874 kerberos5/lib/libwind__L lib/libsqlite3__L
2875 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2876 kerberos5/lib/libroken__L lib/libcom_err__L
2877 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2878 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2879 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2880 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2881 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2882 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2883 kerberos5/lib/libroken__L: lib/libcrypt__L
2884 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2885 kerberos5/lib/libheimbase__L: lib/libthr__L
2886 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2889 lib/libsqlite3__L: lib/libthr__L
2891 .if ${MK_GSSAPI} != "no"
2892 _lib_libgssapi= lib/libgssapi
2895 .if ${MK_KERBEROS} != "no"
2896 _kerberos5_lib= kerberos5/lib
2897 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2898 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2899 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2900 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2901 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2902 _kerberos5_lib_libroken= kerberos5/lib/libroken
2903 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2904 _libsqlite3= lib/libsqlite3
2905 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2906 _kerberos5_lib_libwind= kerberos5/lib/libwind
2907 _libcom_err= lib/libcom_err
2910 .if ${MK_NIS} != "no"
2911 _lib_libypclnt= lib/libypclnt
2914 .if ${MK_OPENSSL} == "no"
2915 lib/libradius__L: lib/libmd__L
2919 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2920 .if ${MK_CXX} != "no" && ${MK_LIBCPLUSPLUS} != "no"
2921 lib/libproc__L: lib/libcxxrt__L
2924 .for _lib in ${_prereq_libs}
2925 ${_lib}__PL: .PHONY .MAKE
2926 .if !defined(_MKSHOWCONFIG) && exists(${.CURDIR}/${_lib})
2927 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2928 cd ${.CURDIR}/${_lib}; \
2929 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
2930 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2931 DIRPRFX=${_lib}/ all; \
2932 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2933 DIRPRFX=${_lib}/ install
2937 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
2938 ${_lib}__L: .PHONY .MAKE
2939 .if !defined(_MKSHOWCONFIG) && exists(${.CURDIR}/${_lib})
2940 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2941 cd ${.CURDIR}/${_lib}; \
2942 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
2943 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2944 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2948 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2949 _startup_libs: ${_startup_libs:S/$/__L/}
2950 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2951 _generic_libs: ${_generic_libs:S/$/__L/}
2953 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2954 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2955 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2956 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2957 # parallel. This is safe for the world stage of buildworld though since it has
2958 # already built libraries in a proper order and installed includes into
2959 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2960 # avoid trashing a system if it crashes mid-install.
2961 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2965 .include <bsd.subdir.mk>
2967 .if make(check-old) || make(check-old-dirs) || \
2968 make(check-old-files) || make(check-old-libs) || \
2969 make(delete-old) || make(delete-old-dirs) || \
2970 make(delete-old-files) || make(delete-old-libs)
2973 # check for / delete old files section
2976 .include "ObsoleteFiles.inc"
2978 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2979 else you can not start such an application. Consult UPDATING for more \
2980 information regarding how to cope with the removal/revision bump of a \
2983 .if !defined(BATCH_DELETE_OLD_FILES)
2989 delete-old-files: .PHONY
2990 @echo ">>> Removing old files (only deletes safe to delete libs)"
2991 # Ask for every old file if the user really wants to remove it.
2992 # It's annoying, but better safe than sorry.
2993 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2994 # argument list will get too long. Using .for/.endfor make "loops" will make
2995 # the Makefile parser segfault.
2998 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2999 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | sort | \
3000 while read file; do \
3001 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3002 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
3003 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
3005 for ext in debug symbols; do \
3006 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
3007 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3008 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
3013 # Remove catpages without corresponding manpages.
3015 find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | sort | \
3016 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
3017 while read catpage; do \
3019 if [ ! -e "$${manpage}" ]; then \
3020 rm ${RM_I} $${catpage} <&3; \
3023 @echo ">>> Old files removed"
3025 check-old-files: .PHONY
3026 @echo ">>> Checking for old files"
3028 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3029 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
3030 while read file; do \
3031 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3032 echo "${DESTDIR}/$${file}"; \
3034 for ext in debug symbols; do \
3035 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3036 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
3040 # Check for catpages without corresponding manpages.
3041 @find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \
3042 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
3043 while read catpage; do \
3045 if [ ! -e "$${manpage}" ]; then \
3050 delete-old-libs: .PHONY
3051 @echo ">>> Removing old libraries"
3052 @echo "${OLD_LIBS_MESSAGE}" | fmt
3055 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3056 -V OLD_LIBS | xargs -n1 | sort | \
3057 while read file; do \
3058 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3059 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
3060 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
3062 for ext in debug symbols; do \
3063 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
3064 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3065 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
3070 @echo ">>> Old libraries removed"
3072 check-old-libs: .PHONY
3073 @echo ">>> Checking for old libraries"
3075 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3076 -V OLD_LIBS | xargs -n1 | \
3077 while read file; do \
3078 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3079 echo "${DESTDIR}/$${file}"; \
3081 for ext in debug symbols; do \
3082 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3083 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
3088 delete-old-dirs: .PHONY
3089 @echo ">>> Removing old directories"
3091 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3092 -V OLD_DIRS | xargs -n1 | sort -r | \
3093 while read dir; do \
3094 if [ -d "${DESTDIR}/$${dir}" ]; then \
3095 rmdir -v "${DESTDIR}/$${dir}" || true; \
3096 elif [ -L "${DESTDIR}/$${dir}" ]; then \
3097 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
3099 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3100 rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \
3101 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3102 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
3105 @echo ">>> Old directories removed"
3107 check-old-dirs: .PHONY
3108 @echo ">>> Checking for old directories"
3110 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3111 -V OLD_DIRS | xargs -n1 | sort -r | \
3112 while read dir; do \
3113 if [ -d "${DESTDIR}/$${dir}" ]; then \
3114 echo "${DESTDIR}/$${dir}"; \
3115 elif [ -L "${DESTDIR}/$${dir}" ]; then \
3116 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
3118 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3119 echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \
3120 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3121 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
3125 delete-old: delete-old-files delete-old-dirs .PHONY
3126 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
3128 check-old: check-old-files check-old-libs check-old-dirs .PHONY
3129 @echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
3130 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
3135 # showconfig - show build configuration.
3138 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes; \
3139 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes) 2>&1 | grep ^MK_ | sort -u
3141 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
3142 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
3144 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
3145 .if !defined(_MKSHOWCONFIG) && exists(${KERNCONFDIR}/${KERNCONF})
3146 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
3147 '${KERNCONFDIR}/${KERNCONF}' ; echo
3153 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
3154 DTBOUTPUTPATH= ${.CURDIR}
3158 # Build 'standalone' Device Tree Blob
3161 @PATH=${TMPPATH} MACHINE=${TARGET} \
3162 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
3163 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
3168 # In the following, the first 'rm' in a series will usually remove all
3169 # files and directories. If it does not, then there are probably some
3170 # files with file flags set, so this unsets them and tries the 'rm' a
3171 # second time. There are situations where this target will be cleaning
3172 # some directories via more than one method, but that duplication is
3173 # needed to correctly handle all the possible situations. Removing all
3174 # files without file flags set in the first 'rm' instance saves time,
3175 # because 'chflags' will need to operate on fewer files afterwards.
3177 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
3178 # created by bsd.obj.mk, except that we don't want to .include that file
3179 # in this makefile. We don't do a cleandir walk if MK_AUTO_OBJ is yes
3180 # since it is not possible for files to land in the wrong place.
3182 .if make(cleanworld)
3183 BW_CANONICALOBJDIR:=${OBJTOP}/
3184 .elif make(cleanuniverse)
3185 BW_CANONICALOBJDIR:=${OBJROOT}
3186 .if ${MK_UNIFIED_OBJDIR} == "no"
3187 .error ${.TARGETS} only supported with WITH_UNIFIED_OBJDIR enabled.
3190 cleanworld cleanuniverse: .PHONY
3191 .if !empty(BW_CANONICALOBJDIR) && exists(${BW_CANONICALOBJDIR}) && \
3192 ${.CURDIR:tA} != ${BW_CANONICALOBJDIR:tA}
3193 -rm -rf ${BW_CANONICALOBJDIR}*
3194 -chflags -R 0 ${BW_CANONICALOBJDIR}
3195 rm -rf ${BW_CANONICALOBJDIR}*
3197 .if make(cleanworld) && ${MK_AUTO_OBJ} == "no" && \
3198 (empty(BW_CANONICALOBJDIR) || ${.CURDIR:tA} == ${BW_CANONICALOBJDIR:tA})
3199 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
3200 # To be safe in this case, fall back to a 'make cleandir'
3201 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
3205 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
3206 XDEV_CPUTYPE?=${CPUTYPE}
3208 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
3211 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
3212 MK_MAN=no MK_NLS=no MK_PROFILE=no \
3213 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
3214 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
3215 CPUTYPE=${XDEV_CPUTYPE}
3217 XDDIR=${TARGET_ARCH}-freebsd
3220 .error XDTP variable should be an absolute path
3223 CDBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/xdev/
3224 CDBOBJTOP= ${CDBOBJROOT}${XDDIR}
3226 INSTALL="sh ${.CURDIR}/tools/install.sh"
3228 TOOLS_PREFIX=${XDTP}
3230 OBJTOP=${CDBOBJTOP:Q} \
3231 OBJROOT=${CDBOBJROOT:Q}
3232 CD2MAKEARGS= ${CDMAKEARGS}
3234 .if ${WANT_COMPILER_TYPE} == gcc || \
3235 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
3236 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
3237 # won't set header path and -L is used to ensure the base library path
3238 # is added before the port PREFIX library path.
3239 CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib
3240 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
3241 # combined with --sysroot.
3242 CD2CFLAGS+= -B${XDDESTDIR}/usr/lib
3243 # Force using libc++ for external GCC.
3244 .if defined(X_COMPILER_TYPE) && \
3245 ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
3246 CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \
3250 CD2CFLAGS+= --sysroot=${XDDESTDIR}/
3251 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \
3252 CPP="${CPP} ${CD2CFLAGS}" \
3253 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
3255 CDTMP= ${OBJTOP}/${XDDIR}/tmp
3256 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${CDMAKEARGS} ${NOFUN}
3257 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} \
3258 ${MAKE} ${CD2MAKEARGS} ${NOFUN}
3259 .if ${MK_META_MODE} != "no"
3260 # Don't rebuild build-tools targets during normal build.
3261 CD2MAKE+= BUILD_TOOLS_META=.NOMETA
3263 XDDESTDIR=${DESTDIR}${XDTP}
3265 .ORDER: xdev-build xdev-install xdev-links
3266 xdev: xdev-build xdev-install .PHONY
3268 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
3269 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
3271 _xb-worldtmp: .PHONY
3272 mkdir -p ${CDTMP}/usr
3273 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
3274 -p ${CDTMP}/usr >/dev/null
3276 _xb-bootstrap-tools: .PHONY
3280 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
3281 cd ${.CURDIR}/${_tool}; \
3282 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
3283 ${CDMAKE} DIRPRFX=${_tool}/ all; \
3284 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
3287 _xb-build-tools: .PHONY
3288 ${_+_}@cd ${.CURDIR}; \
3289 ${CDBENV} ${MAKE} ${CDMAKEARGS} -f Makefile.inc1 ${NOFUN} build-tools
3299 _xb-cross-tools: .PHONY
3300 .for _tool in ${XDEVDIRS}
3301 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
3302 cd ${.CURDIR}/${_tool}; \
3303 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
3304 ${CDMAKE} DIRPRFX=${_tool}/ all
3308 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
3309 mkdir -p ${XDDESTDIR}
3310 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.root.dist \
3311 -p ${XDDESTDIR} >/dev/null
3312 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
3313 -p ${XDDESTDIR}/usr >/dev/null
3314 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
3315 -p ${XDDESTDIR}/usr/include >/dev/null
3316 .if defined(_LIBCOMPAT)
3317 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
3318 -p ${XDDESTDIR}/usr >/dev/null
3320 .if ${MK_TESTS} != "no"
3321 mkdir -p ${XDDESTDIR}${TESTSBASE}
3322 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
3323 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
3326 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
3327 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
3329 _xi-cross-tools: .PHONY
3330 @echo "_xi-cross-tools"
3331 .for _tool in ${XDEVDIRS}
3332 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
3333 cd ${.CURDIR}/${_tool}; \
3334 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
3337 _xi-includes: .PHONY
3338 .if !defined(NO_OBJWALK)
3339 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 _obj \
3340 DESTDIR=${XDDESTDIR}
3342 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
3343 DESTDIR=${XDDESTDIR}
3345 _xi-libraries: .PHONY
3346 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
3347 DESTDIR=${XDDESTDIR}
3350 ${_+_}cd ${XDDESTDIR}/usr/bin; \
3351 mkdir -p ../../../../usr/bin; \
3353 ln -sf ../../${XDTP}/usr/bin/$$i \
3354 ../../../../usr/bin/${XDDIR}-$$i; \
3355 ln -sf ../../${XDTP}/usr/bin/$$i \
3356 ../../../../usr/bin/${XDDIR}${_REVISION}-$$i; \