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_ROOT install without using root privilege
15 # -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects
16 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
17 # LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list
18 # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
19 # LOCAL_MTREE="list of mtree files" to process to allow local directories
20 # to be created before files are installed
21 # LOCAL_LEGACY_DIRS="list of dirs" to add additional dirs to the legacy
23 # LOCAL_BSTOOL_DIRS="list of dirs" to add additional dirs to the
24 # bootstrap-tools target
25 # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
27 # LOCAL_XTOOL_DIRS="list of dirs" to add additional dirs to the
29 # METALOG="path to metadata log" to write permission and ownership
30 # when NO_ROOT is set. (default: ${DESTDIR}/${DISTDIR}/METALOG,
31 # check /etc/make.conf for DISTDIR)
32 # TARGET="machine" to crossbuild world for a different machine type
33 # TARGET_ARCH= may be required when a TARGET supports multiple endians
34 # BUILDENV_SHELL= shell to launch for the buildenv target (def:${SHELL})
35 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
36 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
37 # SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
38 # All libraries and includes, and some build tools will still build.
41 # The intended user-driven targets are:
42 # buildworld - rebuild *everything*, including glue to help do upgrades
43 # installworld- install everything built by "buildworld"
44 # checkworld - run test suite on installed world
45 # doxygen - build API documentation of the kernel
47 # Standard targets (not defined here) are documented in the makefiles in
48 # /usr/share/mk. These include:
49 # obj depend all install clean cleandepend cleanobj
51 .if !defined(TARGET) || !defined(TARGET_ARCH)
52 .error "Both TARGET and TARGET_ARCH must be defined."
55 .if make(showconfig) || make(test-system-*)
60 LOCALBASE?= /usr/local
62 .include "share/mk/src.tools.mk"
64 # Cross toolchain changes must be in effect before bsd.compiler.mk
65 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
66 .if defined(CROSS_TOOLCHAIN)
67 .if exists(${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk)
68 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
69 .elif exists(/usr/share/toolchains/${CROSS_TOOLCHAIN}.mk)
70 .include "/usr/share/toolchains/${CROSS_TOOLCHAIN}.mk"
71 .elif exists(${CROSS_TOOLCHAIN})
72 .include "${CROSS_TOOLCHAIN}"
74 .error CROSS_TOOLCHAIN ${CROSS_TOOLCHAIN} not found
76 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
78 .if defined(CROSS_TOOLCHAIN_PREFIX)
79 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
82 XCOMPILERS= CC CXX CPP
83 .for COMPILER in ${XCOMPILERS}
84 .if defined(CROSS_COMPILER_PREFIX)
85 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
87 X${COMPILER}?= ${${COMPILER}}
90 # If a full path to an external cross compiler is given, don't build
92 .if ${XCC:N${CCACHE_BIN}:M/*}
93 MK_CLANG_BOOTSTRAP= no
94 # Make sure sub-makes see the option as disabled so the hack in bsd.sys.mk to
95 # work around incompatible headers in Clang's resource directory is enabled.
96 .MAKEOVERRIDES+= MK_CLANG_BOOTSTRAP
99 # Pull in compiler metadata from buildworld/toolchain if possible to avoid
100 # running CC from bsd.compiler.mk.
101 .if make(installworld) || make(install) || make(distributeworld) || \
103 .-include "${OBJTOP}/toolchain-metadata.mk"
104 .if !defined(_LOADED_TOOLCHAIN_METADATA)
105 .error A build is required first. You may have the wrong MAKEOBJDIRPREFIX set.
109 # Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early. Pull it from the
110 # tree to be friendlier to foreign OS builds. It's safe to do so unconditionally
111 # here since we will always have the right make, unlike in src/Makefile
112 # Don't include bsd.linker.mk yet until XBINUTILS is handled (after src.opts.mk)
113 _NO_INCLUDE_LINKERMK= t
114 # We also want the X_COMPILER* variables if we are using an external toolchain.
115 _WANT_TOOLCHAIN_CROSS_VARS= t
116 .include "share/mk/bsd.compiler.mk"
117 .undef _NO_INCLUDE_LINKERMK
118 .undef _WANT_TOOLCHAIN_CROSS_VARS
119 # src.opts.mk depends on COMPILER_FEATURES
120 .include "share/mk/src.opts.mk"
122 .if ${TARGET} == ${MACHINE}
123 TARGET_CPUTYPE?=${CPUTYPE}
127 .if !empty(TARGET_CPUTYPE)
128 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
130 _TARGET_CPUTYPE=dummy
132 .if ${TARGET} == "arm"
133 .if ${TARGET_ARCH:Marmv[67]*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
134 TARGET_ABI= gnueabihf
139 MACHINE_ABI?= unknown
140 MACHINE_TRIPLE?=${MACHINE_ARCH:S/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${MACHINE_ABI}-freebsd13.0
142 TARGET_TRIPLE?= ${TARGET_ARCH:S/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${TARGET_ABI}-freebsd13.0
143 KNOWN_ARCHES?= aarch64/arm64 \
160 powerpc64le/powerpc \
165 .if ${TARGET} == ${TARGET_ARCH}
168 _t= ${TARGET_ARCH}/${TARGET}
171 .if empty(KNOWN_ARCHES:M${_t})
172 .error Unknown target ${TARGET_ARCH}:${TARGET}.
176 .if ${.MAKE.OS} != "FreeBSD"
177 CROSSBUILD_HOST=${.MAKE.OS}
178 .if ${.MAKE.OS} != "Linux" && ${.MAKE.OS} != "Darwin"
179 .warning "Unsupported crossbuild system: ${.MAKE.OS}. Build will probably fail!"
181 # We need to force NO_ROOT/DB_FROM_SRC builds when building on other operating
182 # systems since the BSD.foo.dist specs contain users and groups that do not
183 # exist by default on a Linux/MacOS system.
189 # If all targets are disabled for system llvm then don't expect it to work
191 .if !defined(TOOLS_PREFIX) && ${MK_LLVM_TARGET_ALL} == "no" && \
192 ${MACHINE} != ${TARGET} && ${MACHINE_ARCH} != ${TARGET_ARCH} && \
194 MK_SYSTEM_COMPILER= no
198 # Handle external binutils.
199 .if defined(CROSS_TOOLCHAIN_PREFIX)
200 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
202 XBINUTILS= AS AR LD NM OBJCOPY RANLIB SIZE STRINGS STRIPBIN
203 .for BINUTIL in ${XBINUTILS}
204 .if defined(CROSS_BINUTILS_PREFIX) && \
205 exists(${CROSS_BINUTILS_PREFIX}/${${BINUTIL}})
206 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX:C,/*$,,}/${${BINUTIL}}
208 X${BINUTIL}?= ${${BINUTIL}}
212 # If a full path to an external linker is given, don't build lld.
217 # We also want the X_LINKER* variables if we are using an external toolchain.
218 _WANT_TOOLCHAIN_CROSS_VARS= t
219 .include "share/mk/bsd.linker.mk"
220 .undef _WANT_TOOLCHAIN_CROSS_VARS
222 # Begin WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD
224 # WITH_SYSTEM_COMPILER - Pull in needed values and make a decision.
226 # Check if there is a local compiler that can satisfy as an external compiler.
227 # Which compiler is expected to be used?
228 .if ${MK_CLANG_BOOTSTRAP} == "yes"
229 WANT_COMPILER_TYPE= clang
234 .if !defined(WANT_COMPILER_FREEBSD_VERSION) && !make(showconfig) && \
235 !make(test-system-linker)
236 .if ${WANT_COMPILER_TYPE} == "clang"
237 WANT_COMPILER_FREEBSD_VERSION_FILE= lib/clang/freebsd_cc_version.h
238 WANT_COMPILER_FREEBSD_VERSION!= \
239 awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
240 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
241 WANT_COMPILER_VERSION_FILE= lib/clang/include/clang/Basic/Version.inc
242 WANT_COMPILER_VERSION!= \
243 awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
244 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
246 .export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION
247 .endif # !defined(WANT_COMPILER_FREEBSD_VERSION)
249 # It needs to be the same revision as we would build for the bootstrap.
250 # If the expected vs CC is different then we can't skip.
251 # GCC cannot be used for cross-arch yet. For clang we pass -target later if
252 # TARGET_ARCH!=MACHINE_ARCH.
253 .if ${MK_SYSTEM_COMPILER} == "yes" && \
254 defined(WANT_COMPILER_FREEBSD_VERSION) && \
255 ${MK_CLANG_BOOTSTRAP} == "yes" && \
257 ${X_COMPILER_TYPE} == ${WANT_COMPILER_TYPE} && \
258 (${X_COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \
259 ${X_COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \
260 ${X_COMPILER_FREEBSD_VERSION} == ${WANT_COMPILER_FREEBSD_VERSION}
261 # Everything matches, disable the bootstrap compiler.
262 MK_CLANG_BOOTSTRAP= no
263 USING_SYSTEM_COMPILER= yes
264 .endif # ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE}
266 # WITH_SYSTEM_LD - Pull in needed values and make a decision.
268 # Check if there is a local linker that can satisfy as an external linker.
269 # Which linker is expected to be used?
270 .if ${MK_LLD_BOOTSTRAP} == "yes"
271 WANT_LINKER_TYPE= lld
276 .if !defined(WANT_LINKER_FREEBSD_VERSION) && !make(showconfig) && \
277 !make(test-system-compiler)
278 .if ${WANT_LINKER_TYPE} == "lld"
279 WANT_LINKER_FREEBSD_VERSION_FILE= lib/clang/include/VCSVersion.inc
280 _WANT_LINKER_FREEBSD_VERSION!= \
281 awk '$$2 == "LLD_REVISION" {gsub(/"/, "", $$3); print $$3}' \
282 ${SRCDIR}/${WANT_LINKER_FREEBSD_VERSION_FILE} || echo unknown
283 WANT_LINKER_FREEBSD_VERSION=${_WANT_LINKER_FREEBSD_VERSION:C/.*-(.*)/\1/}
284 WANT_LINKER_VERSION_FILE= lib/clang/include/lld/Common/Version.inc
285 WANT_LINKER_VERSION!= \
286 awk '$$2 == "LLD_VERSION_STRING" { gsub("\"", "", $$3); split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
287 ${SRCDIR}/${WANT_LINKER_VERSION_FILE} || echo unknown
289 WANT_LINKER_FREEBSD_VERSION_FILE=
290 WANT_LINKER_FREEBSD_VERSION=
292 .export WANT_LINKER_FREEBSD_VERSION WANT_LINKER_VERSION
293 .endif # !defined(WANT_LINKER_FREEBSD_VERSION)
295 .if ${MK_SYSTEM_LINKER} == "yes" && \
296 defined(WANT_LINKER_FREEBSD_VERSION) && \
297 (${MK_LLD_BOOTSTRAP} == "yes") && \
299 ${X_LINKER_TYPE} == ${WANT_LINKER_TYPE} && \
300 ${X_LINKER_VERSION} == ${WANT_LINKER_VERSION} && \
301 ${X_LINKER_FREEBSD_VERSION} == ${WANT_LINKER_FREEBSD_VERSION}
302 # Everything matches, disable the bootstrap linker.
304 USING_SYSTEM_LINKER= yes
305 .endif # ${WANT_LINKER_TYPE} == ${LINKER_TYPE}
307 # WITH_SYSTEM_COMPILER / WITH_SYSTEM_LINKER - Handle defaults and debug.
308 USING_SYSTEM_COMPILER?= no
309 USING_SYSTEM_LINKER?= no
311 TEST_SYSTEM_COMPILER_VARS= \
312 USING_SYSTEM_COMPILER MK_SYSTEM_COMPILER \
313 MK_CROSS_COMPILER MK_CLANG_BOOTSTRAP \
314 WANT_COMPILER_TYPE WANT_COMPILER_VERSION WANT_COMPILER_VERSION_FILE \
315 WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \
316 CC COMPILER_TYPE COMPILER_FEATURES COMPILER_VERSION \
317 COMPILER_FREEBSD_VERSION \
318 XCC X_COMPILER_TYPE X_COMPILER_FEATURES X_COMPILER_VERSION \
319 X_COMPILER_FREEBSD_VERSION
320 TEST_SYSTEM_LINKER_VARS= \
321 USING_SYSTEM_LINKER MK_SYSTEM_LINKER \
323 WANT_LINKER_TYPE WANT_LINKER_VERSION WANT_LINKER_VERSION_FILE \
324 WANT_LINKER_FREEBSD_VERSION WANT_LINKER_FREEBSD_VERSION_FILE \
325 LD LINKER_TYPE LINKER_FEATURES LINKER_VERSION \
326 LINKER_FREEBSD_VERSION \
327 XLD X_LINKER_TYPE X_LINKER_FEATURES X_LINKER_VERSION \
328 X_LINKER_FREEBSD_VERSION
330 .for _t in compiler linker
331 test-system-${_t}: .PHONY
332 .for v in ${TEST_SYSTEM_${_t:tu}_VARS}
333 ${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}"
336 .if (make(buildworld) || make(buildkernel) || make(kernel-toolchain) || \
337 make(toolchain) || make(_cross-tools))
338 .if ${USING_SYSTEM_COMPILER} == "yes"
339 .info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler.
340 .elif ${MK_CLANG_BOOTSTRAP} == "yes"
341 .info SYSTEM_COMPILER: libclang will be built for bootstrapping a cross-compiler.
343 .if ${USING_SYSTEM_LINKER} == "yes"
344 .info SYSTEM_LINKER: Determined that LD=${LD} matches the source tree. Not bootstrapping a cross-linker.
345 .elif ${MK_LLD_BOOTSTRAP} == "yes"
346 .info SYSTEM_LINKER: libclang will be built for bootstrapping a cross-linker.
350 # End WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD
352 # Store some compiler metadata for use in installworld where we don't
353 # want to invoke CC at all.
354 _TOOLCHAIN_METADATA_VARS= COMPILER_VERSION \
357 COMPILER_FREEBSD_VERSION \
358 COMPILER_RESOURCE_DIR \
362 LINKER_FREEBSD_VERSION
363 toolchain-metadata.mk: .PHONY .META
365 @echo ".info Using cached toolchain metadata from build at $$(hostname) on $$(date)" \
367 @echo "_LOADED_TOOLCHAIN_METADATA=t" >> ${.TARGET}
368 .for v in ${_TOOLCHAIN_METADATA_VARS}
369 @echo "${v}=${${v}}" >> ${.TARGET}
370 @echo "X_${v}=${X_${v}}" >> ${.TARGET}
372 @echo ".export ${_TOOLCHAIN_METADATA_VARS}" >> ${.TARGET}
373 @echo ".export ${_TOOLCHAIN_METADATA_VARS:C,^,X_,}" >> ${.TARGET}
376 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
377 # keep the users system reasonably usable. For static->dynamic root upgrades,
378 # we don't want to install a dynamic binary without rtld and the needed
379 # libraries. More commonly, for dynamic root, we don't want to install a
380 # binary that requires a newer library version that hasn't been installed yet.
381 # This ordering is not a guarantee though. The only guarantee of a working
382 # system here would require fine-grained ordering of all components based
383 # on their dependencies.
384 .if !empty(SUBDIR_OVERRIDE)
385 SUBDIR= ${SUBDIR_OVERRIDE}
388 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
389 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
390 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
391 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
392 _REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
394 .for _DIR in ${LOCAL_LIB_DIRS}
395 .if ${_DIR} == ".WAIT" || (empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
399 .if !defined(NO_ROOT) && (make(installworld) || make(install))
400 # Ensure libraries are installed before progressing.
404 .if ${MK_CDDL} != "no"
408 .if ${MK_KERBEROS} != "no"
411 .if ${MK_RESCUE} != "no"
415 .if ${MK_CRYPT} != "no"
418 .if !defined(NO_SHARE)
421 .if ${MK_BOOT} != "no"
424 SUBDIR+=sys usr.bin usr.sbin
425 .if ${MK_TESTS} != "no"
429 # Local directories are built in parallel with the base system directories.
430 # Users may insert a .WAIT directive at the beginning or elsewhere within
431 # the LOCAL_DIRS and LOCAL_LIB_DIRS lists as needed.
432 .for _DIR in ${LOCAL_DIRS}
433 .if ${_DIR} == ".WAIT" || exists(${.CURDIR}/${_DIR}/Makefile)
438 # We must do etc/ last as it hooks into building the man whatis file
439 # by calling 'makedb' in share/man. This is only relevant for
440 # install/distribute so they build the whatis file after every manpage is
442 .if make(installworld) || make(install)
447 .endif # !empty(SUBDIR_OVERRIDE)
450 .warning The src.conf WITHOUT_CLEAN option can now be used instead of NOCLEAN.
453 .if defined(NO_CLEAN)
454 .info The src.conf WITHOUT_CLEAN option can now be used instead of NO_CLEAN.
457 .if defined(NO_CLEANDIR)
458 CLEANDIR= clean cleandepend
463 .if defined(WORLDFAST)
468 .if ${MK_META_MODE} == "yes"
469 # If filemon is used then we can rely on the build being incremental-safe.
470 # The .meta files will also track the build command and rebuild should
472 .if empty(.MAKE.MODE:Mnofilemon)
476 .if defined(NO_OBJWALK) || ${MK_AUTO_OBJ} == "yes"
480 .if !defined(NO_OBJWALK)
485 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
487 .if empty(SHELL:M*csh*)
488 BUILDENV_SHELL?=${SHELL}
490 BUILDENV_SHELL?=/bin/sh
493 .if !defined(_MKSHOWCONFIG)
494 .if !defined(VCS_REVISION) || empty(VCS_REVISION)
495 .if !defined(SVNVERSION_CMD) || empty(SVNVERSION_CMD)
496 . for _D in ${PATH:S,:, ,g}
497 . if exists(${_D}/svnversion)
498 SVNVERSION_CMD?=${_D}/svnversion
500 . if exists(${_D}/svnliteversion)
501 SVNVERSION_CMD?=${_D}/svnliteversion
505 _VCS_REVISION?= $$(eval ${SVNVERSION_CMD} ${SRCDIR})
506 . if !empty(_VCS_REVISION)
507 VCS_REVISION= $$(echo r${_VCS_REVISION})
512 .if !defined(GIT_CMD) || empty(GIT_CMD)
513 . for _P in /usr/bin /usr/local/bin
514 . if exists(${_P}/git)
521 .if !defined(OSRELDATE)
522 .if exists(/usr/include/osreldate.h)
523 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
524 /usr/include/osreldate.h
531 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
532 .for _V in BRANCH REVISION
534 _${_V}!= eval $$(awk '/^${_V}=/{print}' ${SRCTOP}/sys/conf/newvers.sh); echo $$${_V}
538 .if !defined(SRCRELDATE)
539 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
540 ${SRCDIR}/sys/sys/param.h
543 .if !defined(VERSION)
544 VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
548 .if !defined(PKG_VERSION)
549 _STRTIMENOW= %Y%m%d%H%M%S
550 _TIMENOW= ${_STRTIMENOW:gmtime}
551 .if ${_BRANCH:MCURRENT*} || ${_BRANCH:MSTABLE*} || ${_BRANCH:MPRERELEASE*}
552 _REVISION:= ${_REVISION:R}
553 EXTRA_REVISION= .snap${_TIMENOW}
554 .elif ${_BRANCH:MALPHA*}
555 EXTRA_REVISION= .a${_BRANCH:C/ALPHA([0-9]+).*/\1/}.${_TIMENOW}
556 .elif ${_BRANCH:MBETA*}
557 EXTRA_REVISION= .b${_BRANCH:C/BETA([0-9]+).*/\1/}.${_TIMENOW}
558 .elif ${_BRANCH:MRC*}
559 EXTRA_REVISION= .rc${_BRANCH:C/RC([0-9]+).*/\1/}.${_TIMENOW}
560 .elif ${_BRANCH:M*-p*}
561 EXTRA_REVISION= p${_BRANCH:C/.*-p([0-9]+$)/\1/}
563 PKG_VERSION:= ${_REVISION}${EXTRA_REVISION:C/[[:space:]]//g}
565 .endif # !defined(PKG_VERSION)
567 .if !defined(PKG_TIMESTAMP)
569 SOURCE_DATE_EPOCH= ${TIMEEPOCHNOW:gmtime}
571 SOURCE_DATE_EPOCH= ${PKG_TIMESTAMP}
574 PKG_NAME_PREFIX?= FreeBSD
575 PKG_MAINTAINER?= re@FreeBSD.org
576 PKG_WWW?= https://www.FreeBSD.org
577 .export PKG_NAME_PREFIX
578 .export PKG_MAINTAINER
581 .if !defined(_MKSHOWCONFIG)
582 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} -f /dev/null \
583 -m ${.CURDIR}/share/mk MK_AUTO_OBJ=no -V CPUTYPE
584 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
585 .error CPUTYPE global should be set with ?=.
589 BUILD_ARCH!= uname -p
590 # On some Linux systems uname -p returns "unknown" so skip this check there.
591 # This check only exists to tell people to use TARGET_ARCH instead of
592 # MACHINE_ARCH so skipping it when crossbuilding on non-FreeBSD should be fine.
593 .if ${MACHINE_ARCH} != ${BUILD_ARCH} && ${.MAKE.OS} == "FreeBSD"
594 .error To cross-build, set TARGET_ARCH.
597 WORLDTMP?= ${OBJTOP}/tmp
598 BPATH= ${CCACHE_WRAPPER_PATH_PFX}${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin:${WORLDTMP}/legacy/usr/libexec
599 XPATH= ${WORLDTMP}/bin:${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
601 # When building we want to find the cross tools before the host tools in ${BPATH}.
602 # We also need to add UNIVERSE_TOOLCHAIN_PATH so that we can find the shared
603 # toolchain files (clang, lld, etc.) during make universe/tinderbox
604 STRICTTMPPATH= ${XPATH}:${BPATH}:${UNIVERSE_TOOLCHAIN_PATH}
605 # We should not be using tools from /usr/bin accidentally since this could cause
606 # the build to break on other systems that don't have that tool. For now we
607 # still allow using the old behaviour (inheriting $PATH) if
608 # BUILD_WITH_STRICT_TMPPATH is set to 0 but this will eventually be removed.
610 # Currently strict $PATH can cause build failures and does not work yet with
611 # USING_SYSTEM_LINKER/USING_SYSTEM_COMPILER. Once these issues have been
612 # resolved it will be turned on by default.
613 BUILD_WITH_STRICT_TMPPATH?=0
614 .if defined(CROSSBUILD_HOST)
615 # When building on non-FreeBSD we can't rely on the tools in /usr/bin being compatible
616 # with what FreeBSD expects. Therefore we only use tools from STRICTTMPPATH
617 # during the world build stage. We build most tools during the bootstrap-tools
618 # phase but symlink host tools that are known to work instead of building them
619 BUILD_WITH_STRICT_TMPPATH:=1
621 .if ${BUILD_WITH_STRICT_TMPPATH} != 0
622 TMPPATH= ${STRICTTMPPATH}
624 TMPPATH= ${STRICTTMPPATH}:${PATH}
628 # Avoid running mktemp(1) unless actually needed.
629 # It may not be functional, e.g., due to new ABI
630 # when in the middle of installing over this system.
632 .if make(distributeworld) || make(installworld) || make(stageworld)
633 .if ${BUILD_WITH_STRICT_TMPPATH} != 0
634 MKTEMP=${WORLDTMP}/legacy/usr/bin/mktemp
635 .if !exists(${MKTEMP})
636 .error "mktemp binary doesn't exist in expected location: ${MKTEMP}"
641 INSTALLTMP!= ${MKTEMP} -d -u -t install
644 .if make(stagekernel) || make(distributekernel)
650 # Building a world goes through the following stages
652 # 1. legacy stage [BMAKE]
653 # This stage is responsible for creating compatibility
654 # shims that are needed by the bootstrap-tools,
655 # build-tools and cross-tools stages. These are generally
656 # APIs that tools from one of those three stages need to
657 # build that aren't present on the host.
658 # 1. bootstrap-tools stage [BMAKE]
659 # This stage is responsible for creating programs that
660 # are needed for backward compatibility reasons. They
661 # are not built as cross-tools.
662 # 2. build-tools stage [TMAKE]
663 # This stage is responsible for creating the object
664 # tree and building any tools that are needed during
665 # the build process. Some programs are listed during
666 # this phase because they build binaries to generate
667 # files needed to build these programs. This stage also
668 # builds the 'build-tools' target rather than 'all'.
669 # 3. cross-tools stage [XMAKE]
670 # This stage is responsible for creating any tools that
671 # are needed for building the system. A cross-compiler is one
672 # of them. This differs from build tools in two ways:
673 # 1. the 'all' target is built rather than 'build-tools'
674 # 2. these tools are installed into TMPPATH for stage 4.
675 # 4. world stage [WMAKE]
676 # This stage actually builds the world.
677 # 5. install stage (optional) [IMAKE]
678 # This stage installs a previously built world.
683 MINIMUM_SUPPORTED_OSREL?= 1002501
684 MINIMUM_SUPPORTED_REL?= 10.3
686 # Common environment for world related stages
688 MACHINE_ARCH=${TARGET_ARCH} \
690 CPUTYPE=${TARGET_CPUTYPE}
691 .if ${MK_META_MODE} != "no"
692 # Don't rebuild build-tools targets during normal build.
693 CROSSENV+= BUILD_TOOLS_META=.NOMETA
695 .if defined(TARGET_CFLAGS)
696 CROSSENV+= ${TARGET_CFLAGS}
698 .if (${TARGET} != ${MACHINE} && !defined(WITH_LOCAL_MODULES)) || \
699 defined(WITHOUT_LOCAL_MODULES)
700 CROSSENV+= LOCAL_MODULES=
703 BOOTSTRAPPING_OSRELDATE?=${OSRELDATE}
705 # bootstrap-tools stage
706 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
707 TOOLS_PREFIX=${TOOLS_PREFIX_UNDEF:U${WORLDTMP}} \
708 PATH=${BPATH}:${PATH} \
709 WORLDTMP=${WORLDTMP} \
710 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
711 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
713 OBJTOP='${WORLDTMP}/obj-tools' \
714 OBJROOT='$${OBJTOP}/' \
716 BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
717 BWPHASE=${.TARGET:C,^_,,} \
737 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
739 .if empty(.MAKEOVERRIDES:MMK_LLVM_TARGET_ALL)
740 BMAKE+= MK_LLVM_TARGET_ALL=no
745 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
746 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
748 BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
749 BWPHASE=${.TARGET:C,^_,,} \
763 # TOOLS_PREFIX set in BMAKE
765 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
766 MK_CLANG_IS_CC=${MK_CLANG_BOOTSTRAP} \
771 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
772 PATH=${BPATH}:${PATH} \
773 WORLDTMP=${WORLDTMP} \
774 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
777 TOOLS_PREFIX=${TOOLS_PREFIX_UNDEF:U${WORLDTMP}} \
778 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
780 OBJTOP='${WORLDTMP}/obj-kernel-tools' \
781 OBJROOT='$${OBJTOP}/' \
783 BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
797 WMAKEENV= ${CROSSENV} \
798 INSTALL="${INSTALL_CMD} -U" \
803 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
805 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
808 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
809 CPP="${XCPP} ${XCFLAGS}" \
810 AS="${XAS}" AR="${XAR}" LD="${XLD}" LLVM_LINK="${XLLVM_LINK}" \
811 NM=${XNM} OBJCOPY="${XOBJCOPY}" \
812 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
813 SIZE="${XSIZE}" STRIPBIN="${XSTRIPBIN}"
815 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
816 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
817 # directory, but the compiler will look in the right place for its
818 # tools so we don't need to tell it where to look.
819 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
823 # The internal bootstrap compiler has a default sysroot set by TOOLS_PREFIX
824 # and target set by TARGET/TARGET_ARCH. However, there are several needs to
825 # always pass an explicit --sysroot and -target.
826 # - External compiler needs sysroot and target flags.
827 # - External ld needs sysroot.
828 # - To be clear about the use of a sysroot when using the internal compiler.
829 # - Easier debugging.
830 # - Allowing WITH_SYSTEM_COMPILER+WITH_META_MODE to work together due to
831 # the flip-flopping build command when sometimes using external and
832 # sometimes using internal.
833 # - Allow using lld which has no support for default paths.
834 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
835 BFLAGS+= -B${WORLDTMP}/usr/bin
837 .if ${WANT_COMPILER_TYPE} == gcc || \
838 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
839 .elif ${WANT_COMPILER_TYPE} == clang || \
840 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang)
841 XCFLAGS+= -target ${TARGET_TRIPLE}
843 XCFLAGS+= --sysroot=${WORLDTMP}
849 .if ${MK_LIB32} == "yes"
851 .include "Makefile.libcompat"
852 .elif ${MK_LIBSOFT} == "yes"
854 .include "Makefile.libcompat"
857 # META_MODE normally ignores host file changes since every build updates
858 # timestamps (see NO_META_IGNORE_HOST in sys.mk). There are known times
859 # when the ABI breaks though that we want to force rebuilding WORLDTMP
860 # to get updated host tools.
861 .if ${MK_META_MODE} == "yes" && ${MK_CLEAN} == "no" && \
862 !defined(NO_META_IGNORE_HOST) && !defined(NO_META_IGNORE_HOST_HEADERS) && \
863 !defined(_MKSHOWCONFIG)
864 # r318736 - ino64 major ABI breakage
865 META_MODE_BAD_ABI_VERS+= 1200031
867 .if !defined(OBJDIR_HOST_OSRELDATE)
868 .if exists(${OBJTOP}/host-osreldate.h)
869 OBJDIR_HOST_OSRELDATE!= \
870 awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
871 ${OBJTOP}/host-osreldate.h
872 .elif exists(${WORLDTMP}/usr/include/osreldate.h)
873 OBJDIR_HOST_OSRELDATE= 0
875 .export OBJDIR_HOST_OSRELDATE
878 # Note that this logic is the opposite of normal BOOTSTRAP handling. We want
879 # to compare the WORLDTMP's OSRELDATE to the host's OSRELDATE. If the WORLDTMP
880 # is older than the ABI-breakage OSRELDATE of the HOST then we rebuild.
881 .if defined(OBJDIR_HOST_OSRELDATE)
882 .for _ver in ${META_MODE_BAD_ABI_VERS}
883 .if ${OSRELDATE} >= ${_ver} && ${OBJDIR_HOST_OSRELDATE} < ${_ver}
884 _meta_mode_need_rebuild= ${_ver}
887 .if defined(_meta_mode_need_rebuild)
888 .info META_MODE: Rebuilding host tools due to ABI breakage in __FreeBSD_version ${_meta_mode_need_rebuild}.
889 NO_META_IGNORE_HOST_HEADERS= 1
890 .export NO_META_IGNORE_HOST_HEADERS
891 .endif # defined(_meta_mode_need_rebuild)
892 .endif # defined(OBJDIR_HOST_OSRELDATE)
893 .endif # ${MK_META_MODE} == "yes" && ${MK_CLEAN} == "no" ...
894 # This is only used for META_MODE+filemon to track what the oldest
895 # __FreeBSD_version is in WORLDTMP. This purposely does NOT have
896 # a make dependency on /usr/include/osreldate.h as the file should
897 # only be copied when it is missing or meta mode determines it has changed.
898 # Since host files are normally ignored without NO_META_IGNORE_HOST
899 # the file will never be updated unless that flag is specified. This
900 # allows tracking the oldest osreldate to force rebuilds via
901 # META_MODE_BADABI_REVS above.
902 host-osreldate.h: # DO NOT ADD /usr/include/osreldate.h here
903 .if !defined(CROSSBUILD_HOST)
904 @cp -f /usr/include/osreldate.h ${.TARGET}
906 @echo "#ifndef __FreeBSD_version" > ${.TARGET}
907 @echo "#define __FreeBSD_version ${OSRELDATE}" >> ${.TARGET}
908 @echo "#endif" >> ${.TARGET}
911 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
912 BWPHASE=${.TARGET:C,^_,,} \
915 IMAKEENV= ${CROSSENV}
916 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
917 ${IMAKE_INSTALL} ${IMAKE_MTREE}
918 .if empty(.MAKEFLAGS:M-n)
919 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
920 LD_LIBRARY_PATH=${INSTALLTMP} \
921 PATH_LOCALE=${INSTALLTMP}/locale
922 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
924 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
927 # When generating install media, do not allow user and group information from
928 # the build host to affect the contents of the distribution.
929 .if make(distributeworld) || make(distrib-dirs) || make(distribution) || \
934 .if defined(DB_FROM_SRC)
935 INSTALLFLAGS+= -N ${.CURDIR}/etc
936 MTREEFLAGS+= -N ${.CURDIR}/etc
938 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
939 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
941 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
942 METALOG:= ${METALOG:C,//+,/,g}
943 IMAKE+= -DNO_ROOT METALOG=${METALOG}
944 METALOG_INSTALLFLAGS= -U -M ${METALOG} -D ${INSTALL_DDIR}
945 INSTALLFLAGS+= ${METALOG_INSTALLFLAGS}
946 CERTCTLFLAGS= ${METALOG_INSTALLFLAGS}
949 .if defined(BUILD_PKGS)
950 INSTALLFLAGS+= -h sha256
952 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
953 IMAKE_INSTALL= INSTALL="${INSTALL_CMD} ${INSTALLFLAGS}"
954 IMAKE_MTREE= MTREE_CMD="${MTREE_CMD} ${MTREEFLAGS}"
956 .if make(distributeworld)
957 CERTCTLDESTDIR= ${DESTDIR}/${DISTDIR}/base
959 CERTCTLDESTDIR= ${DESTDIR}
962 DESTDIR_MTREEFLAGS= -deU
963 # When creating worldtmp we don't need to set the directories as owned by root
965 WORLDTMP_MTREEFLAGS= -deUW
967 # When building with -DNO_ROOT we shouldn't be changing the directories
968 # that are created by mtree to be owned by root/wheel.
969 DESTDIR_MTREEFLAGS+= -W
971 DISTR_MTREE= ${MTREE_CMD}
972 .if ${BUILD_WITH_STRICT_TMPPATH} != 0
973 DISTR_MTREE= ${WORLDTMP}/legacy/usr/sbin/mtree
975 WORLDTMP_MTREE= ${DISTR_MTREE} ${WORLDTMP_MTREEFLAGS}
976 DESTDIR_MTREE= ${DISTR_MTREE} ${DESTDIR_MTREEFLAGS}
979 KMAKEENV= ${WMAKEENV:NSYSROOT=*}
980 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
985 # Attempt to rebuild the entire system, with reasonable chance of
986 # success, regardless of how old your existing system is.
988 _sanity_check: .PHONY .MAKE
989 .if ${.CURDIR:C/[^,]//g} != ""
990 # The m4 build of sendmail files doesn't like it if ',' is used
991 # anywhere in the path of it's files.
993 @echo "*** Error: path to source tree contains a comma ','"
996 .elif ${.CURDIR:M*\:*} != ""
997 # Using ':' leaks into PATH and breaks finding cross-tools.
999 @echo "*** Error: path to source tree contains a colon ':'"
1004 # Our current approach to dependency tracking cannot cope with certain source
1005 # tree changes, particularly with respect to removing source files and
1006 # replacing generated files. Handle these cases here in an ad-hoc fashion.
1007 _cleanobj_fast_depend_hack: .PHONY
1008 @echo ">>> Deleting stale dependencies...";
1009 sh ${.CURDIR}/tools/build/depend-cleanup.sh ${OBJTOP}
1013 @echo "--------------------------------------------------------------"
1014 @echo ">>> Rebuilding the temporary build tree"
1015 @echo "--------------------------------------------------------------"
1016 .if ${MK_CLEAN} == "yes"
1019 # Note: for delete-old we need to set $PATH to also include the host $PATH
1020 # since otherwise a partial build with missing symlinks in ${WORLDTMP}/legacy/
1021 # will fail to run due to missing binaries. $WMAKE sets PATH to only ${TMPPATH}
1022 # so we remove that assingnment from $WMAKE and prepend the new $PATH
1023 ${_+_}@if [ -e "${WORLDTMP}" ]; then \
1024 echo ">>> Deleting stale files in build tree..."; \
1025 cd ${.CURDIR}; env PATH=${TMPPATH}:${PATH} ${WMAKE:NPATH=*} \
1026 _NO_INCLUDE_COMPILERMK=t -DBATCH_DELETE_OLD_FILES delete-old \
1027 delete-old-libs >/dev/null; \
1029 rm -rf ${WORLDTMP}/legacy/usr/include
1030 .if ${USING_SYSTEM_COMPILER} == "yes"
1032 if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \
1033 inum=$$(stat -f %i ${WORLDTMP}/usr/bin/${cc}); \
1034 find ${WORLDTMP}/usr/bin -inum $${inum} -delete; \
1037 .endif # ${USING_SYSTEM_COMPILER} == "yes"
1038 .if ${USING_SYSTEM_LINKER} == "yes"
1039 @rm -f ${WORLDTMP}/usr/bin/ld ${WORLDTMP}/usr/bin/ld.lld
1040 .endif # ${USING_SYSTEM_LINKER} == "yes"
1041 .endif # ${MK_CLEAN} == "yes"
1042 @mkdir -p ${WORLDTMP}
1043 @touch ${WORLDTMP}/${.TARGET}
1044 # We can't use mtree to create the worldtmp directories since it may not be
1045 # available on the target system (this happens e.g. when building on non-FreeBSD)
1046 cd ${.CURDIR}/tools/build; \
1047 ${MAKE} DIRPRFX=tools/build/ DESTDIR=${WORLDTMP}/legacy installdirs
1048 # In order to build without inheriting $PATH we need to add symlinks to the host
1049 # tools in $WORLDTMP for the tools that we don't build during bootstrap-tools
1050 cd ${.CURDIR}/tools/build; \
1051 ${MAKE} DIRPRFX=tools/build/ DESTDIR=${WORLDTMP}/legacy host-symlinks
1055 @echo "--------------------------------------------------------------"
1056 @echo ">>> stage 1.1: legacy release compatibility shims"
1057 @echo "--------------------------------------------------------------"
1058 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
1061 @echo "--------------------------------------------------------------"
1062 @echo ">>> stage 1.2: bootstrap tools"
1063 @echo "--------------------------------------------------------------"
1064 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
1065 mkdir -p ${WORLDTMP}/usr ${WORLDTMP}/lib/casper ${WORLDTMP}/lib/geom \
1067 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1068 -p ${WORLDTMP}/usr >/dev/null
1069 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1070 -p ${WORLDTMP}/usr/include >/dev/null
1071 ln -sf ${.CURDIR}/sys ${WORLDTMP}
1072 .if ${MK_DEBUG_FILES} != "no"
1073 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1074 -p ${WORLDTMP}/usr/lib >/dev/null
1076 .for _mtree in ${LOCAL_MTREE}
1077 ${WORLDTMP_MTREE} -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
1080 .if ${MK_CLEAN} == "yes"
1082 @echo "--------------------------------------------------------------"
1083 @echo ">>> stage 2.1: cleaning up the object tree"
1084 @echo "--------------------------------------------------------------"
1085 # Avoid including bsd.compiler.mk in clean and obj with _NO_INCLUDE_COMPILERMK
1086 # since the restricted $PATH might not contain a valid cc binary
1087 ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t ${CLEANDIR}
1088 .if defined(_LIBCOMPAT)
1089 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} _NO_INCLUDE_COMPILERMK=t -f Makefile.inc1 ${CLEANDIR}
1092 ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t _cleanobj_fast_depend_hack
1093 .endif # ${MK_CLEAN} == "yes"
1096 @echo "--------------------------------------------------------------"
1097 @echo ">>> stage 2.2: rebuilding the object tree"
1098 @echo "--------------------------------------------------------------"
1099 ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t obj
1102 @echo "--------------------------------------------------------------"
1103 @echo ">>> stage 2.3: build tools"
1104 @echo "--------------------------------------------------------------"
1105 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
1108 @echo "--------------------------------------------------------------"
1109 @echo ">>> stage 3: cross tools"
1110 @echo "--------------------------------------------------------------"
1111 @rm -f ${OBJTOP}/toolchain-metadata.mk
1112 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
1113 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
1116 @echo "--------------------------------------------------------------"
1117 @echo ">>> stage 3.1: recording build metadata"
1118 @echo "--------------------------------------------------------------"
1119 ${_+_}cd ${.CURDIR}; ${WMAKE} toolchain-metadata.mk
1120 ${_+_}cd ${.CURDIR}; ${WMAKE} host-osreldate.h
1123 @echo "--------------------------------------------------------------"
1124 @echo ">>> stage 4.1: building includes"
1125 @echo "--------------------------------------------------------------"
1126 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
1127 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
1128 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
1129 MK_INCLUDES=yes includes
1130 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
1131 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
1135 @echo "--------------------------------------------------------------"
1136 @echo ">>> stage 4.2: building libraries"
1137 @echo "--------------------------------------------------------------"
1138 ${_+_}cd ${.CURDIR}; \
1139 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
1140 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS_SUPPORT} \
1144 @echo "--------------------------------------------------------------"
1145 @echo ">>> stage 4.4: building everything"
1146 @echo "--------------------------------------------------------------"
1147 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
1150 .if !defined(WORLDFAST)
1151 WMAKE_TGTS+= _sanity_check _worldtmp _legacy
1152 .if empty(SUBDIR_OVERRIDE)
1153 WMAKE_TGTS+= _bootstrap-tools
1155 WMAKE_TGTS+= _cleanobj
1156 .if !defined(NO_OBJWALK)
1159 WMAKE_TGTS+= _build-tools _cross-tools
1160 WMAKE_TGTS+= _build-metadata
1161 WMAKE_TGTS+= _includes
1163 .if !defined(NO_LIBS)
1164 WMAKE_TGTS+= _libraries
1166 .if defined(_LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
1167 WMAKE_TGTS+= build${libcompat}
1169 WMAKE_TGTS+= everything
1171 # record buildworld time in seconds
1172 .if make(buildworld)
1173 _BUILDWORLD_START!= date '+%s'
1174 .export _BUILDWORLD_START
1177 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
1178 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
1180 _ncpu_cmd=sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo unknown
1182 buildworld_prologue: .PHONY
1183 @echo "--------------------------------------------------------------"
1184 @echo ">>> World build started on `LC_ALL=C date`"
1185 @echo "--------------------------------------------------------------"
1187 buildworld_epilogue: .PHONY
1189 @echo "--------------------------------------------------------------"
1190 @echo ">>> World build completed on `LC_ALL=C date`"
1191 @seconds=$$(($$(date '+%s') - ${_BUILDWORLD_START})); \
1192 echo -n ">>> World built in $$seconds seconds, "; \
1193 echo "ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}"
1194 @echo "--------------------------------------------------------------"
1197 # We need to have this as a target because the indirection between Makefile
1198 # and Makefile.inc1 causes the correct PATH to be used, rather than a
1199 # modification of the current environment's PATH. In addition, we need
1200 # to quote multiword values.
1202 buildenvvars: .PHONY
1203 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
1205 .if ${.TARGETS:Mbuildenv}
1206 .if ${.MAKEFLAGS:M-j}
1207 .error The buildenv target is incompatible with -j
1210 BUILDENV_DIR?= ${.CURDIR}
1212 # Note: make will report any errors the shell reports. This can
1213 # be odd if the last command in an interactive shell generates an
1214 # error or is terminated by SIGINT. These reported errors look bad,
1215 # but are harmless. Allowing them also allows BUIDLENV_SHELL to
1216 # be a complex command whose status will be returned to the caller.
1217 # Some scripts in tools rely on this behavior to report build errors.
1220 @echo Entering world for ${TARGET_ARCH}:${TARGET}
1221 .if ${BUILDENV_SHELL:M*zsh*}
1222 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
1224 @cd ${BUILDENV_DIR} && env ${WMAKEENV} \
1225 INSTALL="${INSTALL_CMD} ${INSTALLFLAGS}" \
1226 MTREE_CMD="${MTREE_CMD} ${MTREEFLAGS}" BUILDENV=1 ${BUILDENV_SHELL}
1228 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
1229 toolchain: ${TOOLCHAIN_TGTS} .PHONY
1230 KERNEL_TOOLCHAIN_TGTS= ${TOOLCHAIN_TGTS:N_obj:N_cleanobj:N_includes:N_libraries}
1231 .if make(kernel-toolchain)
1232 .ORDER: ${KERNEL_TOOLCHAIN_TGTS}
1234 kernel-toolchain: ${KERNEL_TOOLCHAIN_TGTS} .PHONY
1239 # Checks to be sure system is ready for installworld/installkernel.
1241 installcheck: _installcheck_world _installcheck_kernel .PHONY
1242 _installcheck_world: .PHONY
1243 @echo "--------------------------------------------------------------"
1244 @echo ">>> Install check world"
1245 @echo "--------------------------------------------------------------"
1246 _installcheck_kernel: .PHONY
1247 @echo "--------------------------------------------------------------"
1248 @echo ">>> Install check kernel"
1249 @echo "--------------------------------------------------------------"
1252 # Require DESTDIR to be set if installing for a different architecture or
1253 # using the user/group database in the source tree.
1255 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
1256 defined(DB_FROM_SRC)
1257 .if !make(distributeworld)
1258 _installcheck_world: __installcheck_DESTDIR
1259 _installcheck_kernel: __installcheck_DESTDIR
1260 __installcheck_DESTDIR: .PHONY
1261 .if !defined(DESTDIR) || empty(DESTDIR)
1262 @echo "ERROR: Please set DESTDIR!"; \
1268 .if !defined(DB_FROM_SRC)
1270 # Check for missing UIDs/GIDs.
1272 CHECK_UIDS= auditdistd
1277 CHECK_GIDS+= proxy authpf
1280 CHECK_UIDS+= unbound
1281 CHECK_GIDS+= unbound
1282 _installcheck_world: __installcheck_UGID
1283 __installcheck_UGID: .PHONY
1284 .for uid in ${CHECK_UIDS}
1285 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
1286 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
1290 .for gid in ${CHECK_GIDS}
1291 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
1292 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
1298 # If installing over the running system (DESTDIR is / or unset) and the install
1299 # includes rescue, try running rescue from the objdir as a sanity check. If
1300 # rescue is not functional (e.g., because it depends on a system call not
1301 # supported by the currently running kernel), abort the installation.
1303 .if !make(distributeworld) && ${MK_RESCUE} != "no" && \
1304 (empty(DESTDIR) || ${DESTDIR} == "/") && empty(BYPASS_INSTALLCHECK_SH)
1305 _installcheck_world: __installcheck_sh_check
1306 __installcheck_sh_check: .PHONY
1307 @if [ "`${OBJTOP}/rescue/rescue/rescue sh -c 'echo OK'`" != \
1309 echo "rescue/sh check failed, installation aborted" >&2; \
1315 # Required install tools to be saved in a scratch dir for safety.
1317 .if ${MK_ZONEINFO} != "no"
1318 _zoneinfo= zic tzsetup
1321 .if !defined(CROSSBUILD_HOST)
1325 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
1326 date echo egrep find grep id install ${_install-info} \
1327 ln make mkdir mtree mv pwd_mkdb \
1328 rm sed services_mkdb sh sort strip ${_sysctl} test true uname wc \
1329 ${_zoneinfo} ${LOCAL_ITOOLS}
1331 # Needed for share/man
1332 .if ${MK_MAN_UTILS} != "no"
1339 # Distributes everything compiled by a `buildworld'.
1343 # Installs everything compiled by a 'buildworld'.
1346 # Non-base distributions produced by the base system
1347 EXTRA_DISTRIBUTIONS=
1348 .if defined(_LIBCOMPAT)
1349 EXTRA_DISTRIBUTIONS+= lib${libcompat}
1351 .if ${MK_TESTS} != "no"
1352 EXTRA_DISTRIBUTIONS+= tests
1355 DEBUG_DISTRIBUTIONS=
1356 .if ${MK_DEBUG_FILES} != "no"
1357 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,tests,,}
1360 MTREE_MAGIC?= mtree 2.0
1362 distributeworld installworld stageworld: _installcheck_world .PHONY
1363 mkdir -p ${INSTALLTMP}
1364 progs=$$(for prog in ${ITOOLS}; do \
1365 if progpath=`env PATH=${TMPPATH} which $$prog`; then \
1368 echo "Required tool $$prog not found in PATH ($$PATH)." >&2; \
1372 if [ -z "${CROSSBUILD_HOST}" ] ; then \
1373 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
1374 while read line; do \
1376 if [ "$$2 $$3" != "not found" ]; then \
1379 echo "Required library $$1 not found." >&2; \
1384 cp $$libs $$progs ${INSTALLTMP}
1385 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
1386 .if defined(NO_ROOT)
1387 -mkdir -p ${METALOG:H}
1388 echo "#${MTREE_MAGIC}" > ${METALOG}
1390 .if make(distributeworld)
1391 .for dist in ${EXTRA_DISTRIBUTIONS}
1392 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
1393 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1394 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
1395 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1396 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1397 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1398 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
1399 .if ${MK_DEBUG_FILES} != "no"
1400 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1401 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
1403 .if defined(_LIBCOMPAT)
1404 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1405 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1406 .if ${MK_DEBUG_FILES} != "no"
1407 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1408 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
1411 .if ${MK_TESTS} != "no" && ${dist} == "tests"
1412 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
1413 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1414 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
1415 .if ${MK_DEBUG_FILES} != "no"
1416 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1417 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
1420 .if defined(NO_ROOT)
1421 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1422 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1423 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1424 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1425 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1426 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1427 .if defined(_LIBCOMPAT)
1428 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
1429 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1433 -mkdir ${DESTDIR}/${DISTDIR}/base
1434 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1435 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1436 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1437 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1438 ${INSTALL_SYMLINK} ${INSTALLFLAGS} usr/src/sys ${INSTALL_DDIR}/base/sys
1439 .endif # make(distributeworld)
1440 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1441 ${IMAKEENV} rm -rf ${INSTALLTMP}
1442 .if make(distributeworld)
1443 .for dist in ${EXTRA_DISTRIBUTIONS}
1444 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete
1446 .if defined(NO_ROOT)
1447 .for dist in base ${EXTRA_DISTRIBUTIONS}
1448 @# For each file that exists in this dist, print the corresponding
1449 @# line from the METALOG. This relies on the fact that
1450 @# a line containing only the filename will sort immediately before
1451 @# the relevant mtree line.
1452 cd ${DESTDIR}/${DISTDIR}; \
1453 find ./${dist} | sort -u ${METALOG} - | \
1454 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1455 ${DESTDIR}/${DISTDIR}/${dist}.meta
1457 .for dist in ${DEBUG_DISTRIBUTIONS}
1458 @# For each file that exists in this dist, print the corresponding
1459 @# line from the METALOG. This relies on the fact that
1460 @# a line containing only the filename will sort immediately before
1461 @# the relevant mtree line.
1462 cd ${DESTDIR}/${DISTDIR}; \
1463 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1464 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1465 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1468 .endif # make(distributeworld)
1469 .if !make(packageworld) && ${MK_CAROOT} != "no"
1470 @if which openssl>/dev/null; then \
1471 DESTDIR=${CERTCTLDESTDIR} PATH=${TMPPATH}:${PATH} \
1472 sh ${SRCTOP}/usr.sbin/certctl/certctl.sh ${CERTCTLFLAGS} rehash \
1474 echo "No openssl on the host, not rehashing certificates target -- /etc/ssl may not be populated."; \
1478 packageworld: .PHONY
1479 .for dist in base ${EXTRA_DISTRIBUTIONS}
1480 .if defined(NO_ROOT)
1481 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1482 tar cvf - --exclude usr/lib/debug \
1483 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1484 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1486 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1487 tar cvf - --exclude usr/lib/debug . | \
1488 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1492 .for dist in ${DEBUG_DISTRIBUTIONS}
1493 . if defined(NO_ROOT)
1494 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1495 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1496 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1498 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1499 tar cvLf - usr/lib/debug | \
1500 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1505 ${_+_}cd ${.CURDIR}/tools/build/options; sh makeman > \
1506 ${.CURDIR}/share/man/man5/src.conf.5
1508 # We can't assume here that ${TMPPATH} will include ${PATH} or /usr/libexec
1509 # because we may be building with a STRICTTMPPATH, so we explicitly include
1510 # /usr/libexec here for flua. ${TMPPATH} still usefully includes anything else
1511 # we may need to function.
1512 _sysent_PATH= ${TMPPATH}:/usr/libexec
1513 _sysent_dirs= sys/kern
1514 _sysent_dirs+= sys/compat/freebsd32
1515 _sysent_dirs+= sys/compat/cloudabi32 \
1516 sys/compat/cloudabi64
1517 _sysent_dirs+= sys/amd64/linux \
1524 .for _dir in ${_sysent_dirs}
1525 sysent-${_dir}: .PHONY
1526 @echo "${MAKE} -C ${.CURDIR}/${_dir} sysent"
1527 ${_+_}@env PATH=${_sysent_PATH} ${MAKE} -C ${.CURDIR}/${_dir} sysent
1529 sysent: sysent-${_dir}
1535 # If you have a build server, you can NFS mount the source and obj directories
1536 # and do a 'make reinstall' on the *client* to install new binaries from the
1537 # most recent server build.
1539 restage reinstall: .MAKE .PHONY
1540 @echo "--------------------------------------------------------------"
1541 @echo ">>> Making hierarchy"
1542 @echo "--------------------------------------------------------------"
1543 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1544 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1546 @echo "--------------------------------------------------------------"
1547 @echo ">>> Making distribution"
1548 @echo "--------------------------------------------------------------"
1549 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1550 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
1553 @echo "--------------------------------------------------------------"
1554 @echo ">>> Installing everything started on `LC_ALL=C date`"
1555 @echo "--------------------------------------------------------------"
1556 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1557 .if defined(_LIBCOMPAT)
1558 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1560 @echo "--------------------------------------------------------------"
1561 @echo ">>> Installing everything completed on `LC_ALL=C date`"
1562 @echo "--------------------------------------------------------------"
1564 redistribute: .MAKE .PHONY
1565 @echo "--------------------------------------------------------------"
1566 @echo ">>> Distributing everything"
1567 @echo "--------------------------------------------------------------"
1568 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1569 .if defined(_LIBCOMPAT)
1570 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1571 DISTRIBUTION=lib${libcompat}
1574 distrib-dirs distribution: .MAKE .PHONY
1575 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1576 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1577 .if make(distribution)
1578 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1579 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1580 METALOG=${METALOG} MK_TESTS=no \
1581 MK_TESTS_SUPPORT=${MK_TESTS_SUPPORT} installconfig
1585 # buildkernel and installkernel
1587 # Which kernels to build and/or install is specified by setting
1588 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1589 # Only the existing (depending TARGET) config files are used
1590 # for building kernels and only the first of these is designated
1591 # as the one being installed.
1593 # Note that we have to use TARGET instead of TARGET_ARCH when
1594 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1595 # be set to cross-build, we have to make sure TARGET is set
1598 .if defined(KERNFAST)
1602 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1603 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1604 KERNCONF=${KERNFAST}
1607 .if ${TARGET_ARCH} == "powerpc64"
1608 KERNCONF?= GENERIC64
1609 .elif ${TARGET_ARCH} == "powerpc64le"
1610 KERNCONF?= GENERIC64LE
1611 .elif ${TARGET_ARCH} == "powerpcspe"
1612 KERNCONF?= MPC85XXSPE
1616 INSTKERNNAME?= kernel
1618 KERNSRCDIR?= ${.CURDIR}/sys
1619 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1620 KRNLOBJDIR= ${OBJTOP}${KERNSRCDIR:C,^${.CURDIR},,}
1621 KERNCONFDIR?= ${KRNLCONFDIR}
1625 .if defined(NO_INSTALLKERNEL)
1626 # All of the BUILDKERNELS loops start at index 1.
1627 BUILDKERNELS+= dummy
1629 .for _kernel in ${KERNCONF}
1630 .if !defined(_MKSHOWCONFIG) && exists(${KERNCONFDIR}/${_kernel})
1631 BUILDKERNELS+= ${_kernel}
1632 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1633 INSTALLKERNEL= ${_kernel}
1636 .if make(buildkernel)
1637 .error Missing KERNCONF ${KERNCONFDIR}/${_kernel}
1642 _cleankernobj_fast_depend_hack: .PHONY
1643 # 20191009 r353340 removal of opensolaris_atomic.S (also r353381)
1644 .if ${MACHINE} != i386
1645 .for f in opensolaris_atomic
1646 .for m in opensolaris zfs
1647 @if [ -e "${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o" ] && \
1648 grep -q ${f}.S "${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o"; then \
1649 echo "Removing stale dependencies for opensolaris_atomic"; \
1650 rm -f ${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.*; \
1656 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1658 # record kernel(s) build time in seconds
1659 .if make(buildkernel)
1660 _BUILDKERNEL_START!= date '+%s'
1666 # Builds all kernels defined by BUILDKERNELS.
1668 buildkernel: .MAKE .PHONY
1669 .if empty(BUILDKERNELS:Ndummy)
1670 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1674 .for _kernel in ${BUILDKERNELS:Ndummy}
1675 @echo "--------------------------------------------------------------"
1676 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1677 @echo "--------------------------------------------------------------"
1678 @echo "===> ${_kernel}"
1679 mkdir -p ${KRNLOBJDIR}
1680 .if !defined(NO_KERNELCONFIG)
1682 @echo "--------------------------------------------------------------"
1683 @echo ">>> stage 1: configuring the kernel"
1684 @echo "--------------------------------------------------------------"
1685 cd ${KRNLCONFDIR}; \
1687 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1688 -I '${KERNCONFDIR}' -I '${KRNLCONFDIR}' \
1689 '${KERNCONFDIR}/${_kernel}'
1691 .if ${MK_CLEAN} == "yes" && !defined(NO_KERNELCLEAN)
1693 @echo "--------------------------------------------------------------"
1694 @echo ">>> stage 2.1: cleaning up the object tree"
1695 @echo "--------------------------------------------------------------"
1696 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1698 ${_+_}cd ${.CURDIR}; ${WMAKE} _cleankernobj_fast_depend_hack
1700 .if !defined(NO_KERNELOBJ)
1702 @echo "--------------------------------------------------------------"
1703 @echo ">>> stage 2.2: rebuilding the object tree"
1704 @echo "--------------------------------------------------------------"
1705 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1708 @echo "--------------------------------------------------------------"
1709 @echo ">>> stage 2.3: build tools"
1710 @echo "--------------------------------------------------------------"
1711 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1713 @echo "--------------------------------------------------------------"
1714 @echo ">>> stage 3.1: building everything"
1715 @echo "--------------------------------------------------------------"
1716 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1717 @echo "--------------------------------------------------------------"
1718 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1719 @echo "--------------------------------------------------------------"
1722 @seconds=$$(($$(date '+%s') - ${_BUILDKERNEL_START})); \
1723 echo -n ">>> Kernel(s) ${BUILDKERNELS} built in $$seconds seconds, "; \
1724 echo "ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}"
1725 @echo "--------------------------------------------------------------"
1727 .if !make(packages) && !make(update-packages)
1728 NO_INSTALLEXTRAKERNELS?= yes
1730 # packages/update-packages installs kernels to a staging directory then builds
1731 # packages from the result to be installed, typically to other systems. It is
1732 # less surprising for these targets to honor KERNCONF if multiple kernels are
1734 NO_INSTALLEXTRAKERNELS?= no
1738 # installkernel, etc.
1740 # Install the kernel defined by INSTALLKERNEL
1742 installkernel installkernel.debug \
1743 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1744 .if !defined(NO_INSTALLKERNEL)
1745 .if empty(INSTALLKERNEL)
1746 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1749 @echo "--------------------------------------------------------------"
1750 @echo ">>> Installing kernel ${INSTALLKERNEL} on $$(LC_ALL=C date)"
1751 @echo "--------------------------------------------------------------"
1752 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1753 ${CROSSENV} PATH=${TMPPATH} \
1754 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1755 @echo "--------------------------------------------------------------"
1756 @echo ">>> Installing kernel ${INSTALLKERNEL} completed on $$(LC_ALL=C date)"
1757 @echo "--------------------------------------------------------------"
1759 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1760 .for _kernel in ${BUILDKERNELS:[2..-1]}
1761 @echo "--------------------------------------------------------------"
1762 @echo ">>> Installing kernel ${_kernel} $$(LC_ALL=C date)"
1763 @echo "--------------------------------------------------------------"
1764 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
1765 ${CROSSENV} PATH=${TMPPATH} \
1766 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1767 @echo "--------------------------------------------------------------"
1768 @echo ">>> Installing kernel ${_kernel} completed on $$(LC_ALL=C date)"
1769 @echo "--------------------------------------------------------------"
1773 distributekernel distributekernel.debug: .PHONY
1774 .if !defined(NO_INSTALLKERNEL)
1775 .if empty(INSTALLKERNEL)
1776 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1779 mkdir -p ${DESTDIR}/${DISTDIR}
1780 .if defined(NO_ROOT)
1781 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1783 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1784 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1785 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1786 DESTDIR=${INSTALL_DDIR}/kernel \
1787 ${.TARGET:S/distributekernel/install/}
1788 .if defined(NO_ROOT)
1789 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1790 ${DESTDIR}/${DISTDIR}/kernel.meta
1793 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1794 .for _kernel in ${BUILDKERNELS:[2..-1]}
1795 .if defined(NO_ROOT)
1796 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1798 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
1799 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1800 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1801 KERNEL=${INSTKERNNAME}.${_kernel} \
1802 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1803 ${.TARGET:S/distributekernel/install/}
1804 .if defined(NO_ROOT)
1805 @sed -e "s|^./kernel.${_kernel}|.|" \
1806 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1807 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1812 packagekernel: .PHONY
1813 .if defined(NO_ROOT)
1814 .if !defined(NO_INSTALLKERNEL)
1815 cd ${DESTDIR}/${DISTDIR}/kernel; \
1816 tar cvf - --exclude '*.debug' \
1817 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1818 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1820 .if ${MK_DEBUG_FILES} != "no"
1821 cd ${DESTDIR}/${DISTDIR}/kernel; \
1822 tar cvf - --include '*/*/*.debug' \
1823 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1824 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1826 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1827 .for _kernel in ${BUILDKERNELS:[2..-1]}
1828 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1829 tar cvf - --exclude '*.debug' \
1830 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1831 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1832 .if ${MK_DEBUG_FILES} != "no"
1833 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1834 tar cvf - --include '*/*/*.debug' \
1835 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1836 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1841 .if !defined(NO_INSTALLKERNEL)
1842 cd ${DESTDIR}/${DISTDIR}/kernel; \
1843 tar cvf - --exclude '*.debug' . | \
1844 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1846 .if ${MK_DEBUG_FILES} != "no"
1847 cd ${DESTDIR}/${DISTDIR}/kernel; \
1848 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1849 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1851 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1852 .for _kernel in ${BUILDKERNELS:[2..-1]}
1853 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1854 tar cvf - --exclude '*.debug' . | \
1855 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1856 .if ${MK_DEBUG_FILES} != "no"
1857 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1858 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1859 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1866 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1868 PORTSDIR?= /usr/ports
1869 WSTAGEDIR?= ${OBJTOP}/worldstage
1870 KSTAGEDIR?= ${OBJTOP}/kernelstage
1871 REPODIR?= ${OBJROOT}repo
1873 PKG_REPO_SIGNING_KEY?= # empty
1874 PKG_OUTPUT_DIR?= ${PKG_VERSION}
1876 .ORDER: stage-packages create-packages
1877 .ORDER: create-packages create-world-packages
1878 .ORDER: create-packages create-kernel-packages
1879 .ORDER: create-packages sign-packages
1881 _pkgbootstrap: .PHONY
1882 .if make(*package*) && !exists(${LOCALBASE}/sbin/pkg)
1883 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1886 .if make(create-world-packages-jobs) || make(create-kernel-packages*) || make(real-update-packages)
1887 PKG_ABI!=${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI
1890 .if !defined(PKG_VERSION_FROM) && make(real-update-packages)
1891 .if defined(PKG_ABI)
1892 .if exists(${REPODIR}/${PKG_ABI})
1893 PKG_VERSION_FROM!=/usr/bin/readlink ${REPODIR}/${PKG_ABI}/latest
1894 PKG_VERSION_FROM_DIR= ${REPODIR}/${PKG_ABI}/${PKG_VERSION_FROM}
1897 PKG_VERSION_FROM_DIR=
1902 PKGMAKEARGS+= PKG_VERSION=${PKG_VERSION} \
1903 NO_INSTALLEXTRAKERNELS=${NO_INSTALLEXTRAKERNELS}
1906 ${_+_}${MAKE} -C ${.CURDIR} ${PKGMAKEARGS} real-packages
1908 update-packages: .PHONY
1909 ${_+_}${MAKE} -C ${.CURDIR} ${PKGMAKEARGS} real-update-packages
1912 rm -rf /tmp/ports.${TARGET} || :
1913 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
1914 PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \
1915 WSTAGEDIR=${WSTAGEDIR} \
1916 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1918 real-packages: stage-packages create-packages sign-packages .PHONY
1920 real-update-packages: stage-packages .PHONY
1921 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} create-packages
1922 .if empty(PKG_VERSION_FROM_DIR)
1923 @echo "==> Bootstrapping repository, not checking for new packages"
1925 @echo "==> Checking for new packages (comparing ${PKG_VERSION} to ${PKG_VERSION_FROM})"
1926 @for pkg in ${PKG_VERSION_FROM_DIR}/${PKG_NAME_PREFIX}-*; do \
1927 pkgname=$$(pkg query -F $${pkg} '%n' | sed 's/${PKG_NAME_PREFIX}-\(.*\)/\1/') ; \
1928 newpkgname=${PKG_NAME_PREFIX}-$${pkgname}-${PKG_VERSION}.${PKG_FORMAT} ; \
1929 oldsum=$$(pkg query -F $${pkg} '%X') ; \
1930 if [ ! -f ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} ]; then \
1933 newsum=$$(pkg query -F ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} '%X') ; \
1934 if [ "$${oldsum}" == "$${newsum}" ]; then \
1935 echo "==> Keeping old ${PKG_NAME_PREFIX}-$${pkgname}-${PKG_VERSION_FROM}.${PKG_FORMAT}" ; \
1936 rm ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} ; \
1937 cp $${pkg} ${REPODIR}/${PKG_ABI}/${PKG_VERSION} ; \
1939 echo "==> New package $${newpkgname}" ; \
1943 ${_+_}@cd ${.CURDIR}; \
1944 ${MAKE} -f Makefile.inc1 PKG_VERSION=${PKG_VERSION} sign-packages
1946 stage-packages-world: .PHONY
1947 @mkdir -p ${WSTAGEDIR}
1948 ${_+_}@cd ${.CURDIR}; \
1949 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT stageworld
1951 stage-packages-kernel: .PHONY
1952 @mkdir -p ${KSTAGEDIR}
1953 ${_+_}@cd ${.CURDIR}; \
1954 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT stagekernel
1956 stage-packages: .PHONY stage-packages-world stage-packages-kernel
1959 @mkdir -p ${REPODIR}
1961 create-packages-world: _pkgbootstrap _repodir .PHONY
1962 ${_+_}@cd ${.CURDIR}; \
1963 ${MAKE} -f Makefile.inc1 \
1964 DESTDIR=${WSTAGEDIR} \
1965 PKG_VERSION=${PKG_VERSION} create-world-packages
1967 create-packages-kernel: _pkgbootstrap _repodir .PHONY
1968 ${_+_}@cd ${.CURDIR}; \
1969 ${MAKE} -f Makefile.inc1 \
1970 DESTDIR=${KSTAGEDIR} \
1971 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1972 SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
1973 create-kernel-packages
1975 create-packages: .PHONY create-packages-world create-packages-kernel
1977 create-world-packages: _pkgbootstrap .PHONY
1978 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1979 @cd ${WSTAGEDIR} ; \
1980 env -i LC_COLLATE=C sort ${WSTAGEDIR}/${DISTDIR}/METALOG | \
1981 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk
1982 @for plist in ${WSTAGEDIR}/*.plist; do \
1983 plist=$${plist##*/} ; \
1984 pkgname=$${plist%.plist} ; \
1985 echo "_PKGS+= $${pkgname}" ; \
1986 done > ${WSTAGEDIR}/packages.mk
1987 ${_+_}@cd ${.CURDIR}; \
1988 ${MAKE} -f Makefile.inc1 create-world-packages-jobs \
1989 SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
1992 .if make(create-world-packages-jobs)
1993 .include "${WSTAGEDIR}/packages.mk"
1996 create-world-packages-jobs: .PHONY
1997 .for pkgname in ${_PKGS}
1998 create-world-packages-jobs: create-world-package-${pkgname}
1999 create-world-package-${pkgname}: .PHONY
2000 @sh ${SRCDIR}/release/packages/generate-ucl.sh -o ${pkgname} \
2001 -s ${SRCDIR} -u ${WSTAGEDIR}/${pkgname}.ucl
2003 /^name/ { printf("===> Creating %s-", $$2); next } \
2004 /^version/ { print $$2; next } \
2005 ' ${WSTAGEDIR}/${pkgname}.ucl
2006 @if [ "${pkgname}" == "runtime" ]; then \
2007 sed -i '' -e "s/%VCS_REVISION%/${VCS_REVISION}/" ${WSTAGEDIR}/${pkgname}.ucl ; \
2009 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname -o ALLOW_BASE_SHLIBS=yes \
2010 create -f ${PKG_FORMAT} -M ${WSTAGEDIR}/${pkgname}.ucl \
2011 -p ${WSTAGEDIR}/${pkgname}.plist \
2013 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
2016 _default_flavor= -default
2017 .if make(*package*) && exists(${KSTAGEDIR}/kernel.meta)
2018 . if ${MK_DEBUG_FILES} != "no"
2021 create-kernel-packages: .PHONY
2022 . for flavor in "" ${_debug}
2023 create-kernel-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}
2024 create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY
2025 @cd ${KSTAGEDIR}/${DISTDIR} ; \
2026 env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.meta | \
2027 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
2028 -v kernel=yes -v _kernconf=${INSTALLKERNEL} ; \
2029 sed -e "s/%VERSION%/${PKG_VERSION}/" \
2030 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
2031 -e "s/%KERNELDIR%/kernel/" \
2032 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
2033 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
2034 -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \
2035 -e "s/%PKG_NAME_PREFIX%/${PKG_NAME_PREFIX}/" \
2036 -e "s/%PKG_MAINTAINER%/${PKG_MAINTAINER}/" \
2037 -e "s|%PKG_WWW%|${PKG_WWW}|" \
2038 ${SRCDIR}/release/packages/kernel.ucl \
2039 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
2041 /name/ { printf("===> Creating %s-", $$2); next } \
2042 /version/ {print $$2; next } ' \
2043 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
2044 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname -o ALLOW_BASE_SHLIBS=yes \
2045 create -f ${PKG_FORMAT} \
2046 -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
2047 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
2048 -r ${KSTAGEDIR}/${DISTDIR} \
2049 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
2052 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
2053 . for _kernel in ${BUILDKERNELS:[2..-1]}
2054 . if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
2055 . if ${MK_DEBUG_FILES} != "no"
2058 . for flavor in "" ${_debug}
2059 create-kernel-packages: create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}
2060 create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}: _pkgbootstrap .PHONY
2061 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
2062 env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.${_kernel}.meta | \
2063 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
2064 -v kernel=yes -v _kernconf=${_kernel} ; \
2065 sed -e "s/%VERSION%/${PKG_VERSION}/" \
2066 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
2067 -e "s/%KERNELDIR%/kernel.${_kernel}/" \
2068 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
2069 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
2070 -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \
2071 -e "s/%PKG_NAME_PREFIX%/${PKG_NAME_PREFIX}/" \
2072 -e "s/%PKG_MAINTAINER%/${PKG_MAINTAINER}/" \
2073 -e "s|%PKG_WWW%|${PKG_WWW}|" \
2074 ${SRCDIR}/release/packages/kernel.ucl \
2075 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
2077 /name/ { printf("===> Creating %s-", $$2); next } \
2078 /version/ {print $$2; next } ' \
2079 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
2080 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname -o ALLOW_BASE_SHLIBS=yes \
2081 create -f ${PKG_FORMAT} \
2082 -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
2083 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
2084 -r ${KSTAGEDIR}/kernel.${_kernel} \
2085 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
2091 sign-packages: _pkgbootstrap .PHONY
2092 printf "version = 2;\npacking_format = \"${PKG_FORMAT}\";\n" > ${WSTAGEDIR}/meta
2093 @[ -L "${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/latest" ] && \
2094 unlink ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/latest ; \
2095 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname repo \
2096 -m ${WSTAGEDIR}/meta \
2097 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/${PKG_VERSION} \
2098 ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/${PKG_VERSION} \
2099 ${PKG_REPO_SIGNING_KEY} ; \
2100 cd ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI); \
2101 ln -s ${PKG_OUTPUT_DIR} latest
2107 # Run test suite on installed world.
2110 @if [ ! -x "${LOCALBASE}/bin/kyua" ] && [ ! -x "/usr/bin/kyua" ]; then \
2111 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
2114 ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile
2120 # Build the API documentation with doxygen
2123 @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \
2124 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
2127 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
2130 # ------------------------------------------------------------------------
2132 # From here onwards are utility targets used by the 'make world' and
2133 # related targets. If your 'world' breaks, you may like to try to fix
2134 # the problem and manually run the following targets to attempt to
2135 # complete the build. Beware, this is *not* guaranteed to work, you
2136 # need to have a pretty good grip on the current state of the system
2137 # to attempt to manually finish it. If in doubt, 'make world' again.
2141 # legacy: Build compatibility shims for the next three targets. This is a
2142 # minimal set of tools and shims necessary to compensate for older systems
2143 # which don't have the APIs required by the targets built in bootstrap-tools,
2144 # build-tools or cross-tools.
2147 .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
2148 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
2154 ${LOCAL_LEGACY_DIRS}
2155 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
2156 cd ${.CURDIR}/${_tool}; \
2157 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2158 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy includes; \
2159 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
2160 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
2161 DESTDIR=${WORLDTMP}/legacy install
2165 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
2166 # are built to build other binaries in the system. However, the focus of these
2167 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
2168 # libraries, augmented by -legacy, in addition to the libraries built during
2171 _bt= _bootstrap-tools
2173 # We want to run the build with only ${WORLDTMP} in $PATH to ensure we don't
2174 # accidentally run tools that are incompatible but happen to be in $PATH.
2175 # This is especially important when building on Linux/MacOS where many of the
2176 # programs used during the build accept different flags or generate different
2177 # output. On those platforms we only symlink the tools known to be compatible
2178 # (e.g. basic utilities such as mkdir) into ${WORLDTMP} and build all others
2179 # from the FreeBSD sources during the bootstrap-tools stage.
2180 # We want to build without the user's $PATH starting in the bootstrap-tools
2181 # phase so the tools used in that phase (ln, cp, etc) must have already been
2182 # linked to $WORLDTMP. The tools are listed in the _host_tools_to_symlink
2183 # variable in tools/build/Makefile and are linked during the legacy phase.
2184 # Since they could be Linux or MacOS binaries, too we must only use flags that
2185 # are portable across operating systems.
2187 # If BOOTSTRAP_ALL_TOOLS is set we will build all the required tools from the
2188 # current source tree. Otherwise we create a symlink to the version found in
2189 # $PATH during the bootstrap-tools stage.
2190 # When building on non-FreeBSD systems we can't assume that the host binaries
2191 # accept compatible flags or produce compatible output. Therefore we force
2192 # BOOTSTRAP_ALL_TOOLS and just build the FreeBSD version of the binary.
2193 .if defined(CROSSBUILD_HOST)
2194 BOOTSTRAP_ALL_TOOLS:= 1
2196 .if defined(BOOTSTRAP_ALL_TOOLS)
2197 # BOOTSTRAPPING will be set on the command line so we can't override it here.
2198 # Instead set BOOTSTRAPPING_OSRELDATE so that the value 0 is set ${BSARGS}
2199 BOOTSTRAPPING_OSRELDATE:= 0
2202 # libnv and libsbuf are requirements for config(8), which is an unconditional
2204 _config=usr.sbin/config lib/libnv lib/libsbuf
2205 ${_bt}-usr.sbin/config: ${_bt}-lib/libnv ${_bt}-lib/libsbuf
2207 .if ${MK_GAMES} != "no"
2208 _strfile= usr.bin/fortune/strfile
2211 # vtfontcvt is used to build font files for loader and to generate
2212 # C source for loader built in font (8x16.c).
2213 _vtfontcvt= usr.bin/vtfontcvt
2215 # If we are not building the bootstrap because BOOTSTRAPPING is sufficient
2216 # we symlink the host version to $WORLDTMP instead. By doing this we can also
2217 # detect when a bootstrap tool is being used without the required MK_FOO.
2218 # If you add a new bootstrap tool where we could also use the host version,
2219 # please ensure that you also add a .else case where you add the tool to the
2220 # _bootstrap_tools_links variable.
2221 .if ${BOOTSTRAPPING} < 1000033
2222 # Note: lex needs m4 to build but m4 also depends on lex (which needs m4 to
2223 # generate any files). To fix this cyclic dependency we can build a bootstrap
2224 # version of m4 (with pre-generated files) then use that to build the real m4.
2225 # We can't simply use the host m4 since e.g. the macOS version does not accept
2226 # the flags that are passed by lex.
2227 # For lex we also use the pre-gerated files since we would otherwise need to
2228 # build awk and sed first (which need lex to build)
2229 # TODO: add a _bootstrap_lex and then build the real lex afterwards
2231 _m4= tools/build/bootstrap-m4 usr.bin/m4
2232 ${_bt}-tools/build/bootstrap-m4: ${_bt}-usr.bin/lex ${_bt}-lib/libopenbsd ${_bt}-usr.bin/yacc
2233 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd ${_bt}-usr.bin/yacc ${_bt}-usr.bin/lex ${_bt}-tools/build/bootstrap-m4
2234 _bt_m4_depend=${_bt}-usr.bin/m4
2235 _bt_lex_depend=${_bt}-usr.bin/lex ${_bt_m4_depend}
2237 _bootstrap_tools_links+=m4 lex
2240 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
2241 # r296685 fix cross-endian objcopy
2242 # r310724 fixed PR 215350, a crash in libdwarf with objects built by GCC 6.2.
2243 # r334881 added libdwarf constants used by ctfconvert.
2244 # r338478 fixed a crash in objcopy for mips64el objects
2245 # r339083 libelf: correct mips64el test to use ELF header
2246 # r348347 Add missing powerpc64 relocation support to libdwarf
2247 .if ${BOOTSTRAPPING} < 1300030
2248 _elftoolchain_libs= lib/libelf lib/libdwarf lib/libzstd
2249 ${_bt}-lib/libelf: ${_bt_m4_depend}
2250 ${_bt}-lib/libdwarf: ${_bt_m4_depend}
2253 # flua is required to regenerate syscall files. It first appeared during the
2254 # 13.0-CURRENT cycle, thus needs to be built on -older releases and stable
2256 .if ${BOOTSTRAPPING} < 1300059
2257 ${_bt}-libexec/flua: ${_bt}-lib/liblua ${_bt}-lib/libucl
2258 _flua= lib/liblua lib/libucl libexec/flua
2261 # r245440 mtree -N support added
2262 # r313404 requires sha384.h for libnetbsd, added to libmd in r292782
2263 .if ${BOOTSTRAPPING} < 1100093
2264 _nmtree= lib/libmd \
2268 ${_bt}-lib/libnetbsd: ${_bt}-lib/libmd
2269 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
2271 _bootstrap_tools_links+=mtree
2274 # r246097: log addition login.conf.db, passwd, pwd.db, and spwd.db with cat -l
2275 .if ${BOOTSTRAPPING} < 1000027
2278 _bootstrap_tools_links+=cat
2281 # r277259 crunchide: Correct 64-bit section header offset
2282 # r281674 crunchide: always include both 32- and 64-bit ELF support
2283 .if ${BOOTSTRAPPING} < 1100078
2284 _crunchide= usr.sbin/crunch/crunchide
2286 _bootstrap_tools_links+=crunchide
2289 # 1300115: Higher WARNS fixes
2290 .if ${BOOTSTRAPPING} < 1202502 || \
2291 (${BOOTSTRAPPING} > 1300000 && ${BOOTSTRAPPING} < 1300131)
2292 _crunchgen= usr.sbin/crunch/crunchgen
2294 _bootstrap_tools_links+=crunchgen
2297 # r296926 -P keymap search path, MFC to stable/10 in r298297
2298 # Note: kbdcontrol can not be bootstrapped on non-FreeBSD systems
2299 .if !defined(CROSSBUILD_HOST)
2300 .if (${BOOTSTRAPPING} < 1003501 || \
2301 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103) || \
2302 (!exists(/usr/sbin/kbdcontrol)))
2303 _kbdcontrol= usr.sbin/kbdcontrol
2305 _bootstrap_tools_links+=kbdcontrol
2309 # 1300102: VHDX support
2310 .if ${BOOTSTRAPPING} < 1201520 || \
2311 (${BOOTSTRAPPING} > 1300000 && ${BOOTSTRAPPING} < 1300102)
2312 _mkimg= usr.bin/mkimg
2314 _bootstrap_tools_links+=mkimg
2319 .if ${MK_BSNMP} != "no"
2320 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
2324 # We need to build tblgen when we're building clang or lld, either as
2325 # bootstrap tools, or as the part of the normal build.
2326 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
2327 ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no" || \
2330 lib/clang/libllvmminimal \
2331 usr.bin/clang/llvm-tblgen
2332 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
2333 _clang_tblgen+= usr.bin/clang/clang-tblgen
2335 .if ${MK_LLDB} != "no"
2336 _clang_tblgen+= usr.bin/clang/lldb-tblgen
2338 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal
2339 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal
2340 ${_bt}-usr.bin/clang/lldb-tblgen: ${_bt}-lib/clang/libllvmminimal
2343 .if ${MK_LOCALES} != "no"
2344 _localedef= usr.bin/localedef
2345 ${_bt}-usr.bin/localedef: ${_bt}-usr.bin/yacc ${_bt_lex_depend}
2348 .if ${MK_ICONV} != "no"
2349 _mkesdb= usr.bin/mkesdb
2350 _mkcsmapper= usr.bin/mkcsmapper
2351 ${_bt}-usr.bin/mkesdb: ${_bt}-usr.bin/yacc ${_bt_lex_depend}
2352 ${_bt}-usr.bin/mkcsmapper: ${_bt}-usr.bin/yacc ${_bt_lex_depend}
2355 .if ${MK_KERBEROS} != "no"
2356 _kerberos5_bootstrap_tools= \
2357 kerberos5/tools/make-roken \
2358 kerberos5/lib/libroken \
2359 kerberos5/lib/libvers \
2360 kerberos5/tools/asn1_compile \
2361 kerberos5/tools/slc \
2364 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
2365 .for _tool in ${_kerberos5_bootstrap_tools}
2366 ${_bt}-${_tool}: ${_bt}-usr.bin/yacc ${_bt_lex_depend}
2370 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
2372 # The tools listed in _basic_bootstrap_tools will generally not be
2373 # bootstrapped unless BOOTSTRAP_ALL_TOOL is set. However, when building on a
2374 # Linux or MacOS host the host versions are incompatible so we need to build
2375 # them from the source tree. Usually the link name will be the same as the subdir,
2376 # but some directories such as grep or test install multiple binaries. In that
2377 # case we use the _basic_bootstrap_tools_multilink variable which is a list of
2378 # subdirectory and comma-separated list of files.
2379 _basic_bootstrap_tools_multilink=usr.bin/grep grep,egrep,fgrep
2380 _basic_bootstrap_tools_multilink+=bin/test test,[
2381 # bootstrap tools needed by buildworld:
2382 _basic_bootstrap_tools+=usr.bin/cut bin/expr usr.bin/gencat usr.bin/join \
2383 usr.bin/mktemp bin/realpath bin/rmdir usr.bin/sed usr.bin/sort \
2384 usr.bin/truncate usr.bin/tsort
2385 # Some build scripts use nawk instead of awk (this happens at least in
2386 # cddl/contrib/opensolaris/lib/libdtrace/common/mknames.sh) so we need both awk
2387 # and nawk in ${WORLDTMP}/legacy/bin.
2388 _basic_bootstrap_tools_multilink+=usr.bin/awk awk,nawk
2389 # file2c is required for building usr.sbin/config:
2390 _basic_bootstrap_tools+=usr.bin/file2c
2391 # uuencode/uudecode required for share/tabset
2392 _basic_bootstrap_tools+=usr.bin/uuencode usr.bin/uudecode
2393 # xargs is required by mkioctls
2394 _basic_bootstrap_tools+=usr.bin/xargs
2395 # cap_mkdb is required for share/termcap:
2396 _basic_bootstrap_tools+=usr.bin/cap_mkdb
2397 # services_mkdb/pwd_mkdb are required for installworld:
2398 _basic_bootstrap_tools+=usr.sbin/services_mkdb usr.sbin/pwd_mkdb
2399 # ldd is required for installcheck (TODO: just always use /usr/bin/ldd instead?)
2400 .if !defined(CROSSBUILD_HOST)
2401 # ldd is only needed for updating the running system so we don't need to
2402 # bootstrap ldd on non-FreeBSD systems
2403 _basic_bootstrap_tools+=usr.bin/ldd
2405 # sysctl/chflags are required for installkernel:
2406 .if !defined(CROSSBUILD_HOST)
2407 _basic_bootstrap_tools+=bin/chflags
2408 # Note: sysctl does not bootstrap on FreeBSD < 13 anymore, but that doesn't
2409 # matter since we don't need any of the new features for the build.
2410 _bootstrap_tools_links+=sysctl
2412 # When building on non-FreeBSD, install a fake chflags instead since the
2413 # version from the source tree cannot work. We also don't need sysctl since we
2414 # are install with -DNO_ROOT.
2415 _other_bootstrap_tools+=tools/build/cross-build/fake_chflags
2417 # mkfifo is used by sys/conf/newvers.sh
2418 _basic_bootstrap_tools+=usr.bin/mkfifo
2419 # jot is needed for the mkimg tests
2420 _basic_bootstrap_tools+=usr.bin/jot
2422 .if ${MK_BOOT} != "no"
2423 # md5 is used by boot/beri (and possibly others)
2424 _basic_bootstrap_tools+=sbin/md5
2427 .if ${MK_ZONEINFO} != "no"
2428 _basic_bootstrap_tools+=usr.sbin/zic usr.sbin/tzsetup
2431 .if defined(BOOTSTRAP_ALL_TOOLS)
2432 _other_bootstrap_tools+=${_basic_bootstrap_tools}
2433 .for _subdir _links in ${_basic_bootstrap_tools_multilink}
2434 _other_bootstrap_tools+=${_subdir}
2436 ${_bt}-usr.bin/awk: ${_bt_lex_depend} ${_bt}-usr.bin/yacc
2437 ${_bt}-bin/expr: ${_bt_lex_depend} ${_bt}-usr.bin/yacc
2438 # If we are bootstrapping file2c, we have to build it before config:
2439 ${_bt}-usr.sbin/config: ${_bt}-usr.bin/file2c ${_bt_lex_depend}
2440 # Note: no symlink to make/bmake in the !BOOTSTRAP_ALL_TOOLS case here since
2441 # the links to make/bmake make links will have already have been created in the
2442 # `make legacy` step. Not adding a link to make is important on non-FreeBSD
2443 # since "make" will usually point to GNU make there.
2444 _other_bootstrap_tools+=usr.bin/bmake
2446 # Avoid dependency on host bz2 headers:
2447 _other_bootstrap_tools+=lib/libbz2
2448 ${_bt}-usr.bin/grep: ${_bt}-lib/libbz2
2450 # All tools in _basic_bootstrap_tools have the same name as the subdirectory
2451 # so we can use :T to get the name of the symlinks that we need to create.
2452 _bootstrap_tools_links+=${_basic_bootstrap_tools:T}
2453 .for _subdir _links in ${_basic_bootstrap_tools_multilink}
2454 _bootstrap_tools_links+=${_links:S/,/ /g}
2456 .endif # defined(BOOTSTRAP_ALL_TOOLS)
2458 # Link the tools that we need for building but don't need to bootstrap because
2459 # the host version is known to be compatible into ${WORLDTMP}/legacy
2460 # We do this before building any of the bootstrap tools in case they depend on
2461 # the presence of any of the links (e.g. as m4/lex/awk)
2462 ${_bt}-links: .PHONY
2464 .for _tool in ${_bootstrap_tools_links}
2465 ${_bt}-link-${_tool}: .PHONY .MAKE
2466 @rm -f "${WORLDTMP}/legacy/bin/${_tool}"; \
2467 source_path=`which ${_tool}`; \
2468 if [ ! -e "$${source_path}" ] ; then \
2469 echo "Cannot find host tool '${_tool}'"; false; \
2471 cp -pf "$${source_path}" "${WORLDTMP}/legacy/bin/${_tool}"
2472 ${_bt}-links: ${_bt}-link-${_tool}
2475 bootstrap-tools: ${_bt}-links .PHONY
2477 # Please document (add comment) why something is in 'bootstrap-tools'.
2478 # Try to bound the building of the bootstrap-tool to just the
2479 # FreeBSD versions that need the tool built at this stage of the build.
2482 ${_kerberos5_bootstrap_tools} \
2487 ${_elftoolchain_libs} \
2495 ${_other_bootstrap_tools} \
2508 ${LOCAL_BSTOOL_DIRS}
2509 ${_bt}-${_tool}: ${_bt}-links .PHONY .MAKE
2510 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2511 cd ${.CURDIR}/${_tool}; \
2512 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2513 if [ "${_tool}" = "usr.bin/lex" ]; then \
2514 ${MAKE} DIRPRFX=${_tool}/ bootstrap; \
2516 ${MAKE} DIRPRFX=${_tool}/ all; \
2517 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy install
2519 bootstrap-tools: ${_bt}-${_tool}
2521 .if target(${_bt}-lib/libmd)
2522 # If we are bootstrapping libmd (e.g. when building on macOS/Linux) add the
2523 # necessary dependencies:
2524 ${_bt}-usr.bin/sort: ${_bt}-lib/libmd
2525 ${_bt}-usr.bin/xinstall: ${_bt}-lib/libmd
2526 ${_bt}-sbin/md5: ${_bt}-lib/libmd
2531 # build-tools: Build special purpose build tools
2533 .if !defined(NO_SHARE) && ${MK_SYSCONS} != "no"
2534 _share= share/syscons/scrnmaps
2537 .if ${MK_RESCUE} != "no"
2538 # rescue includes programs that have build-tools targets
2539 _rescue=rescue/rescue
2542 .if ${MK_TCSH} != "no"
2545 .if ${MK_FILE} != "no"
2546 _libmagic=lib/libmagic
2549 .if ${MK_PMC} != "no"
2550 _jevents=lib/libpmc/pmu-events
2553 # kernel-toolchain skips _cleanobj, so handle cleaning up previous
2554 # build-tools directories if needed.
2555 .if ${MK_CLEAN} == "yes" && make(kernel-toolchain)
2556 _bt_clean= ${CLEANDIR}
2562 ${LOCAL_TOOL_DIRS} \
2564 lib/ncurses/ncurses \
2570 build-tools_${_tool}: .PHONY
2571 ${_+_}@${ECHODIR} "===> ${_tool} (${_bt_clean:D${_bt_clean},}obj,build-tools)"; \
2572 cd ${.CURDIR}/${_tool}; \
2573 if [ -n "${_bt_clean}" ]; then ${MAKE} DIRPRFX=${_tool}/ ${_bt_clean}; fi; \
2574 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2575 ${MAKE} DIRPRFX=${_tool}/ build-tools
2576 build-tools: build-tools_${_tool}
2580 # kernel-tools: Build kernel-building tools
2582 kernel-tools: .PHONY
2583 mkdir -p ${WORLDTMP}/usr
2584 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2585 -p ${WORLDTMP}/usr >/dev/null
2588 # cross-tools: All the tools needed to build the rest of the system after
2589 # we get done with the earlier stages. It is the last set of tools needed
2590 # to begin building the target binaries.
2592 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BUILD_WITH_STRICT_TMPPATH} != 0
2593 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
2594 _btxld= usr.sbin/btxld
2598 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
2599 # resulting from missing bug fixes or ELF Toolchain updates.
2600 .if ${MK_CDDL} != "no"
2601 _dtrace_tools= cddl/lib/libctf cddl/lib/libspl cddl/usr.bin/ctfconvert \
2602 cddl/usr.bin/ctfmerge
2605 # If we're given an XAS, don't build binutils.
2606 .if ${XAS:M/*} == ""
2607 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
2608 _elftctools= lib/libelftc \
2614 # These are not required by the build, but can be useful for developers who
2615 # cross-build on a FreeBSD 10 host:
2616 _elftctools+= usr.bin/addr2line
2618 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
2619 # If cross-building with an external binutils we still need to build strip for
2620 # the target (for at least crunchide).
2621 _elftctools= lib/libelftc \
2626 .if ${MK_CLANG_BOOTSTRAP} != "no"
2627 _clang= usr.bin/clang
2629 .if ${MK_LLD_BOOTSTRAP} != "no"
2630 _lld= usr.bin/clang/lld
2632 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no"
2633 _clang_libs= lib/clang
2635 .if ${MK_USB} != "no"
2636 _usb_tools= stand/usb/tools
2639 .if ${BUILD_WITH_STRICT_TMPPATH} != 0 || defined(BOOTSTRAP_ALL_TOOLS)
2643 cross-tools: .MAKE .PHONY
2645 ${LOCAL_XTOOL_DIRS} \
2654 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2655 cd ${.CURDIR}/${_tool}; \
2656 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2657 ${MAKE} DIRPRFX=${_tool}/ all; \
2658 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP} install
2662 # native-xtools is the current target for qemu-user cross builds of ports
2663 # via poudriere and the imgact_binmisc kernel module.
2664 # This target merely builds a toolchan/sysroot, then builds the tools it wants
2665 # with the options it wants in a special MAKEOBJDIRPREFIX, using the toolchain
2666 # already built. It then installs the static tools to NXBDESTDIR for Poudriere
2669 NXBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/nxb/
2670 NXBOBJTOP= ${NXBOBJROOT}${NXB_TARGET}.${NXB_TARGET_ARCH}
2673 .error NXTP variable should be an absolute path
2675 NXBDESTDIR?= ${DESTDIR}${NXTP}
2677 # This is the list of tools to be built/installed as static and where
2678 # appropriate to build for the given TARGET.TARGET_ARCH.
2742 SUBDIR_DEPEND_usr.bin/clang= lib/clang
2743 .if ${MK_CLANG} != "no"
2745 NXBDIRS+= usr.bin/clang
2747 # XXX: native-xtools passes along ${NXBDIRS} in SUBDIR_OVERRIDE that needs
2748 # to be evaluated after NXBDIRS is set.
2749 .if make(install) && !empty(SUBDIR_OVERRIDE)
2750 SUBDIR= ${SUBDIR_OVERRIDE}
2754 OBJTOP=${NXBOBJTOP:Q} \
2755 OBJROOT=${NXBOBJROOT:Q} \
2760 MK_CLANG_EXTRAS=no \
2761 MK_CLANG_FORMAT=no \
2783 .if make(native-xtools*) && \
2784 (!defined(NXB_TARGET) || !defined(NXB_TARGET_ARCH))
2785 .error Missing NXB_TARGET / NXB_TARGET_ARCH
2787 # For 'toolchain' we want to produce native binaries that themselves generate
2789 NXBTMAKE= ${NXBMAKEENV} ${MAKE} ${NXBMAKEARGS:N-DNO_PIC:N-DNO_SHARED} \
2790 TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH}
2791 # For 'everything' we want to produce native binaries (hence -target to
2792 # be MACHINE) that themselves generate TARGET.TARGET_ARCH binaries.
2793 # TARGET/TARGET_ARCH are still passed along from user.
2795 # Use the toolchain we create as an external toolchain.
2796 .if ${USING_SYSTEM_COMPILER} == "yes" || ${XCC:N${CCACHE_BIN}:M/*}
2797 NXBMAKE+= XCC="${XCC}" \
2801 NXBMAKE+= XCC="${NXBOBJTOP}/tmp/usr/bin/cc" \
2802 XCXX="${NXBOBJTOP}/tmp/usr/bin/c++" \
2803 XCPP="${NXBOBJTOP}/tmp/usr/bin/cpp"
2805 NXBMAKE+= ${NXBMAKEENV} ${MAKE} -f Makefile.inc1 ${NXBMAKEARGS} \
2806 MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} \
2807 TARGET=${NXB_TARGET} TARGET_ARCH=${NXB_TARGET_ARCH} \
2808 TARGET_TRIPLE=${MACHINE_TRIPLE:Q}
2809 # NXBDIRS is improperly based on MACHINE rather than NXB_TARGET. Need to
2810 # invoke a sub-make to reevaluate MK_CLANG, etc, for NXBDIRS.
2811 NXBMAKE+= SUBDIR_OVERRIDE='$${NXBDIRS:M*}'
2812 # Need to avoid the -isystem logic when using clang as an external toolchain
2813 # even if the TARGET being built for wants GCC.
2814 NXBMAKE+= WANT_COMPILER_TYPE='$${X_COMPILER_TYPE}'
2815 native-xtools: .PHONY
2816 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _cleanobj
2817 # Build the bootstrap/host/cross tools that produce native binaries
2818 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} kernel-toolchain
2819 # Populate includes/libraries sysroot that produce native binaries.
2820 # This is split out from 'toolchain' above mostly so that target LLVM
2821 # libraries have a proper LLVM_DEFAULT_TARGET_TRIPLE without
2822 # polluting the cross-compiler build. The LLVM/GCC libs are skipped
2823 # here to avoid the problem but are kept in 'toolchain' so that
2824 # needed build tools are built.
2825 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes MK_CLANG=no
2826 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries MK_CLANG=no
2827 .if !defined(NO_OBJWALK)
2828 ${_+_}cd ${.CURDIR}; ${NXBMAKE} _obj
2830 ${_+_}cd ${.CURDIR}; ${NXBMAKE} everything
2831 @echo ">> native-xtools done. Use 'make native-xtools-install' to install to a given DESTDIR"
2833 native-xtools-install: .PHONY
2834 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
2835 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2836 -p ${NXBDESTDIR}/usr >/dev/null
2837 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2838 -p ${NXBDESTDIR}/usr/include >/dev/null
2839 ${_+_}cd ${.CURDIR}; ${NXBMAKE} \
2840 DESTDIR=${NXBDESTDIR} \
2845 # hierarchy - ensure that all the needed directories are present
2847 hierarchy hier: .MAKE .PHONY
2848 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
2851 # libraries - build all libraries, and install them under ${DESTDIR}.
2853 # The list of libraries with dependents (${_prebuild_libs}) and their
2854 # interdependencies (__L) are built automatically by the
2855 # ${.CURDIR}/tools/make_libdeps.sh script.
2857 libraries: .MAKE .PHONY
2858 ${_+_}cd ${.CURDIR}; \
2859 ${MAKE} -f Makefile.inc1 _prereq_libs; \
2860 ${MAKE} -f Makefile.inc1 _startup_libs; \
2861 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
2862 ${MAKE} -f Makefile.inc1 _generic_libs
2865 # static libgcc.a prerequisite for shared libc
2867 _prereq_libs= lib/libcompiler_rt
2868 .if ${MK_SSP} != "no"
2869 _prereq_libs+= lib/libssp_nonshared
2872 # These dependencies are not automatically generated:
2874 # lib/csu and lib/libc must be built before
2875 # all shared libraries for ELF.
2877 _startup_libs= lib/csu
2878 _startup_libs+= lib/libc
2879 _startup_libs+= lib/libc_nonshared
2880 .if ${MK_LIBCPLUSPLUS} != "no"
2881 _startup_libs+= lib/libcxxrt
2884 _prereq_libs+= lib/libgcc_eh lib/libgcc_s
2885 _startup_libs+= lib/libgcc_eh lib/libgcc_s
2887 lib/libgcc_s__L: lib/libc__L
2888 lib/libgcc_s__L: lib/libc_nonshared__L
2889 .if ${MK_LIBCPLUSPLUS} != "no"
2890 lib/libcxxrt__L: lib/libgcc_s__L
2893 _prebuild_libs= ${_kerberos5_lib_libasn1} \
2894 ${_kerberos5_lib_libhdb} \
2895 ${_kerberos5_lib_libheimbase} \
2896 ${_kerberos5_lib_libheimntlm} \
2898 ${_kerberos5_lib_libheimipcc} \
2899 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
2900 ${_kerberos5_lib_libroken} \
2901 ${_kerberos5_lib_libwind} \
2902 lib/libbz2 ${_libcom_err} lib/libcrypt \
2903 lib/libelf lib/libexpat \
2907 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
2910 lib/ncurses/ncurses \
2911 lib/libopie lib/libpam/libpam lib/libthr \
2912 ${_lib_libradius} lib/libsbuf lib/libtacplus \
2914 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
2915 ${_cddl_lib_libuutil} \
2916 ${_cddl_lib_libavl} \
2917 ${_cddl_lib_libicp} \
2918 ${_cddl_lib_libicp_rescue} \
2919 ${_cddl_lib_libspl} \
2920 ${_cddl_lib_libtpool} \
2921 ${_cddl_lib_libzfs_core} ${_cddl_lib_libzfs} \
2922 ${_cddl_lib_libzutil} \
2923 ${_cddl_lib_libctf} ${_cddl_lib_libzfsbootenv} \
2925 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
2926 ${_secure_lib_libcrypto} ${_secure_lib_libssl} \
2927 ${_lib_libldns} ${_secure_lib_libssh}
2929 .if ${MK_DIALOG} != "no"
2930 _prebuild_libs+= gnu/lib/libdialog
2931 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncurses__L
2934 .if ${MK_GOOGLETEST} != "no"
2935 _prebuild_libs+= lib/libregex
2938 .if ${MK_LIBCPLUSPLUS} != "no"
2939 _prebuild_libs+= lib/libc++
2942 lib/libgeom__L: lib/libexpat__L lib/libsbuf__L
2943 lib/libkvm__L: lib/libelf__L
2945 .if ${MK_RADIUS_SUPPORT} != "no"
2946 _lib_libradius= lib/libradius
2949 .if ${MK_OFED} != "no"
2951 lib/ofed/libibverbs \
2953 lib/ofed/libibumad \
2957 lib/ofed/libibmad__L: lib/ofed/libibumad__L
2958 lib/ofed/complib__L: lib/libthr__L
2959 lib/ofed/libmlx5__L: lib/ofed/libibverbs__L lib/libthr__L
2962 .if ${MK_CASPER} != "no"
2963 _lib_casper= lib/libcasper
2966 lib/libpjdlog__L: lib/libutil__L
2967 lib/libcasper__L: lib/libnv__L
2968 lib/liblzma__L: lib/libmd__L lib/libthr__L
2969 lib/libzstd__L: lib/libthr__L
2971 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib}
2972 .if ${MK_IPFILTER} != "no"
2973 _generic_libs+= sbin/ipf/libipf
2975 .for _DIR in ${LOCAL_LIB_DIRS}
2976 .if ${_DIR} == ".WAIT" || (empty(_generic_libs:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
2977 _generic_libs+= ${_DIR}
2981 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2983 .if ${MK_CDDL} != "no"
2984 _cddl_lib_libumem= cddl/lib/libumem
2985 _cddl_lib_libnvpair= cddl/lib/libnvpair
2986 _cddl_lib_libavl= cddl/lib/libavl
2987 _cddl_lib_libuutil= cddl/lib/libuutil
2988 _cddl_lib_libspl= cddl/lib/libspl
2990 cddl/lib/libuutil__L: cddl/lib/libavl__L cddl/lib/libspl__L
2992 .if ${MK_ZFS} != "no"
2993 _cddl_lib_libicp= cddl/lib/libicp
2994 _cddl_lib_libicp_rescue= cddl/lib/libicp_rescue
2995 _cddl_lib_libtpool= cddl/lib/libtpool
2996 _cddl_lib_libzutil= cddl/lib/libzutil
2997 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2998 _cddl_lib_libzfs= cddl/lib/libzfs
2999 _cddl_lib_libzfsbootenv= cddl/lib/libzfsbootenv
3001 cddl/lib/libtpool__L: cddl/lib/libspl__L
3003 cddl/lib/libzutil__L: cddl/lib/libavl__L cddl/lib/libtpool__L
3005 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
3007 cddl/lib/libzfs__L: cddl/lib/libzfs_core__L lib/msun__L lib/libutil__L
3008 cddl/lib/libzfs__L: lib/libthr__L lib/libmd__L lib/libz__L cddl/lib/libumem__L
3009 cddl/lib/libzfs__L: cddl/lib/libuutil__L cddl/lib/libavl__L lib/libgeom__L
3010 cddl/lib/libzfs__L: cddl/lib/libnvpair__L cddl/lib/libzutil__L
3011 cddl/lib/libzfs__L: secure/lib/libcrypto__L
3013 cddl/lib/libzfsbootenv__L: cddl/lib/libzfs__L
3014 lib/libbe__L: cddl/lib/libzfs__L cddl/lib/libzfsbootenv__L
3016 _cddl_lib_libctf= cddl/lib/libctf
3018 cddl/lib/libctf__L: lib/libz__L cddl/lib/libspl__L
3020 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db
3021 _prebuild_libs+= lib/libprocstat lib/libproc lib/librtld_db
3022 lib/libprocstat__L: lib/libelf__L lib/libkvm__L lib/libutil__L
3023 lib/libproc__L: lib/libprocstat__L
3024 lib/librtld_db__L: lib/libprocstat__L
3026 .if ${MK_CRYPT} != "no"
3027 .if ${MK_OPENSSL} != "no"
3028 _secure_lib_libcrypto= secure/lib/libcrypto
3029 _secure_lib_libssl= secure/lib/libssl
3030 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
3031 secure/lib/libcrypto__L: lib/libthr__L
3032 .if ${MK_LDNS} != "no"
3033 _lib_libldns= lib/libldns
3034 lib/libldns__L: secure/lib/libssl__L
3036 .if ${MK_OPENSSH} != "no"
3037 _secure_lib_libssh= secure/lib/libssh
3038 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
3039 .if ${MK_LDNS} != "no"
3040 secure/lib/libssh__L: lib/libldns__L
3042 .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no"
3043 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
3044 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
3045 lib/libmd__L kerberos5/lib/libroken__L
3049 _secure_lib= secure/lib
3052 .if ${MK_KERBEROS} != "no"
3053 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
3054 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
3055 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
3056 kerberos5/lib/libwind__L lib/libsqlite3__L
3057 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
3058 kerberos5/lib/libroken__L lib/libcom_err__L
3059 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
3060 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
3061 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
3062 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
3063 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
3064 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
3065 kerberos5/lib/libroken__L: lib/libcrypt__L
3066 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
3067 kerberos5/lib/libheimbase__L: lib/libthr__L
3068 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
3071 lib/libsqlite3__L: lib/libthr__L
3073 .if ${MK_GSSAPI} != "no"
3074 _lib_libgssapi= lib/libgssapi
3077 .if ${MK_KERBEROS} != "no"
3078 _kerberos5_lib= kerberos5/lib
3079 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
3080 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
3081 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
3082 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
3083 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
3084 _kerberos5_lib_libroken= kerberos5/lib/libroken
3085 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
3086 _libsqlite3= lib/libsqlite3
3087 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
3088 _kerberos5_lib_libwind= kerberos5/lib/libwind
3089 _libcom_err= lib/libcom_err
3092 .if ${MK_NIS} != "no"
3093 _lib_libypclnt= lib/libypclnt
3096 .if ${MK_OPENSSL} == "no"
3097 lib/libradius__L: lib/libmd__L
3101 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
3102 .if ${MK_CXX} != "no" && ${MK_LIBCPLUSPLUS} != "no"
3103 lib/libproc__L: lib/libcxxrt__L
3106 .for _lib in ${_prereq_libs}
3107 ${_lib}__PL: .PHONY .MAKE
3108 .if !defined(_MKSHOWCONFIG) && exists(${.CURDIR}/${_lib})
3109 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
3110 cd ${.CURDIR}/${_lib}; \
3111 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
3112 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
3113 DIRPRFX=${_lib}/ all; \
3114 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
3115 DIRPRFX=${_lib}/ install
3119 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
3120 ${_lib}__L: .PHONY .MAKE
3121 .if !defined(_MKSHOWCONFIG) && exists(${.CURDIR}/${_lib})
3122 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
3123 cd ${.CURDIR}/${_lib}; \
3124 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
3125 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
3126 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
3130 _prereq_libs: ${_prereq_libs:S/$/__PL/}
3131 _startup_libs: ${_startup_libs:S/$/__L/}
3132 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
3133 _generic_libs: ${_generic_libs:S/$/__L/}
3135 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
3136 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
3137 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
3138 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
3139 # parallel. This is safe for the world stage of buildworld though since it has
3140 # already built libraries in a proper order and installed includes into
3141 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
3142 # avoid trashing a system if it crashes mid-install.
3143 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
3147 .include <bsd.subdir.mk>
3149 .if make(check-old) || make(check-old-dirs) || \
3150 make(check-old-files) || make(check-old-libs) || \
3151 make(delete-old) || make(delete-old-dirs) || \
3152 make(delete-old-files) || make(delete-old-libs)
3155 # check for / delete old files section
3158 .include "ObsoleteFiles.inc"
3160 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
3161 else you can not start such an application. Consult UPDATING for more \
3162 information regarding how to cope with the removal/revision bump of a \
3165 .if !defined(BATCH_DELETE_OLD_FILES)
3171 delete-old-files: .PHONY
3172 @echo ">>> Removing old files (only deletes safe to delete libs)"
3173 # Ask for every old file if the user really wants to remove it.
3174 # It's annoying, but better safe than sorry.
3175 # NB: We cannot pass the list of OLD_FILES as a parameter because the
3176 # argument list will get too long. Using .for/.endfor make "loops" will make
3177 # the Makefile parser segfault.
3180 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3181 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | sort | \
3182 while read file; do \
3183 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3184 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
3185 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
3187 for ext in debug symbols; do \
3188 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
3189 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3190 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
3195 # Remove catpages without corresponding manpages.
3197 find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | sort | \
3198 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
3199 while read catpage; do \
3201 if [ ! -e "$${manpage}" ]; then \
3202 rm ${RM_I} $${catpage} <&3; \
3205 @echo ">>> Old files removed"
3207 check-old-files: .PHONY
3208 @echo ">>> Checking for old files"
3210 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3211 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
3212 while read file; do \
3213 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3214 echo "${DESTDIR}/$${file}"; \
3216 for ext in debug symbols; do \
3217 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3218 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
3222 # Check for catpages without corresponding manpages.
3223 @find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \
3224 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
3225 while read catpage; do \
3227 if [ ! -e "$${manpage}" ]; then \
3232 delete-old-libs: .PHONY
3233 @echo ">>> Removing old libraries"
3234 @echo "${OLD_LIBS_MESSAGE}" | fmt
3237 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3238 -V OLD_LIBS | xargs -n1 | sort | \
3239 while read file; do \
3240 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3241 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
3242 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
3244 for ext in debug symbols; do \
3245 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
3246 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3247 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
3252 @echo ">>> Old libraries removed"
3254 check-old-libs: .PHONY
3255 @echo ">>> Checking for old libraries"
3257 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3258 -V OLD_LIBS | xargs -n1 | \
3259 while read file; do \
3260 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3261 echo "${DESTDIR}/$${file}"; \
3263 for ext in debug symbols; do \
3264 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3265 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
3270 delete-old-dirs: .PHONY
3271 @echo ">>> Removing old directories"
3273 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3274 -V OLD_DIRS | xargs -n1 | sort -r | \
3275 while read dir; do \
3276 if [ -d "${DESTDIR}/$${dir}" ]; then \
3277 rmdir -v "${DESTDIR}/$${dir}" || true; \
3278 elif [ -L "${DESTDIR}/$${dir}" ]; then \
3279 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
3281 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3282 rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \
3283 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3284 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
3287 @echo ">>> Old directories removed"
3289 check-old-dirs: .PHONY
3290 @echo ">>> Checking for old directories"
3292 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3293 -V OLD_DIRS | xargs -n1 | sort -r | \
3294 while read dir; do \
3295 if [ -d "${DESTDIR}/$${dir}" ]; then \
3296 echo "${DESTDIR}/$${dir}"; \
3297 elif [ -L "${DESTDIR}/$${dir}" ]; then \
3298 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
3300 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3301 echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \
3302 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3303 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
3307 delete-old: delete-old-files delete-old-dirs .PHONY
3308 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
3310 check-old: check-old-files check-old-libs check-old-dirs .PHONY
3311 @echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
3312 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
3317 # showconfig - show build configuration.
3320 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes; \
3321 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes) 2>&1 | grep ^MK_ | sort -u
3323 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
3324 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
3326 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
3327 .if !defined(_MKSHOWCONFIG) && exists(${KERNCONFDIR}/${KERNCONF})
3328 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
3329 '${KERNCONFDIR}/${KERNCONF}' ; echo
3335 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
3336 DTBOUTPUTPATH= ${.CURDIR}
3340 # Build 'standalone' Device Tree Blob
3343 @PATH=${TMPPATH} MACHINE=${TARGET} \
3344 sh ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
3345 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
3350 # In the following, the first 'rm' in a series will usually remove all
3351 # files and directories. If it does not, then there are probably some
3352 # files with file flags set, so this unsets them and tries the 'rm' a
3353 # second time. There are situations where this target will be cleaning
3354 # some directories via more than one method, but that duplication is
3355 # needed to correctly handle all the possible situations. Removing all
3356 # files without file flags set in the first 'rm' instance saves time,
3357 # because 'chflags' will need to operate on fewer files afterwards.
3359 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
3360 # created by bsd.obj.mk, except that we don't want to .include that file
3361 # in this makefile. We don't do a cleandir walk if MK_AUTO_OBJ is yes
3362 # since it is not possible for files to land in the wrong place.
3364 .if make(cleanworld)
3365 BW_CANONICALOBJDIR:=${OBJTOP}/
3366 .elif make(cleanuniverse)
3367 BW_CANONICALOBJDIR:=${OBJROOT}
3368 .if ${MK_UNIFIED_OBJDIR} == "no"
3369 .error ${.TARGETS} only supported with WITH_UNIFIED_OBJDIR enabled.
3372 cleanworld cleanuniverse: .PHONY
3373 .if !empty(BW_CANONICALOBJDIR) && exists(${BW_CANONICALOBJDIR}) && \
3374 ${.CURDIR:tA} != ${BW_CANONICALOBJDIR:tA}
3375 -rm -rf ${BW_CANONICALOBJDIR}*
3376 -chflags -R 0 ${BW_CANONICALOBJDIR}
3377 rm -rf ${BW_CANONICALOBJDIR}*
3379 .if make(cleanworld) && ${MK_AUTO_OBJ} == "no" && \
3380 (empty(BW_CANONICALOBJDIR) || ${.CURDIR:tA} == ${BW_CANONICALOBJDIR:tA})
3381 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
3382 # To be safe in this case, fall back to a 'make cleandir'
3383 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
3387 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
3388 XDEV_CPUTYPE?=${CPUTYPE}
3390 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
3393 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
3394 MK_MAN=no MK_NLS=no MK_PROFILE=no \
3395 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WERROR=no \
3396 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
3397 CPUTYPE=${XDEV_CPUTYPE}
3399 XDDIR=${TARGET_ARCH}-freebsd
3402 .error XDTP variable should be an absolute path
3405 CDBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/xdev/
3406 CDBOBJTOP= ${CDBOBJROOT}${XDDIR}
3408 INSTALL="sh ${.CURDIR}/tools/install.sh"
3410 TOOLS_PREFIX=${XDTP}
3412 OBJTOP=${CDBOBJTOP:Q} \
3413 OBJROOT=${CDBOBJROOT:Q}
3414 CD2MAKEARGS= ${CDMAKEARGS}
3416 .if ${WANT_COMPILER_TYPE} == gcc || \
3417 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
3418 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
3419 # won't set header path and -L is used to ensure the base library path
3420 # is added before the port PREFIX library path.
3421 CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib
3422 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
3423 # combined with --sysroot.
3424 CD2CFLAGS+= -B${XDDESTDIR}/usr/lib
3425 # Force using libc++ for external GCC.
3426 .if defined(X_COMPILER_TYPE) && \
3427 ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
3428 CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \
3432 CD2CFLAGS+= --sysroot=${XDDESTDIR}/
3433 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \
3434 CPP="${CPP} ${CD2CFLAGS}" \
3435 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
3437 CDTMP= ${OBJTOP}/${XDDIR}/tmp
3438 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${CDMAKEARGS} ${NOFUN}
3439 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} \
3440 ${MAKE} ${CD2MAKEARGS} ${NOFUN}
3441 .if ${MK_META_MODE} != "no"
3442 # Don't rebuild build-tools targets during normal build.
3443 CD2MAKE+= BUILD_TOOLS_META=.NOMETA
3445 XDDESTDIR=${DESTDIR}${XDTP}
3447 .ORDER: xdev-build xdev-install xdev-links
3448 xdev: xdev-build xdev-install .PHONY
3450 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
3451 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
3453 _xb-worldtmp: .PHONY
3454 mkdir -p ${CDTMP}/usr
3455 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
3456 -p ${CDTMP}/usr >/dev/null
3458 _xb-bootstrap-tools: .PHONY
3462 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
3463 cd ${.CURDIR}/${_tool}; \
3464 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
3465 ${CDMAKE} DIRPRFX=${_tool}/ all; \
3466 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
3469 _xb-build-tools: .PHONY
3470 ${_+_}@cd ${.CURDIR}; \
3471 ${CDBENV} ${MAKE} ${CDMAKEARGS} -f Makefile.inc1 ${NOFUN} build-tools
3480 _xb-cross-tools: .PHONY
3481 .for _tool in ${XDEVDIRS}
3482 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
3483 cd ${.CURDIR}/${_tool}; \
3484 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
3485 ${CDMAKE} DIRPRFX=${_tool}/ all
3489 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
3490 mkdir -p ${XDDESTDIR}
3491 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.root.dist \
3492 -p ${XDDESTDIR} >/dev/null
3493 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
3494 -p ${XDDESTDIR}/usr >/dev/null
3495 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
3496 -p ${XDDESTDIR}/usr/include >/dev/null
3497 .if defined(_LIBCOMPAT)
3498 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
3499 -p ${XDDESTDIR}/usr >/dev/null
3501 .if ${MK_TESTS} != "no"
3502 mkdir -p ${XDDESTDIR}${TESTSBASE}
3503 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
3504 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
3507 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
3508 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
3510 _xi-cross-tools: .PHONY
3511 @echo "_xi-cross-tools"
3512 .for _tool in ${XDEVDIRS}
3513 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
3514 cd ${.CURDIR}/${_tool}; \
3515 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
3518 _xi-includes: .PHONY
3519 .if !defined(NO_OBJWALK)
3520 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 _obj \
3521 DESTDIR=${XDDESTDIR}
3523 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
3524 DESTDIR=${XDDESTDIR}
3526 _xi-libraries: .PHONY
3527 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
3528 DESTDIR=${XDDESTDIR}
3531 ${_+_}cd ${XDDESTDIR}/usr/bin; \
3532 mkdir -p ../../../../usr/bin; \
3534 ln -sf ../../${XDTP}/usr/bin/$$i \
3535 ../../../../usr/bin/${XDDIR}-$$i; \
3536 ln -sf ../../${XDTP}/usr/bin/$$i \
3537 ../../../../usr/bin/${XDDIR}${_REVISION}-$$i; \