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
46 # update - convenient way to update your source tree (eg: svn/svnup)
48 # Standard targets (not defined here) are documented in the makefiles in
49 # /usr/share/mk. These include:
50 # obj depend all install clean cleandepend cleanobj
52 .if !defined(TARGET) || !defined(TARGET_ARCH)
53 .error "Both TARGET and TARGET_ARCH must be defined."
56 .if make(showconfig) || make(test-system-*)
61 LOCALBASE?= /usr/local
63 .include "share/mk/src.tools.mk"
65 # Cross toolchain changes must be in effect before bsd.compiler.mk
66 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
67 .if defined(CROSS_TOOLCHAIN)
68 .if exists(${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk)
69 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
70 .elif exists(/usr/share/toolchains/${CROSS_TOOLCHAIN}.mk)
71 .include "/usr/share/toolchains/${CROSS_TOOLCHAIN}.mk"
72 .elif exists(${CROSS_TOOLCHAIN})
73 .include "${CROSS_TOOLCHAIN}"
75 .error CROSS_TOOLCHAIN ${CROSS_TOOLCHAIN} not found
77 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
79 .if defined(CROSS_TOOLCHAIN_PREFIX)
80 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
83 XCOMPILERS= CC CXX CPP
84 .for COMPILER in ${XCOMPILERS}
85 .if defined(CROSS_COMPILER_PREFIX)
86 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
88 X${COMPILER}?= ${${COMPILER}}
91 # If a full path to an external cross compiler is given, don't build
93 .if ${XCC:N${CCACHE_BIN}:M/*}
94 MK_CLANG_BOOTSTRAP= no
97 # Pull in compiler metadata from buildworld/toolchain if possible to avoid
98 # running CC from bsd.compiler.mk.
99 .if make(installworld) || make(install) || make(distributeworld) || \
101 .-include "${OBJTOP}/toolchain-metadata.mk"
102 .if !defined(_LOADED_TOOLCHAIN_METADATA)
103 .error A build is required first. You may have the wrong MAKEOBJDIRPREFIX set.
107 # Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early. Pull it from the
108 # tree to be friendlier to foreign OS builds. It's safe to do so unconditionally
109 # here since we will always have the right make, unlike in src/Makefile
110 # Don't include bsd.linker.mk yet until XBINUTILS is handled (after src.opts.mk)
111 _NO_INCLUDE_LINKERMK= t
112 # We also want the X_COMPILER* variables if we are using an external toolchain.
113 _WANT_TOOLCHAIN_CROSS_VARS= t
114 .include "share/mk/bsd.compiler.mk"
115 .undef _NO_INCLUDE_LINKERMK
116 .undef _WANT_TOOLCHAIN_CROSS_VARS
117 # src.opts.mk depends on COMPILER_FEATURES
118 .include "share/mk/src.opts.mk"
120 .if ${TARGET} == ${MACHINE}
121 TARGET_CPUTYPE?=${CPUTYPE}
125 .if !empty(TARGET_CPUTYPE)
126 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
128 _TARGET_CPUTYPE=dummy
130 .if ${TARGET} == "arm"
131 .if ${TARGET_ARCH:Marmv[67]*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
132 TARGET_ABI= gnueabihf
137 MACHINE_ABI?= unknown
138 MACHINE_TRIPLE?=${MACHINE_ARCH:S/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${MACHINE_ABI}-freebsd14.0
140 TARGET_TRIPLE?= ${TARGET_ARCH:S/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${TARGET_ABI}-freebsd14.0
141 KNOWN_ARCHES?= aarch64/arm64 \
158 powerpc64le/powerpc \
163 .if ${TARGET} == ${TARGET_ARCH}
166 _t= ${TARGET_ARCH}/${TARGET}
169 .if empty(KNOWN_ARCHES:M${_t})
170 .error Unknown target ${TARGET_ARCH}:${TARGET}.
174 .if ${.MAKE.OS} != "FreeBSD"
175 CROSSBUILD_HOST=${.MAKE.OS}
176 .if ${.MAKE.OS} != "Linux" && ${.MAKE.OS} != "Darwin"
177 .warning "Unsupported crossbuild system: ${.MAKE.OS}. Build will probably fail!"
179 # We need to force NO_ROOT/DB_FROM_SRC builds when building on other operating
180 # systems since the BSD.foo.dist specs contain users and groups that do not
181 # exist by default on a Linux/MacOS system.
187 # If all targets are disabled for system llvm then don't expect it to work
189 .if !defined(TOOLS_PREFIX) && ${MK_LLVM_TARGET_ALL} == "no" && \
190 ${MACHINE} != ${TARGET} && ${MACHINE_ARCH} != ${TARGET_ARCH} && \
192 MK_SYSTEM_COMPILER= no
196 # Handle external binutils.
197 .if defined(CROSS_TOOLCHAIN_PREFIX)
198 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
200 XBINUTILS= AS AR ELFCTL LD NM OBJCOPY RANLIB SIZE STRINGS STRIPBIN
201 .for BINUTIL in ${XBINUTILS}
202 .if defined(CROSS_BINUTILS_PREFIX) && \
203 exists(${CROSS_BINUTILS_PREFIX}/${${BINUTIL}})
204 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX:C,/*$,,}/${${BINUTIL}}
206 X${BINUTIL}?= ${${BINUTIL}}
210 # If a full path to an external linker is given, don't build lld.
215 # We also want the X_LINKER* variables if we are using an external toolchain.
216 _WANT_TOOLCHAIN_CROSS_VARS= t
217 .include "share/mk/bsd.linker.mk"
218 .undef _WANT_TOOLCHAIN_CROSS_VARS
220 # Begin WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD
222 # WITH_SYSTEM_COMPILER - Pull in needed values and make a decision.
224 # Check if there is a local compiler that can satisfy as an external compiler.
225 # Which compiler is expected to be used?
226 .if ${MK_CLANG_BOOTSTRAP} == "yes"
227 WANT_COMPILER_TYPE= clang
232 .if !defined(WANT_COMPILER_FREEBSD_VERSION) && !make(showconfig) && \
233 !make(test-system-linker)
234 .if ${WANT_COMPILER_TYPE} == "clang"
235 WANT_COMPILER_FREEBSD_VERSION_FILE= lib/clang/freebsd_cc_version.h
236 WANT_COMPILER_FREEBSD_VERSION!= \
237 awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
238 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
239 WANT_COMPILER_VERSION_FILE= lib/clang/include/clang/Basic/Version.inc
240 WANT_COMPILER_VERSION!= \
241 awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
242 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
244 .export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION
245 .endif # !defined(WANT_COMPILER_FREEBSD_VERSION)
247 # It needs to be the same revision as we would build for the bootstrap.
248 # If the expected vs CC is different then we can't skip.
249 # GCC cannot be used for cross-arch yet. For clang we pass -target later if
250 # TARGET_ARCH!=MACHINE_ARCH.
251 .if ${MK_SYSTEM_COMPILER} == "yes" && \
252 defined(WANT_COMPILER_FREEBSD_VERSION) && \
253 ${MK_CLANG_BOOTSTRAP} == "yes" && \
255 ${X_COMPILER_TYPE} == ${WANT_COMPILER_TYPE} && \
256 (${X_COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \
257 ${X_COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \
258 ${X_COMPILER_FREEBSD_VERSION} == ${WANT_COMPILER_FREEBSD_VERSION}
259 # Everything matches, disable the bootstrap compiler.
260 MK_CLANG_BOOTSTRAP= no
261 USING_SYSTEM_COMPILER= yes
262 .endif # ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE}
264 # WITH_SYSTEM_LD - Pull in needed values and make a decision.
266 # Check if there is a local linker that can satisfy as an external linker.
267 # Which linker is expected to be used?
268 .if ${MK_LLD_BOOTSTRAP} == "yes"
269 WANT_LINKER_TYPE= lld
274 .if !defined(WANT_LINKER_FREEBSD_VERSION) && !make(showconfig) && \
275 !make(test-system-compiler)
276 .if ${WANT_LINKER_TYPE} == "lld"
277 WANT_LINKER_FREEBSD_VERSION_FILE= lib/clang/include/VCSVersion.inc
278 _WANT_LINKER_FREEBSD_VERSION!= \
279 awk '$$2 == "LLD_REVISION" {gsub(/"/, "", $$3); print $$3}' \
280 ${SRCDIR}/${WANT_LINKER_FREEBSD_VERSION_FILE} || echo unknown
281 WANT_LINKER_FREEBSD_VERSION=${_WANT_LINKER_FREEBSD_VERSION:C/.*-(.*)/\1/}
282 WANT_LINKER_VERSION_FILE= lib/clang/include/lld/Common/Version.inc
283 WANT_LINKER_VERSION!= \
284 awk '$$2 == "LLD_VERSION_STRING" { gsub("\"", "", $$3); split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
285 ${SRCDIR}/${WANT_LINKER_VERSION_FILE} || echo unknown
287 WANT_LINKER_FREEBSD_VERSION_FILE=
288 WANT_LINKER_FREEBSD_VERSION=
290 .export WANT_LINKER_FREEBSD_VERSION WANT_LINKER_VERSION
291 .endif # !defined(WANT_LINKER_FREEBSD_VERSION)
293 .if ${MK_SYSTEM_LINKER} == "yes" && \
294 defined(WANT_LINKER_FREEBSD_VERSION) && \
295 (${MK_LLD_BOOTSTRAP} == "yes") && \
297 ${X_LINKER_TYPE} == ${WANT_LINKER_TYPE} && \
298 ${X_LINKER_VERSION} == ${WANT_LINKER_VERSION} && \
299 ${X_LINKER_FREEBSD_VERSION} == ${WANT_LINKER_FREEBSD_VERSION}
300 # Everything matches, disable the bootstrap linker.
302 USING_SYSTEM_LINKER= yes
303 .endif # ${WANT_LINKER_TYPE} == ${LINKER_TYPE}
305 # WITH_SYSTEM_COMPILER / WITH_SYSTEM_LINKER - Handle defaults and debug.
306 USING_SYSTEM_COMPILER?= no
307 USING_SYSTEM_LINKER?= no
309 TEST_SYSTEM_COMPILER_VARS= \
310 USING_SYSTEM_COMPILER MK_SYSTEM_COMPILER \
311 MK_CROSS_COMPILER MK_CLANG_BOOTSTRAP \
312 WANT_COMPILER_TYPE WANT_COMPILER_VERSION WANT_COMPILER_VERSION_FILE \
313 WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \
314 CC COMPILER_TYPE COMPILER_FEATURES COMPILER_VERSION \
315 COMPILER_FREEBSD_VERSION \
316 XCC X_COMPILER_TYPE X_COMPILER_FEATURES X_COMPILER_VERSION \
317 X_COMPILER_FREEBSD_VERSION
318 TEST_SYSTEM_LINKER_VARS= \
319 USING_SYSTEM_LINKER MK_SYSTEM_LINKER \
321 WANT_LINKER_TYPE WANT_LINKER_VERSION WANT_LINKER_VERSION_FILE \
322 WANT_LINKER_FREEBSD_VERSION WANT_LINKER_FREEBSD_VERSION_FILE \
323 LD LINKER_TYPE LINKER_FEATURES LINKER_VERSION \
324 LINKER_FREEBSD_VERSION \
325 XLD X_LINKER_TYPE X_LINKER_FEATURES X_LINKER_VERSION \
326 X_LINKER_FREEBSD_VERSION
328 .for _t in compiler linker
329 test-system-${_t}: .PHONY
330 .for v in ${TEST_SYSTEM_${_t:tu}_VARS}
331 ${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}"
334 .if (make(buildworld) || make(buildkernel) || make(kernel-toolchain) || \
335 make(toolchain) || make(_cross-tools))
336 .if ${USING_SYSTEM_COMPILER} == "yes"
337 .info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler.
338 .elif ${MK_CLANG_BOOTSTRAP} == "yes"
339 .info SYSTEM_COMPILER: libclang will be built for bootstrapping a cross-compiler.
341 .if ${USING_SYSTEM_LINKER} == "yes"
342 .info SYSTEM_LINKER: Determined that LD=${LD} matches the source tree. Not bootstrapping a cross-linker.
343 .elif ${MK_LLD_BOOTSTRAP} == "yes"
344 .info SYSTEM_LINKER: libclang will be built for bootstrapping a cross-linker.
348 # End WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD
350 # Store some compiler metadata for use in installworld where we don't
351 # want to invoke CC at all.
352 _TOOLCHAIN_METADATA_VARS= COMPILER_VERSION \
355 COMPILER_FREEBSD_VERSION \
356 COMPILER_RESOURCE_DIR \
360 LINKER_FREEBSD_VERSION
361 toolchain-metadata.mk: .PHONY .META
363 @echo ".info Using cached toolchain metadata from build at $$(hostname) on $$(date)" \
365 @echo "_LOADED_TOOLCHAIN_METADATA=t" >> ${.TARGET}
366 .for v in ${_TOOLCHAIN_METADATA_VARS}
367 @echo "${v}=${${v}}" >> ${.TARGET}
368 @echo "X_${v}=${X_${v}}" >> ${.TARGET}
370 @echo ".export ${_TOOLCHAIN_METADATA_VARS}" >> ${.TARGET}
371 @echo ".export ${_TOOLCHAIN_METADATA_VARS:C,^,X_,}" >> ${.TARGET}
374 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
375 # keep the users system reasonably usable. For static->dynamic root upgrades,
376 # we don't want to install a dynamic binary without rtld and the needed
377 # libraries. More commonly, for dynamic root, we don't want to install a
378 # binary that requires a newer library version that hasn't been installed yet.
379 # This ordering is not a guarantee though. The only guarantee of a working
380 # system here would require fine-grained ordering of all components based
381 # on their dependencies.
382 .if !empty(SUBDIR_OVERRIDE)
383 SUBDIR= ${SUBDIR_OVERRIDE}
386 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
387 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
388 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
389 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
390 _REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
392 .for _DIR in ${LOCAL_LIB_DIRS}
393 .if ${_DIR} == ".WAIT" || (empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
397 .if !defined(NO_ROOT) && (make(installworld) || make(install))
398 # Ensure libraries are installed before progressing.
402 .if ${MK_CDDL} != "no"
406 .if ${MK_KERBEROS} != "no"
409 .if ${MK_RESCUE} != "no"
413 .if ${MK_CRYPT} != "no"
416 .if !defined(NO_SHARE)
419 .if ${MK_BOOT} != "no"
422 SUBDIR+=sys usr.bin usr.sbin
423 .if ${MK_TESTS} != "no"
427 # Local directories are built in parallel with the base system directories.
428 # Users may insert a .WAIT directive at the beginning or elsewhere within
429 # the LOCAL_DIRS and LOCAL_LIB_DIRS lists as needed.
430 .for _DIR in ${LOCAL_DIRS}
431 .if ${_DIR} == ".WAIT" || exists(${.CURDIR}/${_DIR}/Makefile)
436 # We must do etc/ last as it hooks into building the man whatis file
437 # by calling 'makedb' in share/man. This is only relevant for
438 # install/distribute so they build the whatis file after every manpage is
440 .if make(installworld) || make(install)
445 .endif # !empty(SUBDIR_OVERRIDE)
448 .warning The src.conf WITHOUT_CLEAN option can now be used instead of NOCLEAN.
451 .if defined(NO_CLEAN)
452 .info The src.conf WITHOUT_CLEAN option can now be used instead of NO_CLEAN.
455 .if defined(NO_CLEANDIR)
456 CLEANDIR= clean cleandepend
461 .if defined(WORLDFAST)
466 .if ${MK_META_MODE} == "yes"
467 # If filemon is used then we can rely on the build being incremental-safe.
468 # The .meta files will also track the build command and rebuild should
470 .if empty(.MAKE.MODE:Mnofilemon)
474 .if defined(NO_OBJWALK) || ${MK_AUTO_OBJ} == "yes"
478 .if !defined(NO_OBJWALK)
483 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
485 .if empty(SHELL:M*csh*)
486 BUILDENV_SHELL?=${SHELL}
488 BUILDENV_SHELL?=/bin/sh
491 .if !defined(_MKSHOWCONFIG)
492 .if !defined(VCS_REVISION) || empty(VCS_REVISION)
493 .if !defined(SVNVERSION_CMD) || empty(SVNVERSION_CMD)
494 . for _D in ${PATH:S,:, ,g}
495 . if exists(${_D}/svnversion)
496 SVNVERSION_CMD?=${_D}/svnversion
498 . if exists(${_D}/svnliteversion)
499 SVNVERSION_CMD?=${_D}/svnliteversion
503 _VCS_REVISION?= $$(eval ${SVNVERSION_CMD} ${SRCDIR})
504 . if !empty(_VCS_REVISION)
505 VCS_REVISION= $$(echo r${_VCS_REVISION})
510 .if !defined(GIT_CMD) || empty(GIT_CMD)
511 . for _P in /usr/bin /usr/local/bin
512 . if exists(${_P}/git)
519 .if !defined(OSRELDATE)
520 .if exists(/usr/include/osreldate.h)
521 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
522 /usr/include/osreldate.h
529 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
530 .for _V in BRANCH REVISION
532 _${_V}!= eval $$(awk '/^${_V}=/{print}' ${SRCTOP}/sys/conf/newvers.sh); echo $$${_V}
536 .if !defined(SRCRELDATE)
537 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
538 ${SRCDIR}/sys/sys/param.h
541 .if !defined(VERSION)
542 VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
546 .if !defined(PKG_VERSION)
547 _STRTIMENOW= %Y%m%d%H%M%S
548 _TIMENOW= ${_STRTIMENOW:gmtime}
549 .if ${_BRANCH:MCURRENT*} || ${_BRANCH:MSTABLE*} || ${_BRANCH:MPRERELEASE*}
550 _REVISION:= ${_REVISION:R}
551 EXTRA_REVISION= .snap${_TIMENOW}
552 .elif ${_BRANCH:MALPHA*}
553 EXTRA_REVISION= .a${_BRANCH:C/ALPHA([0-9]+).*/\1/}.${_TIMENOW}
554 .elif ${_BRANCH:MBETA*}
555 EXTRA_REVISION= .b${_BRANCH:C/BETA([0-9]+).*/\1/}.${_TIMENOW}
556 .elif ${_BRANCH:MRC*}
557 EXTRA_REVISION= .rc${_BRANCH:C/RC([0-9]+).*/\1/}.${_TIMENOW}
558 .elif ${_BRANCH:M*-p*}
559 EXTRA_REVISION= p${_BRANCH:C/.*-p([0-9]+$)/\1/}
561 PKG_VERSION:= ${_REVISION}${EXTRA_REVISION:C/[[:space:]]//g}
563 .endif # !defined(PKG_VERSION)
565 .if !defined(PKG_TIMESTAMP)
567 SOURCE_DATE_EPOCH= ${TIMEEPOCHNOW:gmtime}
569 SOURCE_DATE_EPOCH= ${PKG_TIMESTAMP}
572 PKG_NAME_PREFIX?= FreeBSD
573 PKG_MAINTAINER?= re@FreeBSD.org
574 PKG_WWW?= https://www.FreeBSD.org
575 .export PKG_NAME_PREFIX
576 .export PKG_MAINTAINER
579 .if !defined(_MKSHOWCONFIG)
580 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} -f /dev/null \
581 -m ${.CURDIR}/share/mk MK_AUTO_OBJ=no -V CPUTYPE
582 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
583 .error CPUTYPE global should be set with ?=.
587 BUILD_ARCH!= uname -p
588 # On some Linux systems uname -p returns "unknown" so skip this check there.
589 # This check only exists to tell people to use TARGET_ARCH instead of
590 # MACHINE_ARCH so skipping it when crossbuilding on non-FreeBSD should be fine.
591 .if ${MACHINE_ARCH} != ${BUILD_ARCH} && ${.MAKE.OS} == "FreeBSD"
592 .error To cross-build, set TARGET_ARCH.
595 WORLDTMP?= ${OBJTOP}/tmp
596 BPATH= ${CCACHE_WRAPPER_PATH_PFX}${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin:${WORLDTMP}/legacy/usr/libexec
597 XPATH= ${WORLDTMP}/bin:${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
599 # When building we want to find the cross tools before the host tools in ${BPATH}.
600 # We also need to add UNIVERSE_TOOLCHAIN_PATH so that we can find the shared
601 # toolchain files (clang, lld, etc.) during make universe/tinderbox
602 STRICTTMPPATH= ${XPATH}:${BPATH}:${UNIVERSE_TOOLCHAIN_PATH}
603 # We should not be using tools from /usr/bin accidentally since this could cause
604 # the build to break on other systems that don't have that tool. For now we
605 # still allow using the old behaviour (inheriting $PATH) if
606 # BUILD_WITH_STRICT_TMPPATH is set to 0 but this will eventually be removed.
608 # Currently strict $PATH can cause build failures and does not work yet with
609 # USING_SYSTEM_LINKER/USING_SYSTEM_COMPILER. Once these issues have been
610 # resolved it will be turned on by default.
611 BUILD_WITH_STRICT_TMPPATH?=0
612 .if defined(CROSSBUILD_HOST)
613 # When building on non-FreeBSD we can't rely on the tools in /usr/bin being compatible
614 # with what FreeBSD expects. Therefore we only use tools from STRICTTMPPATH
615 # during the world build stage. We build most tools during the bootstrap-tools
616 # phase but symlink host tools that are known to work instead of building them
617 BUILD_WITH_STRICT_TMPPATH:=1
619 .if ${BUILD_WITH_STRICT_TMPPATH} != 0
620 TMPPATH= ${STRICTTMPPATH}
622 TMPPATH= ${STRICTTMPPATH}:${PATH}
626 # Avoid running mktemp(1) unless actually needed.
627 # It may not be functional, e.g., due to new ABI
628 # when in the middle of installing over this system.
630 .if make(distributeworld) || make(installworld) || make(stageworld)
631 .if ${BUILD_WITH_STRICT_TMPPATH} != 0
632 MKTEMP=${WORLDTMP}/legacy/usr/bin/mktemp
633 .if !exists(${MKTEMP})
634 .error "mktemp binary doesn't exist in expected location: ${MKTEMP}"
639 INSTALLTMP!= ${MKTEMP} -d -u -t install
642 .if make(stagekernel) || make(distributekernel)
648 # Building a world goes through the following stages
650 # 1. legacy stage [BMAKE]
651 # This stage is responsible for creating compatibility
652 # shims that are needed by the bootstrap-tools,
653 # build-tools and cross-tools stages. These are generally
654 # APIs that tools from one of those three stages need to
655 # build that aren't present on the host.
656 # 1. bootstrap-tools stage [BMAKE]
657 # This stage is responsible for creating programs that
658 # are needed for backward compatibility reasons. They
659 # are not built as cross-tools.
660 # 2. build-tools stage [TMAKE]
661 # This stage is responsible for creating the object
662 # tree and building any tools that are needed during
663 # the build process. Some programs are listed during
664 # this phase because they build binaries to generate
665 # files needed to build these programs. This stage also
666 # builds the 'build-tools' target rather than 'all'.
667 # 3. cross-tools stage [XMAKE]
668 # This stage is responsible for creating any tools that
669 # are needed for building the system. A cross-compiler is one
670 # of them. This differs from build tools in two ways:
671 # 1. the 'all' target is built rather than 'build-tools'
672 # 2. these tools are installed into TMPPATH for stage 4.
673 # 4. world stage [WMAKE]
674 # This stage actually builds the world.
675 # 5. install stage (optional) [IMAKE]
676 # This stage installs a previously built world.
681 MINIMUM_SUPPORTED_OSREL?= 1002501
682 MINIMUM_SUPPORTED_REL?= 10.3
684 # Common environment for world related stages
686 MACHINE_ARCH=${TARGET_ARCH} \
688 CPUTYPE=${TARGET_CPUTYPE}
689 .if ${MK_META_MODE} != "no"
690 # Don't rebuild build-tools targets during normal build.
691 CROSSENV+= BUILD_TOOLS_META=.NOMETA
693 .if defined(TARGET_CFLAGS)
694 CROSSENV+= ${TARGET_CFLAGS}
696 .if (${TARGET} != ${MACHINE} && !defined(WITH_LOCAL_MODULES)) || \
697 defined(WITHOUT_LOCAL_MODULES)
698 CROSSENV+= LOCAL_MODULES=
701 BOOTSTRAPPING_OSRELDATE?=${OSRELDATE}
703 # bootstrap-tools stage
704 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
705 TOOLS_PREFIX=${TOOLS_PREFIX_UNDEF:U${WORLDTMP}} \
706 PATH=${BPATH}:${PATH} \
707 WORLDTMP=${WORLDTMP} \
708 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
709 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
711 OBJTOP='${WORLDTMP}/obj-tools' \
712 OBJROOT='$${OBJTOP}/' \
714 BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
715 BWPHASE=${.TARGET:C,^_,,} \
717 MK_HTML=no NO_LINT=yes MK_MAN=no MK_MAN_UTILS=yes \
718 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
719 -DNO_CPU_CFLAGS MK_WERROR=no MK_CTF=no \
720 MK_CLANG_EXTRAS=no MK_CLANG_FORMAT=no MK_CLANG_FULL=no \
721 MK_LLDB=no MK_RETPOLINE=no MK_TESTS=no \
725 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
727 .if empty(.MAKEOVERRIDES:MMK_LLVM_TARGET_ALL)
728 BMAKE+= MK_LLVM_TARGET_ALL=no
733 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
734 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
736 BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
737 BWPHASE=${.TARGET:C,^_,,} \
740 -DNO_CPU_CFLAGS MK_WERROR=no MK_CTF=no \
741 MK_CLANG_EXTRAS=no MK_CLANG_FORMAT=no MK_CLANG_FULL=no \
742 MK_LLDB=no MK_RETPOLINE=no MK_TESTS=no
745 # TOOLS_PREFIX set in BMAKE
747 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
748 MK_CLANG_IS_CC=${MK_CLANG_BOOTSTRAP} \
752 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
753 PATH=${BPATH}:${PATH} \
754 WORLDTMP=${WORLDTMP} \
755 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
758 TOOLS_PREFIX=${TOOLS_PREFIX_UNDEF:U${WORLDTMP}} \
759 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
761 OBJTOP='${WORLDTMP}/obj-kernel-tools' \
762 OBJROOT='$${OBJTOP}/' \
764 BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
766 MK_HTML=no -DNO_LINT MK_MAN=no \
767 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
768 -DNO_CPU_CFLAGS MK_RETPOLINE=no MK_WERROR=no MK_CTF=no
771 WMAKEENV= ${CROSSENV} \
772 INSTALL="${INSTALL_CMD} -U" \
777 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
779 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
782 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
783 CPP="${XCPP} ${XCFLAGS}" \
784 AS="${XAS}" AR="${XAR}" ELFCTL="${XELFCTL}" LD="${XLD}" \
785 LLVM_LINK="${XLLVM_LINK}" NM=${XNM} OBJCOPY="${XOBJCOPY}" \
786 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
787 SIZE="${XSIZE}" STRIPBIN="${XSTRIPBIN}"
789 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
790 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
791 # directory, but the compiler will look in the right place for its
792 # tools so we don't need to tell it where to look.
793 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
797 # The internal bootstrap compiler has a default sysroot set by TOOLS_PREFIX
798 # and target set by TARGET/TARGET_ARCH. However, there are several needs to
799 # always pass an explicit --sysroot and -target.
800 # - External compiler needs sysroot and target flags.
801 # - External ld needs sysroot.
802 # - To be clear about the use of a sysroot when using the internal compiler.
803 # - Easier debugging.
804 # - Allowing WITH_SYSTEM_COMPILER+WITH_META_MODE to work together due to
805 # the flip-flopping build command when sometimes using external and
806 # sometimes using internal.
807 # - Allow using lld which has no support for default paths.
808 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
809 BFLAGS+= -B${WORLDTMP}/usr/bin
811 .if ${WANT_COMPILER_TYPE} == gcc || \
812 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
813 .elif ${WANT_COMPILER_TYPE} == clang || \
814 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang)
815 XCFLAGS+= -target ${TARGET_TRIPLE}
817 XCFLAGS+= --sysroot=${WORLDTMP}
823 .if ${MK_LIB32} == "yes"
825 .include "Makefile.libcompat"
826 .elif ${MK_LIBSOFT} == "yes"
828 .include "Makefile.libcompat"
831 # META_MODE normally ignores host file changes since every build updates
832 # timestamps (see NO_META_IGNORE_HOST in sys.mk). There are known times
833 # when the ABI breaks though that we want to force rebuilding WORLDTMP
834 # to get updated host tools.
835 .if ${MK_META_MODE} == "yes" && ${MK_CLEAN} == "no" && \
836 !defined(NO_META_IGNORE_HOST) && !defined(NO_META_IGNORE_HOST_HEADERS) && \
837 !defined(_MKSHOWCONFIG)
838 # r318736 - ino64 major ABI breakage
839 META_MODE_BAD_ABI_VERS+= 1200031
841 .if !defined(OBJDIR_HOST_OSRELDATE)
842 .if exists(${OBJTOP}/host-osreldate.h)
843 OBJDIR_HOST_OSRELDATE!= \
844 awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
845 ${OBJTOP}/host-osreldate.h
846 .elif exists(${WORLDTMP}/usr/include/osreldate.h)
847 OBJDIR_HOST_OSRELDATE= 0
849 .export OBJDIR_HOST_OSRELDATE
852 # Note that this logic is the opposite of normal BOOTSTRAP handling. We want
853 # to compare the WORLDTMP's OSRELDATE to the host's OSRELDATE. If the WORLDTMP
854 # is older than the ABI-breakage OSRELDATE of the HOST then we rebuild.
855 .if defined(OBJDIR_HOST_OSRELDATE)
856 .for _ver in ${META_MODE_BAD_ABI_VERS}
857 .if ${OSRELDATE} >= ${_ver} && ${OBJDIR_HOST_OSRELDATE} < ${_ver}
858 _meta_mode_need_rebuild= ${_ver}
861 .if defined(_meta_mode_need_rebuild)
862 .info META_MODE: Rebuilding host tools due to ABI breakage in __FreeBSD_version ${_meta_mode_need_rebuild}.
863 NO_META_IGNORE_HOST_HEADERS= 1
864 .export NO_META_IGNORE_HOST_HEADERS
865 .endif # defined(_meta_mode_need_rebuild)
866 .endif # defined(OBJDIR_HOST_OSRELDATE)
867 .endif # ${MK_META_MODE} == "yes" && ${MK_CLEAN} == "no" ...
868 # This is only used for META_MODE+filemon to track what the oldest
869 # __FreeBSD_version is in WORLDTMP. This purposely does NOT have
870 # a make dependency on /usr/include/osreldate.h as the file should
871 # only be copied when it is missing or meta mode determines it has changed.
872 # Since host files are normally ignored without NO_META_IGNORE_HOST
873 # the file will never be updated unless that flag is specified. This
874 # allows tracking the oldest osreldate to force rebuilds via
875 # META_MODE_BADABI_REVS above.
876 host-osreldate.h: # DO NOT ADD /usr/include/osreldate.h here
877 .if !defined(CROSSBUILD_HOST)
878 @cp -f /usr/include/osreldate.h ${.TARGET}
880 @echo "#ifndef __FreeBSD_version" > ${.TARGET}
881 @echo "#define __FreeBSD_version ${OSRELDATE}" >> ${.TARGET}
882 @echo "#endif" >> ${.TARGET}
885 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
886 BWPHASE=${.TARGET:C,^_,,} \
889 IMAKEENV= ${CROSSENV}
890 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
891 ${IMAKE_INSTALL} ${IMAKE_MTREE}
892 .if empty(.MAKEFLAGS:M-n)
893 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
894 LD_LIBRARY_PATH=${INSTALLTMP} \
895 PATH_LOCALE=${INSTALLTMP}/locale
896 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
898 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
901 # When generating install media, do not allow user and group information from
902 # the build host to affect the contents of the distribution.
903 .if make(distributeworld) || make(distrib-dirs) || make(distribution) || \
908 .if defined(DB_FROM_SRC)
909 INSTALLFLAGS+= -N ${.CURDIR}/etc
910 MTREEFLAGS+= -N ${.CURDIR}/etc
912 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
913 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
915 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
916 METALOG:= ${METALOG:C,//+,/,g}
917 IMAKE+= -DNO_ROOT METALOG=${METALOG}
918 METALOG_INSTALLFLAGS= -U -M ${METALOG} -D ${INSTALL_DDIR}
919 INSTALLFLAGS+= ${METALOG_INSTALLFLAGS}
920 CERTCTLFLAGS= ${METALOG_INSTALLFLAGS}
923 .if defined(BUILD_PKGS)
924 INSTALLFLAGS+= -h sha256
926 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
927 IMAKE_INSTALL= INSTALL="${INSTALL_CMD} ${INSTALLFLAGS}"
928 IMAKE_MTREE= MTREE_CMD="${MTREE_CMD} ${MTREEFLAGS}"
930 .if make(distributeworld)
931 CERTCTLDESTDIR= ${DESTDIR}/${DISTDIR}/base
933 CERTCTLDESTDIR= ${DESTDIR}
936 DESTDIR_MTREEFLAGS= -deU
937 # When creating worldtmp we don't need to set the directories as owned by root
939 WORLDTMP_MTREEFLAGS= -deUW
941 # When building with -DNO_ROOT we shouldn't be changing the directories
942 # that are created by mtree to be owned by root/wheel.
943 DESTDIR_MTREEFLAGS+= -W
945 DISTR_MTREE= ${MTREE_CMD}
946 .if ${BUILD_WITH_STRICT_TMPPATH} != 0
947 DISTR_MTREE= ${WORLDTMP}/legacy/usr/sbin/mtree
949 WORLDTMP_MTREE= ${DISTR_MTREE} ${WORLDTMP_MTREEFLAGS}
950 DESTDIR_MTREE= ${DISTR_MTREE} ${DESTDIR_MTREEFLAGS}
953 KMAKEENV= ${WMAKEENV:NSYSROOT=*}
954 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
959 # Attempt to rebuild the entire system, with reasonable chance of
960 # success, regardless of how old your existing system is.
962 _sanity_check: .PHONY .MAKE
963 .if ${.CURDIR:C/[^,]//g} != ""
964 # The m4 build of sendmail files doesn't like it if ',' is used
965 # anywhere in the path of it's files.
967 @echo "*** Error: path to source tree contains a comma ','"
970 .elif ${.CURDIR:M*\:*} != ""
971 # Using ':' leaks into PATH and breaks finding cross-tools.
973 @echo "*** Error: path to source tree contains a colon ':'"
978 # Our current approach to dependency tracking cannot cope with certain source
979 # tree changes, particularly with respect to removing source files and
980 # replacing generated files. Handle these cases here in an ad-hoc fashion.
981 _cleanobj_fast_depend_hack: .PHONY
982 @echo ">>> Deleting stale dependencies...";
983 sh ${.CURDIR}/tools/build/depend-cleanup.sh ${OBJTOP}
987 @echo "--------------------------------------------------------------"
988 @echo ">>> Rebuilding the temporary build tree"
989 @echo "--------------------------------------------------------------"
990 .if ${MK_CLEAN} == "yes"
993 # Note: for delete-old we need to set $PATH to also include the host $PATH
994 # since otherwise a partial build with missing symlinks in ${WORLDTMP}/legacy/
995 # will fail to run due to missing binaries. $WMAKE sets PATH to only ${TMPPATH}
996 # so we remove that assingnment from $WMAKE and prepend the new $PATH
997 ${_+_}@if [ -e "${WORLDTMP}" ]; then \
998 echo ">>> Deleting stale files in build tree..."; \
999 cd ${.CURDIR}; env PATH=${TMPPATH}:${PATH} ${WMAKE:NPATH=*} \
1000 _NO_INCLUDE_COMPILERMK=t -DBATCH_DELETE_OLD_FILES delete-old \
1001 delete-old-libs >/dev/null; \
1003 rm -rf ${WORLDTMP}/legacy/usr/include
1004 .if ${USING_SYSTEM_COMPILER} == "yes"
1006 if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \
1007 inum=$$(stat -f %i ${WORLDTMP}/usr/bin/${cc}); \
1008 find ${WORLDTMP}/usr/bin -inum $${inum} -delete; \
1011 .endif # ${USING_SYSTEM_COMPILER} == "yes"
1012 .if ${USING_SYSTEM_LINKER} == "yes"
1013 @rm -f ${WORLDTMP}/usr/bin/ld ${WORLDTMP}/usr/bin/ld.lld
1014 .endif # ${USING_SYSTEM_LINKER} == "yes"
1015 .endif # ${MK_CLEAN} == "yes"
1016 @mkdir -p ${WORLDTMP}
1017 @touch ${WORLDTMP}/${.TARGET}
1018 # We can't use mtree to create the worldtmp directories since it may not be
1019 # available on the target system (this happens e.g. when building on non-FreeBSD)
1020 cd ${.CURDIR}/tools/build; \
1021 ${MAKE} DIRPRFX=tools/build/ DESTDIR=${WORLDTMP}/legacy installdirs
1022 # In order to build without inheriting $PATH we need to add symlinks to the host
1023 # tools in $WORLDTMP for the tools that we don't build during bootstrap-tools
1024 cd ${.CURDIR}/tools/build; \
1025 ${MAKE} DIRPRFX=tools/build/ DESTDIR=${WORLDTMP}/legacy host-symlinks
1029 @echo "--------------------------------------------------------------"
1030 @echo ">>> stage 1.1: legacy release compatibility shims"
1031 @echo "--------------------------------------------------------------"
1032 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
1035 @echo "--------------------------------------------------------------"
1036 @echo ">>> stage 1.2: bootstrap tools"
1037 @echo "--------------------------------------------------------------"
1038 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
1039 mkdir -p ${WORLDTMP}/usr ${WORLDTMP}/lib/casper ${WORLDTMP}/lib/geom \
1041 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1042 -p ${WORLDTMP}/usr >/dev/null
1043 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1044 -p ${WORLDTMP}/usr/include >/dev/null
1045 ln -sf ${.CURDIR}/sys ${WORLDTMP}
1046 .if ${MK_DEBUG_FILES} != "no"
1047 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1048 -p ${WORLDTMP}/usr/lib >/dev/null
1050 .for _mtree in ${LOCAL_MTREE}
1051 ${WORLDTMP_MTREE} -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
1054 .if ${MK_CLEAN} == "yes"
1056 @echo "--------------------------------------------------------------"
1057 @echo ">>> stage 2.1: cleaning up the object tree"
1058 @echo "--------------------------------------------------------------"
1059 # Avoid including bsd.compiler.mk in clean and obj with _NO_INCLUDE_COMPILERMK
1060 # since the restricted $PATH might not contain a valid cc binary
1061 ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t ${CLEANDIR}
1062 .if defined(_LIBCOMPAT)
1063 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} _NO_INCLUDE_COMPILERMK=t -f Makefile.inc1 ${CLEANDIR}
1066 ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t _cleanobj_fast_depend_hack
1067 .endif # ${MK_CLEAN} == "yes"
1070 @echo "--------------------------------------------------------------"
1071 @echo ">>> stage 2.2: rebuilding the object tree"
1072 @echo "--------------------------------------------------------------"
1073 ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t obj
1076 @echo "--------------------------------------------------------------"
1077 @echo ">>> stage 2.3: build tools"
1078 @echo "--------------------------------------------------------------"
1079 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
1082 @echo "--------------------------------------------------------------"
1083 @echo ">>> stage 3: cross tools"
1084 @echo "--------------------------------------------------------------"
1085 @rm -f ${OBJTOP}/toolchain-metadata.mk
1086 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
1087 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
1090 @echo "--------------------------------------------------------------"
1091 @echo ">>> stage 3.1: recording build metadata"
1092 @echo "--------------------------------------------------------------"
1093 ${_+_}cd ${.CURDIR}; ${WMAKE} toolchain-metadata.mk
1094 ${_+_}cd ${.CURDIR}; ${WMAKE} host-osreldate.h
1097 @echo "--------------------------------------------------------------"
1098 @echo ">>> stage 4.1: building includes"
1099 @echo "--------------------------------------------------------------"
1100 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
1101 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
1102 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
1103 MK_INCLUDES=yes includes
1104 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
1105 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
1109 @echo "--------------------------------------------------------------"
1110 @echo ">>> stage 4.2: building libraries"
1111 @echo "--------------------------------------------------------------"
1112 ${_+_}cd ${.CURDIR}; \
1113 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
1114 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS_SUPPORT} \
1118 @echo "--------------------------------------------------------------"
1119 @echo ">>> stage 4.4: building everything"
1120 @echo "--------------------------------------------------------------"
1121 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
1124 .if !defined(WORLDFAST)
1125 WMAKE_TGTS+= _sanity_check _worldtmp _legacy
1126 .if empty(SUBDIR_OVERRIDE)
1127 WMAKE_TGTS+= _bootstrap-tools
1129 WMAKE_TGTS+= _cleanobj
1130 .if !defined(NO_OBJWALK)
1133 WMAKE_TGTS+= _build-tools _cross-tools
1134 WMAKE_TGTS+= _build-metadata
1135 WMAKE_TGTS+= _includes
1137 .if !defined(NO_LIBS)
1138 WMAKE_TGTS+= _libraries
1140 .if defined(_LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
1141 WMAKE_TGTS+= build${libcompat}
1143 WMAKE_TGTS+= everything
1145 # record buildworld time in seconds
1146 .if make(buildworld)
1147 _BUILDWORLD_START!= date '+%s'
1148 .export _BUILDWORLD_START
1151 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
1152 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
1154 _ncpu_cmd=sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo unknown
1156 buildworld_prologue: .PHONY
1157 @echo "--------------------------------------------------------------"
1158 @echo ">>> World build started on `LC_ALL=C date`"
1159 @echo "--------------------------------------------------------------"
1161 buildworld_epilogue: .PHONY
1163 @echo "--------------------------------------------------------------"
1164 @echo ">>> World build completed on `LC_ALL=C date`"
1165 @seconds=$$(($$(date '+%s') - ${_BUILDWORLD_START})); \
1166 echo -n ">>> World built in $$seconds seconds, "; \
1167 echo "ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}"
1168 @echo "--------------------------------------------------------------"
1171 # We need to have this as a target because the indirection between Makefile
1172 # and Makefile.inc1 causes the correct PATH to be used, rather than a
1173 # modification of the current environment's PATH. In addition, we need
1174 # to quote multiword values.
1176 buildenvvars: .PHONY
1177 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
1179 .if ${.TARGETS:Mbuildenv}
1180 .if ${.MAKEFLAGS:M-j}
1181 .error The buildenv target is incompatible with -j
1184 BUILDENV_DIR?= ${.CURDIR}
1186 # Note: make will report any errors the shell reports. This can
1187 # be odd if the last command in an interactive shell generates an
1188 # error or is terminated by SIGINT. These reported errors look bad,
1189 # but are harmless. Allowing them also allows BUIDLENV_SHELL to
1190 # be a complex command whose status will be returned to the caller.
1191 # Some scripts in tools rely on this behavior to report build errors.
1194 @echo Entering world for ${TARGET_ARCH}:${TARGET}
1195 .if ${BUILDENV_SHELL:M*zsh*}
1196 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
1198 @cd ${BUILDENV_DIR} && env ${WMAKEENV} \
1199 INSTALL="${INSTALL_CMD} ${INSTALLFLAGS}" \
1200 MTREE_CMD="${MTREE_CMD} ${MTREEFLAGS}" BUILDENV=1 ${BUILDENV_SHELL}
1202 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
1203 toolchain: ${TOOLCHAIN_TGTS} .PHONY
1204 KERNEL_TOOLCHAIN_TGTS= ${TOOLCHAIN_TGTS:N_obj:N_cleanobj:N_includes:N_libraries}
1205 .if make(kernel-toolchain)
1206 .ORDER: ${KERNEL_TOOLCHAIN_TGTS}
1208 kernel-toolchain: ${KERNEL_TOOLCHAIN_TGTS} .PHONY
1213 # Checks to be sure system is ready for installworld/installkernel.
1215 installcheck: _installcheck_world _installcheck_kernel .PHONY
1216 _installcheck_world: .PHONY
1217 @echo "--------------------------------------------------------------"
1218 @echo ">>> Install check world"
1219 @echo "--------------------------------------------------------------"
1220 _installcheck_kernel: .PHONY
1221 @echo "--------------------------------------------------------------"
1222 @echo ">>> Install check kernel"
1223 @echo "--------------------------------------------------------------"
1226 # Require DESTDIR to be set if installing for a different architecture or
1227 # using the user/group database in the source tree.
1229 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
1230 defined(DB_FROM_SRC)
1231 .if !make(distributeworld)
1232 _installcheck_world: __installcheck_DESTDIR
1233 _installcheck_kernel: __installcheck_DESTDIR
1234 __installcheck_DESTDIR: .PHONY
1235 .if !defined(DESTDIR) || empty(DESTDIR)
1236 @echo "ERROR: Please set DESTDIR!"; \
1242 .if !defined(DB_FROM_SRC)
1244 # Check for missing UIDs/GIDs.
1246 CHECK_UIDS= auditdistd
1251 CHECK_GIDS+= proxy authpf
1254 CHECK_UIDS+= unbound
1255 CHECK_GIDS+= unbound
1256 _installcheck_world: __installcheck_UGID
1257 __installcheck_UGID: .PHONY
1258 .for uid in ${CHECK_UIDS}
1259 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
1260 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
1264 .for gid in ${CHECK_GIDS}
1265 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
1266 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
1272 # If installing over the running system (DESTDIR is / or unset) and the install
1273 # includes rescue, try running rescue from the objdir as a sanity check. If
1274 # rescue is not functional (e.g., because it depends on a system call not
1275 # supported by the currently running kernel), abort the installation.
1277 .if !make(distributeworld) && ${MK_RESCUE} != "no" && \
1278 (empty(DESTDIR) || ${DESTDIR} == "/") && empty(BYPASS_INSTALLCHECK_SH)
1279 _installcheck_world: __installcheck_sh_check
1280 __installcheck_sh_check: .PHONY
1281 @if [ "`${OBJTOP}/rescue/rescue/rescue sh -c 'echo OK'`" != \
1283 echo "rescue/sh check failed, installation aborted" >&2; \
1289 # Required install tools to be saved in a scratch dir for safety.
1291 .if ${MK_ZONEINFO} != "no"
1292 _zoneinfo= zic tzsetup
1295 .if !defined(CROSSBUILD_HOST)
1299 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
1300 date echo egrep find grep id install ${_install-info} \
1301 ln make mkdir mtree mv pwd_mkdb \
1302 rm sed services_mkdb sh sort strip ${_sysctl} test true uname wc \
1303 ${_zoneinfo} ${LOCAL_ITOOLS}
1305 # Needed for share/man
1306 .if ${MK_MAN_UTILS} != "no"
1313 # Distributes everything compiled by a `buildworld'.
1317 # Installs everything compiled by a 'buildworld'.
1320 # Non-base distributions produced by the base system
1321 EXTRA_DISTRIBUTIONS=
1322 .if defined(_LIBCOMPAT)
1323 EXTRA_DISTRIBUTIONS+= lib${libcompat}
1325 .if ${MK_TESTS} != "no"
1326 EXTRA_DISTRIBUTIONS+= tests
1329 DEBUG_DISTRIBUTIONS=
1330 .if ${MK_DEBUG_FILES} != "no"
1331 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,tests,,}
1334 MTREE_MAGIC?= mtree 2.0
1336 distributeworld installworld stageworld: _installcheck_world .PHONY
1337 mkdir -p ${INSTALLTMP}
1338 progs=$$(for prog in ${ITOOLS}; do \
1339 if progpath=`env PATH=${TMPPATH} which $$prog`; then \
1342 echo "Required tool $$prog not found in PATH ($$PATH)." >&2; \
1346 if [ -z "${CROSSBUILD_HOST}" ] ; then \
1347 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
1348 while read line; do \
1350 if [ "$$2 $$3" != "not found" ]; then \
1353 echo "Required library $$1 not found." >&2; \
1358 cp $$libs $$progs ${INSTALLTMP}
1359 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
1360 .if defined(NO_ROOT)
1361 -mkdir -p ${METALOG:H}
1362 echo "#${MTREE_MAGIC}" > ${METALOG}
1364 .if make(distributeworld)
1365 .for dist in ${EXTRA_DISTRIBUTIONS}
1366 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
1367 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1368 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
1369 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1370 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1371 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1372 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
1373 .if ${MK_DEBUG_FILES} != "no"
1374 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1375 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
1377 .if defined(_LIBCOMPAT)
1378 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1379 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1380 .if ${MK_DEBUG_FILES} != "no"
1381 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1382 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
1385 .if ${MK_TESTS} != "no" && ${dist} == "tests"
1386 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
1387 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1388 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
1389 .if ${MK_DEBUG_FILES} != "no"
1390 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1391 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
1394 .if defined(NO_ROOT)
1395 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1396 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1397 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1398 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1399 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1400 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1401 .if defined(_LIBCOMPAT)
1402 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
1403 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1407 -mkdir ${DESTDIR}/${DISTDIR}/base
1408 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1409 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1410 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1411 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1412 ${INSTALL_SYMLINK} ${INSTALLFLAGS} usr/src/sys ${INSTALL_DDIR}/base/sys
1413 .endif # make(distributeworld)
1414 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1415 ${IMAKEENV} rm -rf ${INSTALLTMP}
1416 .if make(distributeworld)
1417 .for dist in ${EXTRA_DISTRIBUTIONS}
1418 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete
1420 .if defined(NO_ROOT)
1421 .for dist in base ${EXTRA_DISTRIBUTIONS}
1422 @# For each file that exists in this dist, print the corresponding
1423 @# line from the METALOG. This relies on the fact that
1424 @# a line containing only the filename will sort immediately before
1425 @# the relevant mtree line.
1426 cd ${DESTDIR}/${DISTDIR}; \
1427 find ./${dist} | sort -u ${METALOG} - | \
1428 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1429 ${DESTDIR}/${DISTDIR}/${dist}.meta
1431 .for dist in ${DEBUG_DISTRIBUTIONS}
1432 @# For each file that exists in this dist, print the corresponding
1433 @# line from the METALOG. This relies on the fact that
1434 @# a line containing only the filename will sort immediately before
1435 @# the relevant mtree line.
1436 cd ${DESTDIR}/${DISTDIR}; \
1437 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1438 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1439 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1442 .endif # make(distributeworld)
1443 .if !make(packageworld) && ${MK_CAROOT} != "no"
1444 @if which openssl>/dev/null; then \
1445 DESTDIR=${CERTCTLDESTDIR} PATH=${TMPPATH}:${PATH} \
1446 sh ${SRCTOP}/usr.sbin/certctl/certctl.sh ${CERTCTLFLAGS} rehash \
1448 echo "No openssl on the host, not rehashing certificates target -- /etc/ssl may not be populated."; \
1452 packageworld: .PHONY
1453 .for dist in base ${EXTRA_DISTRIBUTIONS}
1454 .if defined(NO_ROOT)
1455 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1456 tar cvf - --exclude usr/lib/debug \
1457 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1458 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1460 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1461 tar cvf - --exclude usr/lib/debug . | \
1462 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1466 .for dist in ${DEBUG_DISTRIBUTIONS}
1467 . if defined(NO_ROOT)
1468 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1469 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1470 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1472 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1473 tar cvLf - usr/lib/debug | \
1474 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1479 ${_+_}cd ${.CURDIR}/tools/build/options; sh makeman > \
1480 ${.CURDIR}/share/man/man5/src.conf.5
1482 # We can't assume here that ${TMPPATH} will include ${PATH} or /usr/libexec
1483 # because we may be building with a STRICTTMPPATH, so we explicitly include
1484 # /usr/libexec here for flua. ${TMPPATH} still usefully includes anything else
1485 # we may need to function.
1486 _sysent_PATH= ${TMPPATH}:/usr/libexec
1487 _sysent_dirs= sys/kern
1488 _sysent_dirs+= sys/compat/freebsd32
1489 _sysent_dirs+= sys/compat/cloudabi32 \
1490 sys/compat/cloudabi64
1491 _sysent_dirs+= sys/amd64/linux \
1498 .for _dir in ${_sysent_dirs}
1499 sysent-${_dir}: .PHONY
1500 @echo "${MAKE} -C ${.CURDIR}/${_dir} sysent"
1501 ${_+_}@env PATH=${_sysent_PATH} ${MAKE} -C ${.CURDIR}/${_dir} sysent
1503 sysent: sysent-${_dir}
1509 # If you have a build server, you can NFS mount the source and obj directories
1510 # and do a 'make reinstall' on the *client* to install new binaries from the
1511 # most recent server build.
1513 restage reinstall: .MAKE .PHONY
1514 @echo "--------------------------------------------------------------"
1515 @echo ">>> Making hierarchy"
1516 @echo "--------------------------------------------------------------"
1517 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1518 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1520 @echo "--------------------------------------------------------------"
1521 @echo ">>> Making distribution"
1522 @echo "--------------------------------------------------------------"
1523 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1524 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
1527 @echo "--------------------------------------------------------------"
1528 @echo ">>> Installing everything started on `LC_ALL=C date`"
1529 @echo "--------------------------------------------------------------"
1530 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1531 .if defined(_LIBCOMPAT)
1532 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1534 @echo "--------------------------------------------------------------"
1535 @echo ">>> Installing everything completed on `LC_ALL=C date`"
1536 @echo "--------------------------------------------------------------"
1538 redistribute: .MAKE .PHONY
1539 @echo "--------------------------------------------------------------"
1540 @echo ">>> Distributing everything"
1541 @echo "--------------------------------------------------------------"
1542 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1543 .if defined(_LIBCOMPAT)
1544 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1545 DISTRIBUTION=lib${libcompat}
1548 distrib-dirs distribution: .MAKE .PHONY
1549 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1550 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1551 .if make(distribution)
1552 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1553 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1554 METALOG=${METALOG} MK_TESTS=no \
1555 MK_TESTS_SUPPORT=${MK_TESTS_SUPPORT} installconfig
1559 # buildkernel and installkernel
1561 # Which kernels to build and/or install is specified by setting
1562 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1563 # Only the existing (depending TARGET) config files are used
1564 # for building kernels and only the first of these is designated
1565 # as the one being installed.
1567 # Note that we have to use TARGET instead of TARGET_ARCH when
1568 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1569 # be set to cross-build, we have to make sure TARGET is set
1572 .if defined(KERNFAST)
1576 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1577 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1578 KERNCONF=${KERNFAST}
1581 .if ${TARGET_ARCH} == "powerpc64"
1582 KERNCONF?= GENERIC64
1583 .elif ${TARGET_ARCH} == "powerpc64le"
1584 KERNCONF?= GENERIC64LE
1585 .elif ${TARGET_ARCH} == "powerpcspe"
1586 KERNCONF?= MPC85XXSPE
1590 INSTKERNNAME?= kernel
1592 KERNSRCDIR?= ${.CURDIR}/sys
1593 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1594 KRNLOBJDIR= ${OBJTOP}${KERNSRCDIR:C,^${.CURDIR},,}
1595 KERNCONFDIR?= ${KRNLCONFDIR}
1599 .if defined(NO_INSTALLKERNEL)
1600 # All of the BUILDKERNELS loops start at index 1.
1601 BUILDKERNELS+= dummy
1603 .for _kernel in ${KERNCONF}
1604 .if !defined(_MKSHOWCONFIG) && exists(${KERNCONFDIR}/${_kernel})
1605 BUILDKERNELS+= ${_kernel}
1606 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1607 INSTALLKERNEL= ${_kernel}
1610 .if make(buildkernel)
1611 .error Missing KERNCONF ${KERNCONFDIR}/${_kernel}
1616 _cleankernobj_fast_depend_hack: .PHONY
1617 # 20191009 r353340 removal of opensolaris_atomic.S (also r353381)
1618 .if ${MACHINE} != i386
1619 .for f in opensolaris_atomic
1620 .for m in opensolaris zfs
1621 @if [ -e "${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o" ] && \
1622 grep -q ${f}.S "${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o"; then \
1623 echo "Removing stale dependencies for opensolaris_atomic"; \
1624 rm -f ${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.*; \
1630 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1632 # record kernel(s) build time in seconds
1633 .if make(buildkernel)
1634 _BUILDKERNEL_START!= date '+%s'
1640 # Builds all kernels defined by BUILDKERNELS.
1642 buildkernel: .MAKE .PHONY
1643 .if empty(BUILDKERNELS:Ndummy)
1644 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1648 .for _kernel in ${BUILDKERNELS:Ndummy}
1649 @echo "--------------------------------------------------------------"
1650 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1651 @echo "--------------------------------------------------------------"
1652 @echo "===> ${_kernel}"
1653 mkdir -p ${KRNLOBJDIR}
1654 .if !defined(NO_KERNELCONFIG)
1656 @echo "--------------------------------------------------------------"
1657 @echo ">>> stage 1: configuring the kernel"
1658 @echo "--------------------------------------------------------------"
1659 cd ${KRNLCONFDIR}; \
1661 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1662 -I '${KERNCONFDIR}' -I '${KRNLCONFDIR}' \
1663 '${KERNCONFDIR}/${_kernel}'
1665 .if ${MK_CLEAN} == "yes" && !defined(NO_KERNELCLEAN)
1667 @echo "--------------------------------------------------------------"
1668 @echo ">>> stage 2.1: cleaning up the object tree"
1669 @echo "--------------------------------------------------------------"
1670 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1672 ${_+_}cd ${.CURDIR}; ${WMAKE} _cleankernobj_fast_depend_hack
1674 .if !defined(NO_KERNELOBJ)
1676 @echo "--------------------------------------------------------------"
1677 @echo ">>> stage 2.2: rebuilding the object tree"
1678 @echo "--------------------------------------------------------------"
1679 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1682 @echo "--------------------------------------------------------------"
1683 @echo ">>> stage 2.3: build tools"
1684 @echo "--------------------------------------------------------------"
1685 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1687 @echo "--------------------------------------------------------------"
1688 @echo ">>> stage 3.1: building everything"
1689 @echo "--------------------------------------------------------------"
1690 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1691 @echo "--------------------------------------------------------------"
1692 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1693 @echo "--------------------------------------------------------------"
1696 @seconds=$$(($$(date '+%s') - ${_BUILDKERNEL_START})); \
1697 echo -n ">>> Kernel(s) ${BUILDKERNELS} built in $$seconds seconds, "; \
1698 echo "ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}"
1699 @echo "--------------------------------------------------------------"
1701 .if !make(packages) && !make(update-packages)
1702 NO_INSTALLEXTRAKERNELS?= yes
1704 # packages/update-packages installs kernels to a staging directory then builds
1705 # packages from the result to be installed, typically to other systems. It is
1706 # less surprising for these targets to honor KERNCONF if multiple kernels are
1708 NO_INSTALLEXTRAKERNELS?= no
1712 # installkernel, etc.
1714 # Install the kernel defined by INSTALLKERNEL
1716 installkernel installkernel.debug \
1717 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1718 .if !defined(NO_INSTALLKERNEL)
1719 .if empty(INSTALLKERNEL)
1720 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1723 @echo "--------------------------------------------------------------"
1724 @echo ">>> Installing kernel ${INSTALLKERNEL} on $$(LC_ALL=C date)"
1725 @echo "--------------------------------------------------------------"
1726 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1727 ${CROSSENV} PATH=${TMPPATH} \
1728 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1729 @echo "--------------------------------------------------------------"
1730 @echo ">>> Installing kernel ${INSTALLKERNEL} completed on $$(LC_ALL=C date)"
1731 @echo "--------------------------------------------------------------"
1733 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1734 .for _kernel in ${BUILDKERNELS:[2..-1]}
1735 @echo "--------------------------------------------------------------"
1736 @echo ">>> Installing kernel ${_kernel} $$(LC_ALL=C date)"
1737 @echo "--------------------------------------------------------------"
1738 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
1739 ${CROSSENV} PATH=${TMPPATH} \
1740 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1741 @echo "--------------------------------------------------------------"
1742 @echo ">>> Installing kernel ${_kernel} completed on $$(LC_ALL=C date)"
1743 @echo "--------------------------------------------------------------"
1747 distributekernel distributekernel.debug: .PHONY
1748 .if !defined(NO_INSTALLKERNEL)
1749 .if empty(INSTALLKERNEL)
1750 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1753 mkdir -p ${DESTDIR}/${DISTDIR}
1754 .if defined(NO_ROOT)
1755 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1757 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1758 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1759 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1760 DESTDIR=${INSTALL_DDIR}/kernel \
1761 ${.TARGET:S/distributekernel/install/}
1762 .if defined(NO_ROOT)
1763 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1764 ${DESTDIR}/${DISTDIR}/kernel.meta
1767 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1768 .for _kernel in ${BUILDKERNELS:[2..-1]}
1769 .if defined(NO_ROOT)
1770 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1772 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
1773 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1774 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1775 KERNEL=${INSTKERNNAME}.${_kernel} \
1776 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1777 ${.TARGET:S/distributekernel/install/}
1778 .if defined(NO_ROOT)
1779 @sed -e "s|^./kernel.${_kernel}|.|" \
1780 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1781 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1786 packagekernel: .PHONY
1787 .if defined(NO_ROOT)
1788 .if !defined(NO_INSTALLKERNEL)
1789 cd ${DESTDIR}/${DISTDIR}/kernel; \
1790 tar cvf - --exclude '*.debug' \
1791 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1792 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1794 .if ${MK_DEBUG_FILES} != "no"
1795 cd ${DESTDIR}/${DISTDIR}/kernel; \
1796 tar cvf - --include '*/*/*.debug' \
1797 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1798 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1800 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1801 .for _kernel in ${BUILDKERNELS:[2..-1]}
1802 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1803 tar cvf - --exclude '*.debug' \
1804 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1805 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1806 .if ${MK_DEBUG_FILES} != "no"
1807 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1808 tar cvf - --include '*/*/*.debug' \
1809 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1810 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1815 .if !defined(NO_INSTALLKERNEL)
1816 cd ${DESTDIR}/${DISTDIR}/kernel; \
1817 tar cvf - --exclude '*.debug' . | \
1818 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1820 .if ${MK_DEBUG_FILES} != "no"
1821 cd ${DESTDIR}/${DISTDIR}/kernel; \
1822 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1823 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1825 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1826 .for _kernel in ${BUILDKERNELS:[2..-1]}
1827 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1828 tar cvf - --exclude '*.debug' . | \
1829 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1830 .if ${MK_DEBUG_FILES} != "no"
1831 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1832 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1833 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1840 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1842 PORTSDIR?= /usr/ports
1843 WSTAGEDIR?= ${OBJTOP}/worldstage
1844 KSTAGEDIR?= ${OBJTOP}/kernelstage
1845 REPODIR?= ${OBJROOT}repo
1847 PKG_REPO_SIGNING_KEY?= # empty
1848 PKG_OUTPUT_DIR?= ${PKG_VERSION}
1850 .ORDER: stage-packages create-packages
1851 .ORDER: create-packages create-world-packages
1852 .ORDER: create-packages create-kernel-packages
1853 .ORDER: create-packages sign-packages
1855 _pkgbootstrap: .PHONY
1856 .if make(*package*) && !exists(${LOCALBASE}/sbin/pkg)
1857 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1860 .if make(create-world-packages-jobs) || make(create-kernel-packages*) || make(real-update-packages)
1861 PKG_ABI!=${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI
1864 .if !defined(PKG_VERSION_FROM) && make(real-update-packages)
1865 .if defined(PKG_ABI)
1866 .if exists(${REPODIR}/${PKG_ABI})
1867 PKG_VERSION_FROM!=/usr/bin/readlink ${REPODIR}/${PKG_ABI}/latest
1868 PKG_VERSION_FROM_DIR= ${REPODIR}/${PKG_ABI}/${PKG_VERSION_FROM}
1871 PKG_VERSION_FROM_DIR=
1876 PKGMAKEARGS+= PKG_VERSION=${PKG_VERSION} \
1877 NO_INSTALLEXTRAKERNELS=${NO_INSTALLEXTRAKERNELS}
1880 ${_+_}${MAKE} -C ${.CURDIR} ${PKGMAKEARGS} real-packages
1882 update-packages: .PHONY
1883 ${_+_}${MAKE} -C ${.CURDIR} ${PKGMAKEARGS} real-update-packages
1886 rm -rf /tmp/ports.${TARGET} || :
1887 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
1888 PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \
1889 WSTAGEDIR=${WSTAGEDIR} \
1890 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1892 real-packages: stage-packages create-packages sign-packages .PHONY
1894 real-update-packages: stage-packages .PHONY
1895 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} create-packages
1896 .if empty(PKG_VERSION_FROM_DIR)
1897 @echo "==> Bootstrapping repository, not checking for new packages"
1899 @echo "==> Checking for new packages (comparing ${PKG_VERSION} to ${PKG_VERSION_FROM})"
1900 @for pkg in ${PKG_VERSION_FROM_DIR}/${PKG_NAME_PREFIX}-*; do \
1901 pkgname=$$(pkg query -F $${pkg} '%n' | sed 's/${PKG_NAME_PREFIX}-\(.*\)/\1/') ; \
1902 newpkgname=${PKG_NAME_PREFIX}-$${pkgname}-${PKG_VERSION}.${PKG_FORMAT} ; \
1903 oldsum=$$(pkg query -F $${pkg} '%X') ; \
1904 if [ ! -f ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} ]; then \
1907 newsum=$$(pkg query -F ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} '%X') ; \
1908 if [ "$${oldsum}" == "$${newsum}" ]; then \
1909 echo "==> Keeping old ${PKG_NAME_PREFIX}-$${pkgname}-${PKG_VERSION_FROM}.${PKG_FORMAT}" ; \
1910 rm ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} ; \
1911 cp $${pkg} ${REPODIR}/${PKG_ABI}/${PKG_VERSION} ; \
1913 echo "==> New package $${newpkgname}" ; \
1917 ${_+_}@cd ${.CURDIR}; \
1918 ${MAKE} -f Makefile.inc1 PKG_VERSION=${PKG_VERSION} sign-packages
1920 stage-packages-world: .PHONY
1921 @mkdir -p ${WSTAGEDIR}
1922 ${_+_}@cd ${.CURDIR}; \
1923 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT stageworld
1925 stage-packages-kernel: .PHONY
1926 @mkdir -p ${KSTAGEDIR}
1927 ${_+_}@cd ${.CURDIR}; \
1928 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT stagekernel
1930 stage-packages: .PHONY stage-packages-world stage-packages-kernel
1933 @mkdir -p ${REPODIR}
1935 create-packages-world: _pkgbootstrap _repodir .PHONY
1936 ${_+_}@cd ${.CURDIR}; \
1937 ${MAKE} -f Makefile.inc1 \
1938 DESTDIR=${WSTAGEDIR} \
1939 PKG_VERSION=${PKG_VERSION} create-world-packages
1941 create-packages-kernel: _pkgbootstrap _repodir .PHONY
1942 ${_+_}@cd ${.CURDIR}; \
1943 ${MAKE} -f Makefile.inc1 \
1944 DESTDIR=${KSTAGEDIR} \
1945 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1946 SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
1947 create-kernel-packages
1949 create-packages: .PHONY create-packages-world create-packages-kernel
1951 create-world-packages: _pkgbootstrap .PHONY
1952 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1953 @cd ${WSTAGEDIR} ; \
1954 env -i LC_COLLATE=C sort ${WSTAGEDIR}/${DISTDIR}/METALOG | \
1955 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk
1956 @for plist in ${WSTAGEDIR}/*.plist; do \
1957 plist=$${plist##*/} ; \
1958 pkgname=$${plist%.plist} ; \
1959 echo "_PKGS+= $${pkgname}" ; \
1960 done > ${WSTAGEDIR}/packages.mk
1961 ${_+_}@cd ${.CURDIR}; \
1962 ${MAKE} -f Makefile.inc1 create-world-packages-jobs \
1963 SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
1966 .if make(create-world-packages-jobs)
1967 .include "${WSTAGEDIR}/packages.mk"
1970 create-world-packages-jobs: .PHONY
1971 .for pkgname in ${_PKGS}
1972 create-world-packages-jobs: create-world-package-${pkgname}
1973 create-world-package-${pkgname}: .PHONY
1974 @sh ${SRCDIR}/release/packages/generate-ucl.sh -o ${pkgname} \
1975 -s ${SRCDIR} -u ${WSTAGEDIR}/${pkgname}.ucl
1977 /^name/ { printf("===> Creating %s-", $$2); next } \
1978 /^version/ { print $$2; next } \
1979 ' ${WSTAGEDIR}/${pkgname}.ucl
1980 @if [ "${pkgname}" == "runtime" ]; then \
1981 sed -i '' -e "s/%VCS_REVISION%/${VCS_REVISION}/" ${WSTAGEDIR}/${pkgname}.ucl ; \
1983 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname -o ALLOW_BASE_SHLIBS=yes \
1984 create -f ${PKG_FORMAT} -M ${WSTAGEDIR}/${pkgname}.ucl \
1985 -p ${WSTAGEDIR}/${pkgname}.plist \
1987 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
1990 _default_flavor= -default
1991 .if make(*package*) && exists(${KSTAGEDIR}/kernel.meta)
1992 . if ${MK_DEBUG_FILES} != "no"
1995 create-kernel-packages: .PHONY
1996 . for flavor in "" ${_debug}
1997 create-kernel-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}
1998 create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY
1999 @cd ${KSTAGEDIR}/${DISTDIR} ; \
2000 env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.meta | \
2001 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
2002 -v kernel=yes -v _kernconf=${INSTALLKERNEL} ; \
2003 sed -e "s/%VERSION%/${PKG_VERSION}/" \
2004 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
2005 -e "s/%KERNELDIR%/kernel/" \
2006 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
2007 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
2008 -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \
2009 -e "s/%PKG_NAME_PREFIX%/${PKG_NAME_PREFIX}/" \
2010 -e "s/%PKG_MAINTAINER%/${PKG_MAINTAINER}/" \
2011 -e "s|%PKG_WWW%|${PKG_WWW}|" \
2012 ${SRCDIR}/release/packages/kernel.ucl \
2013 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
2015 /name/ { printf("===> Creating %s-", $$2); next } \
2016 /version/ {print $$2; next } ' \
2017 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
2018 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname -o ALLOW_BASE_SHLIBS=yes \
2019 create -f ${PKG_FORMAT} \
2020 -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
2021 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
2022 -r ${KSTAGEDIR}/${DISTDIR} \
2023 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
2026 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
2027 . for _kernel in ${BUILDKERNELS:[2..-1]}
2028 . if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
2029 . if ${MK_DEBUG_FILES} != "no"
2032 . for flavor in "" ${_debug}
2033 create-kernel-packages: create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}
2034 create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}: _pkgbootstrap .PHONY
2035 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
2036 env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.${_kernel}.meta | \
2037 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
2038 -v kernel=yes -v _kernconf=${_kernel} ; \
2039 sed -e "s/%VERSION%/${PKG_VERSION}/" \
2040 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
2041 -e "s/%KERNELDIR%/kernel.${_kernel}/" \
2042 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
2043 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
2044 -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \
2045 -e "s/%PKG_NAME_PREFIX%/${PKG_NAME_PREFIX}/" \
2046 -e "s/%PKG_MAINTAINER%/${PKG_MAINTAINER}/" \
2047 -e "s|%PKG_WWW%|${PKG_WWW}|" \
2048 ${SRCDIR}/release/packages/kernel.ucl \
2049 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
2051 /name/ { printf("===> Creating %s-", $$2); next } \
2052 /version/ {print $$2; next } ' \
2053 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
2054 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname -o ALLOW_BASE_SHLIBS=yes \
2055 create -f ${PKG_FORMAT} \
2056 -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
2057 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
2058 -r ${KSTAGEDIR}/kernel.${_kernel} \
2059 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
2065 sign-packages: _pkgbootstrap .PHONY
2066 printf "version = 2;\npacking_format = \"${PKG_FORMAT}\";\n" > ${WSTAGEDIR}/meta
2067 @[ -L "${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/latest" ] && \
2068 unlink ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/latest ; \
2069 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname repo \
2070 -m ${WSTAGEDIR}/meta \
2071 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/${PKG_VERSION} \
2072 ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/${PKG_VERSION} \
2073 ${PKG_REPO_SIGNING_KEY} ; \
2074 cd ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI); \
2075 ln -s ${PKG_OUTPUT_DIR} latest
2081 # Run test suite on installed world.
2084 @if [ ! -x "${LOCALBASE}/bin/kyua" ] && [ ! -x "/usr/bin/kyua" ]; then \
2085 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
2088 ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile
2094 # Build the API documentation with doxygen
2097 @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \
2098 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
2101 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
2104 # ------------------------------------------------------------------------
2106 # From here onwards are utility targets used by the 'make world' and
2107 # related targets. If your 'world' breaks, you may like to try to fix
2108 # the problem and manually run the following targets to attempt to
2109 # complete the build. Beware, this is *not* guaranteed to work, you
2110 # need to have a pretty good grip on the current state of the system
2111 # to attempt to manually finish it. If in doubt, 'make world' again.
2115 # legacy: Build compatibility shims for the next three targets. This is a
2116 # minimal set of tools and shims necessary to compensate for older systems
2117 # which don't have the APIs required by the targets built in bootstrap-tools,
2118 # build-tools or cross-tools.
2121 .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
2122 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
2128 ${LOCAL_LEGACY_DIRS}
2129 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
2130 cd ${.CURDIR}/${_tool}; \
2131 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2132 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy includes; \
2133 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
2134 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
2135 DESTDIR=${WORLDTMP}/legacy install
2139 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
2140 # are built to build other binaries in the system. However, the focus of these
2141 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
2142 # libraries, augmented by -legacy, in addition to the libraries built during
2145 _bt= _bootstrap-tools
2147 # We want to run the build with only ${WORLDTMP} in $PATH to ensure we don't
2148 # accidentally run tools that are incompatible but happen to be in $PATH.
2149 # This is especially important when building on Linux/MacOS where many of the
2150 # programs used during the build accept different flags or generate different
2151 # output. On those platforms we only symlink the tools known to be compatible
2152 # (e.g. basic utilities such as mkdir) into ${WORLDTMP} and build all others
2153 # from the FreeBSD sources during the bootstrap-tools stage.
2154 # We want to build without the user's $PATH starting in the bootstrap-tools
2155 # phase so the tools used in that phase (ln, cp, etc) must have already been
2156 # linked to $WORLDTMP. The tools are listed in the _host_tools_to_symlink
2157 # variable in tools/build/Makefile and are linked during the legacy phase.
2158 # Since they could be Linux or MacOS binaries, too we must only use flags that
2159 # are portable across operating systems.
2161 # If BOOTSTRAP_ALL_TOOLS is set we will build all the required tools from the
2162 # current source tree. Otherwise we create a symlink to the version found in
2163 # $PATH during the bootstrap-tools stage.
2164 # When building on non-FreeBSD systems we can't assume that the host binaries
2165 # accept compatible flags or produce compatible output. Therefore we force
2166 # BOOTSTRAP_ALL_TOOLS and just build the FreeBSD version of the binary.
2167 .if defined(CROSSBUILD_HOST)
2168 BOOTSTRAP_ALL_TOOLS:= 1
2170 .if defined(BOOTSTRAP_ALL_TOOLS)
2171 # BOOTSTRAPPING will be set on the command line so we can't override it here.
2172 # Instead set BOOTSTRAPPING_OSRELDATE so that the value 0 is set ${BSARGS}
2173 BOOTSTRAPPING_OSRELDATE:= 0
2176 # libnv and libsbuf are requirements for config(8), which is an unconditional
2178 _config=usr.sbin/config lib/libnv lib/libsbuf
2179 ${_bt}-usr.sbin/config: ${_bt}-lib/libnv ${_bt}-lib/libsbuf
2181 .if ${MK_GAMES} != "no"
2182 _strfile= usr.bin/fortune/strfile
2185 # vtfontcvt is used to build font files for loader and to generate
2186 # C source for loader built in font (8x16.c).
2187 _vtfontcvt= usr.bin/vtfontcvt
2189 # If we are not building the bootstrap because BOOTSTRAPPING is sufficient
2190 # we symlink the host version to $WORLDTMP instead. By doing this we can also
2191 # detect when a bootstrap tool is being used without the required MK_FOO.
2192 # If you add a new bootstrap tool where we could also use the host version,
2193 # please ensure that you also add a .else case where you add the tool to the
2194 # _bootstrap_tools_links variable.
2195 .if ${BOOTSTRAPPING} < 1000033
2196 # Note: lex needs m4 to build but m4 also depends on lex (which needs m4 to
2197 # generate any files). To fix this cyclic dependency we can build a bootstrap
2198 # version of m4 (with pre-generated files) then use that to build the real m4.
2199 # We can't simply use the host m4 since e.g. the macOS version does not accept
2200 # the flags that are passed by lex.
2201 # For lex we also use the pre-gerated files since we would otherwise need to
2202 # build awk and sed first (which need lex to build)
2203 # TODO: add a _bootstrap_lex and then build the real lex afterwards
2205 _m4= tools/build/bootstrap-m4 usr.bin/m4
2206 ${_bt}-tools/build/bootstrap-m4: ${_bt}-usr.bin/lex ${_bt}-lib/libopenbsd ${_bt}-usr.bin/yacc
2207 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd ${_bt}-usr.bin/yacc ${_bt}-usr.bin/lex ${_bt}-tools/build/bootstrap-m4
2208 _bt_m4_depend=${_bt}-usr.bin/m4
2209 _bt_lex_depend=${_bt}-usr.bin/lex ${_bt_m4_depend}
2211 _bootstrap_tools_links+=m4 lex
2214 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
2215 # r296685 fix cross-endian objcopy
2216 # r310724 fixed PR 215350, a crash in libdwarf with objects built by GCC 6.2.
2217 # r334881 added libdwarf constants used by ctfconvert.
2218 # r338478 fixed a crash in objcopy for mips64el objects
2219 # r339083 libelf: correct mips64el test to use ELF header
2220 # r348347 Add missing powerpc64 relocation support to libdwarf
2221 .if ${BOOTSTRAPPING} < 1300030
2222 _elftoolchain_libs= lib/libelf lib/libdwarf lib/libzstd
2223 ${_bt}-lib/libelf: ${_bt_m4_depend}
2224 ${_bt}-lib/libdwarf: ${_bt_m4_depend}
2227 # flua is required to regenerate syscall files. It first appeared during the
2228 # 13.0-CURRENT cycle, thus needs to be built on -older releases and stable
2230 .if ${BOOTSTRAPPING} < 1300059
2231 ${_bt}-libexec/flua: ${_bt}-lib/liblua ${_bt}-lib/libucl
2232 _flua= lib/liblua lib/libucl libexec/flua
2235 # r245440 mtree -N support added
2236 # r313404 requires sha384.h for libnetbsd, added to libmd in r292782
2237 .if ${BOOTSTRAPPING} < 1100093
2238 _nmtree= lib/libmd \
2242 ${_bt}-lib/libnetbsd: ${_bt}-lib/libmd
2243 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
2245 _bootstrap_tools_links+=mtree
2248 # r246097: log addition login.conf.db, passwd, pwd.db, and spwd.db with cat -l
2249 .if ${BOOTSTRAPPING} < 1000027
2252 _bootstrap_tools_links+=cat
2255 # r277259 crunchide: Correct 64-bit section header offset
2256 # r281674 crunchide: always include both 32- and 64-bit ELF support
2257 .if ${BOOTSTRAPPING} < 1100078
2258 _crunchide= usr.sbin/crunch/crunchide
2260 _bootstrap_tools_links+=crunchide
2263 # 1300115: Higher WARNS fixes
2264 .if ${BOOTSTRAPPING} < 1202502 || \
2265 (${BOOTSTRAPPING} > 1300000 && ${BOOTSTRAPPING} < 1300131)
2266 _crunchgen= usr.sbin/crunch/crunchgen
2268 _bootstrap_tools_links+=crunchgen
2271 # r296926 -P keymap search path, MFC to stable/10 in r298297
2272 # Note: kbdcontrol can not be bootstrapped on non-FreeBSD systems
2273 .if !defined(CROSSBUILD_HOST)
2274 .if (${BOOTSTRAPPING} < 1003501 || \
2275 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103) || \
2276 (!exists(/usr/sbin/kbdcontrol)))
2277 _kbdcontrol= usr.sbin/kbdcontrol
2279 _bootstrap_tools_links+=kbdcontrol
2283 # 1300102: VHDX support
2284 .if ${BOOTSTRAPPING} < 1201520 || \
2285 (${BOOTSTRAPPING} > 1300000 && ${BOOTSTRAPPING} < 1300102)
2286 _mkimg= usr.bin/mkimg
2288 _bootstrap_tools_links+=mkimg
2293 .if ${MK_BSNMP} != "no"
2294 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
2298 # We need to build tblgen when we're building clang or lld, either as
2299 # bootstrap tools, or as the part of the normal build.
2300 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
2301 ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no" || \
2304 lib/clang/libllvmminimal \
2305 usr.bin/clang/llvm-tblgen
2306 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
2307 _clang_tblgen+= usr.bin/clang/clang-tblgen
2309 .if ${MK_LLDB} != "no"
2310 _clang_tblgen+= usr.bin/clang/lldb-tblgen
2312 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal
2313 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal
2314 ${_bt}-usr.bin/clang/lldb-tblgen: ${_bt}-lib/clang/libllvmminimal
2317 .if ${MK_LOCALES} != "no"
2318 _localedef= usr.bin/localedef
2319 ${_bt}-usr.bin/localedef: ${_bt}-usr.bin/yacc ${_bt_lex_depend}
2322 .if ${MK_KERBEROS} != "no"
2323 _kerberos5_bootstrap_tools= \
2324 kerberos5/tools/make-roken \
2325 kerberos5/lib/libroken \
2326 kerberos5/lib/libvers \
2327 kerberos5/tools/asn1_compile \
2328 kerberos5/tools/slc \
2331 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
2332 .for _tool in ${_kerberos5_bootstrap_tools}
2333 ${_bt}-${_tool}: ${_bt}-usr.bin/yacc ${_bt_lex_depend}
2337 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
2339 # The tools listed in _basic_bootstrap_tools will generally not be
2340 # bootstrapped unless BOOTSTRAP_ALL_TOOL is set. However, when building on a
2341 # Linux or MacOS host the host versions are incompatible so we need to build
2342 # them from the source tree. Usually the link name will be the same as the subdir,
2343 # but some directories such as grep or test install multiple binaries. In that
2344 # case we use the _basic_bootstrap_tools_multilink variable which is a list of
2345 # subdirectory and comma-separated list of files.
2346 _basic_bootstrap_tools_multilink=usr.bin/grep grep,egrep,fgrep
2347 _basic_bootstrap_tools_multilink+=bin/test test,[
2348 # bootstrap tools needed by buildworld:
2349 _basic_bootstrap_tools+=usr.bin/cut bin/expr usr.bin/gencat usr.bin/join \
2350 usr.bin/mktemp bin/realpath bin/rmdir usr.bin/sed usr.bin/sort \
2351 usr.bin/truncate usr.bin/tsort
2352 # Some build scripts use nawk instead of awk (this happens at least in
2353 # cddl/contrib/opensolaris/lib/libdtrace/common/mknames.sh) so we need both awk
2354 # and nawk in ${WORLDTMP}/legacy/bin.
2355 _basic_bootstrap_tools_multilink+=usr.bin/awk awk,nawk
2356 # file2c is required for building usr.sbin/config:
2357 _basic_bootstrap_tools+=usr.bin/file2c
2358 # uuencode/uudecode required for share/tabset
2359 _basic_bootstrap_tools+=usr.bin/uuencode usr.bin/uudecode
2360 # xargs is required by mkioctls
2361 _basic_bootstrap_tools+=usr.bin/xargs
2362 # cap_mkdb is required for share/termcap:
2363 _basic_bootstrap_tools+=usr.bin/cap_mkdb
2364 # services_mkdb/pwd_mkdb are required for installworld:
2365 _basic_bootstrap_tools+=usr.sbin/services_mkdb usr.sbin/pwd_mkdb
2366 # ldd is required for installcheck (TODO: just always use /usr/bin/ldd instead?)
2367 .if !defined(CROSSBUILD_HOST)
2368 # ldd is only needed for updating the running system so we don't need to
2369 # bootstrap ldd on non-FreeBSD systems
2370 _basic_bootstrap_tools+=usr.bin/ldd
2372 # sysctl/chflags are required for installkernel:
2373 .if !defined(CROSSBUILD_HOST)
2374 _basic_bootstrap_tools+=bin/chflags
2375 # Note: sysctl does not bootstrap on FreeBSD < 13 anymore, but that doesn't
2376 # matter since we don't need any of the new features for the build.
2377 _bootstrap_tools_links+=sysctl
2379 # When building on non-FreeBSD, install a fake chflags instead since the
2380 # version from the source tree cannot work. We also don't need sysctl since we
2381 # are install with -DNO_ROOT.
2382 _other_bootstrap_tools+=tools/build/cross-build/fake_chflags
2384 # mkfifo is used by sys/conf/newvers.sh
2385 _basic_bootstrap_tools+=usr.bin/mkfifo
2386 # jot is needed for the mkimg tests
2387 _basic_bootstrap_tools+=usr.bin/jot
2389 .if ${MK_BOOT} != "no"
2390 # md5 is used by boot/beri (and possibly others)
2391 _basic_bootstrap_tools+=sbin/md5
2394 .if ${MK_ZONEINFO} != "no"
2395 _basic_bootstrap_tools+=usr.sbin/zic usr.sbin/tzsetup
2398 .if defined(BOOTSTRAP_ALL_TOOLS)
2399 _other_bootstrap_tools+=${_basic_bootstrap_tools}
2400 .for _subdir _links in ${_basic_bootstrap_tools_multilink}
2401 _other_bootstrap_tools+=${_subdir}
2403 ${_bt}-usr.bin/awk: ${_bt_lex_depend} ${_bt}-usr.bin/yacc
2404 ${_bt}-bin/expr: ${_bt_lex_depend} ${_bt}-usr.bin/yacc
2405 # If we are bootstrapping file2c, we have to build it before config:
2406 ${_bt}-usr.sbin/config: ${_bt}-usr.bin/file2c ${_bt_lex_depend}
2407 # Note: no symlink to make/bmake in the !BOOTSTRAP_ALL_TOOLS case here since
2408 # the links to make/bmake make links will have already have been created in the
2409 # `make legacy` step. Not adding a link to make is important on non-FreeBSD
2410 # since "make" will usually point to GNU make there.
2411 _other_bootstrap_tools+=usr.bin/bmake
2413 # Avoid dependency on host bz2 headers:
2414 _other_bootstrap_tools+=lib/libbz2
2415 ${_bt}-usr.bin/grep: ${_bt}-lib/libbz2
2417 # All tools in _basic_bootstrap_tools have the same name as the subdirectory
2418 # so we can use :T to get the name of the symlinks that we need to create.
2419 _bootstrap_tools_links+=${_basic_bootstrap_tools:T}
2420 .for _subdir _links in ${_basic_bootstrap_tools_multilink}
2421 _bootstrap_tools_links+=${_links:S/,/ /g}
2423 .endif # defined(BOOTSTRAP_ALL_TOOLS)
2425 # Link the tools that we need for building but don't need to bootstrap because
2426 # the host version is known to be compatible into ${WORLDTMP}/legacy
2427 # We do this before building any of the bootstrap tools in case they depend on
2428 # the presence of any of the links (e.g. as m4/lex/awk)
2429 ${_bt}-links: .PHONY
2431 .for _tool in ${_bootstrap_tools_links}
2432 ${_bt}-link-${_tool}: .PHONY .MAKE
2433 @rm -f "${WORLDTMP}/legacy/bin/${_tool}"; \
2434 source_path=`which ${_tool}`; \
2435 if [ ! -e "$${source_path}" ] ; then \
2436 echo "Cannot find host tool '${_tool}'"; false; \
2438 cp -pf "$${source_path}" "${WORLDTMP}/legacy/bin/${_tool}"
2439 ${_bt}-links: ${_bt}-link-${_tool}
2442 bootstrap-tools: ${_bt}-links .PHONY
2444 # Please document (add comment) why something is in 'bootstrap-tools'.
2445 # Try to bound the building of the bootstrap-tool to just the
2446 # FreeBSD versions that need the tool built at this stage of the build.
2449 ${_kerberos5_bootstrap_tools} \
2454 ${_elftoolchain_libs} \
2462 ${_other_bootstrap_tools} \
2473 ${LOCAL_BSTOOL_DIRS}
2474 ${_bt}-${_tool}: ${_bt}-links .PHONY .MAKE
2475 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2476 cd ${.CURDIR}/${_tool}; \
2477 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2478 if [ "${_tool}" = "usr.bin/lex" ]; then \
2479 ${MAKE} DIRPRFX=${_tool}/ bootstrap; \
2481 ${MAKE} DIRPRFX=${_tool}/ all; \
2482 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy install
2484 bootstrap-tools: ${_bt}-${_tool}
2486 .if target(${_bt}-lib/libmd)
2487 # If we are bootstrapping libmd (e.g. when building on macOS/Linux) add the
2488 # necessary dependencies:
2489 ${_bt}-usr.bin/sort: ${_bt}-lib/libmd
2490 ${_bt}-usr.bin/xinstall: ${_bt}-lib/libmd
2491 ${_bt}-sbin/md5: ${_bt}-lib/libmd
2496 # build-tools: Build special purpose build tools
2498 .if !defined(NO_SHARE) && ${MK_SYSCONS} != "no"
2499 _share= share/syscons/scrnmaps
2502 .if ${MK_RESCUE} != "no"
2503 # rescue includes programs that have build-tools targets
2504 _rescue=rescue/rescue
2507 .if ${MK_TCSH} != "no"
2510 .if ${MK_FILE} != "no"
2511 _libmagic=lib/libmagic
2514 .if ${MK_PMC} != "no"
2515 _jevents=lib/libpmc/pmu-events
2518 # kernel-toolchain skips _cleanobj, so handle cleaning up previous
2519 # build-tools directories if needed.
2520 .if ${MK_CLEAN} == "yes" && make(kernel-toolchain)
2521 _bt_clean= ${CLEANDIR}
2527 ${LOCAL_TOOL_DIRS} \
2529 lib/ncurses/ncurses \
2534 usr.bin/mkesdb_static \
2535 usr.bin/mkcsmapper_static \
2537 build-tools_${_tool}: .PHONY
2538 ${_+_}@${ECHODIR} "===> ${_tool} (${_bt_clean:D${_bt_clean},}obj,build-tools)"; \
2539 cd ${.CURDIR}/${_tool}; \
2540 if [ -n "${_bt_clean}" ]; then ${MAKE} DIRPRFX=${_tool}/ ${_bt_clean}; fi; \
2541 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2542 ${MAKE} DIRPRFX=${_tool}/ build-tools
2543 build-tools: build-tools_${_tool}
2547 # kernel-tools: Build kernel-building tools
2549 kernel-tools: .PHONY
2550 mkdir -p ${WORLDTMP}/usr
2551 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2552 -p ${WORLDTMP}/usr >/dev/null
2555 # cross-tools: All the tools needed to build the rest of the system after
2556 # we get done with the earlier stages. It is the last set of tools needed
2557 # to begin building the target binaries.
2559 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BUILD_WITH_STRICT_TMPPATH} != 0
2560 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
2561 _btxld= usr.sbin/btxld
2565 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
2566 # resulting from missing bug fixes or ELF Toolchain updates.
2567 .if ${MK_CDDL} != "no"
2568 _dtrace_tools= cddl/lib/libctf cddl/lib/libspl cddl/usr.bin/ctfconvert \
2569 cddl/usr.bin/ctfmerge
2572 # If we're given an XAS, don't build binutils.
2573 .if ${XAS:M/*} == ""
2574 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
2575 _elftctools= lib/libelftc \
2582 # These are not required by the build, but can be useful for developers who
2583 # cross-build on a FreeBSD 10 host:
2584 _elftctools+= usr.bin/addr2line
2586 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
2587 # If cross-building with an external binutils we still need to build strip for
2588 # the target (for at least crunchide).
2589 _elftctools= lib/libelftc \
2595 .if ${MK_CLANG_BOOTSTRAP} != "no"
2596 _clang= usr.bin/clang
2598 .if ${MK_LLD_BOOTSTRAP} != "no"
2599 _lld= usr.bin/clang/lld
2601 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no"
2602 _clang_libs= lib/clang
2604 .if ${MK_USB} != "no"
2605 _usb_tools= stand/usb/tools
2608 .if ${BUILD_WITH_STRICT_TMPPATH} != 0 || defined(BOOTSTRAP_ALL_TOOLS)
2612 cross-tools: .MAKE .PHONY
2614 ${LOCAL_XTOOL_DIRS} \
2623 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2624 cd ${.CURDIR}/${_tool}; \
2625 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2626 ${MAKE} DIRPRFX=${_tool}/ all; \
2627 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP} install
2631 # native-xtools is the current target for qemu-user cross builds of ports
2632 # via poudriere and the imgact_binmisc kernel module.
2633 # This target merely builds a toolchan/sysroot, then builds the tools it wants
2634 # with the options it wants in a special MAKEOBJDIRPREFIX, using the toolchain
2635 # already built. It then installs the static tools to NXBDESTDIR for Poudriere
2638 NXBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/nxb/
2639 NXBOBJTOP= ${NXBOBJROOT}${NXB_TARGET}.${NXB_TARGET_ARCH}
2642 .error NXTP variable should be an absolute path
2644 NXBDESTDIR?= ${DESTDIR}${NXTP}
2646 # This is the list of tools to be built/installed as static and where
2647 # appropriate to build for the given TARGET.TARGET_ARCH.
2711 SUBDIR_DEPEND_usr.bin/clang= lib/clang
2712 .if ${MK_CLANG} != "no"
2714 NXBDIRS+= usr.bin/clang
2716 # XXX: native-xtools passes along ${NXBDIRS} in SUBDIR_OVERRIDE that needs
2717 # to be evaluated after NXBDIRS is set.
2718 .if make(install) && !empty(SUBDIR_OVERRIDE)
2719 SUBDIR= ${SUBDIR_OVERRIDE}
2723 OBJTOP=${NXBOBJTOP:Q} \
2724 OBJROOT=${NXBOBJROOT:Q} \
2731 MK_CLANG_EXTRAS=no \
2732 MK_CLANG_FORMAT=no \
2749 .if make(native-xtools*) && \
2750 (!defined(NXB_TARGET) || !defined(NXB_TARGET_ARCH))
2751 .error Missing NXB_TARGET / NXB_TARGET_ARCH
2753 # For 'toolchain' we want to produce native binaries that themselves generate
2755 NXBTMAKE= ${NXBMAKEENV} ${MAKE} ${NXBMAKEARGS:N-DNO_PIC:N-DNO_SHARED} \
2756 TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH}
2757 # For 'everything' we want to produce native binaries (hence -target to
2758 # be MACHINE) that themselves generate TARGET.TARGET_ARCH binaries.
2759 # TARGET/TARGET_ARCH are still passed along from user.
2761 # Use the toolchain we create as an external toolchain.
2762 .if ${USING_SYSTEM_COMPILER} == "yes" || ${XCC:N${CCACHE_BIN}:M/*}
2763 NXBMAKE+= XCC="${XCC}" \
2767 NXBMAKE+= XCC="${NXBOBJTOP}/tmp/usr/bin/cc" \
2768 XCXX="${NXBOBJTOP}/tmp/usr/bin/c++" \
2769 XCPP="${NXBOBJTOP}/tmp/usr/bin/cpp"
2771 NXBMAKE+= ${NXBMAKEENV} ${MAKE} -f Makefile.inc1 ${NXBMAKEARGS} \
2772 MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} \
2773 TARGET=${NXB_TARGET} TARGET_ARCH=${NXB_TARGET_ARCH} \
2774 TARGET_TRIPLE=${MACHINE_TRIPLE:Q}
2775 # NXBDIRS is improperly based on MACHINE rather than NXB_TARGET. Need to
2776 # invoke a sub-make to reevaluate MK_CLANG, etc, for NXBDIRS.
2777 NXBMAKE+= SUBDIR_OVERRIDE='$${NXBDIRS:M*}'
2778 # Need to avoid the -isystem logic when using clang as an external toolchain
2779 # even if the TARGET being built for wants GCC.
2780 NXBMAKE+= WANT_COMPILER_TYPE='$${X_COMPILER_TYPE}'
2781 native-xtools: .PHONY
2782 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _cleanobj
2783 # Build the bootstrap/host/cross tools that produce native binaries
2784 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} kernel-toolchain
2785 # Populate includes/libraries sysroot that produce native binaries.
2786 # This is split out from 'toolchain' above mostly so that target LLVM
2787 # libraries have a proper LLVM_DEFAULT_TARGET_TRIPLE without
2788 # polluting the cross-compiler build. The LLVM/GCC libs are skipped
2789 # here to avoid the problem but are kept in 'toolchain' so that
2790 # needed build tools are built.
2791 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes MK_CLANG=no
2792 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries MK_CLANG=no
2793 .if !defined(NO_OBJWALK)
2794 ${_+_}cd ${.CURDIR}; ${NXBMAKE} _obj
2796 ${_+_}cd ${.CURDIR}; ${NXBMAKE} everything
2797 @echo ">> native-xtools done. Use 'make native-xtools-install' to install to a given DESTDIR"
2799 native-xtools-install: .PHONY
2800 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
2801 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2802 -p ${NXBDESTDIR}/usr >/dev/null
2803 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2804 -p ${NXBDESTDIR}/usr/include >/dev/null
2805 ${_+_}cd ${.CURDIR}; ${NXBMAKE} \
2806 DESTDIR=${NXBDESTDIR} \
2811 # hierarchy - ensure that all the needed directories are present
2813 hierarchy hier: .MAKE .PHONY
2814 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
2817 # libraries - build all libraries, and install them under ${DESTDIR}.
2819 # The list of libraries with dependents (${_prebuild_libs}) and their
2820 # interdependencies (__L) are built automatically by the
2821 # ${.CURDIR}/tools/make_libdeps.sh script.
2823 libraries: .MAKE .PHONY
2824 ${_+_}cd ${.CURDIR}; \
2825 ${MAKE} -f Makefile.inc1 _prereq_libs; \
2826 ${MAKE} -f Makefile.inc1 _startup_libs; \
2827 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
2828 ${MAKE} -f Makefile.inc1 _generic_libs
2831 # static libgcc.a prerequisite for shared libc
2833 _prereq_libs= lib/libcompiler_rt
2834 .if ${MK_SSP} != "no"
2835 _prereq_libs+= lib/libssp_nonshared
2838 # These dependencies are not automatically generated:
2840 # lib/csu and lib/libc must be built before
2841 # all shared libraries for ELF.
2843 _startup_libs= lib/csu
2844 _startup_libs+= lib/libc
2845 _startup_libs+= lib/libc_nonshared
2846 .if ${MK_CXX} != "no"
2847 _startup_libs+= lib/libcxxrt
2850 _prereq_libs+= lib/libgcc_eh lib/libgcc_s
2851 _startup_libs+= lib/libgcc_eh lib/libgcc_s
2853 lib/libgcc_s__L: lib/libc__L
2854 lib/libgcc_s__L: lib/libc_nonshared__L
2855 .if ${MK_CXX} != "no"
2856 lib/libcxxrt__L: lib/libgcc_s__L
2859 _prebuild_libs= ${_kerberos5_lib_libasn1} \
2860 ${_kerberos5_lib_libhdb} \
2861 ${_kerberos5_lib_libheimbase} \
2862 ${_kerberos5_lib_libheimntlm} \
2864 ${_kerberos5_lib_libheimipcc} \
2865 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
2866 ${_kerberos5_lib_libroken} \
2867 ${_kerberos5_lib_libwind} \
2868 lib/libbz2 ${_libcom_err} lib/libcrypt \
2869 lib/libelf lib/libexpat \
2873 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
2876 lib/ncurses/ncurses \
2877 lib/libopie lib/libpam/libpam lib/libthr \
2878 ${_lib_libradius} lib/libsbuf lib/libtacplus \
2880 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
2881 ${_cddl_lib_libuutil} \
2882 ${_cddl_lib_libavl} \
2883 ${_cddl_lib_libicp} \
2884 ${_cddl_lib_libicp_rescue} \
2885 ${_cddl_lib_libspl} \
2886 ${_cddl_lib_libtpool} \
2887 ${_cddl_lib_libzfs_core} ${_cddl_lib_libzfs} \
2888 ${_cddl_lib_libzutil} \
2889 ${_cddl_lib_libctf} ${_cddl_lib_libzfsbootenv} \
2891 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
2892 ${_secure_lib_libcrypto} ${_secure_lib_libssl} \
2893 ${_lib_libldns} ${_secure_lib_libssh}
2895 .if ${MK_DIALOG} != "no"
2896 _prebuild_libs+= gnu/lib/libdialog
2897 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncurses__L
2900 .if ${MK_GOOGLETEST} != "no"
2901 _prebuild_libs+= lib/libregex
2904 .if ${MK_CXX} != "no"
2905 _prebuild_libs+= lib/libc++
2908 lib/libgeom__L: lib/libexpat__L lib/libsbuf__L
2909 lib/libkvm__L: lib/libelf__L
2911 .if ${MK_RADIUS_SUPPORT} != "no"
2912 _lib_libradius= lib/libradius
2915 .if ${MK_OFED} != "no"
2917 lib/ofed/libibverbs \
2919 lib/ofed/libibumad \
2923 lib/ofed/libibmad__L: lib/ofed/libibumad__L
2924 lib/ofed/complib__L: lib/libthr__L
2925 lib/ofed/libmlx5__L: lib/ofed/libibverbs__L lib/libthr__L
2928 .if ${MK_CASPER} != "no"
2929 _lib_casper= lib/libcasper
2932 lib/libpjdlog__L: lib/libutil__L
2933 lib/libcasper__L: lib/libnv__L
2934 lib/liblzma__L: lib/libmd__L lib/libthr__L
2935 lib/libzstd__L: lib/libthr__L
2937 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib}
2938 .if ${MK_IPFILTER} != "no"
2939 _generic_libs+= sbin/ipf/libipf
2941 .for _DIR in ${LOCAL_LIB_DIRS}
2942 .if ${_DIR} == ".WAIT" || (empty(_generic_libs:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
2943 _generic_libs+= ${_DIR}
2947 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2949 .if ${MK_CDDL} != "no"
2950 _cddl_lib_libumem= cddl/lib/libumem
2951 _cddl_lib_libnvpair= cddl/lib/libnvpair
2952 _cddl_lib_libavl= cddl/lib/libavl
2953 _cddl_lib_libuutil= cddl/lib/libuutil
2954 _cddl_lib_libspl= cddl/lib/libspl
2956 cddl/lib/libuutil__L: cddl/lib/libavl__L cddl/lib/libspl__L
2958 .if ${MK_ZFS} != "no"
2959 _cddl_lib_libicp= cddl/lib/libicp
2960 _cddl_lib_libicp_rescue= cddl/lib/libicp_rescue
2961 _cddl_lib_libtpool= cddl/lib/libtpool
2962 _cddl_lib_libzutil= cddl/lib/libzutil
2963 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2964 _cddl_lib_libzfs= cddl/lib/libzfs
2965 _cddl_lib_libzfsbootenv= cddl/lib/libzfsbootenv
2967 cddl/lib/libtpool__L: cddl/lib/libspl__L
2969 cddl/lib/libzutil__L: cddl/lib/libavl__L cddl/lib/libtpool__L
2971 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2973 cddl/lib/libzfs__L: cddl/lib/libzfs_core__L lib/msun__L lib/libutil__L
2974 cddl/lib/libzfs__L: lib/libthr__L lib/libmd__L lib/libz__L cddl/lib/libumem__L
2975 cddl/lib/libzfs__L: cddl/lib/libuutil__L cddl/lib/libavl__L lib/libgeom__L
2976 cddl/lib/libzfs__L: cddl/lib/libnvpair__L cddl/lib/libzutil__L
2977 cddl/lib/libzfs__L: secure/lib/libcrypto__L
2979 cddl/lib/libzfsbootenv__L: cddl/lib/libzfs__L
2980 lib/libbe__L: cddl/lib/libzfs__L cddl/lib/libzfsbootenv__L
2982 _cddl_lib_libctf= cddl/lib/libctf
2984 cddl/lib/libctf__L: lib/libz__L cddl/lib/libspl__L
2986 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db
2987 _prebuild_libs+= lib/libprocstat lib/libproc lib/librtld_db
2988 lib/libprocstat__L: lib/libelf__L lib/libkvm__L lib/libutil__L
2989 lib/libproc__L: lib/libprocstat__L
2990 lib/librtld_db__L: lib/libprocstat__L
2992 .if ${MK_CRYPT} != "no"
2993 .if ${MK_OPENSSL} != "no"
2994 _secure_lib_libcrypto= secure/lib/libcrypto
2995 _secure_lib_libssl= secure/lib/libssl
2996 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2997 secure/lib/libcrypto__L: lib/libthr__L
2998 .if ${MK_LDNS} != "no"
2999 _lib_libldns= lib/libldns
3000 lib/libldns__L: secure/lib/libssl__L
3002 .if ${MK_OPENSSH} != "no"
3003 _secure_lib_libssh= secure/lib/libssh
3004 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
3005 .if ${MK_LDNS} != "no"
3006 secure/lib/libssh__L: lib/libldns__L
3008 .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no"
3009 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
3010 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
3011 lib/libmd__L kerberos5/lib/libroken__L
3015 _secure_lib= secure/lib
3018 .if ${MK_KERBEROS} != "no"
3019 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
3020 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
3021 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
3022 kerberos5/lib/libwind__L lib/libsqlite3__L
3023 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
3024 kerberos5/lib/libroken__L lib/libcom_err__L
3025 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
3026 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
3027 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
3028 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
3029 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
3030 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
3031 kerberos5/lib/libroken__L: lib/libcrypt__L
3032 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
3033 kerberos5/lib/libheimbase__L: lib/libthr__L
3034 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
3037 lib/libsqlite3__L: lib/libthr__L
3039 .if ${MK_GSSAPI} != "no"
3040 _lib_libgssapi= lib/libgssapi
3043 .if ${MK_KERBEROS} != "no"
3044 _kerberos5_lib= kerberos5/lib
3045 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
3046 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
3047 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
3048 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
3049 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
3050 _kerberos5_lib_libroken= kerberos5/lib/libroken
3051 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
3052 _libsqlite3= lib/libsqlite3
3053 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
3054 _kerberos5_lib_libwind= kerberos5/lib/libwind
3055 _libcom_err= lib/libcom_err
3058 .if ${MK_NIS} != "no"
3059 _lib_libypclnt= lib/libypclnt
3062 .if ${MK_OPENSSL} == "no"
3063 lib/libradius__L: lib/libmd__L
3067 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
3068 .if ${MK_CXX} != "no"
3069 lib/libproc__L: lib/libcxxrt__L
3072 .for _lib in ${_prereq_libs}
3073 ${_lib}__PL: .PHONY .MAKE
3074 .if !defined(_MKSHOWCONFIG) && exists(${.CURDIR}/${_lib})
3075 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
3076 cd ${.CURDIR}/${_lib}; \
3077 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
3078 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
3079 DIRPRFX=${_lib}/ all; \
3080 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
3081 DIRPRFX=${_lib}/ install
3085 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
3086 ${_lib}__L: .PHONY .MAKE
3087 .if !defined(_MKSHOWCONFIG) && exists(${.CURDIR}/${_lib})
3088 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
3089 cd ${.CURDIR}/${_lib}; \
3090 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
3091 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
3092 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
3096 _prereq_libs: ${_prereq_libs:S/$/__PL/}
3097 _startup_libs: ${_startup_libs:S/$/__L/}
3098 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
3099 _generic_libs: ${_generic_libs:S/$/__L/}
3101 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
3102 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
3103 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
3104 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
3105 # parallel. This is safe for the world stage of buildworld though since it has
3106 # already built libraries in a proper order and installed includes into
3107 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
3108 # avoid trashing a system if it crashes mid-install.
3109 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
3113 .include <bsd.subdir.mk>
3115 .if make(check-old) || make(check-old-dirs) || \
3116 make(check-old-files) || make(check-old-libs) || \
3117 make(delete-old) || make(delete-old-dirs) || \
3118 make(delete-old-files) || make(delete-old-libs)
3121 # check for / delete old files section
3124 .include "ObsoleteFiles.inc"
3126 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
3127 else you can not start such an application. Consult UPDATING for more \
3128 information regarding how to cope with the removal/revision bump of a \
3131 .if !defined(BATCH_DELETE_OLD_FILES)
3137 delete-old-files: .PHONY
3138 @echo ">>> Removing old files (only deletes safe to delete libs)"
3139 # Ask for every old file if the user really wants to remove it.
3140 # It's annoying, but better safe than sorry.
3141 # NB: We cannot pass the list of OLD_FILES as a parameter because the
3142 # argument list will get too long. Using .for/.endfor make "loops" will make
3143 # the Makefile parser segfault.
3146 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3147 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | sort | \
3148 while read file; do \
3149 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3150 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
3151 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
3153 for ext in debug symbols; do \
3154 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
3155 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3156 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
3161 # Remove catpages without corresponding manpages.
3163 find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | sort | \
3164 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
3165 while read catpage; do \
3167 if [ ! -e "$${manpage}" ]; then \
3168 rm ${RM_I} $${catpage} <&3; \
3171 @echo ">>> Old files removed"
3173 check-old-files: .PHONY
3174 @echo ">>> Checking for old files"
3176 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3177 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
3178 while read file; do \
3179 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3180 echo "${DESTDIR}/$${file}"; \
3182 for ext in debug symbols; do \
3183 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3184 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
3188 # Check for catpages without corresponding manpages.
3189 @find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \
3190 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
3191 while read catpage; do \
3193 if [ ! -e "$${manpage}" ]; then \
3198 delete-old-libs: .PHONY
3199 @echo ">>> Removing old libraries"
3200 @echo "${OLD_LIBS_MESSAGE}" | fmt
3203 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3204 -V OLD_LIBS | xargs -n1 | sort | \
3205 while read file; do \
3206 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3207 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
3208 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
3210 for ext in debug symbols; do \
3211 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
3212 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3213 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
3218 @echo ">>> Old libraries removed"
3220 check-old-libs: .PHONY
3221 @echo ">>> Checking for old libraries"
3223 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3224 -V OLD_LIBS | xargs -n1 | \
3225 while read file; do \
3226 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3227 echo "${DESTDIR}/$${file}"; \
3229 for ext in debug symbols; do \
3230 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3231 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
3236 delete-old-dirs: .PHONY
3237 @echo ">>> Removing old directories"
3239 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3240 -V OLD_DIRS | xargs -n1 | sort -r | \
3241 while read dir; do \
3242 if [ -d "${DESTDIR}/$${dir}" ]; then \
3243 rmdir -v "${DESTDIR}/$${dir}" || true; \
3244 elif [ -L "${DESTDIR}/$${dir}" ]; then \
3245 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
3247 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3248 rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \
3249 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3250 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
3253 @echo ">>> Old directories removed"
3255 check-old-dirs: .PHONY
3256 @echo ">>> Checking for old directories"
3258 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3259 -V OLD_DIRS | xargs -n1 | sort -r | \
3260 while read dir; do \
3261 if [ -d "${DESTDIR}/$${dir}" ]; then \
3262 echo "${DESTDIR}/$${dir}"; \
3263 elif [ -L "${DESTDIR}/$${dir}" ]; then \
3264 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
3266 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3267 echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \
3268 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3269 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
3273 delete-old: delete-old-files delete-old-dirs .PHONY
3274 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
3276 check-old: check-old-files check-old-libs check-old-dirs .PHONY
3277 @echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
3278 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
3283 # showconfig - show build configuration.
3286 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes; \
3287 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes) 2>&1 | grep ^MK_ | sort -u
3289 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
3290 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
3292 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
3293 .if !defined(_MKSHOWCONFIG) && exists(${KERNCONFDIR}/${KERNCONF})
3294 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
3295 '${KERNCONFDIR}/${KERNCONF}' ; echo
3301 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
3302 DTBOUTPUTPATH= ${.CURDIR}
3306 # Build 'standalone' Device Tree Blob
3309 @PATH=${TMPPATH} MACHINE=${TARGET} \
3310 sh ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
3311 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
3316 # In the following, the first 'rm' in a series will usually remove all
3317 # files and directories. If it does not, then there are probably some
3318 # files with file flags set, so this unsets them and tries the 'rm' a
3319 # second time. There are situations where this target will be cleaning
3320 # some directories via more than one method, but that duplication is
3321 # needed to correctly handle all the possible situations. Removing all
3322 # files without file flags set in the first 'rm' instance saves time,
3323 # because 'chflags' will need to operate on fewer files afterwards.
3325 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
3326 # created by bsd.obj.mk, except that we don't want to .include that file
3327 # in this makefile. We don't do a cleandir walk if MK_AUTO_OBJ is yes
3328 # since it is not possible for files to land in the wrong place.
3330 .if make(cleanworld)
3331 BW_CANONICALOBJDIR:=${OBJTOP}/
3332 .elif make(cleanuniverse)
3333 BW_CANONICALOBJDIR:=${OBJROOT}
3334 .if ${MK_UNIFIED_OBJDIR} == "no"
3335 .error ${.TARGETS} only supported with WITH_UNIFIED_OBJDIR enabled.
3338 cleanworld cleanuniverse: .PHONY
3339 .if !empty(BW_CANONICALOBJDIR) && exists(${BW_CANONICALOBJDIR}) && \
3340 ${.CURDIR:tA} != ${BW_CANONICALOBJDIR:tA}
3341 -rm -rf ${BW_CANONICALOBJDIR}*
3342 -chflags -R 0 ${BW_CANONICALOBJDIR}
3343 rm -rf ${BW_CANONICALOBJDIR}*
3345 .if make(cleanworld) && ${MK_AUTO_OBJ} == "no" && \
3346 (empty(BW_CANONICALOBJDIR) || ${.CURDIR:tA} == ${BW_CANONICALOBJDIR:tA})
3347 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
3348 # To be safe in this case, fall back to a 'make cleandir'
3349 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
3353 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
3354 XDEV_CPUTYPE?=${CPUTYPE}
3356 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
3359 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
3360 MK_MAN=no MK_NLS=no MK_PROFILE=no \
3361 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WERROR=no \
3362 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
3363 CPUTYPE=${XDEV_CPUTYPE}
3365 XDDIR=${TARGET_ARCH}-freebsd
3368 .error XDTP variable should be an absolute path
3371 CDBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/xdev/
3372 CDBOBJTOP= ${CDBOBJROOT}${XDDIR}
3374 INSTALL="sh ${.CURDIR}/tools/install.sh"
3376 TOOLS_PREFIX=${XDTP}
3378 OBJTOP=${CDBOBJTOP:Q} \
3379 OBJROOT=${CDBOBJROOT:Q}
3380 CD2MAKEARGS= ${CDMAKEARGS}
3382 .if ${WANT_COMPILER_TYPE} == gcc || \
3383 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
3384 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
3385 # won't set header path and -L is used to ensure the base library path
3386 # is added before the port PREFIX library path.
3387 CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib
3388 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
3389 # combined with --sysroot.
3390 CD2CFLAGS+= -B${XDDESTDIR}/usr/lib
3391 # Force using libc++ for external GCC.
3392 .if defined(X_COMPILER_TYPE) && \
3393 ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
3394 CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \
3398 CD2CFLAGS+= --sysroot=${XDDESTDIR}/
3399 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \
3400 CPP="${CPP} ${CD2CFLAGS}" \
3401 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
3403 CDTMP= ${OBJTOP}/${XDDIR}/tmp
3404 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${CDMAKEARGS} ${NOFUN}
3405 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} \
3406 ${MAKE} ${CD2MAKEARGS} ${NOFUN}
3407 .if ${MK_META_MODE} != "no"
3408 # Don't rebuild build-tools targets during normal build.
3409 CD2MAKE+= BUILD_TOOLS_META=.NOMETA
3411 XDDESTDIR=${DESTDIR}${XDTP}
3413 .ORDER: xdev-build xdev-install xdev-links
3414 xdev: xdev-build xdev-install .PHONY
3416 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
3417 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
3419 _xb-worldtmp: .PHONY
3420 mkdir -p ${CDTMP}/usr
3421 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
3422 -p ${CDTMP}/usr >/dev/null
3424 _xb-bootstrap-tools: .PHONY
3428 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
3429 cd ${.CURDIR}/${_tool}; \
3430 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
3431 ${CDMAKE} DIRPRFX=${_tool}/ all; \
3432 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
3435 _xb-build-tools: .PHONY
3436 ${_+_}@cd ${.CURDIR}; \
3437 ${CDBENV} ${MAKE} ${CDMAKEARGS} -f Makefile.inc1 ${NOFUN} build-tools
3446 _xb-cross-tools: .PHONY
3447 .for _tool in ${XDEVDIRS}
3448 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
3449 cd ${.CURDIR}/${_tool}; \
3450 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
3451 ${CDMAKE} DIRPRFX=${_tool}/ all
3455 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
3456 mkdir -p ${XDDESTDIR}
3457 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.root.dist \
3458 -p ${XDDESTDIR} >/dev/null
3459 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
3460 -p ${XDDESTDIR}/usr >/dev/null
3461 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
3462 -p ${XDDESTDIR}/usr/include >/dev/null
3463 .if defined(_LIBCOMPAT)
3464 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
3465 -p ${XDDESTDIR}/usr >/dev/null
3467 .if ${MK_TESTS} != "no"
3468 mkdir -p ${XDDESTDIR}${TESTSBASE}
3469 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
3470 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
3473 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
3474 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
3476 _xi-cross-tools: .PHONY
3477 @echo "_xi-cross-tools"
3478 .for _tool in ${XDEVDIRS}
3479 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
3480 cd ${.CURDIR}/${_tool}; \
3481 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
3484 _xi-includes: .PHONY
3485 .if !defined(NO_OBJWALK)
3486 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 _obj \
3487 DESTDIR=${XDDESTDIR}
3489 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
3490 DESTDIR=${XDDESTDIR}
3492 _xi-libraries: .PHONY
3493 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
3494 DESTDIR=${XDDESTDIR}
3497 ${_+_}cd ${XDDESTDIR}/usr/bin; \
3498 mkdir -p ../../../../usr/bin; \
3500 ln -sf ../../${XDTP}/usr/bin/$$i \
3501 ../../../../usr/bin/${XDDIR}-$$i; \
3502 ln -sf ../../${XDTP}/usr/bin/$$i \
3503 ../../../../usr/bin/${XDDIR}${_REVISION}-$$i; \