4 # Make command line options:
5 # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6 # -DNO_CLEAN do not clean at all
7 # -DDB_FROM_SRC use the user/group databases in src/etc instead of
8 # the system database when installing.
9 # -DNO_SHARE do not go into share subdir
10 # -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,OBJ}
11 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
12 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
13 # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
14 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
15 # -DNO_ROOT install without using root privilege
16 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
17 # -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects
18 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
19 # LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list
20 # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
21 # LOCAL_MTREE="list of mtree files" to process to allow local directories
22 # to be created before files are installed
23 # LOCAL_LEGACY_DIRS="list of dirs" to add additional dirs to the legacy
25 # LOCAL_BSTOOL_DIRS="list of dirs" to add additional dirs to the
26 # bootstrap-tools target
27 # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
29 # LOCAL_XTOOL_DIRS="list of dirs" to add additional dirs to the
31 # METALOG="path to metadata log" to write permission and ownership
32 # when NO_ROOT is set. (default: ${DESTDIR}/${DISTDIR}/METALOG,
33 # check /etc/make.conf for DISTDIR)
34 # TARGET="machine" to crossbuild world for a different machine type
35 # TARGET_ARCH= may be required when a TARGET supports multiple endians
36 # BUILDENV_SHELL= shell to launch for the buildenv target (def:${SHELL})
37 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
38 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
39 # SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
40 # All libraries and includes, and some build tools will still build.
43 # The intended user-driven targets are:
44 # buildworld - rebuild *everything*, including glue to help do upgrades
45 # installworld- install everything built by "buildworld"
46 # checkworld - run test suite on installed world
47 # doxygen - build API documentation of the kernel
48 # update - convenient way to update your source tree (eg: svn/svnup)
50 # Standard targets (not defined here) are documented in the makefiles in
51 # /usr/share/mk. These include:
52 # obj depend all install clean cleandepend cleanobj
54 .if !defined(TARGET) || !defined(TARGET_ARCH)
55 .error "Both TARGET and TARGET_ARCH must be defined."
58 .if make(showconfig) || make(test-system-*)
63 LOCALBASE?= /usr/local
65 .include "share/mk/src.tools.mk"
67 # Cross toolchain changes must be in effect before bsd.compiler.mk
68 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
69 .if defined(CROSS_TOOLCHAIN)
70 .if exists(${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk)
71 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
72 .elif exists(/usr/share/toolchains/${CROSS_TOOLCHAIN}.mk)
73 .include "/usr/share/toolchains/${CROSS_TOOLCHAIN}.mk"
74 .elif exists(${CROSS_TOOLCHAIN})
75 .include "${CROSS_TOOLCHAIN}"
77 .error CROSS_TOOLCHAIN ${CROSS_TOOLCHAIN} not found
79 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
81 .if defined(CROSS_TOOLCHAIN_PREFIX)
82 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
85 XCOMPILERS= CC CXX CPP
86 .for COMPILER in ${XCOMPILERS}
87 .if defined(CROSS_COMPILER_PREFIX)
88 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
90 X${COMPILER}?= ${${COMPILER}}
93 # If a full path to an external cross compiler is given, don't build
95 .if ${XCC:N${CCACHE_BIN}:M/*}
96 MK_CLANG_BOOTSTRAP= no
99 # Pull in compiler metadata from buildworld/toolchain if possible to avoid
100 # running CC from bsd.compiler.mk.
101 .if make(installworld) || make(install) || make(distributeworld) || \
103 .-include "${OBJTOP}/toolchain-metadata.mk"
104 .if !defined(_LOADED_TOOLCHAIN_METADATA)
105 .error A build is required first. You may have the wrong MAKEOBJDIRPREFIX set.
109 # Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early. Pull it from the
110 # tree to be friendlier to foreign OS builds. It's safe to do so unconditionally
111 # here since we will always have the right make, unlike in src/Makefile
112 # Don't include bsd.linker.mk yet until XBINUTILS is handled (after src.opts.mk)
113 _NO_INCLUDE_LINKERMK= t
114 # We also want the X_COMPILER* variables if we are using an external toolchain.
115 _WANT_TOOLCHAIN_CROSS_VARS= t
116 .include "share/mk/bsd.compiler.mk"
117 .undef _NO_INCLUDE_LINKERMK
118 .undef _WANT_TOOLCHAIN_CROSS_VARS
119 # src.opts.mk depends on COMPILER_FEATURES
120 .include "share/mk/src.opts.mk"
122 .if ${TARGET} == ${MACHINE}
123 TARGET_CPUTYPE?=${CPUTYPE}
127 .if !empty(TARGET_CPUTYPE)
128 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
130 _TARGET_CPUTYPE=dummy
132 .if ${TARGET} == "arm"
133 .if ${TARGET_ARCH:Marmv[67]*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
134 TARGET_ABI= gnueabihf
139 MACHINE_ABI?= unknown
140 MACHINE_TRIPLE?=${MACHINE_ARCH:S/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${MACHINE_ABI}-freebsd13.0
142 TARGET_TRIPLE?= ${TARGET_ARCH:S/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${TARGET_ABI}-freebsd13.0
143 KNOWN_ARCHES?= aarch64/arm64 \
160 powerpc64le/powerpc \
165 .if ${TARGET} == ${TARGET_ARCH}
168 _t= ${TARGET_ARCH}/${TARGET}
171 .if empty(KNOWN_ARCHES:M${_t})
172 .error Unknown target ${TARGET_ARCH}:${TARGET}.
176 .if ${.MAKE.OS} != "FreeBSD"
177 CROSSBUILD_HOST=${.MAKE.OS}
178 .if ${.MAKE.OS} != "Linux" && ${.MAKE.OS} != "Darwin"
179 .warning "Unsupported crossbuild system: ${.MAKE.OS}. Build will probably fail!"
181 # We need to force NO_ROOT/DB_FROM_SRC builds when building on other operating
182 # systems since the BSD.foo.dist specs contain users and groups that do not
183 # exist by default on a Linux/MacOS system.
189 # If all targets are disabled for system llvm then don't expect it to work
191 .if !defined(TOOLS_PREFIX) && ${MK_LLVM_TARGET_ALL} == "no" && \
192 ${MACHINE} != ${TARGET} && ${MACHINE_ARCH} != ${TARGET_ARCH} && \
194 MK_SYSTEM_COMPILER= no
198 # Handle external binutils.
199 .if defined(CROSS_TOOLCHAIN_PREFIX)
200 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
202 XBINUTILS= AS AR LD NM OBJCOPY RANLIB SIZE STRINGS STRIPBIN
203 .for BINUTIL in ${XBINUTILS}
204 .if defined(CROSS_BINUTILS_PREFIX) && \
205 exists(${CROSS_BINUTILS_PREFIX}/${${BINUTIL}})
206 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX:C,/*$,,}/${${BINUTIL}}
208 X${BINUTIL}?= ${${BINUTIL}}
212 # If a full path to an external linker is given, don't build lld.
217 # We also want the X_LINKER* variables if we are using an external toolchain.
218 _WANT_TOOLCHAIN_CROSS_VARS= t
219 .include "share/mk/bsd.linker.mk"
220 .undef _WANT_TOOLCHAIN_CROSS_VARS
222 # Begin WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD
224 # WITH_SYSTEM_COMPILER - Pull in needed values and make a decision.
226 # Check if there is a local compiler that can satisfy as an external compiler.
227 # Which compiler is expected to be used?
228 .if ${MK_CLANG_BOOTSTRAP} == "yes"
229 WANT_COMPILER_TYPE= clang
234 .if !defined(WANT_COMPILER_FREEBSD_VERSION) && !make(showconfig) && \
235 !make(test-system-linker)
236 .if ${WANT_COMPILER_TYPE} == "clang"
237 WANT_COMPILER_FREEBSD_VERSION_FILE= lib/clang/freebsd_cc_version.h
238 WANT_COMPILER_FREEBSD_VERSION!= \
239 awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
240 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
241 WANT_COMPILER_VERSION_FILE= lib/clang/include/clang/Basic/Version.inc
242 WANT_COMPILER_VERSION!= \
243 awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
244 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
246 .export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION
247 .endif # !defined(WANT_COMPILER_FREEBSD_VERSION)
249 # It needs to be the same revision as we would build for the bootstrap.
250 # If the expected vs CC is different then we can't skip.
251 # GCC cannot be used for cross-arch yet. For clang we pass -target later if
252 # TARGET_ARCH!=MACHINE_ARCH.
253 .if ${MK_SYSTEM_COMPILER} == "yes" && \
254 defined(WANT_COMPILER_FREEBSD_VERSION) && \
255 ${MK_CLANG_BOOTSTRAP} == "yes" && \
257 ${X_COMPILER_TYPE} == ${WANT_COMPILER_TYPE} && \
258 (${X_COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \
259 ${X_COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \
260 ${X_COMPILER_FREEBSD_VERSION} == ${WANT_COMPILER_FREEBSD_VERSION}
261 # Everything matches, disable the bootstrap compiler.
262 MK_CLANG_BOOTSTRAP= no
263 USING_SYSTEM_COMPILER= yes
264 .endif # ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE}
266 # WITH_SYSTEM_LD - Pull in needed values and make a decision.
268 # Check if there is a local linker that can satisfy as an external linker.
269 # Which linker is expected to be used?
270 .if ${MK_LLD_BOOTSTRAP} == "yes"
271 WANT_LINKER_TYPE= lld
276 .if !defined(WANT_LINKER_FREEBSD_VERSION) && !make(showconfig) && \
277 !make(test-system-compiler)
278 .if ${WANT_LINKER_TYPE} == "lld"
279 WANT_LINKER_FREEBSD_VERSION_FILE= lib/clang/include/VCSVersion.inc
280 _WANT_LINKER_FREEBSD_VERSION!= \
281 awk '$$2 == "LLD_REVISION" {gsub(/"/, "", $$3); print $$3}' \
282 ${SRCDIR}/${WANT_LINKER_FREEBSD_VERSION_FILE} || echo unknown
283 WANT_LINKER_FREEBSD_VERSION=${_WANT_LINKER_FREEBSD_VERSION:C/.*-(.*)/\1/}
284 WANT_LINKER_VERSION_FILE= lib/clang/include/lld/Common/Version.inc
285 WANT_LINKER_VERSION!= \
286 awk '$$2 == "LLD_VERSION_STRING" { gsub("\"", "", $$3); split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
287 ${SRCDIR}/${WANT_LINKER_VERSION_FILE} || echo unknown
289 WANT_LINKER_FREEBSD_VERSION_FILE=
290 WANT_LINKER_FREEBSD_VERSION=
292 .export WANT_LINKER_FREEBSD_VERSION WANT_LINKER_VERSION
293 .endif # !defined(WANT_LINKER_FREEBSD_VERSION)
295 .if ${MK_SYSTEM_LINKER} == "yes" && \
296 defined(WANT_LINKER_FREEBSD_VERSION) && \
297 (${MK_LLD_BOOTSTRAP} == "yes") && \
299 ${X_LINKER_TYPE} == ${WANT_LINKER_TYPE} && \
300 ${X_LINKER_VERSION} == ${WANT_LINKER_VERSION} && \
301 ${X_LINKER_FREEBSD_VERSION} == ${WANT_LINKER_FREEBSD_VERSION}
302 # Everything matches, disable the bootstrap linker.
304 USING_SYSTEM_LINKER= yes
305 .endif # ${WANT_LINKER_TYPE} == ${LINKER_TYPE}
307 # WITH_SYSTEM_COMPILER / WITH_SYSTEM_LINKER - Handle defaults and debug.
308 USING_SYSTEM_COMPILER?= no
309 USING_SYSTEM_LINKER?= no
311 TEST_SYSTEM_COMPILER_VARS= \
312 USING_SYSTEM_COMPILER MK_SYSTEM_COMPILER \
313 MK_CROSS_COMPILER MK_CLANG_BOOTSTRAP \
314 WANT_COMPILER_TYPE WANT_COMPILER_VERSION WANT_COMPILER_VERSION_FILE \
315 WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \
316 CC COMPILER_TYPE COMPILER_FEATURES COMPILER_VERSION \
317 COMPILER_FREEBSD_VERSION \
318 XCC X_COMPILER_TYPE X_COMPILER_FEATURES X_COMPILER_VERSION \
319 X_COMPILER_FREEBSD_VERSION
320 TEST_SYSTEM_LINKER_VARS= \
321 USING_SYSTEM_LINKER MK_SYSTEM_LINKER \
323 WANT_LINKER_TYPE WANT_LINKER_VERSION WANT_LINKER_VERSION_FILE \
324 WANT_LINKER_FREEBSD_VERSION WANT_LINKER_FREEBSD_VERSION_FILE \
325 LD LINKER_TYPE LINKER_FEATURES LINKER_VERSION \
326 LINKER_FREEBSD_VERSION \
327 XLD X_LINKER_TYPE X_LINKER_FEATURES X_LINKER_VERSION \
328 X_LINKER_FREEBSD_VERSION
330 .for _t in compiler linker
331 test-system-${_t}: .PHONY
332 .for v in ${TEST_SYSTEM_${_t:tu}_VARS}
333 ${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}"
336 .if (make(buildworld) || make(buildkernel) || make(kernel-toolchain) || \
337 make(toolchain) || make(_cross-tools))
338 .if ${USING_SYSTEM_COMPILER} == "yes"
339 .info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler.
340 .elif ${MK_CLANG_BOOTSTRAP} == "yes"
341 .info SYSTEM_COMPILER: libclang will be built for bootstrapping a cross-compiler.
343 .if ${USING_SYSTEM_LINKER} == "yes"
344 .info SYSTEM_LINKER: Determined that LD=${LD} matches the source tree. Not bootstrapping a cross-linker.
345 .elif ${MK_LLD_BOOTSTRAP} == "yes"
346 .info SYSTEM_LINKER: libclang will be built for bootstrapping a cross-linker.
350 # End WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD
352 # Store some compiler metadata for use in installworld where we don't
353 # want to invoke CC at all.
354 _TOOLCHAIN_METADATA_VARS= COMPILER_VERSION \
357 COMPILER_FREEBSD_VERSION \
358 COMPILER_RESOURCE_DIR \
362 LINKER_FREEBSD_VERSION
363 toolchain-metadata.mk: .PHONY .META
365 @echo ".info Using cached toolchain metadata from build at $$(hostname) on $$(date)" \
367 @echo "_LOADED_TOOLCHAIN_METADATA=t" >> ${.TARGET}
368 .for v in ${_TOOLCHAIN_METADATA_VARS}
369 @echo "${v}=${${v}}" >> ${.TARGET}
370 @echo "X_${v}=${X_${v}}" >> ${.TARGET}
372 @echo ".export ${_TOOLCHAIN_METADATA_VARS}" >> ${.TARGET}
373 @echo ".export ${_TOOLCHAIN_METADATA_VARS:C,^,X_,}" >> ${.TARGET}
376 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
377 # keep the users system reasonably usable. For static->dynamic root upgrades,
378 # we don't want to install a dynamic binary without rtld and the needed
379 # libraries. More commonly, for dynamic root, we don't want to install a
380 # binary that requires a newer library version that hasn't been installed yet.
381 # This ordering is not a guarantee though. The only guarantee of a working
382 # system here would require fine-grained ordering of all components based
383 # on their dependencies.
384 .if !empty(SUBDIR_OVERRIDE)
385 SUBDIR= ${SUBDIR_OVERRIDE}
388 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
389 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
390 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
391 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
392 _REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
394 .for _DIR in ${LOCAL_LIB_DIRS}
395 .if ${_DIR} == ".WAIT" || (empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
399 .if !defined(NO_ROOT) && (make(installworld) || make(install))
400 # Ensure libraries are installed before progressing.
404 .if ${MK_CDDL} != "no"
408 .if ${MK_KERBEROS} != "no"
411 .if ${MK_RESCUE} != "no"
415 .if ${MK_CRYPT} != "no"
418 .if !defined(NO_SHARE)
421 .if ${MK_BOOT} != "no"
424 SUBDIR+=sys usr.bin usr.sbin
425 .if ${MK_TESTS} != "no"
429 # Local directories are built in parallel with the base system directories.
430 # Users may insert a .WAIT directive at the beginning or elsewhere within
431 # the LOCAL_DIRS and LOCAL_LIB_DIRS lists as needed.
432 .for _DIR in ${LOCAL_DIRS}
433 .if ${_DIR} == ".WAIT" || exists(${.CURDIR}/${_DIR}/Makefile)
438 # We must do etc/ last as it hooks into building the man whatis file
439 # by calling 'makedb' in share/man. This is only relevant for
440 # install/distribute so they build the whatis file after every manpage is
442 .if make(installworld) || make(install)
447 .endif # !empty(SUBDIR_OVERRIDE)
450 .warning The src.conf WITHOUT_CLEAN option can now be used instead of NOCLEAN.
453 .if defined(NO_CLEAN)
454 .info The src.conf WITHOUT_CLEAN option can now be used instead of NO_CLEAN.
457 .if defined(NO_CLEANDIR)
458 CLEANDIR= clean cleandepend
463 .if defined(WORLDFAST)
468 .if ${MK_META_MODE} == "yes"
469 # If filemon is used then we can rely on the build being incremental-safe.
470 # The .meta files will also track the build command and rebuild should
472 .if empty(.MAKE.MODE:Mnofilemon)
476 .if defined(NO_OBJWALK) || ${MK_AUTO_OBJ} == "yes"
480 .if !defined(NO_OBJWALK)
485 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
487 .if empty(SHELL:M*csh*)
488 BUILDENV_SHELL?=${SHELL}
490 BUILDENV_SHELL?=/bin/sh
493 .if !defined(_MKSHOWCONFIG)
494 .if !defined(SVN_CMD) || empty(SVN_CMD)
495 . for _P in /usr/bin /usr/local/bin
496 . for _S in svn svnlite
497 . if exists(${_P}/${_S})
505 .if !defined(VCS_REVISION) || empty(VCS_REVISION)
506 .if !defined(SVNVERSION_CMD) || empty(SVNVERSION_CMD)
507 . for _D in ${PATH:S,:, ,g}
508 . if exists(${_D}/svnversion)
509 SVNVERSION_CMD?=${_D}/svnversion
511 . if exists(${_D}/svnliteversion)
512 SVNVERSION_CMD?=${_D}/svnliteversion
516 _VCS_REVISION?= $$(eval ${SVNVERSION_CMD} ${SRCDIR})
517 . if !empty(_VCS_REVISION)
518 VCS_REVISION= $$(echo r${_VCS_REVISION})
523 .if !defined(GIT_CMD) || empty(GIT_CMD)
524 . for _P in /usr/bin /usr/local/bin
525 . if exists(${_P}/git)
532 .if !defined(OSRELDATE)
533 .if exists(/usr/include/osreldate.h)
534 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
535 /usr/include/osreldate.h
542 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
543 .if !defined(_REVISION)
544 _REVISION!= ${MAKE} -C ${SRCDIR}/release MK_AUTO_OBJ=no -V REVISION
547 .if !defined(_BRANCH)
548 _BRANCH!= ${MAKE} -C ${SRCDIR}/release MK_AUTO_OBJ=no -V BRANCH
551 .if !defined(SRCRELDATE)
552 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
553 ${SRCDIR}/sys/sys/param.h
556 .if !defined(VERSION)
557 VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
561 .if !defined(PKG_VERSION)
562 .if ${_BRANCH:MSTABLE*} || ${_BRANCH:MCURRENT*}
563 TIMENOW= %Y%m%d%H%M%S
564 EXTRA_REVISION= .s${TIMENOW:gmtime}
565 .elif ${_BRANCH:MALPHA*}
566 EXTRA_REVISION= _${_BRANCH:C/-ALPHA/.a/}
567 .elif ${_BRANCH:MBETA*}
568 EXTRA_REVISION= _${_BRANCH:C/-BETA/.b/}
569 .elif ${_BRANCH:MRC*}
570 EXTRA_REVISION= _${_BRANCH:C/-RC/.r/}
571 .elif ${_BRANCH:MPRERELEASE*}
572 EXTRA_REVISION= _${_BRANCH:C/-PRERELEASE/.p/}
573 .elif ${_BRANCH:M*-p*}
574 EXTRA_REVISION= _${_BRANCH:C/.*-p([0-9]+$)/\1/}
576 PKG_VERSION:= ${_REVISION}${EXTRA_REVISION}
578 .endif # !defined(PKG_VERSION)
580 .if !defined(PKG_TIMESTAMP)
582 SOURCE_DATE_EPOCH= ${TIMEEPOCHNOW:gmtime}
584 SOURCE_DATE_EPOCH= ${PKG_TIMESTAMP}
587 PKG_NAME_PREFIX?= FreeBSD
588 PKG_MAINTAINER?= re@FreeBSD.org
589 PKG_WWW?= https://www.FreeBSD.org
590 .export PKG_NAME_PREFIX
591 .export PKG_MAINTAINER
594 .if !defined(_MKSHOWCONFIG)
595 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} -f /dev/null \
596 -m ${.CURDIR}/share/mk MK_AUTO_OBJ=no -V CPUTYPE
597 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
598 .error CPUTYPE global should be set with ?=.
602 BUILD_ARCH!= uname -p
603 # On some Linux systems uname -p returns "unknown" so skip this check there.
604 # This check only exists to tell people to use TARGET_ARCH instead of
605 # MACHINE_ARCH so skipping it when crossbuilding on non-FreeBSD should be fine.
606 .if ${MACHINE_ARCH} != ${BUILD_ARCH} && ${.MAKE.OS} == "FreeBSD"
607 .error To cross-build, set TARGET_ARCH.
610 WORLDTMP?= ${OBJTOP}/tmp
611 BPATH= ${CCACHE_WRAPPER_PATH_PFX}${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin:${WORLDTMP}/legacy/usr/libexec
612 XPATH= ${WORLDTMP}/bin:${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
614 # When building we want to find the cross tools before the host tools in ${BPATH}.
615 # We also need to add UNIVERSE_TOOLCHAIN_PATH so that we can find the shared
616 # toolchain files (clang, lld, etc.) during make universe/tinderbox
617 STRICTTMPPATH= ${XPATH}:${BPATH}:${UNIVERSE_TOOLCHAIN_PATH}
618 # We should not be using tools from /usr/bin accidentally since this could cause
619 # the build to break on other systems that don't have that tool. For now we
620 # still allow using the old behaviour (inheriting $PATH) if
621 # BUILD_WITH_STRICT_TMPPATH is set to 0 but this will eventually be removed.
623 # Currently strict $PATH can cause build failures and does not work yet with
624 # USING_SYSTEM_LINKER/USING_SYSTEM_COMPILER. Once these issues have been
625 # resolved it will be turned on by default.
626 BUILD_WITH_STRICT_TMPPATH?=0
627 .if defined(CROSSBUILD_HOST)
628 # When building on non-FreeBSD we can't rely on the tools in /usr/bin being compatible
629 # with what FreeBSD expects. Therefore we only use tools from STRICTTMPPATH
630 # during the world build stage. We build most tools during the bootstrap-tools
631 # phase but symlink host tools that are known to work instead of building them
632 BUILD_WITH_STRICT_TMPPATH:=1
634 .if ${BUILD_WITH_STRICT_TMPPATH} != 0
635 TMPPATH= ${STRICTTMPPATH}
637 TMPPATH= ${STRICTTMPPATH}:${PATH}
641 # Avoid running mktemp(1) unless actually needed.
642 # It may not be functional, e.g., due to new ABI
643 # when in the middle of installing over this system.
645 .if make(distributeworld) || make(installworld) || make(stageworld)
646 .if ${BUILD_WITH_STRICT_TMPPATH} != 0
647 MKTEMP=${WORLDTMP}/legacy/usr/bin/mktemp
648 .if !exists(${MKTEMP})
649 .error "mktemp binary doesn't exist in expected location: ${MKTEMP}"
654 INSTALLTMP!= ${MKTEMP} -d -u -t install
657 .if make(stagekernel) || make(distributekernel)
663 # Building a world goes through the following stages
665 # 1. legacy stage [BMAKE]
666 # This stage is responsible for creating compatibility
667 # shims that are needed by the bootstrap-tools,
668 # build-tools and cross-tools stages. These are generally
669 # APIs that tools from one of those three stages need to
670 # build that aren't present on the host.
671 # 1. bootstrap-tools stage [BMAKE]
672 # This stage is responsible for creating programs that
673 # are needed for backward compatibility reasons. They
674 # are not built as cross-tools.
675 # 2. build-tools stage [TMAKE]
676 # This stage is responsible for creating the object
677 # tree and building any tools that are needed during
678 # the build process. Some programs are listed during
679 # this phase because they build binaries to generate
680 # files needed to build these programs. This stage also
681 # builds the 'build-tools' target rather than 'all'.
682 # 3. cross-tools stage [XMAKE]
683 # This stage is responsible for creating any tools that
684 # are needed for building the system. A cross-compiler is one
685 # of them. This differs from build tools in two ways:
686 # 1. the 'all' target is built rather than 'build-tools'
687 # 2. these tools are installed into TMPPATH for stage 4.
688 # 4. world stage [WMAKE]
689 # This stage actually builds the world.
690 # 5. install stage (optional) [IMAKE]
691 # This stage installs a previously built world.
696 MINIMUM_SUPPORTED_OSREL?= 1002501
697 MINIMUM_SUPPORTED_REL?= 10.3
699 # Common environment for world related stages
701 MACHINE_ARCH=${TARGET_ARCH} \
703 CPUTYPE=${TARGET_CPUTYPE}
704 .if ${MK_META_MODE} != "no"
705 # Don't rebuild build-tools targets during normal build.
706 CROSSENV+= BUILD_TOOLS_META=.NOMETA
708 .if defined(TARGET_CFLAGS)
709 CROSSENV+= ${TARGET_CFLAGS}
711 .if (${TARGET} != ${MACHINE} && !defined(WITH_LOCAL_MODULES)) || \
712 defined(WITHOUT_LOCAL_MODULES)
713 CROSSENV+= LOCAL_MODULES=
716 BOOTSTRAPPING_OSRELDATE?=${OSRELDATE}
718 # bootstrap-tools stage
719 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
720 TOOLS_PREFIX=${TOOLS_PREFIX_UNDEF:U${WORLDTMP}} \
721 PATH=${BPATH}:${PATH} \
722 WORLDTMP=${WORLDTMP} \
723 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
724 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
726 OBJTOP='${WORLDTMP}/obj-tools' \
727 OBJROOT='$${OBJTOP}/' \
729 BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
730 BWPHASE=${.TARGET:C,^_,,} \
732 MK_HTML=no NO_LINT=yes MK_MAN=no MK_MAN_UTILS=yes \
733 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
734 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
735 MK_CLANG_EXTRAS=no MK_CLANG_FORMAT=no MK_CLANG_FULL=no \
736 MK_LLDB=no MK_RETPOLINE=no MK_TESTS=no \
740 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
742 .if empty(.MAKEOVERRIDES:MMK_LLVM_TARGET_ALL)
743 BMAKE+= MK_LLVM_TARGET_ALL=no
748 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
749 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
751 BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
752 BWPHASE=${.TARGET:C,^_,,} \
755 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
756 MK_CLANG_EXTRAS=no MK_CLANG_FORMAT=no MK_CLANG_FULL=no \
757 MK_LLDB=no MK_RETPOLINE=no MK_TESTS=no
760 # TOOLS_PREFIX set in BMAKE
762 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
763 MK_CLANG_IS_CC=${MK_CLANG_BOOTSTRAP} \
764 MK_GDB=no MK_TESTS=no
767 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
768 PATH=${BPATH}:${PATH} \
769 WORLDTMP=${WORLDTMP} \
770 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
773 TOOLS_PREFIX=${TOOLS_PREFIX_UNDEF:U${WORLDTMP}} \
774 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
776 OBJTOP='${WORLDTMP}/obj-kernel-tools' \
777 OBJROOT='$${OBJTOP}/' \
779 BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
781 MK_HTML=no -DNO_LINT MK_MAN=no \
782 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
783 -DNO_CPU_CFLAGS MK_RETPOLINE=no MK_WARNS=no MK_CTF=no
786 WMAKEENV= ${CROSSENV} \
787 INSTALL="${INSTALL_CMD} -U" \
792 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
794 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
797 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
798 CPP="${XCPP} ${XCFLAGS}" \
799 AS="${XAS}" AR="${XAR}" LD="${XLD}" LLVM_LINK="${XLLVM_LINK}" \
800 NM=${XNM} OBJCOPY="${XOBJCOPY}" \
801 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
802 SIZE="${XSIZE}" STRIPBIN="${XSTRIPBIN}"
804 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
805 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
806 # directory, but the compiler will look in the right place for its
807 # tools so we don't need to tell it where to look.
808 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
812 # The internal bootstrap compiler has a default sysroot set by TOOLS_PREFIX
813 # and target set by TARGET/TARGET_ARCH. However, there are several needs to
814 # always pass an explicit --sysroot and -target.
815 # - External compiler needs sysroot and target flags.
816 # - External ld needs sysroot.
817 # - To be clear about the use of a sysroot when using the internal compiler.
818 # - Easier debugging.
819 # - Allowing WITH_SYSTEM_COMPILER+WITH_META_MODE to work together due to
820 # the flip-flopping build command when sometimes using external and
821 # sometimes using internal.
822 # - Allow using lld which has no support for default paths.
823 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
824 BFLAGS+= -B${WORLDTMP}/usr/bin
826 .if ${WANT_COMPILER_TYPE} == gcc || \
827 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
828 .elif ${WANT_COMPILER_TYPE} == clang || \
829 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang)
830 XCFLAGS+= -target ${TARGET_TRIPLE}
832 XCFLAGS+= --sysroot=${WORLDTMP}
838 .if ${MK_LIB32} == "yes"
840 .include "Makefile.libcompat"
841 .elif ${MK_LIBSOFT} == "yes"
843 .include "Makefile.libcompat"
846 # META_MODE normally ignores host file changes since every build updates
847 # timestamps (see NO_META_IGNORE_HOST in sys.mk). There are known times
848 # when the ABI breaks though that we want to force rebuilding WORLDTMP
849 # to get updated host tools.
850 .if ${MK_META_MODE} == "yes" && ${MK_CLEAN} == "no" && \
851 !defined(NO_META_IGNORE_HOST) && !defined(NO_META_IGNORE_HOST_HEADERS) && \
852 !defined(_MKSHOWCONFIG)
853 # r318736 - ino64 major ABI breakage
854 META_MODE_BAD_ABI_VERS+= 1200031
856 .if !defined(OBJDIR_HOST_OSRELDATE)
857 .if exists(${OBJTOP}/host-osreldate.h)
858 OBJDIR_HOST_OSRELDATE!= \
859 awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
860 ${OBJTOP}/host-osreldate.h
861 .elif exists(${WORLDTMP}/usr/include/osreldate.h)
862 OBJDIR_HOST_OSRELDATE= 0
864 .export OBJDIR_HOST_OSRELDATE
867 # Note that this logic is the opposite of normal BOOTSTRAP handling. We want
868 # to compare the WORLDTMP's OSRELDATE to the host's OSRELDATE. If the WORLDTMP
869 # is older than the ABI-breakage OSRELDATE of the HOST then we rebuild.
870 .if defined(OBJDIR_HOST_OSRELDATE)
871 .for _ver in ${META_MODE_BAD_ABI_VERS}
872 .if ${OSRELDATE} >= ${_ver} && ${OBJDIR_HOST_OSRELDATE} < ${_ver}
873 _meta_mode_need_rebuild= ${_ver}
876 .if defined(_meta_mode_need_rebuild)
877 .info META_MODE: Rebuilding host tools due to ABI breakage in __FreeBSD_version ${_meta_mode_need_rebuild}.
878 NO_META_IGNORE_HOST_HEADERS= 1
879 .export NO_META_IGNORE_HOST_HEADERS
880 .endif # defined(_meta_mode_need_rebuild)
881 .endif # defined(OBJDIR_HOST_OSRELDATE)
882 .endif # ${MK_META_MODE} == "yes" && ${MK_CLEAN} == "no" ...
883 # This is only used for META_MODE+filemon to track what the oldest
884 # __FreeBSD_version is in WORLDTMP. This purposely does NOT have
885 # a make dependency on /usr/include/osreldate.h as the file should
886 # only be copied when it is missing or meta mode determines it has changed.
887 # Since host files are normally ignored without NO_META_IGNORE_HOST
888 # the file will never be updated unless that flag is specified. This
889 # allows tracking the oldest osreldate to force rebuilds via
890 # META_MODE_BADABI_REVS above.
891 host-osreldate.h: # DO NOT ADD /usr/include/osreldate.h here
892 .if !defined(CROSSBUILD_HOST)
893 @cp -f /usr/include/osreldate.h ${.TARGET}
895 @echo "#ifndef __FreeBSD_version" > ${.TARGET}
896 @echo "#define __FreeBSD_version ${OSRELDATE}" >> ${.TARGET}
897 @echo "#endif" >> ${.TARGET}
900 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
901 BWPHASE=${.TARGET:C,^_,,} \
904 IMAKEENV= ${CROSSENV}
905 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
906 ${IMAKE_INSTALL} ${IMAKE_MTREE}
907 .if empty(.MAKEFLAGS:M-n)
908 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
909 LD_LIBRARY_PATH=${INSTALLTMP} \
910 PATH_LOCALE=${INSTALLTMP}/locale
911 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
913 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
916 # When generating install media, do not allow user and group information from
917 # the build host to affect the contents of the distribution.
918 .if make(distributeworld) || make(distrib-dirs) || make(distribution) || \
923 .if defined(DB_FROM_SRC)
924 INSTALLFLAGS+= -N ${.CURDIR}/etc
925 MTREEFLAGS+= -N ${.CURDIR}/etc
927 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
928 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
930 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
931 METALOG:= ${METALOG:C,//+,/,g}
932 IMAKE+= -DNO_ROOT METALOG=${METALOG}
933 METALOG_INSTALLFLAGS= -U -M ${METALOG} -D ${INSTALL_DDIR}
934 INSTALLFLAGS+= ${METALOG_INSTALLFLAGS}
935 CERTCTLFLAGS= ${METALOG_INSTALLFLAGS}
938 .if defined(BUILD_PKGS)
939 INSTALLFLAGS+= -h sha256
941 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
942 IMAKE_INSTALL= INSTALL="${INSTALL_CMD} ${INSTALLFLAGS}"
943 IMAKE_MTREE= MTREE_CMD="${MTREE_CMD} ${MTREEFLAGS}"
945 .if make(distributeworld)
946 CERTCTLDESTDIR= ${DESTDIR}/${DISTDIR}/base
948 CERTCTLDESTDIR= ${DESTDIR}
951 DESTDIR_MTREEFLAGS= -deU
952 # When creating worldtmp we don't need to set the directories as owned by root
954 WORLDTMP_MTREEFLAGS= -deUW
956 # When building with -DNO_ROOT we shouldn't be changing the directories
957 # that are created by mtree to be owned by root/wheel.
958 DESTDIR_MTREEFLAGS+= -W
960 DISTR_MTREE= ${MTREE_CMD}
961 .if ${BUILD_WITH_STRICT_TMPPATH} != 0
962 DISTR_MTREE= ${WORLDTMP}/legacy/usr/sbin/mtree
964 WORLDTMP_MTREE= ${DISTR_MTREE} ${WORLDTMP_MTREEFLAGS}
965 DESTDIR_MTREE= ${DISTR_MTREE} ${DESTDIR_MTREEFLAGS}
968 KMAKEENV= ${WMAKEENV:NSYSROOT=*}
969 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
974 # Attempt to rebuild the entire system, with reasonable chance of
975 # success, regardless of how old your existing system is.
977 _sanity_check: .PHONY .MAKE
978 .if ${.CURDIR:C/[^,]//g} != ""
979 # The m4 build of sendmail files doesn't like it if ',' is used
980 # anywhere in the path of it's files.
982 @echo "*** Error: path to source tree contains a comma ','"
985 .elif ${.CURDIR:M*\:*} != ""
986 # Using ':' leaks into PATH and breaks finding cross-tools.
988 @echo "*** Error: path to source tree contains a colon ':'"
993 # Our current approach to dependency tracking cannot cope with certain source
994 # tree changes, particularly with respect to removing source files and
995 # replacing generated files. Handle these cases here in an ad-hoc fashion.
996 _cleanobj_fast_depend_hack: .PHONY
997 @echo ">>> Deleting stale dependencies...";
998 sh ${.CURDIR}/tools/build/depend-cleanup.sh ${OBJTOP}
1002 @echo "--------------------------------------------------------------"
1003 @echo ">>> Rebuilding the temporary build tree"
1004 @echo "--------------------------------------------------------------"
1005 .if ${MK_CLEAN} == "yes"
1008 # Note: for delete-old we need to set $PATH to also include the host $PATH
1009 # since otherwise a partial build with missing symlinks in ${WORLDTMP}/legacy/
1010 # will fail to run due to missing binaries. $WMAKE sets PATH to only ${TMPPATH}
1011 # so we remove that assingnment from $WMAKE and prepend the new $PATH
1012 ${_+_}@if [ -e "${WORLDTMP}" ]; then \
1013 echo ">>> Deleting stale files in build tree..."; \
1014 cd ${.CURDIR}; env PATH=${TMPPATH}:${PATH} ${WMAKE:NPATH=*} \
1015 _NO_INCLUDE_COMPILERMK=t -DBATCH_DELETE_OLD_FILES delete-old \
1016 delete-old-libs >/dev/null; \
1018 rm -rf ${WORLDTMP}/legacy/usr/include
1019 .if ${USING_SYSTEM_COMPILER} == "yes"
1021 if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \
1022 inum=$$(stat -f %i ${WORLDTMP}/usr/bin/${cc}); \
1023 find ${WORLDTMP}/usr/bin -inum $${inum} -delete; \
1026 .endif # ${USING_SYSTEM_COMPILER} == "yes"
1027 .if ${USING_SYSTEM_LINKER} == "yes"
1028 @rm -f ${WORLDTMP}/usr/bin/ld ${WORLDTMP}/usr/bin/ld.lld
1029 .endif # ${USING_SYSTEM_LINKER} == "yes"
1030 .endif # ${MK_CLEAN} == "yes"
1031 @mkdir -p ${WORLDTMP}
1032 @touch ${WORLDTMP}/${.TARGET}
1033 # We can't use mtree to create the worldtmp directories since it may not be
1034 # available on the target system (this happens e.g. when building on non-FreeBSD)
1035 cd ${.CURDIR}/tools/build; \
1036 ${MAKE} DIRPRFX=tools/build/ DESTDIR=${WORLDTMP}/legacy installdirs
1037 # In order to build without inheriting $PATH we need to add symlinks to the host
1038 # tools in $WORLDTMP for the tools that we don't build during bootstrap-tools
1039 cd ${.CURDIR}/tools/build; \
1040 ${MAKE} DIRPRFX=tools/build/ DESTDIR=${WORLDTMP}/legacy host-symlinks
1044 @echo "--------------------------------------------------------------"
1045 @echo ">>> stage 1.1: legacy release compatibility shims"
1046 @echo "--------------------------------------------------------------"
1047 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
1050 @echo "--------------------------------------------------------------"
1051 @echo ">>> stage 1.2: bootstrap tools"
1052 @echo "--------------------------------------------------------------"
1053 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
1054 mkdir -p ${WORLDTMP}/usr ${WORLDTMP}/lib/casper ${WORLDTMP}/lib/geom \
1056 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1057 -p ${WORLDTMP}/usr >/dev/null
1058 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1059 -p ${WORLDTMP}/usr/include >/dev/null
1060 ln -sf ${.CURDIR}/sys ${WORLDTMP}
1061 .if ${MK_DEBUG_FILES} != "no"
1062 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1063 -p ${WORLDTMP}/usr/lib >/dev/null
1065 .for _mtree in ${LOCAL_MTREE}
1066 ${WORLDTMP_MTREE} -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
1069 .if ${MK_CLEAN} == "yes"
1071 @echo "--------------------------------------------------------------"
1072 @echo ">>> stage 2.1: cleaning up the object tree"
1073 @echo "--------------------------------------------------------------"
1074 # Avoid including bsd.compiler.mk in clean and obj with _NO_INCLUDE_COMPILERMK
1075 # since the restricted $PATH might not contain a valid cc binary
1076 ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t ${CLEANDIR}
1077 .if defined(_LIBCOMPAT)
1078 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} _NO_INCLUDE_COMPILERMK=t -f Makefile.inc1 ${CLEANDIR}
1081 ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t _cleanobj_fast_depend_hack
1082 .endif # ${MK_CLEAN} == "yes"
1085 @echo "--------------------------------------------------------------"
1086 @echo ">>> stage 2.2: rebuilding the object tree"
1087 @echo "--------------------------------------------------------------"
1088 ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t obj
1091 @echo "--------------------------------------------------------------"
1092 @echo ">>> stage 2.3: build tools"
1093 @echo "--------------------------------------------------------------"
1094 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
1097 @echo "--------------------------------------------------------------"
1098 @echo ">>> stage 3: cross tools"
1099 @echo "--------------------------------------------------------------"
1100 @rm -f ${OBJTOP}/toolchain-metadata.mk
1101 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
1102 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
1105 @echo "--------------------------------------------------------------"
1106 @echo ">>> stage 3.1: recording build metadata"
1107 @echo "--------------------------------------------------------------"
1108 ${_+_}cd ${.CURDIR}; ${WMAKE} toolchain-metadata.mk
1109 ${_+_}cd ${.CURDIR}; ${WMAKE} host-osreldate.h
1112 @echo "--------------------------------------------------------------"
1113 @echo ">>> stage 4.1: building includes"
1114 @echo "--------------------------------------------------------------"
1115 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
1116 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
1117 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
1118 MK_INCLUDES=yes includes
1119 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
1120 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
1124 @echo "--------------------------------------------------------------"
1125 @echo ">>> stage 4.2: building libraries"
1126 @echo "--------------------------------------------------------------"
1127 ${_+_}cd ${.CURDIR}; \
1128 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
1129 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS_SUPPORT} \
1133 @echo "--------------------------------------------------------------"
1134 @echo ">>> stage 4.4: building everything"
1135 @echo "--------------------------------------------------------------"
1136 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
1139 .if !defined(WORLDFAST)
1140 WMAKE_TGTS+= _sanity_check _worldtmp _legacy
1141 .if empty(SUBDIR_OVERRIDE)
1142 WMAKE_TGTS+= _bootstrap-tools
1144 WMAKE_TGTS+= _cleanobj
1145 .if !defined(NO_OBJWALK)
1148 WMAKE_TGTS+= _build-tools _cross-tools
1149 WMAKE_TGTS+= _build-metadata
1150 WMAKE_TGTS+= _includes
1152 .if !defined(NO_LIBS)
1153 WMAKE_TGTS+= _libraries
1155 .if defined(_LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
1156 WMAKE_TGTS+= build${libcompat}
1158 WMAKE_TGTS+= everything
1160 # record buildworld time in seconds
1161 .if make(buildworld)
1162 _BUILDWORLD_START!= date '+%s'
1163 .export _BUILDWORLD_START
1166 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
1167 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
1169 _ncpu_cmd=sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo unknown
1171 buildworld_prologue: .PHONY
1172 @echo "--------------------------------------------------------------"
1173 @echo ">>> World build started on `LC_ALL=C date`"
1174 @echo "--------------------------------------------------------------"
1176 buildworld_epilogue: .PHONY
1178 @echo "--------------------------------------------------------------"
1179 @echo ">>> World build completed on `LC_ALL=C date`"
1180 @seconds=$$(($$(date '+%s') - ${_BUILDWORLD_START})); \
1181 echo -n ">>> World built in $$seconds seconds, "; \
1182 echo "ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}"
1183 @echo "--------------------------------------------------------------"
1186 # We need to have this as a target because the indirection between Makefile
1187 # and Makefile.inc1 causes the correct PATH to be used, rather than a
1188 # modification of the current environment's PATH. In addition, we need
1189 # to quote multiword values.
1191 buildenvvars: .PHONY
1192 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
1194 .if ${.TARGETS:Mbuildenv}
1195 .if ${.MAKEFLAGS:M-j}
1196 .error The buildenv target is incompatible with -j
1199 BUILDENV_DIR?= ${.CURDIR}
1201 # Note: make will report any errors the shell reports. This can
1202 # be odd if the last command in an interactive shell generates an
1203 # error or is terminated by SIGINT. These reported errors look bad,
1204 # but are harmless. Allowing them also allows BUIDLENV_SHELL to
1205 # be a complex command whose status will be returned to the caller.
1206 # Some scripts in tools rely on this behavior to report build errors.
1209 @echo Entering world for ${TARGET_ARCH}:${TARGET}
1210 .if ${BUILDENV_SHELL:M*zsh*}
1211 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
1213 @cd ${BUILDENV_DIR} && env ${WMAKEENV} \
1214 INSTALL="${INSTALL_CMD} ${INSTALLFLAGS}" \
1215 MTREE_CMD="${MTREE_CMD} ${MTREEFLAGS}" BUILDENV=1 ${BUILDENV_SHELL}
1217 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
1218 toolchain: ${TOOLCHAIN_TGTS} .PHONY
1219 KERNEL_TOOLCHAIN_TGTS= ${TOOLCHAIN_TGTS:N_obj:N_cleanobj:N_includes:N_libraries}
1220 .if make(kernel-toolchain)
1221 .ORDER: ${KERNEL_TOOLCHAIN_TGTS}
1223 kernel-toolchain: ${KERNEL_TOOLCHAIN_TGTS} .PHONY
1228 # Checks to be sure system is ready for installworld/installkernel.
1230 installcheck: _installcheck_world _installcheck_kernel .PHONY
1231 _installcheck_world: .PHONY
1232 @echo "--------------------------------------------------------------"
1233 @echo ">>> Install check world"
1234 @echo "--------------------------------------------------------------"
1235 _installcheck_kernel: .PHONY
1236 @echo "--------------------------------------------------------------"
1237 @echo ">>> Install check kernel"
1238 @echo "--------------------------------------------------------------"
1241 # Require DESTDIR to be set if installing for a different architecture or
1242 # using the user/group database in the source tree.
1244 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
1245 defined(DB_FROM_SRC)
1246 .if !make(distributeworld)
1247 _installcheck_world: __installcheck_DESTDIR
1248 _installcheck_kernel: __installcheck_DESTDIR
1249 __installcheck_DESTDIR: .PHONY
1250 .if !defined(DESTDIR) || empty(DESTDIR)
1251 @echo "ERROR: Please set DESTDIR!"; \
1257 .if !defined(DB_FROM_SRC)
1259 # Check for missing UIDs/GIDs.
1261 CHECK_UIDS= auditdistd
1266 CHECK_GIDS+= proxy authpf
1269 CHECK_UIDS+= unbound
1270 CHECK_GIDS+= unbound
1271 _installcheck_world: __installcheck_UGID
1272 __installcheck_UGID: .PHONY
1273 .for uid in ${CHECK_UIDS}
1274 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
1275 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
1279 .for gid in ${CHECK_GIDS}
1280 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
1281 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
1287 # If installing over the running system (DESTDIR is / or unset) and the install
1288 # includes rescue, try running rescue from the objdir as a sanity check. If
1289 # rescue is not functional (e.g., because it depends on a system call not
1290 # supported by the currently running kernel), abort the installation.
1292 .if !make(distributeworld) && ${MK_RESCUE} != "no" && \
1293 (empty(DESTDIR) || ${DESTDIR} == "/") && empty(BYPASS_INSTALLCHECK_SH)
1294 _installcheck_world: __installcheck_sh_check
1295 __installcheck_sh_check: .PHONY
1296 @if [ "`${OBJTOP}/rescue/rescue/rescue sh -c 'echo OK'`" != \
1298 echo "rescue/sh check failed, installation aborted" >&2; \
1304 # Required install tools to be saved in a scratch dir for safety.
1306 .if ${MK_ZONEINFO} != "no"
1307 _zoneinfo= zic tzsetup
1310 .if !defined(CROSSBUILD_HOST)
1314 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
1315 date echo egrep find grep id install ${_install-info} \
1316 ln make mkdir mtree mv pwd_mkdb \
1317 rm sed services_mkdb sh sort strip ${_sysctl} test true uname wc \
1318 ${_zoneinfo} ${LOCAL_ITOOLS}
1320 # Needed for share/man
1321 .if ${MK_MAN_UTILS} != "no"
1328 # Distributes everything compiled by a `buildworld'.
1332 # Installs everything compiled by a 'buildworld'.
1335 # Non-base distributions produced by the base system
1336 EXTRA_DISTRIBUTIONS=
1337 .if defined(_LIBCOMPAT)
1338 EXTRA_DISTRIBUTIONS+= lib${libcompat}
1340 .if ${MK_TESTS} != "no"
1341 EXTRA_DISTRIBUTIONS+= tests
1344 DEBUG_DISTRIBUTIONS=
1345 .if ${MK_DEBUG_FILES} != "no"
1346 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,tests,,}
1349 MTREE_MAGIC?= mtree 2.0
1351 distributeworld installworld stageworld: _installcheck_world .PHONY
1352 mkdir -p ${INSTALLTMP}
1353 progs=$$(for prog in ${ITOOLS}; do \
1354 if progpath=`env PATH=${TMPPATH} which $$prog`; then \
1357 echo "Required tool $$prog not found in PATH ($$PATH)." >&2; \
1361 if [ -z "${CROSSBUILD_HOST}" ] ; then \
1362 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
1363 while read line; do \
1365 if [ "$$2 $$3" != "not found" ]; then \
1368 echo "Required library $$1 not found." >&2; \
1373 cp $$libs $$progs ${INSTALLTMP}
1374 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
1375 .if defined(NO_ROOT)
1376 -mkdir -p ${METALOG:H}
1377 echo "#${MTREE_MAGIC}" > ${METALOG}
1379 .if make(distributeworld)
1380 .for dist in ${EXTRA_DISTRIBUTIONS}
1381 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
1382 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1383 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
1384 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1385 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1386 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1387 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
1388 .if ${MK_DEBUG_FILES} != "no"
1389 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1390 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
1392 .if defined(_LIBCOMPAT)
1393 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1394 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1395 .if ${MK_DEBUG_FILES} != "no"
1396 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1397 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
1400 .if ${MK_TESTS} != "no" && ${dist} == "tests"
1401 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
1402 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1403 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
1404 .if ${MK_DEBUG_FILES} != "no"
1405 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1406 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
1409 .if defined(NO_ROOT)
1410 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1411 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1412 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1413 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1414 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1415 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1416 .if defined(_LIBCOMPAT)
1417 ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
1418 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1422 -mkdir ${DESTDIR}/${DISTDIR}/base
1423 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1424 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1425 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1426 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1427 ${INSTALL_SYMLINK} ${INSTALLFLAGS} usr/src/sys ${INSTALL_DDIR}/base/sys
1428 .endif # make(distributeworld)
1429 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1430 ${IMAKEENV} rm -rf ${INSTALLTMP}
1431 .if make(distributeworld)
1432 .for dist in ${EXTRA_DISTRIBUTIONS}
1433 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete
1435 .if defined(NO_ROOT)
1436 .for dist in base ${EXTRA_DISTRIBUTIONS}
1437 @# For each file that exists in this dist, print the corresponding
1438 @# line from the METALOG. This relies on the fact that
1439 @# a line containing only the filename will sort immediately before
1440 @# the relevant mtree line.
1441 cd ${DESTDIR}/${DISTDIR}; \
1442 find ./${dist} | sort -u ${METALOG} - | \
1443 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1444 ${DESTDIR}/${DISTDIR}/${dist}.meta
1446 .for dist in ${DEBUG_DISTRIBUTIONS}
1447 @# For each file that exists in this dist, print the corresponding
1448 @# line from the METALOG. This relies on the fact that
1449 @# a line containing only the filename will sort immediately before
1450 @# the relevant mtree line.
1451 cd ${DESTDIR}/${DISTDIR}; \
1452 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1453 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1454 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1457 .endif # make(distributeworld)
1458 .if !make(packageworld) && ${MK_CAROOT} != "no"
1459 @if which openssl>/dev/null; then \
1460 DESTDIR=${CERTCTLDESTDIR} PATH=${TMPPATH}:${PATH} \
1461 sh ${SRCTOP}/usr.sbin/certctl/certctl.sh ${CERTCTLFLAGS} rehash \
1463 echo "No openssl on the host, not rehashing certificates target -- /etc/ssl may not be populated."; \
1467 packageworld: .PHONY
1468 .for dist in base ${EXTRA_DISTRIBUTIONS}
1469 .if defined(NO_ROOT)
1470 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1471 tar cvf - --exclude usr/lib/debug \
1472 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1473 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1475 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1476 tar cvf - --exclude usr/lib/debug . | \
1477 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1481 .for dist in ${DEBUG_DISTRIBUTIONS}
1482 . if defined(NO_ROOT)
1483 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1484 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1485 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1487 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1488 tar cvLf - usr/lib/debug | \
1489 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1494 ${_+_}cd ${.CURDIR}/tools/build/options; sh makeman > \
1495 ${.CURDIR}/share/man/man5/src.conf.5
1497 # We can't assume here that ${TMPPATH} will include ${PATH} or /usr/libexec
1498 # because we may be building with a STRICTTMPPATH, so we explicitly include
1499 # /usr/libexec here for flua. ${TMPPATH} still usefully includes anything else
1500 # we may need to function.
1501 _sysent_PATH= ${TMPPATH}:/usr/libexec
1502 _sysent_dirs= sys/kern
1503 _sysent_dirs+= sys/compat/freebsd32
1504 _sysent_dirs+= sys/compat/cloudabi32 \
1505 sys/compat/cloudabi64
1506 _sysent_dirs+= sys/amd64/linux \
1513 .for _dir in ${_sysent_dirs}
1514 sysent-${_dir}: .PHONY
1515 @echo "${MAKE} -C ${.CURDIR}/${_dir} sysent"
1516 ${_+_}@env PATH=${_sysent_PATH} ${MAKE} -C ${.CURDIR}/${_dir} sysent
1518 sysent: sysent-${_dir}
1524 # If you have a build server, you can NFS mount the source and obj directories
1525 # and do a 'make reinstall' on the *client* to install new binaries from the
1526 # most recent server build.
1528 restage reinstall: .MAKE .PHONY
1529 @echo "--------------------------------------------------------------"
1530 @echo ">>> Making hierarchy"
1531 @echo "--------------------------------------------------------------"
1532 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1533 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1535 @echo "--------------------------------------------------------------"
1536 @echo ">>> Making distribution"
1537 @echo "--------------------------------------------------------------"
1538 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1539 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
1542 @echo "--------------------------------------------------------------"
1543 @echo ">>> Installing everything started on `LC_ALL=C date`"
1544 @echo "--------------------------------------------------------------"
1545 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1546 .if defined(_LIBCOMPAT)
1547 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1549 @echo "--------------------------------------------------------------"
1550 @echo ">>> Installing everything completed on `LC_ALL=C date`"
1551 @echo "--------------------------------------------------------------"
1553 redistribute: .MAKE .PHONY
1554 @echo "--------------------------------------------------------------"
1555 @echo ">>> Distributing everything"
1556 @echo "--------------------------------------------------------------"
1557 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1558 .if defined(_LIBCOMPAT)
1559 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1560 DISTRIBUTION=lib${libcompat}
1563 distrib-dirs distribution: .MAKE .PHONY
1564 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1565 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1566 .if make(distribution)
1567 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1568 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1569 METALOG=${METALOG} MK_TESTS=no \
1570 MK_TESTS_SUPPORT=${MK_TESTS_SUPPORT} installconfig
1574 # buildkernel and installkernel
1576 # Which kernels to build and/or install is specified by setting
1577 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1578 # Only the existing (depending TARGET) config files are used
1579 # for building kernels and only the first of these is designated
1580 # as the one being installed.
1582 # Note that we have to use TARGET instead of TARGET_ARCH when
1583 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1584 # be set to cross-build, we have to make sure TARGET is set
1587 .if defined(KERNFAST)
1591 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1592 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1593 KERNCONF=${KERNFAST}
1596 .if ${TARGET_ARCH} == "powerpc64"
1597 KERNCONF?= GENERIC64
1598 .elif ${TARGET_ARCH} == "powerpc64le"
1599 KERNCONF?= GENERIC64LE
1600 .elif ${TARGET_ARCH} == "powerpcspe"
1601 KERNCONF?= MPC85XXSPE
1605 INSTKERNNAME?= kernel
1607 KERNSRCDIR?= ${.CURDIR}/sys
1608 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1609 KRNLOBJDIR= ${OBJTOP}${KERNSRCDIR:C,^${.CURDIR},,}
1610 KERNCONFDIR?= ${KRNLCONFDIR}
1614 .if defined(NO_INSTALLKERNEL)
1615 # All of the BUILDKERNELS loops start at index 1.
1616 BUILDKERNELS+= dummy
1618 .for _kernel in ${KERNCONF}
1619 .if !defined(_MKSHOWCONFIG) && exists(${KERNCONFDIR}/${_kernel})
1620 BUILDKERNELS+= ${_kernel}
1621 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1622 INSTALLKERNEL= ${_kernel}
1625 .if make(buildkernel)
1626 .error Missing KERNCONF ${KERNCONFDIR}/${_kernel}
1631 _cleankernobj_fast_depend_hack: .PHONY
1632 # 20191009 r353340 removal of opensolaris_atomic.S (also r353381)
1633 .if ${MACHINE} != i386
1634 .for f in opensolaris_atomic
1635 .for m in opensolaris zfs
1636 @if [ -e "${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o" ] && \
1637 grep -q ${f}.S "${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o"; then \
1638 echo "Removing stale dependencies for opensolaris_atomic"; \
1639 rm -f ${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.*; \
1645 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1647 # record kernel(s) build time in seconds
1648 .if make(buildkernel)
1649 _BUILDKERNEL_START!= date '+%s'
1655 # Builds all kernels defined by BUILDKERNELS.
1657 buildkernel: .MAKE .PHONY
1658 .if empty(BUILDKERNELS:Ndummy)
1659 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1663 .for _kernel in ${BUILDKERNELS:Ndummy}
1664 @echo "--------------------------------------------------------------"
1665 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1666 @echo "--------------------------------------------------------------"
1667 @echo "===> ${_kernel}"
1668 mkdir -p ${KRNLOBJDIR}
1669 .if !defined(NO_KERNELCONFIG)
1671 @echo "--------------------------------------------------------------"
1672 @echo ">>> stage 1: configuring the kernel"
1673 @echo "--------------------------------------------------------------"
1674 cd ${KRNLCONFDIR}; \
1676 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1677 -I '${KERNCONFDIR}' -I '${KRNLCONFDIR}' \
1678 '${KERNCONFDIR}/${_kernel}'
1680 .if ${MK_CLEAN} == "yes" && !defined(NO_KERNELCLEAN)
1682 @echo "--------------------------------------------------------------"
1683 @echo ">>> stage 2.1: cleaning up the object tree"
1684 @echo "--------------------------------------------------------------"
1685 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1687 ${_+_}cd ${.CURDIR}; ${WMAKE} _cleankernobj_fast_depend_hack
1689 .if !defined(NO_KERNELOBJ)
1691 @echo "--------------------------------------------------------------"
1692 @echo ">>> stage 2.2: rebuilding the object tree"
1693 @echo "--------------------------------------------------------------"
1694 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1697 @echo "--------------------------------------------------------------"
1698 @echo ">>> stage 2.3: build tools"
1699 @echo "--------------------------------------------------------------"
1700 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1702 @echo "--------------------------------------------------------------"
1703 @echo ">>> stage 3.1: building everything"
1704 @echo "--------------------------------------------------------------"
1705 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1706 @echo "--------------------------------------------------------------"
1707 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1708 @echo "--------------------------------------------------------------"
1711 @seconds=$$(($$(date '+%s') - ${_BUILDKERNEL_START})); \
1712 echo -n ">>> Kernel(s) ${BUILDKERNELS} built in $$seconds seconds, "; \
1713 echo "ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}"
1714 @echo "--------------------------------------------------------------"
1716 NO_INSTALLEXTRAKERNELS?= yes
1719 # installkernel, etc.
1721 # Install the kernel defined by INSTALLKERNEL
1723 installkernel installkernel.debug \
1724 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1725 .if !defined(NO_INSTALLKERNEL)
1726 .if empty(INSTALLKERNEL)
1727 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1730 @echo "--------------------------------------------------------------"
1731 @echo ">>> Installing kernel ${INSTALLKERNEL} on $$(LC_ALL=C date)"
1732 @echo "--------------------------------------------------------------"
1733 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1734 ${CROSSENV} PATH=${TMPPATH} \
1735 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1736 @echo "--------------------------------------------------------------"
1737 @echo ">>> Installing kernel ${INSTALLKERNEL} completed on $$(LC_ALL=C date)"
1738 @echo "--------------------------------------------------------------"
1740 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1741 .for _kernel in ${BUILDKERNELS:[2..-1]}
1742 @echo "--------------------------------------------------------------"
1743 @echo ">>> Installing kernel ${_kernel} $$(LC_ALL=C date)"
1744 @echo "--------------------------------------------------------------"
1745 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
1746 ${CROSSENV} PATH=${TMPPATH} \
1747 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1748 @echo "--------------------------------------------------------------"
1749 @echo ">>> Installing kernel ${_kernel} completed on $$(LC_ALL=C date)"
1750 @echo "--------------------------------------------------------------"
1754 distributekernel distributekernel.debug: .PHONY
1755 .if !defined(NO_INSTALLKERNEL)
1756 .if empty(INSTALLKERNEL)
1757 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1760 mkdir -p ${DESTDIR}/${DISTDIR}
1761 .if defined(NO_ROOT)
1762 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1764 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1765 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1766 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1767 DESTDIR=${INSTALL_DDIR}/kernel \
1768 ${.TARGET:S/distributekernel/install/}
1769 .if defined(NO_ROOT)
1770 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1771 ${DESTDIR}/${DISTDIR}/kernel.meta
1774 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1775 .for _kernel in ${BUILDKERNELS:[2..-1]}
1776 .if defined(NO_ROOT)
1777 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1779 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
1780 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1781 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1782 KERNEL=${INSTKERNNAME}.${_kernel} \
1783 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1784 ${.TARGET:S/distributekernel/install/}
1785 .if defined(NO_ROOT)
1786 @sed -e "s|^./kernel.${_kernel}|.|" \
1787 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1788 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1793 packagekernel: .PHONY
1794 .if defined(NO_ROOT)
1795 .if !defined(NO_INSTALLKERNEL)
1796 cd ${DESTDIR}/${DISTDIR}/kernel; \
1797 tar cvf - --exclude '*.debug' \
1798 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1799 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1801 .if ${MK_DEBUG_FILES} != "no"
1802 cd ${DESTDIR}/${DISTDIR}/kernel; \
1803 tar cvf - --include '*/*/*.debug' \
1804 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1805 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1807 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1808 .for _kernel in ${BUILDKERNELS:[2..-1]}
1809 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1810 tar cvf - --exclude '*.debug' \
1811 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1812 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1813 .if ${MK_DEBUG_FILES} != "no"
1814 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1815 tar cvf - --include '*/*/*.debug' \
1816 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1817 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1822 .if !defined(NO_INSTALLKERNEL)
1823 cd ${DESTDIR}/${DISTDIR}/kernel; \
1824 tar cvf - --exclude '*.debug' . | \
1825 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1827 .if ${MK_DEBUG_FILES} != "no"
1828 cd ${DESTDIR}/${DISTDIR}/kernel; \
1829 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1830 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1832 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1833 .for _kernel in ${BUILDKERNELS:[2..-1]}
1834 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1835 tar cvf - --exclude '*.debug' . | \
1836 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1837 .if ${MK_DEBUG_FILES} != "no"
1838 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1839 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1840 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1847 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1849 PORTSDIR?= /usr/ports
1850 WSTAGEDIR?= ${OBJTOP}/worldstage
1851 KSTAGEDIR?= ${OBJTOP}/kernelstage
1852 REPODIR?= ${OBJROOT}repo
1854 PKGSIGNKEY?= # empty
1855 PKG_OUTPUT_DIR?= ${PKG_VERSION}
1857 .ORDER: stage-packages create-packages
1858 .ORDER: create-packages create-world-packages
1859 .ORDER: create-packages create-kernel-packages
1860 .ORDER: create-packages sign-packages
1862 _pkgbootstrap: .PHONY
1863 .if make(*package*) && !exists(${LOCALBASE}/sbin/pkg)
1864 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1867 .if make(create-world-packages-jobs) || make(create-kernel-packages*) || make(real-update-packages)
1868 PKG_ABI!=${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI
1871 .if !defined(PKG_VERSION_FROM)
1872 .if defined(PKG_ABI)
1873 PKG_VERSION_FROM!=/usr/bin/readlink ${REPODIR}/${PKG_ABI}/latest
1878 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1880 update-packages: .PHONY
1881 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-update-packages
1884 rm -rf /tmp/ports.${TARGET} || :
1885 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
1886 PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \
1887 WSTAGEDIR=${WSTAGEDIR} \
1888 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1890 real-packages: stage-packages create-packages sign-packages .PHONY
1892 real-update-packages: stage-packages .PHONY
1893 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} create-packages
1894 @echo "==> Checking for new packages (comparing ${PKG_VERSION} to ${PKG_VERSION_FROM})"
1895 @for pkg in ${REPODIR}/${PKG_ABI}/${PKG_VERSION_FROM}/${PKG_NAME_PREFIX}-*; do \
1896 pkgname=$$(pkg query -F $${pkg} '%n' | sed 's/${PKG_NAME_PREFIX}-\(.*\)/\1/') ; \
1897 newpkgname=${PKG_NAME_PREFIX}-$${pkgname}-${PKG_VERSION}.${PKG_FORMAT} ; \
1898 oldsum=$$(pkg query -F $${pkg} '%X') ; \
1899 if [ ! -f ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} ]; then \
1902 newsum=$$(pkg query -F ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} '%X') ; \
1903 if [ "$${oldsum}" == "$${newsum}" ]; then \
1904 echo "==> Keeping old ${PKG_NAME_PREFIX}-$${pkgname}-${PKG_VERSION_FROM}.${PKG_FORMAT}" ; \
1905 rm ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} ; \
1906 cp $${pkg} ${REPODIR}/${PKG_ABI}/${PKG_VERSION} ; \
1908 echo "==> New package $${newpkgname}" ; \
1911 ${_+_}@cd ${.CURDIR}; \
1912 ${MAKE} -f Makefile.inc1 PKG_VERSION=${PKG_VERSION} sign-packages
1914 stage-packages-world: .PHONY
1915 @mkdir -p ${WSTAGEDIR}
1916 ${_+_}@cd ${.CURDIR}; \
1917 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT stageworld
1919 stage-packages-kernel: .PHONY
1920 @mkdir -p ${KSTAGEDIR}
1921 ${_+_}@cd ${.CURDIR}; \
1922 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT stagekernel
1924 stage-packages: .PHONY stage-packages-world stage-packages-kernel
1927 @mkdir -p ${REPODIR}
1929 create-packages-world: _pkgbootstrap _repodir .PHONY
1930 ${_+_}@cd ${.CURDIR}; \
1931 ${MAKE} -f Makefile.inc1 \
1932 DESTDIR=${WSTAGEDIR} \
1933 PKG_VERSION=${PKG_VERSION} create-world-packages
1935 create-packages-kernel: _pkgbootstrap _repodir .PHONY
1936 ${_+_}@cd ${.CURDIR}; \
1937 ${MAKE} -f Makefile.inc1 \
1938 DESTDIR=${KSTAGEDIR} \
1939 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1940 SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
1941 create-kernel-packages
1943 create-packages: .PHONY create-packages-world create-packages-kernel
1945 create-world-packages: _pkgbootstrap .PHONY
1946 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1947 @cd ${WSTAGEDIR} ; \
1948 env -i LC_COLLATE=C sort ${WSTAGEDIR}/${DISTDIR}/METALOG | \
1949 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk
1950 @for plist in ${WSTAGEDIR}/*.plist; do \
1951 plist=$${plist##*/} ; \
1952 pkgname=$${plist%.plist} ; \
1953 echo "_PKGS+= $${pkgname}" ; \
1954 done > ${WSTAGEDIR}/packages.mk
1955 ${_+_}@cd ${.CURDIR}; \
1956 ${MAKE} -f Makefile.inc1 create-world-packages-jobs \
1957 SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
1960 .if make(create-world-packages-jobs)
1961 .include "${WSTAGEDIR}/packages.mk"
1964 create-world-packages-jobs: .PHONY
1965 .for pkgname in ${_PKGS}
1966 create-world-packages-jobs: create-world-package-${pkgname}
1967 create-world-package-${pkgname}: .PHONY
1968 @sh ${SRCDIR}/release/packages/generate-ucl.sh -o ${pkgname} \
1969 -s ${SRCDIR} -u ${WSTAGEDIR}/${pkgname}.ucl
1971 /^name/ { printf("===> Creating %s-", $$2); next } \
1972 /^version/ { print $$2; next } \
1973 ' ${WSTAGEDIR}/${pkgname}.ucl
1974 @if [ "${pkgname}" == "runtime" ]; then \
1975 sed -i '' -e "s/%VCS_REVISION%/${VCS_REVISION}/" ${WSTAGEDIR}/${pkgname}.ucl ; \
1977 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname -o ALLOW_BASE_SHLIBS=yes \
1978 create -f ${PKG_FORMAT} -M ${WSTAGEDIR}/${pkgname}.ucl \
1979 -p ${WSTAGEDIR}/${pkgname}.plist \
1981 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
1984 _default_flavor= -default
1985 .if make(*package*) && exists(${KSTAGEDIR}/kernel.meta)
1986 . if ${MK_DEBUG_FILES} != "no"
1989 create-kernel-packages: .PHONY
1990 . for flavor in "" ${_debug}
1991 create-kernel-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}
1992 create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY
1993 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1994 env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.meta | \
1995 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1996 -v kernel=yes -v _kernconf=${INSTALLKERNEL} ; \
1997 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1998 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1999 -e "s/%KERNELDIR%/kernel/" \
2000 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
2001 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
2002 -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \
2003 -e "s/%PKG_NAME_PREFIX%/${PKG_NAME_PREFIX}/" \
2004 -e "s/%PKG_MAINTAINER%/${PKG_MAINTAINER}/" \
2005 -e "s|%PKG_WWW%|${PKG_WWW}|" \
2006 ${SRCDIR}/release/packages/kernel.ucl \
2007 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
2009 /name/ { printf("===> Creating %s-", $$2); next } \
2010 /version/ {print $$2; next } ' \
2011 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
2012 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname -o ALLOW_BASE_SHLIBS=yes \
2013 create -f ${PKG_FORMAT} \
2014 -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
2015 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
2016 -r ${KSTAGEDIR}/${DISTDIR} \
2017 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
2020 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
2021 . for _kernel in ${BUILDKERNELS:[2..-1]}
2022 . if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
2023 . if ${MK_DEBUG_FILES} != "no"
2026 . for flavor in "" ${_debug}
2027 create-kernel-packages: create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}
2028 create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}: _pkgbootstrap .PHONY
2029 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
2030 env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.${_kernel}.meta | \
2031 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
2032 -v kernel=yes -v _kernconf=${_kernel} ; \
2033 sed -e "s/%VERSION%/${PKG_VERSION}/" \
2034 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
2035 -e "s/%KERNELDIR%/kernel.${_kernel}/" \
2036 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
2037 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
2038 -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \
2039 -e "s/%PKG_NAME_PREFIX%/${PKG_NAME_PREFIX}/" \
2040 -e "s/%PKG_MAINTAINER%/${PKG_MAINTAINER}/" \
2041 -e "s|%PKG_WWW%|${PKG_WWW}|" \
2042 ${SRCDIR}/release/packages/kernel.ucl \
2043 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
2045 /name/ { printf("===> Creating %s-", $$2); next } \
2046 /version/ {print $$2; next } ' \
2047 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
2048 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname -o ALLOW_BASE_SHLIBS=yes \
2049 create -f ${PKG_FORMAT} \
2050 -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
2051 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
2052 -r ${KSTAGEDIR}/kernel.${_kernel} \
2053 -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
2059 sign-packages: _pkgbootstrap .PHONY
2060 printf "version = 2;\npacking_format = \"${PKG_FORMAT}\";\n" > ${WSTAGEDIR}/meta
2061 @[ -L "${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/latest" ] && \
2062 unlink ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/latest ; \
2063 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname repo \
2064 -m ${WSTAGEDIR}/meta \
2065 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/${PKG_VERSION} \
2066 ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI)/${PKG_VERSION} \
2068 cd ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI); \
2069 ln -s ${PKG_OUTPUT_DIR} latest
2075 # Run test suite on installed world.
2078 @if [ ! -x "${LOCALBASE}/bin/kyua" ] && [ ! -x "/usr/bin/kyua" ]; then \
2079 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
2082 ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile
2088 # Build the API documentation with doxygen
2091 @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \
2092 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
2095 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
2100 # Update the source tree(s), by running svn/svnup to update to the
2104 .if defined(SVN_UPDATE)
2105 @echo "--------------------------------------------------------------"
2106 @echo ">>> Updating ${.CURDIR} using Subversion"
2107 @echo "--------------------------------------------------------------"
2108 @(cd ${.CURDIR}; ${SVN_CMD} update ${SVNFLAGS})
2112 # ------------------------------------------------------------------------
2114 # From here onwards are utility targets used by the 'make world' and
2115 # related targets. If your 'world' breaks, you may like to try to fix
2116 # the problem and manually run the following targets to attempt to
2117 # complete the build. Beware, this is *not* guaranteed to work, you
2118 # need to have a pretty good grip on the current state of the system
2119 # to attempt to manually finish it. If in doubt, 'make world' again.
2123 # legacy: Build compatibility shims for the next three targets. This is a
2124 # minimal set of tools and shims necessary to compensate for older systems
2125 # which don't have the APIs required by the targets built in bootstrap-tools,
2126 # build-tools or cross-tools.
2129 .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
2130 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
2136 ${LOCAL_LEGACY_DIRS}
2137 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
2138 cd ${.CURDIR}/${_tool}; \
2139 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2140 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy includes; \
2141 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
2142 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
2143 DESTDIR=${WORLDTMP}/legacy install
2147 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
2148 # are built to build other binaries in the system. However, the focus of these
2149 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
2150 # libraries, augmented by -legacy, in addition to the libraries built during
2153 _bt= _bootstrap-tools
2155 # We want to run the build with only ${WORLDTMP} in $PATH to ensure we don't
2156 # accidentally run tools that are incompatible but happen to be in $PATH.
2157 # This is especially important when building on Linux/MacOS where many of the
2158 # programs used during the build accept different flags or generate different
2159 # output. On those platforms we only symlink the tools known to be compatible
2160 # (e.g. basic utilities such as mkdir) into ${WORLDTMP} and build all others
2161 # from the FreeBSD sources during the bootstrap-tools stage.
2162 # We want to build without the user's $PATH starting in the bootstrap-tools
2163 # phase so the tools used in that phase (ln, cp, etc) must have already been
2164 # linked to $WORLDTMP. The tools are listed in the _host_tools_to_symlink
2165 # variable in tools/build/Makefile and are linked during the legacy phase.
2166 # Since they could be Linux or MacOS binaries, too we must only use flags that
2167 # are portable across operating systems.
2169 # If BOOTSTRAP_ALL_TOOLS is set we will build all the required tools from the
2170 # current source tree. Otherwise we create a symlink to the version found in
2171 # $PATH during the bootstrap-tools stage.
2172 # When building on non-FreeBSD systems we can't assume that the host binaries
2173 # accept compatible flags or produce compatible output. Therefore we force
2174 # BOOTSTRAP_ALL_TOOLS and just build the FreeBSD version of the binary.
2175 .if defined(CROSSBUILD_HOST)
2176 BOOTSTRAP_ALL_TOOLS:= 1
2178 .if defined(BOOTSTRAP_ALL_TOOLS)
2179 # BOOTSTRAPPING will be set on the command line so we can't override it here.
2180 # Instead set BOOTSTRAPPING_OSRELDATE so that the value 0 is set ${BSARGS}
2181 BOOTSTRAPPING_OSRELDATE:= 0
2184 # libnv and libsbuf are requirements for config(8), which is an unconditional
2186 _config=usr.sbin/config lib/libnv lib/libsbuf
2187 ${_bt}-usr.sbin/config: ${_bt}-lib/libnv ${_bt}-lib/libsbuf
2189 .if ${MK_GAMES} != "no"
2190 _strfile= usr.bin/fortune/strfile
2193 .if ${MK_VT} != "no"
2194 _vtfontcvt= usr.bin/vtfontcvt
2197 # If we are not building the bootstrap because BOOTSTRAPPING is sufficient
2198 # we symlink the host version to $WORLDTMP instead. By doing this we can also
2199 # detect when a bootstrap tool is being used without the required MK_FOO.
2200 # If you add a new bootstrap tool where we could also use the host version,
2201 # please ensure that you also add a .else case where you add the tool to the
2202 # _bootstrap_tools_links variable.
2203 .if ${BOOTSTRAPPING} < 1000033
2204 # Note: lex needs m4 to build but m4 also depends on lex (which needs m4 to
2205 # generate any files). To fix this cyclic dependency we can build a bootstrap
2206 # version of m4 (with pre-generated files) then use that to build the real m4.
2207 # We can't simply use the host m4 since e.g. the macOS version does not accept
2208 # the flags that are passed by lex.
2209 # For lex we also use the pre-gerated files since we would otherwise need to
2210 # build awk and sed first (which need lex to build)
2211 # TODO: add a _bootstrap_lex and then build the real lex afterwards
2213 _m4= tools/build/bootstrap-m4 usr.bin/m4
2214 ${_bt}-tools/build/bootstrap-m4: ${_bt}-usr.bin/lex ${_bt}-lib/libopenbsd ${_bt}-usr.bin/yacc
2215 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd ${_bt}-usr.bin/yacc ${_bt}-usr.bin/lex ${_bt}-tools/build/bootstrap-m4
2216 _bt_m4_depend=${_bt}-usr.bin/m4
2217 _bt_lex_depend=${_bt}-usr.bin/lex ${_bt_m4_depend}
2219 _bootstrap_tools_links+=m4 lex
2222 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
2223 # r296685 fix cross-endian objcopy
2224 # r310724 fixed PR 215350, a crash in libdwarf with objects built by GCC 6.2.
2225 # r334881 added libdwarf constants used by ctfconvert.
2226 # r338478 fixed a crash in objcopy for mips64el objects
2227 # r339083 libelf: correct mips64el test to use ELF header
2228 # r348347 Add missing powerpc64 relocation support to libdwarf
2229 .if ${BOOTSTRAPPING} < 1300030
2230 _elftoolchain_libs= lib/libelf lib/libdwarf lib/libzstd
2231 ${_bt}-lib/libelf: ${_bt_m4_depend}
2232 ${_bt}-lib/libdwarf: ${_bt_m4_depend}
2235 # flua is required to regenerate syscall files. It first appeared during the
2236 # 13.0-CURRENT cycle, thus needs to be built on -older releases and stable
2238 .if ${BOOTSTRAPPING} < 1300059
2239 ${_bt}-libexec/flua: ${_bt}-lib/liblua ${_bt}-lib/libucl
2240 _flua= lib/liblua lib/libucl libexec/flua
2243 # r245440 mtree -N support added
2244 # r313404 requires sha384.h for libnetbsd, added to libmd in r292782
2245 .if ${BOOTSTRAPPING} < 1100093
2246 _nmtree= lib/libmd \
2250 ${_bt}-lib/libnetbsd: ${_bt}-lib/libmd
2251 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
2253 _bootstrap_tools_links+=mtree
2256 # r246097: log addition login.conf.db, passwd, pwd.db, and spwd.db with cat -l
2257 .if ${BOOTSTRAPPING} < 1000027
2260 _bootstrap_tools_links+=cat
2263 # r277259 crunchide: Correct 64-bit section header offset
2264 # r281674 crunchide: always include both 32- and 64-bit ELF support
2265 .if ${BOOTSTRAPPING} < 1100078
2266 _crunchide= usr.sbin/crunch/crunchide
2268 _bootstrap_tools_links+=crunchide
2271 # 1300115: Higher WARNS fixes
2272 .if ${BOOTSTRAPPING} < 1202502 || \
2273 (${BOOTSTRAPPING} > 1300000 && ${BOOTSTRAPPING} < 1300131)
2274 _crunchgen= usr.sbin/crunch/crunchgen
2276 _bootstrap_tools_links+=crunchgen
2279 # r296926 -P keymap search path, MFC to stable/10 in r298297
2280 # Note: kbdcontrol can not be bootstrapped on non-FreeBSD systems
2281 .if !defined(CROSSBUILD_HOST)
2282 .if (${BOOTSTRAPPING} < 1003501 || \
2283 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103))
2284 _kbdcontrol= usr.sbin/kbdcontrol
2286 _bootstrap_tools_links+=kbdcontrol
2292 .if ${MK_BSNMP} != "no"
2293 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
2297 # We need to build tblgen when we're building clang or lld, either as
2298 # bootstrap tools, or as the part of the normal build.
2299 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
2300 ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no"
2302 lib/clang/libllvmminimal \
2303 usr.bin/clang/llvm-tblgen \
2304 usr.bin/clang/clang-tblgen \
2305 usr.bin/clang/lldb-tblgen
2306 # XXX: lldb-tblgen is not needed, if top-level MK_LLDB=no
2308 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal
2309 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal
2310 ${_bt}-usr.bin/clang/lldb-tblgen: ${_bt}-lib/clang/libllvmminimal
2313 .if ${MK_LOCALES} != "no"
2314 _localedef= usr.bin/localedef
2315 ${_bt}-usr.bin/localedef: ${_bt}-usr.bin/yacc ${_bt_lex_depend}
2318 .if ${MK_KERBEROS} != "no"
2319 _kerberos5_bootstrap_tools= \
2320 kerberos5/tools/make-roken \
2321 kerberos5/lib/libroken \
2322 kerberos5/lib/libvers \
2323 kerberos5/tools/asn1_compile \
2324 kerberos5/tools/slc \
2327 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
2328 .for _tool in ${_kerberos5_bootstrap_tools}
2329 ${_bt}-${_tool}: ${_bt}-usr.bin/yacc ${_bt_lex_depend}
2333 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
2335 # The tools listed in _basic_bootstrap_tools will generally not be
2336 # bootstrapped unless BOOTSTRAP_ALL_TOOL is set. However, when building on a
2337 # Linux or MacOS host the host versions are incompatible so we need to build
2338 # them from the source tree. Usually the link name will be the same as the subdir,
2339 # but some directories such as grep or test install multiple binaries. In that
2340 # case we use the _basic_bootstrap_tools_multilink variable which is a list of
2341 # subdirectory and comma-separated list of files.
2342 _basic_bootstrap_tools_multilink=usr.bin/grep grep,egrep,fgrep
2343 _basic_bootstrap_tools_multilink+=bin/test test,[
2344 # bootstrap tools needed by buildworld:
2345 _basic_bootstrap_tools+=usr.bin/cut bin/expr usr.bin/gencat usr.bin/join \
2346 usr.bin/mktemp bin/realpath bin/rmdir usr.bin/sed usr.bin/sort \
2347 usr.bin/truncate usr.bin/tsort
2348 # Some build scripts use nawk instead of awk (this happens at least in
2349 # cddl/contrib/opensolaris/lib/libdtrace/common/mknames.sh) so we need both awk
2350 # and nawk in ${WORLDTMP}/legacy/bin.
2351 _basic_bootstrap_tools_multilink+=usr.bin/awk awk,nawk
2352 # file2c is required for building usr.sbin/config:
2353 _basic_bootstrap_tools+=usr.bin/file2c
2354 # uuencode/uudecode required for share/tabset
2355 _basic_bootstrap_tools+=usr.bin/uuencode usr.bin/uudecode
2356 # xargs is required by mkioctls
2357 _basic_bootstrap_tools+=usr.bin/xargs
2358 # cap_mkdb is required for share/termcap:
2359 _basic_bootstrap_tools+=usr.bin/cap_mkdb
2360 # services_mkdb/pwd_mkdb are required for installworld:
2361 _basic_bootstrap_tools+=usr.sbin/services_mkdb usr.sbin/pwd_mkdb
2362 # ldd is required for installcheck (TODO: just always use /usr/bin/ldd instead?)
2363 .if !defined(CROSSBUILD_HOST)
2364 # ldd is only needed for updating the running system so we don't need to
2365 # bootstrap ldd on non-FreeBSD systems
2366 _basic_bootstrap_tools+=usr.bin/ldd
2368 # sysctl/chflags are required for installkernel:
2369 .if !defined(CROSSBUILD_HOST)
2370 _basic_bootstrap_tools+=bin/chflags
2371 # Note: sysctl does not bootstrap on FreeBSD < 13 anymore, but that doesn't
2372 # matter since we don't need any of the new features for the build.
2373 _bootstrap_tools_links+=sysctl
2375 # When building on non-FreeBSD, install a fake chflags instead since the
2376 # version from the source tree cannot work. We also don't need sysctl since we
2377 # are install with -DNO_ROOT.
2378 _other_bootstrap_tools+=tools/build/cross-build/fake_chflags
2380 # mkfifo is used by sys/conf/newvers.sh
2381 _basic_bootstrap_tools+=usr.bin/mkfifo
2382 # jot is needed for the mkimg tests
2383 _basic_bootstrap_tools+=usr.bin/jot
2385 .if ${MK_BOOT} != "no"
2386 # md5 is used by boot/beri (and possibly others)
2387 _basic_bootstrap_tools+=sbin/md5
2390 .if ${MK_ZONEINFO} != "no"
2391 _basic_bootstrap_tools+=usr.sbin/zic usr.sbin/tzsetup
2394 .if defined(BOOTSTRAP_ALL_TOOLS)
2395 _other_bootstrap_tools+=${_basic_bootstrap_tools}
2396 .for _subdir _links in ${_basic_bootstrap_tools_multilink}
2397 _other_bootstrap_tools+=${_subdir}
2399 ${_bt}-usr.bin/awk: ${_bt_lex_depend} ${_bt}-usr.bin/yacc
2400 ${_bt}-bin/expr: ${_bt_lex_depend} ${_bt}-usr.bin/yacc
2401 # If we are bootstrapping file2c, we have to build it before config:
2402 ${_bt}-usr.sbin/config: ${_bt}-usr.bin/file2c ${_bt_lex_depend}
2403 # Note: no symlink to make/bmake in the !BOOTSTRAP_ALL_TOOLS case here since
2404 # the links to make/bmake make links will have already have been created in the
2405 # `make legacy` step. Not adding a link to make is important on non-FreeBSD
2406 # since "make" will usually point to GNU make there.
2407 _other_bootstrap_tools+=usr.bin/bmake
2409 # Avoid dependency on host bz2 headers:
2410 _other_bootstrap_tools+=lib/libbz2
2411 ${_bt}-usr.bin/grep: ${_bt}-lib/libbz2
2413 # All tools in _basic_bootstrap_tools have the same name as the subdirectory
2414 # so we can use :T to get the name of the symlinks that we need to create.
2415 _bootstrap_tools_links+=${_basic_bootstrap_tools:T}
2416 .for _subdir _links in ${_basic_bootstrap_tools_multilink}
2417 _bootstrap_tools_links+=${_links:S/,/ /g}
2419 .endif # defined(BOOTSTRAP_ALL_TOOLS)
2421 # Link the tools that we need for building but don't need to bootstrap because
2422 # the host version is known to be compatible into ${WORLDTMP}/legacy
2423 # We do this before building any of the bootstrap tools in case they depend on
2424 # the presence of any of the links (e.g. as m4/lex/awk)
2425 ${_bt}-links: .PHONY
2427 .for _tool in ${_bootstrap_tools_links}
2428 ${_bt}-link-${_tool}: .PHONY .MAKE
2429 @rm -f "${WORLDTMP}/legacy/bin/${_tool}"; \
2430 source_path=`which ${_tool}`; \
2431 if [ ! -e "$${source_path}" ] ; then \
2432 echo "Cannot find host tool '${_tool}'"; false; \
2434 cp -pf "$${source_path}" "${WORLDTMP}/legacy/bin/${_tool}"
2435 ${_bt}-links: ${_bt}-link-${_tool}
2438 bootstrap-tools: ${_bt}-links .PHONY
2440 # Please document (add comment) why something is in 'bootstrap-tools'.
2441 # Try to bound the building of the bootstrap-tool to just the
2442 # FreeBSD versions that need the tool built at this stage of the build.
2445 ${_kerberos5_bootstrap_tools} \
2450 ${_elftoolchain_libs} \
2458 ${_other_bootstrap_tools} \
2468 ${LOCAL_BSTOOL_DIRS}
2469 ${_bt}-${_tool}: ${_bt}-links .PHONY .MAKE
2470 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2471 cd ${.CURDIR}/${_tool}; \
2472 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2473 if [ "${_tool}" = "usr.bin/lex" ]; then \
2474 ${MAKE} DIRPRFX=${_tool}/ bootstrap; \
2476 ${MAKE} DIRPRFX=${_tool}/ all; \
2477 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy install
2479 bootstrap-tools: ${_bt}-${_tool}
2481 .if target(${_bt}-lib/libmd)
2482 # If we are bootstrapping libmd (e.g. when building on macOS/Linux) add the
2483 # necessary dependencies:
2484 ${_bt}-usr.bin/sort: ${_bt}-lib/libmd
2485 ${_bt}-usr.bin/xinstall: ${_bt}-lib/libmd
2486 ${_bt}-sbin/md5: ${_bt}-lib/libmd
2491 # build-tools: Build special purpose build tools
2493 .if !defined(NO_SHARE) && ${MK_SYSCONS} != "no"
2494 _share= share/syscons/scrnmaps
2497 .if ${MK_RESCUE} != "no"
2498 # rescue includes programs that have build-tools targets
2499 _rescue=rescue/rescue
2502 .if ${MK_TCSH} != "no"
2505 .if ${MK_FILE} != "no"
2506 _libmagic=lib/libmagic
2509 .if ${MK_PMC} != "no" && \
2510 (${TARGET_ARCH} == "aarch64" || ${TARGET_ARCH} == "amd64" || \
2511 ${TARGET_ARCH} == "i386")
2512 _jevents=lib/libpmc/pmu-events
2515 # kernel-toolchain skips _cleanobj, so handle cleaning up previous
2516 # build-tools directories if needed.
2517 .if ${MK_CLEAN} == "yes" && make(kernel-toolchain)
2518 _bt_clean= ${CLEANDIR}
2524 ${LOCAL_TOOL_DIRS} \
2526 lib/ncurses/ncurses \
2527 lib/ncurses/ncursesw \
2532 usr.bin/mkesdb_static \
2533 usr.bin/mkcsmapper_static \
2535 build-tools_${_tool}: .PHONY
2536 ${_+_}@${ECHODIR} "===> ${_tool} (${_bt_clean:D${_bt_clean},}obj,build-tools)"; \
2537 cd ${.CURDIR}/${_tool}; \
2538 if [ -n "${_bt_clean}" ]; then ${MAKE} DIRPRFX=${_tool}/ ${_bt_clean}; fi; \
2539 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2540 ${MAKE} DIRPRFX=${_tool}/ build-tools
2541 build-tools: build-tools_${_tool}
2545 # kernel-tools: Build kernel-building tools
2547 kernel-tools: .PHONY
2548 mkdir -p ${WORLDTMP}/usr
2549 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2550 -p ${WORLDTMP}/usr >/dev/null
2553 # cross-tools: All the tools needed to build the rest of the system after
2554 # we get done with the earlier stages. It is the last set of tools needed
2555 # to begin building the target binaries.
2557 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BUILD_WITH_STRICT_TMPPATH} != 0
2558 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
2559 _btxld= usr.sbin/btxld
2563 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
2564 # resulting from missing bug fixes or ELF Toolchain updates.
2565 .if ${MK_CDDL} != "no"
2566 _dtrace_tools= cddl/lib/libctf cddl/lib/libspl cddl/usr.bin/ctfconvert \
2567 cddl/usr.bin/ctfmerge
2570 # If we're given an XAS, don't build binutils.
2571 .if ${XAS:M/*} == ""
2572 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
2573 _elftctools= lib/libelftc \
2579 # These are not required by the build, but can be useful for developers who
2580 # cross-build on a FreeBSD 10 host:
2581 _elftctools+= usr.bin/addr2line
2583 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
2584 # If cross-building with an external binutils we still need to build strip for
2585 # the target (for at least crunchide).
2586 _elftctools= lib/libelftc \
2591 .if ${MK_CLANG_BOOTSTRAP} != "no"
2592 _clang= usr.bin/clang
2594 .if ${MK_LLD_BOOTSTRAP} != "no"
2595 _lld= usr.bin/clang/lld
2597 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no"
2598 _clang_libs= lib/clang
2600 .if ${MK_USB} != "no"
2601 _usb_tools= stand/usb/tools
2604 .if ${BUILD_WITH_STRICT_TMPPATH} != 0 || defined(BOOTSTRAP_ALL_TOOLS)
2608 cross-tools: .MAKE .PHONY
2610 ${LOCAL_XTOOL_DIRS} \
2619 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2620 cd ${.CURDIR}/${_tool}; \
2621 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2622 ${MAKE} DIRPRFX=${_tool}/ all; \
2623 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP} install
2627 # native-xtools is the current target for qemu-user cross builds of ports
2628 # via poudriere and the imgact_binmisc kernel module.
2629 # This target merely builds a toolchan/sysroot, then builds the tools it wants
2630 # with the options it wants in a special MAKEOBJDIRPREFIX, using the toolchain
2631 # already built. It then installs the static tools to NXBDESTDIR for Poudriere
2634 NXBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/nxb/
2635 NXBOBJTOP= ${NXBOBJROOT}${NXB_TARGET}.${NXB_TARGET_ARCH}
2638 .error NXTP variable should be an absolute path
2640 NXBDESTDIR?= ${DESTDIR}${NXTP}
2642 # This is the list of tools to be built/installed as static and where
2643 # appropriate to build for the given TARGET.TARGET_ARCH.
2707 SUBDIR_DEPEND_usr.bin/clang= lib/clang
2708 .if ${MK_CLANG} != "no"
2710 NXBDIRS+= usr.bin/clang
2712 # XXX: native-xtools passes along ${NXBDIRS} in SUBDIR_OVERRIDE that needs
2713 # to be evaluated after NXBDIRS is set.
2714 .if make(install) && !empty(SUBDIR_OVERRIDE)
2715 SUBDIR= ${SUBDIR_OVERRIDE}
2719 OBJTOP=${NXBOBJTOP:Q} \
2720 OBJROOT=${NXBOBJROOT:Q} \
2727 MK_CLANG_EXTRAS=no \
2728 MK_CLANG_FORMAT=no \
2747 .if make(native-xtools*) && \
2748 (!defined(NXB_TARGET) || !defined(NXB_TARGET_ARCH))
2749 .error Missing NXB_TARGET / NXB_TARGET_ARCH
2751 # For 'toolchain' we want to produce native binaries that themselves generate
2753 NXBTMAKE= ${NXBMAKEENV} ${MAKE} ${NXBMAKEARGS:N-DNO_PIC:N-DNO_SHARED} \
2754 TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH}
2755 # For 'everything' we want to produce native binaries (hence -target to
2756 # be MACHINE) that themselves generate TARGET.TARGET_ARCH binaries.
2757 # TARGET/TARGET_ARCH are still passed along from user.
2759 # Use the toolchain we create as an external toolchain.
2760 .if ${USING_SYSTEM_COMPILER} == "yes" || ${XCC:N${CCACHE_BIN}:M/*}
2761 NXBMAKE+= XCC="${XCC}" \
2765 NXBMAKE+= XCC="${NXBOBJTOP}/tmp/usr/bin/cc" \
2766 XCXX="${NXBOBJTOP}/tmp/usr/bin/c++" \
2767 XCPP="${NXBOBJTOP}/tmp/usr/bin/cpp"
2769 NXBMAKE+= ${NXBMAKEENV} ${MAKE} -f Makefile.inc1 ${NXBMAKEARGS} \
2770 MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} \
2771 TARGET=${NXB_TARGET} TARGET_ARCH=${NXB_TARGET_ARCH} \
2772 TARGET_TRIPLE=${MACHINE_TRIPLE:Q}
2773 # NXBDIRS is improperly based on MACHINE rather than NXB_TARGET. Need to
2774 # invoke a sub-make to reevaluate MK_CLANG, etc, for NXBDIRS.
2775 NXBMAKE+= SUBDIR_OVERRIDE='$${NXBDIRS:M*}'
2776 # Need to avoid the -isystem logic when using clang as an external toolchain
2777 # even if the TARGET being built for wants GCC.
2778 NXBMAKE+= WANT_COMPILER_TYPE='$${X_COMPILER_TYPE}'
2779 native-xtools: .PHONY
2780 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _cleanobj
2781 # Build the bootstrap/host/cross tools that produce native binaries
2782 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} kernel-toolchain
2783 # Populate includes/libraries sysroot that produce native binaries.
2784 # This is split out from 'toolchain' above mostly so that target LLVM
2785 # libraries have a proper LLVM_DEFAULT_TARGET_TRIPLE without
2786 # polluting the cross-compiler build. The LLVM/GCC libs are skipped
2787 # here to avoid the problem but are kept in 'toolchain' so that
2788 # needed build tools are built.
2789 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes MK_CLANG=no
2790 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries MK_CLANG=no
2791 .if !defined(NO_OBJWALK)
2792 ${_+_}cd ${.CURDIR}; ${NXBMAKE} _obj
2794 ${_+_}cd ${.CURDIR}; ${NXBMAKE} everything
2795 @echo ">> native-xtools done. Use 'make native-xtools-install' to install to a given DESTDIR"
2797 native-xtools-install: .PHONY
2798 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
2799 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2800 -p ${NXBDESTDIR}/usr >/dev/null
2801 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2802 -p ${NXBDESTDIR}/usr/include >/dev/null
2803 ${_+_}cd ${.CURDIR}; ${NXBMAKE} \
2804 DESTDIR=${NXBDESTDIR} \
2809 # hierarchy - ensure that all the needed directories are present
2811 hierarchy hier: .MAKE .PHONY
2812 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
2815 # libraries - build all libraries, and install them under ${DESTDIR}.
2817 # The list of libraries with dependents (${_prebuild_libs}) and their
2818 # interdependencies (__L) are built automatically by the
2819 # ${.CURDIR}/tools/make_libdeps.sh script.
2821 libraries: .MAKE .PHONY
2822 ${_+_}cd ${.CURDIR}; \
2823 ${MAKE} -f Makefile.inc1 _prereq_libs; \
2824 ${MAKE} -f Makefile.inc1 _startup_libs; \
2825 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
2826 ${MAKE} -f Makefile.inc1 _generic_libs
2829 # static libgcc.a prerequisite for shared libc
2831 _prereq_libs= lib/libcompiler_rt
2832 .if ${MK_SSP} != "no"
2833 _prereq_libs+= lib/libssp_nonshared
2836 # These dependencies are not automatically generated:
2838 # lib/csu and lib/libc must be built before
2839 # all shared libraries for ELF.
2841 _startup_libs= lib/csu
2842 _startup_libs+= lib/libc
2843 _startup_libs+= lib/libc_nonshared
2844 .if ${MK_LIBCPLUSPLUS} != "no"
2845 _startup_libs+= lib/libcxxrt
2848 _prereq_libs+= lib/libgcc_eh lib/libgcc_s
2849 _startup_libs+= lib/libgcc_eh lib/libgcc_s
2851 lib/libgcc_s__L: lib/libc__L
2852 lib/libgcc_s__L: lib/libc_nonshared__L
2853 .if ${MK_LIBCPLUSPLUS} != "no"
2854 lib/libcxxrt__L: lib/libgcc_s__L
2857 _prebuild_libs= ${_kerberos5_lib_libasn1} \
2858 ${_kerberos5_lib_libhdb} \
2859 ${_kerberos5_lib_libheimbase} \
2860 ${_kerberos5_lib_libheimntlm} \
2862 ${_kerberos5_lib_libheimipcc} \
2863 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
2864 ${_kerberos5_lib_libroken} \
2865 ${_kerberos5_lib_libwind} \
2866 lib/libbz2 ${_libcom_err} lib/libcrypt \
2867 lib/libelf lib/libexpat \
2871 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
2874 lib/ncurses/ncurses lib/ncurses/ncursesw \
2875 lib/libopie lib/libpam/libpam ${_lib_libthr} \
2876 ${_lib_libradius} lib/libsbuf lib/libtacplus \
2878 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
2879 ${_cddl_lib_libuutil} \
2880 ${_cddl_lib_libavl} \
2881 ${_cddl_lib_libicp} \
2882 ${_cddl_lib_libicp_rescue} \
2883 ${_cddl_lib_libspl} \
2884 ${_cddl_lib_libtpool} \
2885 ${_cddl_lib_libzfs_core} ${_cddl_lib_libzfs} \
2886 ${_cddl_lib_libzutil} \
2887 ${_cddl_lib_libctf} ${_cddl_lib_libzfsbootenv} \
2889 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
2890 ${_secure_lib_libcrypto} ${_secure_lib_libssl} \
2891 ${_lib_libldns} ${_secure_lib_libssh}
2893 .if ${MK_DIALOG} != "no"
2894 _prebuild_libs+= gnu/lib/libdialog
2895 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2898 .if ${MK_GOOGLETEST} != "no"
2899 _prebuild_libs+= lib/libregex
2902 .if ${MK_LIBCPLUSPLUS} != "no"
2903 _prebuild_libs+= lib/libc++
2906 lib/libgeom__L: lib/libexpat__L lib/libsbuf__L
2907 lib/libkvm__L: lib/libelf__L
2909 .if ${MK_LIBTHR} != "no"
2910 _lib_libthr= lib/libthr
2913 .if ${MK_RADIUS_SUPPORT} != "no"
2914 _lib_libradius= lib/libradius
2917 .if ${MK_OFED} != "no"
2919 lib/ofed/libibverbs \
2921 lib/ofed/libibumad \
2925 lib/ofed/libibmad__L: lib/ofed/libibumad__L
2926 lib/ofed/complib__L: lib/libthr__L
2927 lib/ofed/libmlx5__L: lib/ofed/libibverbs__L lib/libthr__L
2930 .if ${MK_CASPER} != "no"
2931 _lib_casper= lib/libcasper
2934 lib/libpjdlog__L: lib/libutil__L
2935 lib/libcasper__L: lib/libnv__L
2936 lib/liblzma__L: lib/libmd__L lib/libthr__L
2937 lib/libzstd__L: lib/libthr__L
2939 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib}
2940 .if ${MK_IPFILTER} != "no"
2941 _generic_libs+= sbin/ipf/libipf
2943 .for _DIR in ${LOCAL_LIB_DIRS}
2944 .if ${_DIR} == ".WAIT" || (empty(_generic_libs:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
2945 _generic_libs+= ${_DIR}
2949 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2951 .if ${MK_CDDL} != "no"
2952 _cddl_lib_libumem= cddl/lib/libumem
2953 _cddl_lib_libnvpair= cddl/lib/libnvpair
2954 _cddl_lib_libavl= cddl/lib/libavl
2955 _cddl_lib_libuutil= cddl/lib/libuutil
2956 _cddl_lib_libspl= cddl/lib/libspl
2958 cddl/lib/libuutil__L: cddl/lib/libavl__L cddl/lib/libspl__L
2960 .if ${MK_ZFS} != "no"
2961 _cddl_lib_libicp= cddl/lib/libicp
2962 _cddl_lib_libicp_rescue= cddl/lib/libicp_rescue
2963 _cddl_lib_libtpool= cddl/lib/libtpool
2964 _cddl_lib_libzutil= cddl/lib/libzutil
2965 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2966 _cddl_lib_libzfs= cddl/lib/libzfs
2967 _cddl_lib_libzfsbootenv= cddl/lib/libzfsbootenv
2969 cddl/lib/libtpool__L: cddl/lib/libspl__L
2971 cddl/lib/libzutil__L: cddl/lib/libavl__L cddl/lib/libtpool__L
2973 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2975 cddl/lib/libzfs__L: cddl/lib/libzfs_core__L lib/msun__L lib/libutil__L
2976 cddl/lib/libzfs__L: lib/libthr__L lib/libmd__L lib/libz__L cddl/lib/libumem__L
2977 cddl/lib/libzfs__L: cddl/lib/libuutil__L cddl/lib/libavl__L lib/libgeom__L
2978 cddl/lib/libzfs__L: cddl/lib/libnvpair__L cddl/lib/libzutil__L
2979 cddl/lib/libzfs__L: secure/lib/libcrypto__L
2981 cddl/lib/libzfsbootenv__L: cddl/lib/libzfs__L
2982 lib/libbe__L: cddl/lib/libzfs__L cddl/lib/libzfsbootenv__L
2984 _cddl_lib_libctf= cddl/lib/libctf
2986 cddl/lib/libctf__L: lib/libz__L cddl/lib/libspl__L
2988 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db
2989 _prebuild_libs+= lib/libprocstat lib/libproc lib/librtld_db
2990 lib/libprocstat__L: lib/libelf__L lib/libkvm__L lib/libutil__L
2991 lib/libproc__L: lib/libprocstat__L
2992 lib/librtld_db__L: lib/libprocstat__L
2994 .if ${MK_CRYPT} != "no"
2995 .if ${MK_OPENSSL} != "no"
2996 _secure_lib_libcrypto= secure/lib/libcrypto
2997 _secure_lib_libssl= secure/lib/libssl
2998 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2999 secure/lib/libcrypto__L: lib/libthr__L
3000 .if ${MK_LDNS} != "no"
3001 _lib_libldns= lib/libldns
3002 lib/libldns__L: secure/lib/libssl__L
3004 .if ${MK_OPENSSH} != "no"
3005 _secure_lib_libssh= secure/lib/libssh
3006 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
3007 .if ${MK_LDNS} != "no"
3008 secure/lib/libssh__L: lib/libldns__L
3010 .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no"
3011 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
3012 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
3013 lib/libmd__L kerberos5/lib/libroken__L
3017 _secure_lib= secure/lib
3020 .if ${MK_KERBEROS} != "no"
3021 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
3022 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
3023 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
3024 kerberos5/lib/libwind__L lib/libsqlite3__L
3025 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
3026 kerberos5/lib/libroken__L lib/libcom_err__L
3027 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
3028 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
3029 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
3030 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
3031 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
3032 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
3033 kerberos5/lib/libroken__L: lib/libcrypt__L
3034 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
3035 kerberos5/lib/libheimbase__L: lib/libthr__L
3036 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
3039 lib/libsqlite3__L: lib/libthr__L
3041 .if ${MK_GSSAPI} != "no"
3042 _lib_libgssapi= lib/libgssapi
3045 .if ${MK_KERBEROS} != "no"
3046 _kerberos5_lib= kerberos5/lib
3047 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
3048 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
3049 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
3050 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
3051 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
3052 _kerberos5_lib_libroken= kerberos5/lib/libroken
3053 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
3054 _libsqlite3= lib/libsqlite3
3055 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
3056 _kerberos5_lib_libwind= kerberos5/lib/libwind
3057 _libcom_err= lib/libcom_err
3060 .if ${MK_NIS} != "no"
3061 _lib_libypclnt= lib/libypclnt
3064 .if ${MK_OPENSSL} == "no"
3065 lib/libradius__L: lib/libmd__L
3069 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
3070 .if ${MK_CXX} != "no" && ${MK_LIBCPLUSPLUS} != "no"
3071 lib/libproc__L: lib/libcxxrt__L
3074 .for _lib in ${_prereq_libs}
3075 ${_lib}__PL: .PHONY .MAKE
3076 .if !defined(_MKSHOWCONFIG) && exists(${.CURDIR}/${_lib})
3077 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
3078 cd ${.CURDIR}/${_lib}; \
3079 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
3080 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
3081 DIRPRFX=${_lib}/ all; \
3082 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
3083 DIRPRFX=${_lib}/ install
3087 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
3088 ${_lib}__L: .PHONY .MAKE
3089 .if !defined(_MKSHOWCONFIG) && exists(${.CURDIR}/${_lib})
3090 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
3091 cd ${.CURDIR}/${_lib}; \
3092 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
3093 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
3094 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
3098 _prereq_libs: ${_prereq_libs:S/$/__PL/}
3099 _startup_libs: ${_startup_libs:S/$/__L/}
3100 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
3101 _generic_libs: ${_generic_libs:S/$/__L/}
3103 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
3104 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
3105 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
3106 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
3107 # parallel. This is safe for the world stage of buildworld though since it has
3108 # already built libraries in a proper order and installed includes into
3109 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
3110 # avoid trashing a system if it crashes mid-install.
3111 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
3115 .include <bsd.subdir.mk>
3117 .if make(check-old) || make(check-old-dirs) || \
3118 make(check-old-files) || make(check-old-libs) || \
3119 make(delete-old) || make(delete-old-dirs) || \
3120 make(delete-old-files) || make(delete-old-libs)
3123 # check for / delete old files section
3126 .include "ObsoleteFiles.inc"
3128 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
3129 else you can not start such an application. Consult UPDATING for more \
3130 information regarding how to cope with the removal/revision bump of a \
3133 .if !defined(BATCH_DELETE_OLD_FILES)
3139 delete-old-files: .PHONY
3140 @echo ">>> Removing old files (only deletes safe to delete libs)"
3141 # Ask for every old file if the user really wants to remove it.
3142 # It's annoying, but better safe than sorry.
3143 # NB: We cannot pass the list of OLD_FILES as a parameter because the
3144 # argument list will get too long. Using .for/.endfor make "loops" will make
3145 # the Makefile parser segfault.
3148 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3149 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | sort | \
3150 while read file; do \
3151 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3152 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
3153 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
3155 for ext in debug symbols; do \
3156 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
3157 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3158 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
3163 # Remove catpages without corresponding manpages.
3165 find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | sort | \
3166 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
3167 while read catpage; do \
3169 if [ ! -e "$${manpage}" ]; then \
3170 rm ${RM_I} $${catpage} <&3; \
3173 @echo ">>> Old files removed"
3175 check-old-files: .PHONY
3176 @echo ">>> Checking for old files"
3178 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3179 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
3180 while read file; do \
3181 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3182 echo "${DESTDIR}/$${file}"; \
3184 for ext in debug symbols; do \
3185 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3186 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
3190 # Check for catpages without corresponding manpages.
3191 @find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \
3192 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
3193 while read catpage; do \
3195 if [ ! -e "$${manpage}" ]; then \
3200 delete-old-libs: .PHONY
3201 @echo ">>> Removing old libraries"
3202 @echo "${OLD_LIBS_MESSAGE}" | fmt
3205 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3206 -V OLD_LIBS | xargs -n1 | sort | \
3207 while read file; do \
3208 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3209 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
3210 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
3212 for ext in debug symbols; do \
3213 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
3214 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3215 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
3220 @echo ">>> Old libraries removed"
3222 check-old-libs: .PHONY
3223 @echo ">>> Checking for old libraries"
3225 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3226 -V OLD_LIBS | xargs -n1 | \
3227 while read file; do \
3228 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
3229 echo "${DESTDIR}/$${file}"; \
3231 for ext in debug symbols; do \
3232 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
3233 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
3238 delete-old-dirs: .PHONY
3239 @echo ">>> Removing old directories"
3241 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3242 -V OLD_DIRS | xargs -n1 | sort -r | \
3243 while read dir; do \
3244 if [ -d "${DESTDIR}/$${dir}" ]; then \
3245 rmdir -v "${DESTDIR}/$${dir}" || true; \
3246 elif [ -L "${DESTDIR}/$${dir}" ]; then \
3247 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
3249 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3250 rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \
3251 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3252 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
3255 @echo ">>> Old directories removed"
3257 check-old-dirs: .PHONY
3258 @echo ">>> Checking for old directories"
3260 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
3261 -V OLD_DIRS | xargs -n1 | sort -r | \
3262 while read dir; do \
3263 if [ -d "${DESTDIR}/$${dir}" ]; then \
3264 echo "${DESTDIR}/$${dir}"; \
3265 elif [ -L "${DESTDIR}/$${dir}" ]; then \
3266 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
3268 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3269 echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \
3270 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
3271 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
3275 delete-old: delete-old-files delete-old-dirs .PHONY
3276 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
3278 check-old: check-old-files check-old-libs check-old-dirs .PHONY
3279 @echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
3280 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
3285 # showconfig - show build configuration.
3288 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes; \
3289 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes) 2>&1 | grep ^MK_ | sort -u
3291 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
3292 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
3294 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
3295 .if !defined(_MKSHOWCONFIG) && exists(${KERNCONFDIR}/${KERNCONF})
3296 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
3297 '${KERNCONFDIR}/${KERNCONF}' ; echo
3303 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
3304 DTBOUTPUTPATH= ${.CURDIR}
3308 # Build 'standalone' Device Tree Blob
3311 @PATH=${TMPPATH} MACHINE=${TARGET} \
3312 sh ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
3313 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
3318 # In the following, the first 'rm' in a series will usually remove all
3319 # files and directories. If it does not, then there are probably some
3320 # files with file flags set, so this unsets them and tries the 'rm' a
3321 # second time. There are situations where this target will be cleaning
3322 # some directories via more than one method, but that duplication is
3323 # needed to correctly handle all the possible situations. Removing all
3324 # files without file flags set in the first 'rm' instance saves time,
3325 # because 'chflags' will need to operate on fewer files afterwards.
3327 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
3328 # created by bsd.obj.mk, except that we don't want to .include that file
3329 # in this makefile. We don't do a cleandir walk if MK_AUTO_OBJ is yes
3330 # since it is not possible for files to land in the wrong place.
3332 .if make(cleanworld)
3333 BW_CANONICALOBJDIR:=${OBJTOP}/
3334 .elif make(cleanuniverse)
3335 BW_CANONICALOBJDIR:=${OBJROOT}
3336 .if ${MK_UNIFIED_OBJDIR} == "no"
3337 .error ${.TARGETS} only supported with WITH_UNIFIED_OBJDIR enabled.
3340 cleanworld cleanuniverse: .PHONY
3341 .if !empty(BW_CANONICALOBJDIR) && exists(${BW_CANONICALOBJDIR}) && \
3342 ${.CURDIR:tA} != ${BW_CANONICALOBJDIR:tA}
3343 -rm -rf ${BW_CANONICALOBJDIR}*
3344 -chflags -R 0 ${BW_CANONICALOBJDIR}
3345 rm -rf ${BW_CANONICALOBJDIR}*
3347 .if make(cleanworld) && ${MK_AUTO_OBJ} == "no" && \
3348 (empty(BW_CANONICALOBJDIR) || ${.CURDIR:tA} == ${BW_CANONICALOBJDIR:tA})
3349 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
3350 # To be safe in this case, fall back to a 'make cleandir'
3351 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
3355 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
3356 XDEV_CPUTYPE?=${CPUTYPE}
3358 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
3361 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
3362 MK_MAN=no MK_NLS=no MK_PROFILE=no \
3363 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
3364 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
3365 CPUTYPE=${XDEV_CPUTYPE}
3367 XDDIR=${TARGET_ARCH}-freebsd
3370 .error XDTP variable should be an absolute path
3373 CDBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/xdev/
3374 CDBOBJTOP= ${CDBOBJROOT}${XDDIR}
3376 INSTALL="sh ${.CURDIR}/tools/install.sh"
3378 TOOLS_PREFIX=${XDTP}
3380 OBJTOP=${CDBOBJTOP:Q} \
3381 OBJROOT=${CDBOBJROOT:Q}
3382 CD2MAKEARGS= ${CDMAKEARGS}
3384 .if ${WANT_COMPILER_TYPE} == gcc || \
3385 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
3386 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
3387 # won't set header path and -L is used to ensure the base library path
3388 # is added before the port PREFIX library path.
3389 CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib
3390 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
3391 # combined with --sysroot.
3392 CD2CFLAGS+= -B${XDDESTDIR}/usr/lib
3393 # Force using libc++ for external GCC.
3394 .if defined(X_COMPILER_TYPE) && \
3395 ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
3396 CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \
3400 CD2CFLAGS+= --sysroot=${XDDESTDIR}/
3401 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \
3402 CPP="${CPP} ${CD2CFLAGS}" \
3403 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
3405 CDTMP= ${OBJTOP}/${XDDIR}/tmp
3406 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${CDMAKEARGS} ${NOFUN}
3407 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} \
3408 ${MAKE} ${CD2MAKEARGS} ${NOFUN}
3409 .if ${MK_META_MODE} != "no"
3410 # Don't rebuild build-tools targets during normal build.
3411 CD2MAKE+= BUILD_TOOLS_META=.NOMETA
3413 XDDESTDIR=${DESTDIR}${XDTP}
3415 .ORDER: xdev-build xdev-install xdev-links
3416 xdev: xdev-build xdev-install .PHONY
3418 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
3419 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
3421 _xb-worldtmp: .PHONY
3422 mkdir -p ${CDTMP}/usr
3423 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
3424 -p ${CDTMP}/usr >/dev/null
3426 _xb-bootstrap-tools: .PHONY
3430 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
3431 cd ${.CURDIR}/${_tool}; \
3432 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
3433 ${CDMAKE} DIRPRFX=${_tool}/ all; \
3434 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
3437 _xb-build-tools: .PHONY
3438 ${_+_}@cd ${.CURDIR}; \
3439 ${CDBENV} ${MAKE} ${CDMAKEARGS} -f Makefile.inc1 ${NOFUN} build-tools
3448 _xb-cross-tools: .PHONY
3449 .for _tool in ${XDEVDIRS}
3450 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
3451 cd ${.CURDIR}/${_tool}; \
3452 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
3453 ${CDMAKE} DIRPRFX=${_tool}/ all
3457 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
3458 mkdir -p ${XDDESTDIR}
3459 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.root.dist \
3460 -p ${XDDESTDIR} >/dev/null
3461 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
3462 -p ${XDDESTDIR}/usr >/dev/null
3463 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
3464 -p ${XDDESTDIR}/usr/include >/dev/null
3465 .if defined(_LIBCOMPAT)
3466 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
3467 -p ${XDDESTDIR}/usr >/dev/null
3469 .if ${MK_TESTS} != "no"
3470 mkdir -p ${XDDESTDIR}${TESTSBASE}
3471 ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
3472 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
3475 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
3476 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
3478 _xi-cross-tools: .PHONY
3479 @echo "_xi-cross-tools"
3480 .for _tool in ${XDEVDIRS}
3481 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
3482 cd ${.CURDIR}/${_tool}; \
3483 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
3486 _xi-includes: .PHONY
3487 .if !defined(NO_OBJWALK)
3488 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 _obj \
3489 DESTDIR=${XDDESTDIR}
3491 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
3492 DESTDIR=${XDDESTDIR}
3494 _xi-libraries: .PHONY
3495 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
3496 DESTDIR=${XDDESTDIR}
3499 ${_+_}cd ${XDDESTDIR}/usr/bin; \
3500 mkdir -p ../../../../usr/bin; \
3502 ln -sf ../../${XDTP}/usr/bin/$$i \
3503 ../../../../usr/bin/${XDDIR}-$$i; \
3504 ln -sf ../../${XDTP}/usr/bin/$$i \
3505 ../../../../usr/bin/${XDDIR}${_REVISION}-$$i; \