3 # Make command line options:
4 # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
5 # -DNO_CLEAN do not clean at all
6 # -DDB_FROM_SRC use the user/group databases in src/etc instead of
7 # the system database when installing.
8 # -DNO_SHARE do not go into share subdir
9 # -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,OBJ}
10 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
11 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
12 # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
13 # -DNO_ROOT install without using root privilege
14 # -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects
15 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
16 # LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list
17 # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
18 # LOCAL_MTREE="list of mtree files" to process to allow local directories
19 # to be created before files are installed
20 # LOCAL_LEGACY_DIRS="list of dirs" to add additional dirs to the legacy
22 # LOCAL_BSTOOL_DIRS="list of dirs" to add additional dirs to the
23 # bootstrap-tools target
24 # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
26 # LOCAL_XTOOL_DIRS="list of dirs" to add additional dirs to the
28 # METALOG="path to metadata log" to write permission and ownership
29 # when NO_ROOT is set. (default: ${DESTDIR}/${DISTDIR}/METALOG,
30 # check /etc/make.conf for DISTDIR)
31 # TARGET="machine" to crossbuild world for a different machine type
32 # TARGET_ARCH= may be required when a TARGET supports multiple endians
33 # BUILDENV_SHELL= shell to launch for the buildenv target (def:${SHELL})
34 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
35 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
36 # SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
37 # All libraries and includes, and some build tools will still build.
40 # The intended user-driven targets are:
41 # buildworld - rebuild *everything*, including glue to help do upgrades
42 # installworld- install everything built by "buildworld"
43 # checkworld - run test suite on installed world
44 # doxygen - build API documentation of the kernel
46 # Standard targets (not defined here) are documented in the makefiles in
47 # /usr/share/mk. These include:
48 # obj depend all install clean cleandepend cleanobj
50 .if !defined(TARGET) || !defined(TARGET_ARCH)
51 .error Both TARGET and TARGET_ARCH must be defined.
54 .if make(showconfig) || make(test-system-*)
59 LOCALBASE?= /usr/local
62 .include "share/mk/src.tools.mk"
64 # Cross toolchain changes must be in effect before bsd.compiler.mk
65 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
66 .if defined(CROSS_TOOLCHAIN)
67 .if exists(${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk)
68 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
69 .elif exists(${CROSS_TOOLCHAIN})
70 .include "${CROSS_TOOLCHAIN}"
72 .error CROSS_TOOLCHAIN ${CROSS_TOOLCHAIN} not found
74 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
75 .elif defined(UNIVERSE_TOOLCHAIN)
76 UNIVERSE_TOOLCHAIN_PATH?=${HOST_OBJTOP}/tmp/usr/bin
77 XCC?="${UNIVERSE_TOOLCHAIN_PATH}/cc"
78 XCXX?="${UNIVERSE_TOOLCHAIN_PATH}/c++"
79 XCPP?="${UNIVERSE_TOOLCHAIN_PATH}/cpp"
80 XLD?="${UNIVERSE_TOOLCHAIN_PATH}/ld"
82 .if defined(CROSS_TOOLCHAIN_PREFIX)
83 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
86 XCOMPILERS= CC CXX CPP
87 .for COMPILER in ${XCOMPILERS}
88 .if defined(CROSS_COMPILER_PREFIX)
89 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
91 X${COMPILER}?= ${${COMPILER}}
94 # If a full path to an external cross compiler is given, don't build
96 .if ${XCC:N${CCACHE_BIN}:M/*}
97 MK_CLANG_BOOTSTRAP= no
98 # Make sure sub-makes see the option as disabled so the hack in bsd.sys.mk to
99 # work around incompatible headers in Clang's resource directory is enabled.
100 .MAKEOVERRIDES+= MK_CLANG_BOOTSTRAP
103 # Pull in compiler metadata from buildworld/toolchain if possible to avoid
104 # running CC from bsd.compiler.mk.
105 .if make(installworld) || make(install) || make(distributeworld) || \
107 .-include "${OBJTOP}/toolchain-metadata.mk"
108 .if !defined(_LOADED_TOOLCHAIN_METADATA)
109 .error A build is required first. You may have the wrong MAKEOBJDIRPREFIX set.
113 # Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early. Pull it from the
114 # tree to be friendlier to foreign OS builds. It's safe to do so unconditionally
115 # here since we will always have the right make, unlike in src/Makefile
116 # Don't include bsd.linker.mk yet until XBINUTILS is handled (after src.opts.mk)
117 _NO_INCLUDE_LINKERMK= t
118 # We also want the X_COMPILER* variables if we are using an external toolchain.
119 _WANT_TOOLCHAIN_CROSS_VARS= t
120 .include "share/mk/bsd.compiler.mk"
121 .undef _NO_INCLUDE_LINKERMK
122 .undef _WANT_TOOLCHAIN_CROSS_VARS
123 # src.opts.mk depends on COMPILER_FEATURES
124 .include "share/mk/src.opts.mk"
126 .if ${TARGET} == ${MACHINE}
127 TARGET_CPUTYPE?=${CPUTYPE}
131 .if !empty(TARGET_CPUTYPE)
132 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
134 _TARGET_CPUTYPE=dummy
136 .if ${TARGET} == "arm"
137 .if ${TARGET_CPUTYPE:M*soft*} == ""
138 TARGET_TRIPLE_ABI= gnueabihf
140 TARGET_TRIPLE_ABI= gnueabi
143 MACHINE_TRIPLE_ABI?= unknown
144 MACHINE_TRIPLE?=${MACHINE_ARCH:S/amd64/x86_64/}-${MACHINE_TRIPLE_ABI}-freebsd${OS_REVISION}
145 TARGET_TRIPLE_ABI?= unknown
146 TARGET_TRIPLE?= ${TARGET_ARCH:S/amd64/x86_64/}-${TARGET_TRIPLE_ABI}-freebsd${OS_REVISION}
147 KNOWN_ARCHES?= aarch64/arm64 \
153 powerpc64le/powerpc \
157 .if ${TARGET} == ${TARGET_ARCH}
160 _t= ${TARGET_ARCH}/${TARGET}
163 .if empty(KNOWN_ARCHES:M${_t})
164 .error Unknown target ${TARGET_ARCH}:${TARGET}.
168 .if ${TARGET_ARCH} == "amd64"
169 LIBCOMPAT_INCLUDE_DIRS+= i386
170 .elif ${TARGET_ARCH} == "aarch64"
171 LIBCOMPAT_INCLUDE_DIRS+= arm
174 .if !defined(_MKSHOWCONFIG)
175 .if ((defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == "gcc") || \
176 (!defined(X_COMPILER_TYPE) && ${COMPILER_TYPE} == "gcc"))
177 .if ${TARGET} == "arm"
178 _GCC_BROKEN="https://reviews.freebsd.org/D36754"
180 .if ${TARGET_ARCH} == "powerpc"
181 _GCC_BROKEN=Missing atomic builtins in libc++.
183 .if ${TARGET_ARCH:Mpowerpc64*}
184 _GCC_BROKEN=libsys.so.7.full has a LOAD segment with RWX permissions.
186 .if ${TARGET} == "riscv"
187 _GCC_BROKEN=boot code linker script issues.
189 .if defined(_GCC_BROKEN)
190 .warning Target ${TARGET} is broken with GCC: ${_GCC_BROKEN}
191 .if defined(TRY_GCC_BROKEN)
192 .warning Trying build anyway.
194 .error Avoiding broken build. Define TRY_GCC_BROKEN to try anyway.
200 .if ${.MAKE.OS} != "FreeBSD"
201 CROSSBUILD_HOST=${.MAKE.OS}
202 .if ${.MAKE.OS} != "Linux" && ${.MAKE.OS} != "Darwin"
203 .warning Unsupported crossbuild system: ${.MAKE.OS}. Build will probably fail!
205 # We need to force NO_ROOT/DB_FROM_SRC builds when building on other operating
206 # systems since the BSD.foo.dist specs contain users and groups that do not
207 # exist by default on a Linux/MacOS system.
213 # If all targets are disabled for system llvm then don't expect it to work
215 .if !defined(TOOLS_PREFIX) && ${MK_LLVM_TARGET_ALL} == "no" && \
216 ${MACHINE} != ${TARGET} && ${MACHINE_ARCH} != ${TARGET_ARCH} && \
218 MK_SYSTEM_COMPILER= no
222 # Handle external binutils.
223 .if defined(CROSS_TOOLCHAIN_PREFIX)
224 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
226 XBINUTILS= AS AR ELFCTL LD NM OBJCOPY RANLIB SIZE STRINGS STRIPBIN
227 .for BINUTIL in ${XBINUTILS}
228 .if defined(CROSS_BINUTILS_PREFIX) && \
229 exists(${CROSS_BINUTILS_PREFIX}/${${BINUTIL}})
230 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX:C,/*$,,}/${${BINUTIL}}
232 X${BINUTIL}?= ${${BINUTIL}}
236 # If a full path to an external linker is given, don't build lld.
241 # We also want the X_LINKER* variables if we are using an external toolchain.
242 _WANT_TOOLCHAIN_CROSS_VARS= t
243 .include "share/mk/bsd.linker.mk"
244 .undef _WANT_TOOLCHAIN_CROSS_VARS
246 # Begin WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD
248 # WITH_SYSTEM_COMPILER - Pull in needed values and make a decision.
250 # Check if there is a local compiler that can satisfy as an external compiler.
251 # Which compiler is expected to be used?
252 .if ${MK_CLANG_BOOTSTRAP} == "yes"
253 WANT_COMPILER_TYPE= clang
258 .if !defined(WANT_COMPILER_FREEBSD_VERSION) && !make(showconfig) && \
259 !make(test-system-linker)
260 .if ${WANT_COMPILER_TYPE} == "clang"
261 WANT_COMPILER_FREEBSD_VERSION_FILE= lib/clang/freebsd_cc_version.h
262 WANT_COMPILER_FREEBSD_VERSION!= \
263 awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
264 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
265 WANT_COMPILER_VERSION_FILE= lib/clang/include/clang/Basic/Version.inc
266 WANT_COMPILER_VERSION!= \
267 awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
268 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
270 .export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION
271 .endif # !defined(WANT_COMPILER_FREEBSD_VERSION)
273 # It needs to be the same revision as we would build for the bootstrap.
274 # If the expected vs CC is different then we can't skip.
275 # GCC cannot be used for cross-arch yet. For clang we pass -target later if
276 # TARGET_ARCH!=MACHINE_ARCH.
277 .if ${MK_SYSTEM_COMPILER} == "yes" && \
278 defined(WANT_COMPILER_FREEBSD_VERSION) && \
279 ${MK_CLANG_BOOTSTRAP} == "yes" && \
281 ${X_COMPILER_TYPE} == ${WANT_COMPILER_TYPE} && \
282 (${X_COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \
283 ${X_COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \
284 ${X_COMPILER_FREEBSD_VERSION} == ${WANT_COMPILER_FREEBSD_VERSION}
285 # Everything matches, disable the bootstrap compiler.
286 MK_CLANG_BOOTSTRAP= no
287 USING_SYSTEM_COMPILER= yes
288 .endif # ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE}
290 # WITH_SYSTEM_LD - Pull in needed values and make a decision.
292 # Check if there is a local linker that can satisfy as an external linker.
293 # Which linker is expected to be used?
294 .if ${MK_LLD_BOOTSTRAP} == "yes"
295 WANT_LINKER_TYPE= lld
300 .if !defined(WANT_LINKER_FREEBSD_VERSION) && !make(showconfig) && \
301 !make(test-system-compiler)
302 .if ${WANT_LINKER_TYPE} == "lld"
303 WANT_LINKER_FREEBSD_VERSION_FILE= lib/clang/include/lld/Common/Version.inc
304 WANT_LINKER_FREEBSD_VERSION!= \
305 awk '$$2 == "LLD_FREEBSD_VERSION" {print $$3}' \
306 ${SRCDIR}/${WANT_LINKER_FREEBSD_VERSION_FILE} || echo unknown
307 WANT_LINKER_VERSION_FILE= lib/clang/include/lld/Common/Version.inc
308 WANT_LINKER_VERSION!= \
309 awk '$$2 == "LLD_VERSION_STRING" {gsub("\"", "", $$3); split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
310 ${SRCDIR}/${WANT_LINKER_VERSION_FILE} || echo unknown
312 WANT_LINKER_FREEBSD_VERSION_FILE=
313 WANT_LINKER_FREEBSD_VERSION=
315 .export WANT_LINKER_FREEBSD_VERSION WANT_LINKER_VERSION
316 .endif # !defined(WANT_LINKER_FREEBSD_VERSION)
318 .if ${MK_SYSTEM_LINKER} == "yes" && \
319 defined(WANT_LINKER_FREEBSD_VERSION) && \
320 (${MK_LLD_BOOTSTRAP} == "yes") && \
322 ${X_LINKER_TYPE} == ${WANT_LINKER_TYPE} && \
323 ${X_LINKER_VERSION} == ${WANT_LINKER_VERSION} && \
324 ${X_LINKER_FREEBSD_VERSION} == ${WANT_LINKER_FREEBSD_VERSION}
325 # Everything matches, disable the bootstrap linker.
327 USING_SYSTEM_LINKER= yes
328 .endif # ${WANT_LINKER_TYPE} == ${LINKER_TYPE}
330 # WITH_SYSTEM_COMPILER / WITH_SYSTEM_LINKER - Handle defaults and debug.
331 USING_SYSTEM_COMPILER?= no
332 USING_SYSTEM_LINKER?= no
334 TEST_SYSTEM_COMPILER_VARS= \
335 USING_SYSTEM_COMPILER MK_SYSTEM_COMPILER \
336 MK_CROSS_COMPILER MK_CLANG_BOOTSTRAP \
337 WANT_COMPILER_TYPE WANT_COMPILER_VERSION WANT_COMPILER_VERSION_FILE \
338 WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \
339 CC COMPILER_TYPE COMPILER_FEATURES COMPILER_VERSION \
340 COMPILER_FREEBSD_VERSION \
341 XCC X_COMPILER_TYPE X_COMPILER_FEATURES X_COMPILER_VERSION \
342 X_COMPILER_FREEBSD_VERSION
343 TEST_SYSTEM_LINKER_VARS= \
344 USING_SYSTEM_LINKER MK_SYSTEM_LINKER \
346 WANT_LINKER_TYPE WANT_LINKER_VERSION WANT_LINKER_VERSION_FILE \
347 WANT_LINKER_FREEBSD_VERSION WANT_LINKER_FREEBSD_VERSION_FILE \
348 LD LINKER_TYPE LINKER_FEATURES LINKER_VERSION \
349 LINKER_FREEBSD_VERSION \
350 XLD X_LINKER_TYPE X_LINKER_FEATURES X_LINKER_VERSION \
351 X_LINKER_FREEBSD_VERSION
353 .for _t in compiler linker
354 test-system-${_t}: .PHONY
355 .for v in ${TEST_SYSTEM_${_t:tu}_VARS}
356 ${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}"
359 .if (make(buildworld) || make(buildkernel) || make(kernel-toolchain) || \
360 make(toolchain) || make(_cross-tools))
361 .if ${USING_SYSTEM_COMPILER} == "yes"
362 .info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler.
363 .elif ${MK_CLANG_BOOTSTRAP} == "yes"
364 .info SYSTEM_COMPILER: libclang will be built for bootstrapping a cross-compiler.
366 .if ${USING_SYSTEM_LINKER} == "yes"
367 .info SYSTEM_LINKER: Determined that LD=${LD} matches the source tree. Not bootstrapping a cross-linker.
368 .elif ${MK_LLD_BOOTSTRAP} == "yes"
369 .info SYSTEM_LINKER: libclang will be built for bootstrapping a cross-linker.
373 # End WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD
375 # Store some compiler metadata for use in installworld where we don't
376 # want to invoke CC at all.
377 _TOOLCHAIN_METADATA_VARS= COMPILER_VERSION \
380 COMPILER_FREEBSD_VERSION \
381 COMPILER_RESOURCE_DIR \
385 LINKER_FREEBSD_VERSION
386 toolchain-metadata.mk: .PHONY .META
388 @echo ".info Using cached toolchain metadata from build at $$(hostname) on $$(date)" \
390 @echo "_LOADED_TOOLCHAIN_METADATA=t" >> ${.TARGET}
391 .for v in ${_TOOLCHAIN_METADATA_VARS}
392 @echo "${v}=${${v}}" >> ${.TARGET}
393 @echo "X_${v}=${X_${v}}" >> ${.TARGET}
395 @echo ".export ${_TOOLCHAIN_METADATA_VARS}" >> ${.TARGET}
396 @echo ".export ${_TOOLCHAIN_METADATA_VARS:C,^,X_,}" >> ${.TARGET}
399 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
400 # keep the users system reasonably usable. For static->dynamic root upgrades,
401 # we don't want to install a dynamic binary without rtld and the needed
402 # libraries. More commonly, for dynamic root, we don't want to install a
403 # binary that requires a newer library version that hasn't been installed yet.
404 # This ordering is not a guarantee though. The only guarantee of a working
405 # system here would require fine-grained ordering of all components based
406 # on their dependencies.
407 .if !empty(SUBDIR_OVERRIDE)
408 SUBDIR= ${SUBDIR_OVERRIDE}
411 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
412 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
413 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
414 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
415 _REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
417 .for _DIR in ${LOCAL_LIB_DIRS}
418 .if ${_DIR} == ".WAIT" || (empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
422 .if !defined(NO_ROOT) && (make(installworld) || make(install))
423 # Ensure libraries are installed before progressing.
427 .if ${MK_CDDL} != "no"
431 .if ${MK_KERBEROS} != "no"
434 .if ${MK_RESCUE} != "no"
438 .if ${MK_CRYPT} != "no"
441 .if !defined(NO_SHARE)
444 .if ${MK_BOOT} != "no"
447 SUBDIR+=sys usr.bin usr.sbin
448 .if ${MK_TESTS} != "no"
452 # Local directories are built in parallel with the base system directories.
453 # Users may insert a .WAIT directive at the beginning or elsewhere within
454 # the LOCAL_DIRS and LOCAL_LIB_DIRS lists as needed.
455 .for _DIR in ${LOCAL_DIRS}
456 .if ${_DIR} == ".WAIT" || exists(${.CURDIR}/${_DIR}/Makefile)
461 # We must do etc/ last as it hooks into building the man whatis file
462 # by calling 'makedb' in share/man. This is only relevant for
463 # install/distribute so they build the whatis file after every manpage is
465 .if make(installworld) || make(install)
470 .endif # !empty(SUBDIR_OVERRIDE)
473 .warning The src.conf WITHOUT_CLEAN option can now be used instead of NOCLEAN.
476 .if defined(NO_CLEAN)
477 .info The src.conf WITHOUT_CLEAN option can now be used instead of NO_CLEAN.
480 .if defined(NO_CLEANDIR)
481 CLEANDIR= clean cleandepend
486 .if defined(WORLDFAST)
491 .if ${MK_META_MODE} == "yes"
492 # If filemon is used then we can rely on the build being incremental-safe.
493 # The .meta files will also track the build command and rebuild should
495 .if empty(.MAKE.MODE:Mnofilemon)
499 .if defined(NO_OBJWALK) || ${MK_AUTO_OBJ} == "yes"
503 .if !defined(NO_OBJWALK)
508 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
510 .if empty(SHELL:M*csh*)
511 BUILDENV_SHELL?=${SHELL}
513 BUILDENV_SHELL?=/bin/sh
516 .if !defined(_MKSHOWCONFIG)
517 .if !defined(VCS_REVISION) || empty(VCS_REVISION)
518 .if !defined(SVNVERSION_CMD) || empty(SVNVERSION_CMD)
519 . for _D in ${PATH:S,:, ,g}
520 . if exists(${_D}/svnversion)
521 SVNVERSION_CMD?=${_D}/svnversion
523 . if exists(${_D}/svnliteversion)
524 SVNVERSION_CMD?=${_D}/svnliteversion
528 .if defined(SVNVERSION_CMD) && !empty(SVNVERSION_CMD)
529 _VCS_REVISION?= $$(eval ${SVNVERSION_CMD} ${SRCDIR})
530 . if !empty(_VCS_REVISION)
531 VCS_REVISION= $$(echo r${_VCS_REVISION})
537 .if !defined(GIT_CMD) || empty(GIT_CMD)
538 . for _P in /usr/bin /usr/local/bin
539 . if exists(${_P}/git)
546 .if !defined(OSRELDATE)
547 .if exists(/usr/include/osreldate.h)
548 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
549 /usr/include/osreldate.h
556 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
557 .for _V in BRANCH REVISION TYPE
559 _${_V}!= eval $$(awk '/^${_V}=/{print}' ${SRCTOP}/sys/conf/newvers.sh); echo $$${_V}
563 .if !defined(SRCRELDATE)
564 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
565 ${SRCDIR}/sys/sys/param.h
568 .if !defined(VERSION)
569 VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
572 MAJOR_REVISION= ${_REVISION:R}
574 _PKG_REVISION= ${_REVISION}
575 _STRTIMENOW= %Y%m%d%H%M%S
576 _TIMENOW= ${_STRTIMENOW:gmtime}
578 .if ${_BRANCH:MCURRENT*} || ${_BRANCH:MSTABLE*} || ${_BRANCH:MPRERELEASE*}
579 _PKG_REVISION:= ${MAJOR_REVISION}
580 BRANCH_EXT= ${MAJOR_REVISION}.snap
581 EXTRA_REVISION= .snap${_TIMENOW}
582 .elif ${_BRANCH:MALPHA*}
584 EXTRA_REVISION= .${_BRANCH:C/ALPHA([0-9]+).*/\1/}.${_TIMENOW}
585 .elif ${_BRANCH:MBETA*}
587 EXTRA_REVISION= .${_BRANCH:C/BETA([0-9]+).*/\1/}.${_TIMENOW}
588 .elif ${_BRANCH:MRC*}
590 EXTRA_REVISION= .rc${_BRANCH:C/RC([0-9]+).*/\1/}.${_TIMENOW}
591 .elif ${_BRANCH:M*-p*}
592 EXTRA_REVISION= p${_BRANCH:C/.*-p([0-9]+$)/\1/}
594 .if !defined(PKG_VERSION)
595 PKG_VERSION:= ${_PKG_REVISION}${EXTRA_REVISION:C/[[:space:]]//g}
597 .endif # !defined(PKG_VERSION)
599 .if !defined(PKG_TIMESTAMP)
601 SOURCE_DATE_EPOCH= ${TIMEEPOCHNOW:gmtime}
603 SOURCE_DATE_EPOCH= ${PKG_TIMESTAMP}
606 PKG_NAME_PREFIX?= FreeBSD
607 PKG_MAINTAINER?= re@FreeBSD.org
608 PKG_WWW?= https://www.FreeBSD.org
609 .export PKG_NAME_PREFIX
610 .export PKG_MAINTAINER
613 .if !defined(_MKSHOWCONFIG)
614 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} -f /dev/null \
615 -m ${.CURDIR}/share/mk MK_AUTO_OBJ=no -V CPUTYPE
616 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
617 .error CPUTYPE global should be set with ?=.
621 BUILD_ARCH!= uname -p
622 # On some Linux systems uname -p returns "unknown" so skip this check there.
623 # This check only exists to tell people to use TARGET_ARCH instead of
624 # MACHINE_ARCH so skipping it when crossbuilding on non-FreeBSD should be fine.
625 .if ${MACHINE_ARCH} != ${BUILD_ARCH} && ${.MAKE.OS} == "FreeBSD"
626 .error To cross-build, set TARGET_ARCH.
629 WORLDTMP?= ${OBJTOP}/tmp
630 BPATH= ${CCACHE_WRAPPER_PATH_PFX}${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin:${WORLDTMP}/legacy/usr/libexec
631 XPATH= ${WORLDTMP}/bin:${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
633 # When building we want to find the cross tools before the host tools in ${BPATH}.
634 # We also need to add UNIVERSE_TOOLCHAIN_PATH so that we can find the shared
635 # toolchain files (clang, lld, etc.) during make universe/tinderbox
636 STRICTTMPPATH= ${XPATH}:${BPATH}:${UNIVERSE_TOOLCHAIN_PATH}
637 # We should not be using tools from /usr/bin accidentally since this could cause
638 # the build to break on other systems that don't have that tool. For now we
639 # still allow using the old behaviour (inheriting $PATH) if
640 # BUILD_WITH_STRICT_TMPPATH is set to 0 but this will eventually be removed.
642 # Currently strict $PATH can cause build failures. Once the remaining issues
643 # have been resolved it will be turned on by default.
644 BUILD_WITH_STRICT_TMPPATH?=0
645 .if defined(CROSSBUILD_HOST)
646 # When building on non-FreeBSD we can't rely on the tools in /usr/bin being compatible
647 # with what FreeBSD expects. Therefore we only use tools from STRICTTMPPATH
648 # during the world build stage. We build most tools during the bootstrap-tools
649 # phase but symlink host tools that are known to work instead of building them
650 BUILD_WITH_STRICT_TMPPATH:=1
652 .if ${BUILD_WITH_STRICT_TMPPATH} != 0
653 TMPPATH= ${STRICTTMPPATH}
655 TMPPATH= ${STRICTTMPPATH}:${PATH}
659 # Avoid running mktemp(1) unless actually needed.
660 # It may not be functional, e.g., due to new ABI
661 # when in the middle of installing over this system.
663 .if make(distributeworld) || make(installworld) || make(stageworld)
664 .if ${BUILD_WITH_STRICT_TMPPATH} != 0
665 MKTEMP=${WORLDTMP}/legacy/usr/bin/mktemp
666 .if !exists(${MKTEMP})
667 .error mktemp binary doesn't exist in expected location: ${MKTEMP}
672 INSTALLTMP!= ${MKTEMP} -d -u -t install
674 .if ${.MAKE.OS} == "FreeBSD"
675 # When building on FreeBSD we always copy the host tools instead of linking
676 # into INSTALLTMP to avoid issues with incompatible libraries (see r364030).
677 # Note: we could create links if we don't intend to update the current machine.
678 INSTALLTMP_COPY_HOST_TOOL=cp
680 # However, this is not necessary on Linux/macOS. Additionally, copying the host
681 # tools to another directory with cp results in AMFI Launch Constraint
682 # Violations on macOS Ventura as part of its System Integrity Protection.
683 INSTALLTMP_COPY_HOST_TOOL=ln -s
687 .if make(stagekernel) || make(distributekernel)
693 # Building a world goes through the following stages
695 # 1. legacy stage [BMAKE]
696 # This stage is responsible for creating compatibility
697 # shims that are needed by the bootstrap-tools,
698 # build-tools and cross-tools stages. These are generally
699 # APIs that tools from one of those three stages need to
700 # build that aren't present on the host.
701 # 1. bootstrap-tools stage [BMAKE]
702 # This stage is responsible for creating programs that
703 # are needed for backward compatibility reasons. They
704 # are not built as cross-tools.
705 # 2. build-tools stage [TMAKE]
706 # This stage is responsible for creating the object
707 # tree and building any tools that are needed during
708 # the build process. Some programs are listed during
709 # this phase because they build binaries to generate
710 # files needed to build these programs. This stage also
711 # builds the 'build-tools' target rather than 'all'.
712 # 3. cross-tools stage [XMAKE]
713 # This stage is responsible for creating any tools that
714 # are needed for building the system. A cross-compiler is one
715 # of them. This differs from build tools in two ways:
716 # 1. the 'all' target is built rather than 'build-tools'
717 # 2. these tools are installed into TMPPATH for stage 4.
718 # 4. world stage [WMAKE]
719 # This stage actually builds the world.
720 # 5. install stage (optional) [IMAKE]
721 # This stage installs a previously built world.
726 MINIMUM_SUPPORTED_OSREL?= 1104001
727 MINIMUM_SUPPORTED_REL?= 11.4
729 # Common environment for world related stages
731 MACHINE_ARCH=${TARGET_ARCH} \
733 CPUTYPE=${TARGET_CPUTYPE}
734 .if ${MK_META_MODE} != "no"
735 # Don't rebuild build-tools targets during normal build.
736 CROSSENV+= BUILD_TOOLS_META=.NOMETA
738 .if defined(TARGET_CFLAGS)
739 CROSSENV+= ${TARGET_CFLAGS}
741 .if (${TARGET} != ${MACHINE} && !defined(WITH_LOCAL_MODULES)) || \
742 defined(WITHOUT_LOCAL_MODULES)
743 CROSSENV+= LOCAL_MODULES=
746 BOOTSTRAPPING_OSRELDATE?=${OSRELDATE}
748 # bootstrap-tools stage
749 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
750 TOOLS_PREFIX=${TOOLS_PREFIX_UNDEF:U${WORLDTMP}} \
751 PATH=${BPATH:Q}:${PATH:Q} \
752 WORLDTMP=${WORLDTMP} \
753 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
754 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
756 OBJTOP='${WORLDTMP}/obj-tools' \
757 OBJROOT='$${OBJTOP}/' \
758 UNIVERSE_TOOLCHAIN_PATH=${UNIVERSE_TOOLCHAIN_PATH} \
760 BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
761 BWPHASE=${.TARGET:C,^_,,} \
782 ${TIME_ENV} ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
784 .if empty(.MAKEOVERRIDES:MMK_LLVM_TARGET_ALL)
785 BMAKE+= MK_LLVM_TARGET_ALL=no
790 ${TIME_ENV} ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
791 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
793 BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
794 BWPHASE=${.TARGET:C,^_,,} \
810 # TOOLS_PREFIX set in BMAKE
812 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
814 MK_LLVM_BINUTILS=no \
818 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
819 PATH=${BPATH:Q}:${PATH:Q} \
820 WORLDTMP=${WORLDTMP} \
821 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
823 KTMAKE= ${TIME_ENV} \
824 TOOLS_PREFIX=${TOOLS_PREFIX_UNDEF:U${WORLDTMP}} \
825 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
827 OBJTOP='${WORLDTMP}/obj-kernel-tools' \
828 OBJROOT='$${OBJTOP}/' \
829 UNIVERSE_TOOLCHAIN_PATH=${UNIVERSE_TOOLCHAIN_PATH} \
831 BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
844 WMAKEENV= ${CROSSENV} \
845 INSTALL="${INSTALL_CMD} -U" \
850 HMAKE= PATH=${TMPPATH:Q} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
852 HMAKE+= PATH=${TMPPATH:Q} METALOG=${METALOG} -DNO_ROOT
855 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
856 CPP="${XCPP} ${XCFLAGS}" \
857 AS="${XAS}" AR="${XAR}" ELFCTL="${XELFCTL}" LD="${XLD}" \
858 LLVM_LINK="${XLLVM_LINK}" NM=${XNM} OBJCOPY="${XOBJCOPY}" \
859 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
860 SIZE="${XSIZE}" STRIPBIN="${XSTRIPBIN}"
862 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
863 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
864 # directory, but the compiler will look in the right place for its
865 # tools so we don't need to tell it where to look.
866 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
870 # The internal bootstrap compiler has a default sysroot set by TOOLS_PREFIX
871 # and target set by TARGET/TARGET_ARCH. However, there are several needs to
872 # always pass an explicit --sysroot and -target.
873 # - External compiler needs sysroot and target flags.
874 # - External ld needs sysroot.
875 # - To be clear about the use of a sysroot when using the internal compiler.
876 # - Easier debugging.
877 # - Allowing WITH_SYSTEM_COMPILER+WITH_META_MODE to work together due to
878 # the flip-flopping build command when sometimes using external and
879 # sometimes using internal.
880 # - Allow using lld which has no support for default paths.
881 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
882 BFLAGS+= -B${WORLDTMP}/usr/bin
884 .if ${WANT_COMPILER_TYPE} == gcc || \
885 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
886 .elif ${WANT_COMPILER_TYPE} == clang || \
887 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang)
888 XCFLAGS+= -target ${TARGET_TRIPLE}
890 XCFLAGS+= --sysroot=${WORLDTMP}
896 .include "share/mk/bsd.compat.pre.mk"
897 .for LIBCOMPAT in ${_ALL_LIBCOMPATS}
898 .if ${MK_LIB${LIBCOMPAT}} == "yes"
899 _LIBCOMPATS+= ${LIBCOMPAT}
902 .include "Makefile.libcompat"
904 # META_MODE normally ignores host file changes since every build updates
905 # timestamps (see NO_META_IGNORE_HOST in sys.mk). There are known times
906 # when the ABI breaks though that we want to force rebuilding WORLDTMP
907 # to get updated host tools.
908 .if ${MK_META_MODE} == "yes" && ${MK_CLEAN} == "no" && \
909 !defined(NO_META_IGNORE_HOST) && !defined(NO_META_IGNORE_HOST_HEADERS) && \
910 !defined(_MKSHOWCONFIG)
911 # r318736 - ino64 major ABI breakage
912 META_MODE_BAD_ABI_VERS+= 1200031
914 .if !defined(OBJDIR_HOST_OSRELDATE)
915 .if exists(${OBJTOP}/host-osreldate.h)
916 OBJDIR_HOST_OSRELDATE!= \
917 awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
918 ${OBJTOP}/host-osreldate.h
919 .elif exists(${WORLDTMP}/usr/include/osreldate.h)
920 OBJDIR_HOST_OSRELDATE= 0
922 .export OBJDIR_HOST_OSRELDATE
925 # Note that this logic is the opposite of normal BOOTSTRAP handling. We want
926 # to compare the WORLDTMP's OSRELDATE to the host's OSRELDATE. If the WORLDTMP
927 # is older than the ABI-breakage OSRELDATE of the HOST then we rebuild.
928 .if defined(OBJDIR_HOST_OSRELDATE)
929 .for _ver in ${META_MODE_BAD_ABI_VERS}
930 .if ${OSRELDATE} >= ${_ver} && ${OBJDIR_HOST_OSRELDATE} < ${_ver}
931 _meta_mode_need_rebuild= ${_ver}
934 .if defined(_meta_mode_need_rebuild)
935 .info META_MODE: Rebuilding host tools due to ABI breakage in __FreeBSD_version ${_meta_mode_need_rebuild}.
936 NO_META_IGNORE_HOST_HEADERS= 1
937 .export NO_META_IGNORE_HOST_HEADERS
938 .endif # defined(_meta_mode_need_rebuild)
939 .endif # defined(OBJDIR_HOST_OSRELDATE)
940 .endif # ${MK_META_MODE} == "yes" && ${MK_CLEAN} == "no" ...
941 # This is only used for META_MODE+filemon to track what the oldest
942 # __FreeBSD_version is in WORLDTMP. This purposely does NOT have
943 # a make dependency on /usr/include/osreldate.h as the file should
944 # only be copied when it is missing or meta mode determines it has changed.
945 # Since host files are normally ignored without NO_META_IGNORE_HOST
946 # the file will never be updated unless that flag is specified. This
947 # allows tracking the oldest osreldate to force rebuilds via
948 # META_MODE_BADABI_REVS above.
949 host-osreldate.h: # DO NOT ADD /usr/include/osreldate.h here
950 .if !defined(CROSSBUILD_HOST)
951 @cp -f /usr/include/osreldate.h ${.TARGET}
953 @echo "#ifndef __FreeBSD_version" > ${.TARGET}
954 @echo "#define __FreeBSD_version ${OSRELDATE}" >> ${.TARGET}
955 @echo "#endif" >> ${.TARGET}
958 WMAKE= ${TIME_ENV} ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
959 BWPHASE=${.TARGET:C,^_,,} \
962 IMAKEENV= ${CROSSENV}
963 IMAKE= ${TIME_ENV} ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
964 ${IMAKE_INSTALL} ${IMAKE_MTREE}
965 .if empty(.MAKEFLAGS:M-n)
966 IMAKEENV+= PATH=${STRICTTMPPATH:Q}:${INSTALLTMP:Q} \
967 LD_LIBRARY_PATH=${INSTALLTMP:Q} \
968 PATH_LOCALE=${INSTALLTMP}/locale
969 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
971 IMAKEENV+= PATH=${TMPPATH:Q}:${INSTALLTMP:Q}
974 # When generating install media, do not allow user and group information from
975 # the build host to affect the contents of the distribution.
976 .if make(distributeworld) || make(distrib-dirs) || make(distribution) || \
981 .if defined(DB_FROM_SRC)
982 INSTALLFLAGS+= -N ${.CURDIR}/etc
983 MTREEFLAGS+= -N ${.CURDIR}/etc
985 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
986 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
988 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
989 METALOG:= ${METALOG:C,//+,/,g}
990 IMAKE+= -DNO_ROOT METALOG=${METALOG}
991 METALOG_INSTALLFLAGS= -U -M ${METALOG} -D ${INSTALL_DDIR}
992 INSTALLFLAGS+= ${METALOG_INSTALLFLAGS}
993 CERTCTLFLAGS= ${METALOG_INSTALLFLAGS}
996 .if defined(BUILD_PKGS)
997 INSTALLFLAGS+= -h sha256
999 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
1000 IMAKE_INSTALL= INSTALL="${INSTALL_CMD} ${INSTALLFLAGS}"
1001 IMAKE_MTREE= MTREE_CMD="${MTREE_CMD} ${MTREEFLAGS}"
1004 .if make(distributeworld) || make(packageworld) || make(distributekernel) || \
1006 .if ${DISTDIR:U/} == /
1007 .error DISTDIR must be set for make distribute* and make package*, and may not be the root directory.
1009 .if !defined(NO_ROOT) || !defined(METALOG)
1010 .error NO_ROOT and METALOG must be set for make distribute* and make package*.
1014 .if make(distributeworld)
1015 CERTCTLDESTDIR= ${DESTDIR}/${DISTDIR}
1016 CERTCTLFLAGS+= -d /base
1018 CERTCTLDESTDIR= ${DESTDIR}
1020 CERTCTLFLAGS+= -D "${CERTCTLDESTDIR}"
1022 DESTDIR_MTREEFLAGS= -deU
1023 # When creating worldtmp we don't need to set the directories as owned by root
1024 # so we also pass -W
1025 WORLDTMP_MTREEFLAGS= -deUW
1026 .if defined(NO_ROOT)
1027 # When building with -DNO_ROOT we shouldn't be changing the directories
1028 # that are created by mtree to be owned by root/wheel.
1029 DESTDIR_MTREEFLAGS+= -W
1031 .if defined(DB_FROM_SRC)
1032 DISTR_MTREEFLAGS= -N ${.CURDIR}/etc
1034 DISTR_MTREECMD= ${MTREE_CMD}
1035 .if ${BUILD_WITH_STRICT_TMPPATH} != 0
1036 DISTR_MTREECMD= ${WORLDTMP}/legacy/usr/sbin/mtree
1038 DISTR_MTREE= ${DISTR_MTREECMD} ${DISTR_MTREEFLAGS}
1039 WORLDTMP_MTREE= ${DISTR_MTREECMD} ${WORLDTMP_MTREEFLAGS}
1040 DESTDIR_MTREE= ${DISTR_MTREECMD} ${DESTDIR_MTREEFLAGS}
1042 METALOG_SORT_CMD= env -i LC_COLLATE=C sort
1045 KMAKEENV= ${WMAKEENV:NSYSROOT=*}
1046 KMAKE= ${TIME_ENV} ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
1051 # Attempt to rebuild the entire system, with reasonable chance of
1052 # success, regardless of how old your existing system is.
1054 _sanity_check: .PHONY .MAKE
1055 .if ${.CURDIR:C/[^,]//g} != ""
1056 # The m4 build of sendmail files doesn't like it if ',' is used
1057 # anywhere in the path of it's files.
1059 @echo "*** Error: path to source tree contains a comma ','"
1062 .elif ${.CURDIR:M*\:*} != ""
1063 # Using ':' leaks into PATH and breaks finding cross-tools.
1065 @echo "*** Error: path to source tree contains a colon ':'"
1070 # Our current approach to dependency tracking cannot cope with certain source
1071 # tree changes, particularly with respect to removing source files and
1072 # replacing generated files. Handle these cases here in an ad-hoc fashion.
1073 _cleanobj_fast_depend_hack: .PHONY
1074 @echo ">>> Deleting stale dependencies...";
1075 MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} \
1076 ALL_libcompats=${_ALL_libcompats:Q} \
1077 sh ${.CURDIR}/tools/build/depend-cleanup.sh ${OBJTOP}
1079 _cleanworldtmp: .PHONY
1080 .if ${MK_CLEAN} == "yes"
1082 @echo "--------------------------------------------------------------"
1083 @echo ">>> Cleaning up the temporary build tree"
1084 @echo "--------------------------------------------------------------"
1087 # Note: for delete-old we need to set $PATH to also include the host $PATH
1088 # since otherwise a partial build with missing symlinks in ${WORLDTMP}/legacy/
1089 # will fail to run due to missing binaries. $WMAKE sets PATH to only ${TMPPATH}
1090 # so we remove that assignment from $WMAKE and prepend the new $PATH
1091 ${_+_}@if [ -e "${WORLDTMP}" ]; then \
1092 echo ">>> Deleting stale files in build tree..."; \
1093 cd ${.CURDIR}; env PATH=${TMPPATH:Q}:${PATH:Q} ${WMAKE:NPATH=*} \
1094 _NO_INCLUDE_COMPILERMK=t -DBATCH_DELETE_OLD_FILES delete-old \
1095 delete-old-libs >/dev/null; \
1097 rm -rf ${WORLDTMP}/legacy/usr/include
1098 .if ${USING_SYSTEM_COMPILER} == "yes"
1100 if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \
1101 inum=$$(ls -i ${WORLDTMP}/usr/bin/${cc}); \
1102 find ${WORLDTMP}/usr/bin -inum $${inum%% *} -delete; \
1105 .endif # ${USING_SYSTEM_COMPILER} == "yes"
1106 .if ${USING_SYSTEM_LINKER} == "yes"
1107 @rm -f ${WORLDTMP}/usr/bin/ld ${WORLDTMP}/usr/bin/ld.lld
1108 .endif # ${USING_SYSTEM_LINKER} == "yes"
1109 .endif # ${MK_CLEAN} == "yes"
1112 @echo "--------------------------------------------------------------"
1113 @echo ">>> Rebuilding the temporary build tree"
1114 @echo "--------------------------------------------------------------"
1115 @mkdir -p ${WORLDTMP}
1116 @touch ${WORLDTMP}/${.TARGET}
1117 # We can't use mtree to create the worldtmp directories since it may not be
1118 # available on the target system (this happens e.g. when building on non-FreeBSD)
1119 ${_+_}cd ${.CURDIR}/tools/build; \
1120 ${MAKE} DIRPRFX=tools/build/ DESTDIR=${WORLDTMP}/legacy installdirs
1121 # In order to build without inheriting $PATH we need to add symlinks to the host
1122 # tools in $WORLDTMP for the tools that we don't build during bootstrap-tools
1123 ${_+_}cd ${.CURDIR}/tools/build; \
1124 ${MAKE} DIRPRFX=tools/build/ DESTDIR=${WORLDTMP}/legacy host-symlinks
1128 @echo "--------------------------------------------------------------"
1129 @echo ">>> stage 1.1: legacy release compatibility shims"
1130 @echo "--------------------------------------------------------------"
1131 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
1134 @echo "--------------------------------------------------------------"
1135 @echo ">>> stage 1.2: bootstrap tools"
1136 @echo "--------------------------------------------------------------"
1137 .if ${MK_CLEAN} != "yes"
1138 ${_+_}cd ${.CURDIR}; ${BMAKE} _NO_INCLUDE_COMPILERMK=t _cleanobj_fast_depend_hack
1140 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
1141 mkdir -p ${WORLDTMP}/usr ${WORLDTMP}/lib/geom ${WORLDTMP}/bin
1142 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1143 -p ${WORLDTMP}/usr >/dev/null
1144 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1145 -p ${WORLDTMP}/usr/include >/dev/null
1146 .for d in ${LIBCOMPAT_INCLUDE_DIRS}
1147 mkdir -p ${WORLDTMP}/usr/include/${d}
1149 ln -sf ${.CURDIR}/sys ${WORLDTMP}
1150 .if ${MK_DEBUG_FILES} != "no"
1151 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1152 -p ${WORLDTMP}/usr/lib >/dev/null
1154 .for _mtree in ${LOCAL_MTREE}
1155 ${WORLDTMP_MTREE} -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
1158 .if ${MK_CLEAN} == "yes"
1160 @echo "--------------------------------------------------------------"
1161 @echo ">>> stage 2.1: cleaning up the object tree"
1162 @echo "--------------------------------------------------------------"
1163 # Avoid including bsd.compiler.mk in clean and obj with _NO_INCLUDE_COMPILERMK
1164 # since the restricted $PATH might not contain a valid cc binary
1165 ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t ${CLEANDIR}
1166 .for LIBCOMPAT in ${_LIBCOMPATS}
1167 ${_+_}cd ${.CURDIR}; ${LIB${LIBCOMPAT}WMAKE} _NO_INCLUDE_COMPILERMK=t -f Makefile.inc1 ${CLEANDIR}
1170 ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t _cleanobj_fast_depend_hack
1171 .endif # ${MK_CLEAN} == "yes"
1174 @echo "--------------------------------------------------------------"
1175 @echo ">>> stage 2.2: rebuilding the object tree"
1176 @echo "--------------------------------------------------------------"
1177 ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t obj
1180 @echo "--------------------------------------------------------------"
1181 @echo ">>> stage 2.3: build tools"
1182 @echo "--------------------------------------------------------------"
1183 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
1186 @echo "--------------------------------------------------------------"
1187 @echo ">>> stage 3: cross tools"
1188 @echo "--------------------------------------------------------------"
1189 @rm -f ${OBJTOP}/toolchain-metadata.mk
1190 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
1191 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
1194 @echo "--------------------------------------------------------------"
1195 @echo ">>> stage 3.1: recording build metadata"
1196 @echo "--------------------------------------------------------------"
1197 ${_+_}cd ${.CURDIR}; ${WMAKE} toolchain-metadata.mk
1198 ${_+_}cd ${.CURDIR}; ${WMAKE} host-osreldate.h
1201 @echo "--------------------------------------------------------------"
1202 @echo ">>> stage 4.1: building includes"
1203 @echo "--------------------------------------------------------------"
1204 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
1205 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
1206 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
1207 MK_INCLUDES=yes includes
1208 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
1209 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
1211 ${_+_}cd ${.CURDIR}; ${WMAKE} test-includes
1214 @echo "--------------------------------------------------------------"
1215 @echo ">>> stage 4.2: building libraries"
1216 @echo "--------------------------------------------------------------"
1217 ${_+_}cd ${.CURDIR}; \
1218 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
1219 MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS_SUPPORT} \
1223 @echo "--------------------------------------------------------------"
1224 @echo ">>> stage 4.4: building everything"
1225 @echo "--------------------------------------------------------------"
1226 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
1229 .if !defined(WORLDFAST)
1230 WMAKE_TGTS+= _sanity_check _cleanworldtmp _worldtmp _legacy
1231 .if empty(SUBDIR_OVERRIDE)
1232 WMAKE_TGTS+= _bootstrap-tools
1234 WMAKE_TGTS+= _cleanobj
1235 .if !defined(NO_OBJWALK)
1238 WMAKE_TGTS+= _build-tools _cross-tools
1239 WMAKE_TGTS+= _build-metadata
1240 WMAKE_TGTS+= _includes
1242 .if !defined(NO_LIBS)
1243 WMAKE_TGTS+= _libraries
1245 .if empty(SUBDIR_OVERRIDE)
1246 .for libcompat in ${libcompats}
1247 WMAKE_TGTS+= build${libcompat}
1250 WMAKE_TGTS+= everything
1252 # record buildworld / install time in seconds
1253 .if make(buildworld)
1254 _BUILDWORLD_START!= date '+%s'
1255 .export _BUILDWORLD_START
1257 .if make(reinstall) || make(restage)
1258 _INSTALLWORLD_START!= date '+%s'
1259 .export _INSTALLWORLD_START
1261 .if make(*installkernel*)
1262 _INSTALLKERNEL_START!= date '+%s'
1263 .export _INSTALLKERNEL_START
1266 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
1267 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
1269 _ncpu_cmd=sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo unknown
1271 buildworld_prologue: .PHONY
1272 @echo "--------------------------------------------------------------"
1273 @echo ">>> World build started on `LC_ALL=C date`"
1274 @echo "--------------------------------------------------------------"
1276 buildworld_epilogue: .PHONY
1278 @echo "--------------------------------------------------------------"
1279 @echo ">>> World build completed on `LC_ALL=C date`"
1280 @seconds=$$(($$(date '+%s') - ${_BUILDWORLD_START})); \
1281 echo ">>> World built in $$seconds seconds, ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}"
1282 @echo "--------------------------------------------------------------"
1285 # We need to have this as a target because the indirection between Makefile
1286 # and Makefile.inc1 causes the correct PATH to be used, rather than a
1287 # modification of the current environment's PATH. In addition, we need
1288 # to quote multiword values.
1290 buildenvvars: .PHONY
1291 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
1293 .if ${.TARGETS:Mbuildenv}
1294 .if ${.MAKEFLAGS:M-j}
1295 .error The buildenv target is incompatible with -j
1298 BUILDENV_DIR?= ${.CURDIR}
1300 # Note: make will report any errors the shell reports. This can
1301 # be odd if the last command in an interactive shell generates an
1302 # error or is terminated by SIGINT. These reported errors look bad,
1303 # but are harmless. Allowing them also allows BUILDENV_SHELL to
1304 # be a complex command whose status will be returned to the caller.
1305 # Some scripts in tools rely on this behavior to report build errors.
1308 @echo Entering world for ${TARGET_ARCH}:${TARGET}
1309 .if ${BUILDENV_SHELL:M*zsh*}
1310 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
1312 @cd ${BUILDENV_DIR} && env ${WMAKEENV} \
1313 INSTALL="${INSTALL_CMD} ${INSTALLFLAGS}" \
1314 MTREE_CMD="${MTREE_CMD} ${MTREEFLAGS}" BUILDENV=1 ${BUILDENV_SHELL}
1316 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:${libcompats:@v@Nbuild${v}@:ts:}}
1317 toolchain: ${TOOLCHAIN_TGTS} .PHONY
1318 KERNEL_TOOLCHAIN_TGTS= ${TOOLCHAIN_TGTS:N_obj:N_cleanobj:N_includes:N_libraries}
1319 .if make(kernel-toolchain)
1320 .ORDER: ${KERNEL_TOOLCHAIN_TGTS}
1322 kernel-toolchain: ${KERNEL_TOOLCHAIN_TGTS} .PHONY
1327 # Checks to be sure system is ready for installworld/installkernel.
1329 installcheck: _installcheck_world _installcheck_kernel .PHONY
1330 _installcheck_world: .PHONY
1331 @echo "--------------------------------------------------------------"
1332 @echo ">>> Install check world started on `LC_ALL=C date`"
1333 @echo "--------------------------------------------------------------"
1334 _installcheck_kernel: .PHONY
1335 @echo "--------------------------------------------------------------"
1336 @echo ">>> Install check kernel started on `LC_ALL=C date`"
1337 @echo "--------------------------------------------------------------"
1340 # Require DESTDIR to be set if installing for a different architecture or
1341 # using the user/group database in the source tree.
1343 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
1344 defined(DB_FROM_SRC)
1345 .if !make(distributeworld)
1346 _installcheck_world: __installcheck_DESTDIR
1347 _installcheck_kernel: __installcheck_DESTDIR
1348 __installcheck_DESTDIR: .PHONY
1349 .if !defined(DESTDIR) || empty(DESTDIR)
1350 @echo "ERROR: Please set DESTDIR!"; \
1356 .if !defined(DB_FROM_SRC)
1358 # Check for missing UIDs/GIDs.
1360 CHECK_UIDS= auditdistd
1365 CHECK_GIDS+= proxy authpf
1368 CHECK_UIDS+= unbound
1369 CHECK_GIDS+= unbound
1370 _installcheck_world: __installcheck_UGID
1371 __installcheck_UGID: .PHONY
1372 .for uid in ${CHECK_UIDS}
1373 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
1374 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
1378 .for gid in ${CHECK_GIDS}
1379 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
1380 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
1386 # If installing over the running system (DESTDIR is / or unset) and the install
1387 # includes rescue, try running rescue from the objdir as a sanity check. If
1388 # rescue is not functional (e.g., because it depends on a system call not
1389 # supported by the currently running kernel), abort the installation.
1391 .if !make(distributeworld) && ${MK_RESCUE} != "no" && \
1392 (empty(DESTDIR) || ${DESTDIR} == "/") && empty(BYPASS_INSTALLCHECK_SH)
1393 _installcheck_world: __installcheck_sh_check
1394 __installcheck_sh_check: .PHONY
1395 @if [ "`${OBJTOP}/rescue/rescue/rescue sh -c 'echo OK'`" != \
1397 echo "rescue/sh check failed, installation aborted" >&2; \
1403 # Required install tools to be saved in a scratch dir for safety.
1405 .if !defined(CROSSBUILD_HOST)
1409 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
1410 date echo egrep find grep id install ${_install-info} \
1411 ln make mkdir mtree mv pwd_mkdb \
1412 rm sed services_mkdb sh sort strip ${_sysctl} test time true uname wc
1414 .if ${MK_ZONEINFO} != "no"
1418 # Needed for share/man
1419 .if ${MK_MAN_UTILS} != "no"
1423 ITOOLS+=${LOCAL_ITOOLS}
1428 # Distributes everything compiled by a `buildworld'.
1432 # Installs everything compiled by a 'buildworld'.
1435 # Non-base distributions produced by the base system
1436 EXTRA_DISTRIBUTIONS=
1437 .for libcompat in ${libcompats}
1438 EXTRA_DISTRIBUTIONS+= lib${libcompat}
1440 .if ${MK_TESTS} != "no"
1441 EXTRA_DISTRIBUTIONS+= tests
1444 DEBUG_DISTRIBUTIONS=
1445 .if ${MK_DEBUG_FILES} != "no"
1446 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,tests,,}
1449 MTREE_MAGIC?= mtree 2.0
1451 distributeworld installworld stageworld: _installcheck_world .PHONY
1452 mkdir -p ${INSTALLTMP}
1453 progs=$$(for prog in ${ITOOLS}; do \
1454 if progpath=`env PATH=${TMPPATH:Q} which $$prog`; then \
1457 echo "Required tool $$prog not found in PATH ("${TMPPATH:Q}")." >&2; \
1461 if [ -z "${CROSSBUILD_HOST}" ] ; then \
1462 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | grep -Ev '\[.*]' | \
1463 while read line; do \
1465 if [ "$$2 $$3" != "not found" ]; then \
1468 echo "Required library $$1 not found." >&2; \
1473 ${INSTALLTMP_COPY_HOST_TOOL} $$libs $$progs ${INSTALLTMP}
1474 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
1475 .if defined(NO_ROOT)
1476 -mkdir -p ${METALOG:H}
1477 echo "#${MTREE_MAGIC}" > ${METALOG}
1479 .if make(distributeworld)
1480 .for dist in ${EXTRA_DISTRIBUTIONS}
1481 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
1482 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1483 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
1484 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1485 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1486 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1487 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
1488 .for d in ${LIBCOMPAT_INCLUDE_DIRS}
1489 -mkdir ${DESTDIR}/${DISTDIR}/${dist}/usr/include/${d}
1491 .if ${MK_DEBUG_FILES} != "no"
1492 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1493 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
1495 .for libcompat in ${libcompats}
1496 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1497 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1498 .if ${MK_DEBUG_FILES} != "no"
1499 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1500 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
1503 .if ${MK_TESTS} != "no" && ${dist} == "tests"
1504 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
1505 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1506 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
1507 .if ${MK_DEBUG_FILES} != "no"
1508 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1509 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug${TESTSBASE} >/dev/null
1512 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1513 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1514 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1515 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1516 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1517 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1518 .for d in ${LIBCOMPAT_INCLUDE_DIRS}
1519 echo "./${dist}/usr/include/${d} type=dir uname=root gname=wheel mode=0755" >> ${METALOG}
1521 .for libcompat in ${libcompats}
1522 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
1523 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1526 -mkdir ${DESTDIR}/${DISTDIR}/base
1527 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH:Q} ${MAKE} \
1528 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1529 DISTBASE=/base DESTDIR=${INSTALL_DDIR}/base \
1530 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1531 ${INSTALL_SYMLINK} ${INSTALLFLAGS} usr/src/sys ${INSTALL_DDIR}/base/sys
1532 .endif # make(distributeworld)
1533 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1534 ${IMAKEENV} rm -rf ${INSTALLTMP}
1535 .if !make(packageworld) && ${MK_CAROOT} != "no"
1536 @if which openssl>/dev/null; then \
1537 PATH=${TMPPATH:Q}:${PATH:Q} \
1538 LOCALBASE=${LOCALBASE:Q} \
1539 sh ${SRCTOP}/usr.sbin/certctl/certctl.sh ${CERTCTLFLAGS} rehash; \
1541 echo "No openssl on the host, not rehashing certificates target -- /etc/ssl may not be populated."; \
1544 .if make(distributeworld)
1545 .for dist in ${EXTRA_DISTRIBUTIONS}
1546 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete
1548 .for dist in base ${EXTRA_DISTRIBUTIONS}
1549 .for path suffix in "" .meta /usr/lib/debug .debug.meta
1550 @# For each file that exists in this dist, print the corresponding
1551 @# line from the METALOG. This relies on the fact that
1552 @# a line containing only the filename will sort immediately before
1553 @# the relevant mtree line.
1554 cd ${DESTDIR}/${DISTDIR}; \
1555 find ./${dist}${path} | ${METALOG_SORT_CMD} -u ${METALOG} - | \
1556 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}/, "."); print } }' > \
1557 ${DESTDIR}/${DISTDIR}/${dist}${suffix}
1560 .endif # make(distributeworld)
1562 packageworld: .PHONY
1563 .for dist in base ${EXTRA_DISTRIBUTIONS}
1564 .if defined(NO_ROOT)
1565 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1566 ${TAR_CMD} cvf - --exclude usr/lib/debug \
1567 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1568 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1570 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1571 ${TAR_CMD} cvf - --exclude usr/lib/debug . | \
1572 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1576 .for dist in ${DEBUG_DISTRIBUTIONS}
1577 . if defined(NO_ROOT)
1578 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1579 ${TAR_CMD} cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1580 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1582 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1583 ${TAR_CMD} cvLf - usr/lib/debug | \
1584 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1589 ${_+_}cd ${.CURDIR}/tools/build/options; sh makeman > \
1590 ${.CURDIR}/share/man/man5/src.conf.5
1592 # Ensure no regressions in self-includeability of sys/*.h and net*/*.h
1593 test-includes: .PHONY
1594 ${_+_}cd ${.CURDIR}/tools/build/test-includes; \
1595 ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} DESTDIR=${WORLDTMP} test-includes
1597 # We can't assume here that ${TMPPATH} will include ${PATH} or /usr/libexec
1598 # because we may be building with a STRICTTMPPATH, so we explicitly include
1599 # /usr/libexec here for flua. ${TMPPATH} still usefully includes anything else
1600 # we may need to function.
1601 _sysent_PATH= ${TMPPATH}:/usr/libexec
1602 _sysent_dirs= sys/kern
1603 _sysent_dirs+= sys/compat/freebsd32
1604 _sysent_dirs+= sys/amd64/linux \
1610 .for _dir in ${_sysent_dirs}
1611 sysent-${_dir}: .PHONY
1612 @echo "${MAKE} -C ${.CURDIR}/${_dir} sysent"
1613 ${_+_}@env PATH=${_sysent_PATH:Q} ${MAKE} -C ${.CURDIR}/${_dir} sysent
1615 sysent: sysent-${_dir}
1621 # If you have a build server, you can NFS mount the source and obj directories
1622 # and do a 'make reinstall' on the *client* to install new binaries from the
1623 # most recent server build.
1625 restage reinstall: .MAKE .PHONY
1626 @echo "--------------------------------------------------------------"
1627 @echo ">>> Making hierarchy"
1628 @echo "--------------------------------------------------------------"
1629 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1630 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1632 @echo "--------------------------------------------------------------"
1633 @echo ">>> Making distribution"
1634 @echo "--------------------------------------------------------------"
1635 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1636 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
1639 @echo "--------------------------------------------------------------"
1640 @echo ">>> Installing everything started on `LC_ALL=C date`"
1641 @echo "--------------------------------------------------------------"
1642 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1643 .for libcompat in ${libcompats}
1644 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1646 @echo "--------------------------------------------------------------"
1647 @echo ">>> Installing everything completed on `LC_ALL=C date`"
1648 @seconds=$$(($$(date '+%s') - ${_INSTALLWORLD_START})); \
1649 echo ">>> Install world completed in $$seconds seconds, ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}"
1650 @echo "--------------------------------------------------------------"
1652 redistribute: .MAKE .PHONY
1653 @echo "--------------------------------------------------------------"
1654 @echo ">>> Distributing everything"
1655 @echo "--------------------------------------------------------------"
1656 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1657 .for libcompat in ${libcompats}
1658 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1659 DISTRIBUTION=lib${libcompat}
1662 distrib-dirs distribution: .MAKE .PHONY
1663 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH:Q} ${MAKE} \
1664 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1665 .if make(distribution)
1666 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH:Q} \
1667 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1668 METALOG=${METALOG} MK_TESTS=no \
1669 MK_TESTS_SUPPORT=${MK_TESTS_SUPPORT} installconfig
1673 # buildetc and installetc
1675 buildetc: .MAKE .PHONY
1676 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 _worldtmp
1677 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 _legacy
1678 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 _bootstrap-tools \
1679 MK_CROSS_COMPILER=no MK_TOOLCHAIN=no
1680 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 _obj \
1682 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 everything \
1685 installetc: .MAKE .PHONY
1686 @echo "--------------------------------------------------------------"
1687 @echo ">>> Making hierarchy"
1688 @echo "--------------------------------------------------------------"
1689 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distrib-dirs
1690 @echo "--------------------------------------------------------------"
1691 @echo ">>> Making distribution"
1692 @echo "--------------------------------------------------------------"
1693 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribution
1696 # buildkernel and installkernel
1698 # Which kernels to build and/or install is specified by setting
1699 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1700 # Only the existing (depending TARGET) config files are used
1701 # for building kernels and only the first of these is designated
1702 # as the one being installed.
1704 # Note that we have to use TARGET instead of TARGET_ARCH when
1705 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1706 # be set to cross-build, we have to make sure TARGET is set
1709 .if defined(KERNFAST)
1713 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1714 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1715 KERNCONF=${KERNFAST}
1718 GENERIC_KERNCONF_SUFX_powerpc64= 64
1719 GENERIC_KERNCONF_SUFX_powerpc64le= 64LE
1720 GENERIC_KERNCONF_powerpcspe= MPC85XXSPE
1721 GENERIC_KERNCONF?= ${GENERIC_KERNCONF_${TARGET_ARCH}:UGENERIC${GENERIC_KERNCONF_SUFX_${TARGET_ARCH}}}
1722 INSTKERNNAME?= kernel
1724 KERNSRCDIR?= ${.CURDIR}/sys
1725 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1726 KRNLOBJDIR= ${OBJTOP}${KERNSRCDIR:C,^${.CURDIR},,}
1727 KERNCONFDIR?= ${KRNLCONFDIR}
1729 .for _k in ${GENERIC_KERNCONF} MINIMAL${GENERIC_KERNCONF_SUFX_${TARGET_ARCH}} ${GENERIC_KERNCONF}-MMCCAM
1730 .if exists(${KERNCONFDIR}/${_k})
1731 PKG_KERNCONF+= ${_k}
1732 .for _dbg in NODEBUG DEBUG
1733 .if exists(${KERNCONFDIR}/${_k}-${_dbg})
1734 PKG_KERNCONF+= ${_k}-${_dbg}
1740 .if defined(PACKAGE_BUILDING)
1741 KERNCONF?= ${PKG_KERNCONF}
1743 KERNCONF?= ${GENERIC_KERNCONF}
1748 .if defined(NO_INSTALLKERNEL)
1749 # All of the BUILDKERNELS loops start at index 1.
1750 BUILDKERNELS+= dummy
1752 .for _kernel in ${KERNCONF}
1753 .if !defined(_MKSHOWCONFIG) && exists(${KERNCONFDIR}/${_kernel})
1754 BUILDKERNELS+= ${_kernel}
1755 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1756 INSTALLKERNEL= ${_kernel}
1759 .if make(buildkernel)
1760 .error Missing KERNCONF ${KERNCONFDIR}/${_kernel}
1765 _cleankernobj_fast_depend_hack: .PHONY
1766 # 20191009 r353340 removal of opensolaris_atomic.S (also r353381)
1767 .if ${MACHINE} != i386
1768 .for f in opensolaris_atomic
1769 .for m in opensolaris zfs
1770 @if [ -e "${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o" ] && \
1771 grep -q ${f}.S "${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o"; then \
1772 echo "Removing stale dependencies for opensolaris_atomic"; \
1773 rm -f ${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.*; \
1779 ${WMAKE_TGTS:N_cleanworldtmp:N_worldtmp:${libcompats:@v@Nbuild${v}@:ts:}}: .MAKE .PHONY
1780 ${.ALLTARGETS:M_*:N_cleanworldtmp:N_worldtmp}: .MAKE .PHONY
1782 # record kernel(s) build time in seconds
1783 .if make(buildkernel)
1784 _BUILDKERNEL_START!= date '+%s'
1790 # Builds all kernels defined by BUILDKERNELS.
1792 buildkernel: .MAKE .PHONY
1793 .if empty(BUILDKERNELS:Ndummy)
1794 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1798 .for _kernel in ${BUILDKERNELS:Ndummy}
1799 @echo "--------------------------------------------------------------"
1800 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1801 @echo "--------------------------------------------------------------"
1802 @echo "===> ${_kernel}"
1803 mkdir -p ${KRNLOBJDIR}
1804 .if !defined(NO_KERNELCONFIG)
1806 @echo "--------------------------------------------------------------"
1807 @echo ">>> stage 1: configuring the kernel"
1808 @echo "--------------------------------------------------------------"
1809 cd ${KRNLCONFDIR}; \
1811 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1812 -I '${KERNCONFDIR}' -I '${KRNLCONFDIR}' \
1813 '${KERNCONFDIR}/${_kernel}'
1815 .if ${MK_CLEAN} == "yes" && !defined(NO_KERNELCLEAN)
1817 @echo "--------------------------------------------------------------"
1818 @echo ">>> stage 2.1: cleaning up the object tree"
1819 @echo "--------------------------------------------------------------"
1820 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1822 ${_+_}cd ${.CURDIR}; ${WMAKE} _cleankernobj_fast_depend_hack
1824 .if !defined(NO_KERNELOBJ)
1826 @echo "--------------------------------------------------------------"
1827 @echo ">>> stage 2.2: rebuilding the object tree"
1828 @echo "--------------------------------------------------------------"
1829 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1832 @echo "--------------------------------------------------------------"
1833 @echo ">>> stage 2.3: build tools"
1834 @echo "--------------------------------------------------------------"
1835 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1837 @echo "--------------------------------------------------------------"
1838 @echo ">>> stage 3.1: building everything"
1839 @echo "--------------------------------------------------------------"
1840 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1841 @echo "--------------------------------------------------------------"
1842 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1843 @echo "--------------------------------------------------------------"
1846 @seconds=$$(($$(date '+%s') - ${_BUILDKERNEL_START})); \
1847 echo ">>> Kernel(s) ${BUILDKERNELS} built in $$seconds seconds, ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}"
1848 @echo "--------------------------------------------------------------"
1850 .if !make(packages) && !make(update-packages)
1851 NO_INSTALLEXTRAKERNELS?= yes
1853 # packages/update-packages installs kernels to a staging directory then builds
1854 # packages from the result to be installed, typically to other systems. It is
1855 # less surprising for these targets to honor KERNCONF if multiple kernels are
1857 NO_INSTALLEXTRAKERNELS?= no
1861 # installkernel, etc.
1863 # Install the kernel defined by INSTALLKERNEL
1865 installkernel installkernel.debug \
1866 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1867 .if !defined(NO_INSTALLKERNEL)
1868 .if empty(INSTALLKERNEL)
1869 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1872 @echo "--------------------------------------------------------------"
1873 @echo ">>> Installing kernel ${INSTALLKERNEL} on $$(LC_ALL=C date)"
1874 @echo "--------------------------------------------------------------"
1875 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1876 ${CROSSENV} PATH=${TMPPATH:Q} \
1877 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} METALOG=${METALOG} \
1878 ${.TARGET:S/kernel//}
1879 @echo "--------------------------------------------------------------"
1880 @echo ">>> Installing kernel ${INSTALLKERNEL} completed on $$(LC_ALL=C date)"
1881 @echo "--------------------------------------------------------------"
1882 @seconds=$$(($$(date '+%s') - ${_INSTALLKERNEL_START})); \
1883 echo ">>> Install kernel(s) ${INSTALLKERNEL} completed in $$seconds seconds, ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}"
1884 @echo "--------------------------------------------------------------"
1886 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1887 .for _kernel in ${BUILDKERNELS:[2..-1]}
1888 @echo "--------------------------------------------------------------"
1889 @echo ">>> Installing kernel ${_kernel} $$(LC_ALL=C date)"
1890 @echo "--------------------------------------------------------------"
1891 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
1892 ${CROSSENV} PATH=${TMPPATH:Q} \
1893 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} METALOG=${METALOG} \
1894 ${.TARGET:S/kernel//}
1895 @echo "--------------------------------------------------------------"
1896 @echo ">>> Installing kernel ${_kernel} completed on $$(LC_ALL=C date)"
1897 @echo "--------------------------------------------------------------"
1899 @seconds=$$(($$(date '+%s') - ${_INSTALLKERNEL_START})); \
1900 echo ">>> Install kernel(s) ${BUILDKERNELS} completed in $$seconds seconds, ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}"
1901 @echo "--------------------------------------------------------------"
1904 distributekernel distributekernel.debug: .PHONY
1905 .if !defined(NO_INSTALLKERNEL)
1906 .if empty(INSTALLKERNEL)
1907 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1910 mkdir -p ${DESTDIR}/${DISTDIR}
1911 rm -f ${DESTDIR}/${DISTDIR}/kernel.premeta
1912 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1913 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1914 ${IMAKE_MTREE} PATH=${TMPPATH:Q} ${MAKE} KERNEL=${INSTKERNNAME} \
1915 DISTBASE=/kernel DESTDIR=${INSTALL_DDIR}/kernel \
1916 METALOG=${METALOG:S/METALOG/kernel.premeta/} \
1917 ${.TARGET:S/distributekernel/install/}
1918 .if defined(NO_ROOT)
1919 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.meta
1920 sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta | \
1921 ${METALOG_SORT_CMD} >> ${DESTDIR}/${DISTDIR}/kernel.meta
1924 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1925 .for _kernel in ${BUILDKERNELS:[2..-1]}
1926 rm -f ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1927 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
1928 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1929 ${IMAKE_MTREE} PATH=${TMPPATH:Q} ${MAKE} \
1930 KERNEL=${INSTKERNNAME}.${_kernel} \
1931 DISTBASE=/kernel.${_kernel} DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1932 METALOG=${METALOG:S/METALOG/kernel.${_kernel}.premeta/} \
1933 ${.TARGET:S/distributekernel/install/}
1934 .if defined(NO_ROOT)
1935 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1936 sed -e "s|^./kernel.${_kernel}|.|" \
1937 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta | \
1938 ${METALOG_SORT_CMD} >> ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1943 packagekernel: .PHONY
1944 .if defined(NO_ROOT)
1945 .if !defined(NO_INSTALLKERNEL)
1946 cd ${DESTDIR}/${DISTDIR}/kernel; \
1947 ${TAR_CMD} cvf - --exclude '*.debug' \
1948 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1949 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1951 .if ${MK_DEBUG_FILES} != "no"
1952 cd ${DESTDIR}/${DISTDIR}/kernel; \
1953 ${TAR_CMD} cvf - --include '*/*/*.debug' \
1954 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1955 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1957 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1958 .for _kernel in ${BUILDKERNELS:[2..-1]}
1959 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1960 ${TAR_CMD} cvf - --exclude '*.debug' \
1961 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1962 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1963 .if ${MK_DEBUG_FILES} != "no"
1964 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1965 ${TAR_CMD} cvf - --include '*/*/*.debug' \
1966 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1967 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1972 .if !defined(NO_INSTALLKERNEL)
1973 cd ${DESTDIR}/${DISTDIR}/kernel; \
1974 ${TAR_CMD} cvf - --exclude '*.debug' . | \
1975 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1977 .if ${MK_DEBUG_FILES} != "no"
1978 cd ${DESTDIR}/${DISTDIR}/kernel; \
1979 ${TAR_CMD} cvf - --include '*/*/*.debug' $$(eval find .) | \
1980 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1982 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1983 .for _kernel in ${BUILDKERNELS:[2..-1]}
1984 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1985 ${TAR_CMD} cvf - --exclude '*.debug' . | \
1986 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1987 .if ${MK_DEBUG_FILES} != "no"
1988 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1989 ${TAR_CMD} cvf - --include '*/*/*.debug' $$(eval find .) | \
1990 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1997 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} DISTDIR=. distributekernel
1999 PORTSDIR?= /usr/ports
2000 WSTAGEDIR?= ${OBJTOP}/worldstage
2001 KSTAGEDIR?= ${OBJTOP}/kernelstage
2002 SSTAGEDIR?= ${OBJTOP}/sourcestage
2003 REPODIR?= ${OBJROOT}repo
2006 PKG_CLEVEL?= ${"${PKG_FORMAT:Mtar}" != "":?:-l ${PKG_LEVEL}}
2007 PKG_REPO_SIGNING_KEY?= # empty
2008 PKG_OUTPUT_DIR?= ${PKG_VERSION}
2009 PKG_ABI_FILE?= ${WSTAGEDIR}/usr/bin/uname
2010 .if make(create-*-packages*) || make(real-update-packages) || make(real-sign-packages)
2011 PKG_ABI!= ${PKG_CMD} -o ABI_FILE=${PKG_ABI_FILE} config ABI
2014 .ORDER: stage-packages create-packages
2015 .ORDER: create-packages create-world-packages
2016 .ORDER: create-packages create-source-packages
2017 .ORDER: create-packages create-kernel-packages
2018 .ORDER: create-packages sign-packages
2020 _pkgbootstrap: .PHONY
2021 .if make(*package*) && !exists(${LOCALBASE}/sbin/pkg)
2022 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
2025 PKG_BIN_VERSION!=${PKG_CMD} --version </dev/null 2>/dev/null |\
2026 awk -F. '/^[0-9.]+$$/ {print $$1 * 10000 + $$2 * 100 + $$3}'
2027 .if ${PKG_BIN_VERSION} < 11700
2028 PKG_EXT= ${PKG_FORMAT}
2033 .if !defined(PKG_VERSION_FROM) && make(real-update-packages)
2034 .if exists(${PKG_ABI_FILE}) && exists(${REPODIR}/${PKG_ABI})
2035 PKG_VERSION_FROM!=/usr/bin/readlink ${REPODIR}/${PKG_ABI}/latest
2036 PKG_VERSION_FROM_DIR= ${REPODIR}/${PKG_ABI}/${PKG_VERSION_FROM}
2037 # Determine the name of the branch base on the version
2042 # all others mean release
2044 # This will be used when comparing to the branch that we are building
2045 # to decide if we keep old packages or new packages when only their
2048 .if ${PKG_VERSION_FROM:M*.snap*}
2049 BRANCH_EXT_FROM= ${PKG_VERSION_FROM:C/.snap.*$//}.snap
2050 .elif ${PKG_VERSION_FROM:M*.b*}
2051 BRANCH_EXT_FROM= beta
2052 .elif ${PKG_VERSION_FROM:M*.rc*}
2054 .elif ${PKG_VERSION_FROM:M*.a*}
2055 BRANCH_EXT_FROM= alpha
2059 PKG_VERSION_FROM_DIR=
2064 PKGMAKEARGS+= PKG_VERSION=${PKG_VERSION} \
2065 NO_INSTALLEXTRAKERNELS=${NO_INSTALLEXTRAKERNELS}
2068 ${_+_}${MAKE} -C ${.CURDIR} ${PKGMAKEARGS} real-packages
2070 update-packages: .PHONY
2071 ${_+_}${MAKE} -C ${.CURDIR} ${PKGMAKEARGS} real-update-packages
2074 rm -rf /tmp/ports.${TARGET} || :
2075 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
2076 PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \
2077 WSTAGEDIR=${WSTAGEDIR} \
2078 OSVERSION="${SRCRELDATE}" \
2079 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
2081 real-packages: stage-packages create-packages sign-packages .PHONY
2083 real-update-packages: stage-packages .PHONY
2084 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} create-packages
2085 .if empty(PKG_VERSION_FROM_DIR)
2086 @echo "==> Bootstrapping repository, not checking for new packages"
2088 @echo "==> Checking for new packages (comparing ${PKG_VERSION} to ${PKG_VERSION_FROM})"
2089 @for pkg in ${PKG_VERSION_FROM_DIR}/${PKG_NAME_PREFIX}-*; do \
2090 pkgname=$$(pkg query -F $${pkg} '%n' | sed 's/${PKG_NAME_PREFIX}-\(.*\)/\1/') ; \
2091 newpkgname=${PKG_NAME_PREFIX}-$${pkgname}-${PKG_VERSION}.${PKG_EXT} ; \
2092 oldsum=$$(pkg query -F $${pkg} '%X') ; \
2093 if [ ! -f ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} ]; then \
2096 newsum=$$(pkg query -F ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} '%X') ; \
2097 if [ "${BRANCH_EXT_FROM}" = "${BRANCH_EXT}" -a "$${oldsum}" = "$${newsum}" ]; then \
2098 echo "==> Keeping old ${PKG_NAME_PREFIX}-$${pkgname}-${PKG_VERSION_FROM}.${PKG_EXT}" ; \
2099 rm ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} ; \
2100 cp $${pkg} ${REPODIR}/${PKG_ABI}/${PKG_VERSION} ; \
2102 echo "==> New package $${newpkgname}" ; \
2106 ${_+_}@cd ${.CURDIR}; \
2107 ${MAKE} -f Makefile.inc1 PKG_VERSION=${PKG_VERSION} sign-packages
2109 stage-packages-world: .PHONY
2110 @mkdir -p ${WSTAGEDIR}
2111 ${_+_}@cd ${.CURDIR}; \
2112 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT stageworld
2114 stage-packages-kernel: .PHONY
2115 @mkdir -p ${KSTAGEDIR}
2116 ${_+_}@cd ${.CURDIR}; \
2117 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT stagekernel
2119 stage-packages-source: .PHONY
2120 @mkdir -p ${SSTAGEDIR};
2122 stage-packages: .PHONY stage-packages-world stage-packages-kernel stage-packages-source
2125 @mkdir -p ${REPODIR}
2127 create-packages-world: _pkgbootstrap _repodir .PHONY
2128 ${_+_}@cd ${.CURDIR}; \
2129 ${MAKE} -f Makefile.inc1 \
2130 DESTDIR=${WSTAGEDIR} \
2131 PKG_VERSION=${PKG_VERSION} create-world-packages
2133 create-packages-kernel: _pkgbootstrap _repodir .PHONY
2134 ${_+_}@cd ${.CURDIR}; \
2135 ${MAKE} -f Makefile.inc1 \
2136 DESTDIR=${KSTAGEDIR} \
2137 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
2138 SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
2139 create-kernel-packages
2141 create-packages-kernel-repo: .PHONY create-packages-kernel sign-packages
2143 create-packages-world-repo: .PHONY create-packages-world sign-packages
2145 create-packages-source: _pkgbootstrap _repodir .PHONY
2146 ${_+_}@cd ${.CURDIR}; \
2147 ${MAKE} -f Makefile.inc1 \
2148 DESTDIR=${SSTAGEDIR} \
2149 PKG_VERSION=${PKG_VERSION} create-source-packages
2151 create-packages: .PHONY create-packages-world create-packages-kernel create-packages-source
2153 create-source-src-package: _pkgbootstrap .PHONY
2154 rm -f ${SSTAGEDIR}/src.plist 2>/dev/null || :
2155 .if !empty(GIT_CMD) && exists(${GIT_CMD}) && exists(${SRCDIR}/.git)
2157 ( echo "@override_prefix /usr/src" ; \
2158 ${GIT_CMD} ls-files --recurse-submodules ":!:sys/" ) \
2159 > ${SSTAGEDIR}/src.plist
2160 ${SRCDIR}/release/packages/generate-ucl.lua \
2163 VERSION "${PKG_VERSION}" \
2164 DESC "FreeBSD Kernel Sources" \
2165 COMMENT "FreeBSD Userland Sources" \
2166 PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \
2167 PKG_MAINTAINER "${PKG_MAINTAINER}" \
2168 PKG_WWW "${PKG_WWW}" \
2169 ${SRCDIR}/release/packages/template.ucl \
2170 ${SSTAGEDIR}/src.ucl
2171 ${PKG_CMD} -o ABI=${PKG_ABI} \
2172 -o OSVERSION="${SRCRELDATE}" \
2173 create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
2174 -M ${SSTAGEDIR}/src.ucl \
2175 -p ${SSTAGEDIR}/src.plist \
2177 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
2180 create-source-src-sys-package: _pkgbootstrap .PHONY
2181 rm -f ${SSTAGEDIR}/src-sys.plist 2>/dev/null || :
2182 .if !empty(GIT_CMD) && exists(${GIT_CMD}) && exists(${SRCDIR}/.git)
2184 ( echo "@override_prefix /usr/src" ; \
2185 ${GIT_CMD} ls-files --recurse-submodules "sys/" ) \
2186 > ${SSTAGEDIR}/src-sys.plist
2187 ${SRCDIR}/release/packages/generate-ucl.lua \
2190 VERSION "${PKG_VERSION}" \
2191 DESC "FreeBSD Kernel Sources" \
2192 COMMENT "FreeBSD Kernel Sources" \
2193 PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \
2194 PKG_MAINTAINER "${PKG_MAINTAINER}" \
2195 PKG_WWW "${PKG_WWW}" \
2196 ${SRCDIR}/release/packages/template.ucl \
2197 ${SSTAGEDIR}/src-sys.ucl
2198 ${PKG_CMD} -o ABI=${PKG_ABI} \
2199 -o OSVERSION="${SRCRELDATE}" \
2200 create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
2201 -M ${SSTAGEDIR}/src-sys.ucl \
2202 -p ${SSTAGEDIR}/src-sys.plist \
2204 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
2207 create-source-packages: .PHONY _pkgbootstrap create-source-src-package create-source-src-sys-package
2209 create-world-packages: _pkgbootstrap .PHONY
2210 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
2211 @cd ${WSTAGEDIR} ; \
2212 ${METALOG_SORT_CMD} ${WSTAGEDIR}/${DISTDIR}/METALOG | \
2213 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk
2214 @for plist in ${WSTAGEDIR}/*.plist; do \
2215 plist=$${plist##*/} ; \
2216 pkgname=$${plist%.plist} ; \
2217 echo "_PKGS+= $${pkgname}" ; \
2218 done > ${WSTAGEDIR}/packages.mk
2219 ${_+_}@cd ${.CURDIR}; \
2220 ${MAKE} -f Makefile.inc1 create-world-packages-jobs \
2221 SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
2224 .if make(create-world-packages-jobs)
2225 .include "${WSTAGEDIR}/packages.mk"
2228 create-world-packages-jobs: .PHONY
2229 .for pkgname in ${_PKGS}
2230 create-world-packages-jobs: create-world-package-${pkgname}
2231 create-world-package-${pkgname}: .PHONY
2232 @sh ${SRCDIR}/release/packages/generate-ucl.sh -o ${pkgname} \
2233 -s ${SRCDIR} -u ${WSTAGEDIR}/${pkgname}.ucl
2235 /^name/ { printf("===> Creating %s-", $$2); next } \
2236 /^version/ { print $$2; next } \
2237 ' ${WSTAGEDIR}/${pkgname}.ucl
2238 @if [ "${pkgname}" == "runtime" ]; then \
2239 sed -i '' -e "s/%VCS_REVISION%/${VCS_REVISION}/" ${WSTAGEDIR}/${pkgname}.ucl ; \
2241 ${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \
2242 -o OSVERSION="${SRCRELDATE}" \
2243 create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
2244 -M ${WSTAGEDIR}/${pkgname}.ucl \
2245 -p ${WSTAGEDIR}/${pkgname}.plist \
2247 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
2250 _default_flavor= -default
2251 .if make(*package*) && exists(${KSTAGEDIR}/kernel.meta)
2252 . if ${MK_DEBUG_FILES} != "no"
2257 @if [ -f ${KSTAGEDIR}/${DISTDIR}/dtb.plist ]; then \
2258 ${SRCDIR}/release/packages/generate-ucl.lua \
2260 VERSION "${PKG_VERSION}" \
2261 COMMENT "FreeBSD Devicetree Blobs" \
2262 DESC "FreeBSD Devicetree Blobs" \
2263 PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \
2264 PKG_MAINTAINER "${PKG_MAINTAINER}" \
2265 PKG_WWW "${PKG_WWW}" \
2266 ${SRCDIR}/release/packages/template.ucl \
2267 ${KSTAGEDIR}/${DISTDIR}/dtb.ucl ; \
2269 /name/ { printf("===> Creating %s-", $$2); next } \
2270 /version/ {print $$2; next } ' \
2271 ${KSTAGEDIR}/${DISTDIR}/dtb.ucl ; \
2272 ${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \
2273 -o OSVERSION="${SRCRELDATE}" \
2274 create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
2275 -M ${KSTAGEDIR}/${DISTDIR}/dtb.ucl \
2276 -p ${KSTAGEDIR}/${DISTDIR}/dtb.plist \
2277 -r ${KSTAGEDIR}/${DISTDIR} \
2278 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR} ; \
2281 create-kernel-packages: .PHONY
2282 . for flavor in "" ${_debug}
2283 create-kernel-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},} create-dtb-package
2284 create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY
2285 @cd ${KSTAGEDIR}/${DISTDIR} ; \
2286 ${METALOG_SORT_CMD} ${KSTAGEDIR}/kernel.meta | \
2287 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
2288 -v kernel=yes -v _kernconf=${INSTALLKERNEL} ; \
2289 ${SRCDIR}/release/packages/generate-ucl.lua \
2290 PKGNAME "kernel-${INSTALLKERNEL:tl}${flavor}" \
2291 VERSION "${PKG_VERSION}" \
2292 KERNELDIR "kernel" \
2293 COMMENT "FreeBSD ${INSTALLKERNEL} kernel ${flavor}" \
2294 DESC "FreeBSD ${INSTALLKERNEL} kernel ${flavor}" \
2295 PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \
2296 PKG_MAINTAINER "${PKG_MAINTAINER}" \
2297 PKG_WWW "${PKG_WWW}" \
2298 ${SRCDIR}/release/packages/template.ucl \
2299 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
2301 /name/ { printf("===> Creating %s-", $$2); next } \
2302 /version/ {print $$2; next } ' \
2303 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
2304 ${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \
2305 -o OSVERSION="${SRCRELDATE}" \
2306 create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
2307 -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
2308 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
2309 -r ${KSTAGEDIR}/${DISTDIR} \
2310 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
2313 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
2314 . for _kernel in ${BUILDKERNELS:[2..-1]}
2315 . if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
2316 . if ${MK_DEBUG_FILES} != "no"
2319 . for flavor in "" ${_debug}
2320 create-kernel-packages: create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}
2321 create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}: _pkgbootstrap .PHONY
2322 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
2323 ${METALOG_SORT_CMD} ${KSTAGEDIR}/kernel.${_kernel}.meta | \
2324 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
2325 -v kernel=yes -v _kernconf=${_kernel} ; \
2326 ${SRCDIR}/release/packages/generate-ucl.lua \
2327 PKGNAME "kernel-${_kernel:tl}${flavor}" \
2328 PKGGENNAME "kernel" \
2329 FORCEINCLUDE "kernel${flavor}" \
2330 UCLFILES "${SRCDIR}/release/packages/" \
2331 VERSION "${PKG_VERSION}" \
2332 KERNELDIR "kernel.${_kernel}" \
2333 DESC "FreeBSD ${_kernel} kernel ${flavor}" \
2334 COMMENT "FreeBSD ${_kernel} kernel ${flavor}" \
2335 PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \
2336 PKG_MAINTAINER "${PKG_MAINTAINER}" \
2337 PKG_WWW "${PKG_WWW}" \
2338 ${SRCDIR}/release/packages/template.ucl \
2339 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
2341 /name/ { printf("===> Creating %s-", $$2); next } \
2342 /version/ {print $$2; next } ' \
2343 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
2344 ${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \
2345 -o OSVERSION="${SRCRELDATE}" \
2346 create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
2347 -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
2348 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
2349 -r ${KSTAGEDIR}/kernel.${_kernel} \
2350 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
2356 sign-packages: .PHONY
2357 ${_+_}@cd ${.CURDIR}; \
2358 ${MAKE} -f Makefile.inc1 PKG_VERSION=${PKG_VERSION} real-sign-packages
2360 real-sign-packages: _pkgbootstrap .PHONY
2361 printf "version = 2;\n" > ${WSTAGEDIR}/meta
2362 .if ${PKG_BIN_VERSION} < 11700
2363 printf "packing_format = \"${PKG_FORMAT}\";\n" >> ${WSTAGEDIR}/meta
2365 @${PKG_CMD} -o ABI=${PKG_ABI} -o OSVERSION="${SRCRELDATE}" repo \
2366 -m ${WSTAGEDIR}/meta \
2367 -o ${REPODIR}/${PKG_ABI}/${PKG_VERSION} \
2368 ${REPODIR}/${PKG_ABI}/${PKG_VERSION} \
2369 ${PKG_REPO_SIGNING_KEY} ; \
2370 cd ${REPODIR}/${PKG_ABI}; \
2371 ln -hfs ${PKG_OUTPUT_DIR} latest
2377 # Run test suite on installed world.
2380 @if [ ! -x "${LOCALBASE}/bin/kyua" ] && [ ! -x "/usr/bin/kyua" ]; then \
2381 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
2384 ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile
2390 # Build the API documentation with doxygen
2393 @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \
2394 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
2397 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
2400 # ------------------------------------------------------------------------
2402 # From here onwards are utility targets used by the 'make world' and
2403 # related targets. If your 'world' breaks, you may like to try to fix
2404 # the problem and manually run the following targets to attempt to
2405 # complete the build. Beware, this is *not* guaranteed to work, you
2406 # need to have a pretty good grip on the current state of the system
2407 # to attempt to manually finish it. If in doubt, 'make world' again.
2411 # legacy: Build compatibility shims for the next three targets. This is a
2412 # minimal set of tools and shims necessary to compensate for older systems
2413 # which don't have the APIs required by the targets built in bootstrap-tools,
2414 # build-tools or cross-tools.
2417 .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
2418 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
2424 ${LOCAL_LEGACY_DIRS}
2425 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
2426 cd ${.CURDIR}/${_tool}; \
2427 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2428 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy includes; \
2429 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
2430 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
2431 DESTDIR=${WORLDTMP}/legacy install
2435 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
2436 # are built to build other binaries in the system. However, the focus of these
2437 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
2438 # libraries, augmented by -legacy, in addition to the libraries built during
2441 _bt= _bootstrap-tools
2443 # We want to run the build with only ${WORLDTMP} in $PATH to ensure we don't
2444 # accidentally run tools that are incompatible but happen to be in $PATH.
2445 # This is especially important when building on Linux/MacOS where many of the
2446 # programs used during the build accept different flags or generate different
2447 # output. On those platforms we only symlink the tools known to be compatible
2448 # (e.g. basic utilities such as mkdir) into ${WORLDTMP} and build all others
2449 # from the FreeBSD sources during the bootstrap-tools stage.
2450 # We want to build without the user's $PATH starting in the bootstrap-tools
2451 # phase so the tools used in that phase (ln, cp, etc) must have already been
2452 # linked to $WORLDTMP. The tools are listed in the _host_tools_to_symlink
2453 # variable in tools/build/Makefile and are linked during the legacy phase.
2454 # Since they could be Linux or MacOS binaries, too we must only use flags that
2455 # are portable across operating systems.
2457 # If BOOTSTRAP_ALL_TOOLS is set we will build all the required tools from the
2458 # current source tree. Otherwise we create a symlink to the version found in
2459 # $PATH during the bootstrap-tools stage.
2460 # When building on non-FreeBSD systems we can't assume that the host binaries
2461 # accept compatible flags or produce compatible output. Therefore we force
2462 # BOOTSTRAP_ALL_TOOLS and just build the FreeBSD version of the binary.
2463 .if defined(CROSSBUILD_HOST)
2464 BOOTSTRAP_ALL_TOOLS:= 1
2466 .if defined(BOOTSTRAP_ALL_TOOLS)
2467 # BOOTSTRAPPING will be set on the command line so we can't override it here.
2468 # Instead set BOOTSTRAPPING_OSRELDATE so that the value 0 is set ${BSARGS}
2469 BOOTSTRAPPING_OSRELDATE:= 0
2472 .if ${MK_GAMES} != "no"
2473 _strfile= usr.bin/fortune/strfile
2476 # vtfontcvt is used to build font files for loader and to generate
2477 # C source for loader built in font (8x16.c).
2478 _vtfontcvt= usr.bin/vtfontcvt
2480 # zic is used to compile timezone data
2481 .if ${MK_ZONEINFO} != "no"
2485 # If we are not building the bootstrap because BOOTSTRAPPING is sufficient
2486 # we symlink the host version to $WORLDTMP instead. By doing this we can also
2487 # detect when a bootstrap tool is being used without the required MK_FOO.
2488 # If you add a new bootstrap tool where we could also use the host version,
2489 # please ensure that you also add a .else case where you add the tool to the
2490 # _bootstrap_tools_links variable.
2491 .if ${BOOTSTRAPPING} < 1000033
2492 # Note: lex needs m4 to build but m4 also depends on lex (which needs m4 to
2493 # generate any files). To fix this cyclic dependency we can build a bootstrap
2494 # version of m4 (with pre-generated files) then use that to build the real m4.
2495 # We can't simply use the host m4 since e.g. the macOS version does not accept
2496 # the flags that are passed by lex.
2497 # For lex we also use the pre-gerated files since we would otherwise need to
2498 # build awk and sed first (which need lex to build)
2499 # TODO: add a _bootstrap_lex and then build the real lex afterwards
2501 _m4= tools/build/bootstrap-m4 usr.bin/m4
2502 ${_bt}-tools/build/bootstrap-m4: ${_bt}-usr.bin/lex ${_bt}-lib/libopenbsd ${_bt}-usr.bin/yacc
2503 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd ${_bt}-usr.bin/yacc ${_bt}-usr.bin/lex ${_bt}-tools/build/bootstrap-m4
2504 _bt_m4_depend=${_bt}-usr.bin/m4
2505 _bt_lex_depend=${_bt}-usr.bin/lex ${_bt_m4_depend}
2507 _bootstrap_tools_links+=m4 lex
2510 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
2511 # r296685 fix cross-endian objcopy
2512 # r310724 fixed PR 215350, a crash in libdwarf with objects built by GCC 6.2.
2513 # r334881 added libdwarf constants used by ctfconvert.
2514 # r338478 fixed a crash in objcopy for mips64el objects
2515 # r339083 libelf: correct mips64el test to use ELF header
2516 # r348347 Add missing powerpc64 relocation support to libdwarf
2517 .if ${BOOTSTRAPPING} < 1300030
2518 _elftoolchain_libs= lib/libelf lib/libdwarf lib/libzstd
2519 ${_bt}-lib/libelf: ${_bt_m4_depend}
2520 ${_bt}-lib/libdwarf: ${_bt_m4_depend}
2521 _bt_libelf_depend=${_bt}-lib/libelf
2524 _libkldelf= lib/libkldelf
2525 ${_bt}-lib/libkldelf: ${_bt_libelf_depend}
2526 _bt_libkldelf_depend=${_bt}-lib/libkldelf
2528 _kldxref= usr.sbin/kldxref
2529 ${_bt}-usr.sbin/kldxref: ${_bt_libelf_depend} ${_bt_libkldelf_depend}
2531 # flua is required to regenerate syscall files. It first appeared during the
2532 # 13.0-CURRENT cycle, thus needs to be built on -older releases and stable
2534 .if ${BOOTSTRAPPING} < 1300059
2535 ${_bt}-libexec/flua: ${_bt}-lib/liblua
2536 _flua= lib/liblua libexec/flua
2539 # r245440 mtree -N support added
2540 # r313404 requires sha384.h for libnetbsd, added to libmd in r292782
2541 .if ${BOOTSTRAPPING} < 1100093
2542 _libnetbsd= lib/libnetbsd
2543 _nmtree= lib/libmd \
2546 ${_bt}-lib/libnetbsd: ${_bt}-lib/libmd
2547 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
2549 _bootstrap_tools_links+=mtree
2552 # r246097: log addition login.conf.db, passwd, pwd.db, and spwd.db with cat -l
2553 .if ${BOOTSTRAPPING} < 1000027
2556 _bootstrap_tools_links+=cat
2559 # r277259 crunchide: Correct 64-bit section header offset
2560 # r281674 crunchide: always include both 32- and 64-bit ELF support
2561 .if ${BOOTSTRAPPING} < 1100078
2562 _crunchide= usr.sbin/crunch/crunchide
2564 _bootstrap_tools_links+=crunchide
2567 # 1400052, 1300526, 1203507: Removed -dc from linker invocation
2568 .if ${BOOTSTRAPPING} < 1203507 || \
2569 (${BOOTSTRAPPING} > 1300000 && ${BOOTSTRAPPING} < 1300526) || \
2570 (${BOOTSTRAPPING} > 1400000 && ${BOOTSTRAPPING} < 1400052)
2571 _crunchgen= usr.sbin/crunch/crunchgen
2573 _bootstrap_tools_links+=crunchgen
2576 # The ATKBD_DFLT_KEYMAP, UKBD_DFLT_KEYMAP and KBDMUX_DFLT_KEYMAP kernel options
2577 # require kbdcontrol. Note that, even on FreeBSD, the host will lack kbdcontrol
2578 # if built with WITHOUT_LEGACY_CONSOLE.
2579 .if defined(BOOTSTRAP_ALL_TOOLS) || !exists(/usr/sbin/kbdcontrol)
2580 _kbdcontrol= usr.sbin/kbdcontrol
2582 _bootstrap_tools_links+=kbdcontrol
2585 .if ${MK_DISK_IMAGE_TOOLS_BOOTSTRAP} != "no"
2586 _etdump= usr.bin/etdump
2587 _makefs= usr.sbin/makefs
2589 _libnetbsd= lib/libnetbsd
2590 ${_bt}-usr.sbin/makefs: ${_bt}-lib/libnetbsd
2592 .if defined(BOOTSTRAP_ALL_TOOLS)
2593 _libsbuf= lib/libsbuf
2594 ${_bt}-usr.sbin/makefs: ${_bt}-lib/libsbuf
2598 # 1300102: VHDX support
2599 .if ${BOOTSTRAPPING} < 1201520 || \
2600 (${BOOTSTRAPPING} > 1300000 && ${BOOTSTRAPPING} < 1300102) || \
2601 ${MK_DISK_IMAGE_TOOLS_BOOTSTRAP} != "no"
2602 _mkimg= usr.bin/mkimg
2604 _bootstrap_tools_links+=mkimg
2609 .if ${MK_BSNMP} != "no"
2610 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
2614 # We need to build tblgen when we're building clang or lld, either as
2615 # bootstrap tools, or as the part of the normal build.
2616 # llvm-tblgen is also needed for various llvm binutils (e.g. objcopy).
2617 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
2618 ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no" || \
2619 ${MK_LLDB} != "no" || ${MK_LLVM_BINUTILS} != "no"
2621 lib/clang/libllvmminimal \
2622 usr.bin/clang/llvm-min-tblgen \
2623 usr.bin/clang/llvm-tblgen
2624 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
2626 _clang_tblgen+= lib/clang/libclangminimal
2627 _clang_tblgen+= usr.bin/clang/clang-tblgen
2629 .if ${MK_LLDB} != "no"
2630 _clang_tblgen+= usr.bin/clang/lldb-tblgen
2632 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal
2633 ${_bt}-usr.bin/clang/lldb-tblgen: ${_bt}-lib/clang/libllvmminimal
2634 ${_bt}-usr.bin/clang/llvm-min-tblgen: ${_bt}-lib/clang/libllvmminimal
2635 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal
2636 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-usr.bin/clang/llvm-min-tblgen
2639 # C.UTF-8 is always built in share/ctypes and we need localedef for that.
2640 _localedef= usr.bin/localedef
2641 ${_bt}-usr.bin/localedef: ${_bt}-usr.bin/yacc ${_bt_lex_depend}
2643 .if ${MK_ICONV} != "no"
2644 _mkesdb= usr.bin/mkesdb
2645 _mkcsmapper= usr.bin/mkcsmapper
2646 ${_bt}-usr.bin/mkesdb: ${_bt}-usr.bin/yacc ${_bt_lex_depend}
2647 ${_bt}-usr.bin/mkcsmapper: ${_bt}-usr.bin/yacc ${_bt_lex_depend}
2650 .if ${MK_KERBEROS} != "no"
2651 _kerberos5_bootstrap_tools= \
2652 kerberos5/tools/make-roken \
2653 kerberos5/lib/libroken \
2654 kerberos5/lib/libvers \
2655 kerberos5/tools/asn1_compile \
2656 kerberos5/tools/slc \
2659 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
2660 .for _tool in ${_kerberos5_bootstrap_tools}
2661 ${_bt}-${_tool}: ${_bt}-usr.bin/yacc ${_bt_lex_depend}
2665 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
2667 # The tools listed in _basic_bootstrap_tools will generally not be
2668 # bootstrapped unless BOOTSTRAP_ALL_TOOL is set. However, when building on a
2669 # Linux or MacOS host the host versions are incompatible so we need to build
2670 # them from the source tree. Usually the link name will be the same as the subdir,
2671 # but some directories such as grep or test install multiple binaries. In that
2672 # case we use the _basic_bootstrap_tools_multilink variable which is a list of
2673 # subdirectory and comma-separated list of files.
2674 _basic_bootstrap_tools_multilink=usr.bin/grep grep,egrep,fgrep
2675 _basic_bootstrap_tools_multilink+=bin/test test,[
2676 # bootstrap tools needed by buildworld:
2677 _basic_bootstrap_tools+=usr.bin/cut bin/expr usr.bin/gencat usr.bin/join \
2678 usr.bin/mktemp bin/realpath bin/rmdir usr.bin/sed usr.bin/sort \
2679 usr.bin/truncate usr.bin/tsort
2680 # Some build scripts use nawk instead of awk (this happens at least in
2681 # cddl/contrib/opensolaris/lib/libdtrace/common/mknames.sh) so we need both awk
2682 # and nawk in ${WORLDTMP}/legacy/bin.
2683 _basic_bootstrap_tools_multilink+=usr.bin/awk awk,nawk
2684 # file2c is required for building usr.sbin/config:
2685 _basic_bootstrap_tools+=usr.bin/file2c
2686 # uuencode/uudecode required for share/tabset
2687 _basic_bootstrap_tools_multilink+=usr.bin/bintrans uuencode,uudecode
2688 # xargs is required by mkioctls
2689 _basic_bootstrap_tools+=usr.bin/xargs
2690 # cap_mkdb is required for share/termcap:
2691 _basic_bootstrap_tools+=usr.bin/cap_mkdb
2692 # services_mkdb/pwd_mkdb are required for installworld:
2693 _basic_bootstrap_tools+=usr.sbin/services_mkdb usr.sbin/pwd_mkdb
2694 # ldd is required for installcheck (TODO: just always use /usr/bin/ldd instead?)
2695 .if !defined(CROSSBUILD_HOST)
2696 # ldd is only needed for updating the running system so we don't need to
2697 # bootstrap ldd on non-FreeBSD systems
2698 _basic_bootstrap_tools+=usr.bin/ldd
2700 # sysctl/chflags are required for installkernel:
2701 .if !defined(CROSSBUILD_HOST)
2702 _basic_bootstrap_tools+=bin/chflags
2703 # Note: sysctl does not bootstrap on FreeBSD < 13 anymore, but that doesn't
2704 # matter since we don't need any of the new features for the build.
2705 _bootstrap_tools_links+=sysctl
2707 # When building on non-FreeBSD, install a fake chflags instead since the
2708 # version from the source tree cannot work. We also don't need sysctl since we
2709 # are install with -DNO_ROOT.
2710 _other_bootstrap_tools+=tools/build/cross-build/fake_chflags
2712 # mkfifo is used by sys/conf/newvers.sh
2713 _basic_bootstrap_tools+=usr.bin/mkfifo
2714 # jot is needed for the mkimg tests
2715 _basic_bootstrap_tools+=usr.bin/jot
2717 .if defined(BOOTSTRAP_ALL_TOOLS)
2718 # sha256 and sha512 are used by release/ (and possibly others)
2719 _basic_bootstrap_tools+=sbin/md5
2722 # tzsetup is needed as an install tool
2723 .if ${MK_ZONEINFO} != "no"
2724 _basic_bootstrap_tools+=usr.sbin/tzsetup
2727 .if defined(BOOTSTRAP_ALL_TOOLS)
2728 _other_bootstrap_tools+=${_basic_bootstrap_tools}
2729 .for _subdir _links in ${_basic_bootstrap_tools_multilink}
2730 _other_bootstrap_tools+=${_subdir}
2732 ${_bt}-usr.bin/awk: ${_bt_lex_depend} ${_bt}-usr.bin/yacc
2733 ${_bt}-bin/expr: ${_bt_lex_depend} ${_bt}-usr.bin/yacc
2734 # If we are bootstrapping file2c, we have to build it before config:
2735 ${_bt}-usr.sbin/config: ${_bt}-usr.bin/file2c ${_bt_lex_depend}
2736 # Note: no symlink to make/bmake in the !BOOTSTRAP_ALL_TOOLS case here since
2737 # the links to make/bmake make links will have already have been created in the
2738 # `make legacy` step. Not adding a link to make is important on non-FreeBSD
2739 # since "make" will usually point to GNU make there.
2740 _other_bootstrap_tools+=usr.bin/bmake
2742 # Avoid dependency on host bz2 headers:
2743 _other_bootstrap_tools+=lib/libbz2
2744 ${_bt}-usr.bin/grep: ${_bt}-lib/libbz2
2746 # libdwarf depends on libz
2747 _other_bootstrap_tools+=lib/libz
2748 ${_bt}-lib/libdwarf: ${_bt}-lib/libz
2750 # libroken depends on libcrypt
2751 _other_bootstrap_tools+=lib/libcrypt
2752 ${_bt}-lib/libroken: ${_bt}-lib/libcrypt
2754 # All tools in _basic_bootstrap_tools have the same name as the subdirectory
2755 # so we can use :T to get the name of the symlinks that we need to create.
2756 _bootstrap_tools_links+=${_basic_bootstrap_tools:T}
2757 .for _subdir _links in ${_basic_bootstrap_tools_multilink}
2758 _bootstrap_tools_links+=${_links:S/,/ /g}
2760 .endif # defined(BOOTSTRAP_ALL_TOOLS)
2762 # Link the tools that we need for building but don't need to bootstrap because
2763 # the host version is known to be compatible into ${WORLDTMP}/legacy
2764 # We do this before building any of the bootstrap tools in case they depend on
2765 # the presence of any of the links (e.g. as m4/lex/awk)
2766 ${_bt}-links: .PHONY
2768 .for _tool in ${_bootstrap_tools_links}
2769 ${_bt}-link-${_tool}: .PHONY
2770 @rm -f "${WORLDTMP}/legacy/bin/${_tool}"; \
2771 source_path=`which ${_tool}`; \
2772 if [ ! -e "$${source_path}" ] ; then \
2773 echo "Cannot find host tool '${_tool}'"; false; \
2775 cp -pf "$${source_path}" "${WORLDTMP}/legacy/bin/${_tool}"
2776 ${_bt}-links: ${_bt}-link-${_tool}
2779 bootstrap-tools: ${_bt}-links .PHONY
2781 # Please document (add comment) why something is in 'bootstrap-tools'.
2782 # Try to bound the building of the bootstrap-tool to just the
2783 # FreeBSD versions that need the tool built at this stage of the build.
2786 ${_kerberos5_bootstrap_tools} \
2791 ${_elftoolchain_libs} \
2800 ${_other_bootstrap_tools} \
2818 ${LOCAL_BSTOOL_DIRS}
2819 ${_bt}-${_tool}: ${_bt}-links .PHONY .MAKE
2820 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2821 cd ${.CURDIR}/${_tool}; \
2822 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2823 if [ "${_tool}" = "usr.bin/lex" ]; then \
2824 ${MAKE} DIRPRFX=${_tool}/ bootstrap; \
2826 ${MAKE} DIRPRFX=${_tool}/ all; \
2827 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy install
2829 bootstrap-tools: ${_bt}-${_tool}
2831 .if target(${_bt}-lib/libmd)
2832 # If we are bootstrapping libmd (e.g. when building on macOS/Linux) add the
2833 # necessary dependencies:
2834 ${_bt}-usr.bin/sort: ${_bt}-lib/libmd
2835 ${_bt}-usr.bin/xinstall: ${_bt}-lib/libmd
2836 ${_bt}-sbin/md5: ${_bt}-lib/libmd
2841 # build-tools: Build special purpose build tools
2843 .if !defined(NO_SHARE) && ${MK_SYSCONS} != "no"
2844 _share= share/syscons/scrnmaps
2847 .if ${MK_RESCUE} != "no"
2848 # rescue includes programs that have build-tools targets
2849 _rescue=rescue/rescue
2852 .if ${MK_TCSH} != "no"
2855 .if ${MK_FILE} != "no"
2856 _libmagic=lib/libmagic
2859 .if ${MK_PMC} != "no"
2860 _jevents=lib/libpmc/pmu-events
2863 # kernel-toolchain skips _cleanobj, so handle cleaning up previous
2864 # build-tools directories if needed.
2865 .if ${MK_CLEAN} == "yes" && make(kernel-toolchain)
2866 _bt_clean= ${CLEANDIR}
2872 ${LOCAL_TOOL_DIRS} \
2880 build-tools_${_tool}: .PHONY
2881 ${_+_}@${ECHODIR} "===> ${_tool} (${_bt_clean:D${_bt_clean},}obj,build-tools)"; \
2882 cd ${.CURDIR}/${_tool}; \
2883 if [ -n "${_bt_clean}" ]; then ${MAKE} DIRPRFX=${_tool}/ ${_bt_clean}; fi; \
2884 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2885 ${MAKE} DIRPRFX=${_tool}/ build-tools
2886 build-tools: build-tools_${_tool}
2890 # kernel-tools: Build kernel-building tools
2892 kernel-tools: .PHONY
2893 mkdir -p ${WORLDTMP}/usr
2894 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2895 -p ${WORLDTMP}/usr >/dev/null
2898 # cross-tools: All the tools needed to build the rest of the system after
2899 # we get done with the earlier stages. It is the last set of tools needed
2900 # to begin building the target binaries.
2902 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BUILD_WITH_STRICT_TMPPATH} != 0
2903 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
2904 _btxld= usr.sbin/btxld
2908 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
2909 # resulting from missing bug fixes or ELF Toolchain updates.
2910 .if ${MK_CDDL} != "no"
2911 _dtrace_tools= cddl/lib/libctf cddl/lib/libspl cddl/usr.bin/ctfconvert \
2912 cddl/usr.bin/ctfmerge
2915 # If we're given an XAS, don't build binutils.
2916 .if ${XAS:M/*} == ""
2917 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
2918 _elftctools= lib/libelftc \
2926 # These are not required by the build, but can be useful for developers who
2927 # cross-build on a FreeBSD 10 host:
2928 _elftctools+= usr.bin/addr2line
2930 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
2931 # If cross-building with an external binutils we still need to build strip for
2932 # the target (for at least crunchide).
2933 _elftctools= lib/libelftc \
2940 .if ${MK_CLANG_BOOTSTRAP} != "no"
2941 _clang= usr.bin/clang
2943 .if ${MK_LLD_BOOTSTRAP} != "no"
2944 _lld= usr.bin/clang/lld
2946 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no"
2947 _clang_libs= lib/clang
2949 .if ${MK_USB} != "no"
2950 _usb_tools= stand/usb/tools
2953 .if ${BUILD_WITH_STRICT_TMPPATH} != 0 || defined(BOOTSTRAP_ALL_TOOLS)
2957 cross-tools: .MAKE .PHONY
2959 ${LOCAL_XTOOL_DIRS} \
2968 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2969 cd ${.CURDIR}/${_tool}; \
2970 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2971 ${MAKE} DIRPRFX=${_tool}/ all; \
2972 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP} install
2976 # native-xtools is the current target for qemu-user cross builds of ports
2977 # via poudriere and the imgact_binmisc kernel module.
2978 # This target merely builds a toolchan/sysroot, then builds the tools it wants
2979 # with the options it wants in a special MAKEOBJDIRPREFIX, using the toolchain
2980 # already built. It then installs the static tools to NXBDESTDIR for Poudriere
2983 NXBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/nxb/
2984 NXBOBJTOP= ${NXBOBJROOT}${NXB_TARGET}.${NXB_TARGET_ARCH}
2987 .error NXTP variable should be an absolute path
2989 NXBDESTDIR?= ${DESTDIR}${NXTP}
2991 # This is the list of tools to be built/installed as static and where
2992 # appropriate to build for the given TARGET.TARGET_ARCH.
3055 SUBDIR_DEPEND_usr.bin/clang= lib/clang
3056 .if ${MK_CLANG} != "no"
3058 NXBDIRS+= usr.bin/clang
3060 # XXX: native-xtools passes along ${NXBDIRS} in SUBDIR_OVERRIDE that needs
3061 # to be evaluated after NXBDIRS is set.
3062 .if make(install) && !empty(SUBDIR_OVERRIDE)
3063 SUBDIR= ${SUBDIR_OVERRIDE}
3067 OBJTOP=${NXBOBJTOP:Q} \
3068 OBJROOT=${NXBOBJROOT:Q} \
3073 MK_CLANG_EXTRAS=no \
3074 MK_CLANG_FORMAT=no \
3094 # This should match all of the knobs in lib/Makefile that it takes to avoid
3095 # descending into lib/clang!
3096 NXBTNOTOOLS= MK_CLANG=no MK_LLD=no MK_LLDB=no MK_LLVM_BINUTILS=no
3098 .if make(native-xtools*) && \
3099 (!defined(NXB_TARGET) || !defined(NXB_TARGET_ARCH))
3100 .error Missing NXB_TARGET / NXB_TARGET_ARCH
3102 # For 'toolchain' we want to produce native binaries that themselves generate
3104 NXBTMAKE= ${NXBMAKEENV} ${MAKE} ${NXBMAKEARGS:N-DNO_PIC:N-DNO_SHARED} \
3105 TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH}
3106 # For 'everything' we want to produce native binaries (hence -target to
3107 # be MACHINE) that themselves generate TARGET.TARGET_ARCH binaries.
3108 # TARGET/TARGET_ARCH are still passed along from user.
3110 # Use the toolchain we create as an external toolchain.
3111 .if ${USING_SYSTEM_COMPILER} == "yes" || ${XCC:N${CCACHE_BIN}:M/*}
3112 NXBMAKE+= XCC="${XCC}" \
3116 NXBMAKE+= XCC="${NXBOBJTOP}/tmp/usr/bin/cc" \
3117 XCXX="${NXBOBJTOP}/tmp/usr/bin/c++" \
3118 XCPP="${NXBOBJTOP}/tmp/usr/bin/cpp"
3120 NXBMAKE+= ${NXBMAKEENV} ${MAKE} -f Makefile.inc1 ${NXBMAKEARGS} \
3121 MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} \
3122 TARGET=${NXB_TARGET} TARGET_ARCH=${NXB_TARGET_ARCH} \
3123 TARGET_TRIPLE=${MACHINE_TRIPLE:Q}
3124 # NXBDIRS is improperly based on MACHINE rather than NXB_TARGET. Need to
3125 # invoke a sub-make to reevaluate MK_CLANG, etc, for NXBDIRS.
3126 NXBMAKE+= SUBDIR_OVERRIDE='$${NXBDIRS:M*}'
3127 # Need to avoid the -isystem logic when using clang as an external toolchain
3128 # even if the TARGET being built for wants GCC.
3129 NXBMAKE+= WANT_COMPILER_TYPE='$${X_COMPILER_TYPE}'
3130 native-xtools: .PHONY
3131 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _cleanobj
3132 # Build the bootstrap/host/cross tools that produce native binaries
3133 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} kernel-toolchain
3134 # Populate includes/libraries sysroot that produce native binaries.
3135 # This is split out from 'toolchain' above mostly so that target LLVM
3136 # libraries have a proper LLVM_DEFAULT_TARGET_TRIPLE without
3137 # polluting the cross-compiler build. The LLVM libs are skipped
3138 # here to avoid the problem but are kept in 'toolchain' so that
3139 # needed build tools are built.
3140 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes ${NXBTNOTOOLS}
3141 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries ${NXBTNOTOOLS}
3142 .if !defined(NO_OBJWALK)
3143 ${_+_}cd ${.CURDIR}; ${NXBMAKE} _obj
3145 ${_+_}cd ${.CURDIR}; ${NXBMAKE} everything
3146 @echo ">> native-xtools done. Use 'make native-xtools-install' to install to a given DESTDIR"
3148 native-xtools-install: .PHONY
3149 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
3150 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
3151 -p ${NXBDESTDIR}/usr >/dev/null
3152 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
3153 -p ${NXBDESTDIR}/usr/include >/dev/null
3154 .for d in ${LIBCOMPAT_INCLUDE_DIRS}
3155 mkdir -p ${NXBDESTDIR}/usr/include/${d}
3157 ${_+_}cd ${.CURDIR}; ${NXBMAKE} \
3158 DESTDIR=${NXBDESTDIR} \
3163 # hierarchy - ensure that all the needed directories are present
3165 hierarchy hier: .MAKE .PHONY
3166 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
3169 # libraries - build all libraries, and install them under ${DESTDIR}.
3171 # The list of libraries with dependents (${_prebuild_libs}) and their
3172 # interdependencies (__L) are built automatically by the
3173 # ${.CURDIR}/tools/make_libdeps.sh script.
3175 libraries: .MAKE .PHONY
3176 ${_+_}cd ${.CURDIR}; \
3177 ${MAKE} -f Makefile.inc1 _prereq_libs; \
3178 ${MAKE} -f Makefile.inc1 _startup_libs; \
3179 ${MAKE} -f Makefile.inc1 _prebuild_libs -DLIBCRYPTO_WITHOUT_SUBDIRS; \
3180 ${MAKE} -f Makefile.inc1 _generic_libs
3183 # static libgcc.a prerequisite for shared libc
3185 _prereq_libs= lib/libcompiler_rt
3186 .if ${MK_SSP} != "no"
3187 _prereq_libs+= lib/libssp_nonshared
3189 .if ${MK_ASAN} != "no"
3190 _prereq_libs+= lib/libclang_rt/asan
3191 _prereq_libs+= lib/libclang_rt/asan-preinit
3192 _prereq_libs+= lib/libclang_rt/asan_cxx
3193 _prereq_libs+= lib/libclang_rt/asan_static
3195 .if ${MK_UBSAN} != "no"
3196 _prereq_libs+= lib/libclang_rt/ubsan_minimal
3197 _prereq_libs+= lib/libclang_rt/ubsan_standalone
3198 _prereq_libs+= lib/libclang_rt/ubsan_standalone_cxx
3201 # These dependencies are not automatically generated:
3203 # lib/csu and lib/libc must be built before
3204 # all shared libraries for ELF.
3206 _startup_libs= lib/csu
3207 _startup_libs+= lib/libc
3208 _startup_libs+= lib/libc_nonshared
3209 _startup_libs+= lib/libcxxrt
3210 _startup_libs+= lib/libsys
3212 _prereq_libs+= lib/libgcc_eh lib/libgcc_s
3213 _startup_libs+= lib/libgcc_eh lib/libgcc_s
3215 lib/libc__L: lib/libsys__L
3216 lib/libgcc_s__L: lib/libc__L
3217 lib/libgcc_s__L: lib/libc_nonshared__L
3218 lib/libcxxrt__L: lib/libgcc_s__L
3219 lib/libcrypt__L: lib/libmd__L
3221 _prebuild_libs= ${_kerberos5_lib_libasn1} \
3222 ${_kerberos5_lib_libhdb} \
3223 ${_kerberos5_lib_libheimbase} \
3224 ${_kerberos5_lib_libheimntlm} \
3226 ${_kerberos5_lib_libheimipcc} \
3227 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
3228 ${_kerberos5_lib_libroken} \
3229 ${_kerberos5_lib_libwind} \
3230 lib/libbz2 ${_libcom_err} lib/libcrypt \
3232 lib/libelf lib/libexpat \
3236 lib/libkiconv lib/libkldelf lib/libkvm \
3237 lib/liblzma lib/libmd lib/libnv \
3241 lib/ncurses/ncurses \
3242 lib/libpam/libpam lib/libthr \
3243 ${_lib_libradius} lib/libsbuf lib/libtacplus \
3246 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
3247 ${_cddl_lib_libuutil} \
3248 ${_cddl_lib_libavl} \
3249 ${_cddl_lib_libicp} \
3250 ${_cddl_lib_libicp_rescue} \
3251 ${_cddl_lib_libspl} \
3252 ${_cddl_lib_libtpool} \
3253 ${_cddl_lib_libzfs_core} ${_cddl_lib_libzfs} \
3254 ${_cddl_lib_libzutil} \
3255 ${_cddl_lib_libctf} ${_cddl_lib_libzfsbootenv} \
3257 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
3259 ${_secure_lib_libcrypto} ${_secure_lib_libssl} \
3260 ${_lib_libldns} ${_secure_lib_libssh}
3262 .if ${MK_DIALOG} != "no"
3263 _prebuild_libs+= gnu/lib/libdialog
3264 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/tinfo__L lib/ncurses/ncurses__L
3267 .if ${MK_GOOGLETEST} != "no"
3268 _prebuild_libs+= lib/libregex
3271 lib/libgeom__L: lib/libexpat__L lib/libsbuf__L
3272 lib/libkldelf__L: lib/libelf__L
3273 lib/libkvm__L: lib/libelf__L
3275 .if ${MK_RADIUS_SUPPORT} != "no"
3276 _lib_libradius= lib/libradius
3279 lib/ncurses/ncurses__L: lib/ncurses/tinfo__L
3281 .if ${MK_OFED} != "no"
3283 lib/ofed/libibverbs \
3285 lib/ofed/libibumad \
3289 lib/ofed/libibmad__L: lib/ofed/libibumad__L
3290 lib/ofed/complib__L: lib/libthr__L
3291 lib/ofed/libmlx5__L: lib/ofed/libibverbs__L lib/libthr__L
3294 .if ${MK_CASPER} != "no"
3295 _lib_casper= lib/libcasper
3298 lib/libpjdlog__L: lib/libutil__L
3299 lib/libcasper__L: lib/libnv__L
3300 lib/liblzma__L: lib/libmd__L lib/libthr__L
3301 lib/libzstd__L: lib/libthr__L
3302 lib/librt__L: lib/libthr__L
3304 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib}
3305 .if ${MK_IPFILTER} != "no"
3306 _generic_libs+= sbin/ipf/libipf
3308 .for _DIR in ${LOCAL_LIB_DIRS}
3309 .if ${_DIR} == ".WAIT" || (empty(_generic_libs:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
3310 _generic_libs+= ${_DIR}
3314 lib/libtacplus__L: lib/libmd__L lib/libpam/libpam__L
3315 lib/libxo__L: lib/libutil__L
3317 .if ${MK_CDDL} != "no"
3318 _cddl_lib_libumem= cddl/lib/libumem
3319 _cddl_lib_libnvpair= cddl/lib/libnvpair
3320 _cddl_lib_libavl= cddl/lib/libavl
3321 _cddl_lib_libuutil= cddl/lib/libuutil
3322 _cddl_lib_libspl= cddl/lib/libspl
3324 cddl/lib/libavl__L: cddl/lib/libspl__L
3325 cddl/lib/libnvpair__L: cddl/lib/libspl__L
3326 cddl/lib/libuutil__L: cddl/lib/libavl__L cddl/lib/libspl__L
3328 .if ${MK_ZFS} != "no"
3329 _lib_librt= lib/librt
3330 _cddl_lib_libicp= cddl/lib/libicp
3331 _cddl_lib_libicp_rescue= cddl/lib/libicp_rescue
3332 _cddl_lib_libtpool= cddl/lib/libtpool
3333 _cddl_lib_libzutil= cddl/lib/libzutil
3334 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
3335 _cddl_lib_libzfs= cddl/lib/libzfs
3336 _cddl_lib_libzfsbootenv= cddl/lib/libzfsbootenv
3338 cddl/lib/libtpool__L: cddl/lib/libspl__L
3340 cddl/lib/libzutil__L: cddl/lib/libavl__L lib/libgeom__L lib/msun__L cddl/lib/libtpool__L
3342 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L cddl/lib/libspl__L cddl/lib/libzutil__L
3344 cddl/lib/libzfs__L: cddl/lib/libzfs_core__L lib/msun__L lib/libutil__L lib/librt__L
3345 cddl/lib/libzfs__L: lib/libthr__L lib/libmd__L lib/libz__L cddl/lib/libumem__L
3346 cddl/lib/libzfs__L: cddl/lib/libuutil__L cddl/lib/libavl__L lib/libgeom__L
3347 cddl/lib/libzfs__L: cddl/lib/libnvpair__L cddl/lib/libzutil__L
3348 cddl/lib/libzfs__L: secure/lib/libcrypto__L
3350 cddl/lib/libzfsbootenv__L: cddl/lib/libzfs__L
3351 lib/libbe__L: cddl/lib/libzfs__L cddl/lib/libzfsbootenv__L
3353 _cddl_lib_libctf= cddl/lib/libctf
3355 cddl/lib/libctf__L: lib/libz__L cddl/lib/libspl__L
3356 cddl/lib/libdtrace__L: lib/libxo__L
3358 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db
3359 _prebuild_libs+= lib/libprocstat lib/libproc lib/librtld_db
3360 lib/libprocstat__L: lib/libelf__L lib/libkvm__L lib/libutil__L
3361 lib/libproc__L: lib/libprocstat__L
3362 lib/librtld_db__L: lib/libprocstat__L
3364 .if ${MK_CRYPT} != "no"
3365 .if ${MK_OPENSSL} != "no"
3366 _secure_lib_libcrypto= secure/lib/libcrypto
3367 _secure_lib_libssl= secure/lib/libssl
3368 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
3369 secure/lib/libcrypto__L: lib/libthr__L
3370 .if ${MK_LDNS} != "no"
3371 _lib_libldns= lib/libldns
3372 lib/libldns__L: secure/lib/libssl__L
3374 .if ${MK_OPENSSH} != "no"
3375 _secure_lib_libssh= secure/lib/libssh
3376 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
3377 .if ${MK_LDNS} != "no"
3378 secure/lib/libssh__L: lib/libldns__L
3380 .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no"
3381 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
3382 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
3383 lib/libmd__L kerberos5/lib/libroken__L
3387 _secure_lib= secure/lib
3390 .if ${MK_KERBEROS} != "no"
3391 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
3392 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
3393 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
3394 kerberos5/lib/libwind__L lib/libsqlite3__L
3395 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
3396 kerberos5/lib/libroken__L lib/libcom_err__L
3397 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
3398 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
3399 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
3400 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
3401 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
3402 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
3403 kerberos5/lib/libroken__L: lib/libcrypt__L
3404 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
3405 kerberos5/lib/libheimbase__L: lib/libthr__L
3406 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
3409 lib/libsqlite3__L: lib/libthr__L
3411 .if ${MK_GSSAPI} != "no"
3412 _lib_libgssapi= lib/libgssapi
3415 .if ${MK_KERBEROS} != "no"
3416 _kerberos5_lib= kerberos5/lib
3417 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
3418 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
3419 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
3420 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
3421 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
3422 _kerberos5_lib_libroken= kerberos5/lib/libroken
3423 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
3424 _libsqlite3= lib/libsqlite3
3425 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
3426 _kerberos5_lib_libwind= kerberos5/lib/libwind
3427 _libcom_err= lib/libcom_err
3430 .if ${MK_NIS} != "no"
3431 _lib_libypclnt= lib/libypclnt
3434 .if ${MK_OPENSSL} == "no"
3435 lib/libradius__L: lib/libmd__L
3439 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} \
3440 lib/libelf__L lib/librtld_db__L lib/libutil__L lib/libcxxrt__L
3442 .for _lib in ${_prereq_libs}
3443 ${_lib}__PL: .PHONY .MAKE
3444 .if !defined(_MKSHOWCONFIG) && exists(${.CURDIR}/${_lib})
3445 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
3446 cd ${.CURDIR}/${_lib}; \
3447 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
3448 ${MAKE} MK_TESTS=no -DNO_PIC \
3449 DIRPRFX=${_lib}/ all; \
3450 ${MAKE} MK_TESTS=no -DNO_PIC \
3451 DIRPRFX=${_lib}/ install
3455 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
3456 ${_lib}__L: .PHONY .MAKE
3457 .if !defined(_MKSHOWCONFIG) && exists(${.CURDIR}/${_lib})
3458 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
3459 cd ${.CURDIR}/${_lib}; \
3460 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
3461 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
3462 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
3466 _prereq_libs: ${_prereq_libs:S/$/__PL/}
3467 _startup_libs: ${_startup_libs:S/$/__L/}
3468 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
3469 _generic_libs: ${_generic_libs:S/$/__L/}
3471 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
3472 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
3473 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
3474 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
3475 # parallel. This is safe for the world stage of buildworld though since it has
3476 # already built libraries in a proper order and installed includes into
3477 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
3478 # avoid trashing a system if it crashes mid-install.
3479 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
3483 .include <bsd.subdir.mk>
3485 .if make(check-old) || make(check-old-dirs) || \
3486 make(check-old-files) || make(check-old-libs) || \
3487 make(delete-old) || make(delete-old-dirs) || \
3488 make(delete-old-files) || make(delete-old-libs) || \
3489 make(list-old-dirs) || make(list-old-files) || make(list-old-libs)
3492 # check for / delete old files section
3495 .include "ObsoleteFiles.inc"
3497 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
3498 else you can not start such an application. Consult UPDATING for more \
3499 information regarding how to cope with the removal/revision bump of a \
3502 .if !defined(BATCH_DELETE_OLD_FILES)
3508 list-old-files: .PHONY
3510 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3511 -V "OLD_FILES:ts\n" -V "OLD_FILES:Musr/share/*.gz:R:ts\n" \
3512 -V "MOVED_LIBS:ts\n" \
3513 ${_ALL_libcompats:@v@-V "OLD_FILES:Mlib/*.so.*:S,^lib,usr/lib$v,:ts\n"@} \
3514 ${_ALL_libcompats:@v@-V "OLD_FILES:Musr/lib/*:S,^usr/lib,usr/lib$v,:ts\n"@} | \
3517 delete-old-files: .PHONY
3518 @echo ">>> Removing old files (only deletes safe to delete libs)"
3519 # Ask for every old file if the user really wants to remove it.
3520 # It's annoying, but better safe than sorry.
3521 # NB: We cannot pass the list of OLD_FILES as a parameter because the
3522 # argument list will get too long. Using .for/.endfor make "loops" will make
3523 # the Makefile parser segfault.
3526 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-files | \
3527 while read file; do \
3528 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3529 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
3530 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
3532 for ext in debug symbols; do \
3533 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
3534 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3535 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
3540 # Remove catpages without corresponding manpages.
3542 find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | sort | \
3543 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
3544 while read catpage; do \
3546 if [ ! -e "$${manpage}" ]; then \
3547 rm ${RM_I} $${catpage} <&3; \
3550 @echo ">>> Old files removed"
3552 check-old-files: .PHONY
3553 @echo ">>> Checking for old files"
3555 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-files | \
3556 while read file; do \
3557 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3558 echo "${DESTDIR}/$${file}"; \
3560 for ext in debug symbols; do \
3561 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3562 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
3566 # Check for catpages without corresponding manpages.
3567 @find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \
3568 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
3569 while read catpage; do \
3571 if [ ! -e "$${manpage}" ]; then \
3576 list-old-libs: .PHONY
3578 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3579 -V "OLD_LIBS:ts\n" \
3580 ${_ALL_libcompats:@v@-V "OLD_LIBS:Mlib/*:S,^lib,usr/lib$v,:ts\n"@} \
3581 ${_ALL_libcompats:@v@-V "OLD_LIBS:Musr/lib/*:S,^usr/lib,usr/lib$v,:ts\n"@} \
3582 ${_ALL_libcompats:@v@-V "OLD_LIBS:Mlib/casper/*:S,^lib/casper,usr/lib$v,:ts\n"@} | \
3585 delete-old-libs: .PHONY
3586 @echo ">>> Removing old libraries"
3587 @echo "${OLD_LIBS_MESSAGE}" | fmt
3590 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-libs | \
3591 while read file; do \
3592 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3593 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
3594 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
3596 for ext in debug symbols; do \
3597 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
3598 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3599 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
3604 @echo ">>> Old libraries removed"
3606 check-old-libs: .PHONY
3607 @echo ">>> Checking for old libraries"
3609 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-libs | \
3610 while read file; do \
3611 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3612 echo "${DESTDIR}/$${file}"; \
3614 for ext in debug symbols; do \
3615 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3616 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
3621 list-old-dirs: .PHONY
3623 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3624 -V OLD_DIRS | sed -E 's/[[:space:]]+/\n/g' | sort -r
3626 delete-old-dirs: .PHONY
3627 @echo ">>> Removing old directories"
3629 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-dirs | \
3630 while read dir; do \
3631 if [ -d "${DESTDIR}/$${dir}" ]; then \
3632 rmdir -v "${DESTDIR}/$${dir}" || true; \
3633 elif [ -L "${DESTDIR}/$${dir}" ]; then \
3634 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
3636 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3637 rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \
3638 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3639 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
3642 @echo ">>> Old directories removed"
3644 check-old-dirs: .PHONY
3645 @echo ">>> Checking for old directories"
3647 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-dirs | \
3648 while read dir; do \
3649 if [ -d "${DESTDIR}/$${dir}" ]; then \
3650 echo "${DESTDIR}/$${dir}"; \
3651 elif [ -L "${DESTDIR}/$${dir}" ]; then \
3652 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
3654 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3655 echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \
3656 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3657 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
3661 delete-old: delete-old-files delete-old-dirs .PHONY
3662 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
3664 check-old: check-old-files check-old-libs check-old-dirs .PHONY
3665 @echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
3666 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
3671 # showconfig - show build configuration.
3673 # ignore lower case knobs (not for use with WITH*)
3676 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}; \
3677 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}) 2>&1 | \
3678 grep -E '^(MK|OPT)_[A-Z]' | sort -u
3680 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
3681 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
3683 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
3684 .if !defined(_MKSHOWCONFIG) && exists(${KERNCONFDIR}/${KERNCONF})
3685 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
3686 '${KERNCONFDIR}/${KERNCONF}' ; echo
3692 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
3693 DTBOUTPUTPATH= ${.CURDIR}
3697 # Build 'standalone' Device Tree Blob
3700 @PATH=${TMPPATH:Q} MACHINE=${TARGET} \
3701 sh ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
3702 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
3707 # In the following, the first 'rm' in a series will usually remove all
3708 # files and directories. If it does not, then there are probably some
3709 # files with file flags set, so this unsets them and tries the 'rm' a
3710 # second time. There are situations where this target will be cleaning
3711 # some directories via more than one method, but that duplication is
3712 # needed to correctly handle all the possible situations. Removing all
3713 # files without file flags set in the first 'rm' instance saves time,
3714 # because 'chflags' will need to operate on fewer files afterwards.
3716 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
3717 # created by bsd.obj.mk, except that we don't want to .include that file
3718 # in this makefile. We don't do a cleandir walk if MK_AUTO_OBJ is yes
3719 # since it is not possible for files to land in the wrong place.
3721 .if make(cleanworld)
3722 BW_CANONICALOBJDIR:=${OBJTOP}/
3723 .elif make(cleankernel)
3724 BW_CANONICALOBJDIR:=${KRNLOBJDIR}/${KERNCONF}/
3725 .elif make(cleanuniverse)
3726 BW_CANONICALOBJDIR:=${OBJROOT}
3727 .if ${MK_UNIFIED_OBJDIR} == "no"
3728 .error ${.TARGETS} only supported with WITH_UNIFIED_OBJDIR enabled.
3731 cleanworld cleanuniverse cleankernel: .PHONY
3732 .if !empty(BW_CANONICALOBJDIR) && exists(${BW_CANONICALOBJDIR}) && \
3733 ${.CURDIR:tA} != ${BW_CANONICALOBJDIR:tA}
3734 -(cd ${BW_CANONICALOBJDIR} && rm -rf *)
3735 -chflags -R 0 ${BW_CANONICALOBJDIR}
3736 -(cd ${BW_CANONICALOBJDIR} && rm -rf *)
3738 .if make(cleanworld) && ${MK_AUTO_OBJ} == "no" && \
3739 (empty(BW_CANONICALOBJDIR) || ${.CURDIR:tA} == ${BW_CANONICALOBJDIR:tA})
3740 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
3741 # To be safe in this case, fall back to a 'make cleandir'
3742 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
3746 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
3747 XDEV_CPUTYPE?=${CPUTYPE}
3749 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
3752 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
3753 MK_MAN=no MK_NLS=no \
3754 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WERROR=no \
3755 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
3756 CPUTYPE=${XDEV_CPUTYPE}
3758 XDDIR=${TARGET_ARCH}-freebsd
3761 .error XDTP variable should be an absolute path
3764 CDBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/xdev/
3765 CDBOBJTOP= ${CDBOBJROOT}${XDDIR}
3767 INSTALL="sh ${.CURDIR}/tools/install.sh"
3769 TOOLS_PREFIX=${XDTP}
3771 OBJTOP=${CDBOBJTOP:Q} \
3772 OBJROOT=${CDBOBJROOT:Q}
3773 CD2MAKEARGS= ${CDMAKEARGS}
3775 .if ${WANT_COMPILER_TYPE} == gcc || \
3776 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
3777 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
3778 # won't set header path and -L is used to ensure the base library path
3779 # is added before the port PREFIX library path.
3780 CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib
3781 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
3782 # combined with --sysroot.
3783 CD2CFLAGS+= -B${XDDESTDIR}/usr/lib
3784 # Force using libc++ for external GCC.
3785 .if defined(X_COMPILER_TYPE) && \
3786 ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
3787 CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \
3791 CD2CFLAGS+= --sysroot=${XDDESTDIR}/
3792 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \
3793 CPP="${CPP} ${CD2CFLAGS}" \
3794 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
3796 CDTMP= ${OBJTOP}/${XDDIR}/tmp
3797 CDMAKE=${CDENV} PATH=${CDTMP:Q}/usr/bin:${PATH:Q} ${MAKE} ${CDMAKEARGS} ${NOFUN}
3798 CD2MAKE=${CD2ENV} PATH=${CDTMP:Q}/usr/bin:${XDDESTDIR:Q}/usr/bin:${PATH:Q} \
3799 ${MAKE} ${CD2MAKEARGS} ${NOFUN}
3800 .if ${MK_META_MODE} != "no"
3801 # Don't rebuild build-tools targets during normal build.
3802 CD2MAKE+= BUILD_TOOLS_META=.NOMETA
3804 XDDESTDIR=${DESTDIR}${XDTP}
3806 .ORDER: xdev-build xdev-install xdev-links
3807 xdev: xdev-build xdev-install .PHONY
3809 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
3810 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
3812 _xb-worldtmp: .PHONY
3813 mkdir -p ${CDTMP}/usr
3814 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
3815 -p ${CDTMP}/usr >/dev/null
3817 _xb-bootstrap-tools: .PHONY
3821 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
3822 cd ${.CURDIR}/${_tool}; \
3823 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
3824 ${CDMAKE} DIRPRFX=${_tool}/ all; \
3825 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
3828 _xb-build-tools: .PHONY
3829 ${_+_}@cd ${.CURDIR}; \
3830 ${CDBENV} ${MAKE} ${CDMAKEARGS} -f Makefile.inc1 ${NOFUN} build-tools
3839 _xb-cross-tools: .PHONY
3840 .for _tool in ${XDEVDIRS}
3841 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
3842 cd ${.CURDIR}/${_tool}; \
3843 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
3844 ${CDMAKE} DIRPRFX=${_tool}/ all
3848 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
3849 mkdir -p ${XDDESTDIR}
3850 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.root.dist \
3851 -p ${XDDESTDIR} >/dev/null
3852 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
3853 -p ${XDDESTDIR}/usr >/dev/null
3854 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
3855 -p ${XDDESTDIR}/usr/include >/dev/null
3856 .for d in ${LIBCOMPAT_INCLUDE_DIRS}
3857 mkdir -p ${XDDESTDIR}/usr/include/${d}
3859 .for libcompat in ${libcompats}
3860 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
3861 -p ${XDDESTDIR}/usr >/dev/null
3863 .if ${MK_TESTS} != "no"
3864 mkdir -p ${XDDESTDIR}${TESTSBASE}
3865 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
3866 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
3869 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
3870 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
3872 _xi-cross-tools: .PHONY
3873 @echo "_xi-cross-tools"
3874 .for _tool in ${XDEVDIRS}
3875 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
3876 cd ${.CURDIR}/${_tool}; \
3877 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
3880 _xi-includes: .PHONY
3881 .if !defined(NO_OBJWALK)
3882 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 _obj \
3883 DESTDIR=${XDDESTDIR}
3885 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
3886 DESTDIR=${XDDESTDIR}
3888 _xi-libraries: .PHONY
3889 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
3890 DESTDIR=${XDDESTDIR}
3893 ${_+_}cd ${XDDESTDIR}/usr/bin; \
3894 mkdir -p ../../../../usr/bin; \
3896 ln -sf ../../${XDTP}/usr/bin/$$i \
3897 ../../../../usr/bin/${XDDIR}-$$i; \
3898 ln -sf ../../${XDTP}/usr/bin/$$i \
3899 ../../../../usr/bin/${XDDIR}${_REVISION}-$$i; \