4 # Make command line options:
5 # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6 # -DNO_CLEAN do not clean at all
7 # -DDB_FROM_SRC use the user/group databases in src/etc instead of
8 # the system database when installing.
9 # -DNO_SHARE do not go into share subdir
10 # -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,OBJ}
11 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
12 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
13 # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
14 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
15 # -DNO_ROOT install without using root privilege
16 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
17 # -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects
18 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
19 # LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list
20 # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
21 # LOCAL_MTREE="list of mtree files" to process to allow local directories
22 # to be created before files are installed
23 # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
25 # LOCAL_XTOOL_DIRS="list of dirs" to add additional dirs to the
27 # METALOG="path to metadata log" to write permission and ownership
28 # when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
29 # TARGET="machine" to crossbuild world for a different machine type
30 # TARGET_ARCH= may be required when a TARGET supports multiple endians
31 # BUILDENV_SHELL= shell to launch for the buildenv target (def:${SHELL})
32 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
33 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
34 # SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
35 # All libraries and includes, and some build tools will still build.
38 # The intended user-driven targets are:
39 # buildworld - rebuild *everything*, including glue to help do upgrades
40 # installworld- install everything built by "buildworld"
41 # checkworld - run test suite on installed world
42 # doxygen - build API documentation of the kernel
43 # update - convenient way to update your source tree (eg: svn/svnup)
45 # Standard targets (not defined here) are documented in the makefiles in
46 # /usr/share/mk. These include:
47 # obj depend all install clean cleandepend cleanobj
49 .if !defined(TARGET) || !defined(TARGET_ARCH)
50 .error "Both TARGET and TARGET_ARCH must be defined."
54 LOCALBASE?= /usr/local
56 # Cross toolchain changes must be in effect before bsd.compiler.mk
57 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
58 .if defined(CROSS_TOOLCHAIN)
59 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
60 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
62 .if defined(CROSS_TOOLCHAIN_PREFIX)
63 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
66 XCOMPILERS= CC CXX CPP
67 .for COMPILER in ${XCOMPILERS}
68 .if defined(CROSS_COMPILER_PREFIX)
69 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
71 X${COMPILER}?= ${${COMPILER}}
74 # If a full path to an external cross compiler is given, don't build
76 .if ${XCC:N${CCACHE_BIN}:M/*}
77 MK_CLANG_BOOTSTRAP= no
81 # Pull in compiler metadata from buildworld/toolchain if possible to avoid
82 # running CC from bsd.compiler.mk.
83 .if make(installworld) || make(install) || make(distributeworld) || \
85 .-include "${OBJTOP}/compiler-metadata.mk"
88 # Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early. Pull it from the
89 # tree to be friendlier to foreign OS builds. It's safe to do so unconditionally
90 # here since we will always have the right make, unlike in src/Makefile
91 .include "share/mk/bsd.compiler.mk"
92 .include "share/mk/src.opts.mk"
94 # Check if there is a local compiler that can satisfy as an external compiler.
95 # Which compiler is expected to be used?
96 .if ${MK_CLANG_BOOTSTRAP} == "yes"
97 WANT_COMPILER_TYPE= clang
98 .elif ${MK_GCC_BOOTSTRAP} == "yes"
99 WANT_COMPILER_TYPE= gcc
103 .if !defined(WANT_COMPILER_FREEBSD_VERSION)
104 .if ${WANT_COMPILER_TYPE} == "clang"
105 WANT_COMPILER_FREEBSD_VERSION_FILE= lib/clang/freebsd_cc_version.h
106 WANT_COMPILER_FREEBSD_VERSION!= \
107 awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
108 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
109 WANT_COMPILER_VERSION_FILE= lib/clang/include/clang/Basic/Version.inc
110 WANT_COMPILER_VERSION!= \
111 awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
112 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
113 .elif ${WANT_COMPILER_TYPE} == "gcc"
114 WANT_COMPILER_FREEBSD_VERSION_FILE= gnu/usr.bin/cc/cc_tools/freebsd-native.h
115 WANT_COMPILER_FREEBSD_VERSION!= \
116 awk '$$2 == "FBSD_CC_VER" {printf("%d\n", $$3)}' \
117 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
118 WANT_COMPILER_VERSION_FILE= contrib/gcc/BASE-VER
119 WANT_COMPILER_VERSION!= \
120 awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3}' \
121 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
123 .export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION
124 .endif # !defined(WANT_COMPILER_FREEBSD_VERSION)
125 # It needs to be the same revision as we would build for the bootstrap.
126 # If the expected vs CC is different then we can't skip.
127 # GCC cannot be used for cross-arch yet. For clang we pass -target later if
128 # TARGET_ARCH!=MACHINE_ARCH.
129 .if ${MK_SYSTEM_COMPILER} == "yes" && \
130 (${MK_CLANG_BOOTSTRAP} == "yes" || ${MK_GCC_BOOTSTRAP} == "yes") && \
131 !make(showconfig) && !make(xdev*) && \
132 ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE} && \
133 (${COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \
134 ${COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \
135 ${COMPILER_FREEBSD_VERSION} == ${WANT_COMPILER_FREEBSD_VERSION}
136 # Everything matches, disable the bootstrap compiler.
137 MK_CLANG_BOOTSTRAP= no
139 USING_SYSTEM_COMPILER= yes
140 .endif # ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE}
141 USING_SYSTEM_COMPILER?= no
142 TEST_SYSTEM_COMPILER_VARS= \
143 USING_SYSTEM_COMPILER MK_SYSTEM_COMPILER \
144 MK_CROSS_COMPILER MK_CLANG_BOOTSTRAP MK_GCC_BOOTSTRAP \
145 WANT_COMPILER_TYPE WANT_COMPILER_VERSION WANT_COMPILER_VERSION_FILE \
146 WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \
147 CC COMPILER_TYPE COMPILER_FEATURES COMPILER_VERSION \
148 COMPILER_FREEBSD_VERSION \
149 X_COMPILER_TYPE X_COMPILER_FEATURES X_COMPILER_VERSION \
150 X_COMPILER_FREEBSD_VERSION \
151 LINKER_TYPE LINKER_FEATURES LINKER_VERSION \
152 X_LINKER_TYPE X_LINKER_FEATURES X_LINKER_VERSION
153 test-system-compiler: .PHONY
154 .for v in ${TEST_SYSTEM_COMPILER_VARS}
155 ${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}"
157 .if ${USING_SYSTEM_COMPILER} == "yes" && \
158 (make(buildworld) || make(buildkernel) || make(kernel-toolchain) || \
159 make(toolchain) || make(_cross-tools))
160 .info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler.
163 # For installworld need to ensure that the looked-up compiler metadata is
164 # passed along rather than trying to run cc from the restricted
166 .if ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
167 .if !defined(X_COMPILER_TYPE)
168 CROSSENV+= COMPILER_VERSION=${COMPILER_VERSION} \
169 COMPILER_TYPE=${COMPILER_TYPE} \
170 COMPILER_FEATURES="${COMPILER_FEATURES}" \
171 COMPILER_FREEBSD_VERSION=${COMPILER_FREEBSD_VERSION}
173 CROSSENV+= COMPILER_VERSION=${X_COMPILER_VERSION} \
174 COMPILER_FEATURES="${X_COMPILER_FEATURES}" \
175 COMPILER_TYPE=${X_COMPILER_TYPE} \
176 COMPILER_FREEBSD_VERSION=${X_COMPILER_FREEBSD_VERSION}
179 # Store some compiler metadata for use in installworld where we don't
180 # want to invoke CC at all.
181 _COMPILER_METADATA_VARS= COMPILER_VERSION \
184 COMPILER_FREEBSD_VERSION \
188 compiler-metadata.mk: .PHONY .META
190 @echo ".info Using cached compiler metadata from build at $$(hostname) on $$(date)" \
192 .for v in ${_COMPILER_METADATA_VARS}
193 @echo "${v}=${${v}}" >> ${.TARGET}
195 @echo ".export ${_COMPILER_METADATA_VARS}" >> ${.TARGET}
197 # Handle external binutils.
198 .if defined(CROSS_TOOLCHAIN_PREFIX)
199 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
201 # If we do not have a bootstrap binutils (because the in-tree one does not
202 # support the target architecture), provide a default cross-binutils prefix.
203 # This allows riscv64 builds, for example, to automatically use the
204 # riscv64-binutils port or package.
205 .if !make(showconfig)
206 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
207 ${MK_LLD_BOOTSTRAP} == "no" && \
208 !defined(CROSS_BINUTILS_PREFIX)
209 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
210 .if !exists(${CROSS_BINUTILS_PREFIX})
211 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
215 XBINUTILS= AS AR LD NM OBJCOPY RANLIB SIZE STRINGS
216 .for BINUTIL in ${XBINUTILS}
217 .if defined(CROSS_BINUTILS_PREFIX) && \
218 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
219 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
221 X${BINUTIL}?= ${${BINUTIL}}
226 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
227 # keep the users system reasonably usable. For static->dynamic root upgrades,
228 # we don't want to install a dynamic binary without rtld and the needed
229 # libraries. More commonly, for dynamic root, we don't want to install a
230 # binary that requires a newer library version that hasn't been installed yet.
231 # This ordering is not a guarantee though. The only guarantee of a working
232 # system here would require fine-grained ordering of all components based
233 # on their dependencies.
234 .if !empty(SUBDIR_OVERRIDE)
235 SUBDIR= ${SUBDIR_OVERRIDE}
238 .if !defined(NO_ROOT) && (make(installworld) || make(install))
239 # Ensure libraries are installed before progressing.
243 .if ${MK_CDDL} != "no"
247 .if ${MK_KERBEROS} != "no"
250 .if ${MK_RESCUE} != "no"
254 .if ${MK_CRYPT} != "no"
257 .if !defined(NO_SHARE)
260 .if ${MK_BOOT} != "no"
263 SUBDIR+=sys usr.bin usr.sbin
264 .if ${MK_TESTS} != "no"
267 .if ${MK_OFED} != "no"
271 # Local directories are built in parallel with the base system directories.
272 # Users may insert a .WAIT directive at the beginning or elsewhere within
273 # the LOCAL_DIRS and LOCAL_LIB_DIRS lists as needed.
274 .for _DIR in ${LOCAL_DIRS}
275 .if ${_DIR} == ".WAIT" || exists(${.CURDIR}/${_DIR}/Makefile)
279 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
280 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
281 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
282 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
283 _REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
285 .for _DIR in ${LOCAL_LIB_DIRS}
286 .if ${_DIR} == ".WAIT" || (empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
291 # We must do etc/ last as it hooks into building the man whatis file
292 # by calling 'makedb' in share/man. This is only relevant for
293 # install/distribute so they build the whatis file after every manpage is
295 .if make(installworld) || make(install)
300 .endif # !empty(SUBDIR_OVERRIDE)
303 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
306 .if defined(NO_CLEANDIR)
307 CLEANDIR= clean cleandepend
312 .if defined(WORLDFAST)
317 .if ${MK_META_MODE} == "yes"
318 # If filemon is used then we can rely on the build being incremental-safe.
319 # The .meta files will also track the build command and rebuild should
321 .if empty(.MAKE.MODE:Mnofilemon)
325 .if defined(NO_OBJWALK) || ${MK_AUTO_OBJ} == "yes"
329 .if !defined(NO_OBJWALK)
334 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
336 .if empty(SHELL:M*csh*)
337 BUILDENV_SHELL?=${SHELL}
339 BUILDENV_SHELL?=/bin/sh
342 .if !defined(SVN_CMD) || empty(SVN_CMD)
343 . for _P in /usr/bin /usr/local/bin
344 . for _S in svn svnlite
345 . if exists(${_P}/${_S})
353 .if !defined(VCS_REVISION) || empty(VCS_REVISION)
354 .if !defined(SVNVERSION_CMD) || empty(SVNVERSION_CMD)
355 . for _D in ${PATH:S,:, ,g}
356 . if exists(${_D}/svnversion)
357 SVNVERSION_CMD?=${_D}/svnversion
359 . if exists(${_D}/svnliteversion)
360 SVNVERSION_CMD?=${_D}/svnliteversion
364 _VCS_REVISION?= $$(eval ${SVNVERSION_CMD} ${SRCDIR})
365 . if !empty(_VCS_REVISION)
366 VCS_REVISION= $$(echo r${_VCS_REVISION})
371 .if !defined(OSRELDATE)
372 .if exists(/usr/include/osreldate.h)
373 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
374 /usr/include/osreldate.h
381 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
382 .if !defined(_REVISION)
383 _REVISION!= ${MAKE} -C ${SRCDIR}/release MK_AUTO_OBJ=no -V REVISION
386 .if !defined(_BRANCH)
387 _BRANCH!= ${MAKE} -C ${SRCDIR}/release MK_AUTO_OBJ=no -V BRANCH
390 .if !defined(SRCRELDATE)
391 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
392 ${SRCDIR}/sys/sys/param.h
395 .if !defined(VERSION)
396 VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
400 .if !defined(PKG_VERSION)
401 .if ${_BRANCH:MSTABLE*} || ${_BRANCH:MCURRENT*} || ${_BRANCH:MALPHA*}
402 TIMENOW= %Y%m%d%H%M%S
403 EXTRA_REVISION= .s${TIMENOW:gmtime}
406 EXTRA_REVISION= _${_BRANCH:C/.*-p([0-9]+$)/\1/}
408 PKG_VERSION= ${_REVISION}${EXTRA_REVISION}
411 KNOWN_ARCHES?= aarch64/arm64 \
435 .if ${TARGET} == ${TARGET_ARCH}
438 _t= ${TARGET_ARCH}/${TARGET}
441 .if empty(KNOWN_ARCHES:M${_t})
442 .error Unknown target ${TARGET_ARCH}:${TARGET}.
446 .if ${TARGET} == ${MACHINE}
447 TARGET_CPUTYPE?=${CPUTYPE}
452 .if !empty(TARGET_CPUTYPE)
453 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
455 _TARGET_CPUTYPE=dummy
457 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} -f /dev/null \
458 -m ${.CURDIR}/share/mk MK_AUTO_OBJ=no -V CPUTYPE
459 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
460 .error CPUTYPE global should be set with ?=.
463 BUILD_ARCH!= uname -p
464 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
465 .error To cross-build, set TARGET_ARCH.
468 WORLDTMP?= ${OBJTOP}/tmp
469 BPATH= ${CCACHE_WRAPPER_PATH_PFX}${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
470 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
471 STRICTTMPPATH= ${BPATH}:${XPATH}
472 TMPPATH= ${STRICTTMPPATH}:${PATH}
475 # Avoid running mktemp(1) unless actually needed.
476 # It may not be functional, e.g., due to new ABI
477 # when in the middle of installing over this system.
479 .if make(distributeworld) || make(installworld) || make(stageworld)
480 INSTALLTMP!= mktemp -d -u -t install
483 .if make(stagekernel) || make(distributekernel)
489 # Building a world goes through the following stages
491 # 1. legacy stage [BMAKE]
492 # This stage is responsible for creating compatibility
493 # shims that are needed by the bootstrap-tools,
494 # build-tools and cross-tools stages. These are generally
495 # APIs that tools from one of those three stages need to
496 # build that aren't present on the host.
497 # 1. bootstrap-tools stage [BMAKE]
498 # This stage is responsible for creating programs that
499 # are needed for backward compatibility reasons. They
500 # are not built as cross-tools.
501 # 2. build-tools stage [TMAKE]
502 # This stage is responsible for creating the object
503 # tree and building any tools that are needed during
504 # the build process. Some programs are listed during
505 # this phase because they build binaries to generate
506 # files needed to build these programs. This stage also
507 # builds the 'build-tools' target rather than 'all'.
508 # 3. cross-tools stage [XMAKE]
509 # This stage is responsible for creating any tools that
510 # are needed for building the system. A cross-compiler is one
511 # of them. This differs from build tools in two ways:
512 # 1. the 'all' target is built rather than 'build-tools'
513 # 2. these tools are installed into TMPPATH for stage 4.
514 # 4. world stage [WMAKE]
515 # This stage actually builds the world.
516 # 5. install stage (optional) [IMAKE]
517 # This stage installs a previously built world.
521 # Keep these in sync -- see below for special case exception
522 MINIMUM_SUPPORTED_OSREL?= 900044
523 MINIMUM_SUPPORTED_REL?= 9.1
525 # Common environment for world related stages
527 MACHINE_ARCH=${TARGET_ARCH} \
529 CPUTYPE=${TARGET_CPUTYPE}
530 .if ${MK_META_MODE} != "no"
531 # Don't rebuild build-tools targets during normal build.
532 CROSSENV+= BUILD_TOOLS_META=.NOMETA
534 .if defined(TARGET_CFLAGS)
535 CROSSENV+= ${TARGET_CFLAGS}
538 # bootstrap-tools stage
539 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
540 TOOLS_PREFIX=${WORLDTMP} \
541 PATH=${BPATH}:${PATH} \
542 WORLDTMP=${WORLDTMP} \
543 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
544 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
546 OBJTOP='${WORLDTMP}/obj-tools' \
547 OBJROOT='$${OBJTOP}/' \
549 BOOTSTRAPPING=${OSRELDATE} \
550 BWPHASE=${.TARGET:C,^_,,} \
552 MK_HTML=no NO_LINT=yes MK_MAN=no \
553 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
554 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
555 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
556 MK_LLDB=no MK_TESTS=no \
557 MK_LLD=${MK_LLD_BOOTSTRAP} \
561 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
566 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
567 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
569 BOOTSTRAPPING=${OSRELDATE} \
570 BWPHASE=${.TARGET:C,^_,,} \
573 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
574 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
575 MK_LLDB=no MK_TESTS=no
578 # TOOLS_PREFIX set in BMAKE
580 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
581 MK_GDB=no MK_LLD_IS_LD=${MK_LLD_BOOTSTRAP} MK_TESTS=no
584 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
585 PATH=${BPATH}:${PATH} \
587 KTMAKE= TOOLS_PREFIX=${WORLDTMP} \
588 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
590 OBJTOP='${WORLDTMP}/obj-kernel-tools' \
591 OBJROOT='$${OBJTOP}/' \
593 BOOTSTRAPPING=${OSRELDATE} \
595 MK_HTML=no -DNO_LINT MK_MAN=no \
596 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
597 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
600 WMAKEENV= ${CROSSENV} \
601 INSTALL="sh ${.CURDIR}/tools/install.sh" \
606 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
608 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
611 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
612 CPP="${XCPP} ${XCFLAGS}" \
613 AS="${XAS}" AR="${XAR}" LD="${XLD}" LLVM_LINK="${XLLVM_LINK}" \
614 NM=${XNM} OBJCOPY="${XOBJCOPY}" \
615 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
618 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
619 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
620 # directory, but the compiler will look in the right place for its
621 # tools so we don't need to tell it where to look.
622 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
626 # The internal bootstrap compiler has a default sysroot set by TOOLS_PREFIX
627 # and target set by TARGET/TARGET_ARCH. However, there are several needs to
628 # always pass an explicit --sysroot and -target.
629 # - External compiler needs sysroot and target flags.
630 # - External ld needs sysroot.
631 # - To be clear about the use of a sysroot when using the internal compiler.
632 # - Easier debugging.
633 # - Allowing WITH_SYSTEM_COMPILER+WITH_META_MODE to work together due to
634 # the flip-flopping build command when sometimes using external and
635 # sometimes using internal.
636 # - Allow using lld which has no support for default paths.
637 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
638 BFLAGS+= -B${WORLDTMP}/usr/bin
640 .if ${TARGET} == "arm"
641 .if ${TARGET_ARCH:Marmv[67]*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
642 TARGET_ABI= gnueabihf
647 .if ${WANT_COMPILER_TYPE} == gcc || \
648 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
649 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
650 # won't set header path and -L is used to ensure the base library path
651 # is added before the port PREFIX library path.
652 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
653 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
654 # combined with --sysroot.
655 XCFLAGS+= -B${WORLDTMP}/usr/lib
656 # Force using libc++ for external GCC.
657 .if defined(X_COMPILER_TYPE) && \
658 ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
659 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
662 .elif ${WANT_COMPILER_TYPE} == clang || \
663 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang)
664 MACHINE_ABI?= unknown
665 MACHINE_TRIPLE?=${MACHINE_ARCH:S/amd64/x86_64/:C/hf$//:S/mipsn32/mips64/}-${MACHINE_ABI}-freebsd12.0
667 TARGET_TRIPLE?= ${TARGET_ARCH:S/amd64/x86_64/:C/hf$//:S/mipsn32/mips64/}-${TARGET_ABI}-freebsd12.0
668 XCFLAGS+= -target ${TARGET_TRIPLE}
670 XCFLAGS+= --sysroot=${WORLDTMP}
676 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
677 ${TARGET_ARCH} == "powerpc64" || ${TARGET_ARCH:Mmips64*} != "")
679 .include "Makefile.libcompat"
680 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH:Marmv[67]*} != ""
682 .include "Makefile.libcompat"
685 # META_MODE normally ignores host file changes since every build updates
686 # timestamps (see NO_META_IGNORE_HOST in sys.mk). There are known times
687 # when the ABI breaks though that we want to force rebuilding WORLDTMP
688 # to get updated host tools.
689 .if ${MK_META_MODE} == "yes" && defined(NO_CLEAN) && \
690 !defined(NO_META_IGNORE_HOST) && !defined(NO_META_IGNORE_HOST_HEADERS) && \
692 # r318736 - ino64 major ABI breakage
693 META_MODE_BAD_ABI_VERS+= 1200031
695 .if !defined(OBJDIR_HOST_OSRELDATE)
696 .if exists(${OBJTOP}/host-osreldate.h)
697 OBJDIR_HOST_OSRELDATE!= \
698 awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
699 ${OBJTOP}/host-osreldate.h
700 .elif exists(${WORLDTMP}/usr/include/osreldate.h)
701 OBJDIR_HOST_OSRELDATE= 0
703 .export OBJDIR_HOST_OSRELDATE
706 # Note that this logic is the opposite of normal BOOTSTRAP handling. We want
707 # to compare the WORLDTMP's OSRELDATE to the host's OSRELDATE. If the WORLDTMP
708 # is older than the ABI-breakage OSRELDATE of the HOST then we rebuild.
709 .if defined(OBJDIR_HOST_OSRELDATE)
710 .for _ver in ${META_MODE_BAD_ABI_VERS}
711 .if ${OSRELDATE} >= ${_ver} && ${OBJDIR_HOST_OSRELDATE} < ${_ver}
712 _meta_mode_need_rebuild= ${_ver}
715 .if defined(_meta_mode_need_rebuild)
716 .info META_MODE: Rebuilding host tools due to ABI breakage in __FreeBSD_version ${_meta_mode_need_rebuild}.
717 NO_META_IGNORE_HOST_HEADERS= 1
718 .export NO_META_IGNORE_HOST_HEADERS
719 .endif # defined(_meta_mode_need_rebuild)
720 .endif # defined(OBJDIR_HOST_OSRELDATE)
721 .endif # ${MK_META_MODE} == "yes" && defined(NO_CLEAN) ...
722 # This is only used for META_MODE+filemon to track what the oldest
723 # __FreeBSD_version is in WORLDTMP. This purposely does NOT have
724 # a make dependency on /usr/include/osreldate.h as the file should
725 # only be copied when it is missing or meta mode determines it has changed.
726 # Since host files are normally ignored without NO_META_IGNORE_HOST
727 # the file will never be updated unless that flag is specified. This
728 # allows tracking the oldest osreldate to force rebuilds via
729 # META_MODE_BADABI_REVS above.
730 host-osreldate.h: # DO NOT ADD /usr/include/osreldate.h here
731 @cp -f /usr/include/osreldate.h ${.TARGET}
733 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
734 BWPHASE=${.TARGET:C,^_,,} \
737 IMAKEENV= ${CROSSENV}
738 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
739 ${IMAKE_INSTALL} ${IMAKE_MTREE}
740 .if empty(.MAKEFLAGS:M-n)
741 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
742 LD_LIBRARY_PATH=${INSTALLTMP} \
743 PATH_LOCALE=${INSTALLTMP}/locale
744 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
746 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
748 .if defined(DB_FROM_SRC)
749 INSTALLFLAGS+= -N ${.CURDIR}/etc
750 MTREEFLAGS+= -N ${.CURDIR}/etc
752 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
753 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
755 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
756 METALOG:= ${METALOG:C,//+,/,g}
757 IMAKE+= -DNO_ROOT METALOG=${METALOG}
758 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
761 .if defined(BUILD_PKGS)
762 INSTALLFLAGS+= -h sha256
764 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
765 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
766 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
770 KMAKEENV= ${WMAKEENV:NSYSROOT=*}
771 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
776 # Attempt to rebuild the entire system, with reasonable chance of
777 # success, regardless of how old your existing system is.
779 _sanity_check: .PHONY .MAKE
780 .if ${.CURDIR:C/[^,]//g} != ""
781 # The m4 build of sendmail files doesn't like it if ',' is used
782 # anywhere in the path of it's files.
784 @echo "*** Error: path to source tree contains a comma ','"
787 .elif ${.CURDIR:M*\:*} != ""
788 # Using ':' leaks into PATH and breaks finding cross-tools.
790 @echo "*** Error: path to source tree contains a colon ':'"
795 # Our current approach to dependency tracking cannot cope with certain source
796 # tree changes, particularly with respect to removing source files and
797 # replacing generated files. Handle these cases here in an ad-hoc fashion.
798 _cleanobj_fast_depend_hack: .PHONY
799 # Syscall stubs rewritten in C
800 # Date SVN Rev Syscalls
801 # 20160829 r305012 ptrace
802 # 20170624 r320278 fstat fstatat fstatfs getdirentries getfsstat statfs
803 .for f in fstat fstatat fstatfs getdirentries getfsstat ptrace statfs
804 .if exists(${OBJTOP}/lib/libc/.depend.${f}.o)
805 @if egrep -qw '${f}\.[sS]' \
806 ${OBJTOP}/lib/libc/.depend.${f}.o; then \
807 echo Removing stale dependencies for ${f} syscall wrappers; \
808 rm -f ${OBJTOP}/lib/libc/.depend.${f}.* \
809 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \
813 # 20170607 remove stale dependencies for utimens* wrappers removed in r319663
814 .for f in futimens utimensat
815 .if exists(${OBJTOP}/lib/libc/.depend.${f}.o)
816 @if egrep -q '/${f}.c' \
817 ${OBJTOP}/lib/libc/.depend.${f}.o; then \
818 echo Removing stale dependencies for ${f} syscall wrappers; \
819 rm -f ${OBJTOP}/lib/libc/.depend.${f}.* \
820 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \
824 # 20170523 remove stale generated asm files for functions which are no longer
825 # syscalls after r302092 (pipe) and r318736 (others)
826 .for f in getdents lstat mknod pipe stat
827 .if exists(${OBJTOP}/lib/libc/${f}.s) || \
828 exists(${OBJTOP}/lib/libc/${f}.S)
829 @echo Removing stale generated ${f} syscall files
830 @rm -f ${OBJTOP}/lib/libc/${f}.* \
831 ${OBJTOP}/lib/libc/.depend.${f}.* \
832 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/${f}.*} \
833 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}
839 @echo "--------------------------------------------------------------"
840 @echo ">>> Rebuilding the temporary build tree"
841 @echo "--------------------------------------------------------------"
842 .if !defined(NO_CLEAN)
845 .if exists(${WORLDTMP})
846 @echo ">>> Deleting stale files in build tree..."
847 ${_+_}cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \
848 delete-old delete-old-libs >/dev/null
850 rm -rf ${WORLDTMP}/legacy/usr/include
851 .if ${USING_SYSTEM_COMPILER} == "yes"
853 if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \
854 inum=$$(stat -f %i ${WORLDTMP}/usr/bin/${cc}); \
855 find ${WORLDTMP}/usr/bin -inum $${inum} -delete; \
858 .endif # ${USING_SYSTEM_COMPILER} == "yes"
859 .endif # !defined(NO_CLEAN)
860 @mkdir -p ${WORLDTMP}
861 @touch ${WORLDTMP}/${.TARGET}
864 lib lib/casper usr legacy/bin legacy/usr
865 mkdir -p ${WORLDTMP}/${_dir}
867 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
868 -p ${WORLDTMP}/legacy/usr >/dev/null
869 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
870 -p ${WORLDTMP}/legacy/usr/include >/dev/null
871 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
872 -p ${WORLDTMP}/usr >/dev/null
873 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
874 -p ${WORLDTMP}/usr/include >/dev/null
875 ln -sf ${.CURDIR}/sys ${WORLDTMP}
876 .if ${MK_DEBUG_FILES} != "no"
877 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
878 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
879 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
880 -p ${WORLDTMP}/usr/lib >/dev/null
882 .for _mtree in ${LOCAL_MTREE}
883 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
887 @echo "--------------------------------------------------------------"
888 @echo ">>> stage 1.1: legacy release compatibility shims"
889 @echo "--------------------------------------------------------------"
890 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
893 @echo "--------------------------------------------------------------"
894 @echo ">>> stage 1.2: bootstrap tools"
895 @echo "--------------------------------------------------------------"
896 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
898 .if !defined(NO_CLEAN)
900 @echo "--------------------------------------------------------------"
901 @echo ">>> stage 2.1: cleaning up the object tree"
902 @echo "--------------------------------------------------------------"
903 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
904 .if defined(LIBCOMPAT)
905 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
908 ${_+_}cd ${.CURDIR}; ${WMAKE} _cleanobj_fast_depend_hack
909 .endif # !defined(NO_CLEAN)
912 @echo "--------------------------------------------------------------"
913 @echo ">>> stage 2.2: rebuilding the object tree"
914 @echo "--------------------------------------------------------------"
915 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
918 @echo "--------------------------------------------------------------"
919 @echo ">>> stage 2.3: build tools"
920 @echo "--------------------------------------------------------------"
921 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
924 @echo "--------------------------------------------------------------"
925 @echo ">>> stage 3: cross tools"
926 @echo "--------------------------------------------------------------"
927 @rm -f ${OBJTOP}/compiler-metadata.mk
928 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
929 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
932 @echo "--------------------------------------------------------------"
933 @echo ">>> stage 3.1: recording build metadata"
934 @echo "--------------------------------------------------------------"
935 ${_+_}cd ${.CURDIR}; ${WMAKE} compiler-metadata.mk
936 ${_+_}cd ${.CURDIR}; ${WMAKE} host-osreldate.h
939 @echo "--------------------------------------------------------------"
940 @echo ">>> stage 4.1: building includes"
941 @echo "--------------------------------------------------------------"
942 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
943 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
944 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
945 MK_INCLUDES=yes includes
946 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
947 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
951 @echo "--------------------------------------------------------------"
952 @echo ">>> stage 4.2: building libraries"
953 @echo "--------------------------------------------------------------"
954 ${_+_}cd ${.CURDIR}; \
955 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
956 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
959 @echo "--------------------------------------------------------------"
960 @echo ">>> stage 4.3: building everything"
961 @echo "--------------------------------------------------------------"
962 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
965 .if !defined(WORLDFAST)
966 WMAKE_TGTS+= _sanity_check _worldtmp _legacy
967 .if empty(SUBDIR_OVERRIDE)
968 WMAKE_TGTS+= _bootstrap-tools
970 WMAKE_TGTS+= _cleanobj
971 .if !defined(NO_OBJWALK)
974 WMAKE_TGTS+= _build-tools _cross-tools
975 WMAKE_TGTS+= _build-metadata
976 WMAKE_TGTS+= _includes
978 .if !defined(NO_LIBS)
979 WMAKE_TGTS+= _libraries
981 WMAKE_TGTS+= everything
982 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
983 WMAKE_TGTS+= build${libcompat}
986 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
987 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
989 buildworld_prologue: .PHONY
990 @echo "--------------------------------------------------------------"
991 @echo ">>> World build started on `LC_ALL=C date`"
992 @echo "--------------------------------------------------------------"
994 buildworld_epilogue: .PHONY
996 @echo "--------------------------------------------------------------"
997 @echo ">>> World build completed on `LC_ALL=C date`"
998 @echo "--------------------------------------------------------------"
1001 # We need to have this as a target because the indirection between Makefile
1002 # and Makefile.inc1 causes the correct PATH to be used, rather than a
1003 # modification of the current environment's PATH. In addition, we need
1004 # to quote multiword values.
1006 buildenvvars: .PHONY
1007 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
1009 .if ${.TARGETS:Mbuildenv}
1010 .if ${.MAKEFLAGS:M-j}
1011 .error The buildenv target is incompatible with -j
1014 BUILDENV_DIR?= ${.CURDIR}
1016 # Note: make will report any errors the shell reports. This can
1017 # be odd if the last command in an interactive shell generates an
1018 # error or is terminated by SIGINT. These reported errors look bad,
1019 # but are harmless. Allowing them also allows BUIDLENV_SHELL to
1020 # be a complex command whose status will be returned to the caller.
1021 # Some scripts in tools rely on this behavior to report build errors.
1024 @echo Entering world for ${TARGET_ARCH}:${TARGET}
1025 .if ${BUILDENV_SHELL:M*zsh*}
1026 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
1028 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL}
1030 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
1031 toolchain: ${TOOLCHAIN_TGTS} .PHONY
1032 KERNEL_TOOLCHAIN_TGTS= ${TOOLCHAIN_TGTS:N_obj:N_cleanobj:N_includes:N_libraries}
1033 .if make(kernel-toolchain)
1034 .ORDER: ${KERNEL_TOOLCHAIN_TGTS}
1036 kernel-toolchain: ${KERNEL_TOOLCHAIN_TGTS} .PHONY
1041 # Checks to be sure system is ready for installworld/installkernel.
1043 installcheck: _installcheck_world _installcheck_kernel .PHONY
1044 _installcheck_world: .PHONY
1045 _installcheck_kernel: .PHONY
1048 # Require DESTDIR to be set if installing for a different architecture or
1049 # using the user/group database in the source tree.
1051 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
1052 defined(DB_FROM_SRC)
1053 .if !make(distributeworld)
1054 _installcheck_world: __installcheck_DESTDIR
1055 _installcheck_kernel: __installcheck_DESTDIR
1056 __installcheck_DESTDIR: .PHONY
1057 .if !defined(DESTDIR) || empty(DESTDIR)
1058 @echo "ERROR: Please set DESTDIR!"; \
1064 .if !defined(DB_FROM_SRC)
1066 # Check for missing UIDs/GIDs.
1068 CHECK_UIDS= auditdistd
1070 .if ${MK_SENDMAIL} != "no"
1074 .if ${MK_PF} != "no"
1076 CHECK_GIDS+= proxy authpf
1078 .if ${MK_UNBOUND} != "no"
1079 CHECK_UIDS+= unbound
1080 CHECK_GIDS+= unbound
1082 _installcheck_world: __installcheck_UGID
1083 __installcheck_UGID: .PHONY
1084 .for uid in ${CHECK_UIDS}
1085 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
1086 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
1090 .for gid in ${CHECK_GIDS}
1091 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
1092 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
1098 # If installing over the running system (DESTDIR is / or unset) and the install
1099 # includes rescue, try running rescue from the objdir as a sanity check. If
1100 # rescue is not functional (e.g., because it depends on a system call not
1101 # supported by the currently running kernel), abort the installation.
1103 .if !make(distributeworld) && ${MK_RESCUE} != "no" && \
1104 (empty(DESTDIR) || ${DESTDIR} == "/") && empty(BYPASS_INSTALLCHECK_SH)
1105 _installcheck_world: __installcheck_sh_check
1106 __installcheck_sh_check: .PHONY
1107 @if [ "`${OBJTOP}/rescue/rescue/rescue sh -c 'echo OK'`" != \
1109 echo "rescue/sh check failed, installation aborted" >&2; \
1115 # Required install tools to be saved in a scratch dir for safety.
1117 .if ${MK_ZONEINFO} != "no"
1118 _zoneinfo= zic tzsetup
1121 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
1122 date echo egrep find grep id install ${_install-info} \
1123 ln make mkdir mtree mv pwd_mkdb \
1124 rm sed services_mkdb sh sort strip sysctl test true uname wc ${_zoneinfo} \
1127 # Needed for share/man
1128 .if ${MK_MAN_UTILS} != "no"
1135 # Distributes everything compiled by a `buildworld'.
1139 # Installs everything compiled by a 'buildworld'.
1142 # Non-base distributions produced by the base system
1143 EXTRA_DISTRIBUTIONS= doc
1144 .if defined(LIBCOMPAT)
1145 EXTRA_DISTRIBUTIONS+= lib${libcompat}
1147 .if ${MK_TESTS} != "no"
1148 EXTRA_DISTRIBUTIONS+= tests
1151 DEBUG_DISTRIBUTIONS=
1152 .if ${MK_DEBUG_FILES} != "no"
1153 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
1156 MTREE_MAGIC?= mtree 2.0
1158 distributeworld installworld stageworld: _installcheck_world .PHONY
1159 mkdir -p ${INSTALLTMP}
1160 progs=$$(for prog in ${ITOOLS}; do \
1161 if progpath=`which $$prog`; then \
1164 echo "Required tool $$prog not found in PATH." >&2; \
1168 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
1169 while read line; do \
1171 if [ "$$2 $$3" != "not found" ]; then \
1174 echo "Required library $$1 not found." >&2; \
1178 cp $$libs $$progs ${INSTALLTMP}
1179 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
1180 .if defined(NO_ROOT)
1181 -mkdir -p ${METALOG:H}
1182 echo "#${MTREE_MAGIC}" > ${METALOG}
1184 .if make(distributeworld)
1185 .for dist in ${EXTRA_DISTRIBUTIONS}
1186 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
1187 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1188 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
1189 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1190 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1191 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1192 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
1193 .if ${MK_DEBUG_FILES} != "no"
1194 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1195 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
1197 .if defined(LIBCOMPAT)
1198 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1199 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1200 .if ${MK_DEBUG_FILES} != "no"
1201 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1202 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
1205 .if ${MK_TESTS} != "no" && ${dist} == "tests"
1206 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
1207 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1208 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
1209 .if ${MK_DEBUG_FILES} != "no"
1210 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1211 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
1214 .if defined(NO_ROOT)
1215 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1216 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1217 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1218 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1219 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1220 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1221 .if defined(LIBCOMPAT)
1222 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
1223 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1227 -mkdir ${DESTDIR}/${DISTDIR}/base
1228 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1229 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1230 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1231 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1233 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1234 ${IMAKEENV} rm -rf ${INSTALLTMP}
1235 .if make(distributeworld)
1236 .for dist in ${EXTRA_DISTRIBUTIONS}
1237 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete
1239 .if defined(NO_ROOT)
1240 .for dist in base ${EXTRA_DISTRIBUTIONS}
1241 @# For each file that exists in this dist, print the corresponding
1242 @# line from the METALOG. This relies on the fact that
1243 @# a line containing only the filename will sort immediately before
1244 @# the relevant mtree line.
1245 cd ${DESTDIR}/${DISTDIR}; \
1246 find ./${dist} | sort -u ${METALOG} - | \
1247 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1248 ${DESTDIR}/${DISTDIR}/${dist}.meta
1250 .for dist in ${DEBUG_DISTRIBUTIONS}
1251 @# For each file that exists in this dist, print the corresponding
1252 @# line from the METALOG. This relies on the fact that
1253 @# a line containing only the filename will sort immediately before
1254 @# the relevant mtree line.
1255 cd ${DESTDIR}/${DISTDIR}; \
1256 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1257 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1258 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1263 packageworld: .PHONY
1264 .for dist in base ${EXTRA_DISTRIBUTIONS}
1265 .if defined(NO_ROOT)
1266 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1267 tar cvf - --exclude usr/lib/debug \
1268 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1269 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1271 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1272 tar cvf - --exclude usr/lib/debug . | \
1273 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1277 .for dist in ${DEBUG_DISTRIBUTIONS}
1278 . if defined(NO_ROOT)
1279 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1280 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1281 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1283 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1284 tar cvLf - usr/lib/debug | \
1285 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1292 # If you have a build server, you can NFS mount the source and obj directories
1293 # and do a 'make reinstall' on the *client* to install new binaries from the
1294 # most recent server build.
1296 restage reinstall: .MAKE .PHONY
1297 @echo "--------------------------------------------------------------"
1298 @echo ">>> Making hierarchy"
1299 @echo "--------------------------------------------------------------"
1300 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1301 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1303 @echo "--------------------------------------------------------------"
1304 @echo ">>> Making distribution"
1305 @echo "--------------------------------------------------------------"
1306 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1307 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
1310 @echo "--------------------------------------------------------------"
1311 @echo ">>> Installing everything"
1312 @echo "--------------------------------------------------------------"
1313 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1314 .if defined(LIBCOMPAT)
1315 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1318 redistribute: .MAKE .PHONY
1319 @echo "--------------------------------------------------------------"
1320 @echo ">>> Distributing everything"
1321 @echo "--------------------------------------------------------------"
1322 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1323 .if defined(LIBCOMPAT)
1324 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1325 DISTRIBUTION=lib${libcompat}
1328 distrib-dirs distribution: .MAKE .PHONY
1329 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1330 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1331 .if make(distribution)
1332 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1333 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1334 METALOG=${METALOG} MK_TESTS=no installconfig
1338 # buildkernel and installkernel
1340 # Which kernels to build and/or install is specified by setting
1341 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1342 # Only the existing (depending TARGET) config files are used
1343 # for building kernels and only the first of these is designated
1344 # as the one being installed.
1346 # Note that we have to use TARGET instead of TARGET_ARCH when
1347 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1348 # be set to cross-build, we have to make sure TARGET is set
1351 .if defined(KERNFAST)
1355 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1356 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1357 KERNCONF=${KERNFAST}
1360 .if ${TARGET_ARCH} == "powerpc64"
1361 KERNCONF?= GENERIC64
1365 INSTKERNNAME?= kernel
1367 KERNSRCDIR?= ${.CURDIR}/sys
1368 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1369 KRNLOBJDIR= ${OBJTOP}${KERNSRCDIR:C,^${.CURDIR},,}
1370 KERNCONFDIR?= ${KRNLCONFDIR}
1374 .if defined(NO_INSTALLKERNEL)
1375 # All of the BUILDKERNELS loops start at index 1.
1376 BUILDKERNELS+= dummy
1378 .for _kernel in ${KERNCONF}
1379 .if exists(${KERNCONFDIR}/${_kernel})
1380 BUILDKERNELS+= ${_kernel}
1381 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1382 INSTALLKERNEL= ${_kernel}
1385 .if make(buildkernel)
1386 .error Missing KERNCONF ${KERNCONFDIR}/${_kernel}
1391 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1396 # Builds all kernels defined by BUILDKERNELS.
1398 buildkernel: .MAKE .PHONY
1399 .if empty(BUILDKERNELS:Ndummy)
1400 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1404 .for _kernel in ${BUILDKERNELS:Ndummy}
1405 @echo "--------------------------------------------------------------"
1406 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1407 @echo "--------------------------------------------------------------"
1408 @echo "===> ${_kernel}"
1409 mkdir -p ${KRNLOBJDIR}
1410 .if !defined(NO_KERNELCONFIG)
1412 @echo "--------------------------------------------------------------"
1413 @echo ">>> stage 1: configuring the kernel"
1414 @echo "--------------------------------------------------------------"
1415 cd ${KRNLCONFDIR}; \
1417 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1418 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1420 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1422 @echo "--------------------------------------------------------------"
1423 @echo ">>> stage 2.1: cleaning up the object tree"
1424 @echo "--------------------------------------------------------------"
1425 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1427 .if !defined(NO_KERNELOBJ)
1429 @echo "--------------------------------------------------------------"
1430 @echo ">>> stage 2.2: rebuilding the object tree"
1431 @echo "--------------------------------------------------------------"
1432 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1435 @echo "--------------------------------------------------------------"
1436 @echo ">>> stage 2.3: build tools"
1437 @echo "--------------------------------------------------------------"
1438 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1440 @echo "--------------------------------------------------------------"
1441 @echo ">>> stage 3.1: building everything"
1442 @echo "--------------------------------------------------------------"
1443 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1444 @echo "--------------------------------------------------------------"
1445 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1446 @echo "--------------------------------------------------------------"
1449 NO_INSTALLEXTRAKERNELS?= yes
1452 # installkernel, etc.
1454 # Install the kernel defined by INSTALLKERNEL
1456 installkernel installkernel.debug \
1457 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1458 .if !defined(NO_INSTALLKERNEL)
1459 .if empty(INSTALLKERNEL)
1460 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1463 @echo "--------------------------------------------------------------"
1464 @echo ">>> Installing kernel ${INSTALLKERNEL} on $$(LC_ALL=C date)"
1465 @echo "--------------------------------------------------------------"
1466 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1467 ${CROSSENV} PATH=${TMPPATH} \
1468 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1469 @echo "--------------------------------------------------------------"
1470 @echo ">>> Installing kernel ${INSTALLKERNEL} completed on $$(LC_ALL=C date)"
1471 @echo "--------------------------------------------------------------"
1473 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1474 .for _kernel in ${BUILDKERNELS:[2..-1]}
1475 @echo "--------------------------------------------------------------"
1476 @echo ">>> Installing kernel ${_kernel} $$(LC_ALL=C date)"
1477 @echo "--------------------------------------------------------------"
1478 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
1479 ${CROSSENV} PATH=${TMPPATH} \
1480 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1481 @echo "--------------------------------------------------------------"
1482 @echo ">>> Installing kernel ${_kernel} completed on $$(LC_ALL=C date)"
1483 @echo "--------------------------------------------------------------"
1487 distributekernel distributekernel.debug: .PHONY
1488 .if !defined(NO_INSTALLKERNEL)
1489 .if empty(INSTALLKERNEL)
1490 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1493 mkdir -p ${DESTDIR}/${DISTDIR}
1494 .if defined(NO_ROOT)
1495 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1497 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1498 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1499 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1500 DESTDIR=${INSTALL_DDIR}/kernel \
1501 ${.TARGET:S/distributekernel/install/}
1502 .if defined(NO_ROOT)
1503 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1504 ${DESTDIR}/${DISTDIR}/kernel.meta
1507 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1508 .for _kernel in ${BUILDKERNELS:[2..-1]}
1509 .if defined(NO_ROOT)
1510 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1512 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
1513 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1514 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1515 KERNEL=${INSTKERNNAME}.${_kernel} \
1516 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1517 ${.TARGET:S/distributekernel/install/}
1518 .if defined(NO_ROOT)
1519 @sed -e "s|^./kernel.${_kernel}|.|" \
1520 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1521 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1526 packagekernel: .PHONY
1527 .if defined(NO_ROOT)
1528 .if !defined(NO_INSTALLKERNEL)
1529 cd ${DESTDIR}/${DISTDIR}/kernel; \
1530 tar cvf - --exclude '*.debug' \
1531 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1532 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1534 .if ${MK_DEBUG_FILES} != "no"
1535 cd ${DESTDIR}/${DISTDIR}/kernel; \
1536 tar cvf - --include '*/*/*.debug' \
1537 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1538 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1540 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1541 .for _kernel in ${BUILDKERNELS:[2..-1]}
1542 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1543 tar cvf - --exclude '*.debug' \
1544 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1545 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1546 .if ${MK_DEBUG_FILES} != "no"
1547 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1548 tar cvf - --include '*/*/*.debug' \
1549 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1550 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1555 .if !defined(NO_INSTALLKERNEL)
1556 cd ${DESTDIR}/${DISTDIR}/kernel; \
1557 tar cvf - --exclude '*.debug' . | \
1558 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1560 .if ${MK_DEBUG_FILES} != "no"
1561 cd ${DESTDIR}/${DISTDIR}/kernel; \
1562 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1563 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1565 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1566 .for _kernel in ${BUILDKERNELS:[2..-1]}
1567 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1568 tar cvf - --exclude '*.debug' . | \
1569 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1570 .if ${MK_DEBUG_FILES} != "no"
1571 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1572 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1573 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1580 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1582 PORTSDIR?= /usr/ports
1583 WSTAGEDIR?= ${OBJTOP}/worldstage
1584 KSTAGEDIR?= ${OBJTOP}/kernelstage
1585 REPODIR?= ${OBJROOT}repo
1586 PKGSIGNKEY?= # empty
1588 .ORDER: stage-packages create-packages
1589 .ORDER: create-packages create-world-packages
1590 .ORDER: create-packages create-kernel-packages
1591 .ORDER: create-packages sign-packages
1593 _pkgbootstrap: .PHONY
1594 .if !exists(${LOCALBASE}/sbin/pkg)
1595 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1599 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1602 rm -rf /tmp/ports.${TARGET} || :
1603 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
1604 PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \
1605 WSTAGEDIR=${WSTAGEDIR} \
1606 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1608 real-packages: stage-packages create-packages sign-packages .PHONY
1610 stage-packages-world: .PHONY
1611 @mkdir -p ${WSTAGEDIR}
1612 ${_+_}@cd ${.CURDIR}; \
1613 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT stageworld
1615 stage-packages-kernel: .PHONY
1616 @mkdir -p ${KSTAGEDIR}
1617 ${_+_}@cd ${.CURDIR}; \
1618 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT stagekernel
1620 stage-packages: .PHONY stage-packages-world stage-packages-kernel
1623 @mkdir -p ${REPODIR}
1625 create-packages-world: _pkgbootstrap _repodir .PHONY
1626 ${_+_}@cd ${.CURDIR}; \
1627 ${MAKE} -f Makefile.inc1 \
1628 DESTDIR=${WSTAGEDIR} \
1629 PKG_VERSION=${PKG_VERSION} create-world-packages
1631 create-packages-kernel: _pkgbootstrap _repodir .PHONY
1632 ${_+_}@cd ${.CURDIR}; \
1633 ${MAKE} -f Makefile.inc1 \
1634 DESTDIR=${KSTAGEDIR} \
1635 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1636 create-kernel-packages
1638 create-packages: .PHONY create-packages-world create-packages-kernel
1640 create-world-packages: _pkgbootstrap .PHONY
1641 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1642 @cd ${WSTAGEDIR} ; \
1643 env -i LC_COLLATE=C sort ${WSTAGEDIR}/METALOG | \
1644 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk
1645 @for plist in ${WSTAGEDIR}/*.plist; do \
1646 plist=$${plist##*/} ; \
1647 pkgname=$${plist%.plist} ; \
1648 echo "_PKGS+= $${pkgname}" ; \
1649 done > ${WSTAGEDIR}/packages.mk
1650 ${_+_}@cd ${.CURDIR}; \
1651 ${MAKE} -f Makefile.inc1 create-world-packages-jobs \
1654 .if make(create-world-packages-jobs)
1655 .include "${WSTAGEDIR}/packages.mk"
1658 create-world-packages-jobs: .PHONY
1659 .for pkgname in ${_PKGS}
1660 create-world-packages-jobs: create-world-package-${pkgname}
1661 create-world-package-${pkgname}: .PHONY
1662 @sh ${SRCDIR}/release/packages/generate-ucl.sh -o ${pkgname} \
1663 -s ${SRCDIR} -u ${WSTAGEDIR}/${pkgname}.ucl
1665 /^name/ { printf("===> Creating %s-", $$2); next } \
1666 /^version/ { print $$2; next } \
1667 ' ${WSTAGEDIR}/${pkgname}.ucl
1668 @if [ "${pkgname}" == "runtime" ]; then \
1669 sed -i '' -e "s/%VCS_REVISION%/${VCS_REVISION}/" ${WSTAGEDIR}/${pkgname}.ucl ; \
1671 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1672 create -M ${WSTAGEDIR}/${pkgname}.ucl \
1673 -p ${WSTAGEDIR}/${pkgname}.plist \
1675 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1678 create-kernel-packages: .PHONY
1679 _default_flavor= -default
1680 .if exists(${KSTAGEDIR}/kernel.meta)
1681 . if ${MK_DEBUG_FILES} != "no"
1684 . for flavor in "" ${_debug}
1685 create-kernel-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}
1686 create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY
1687 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1688 env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.meta | \
1689 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1690 -v kernel=yes -v _kernconf=${INSTALLKERNEL} ; \
1691 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1692 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1693 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1694 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1695 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1696 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1697 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1698 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1699 -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \
1700 ${SRCDIR}/release/packages/kernel.ucl \
1701 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1703 /name/ { printf("===> Creating %s-", $$2); next } \
1704 /version/ {print $$2; next } ' \
1705 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1706 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1707 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1708 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1709 -r ${KSTAGEDIR}/${DISTDIR} \
1710 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1713 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1714 . for _kernel in ${BUILDKERNELS:[2..-1]}
1715 . if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1716 . if ${MK_DEBUG_FILES} != "no"
1719 . for flavor in "" ${_debug}
1720 create-kernel-packages: create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}
1721 create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}: _pkgbootstrap .PHONY
1722 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1723 env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.${_kernel}.meta | \
1724 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1725 -v kernel=yes -v _kernconf=${_kernel} ; \
1726 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1727 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1728 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1729 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1730 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1731 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1732 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1733 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1734 -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \
1735 ${SRCDIR}/release/packages/kernel.ucl \
1736 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1738 /name/ { printf("===> Creating %s-", $$2); next } \
1739 /version/ {print $$2; next } ' \
1740 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1741 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1742 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1743 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1744 -r ${KSTAGEDIR}/kernel.${_kernel} \
1745 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1751 sign-packages: _pkgbootstrap .PHONY
1752 @[ -L "${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1753 unlink ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1754 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1755 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1756 ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1758 cd ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI); \
1759 ln -s ${PKG_VERSION} latest
1765 # Run test suite on installed world.
1768 @if [ ! -x "${LOCALBASE}/bin/kyua" ]; then \
1769 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1772 ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile
1778 # Build the API documentation with doxygen
1781 @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \
1782 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1785 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1790 # Update the source tree(s), by running svn/svnup to update to the
1794 .if defined(SVN_UPDATE)
1795 @echo "--------------------------------------------------------------"
1796 @echo ">>> Updating ${.CURDIR} using Subversion"
1797 @echo "--------------------------------------------------------------"
1798 @(cd ${.CURDIR}; ${SVN_CMD} update ${SVNFLAGS})
1802 # ------------------------------------------------------------------------
1804 # From here onwards are utility targets used by the 'make world' and
1805 # related targets. If your 'world' breaks, you may like to try to fix
1806 # the problem and manually run the following targets to attempt to
1807 # complete the build. Beware, this is *not* guaranteed to work, you
1808 # need to have a pretty good grip on the current state of the system
1809 # to attempt to manually finish it. If in doubt, 'make world' again.
1813 # legacy: Build compatibility shims for the next three targets. This is a
1814 # minimal set of tools and shims necessary to compensate for older systems
1815 # which don't have the APIs required by the targets built in bootstrap-tools,
1816 # build-tools or cross-tools.
1819 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1820 # r296685 fix cross-endian objcopy
1821 # r310724 fixed PR 215350, a crash in libdwarf with objects built by GCC 6.2.
1822 .if ${BOOTSTRAPPING} < 1200020
1823 _elftoolchain_libs= lib/libelf lib/libdwarf
1827 # Temporary special case for automatically detecting the clang compiler issue
1828 # Note: 9.x didn't have FreeBSD_version bumps often enough, so you may need to
1829 # set BOOTSTRAPPING to 0 if you're stable/9 tree post-dates r286035 but is before
1830 # the version bump in r296219 (from July 29, 2015 -> Feb 29, 2016).
1831 .if ${BOOTSTRAPPING} != 0 && \
1832 ${WANT_COMPILER_TYPE} == "clang" && ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} < 30601
1833 .if ${BOOTSTRAPPING} > 10000000 && ${BOOTSTRAPPING} < 1002501
1834 @echo "ERROR: Source upgrades from stable/10 prior to r286033 are not supported."; false
1835 .elif ${BOOTSTRAPPING} > 9000000 && ${BOOTSTRAPPING} < 903509
1836 @echo "ERROR: Source upgrades from stable/9 prior to r286035 are not supported."; false
1839 .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
1840 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
1844 .for _tool in tools/build ${_elftoolchain_libs}
1845 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1846 cd ${.CURDIR}/${_tool}; \
1847 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
1848 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy includes; \
1849 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
1850 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
1851 DESTDIR=${WORLDTMP}/legacy install
1855 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1856 # are built to build other binaries in the system. However, the focus of these
1857 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1858 # libraries, augmented by -legacy.
1860 _bt= _bootstrap-tools
1862 .if ${MK_GAMES} != "no"
1863 _strfile= usr.bin/fortune/strfile
1866 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1867 _gperf= gnu/usr.bin/gperf
1870 .if ${MK_VT} != "no"
1871 _vtfontcvt= usr.bin/vtfontcvt
1874 .if ${BOOTSTRAPPING} < 1000033
1878 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1879 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1882 # r245440 mtree -N support added
1883 # r313404 requires sha384.h for libnetbsd, added to libmd in r292782
1884 .if ${BOOTSTRAPPING} < 1100093
1885 _nmtree= lib/libmd \
1889 ${_bt}-lib/libnetbsd: ${_bt}-lib/libmd
1890 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1893 # r246097: log addition login.conf.db, passwd, pwd.db, and spwd.db with cat -l
1894 .if ${BOOTSTRAPPING} < 1000027
1898 # r277259 crunchide: Correct 64-bit section header offset
1899 # r281674 crunchide: always include both 32- and 64-bit ELF support
1900 .if ${BOOTSTRAPPING} < 1100078
1901 _crunchide= usr.sbin/crunch/crunchide
1904 # r285986 crunchen: use STRIPBIN rather than STRIP
1905 # 1100113: Support MK_AUTO_OBJ
1906 # 1200006: META_MODE fixes
1907 .if ${BOOTSTRAPPING} < 1100078 || \
1908 (${MK_AUTO_OBJ} == "yes" && ${BOOTSTRAPPING} < 1100114) || \
1909 (${MK_META_MODE} == "yes" && ${BOOTSTRAPPING} < 1200006)
1910 _crunchgen= usr.sbin/crunch/crunchgen
1913 # r296926 -P keymap search path, MFC to stable/10 in r298297
1914 .if ${BOOTSTRAPPING} < 1003501 || \
1915 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
1916 _kbdcontrol= usr.sbin/kbdcontrol
1922 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1924 .if ${MK_BSNMP} != "no"
1925 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1928 # We need to build tblgen when we're building clang or lld, either as
1929 # bootstrap tools, or as the part of the normal build.
1930 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
1931 ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no"
1933 lib/clang/libllvmminimal \
1934 usr.bin/clang/llvm-tblgen \
1935 usr.bin/clang/clang-tblgen
1937 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal
1938 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal
1941 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1944 .if ${MK_GPL_DTC} != "no"
1945 _dtc= gnu/usr.bin/dtc
1948 .if ${MK_KERBEROS} != "no"
1949 _kerberos5_bootstrap_tools= \
1950 kerberos5/tools/make-roken \
1951 kerberos5/lib/libroken \
1952 kerberos5/lib/libvers \
1953 kerberos5/tools/asn1_compile \
1954 kerberos5/tools/slc \
1957 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1960 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
1962 bootstrap-tools: .PHONY
1964 # Please document (add comment) why something is in 'bootstrap-tools'.
1965 # Try to bound the building of the bootstrap-tool to just the
1966 # FreeBSD versions that need the tool built at this stage of the build.
1969 ${_kerberos5_bootstrap_tools} \
1990 ${_bt}-${_tool}: .PHONY .MAKE
1991 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1992 cd ${.CURDIR}/${_tool}; \
1993 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
1994 ${MAKE} DIRPRFX=${_tool}/ all; \
1995 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy install
1997 bootstrap-tools: ${_bt}-${_tool}
2001 # build-tools: Build special purpose build tools
2003 .if !defined(NO_SHARE) && ${MK_SYSCONS} != "no"
2004 _share= share/syscons/scrnmaps
2007 .if ${MK_GCC} != "no"
2008 _gcc_tools= gnu/usr.bin/cc/cc_tools
2011 .if ${MK_RESCUE} != "no"
2012 # rescue includes programs that have build-tools targets
2013 _rescue=rescue/rescue
2016 .if ${MK_TCSH} != "no"
2019 .if ${MK_FILE} != "no"
2020 _libmagic=lib/libmagic
2023 # kernel-toolchain skips _cleanobj, so handle cleaning up previous
2024 # build-tools directories if needed.
2025 .if !defined(NO_CLEAN) && make(kernel-toolchain)
2026 _bt_clean= ${CLEANDIR}
2032 ${LOCAL_TOOL_DIRS} \
2033 lib/ncurses/ncurses \
2034 lib/ncurses/ncursesw \
2039 usr.bin/mkesdb_static \
2040 usr.bin/mkcsmapper_static \
2041 usr.bin/vi/catalog \
2043 build-tools_${_tool}: .PHONY
2044 ${_+_}@${ECHODIR} "===> ${_tool} (${_bt_clean:D${_bt_clean},}obj,build-tools)"; \
2045 cd ${.CURDIR}/${_tool}; \
2046 if [ -n "${_bt_clean}" ]; then ${MAKE} DIRPRFX=${_tool}/ ${_bt_clean}; fi; \
2047 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2048 ${MAKE} DIRPRFX=${_tool}/ build-tools
2049 build-tools: build-tools_${_tool}
2053 # kernel-tools: Build kernel-building tools
2055 kernel-tools: .PHONY
2056 mkdir -p ${WORLDTMP}/usr
2057 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2058 -p ${WORLDTMP}/usr >/dev/null
2061 # cross-tools: All the tools needed to build the rest of the system after
2062 # we get done with the earlier stages. It is the last set of tools needed
2063 # to begin building the target binaries.
2065 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
2066 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
2067 _btxld= usr.sbin/btxld
2071 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
2072 # resulting from missing bug fixes or ELF Toolchain updates.
2073 .if ${MK_CDDL} != "no"
2074 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
2075 cddl/usr.bin/ctfmerge
2078 # If we're given an XAS, don't build binutils.
2079 .if ${XAS:M/*} == ""
2080 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
2081 _binutils= gnu/usr.bin/binutils
2083 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
2084 _elftctools= lib/libelftc \
2090 # These are not required by the build, but can be useful for developers who
2091 # cross-build on a FreeBSD 10 host:
2092 _elftctools+= usr.bin/addr2line
2094 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
2095 # If cross-building with an external binutils we still need to build strip for
2096 # the target (for at least crunchide).
2097 _elftctools= lib/libelftc \
2102 .if ${MK_CLANG_BOOTSTRAP} != "no"
2103 _clang= usr.bin/clang
2105 .if ${MK_LLD_BOOTSTRAP} != "no"
2106 _lld= usr.bin/clang/lld
2108 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no"
2109 _clang_libs= lib/clang
2111 .if ${MK_GCC_BOOTSTRAP} != "no"
2112 _gcc= gnu/usr.bin/cc
2114 .if ${MK_USB} != "no"
2115 _usb_tools= stand/usb/tools
2118 cross-tools: .MAKE .PHONY
2120 ${LOCAL_XTOOL_DIRS} \
2130 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2131 cd ${.CURDIR}/${_tool}; \
2132 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2133 ${MAKE} DIRPRFX=${_tool}/ all; \
2134 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP} install
2138 # native-xtools is the current target for qemu-user cross builds of ports
2139 # via poudriere and the imgact_binmisc kernel module.
2140 # This target merely builds a toolchan/sysroot, then builds the tools it wants
2141 # with the options it wants in a special MAKEOBJDIRPREFIX, using the toolchain
2142 # already built. It then installs the static tools to NXBDESTDIR for Poudriere
2145 NXBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/nxb/
2146 NXBOBJTOP= ${NXBOBJROOT}${NXB_TARGET}.${NXB_TARGET_ARCH}
2149 .error NXTP variable should be an absolute path
2151 NXBDESTDIR?= ${DESTDIR}${NXTP}
2153 # This is the list of tools to be built/installed as static and where
2154 # appropriate to build for the given TARGET.TARGET_ARCH.
2216 SUBDIR_DEPEND_usr.bin/clang= lib/clang
2217 .if ${MK_CLANG} != "no"
2219 NXBDIRS+= usr.bin/clang
2221 .if ${MK_GCC} != "no"
2222 NXBDIRS+= gnu/usr.bin/cc
2224 .if ${MK_BINUTILS} != "no"
2225 NXBDIRS+= gnu/usr.bin/binutils
2227 # XXX: native-xtools passes along ${NXBDIRS} in SUBDIR_OVERRIDE that needs
2228 # to be evaluated after NXBDIRS is set.
2229 .if make(install) && !empty(SUBDIR_OVERRIDE)
2230 SUBDIR= ${SUBDIR_OVERRIDE}
2234 OBJTOP=${NXBOBJTOP:Q} \
2235 OBJROOT=${NXBOBJROOT:Q} \
2241 MK_CLANG_EXTRAS=no \
2259 .if make(native-xtools*) && \
2260 (!defined(NXB_TARGET) || !defined(NXB_TARGET_ARCH))
2261 .error Missing NXB_TARGET / NXB_TARGET_ARCH
2263 # For 'toolchain' we want to produce native binaries that themselves generate
2265 NXBTMAKE= ${NXBMAKEENV} ${MAKE} ${NXBMAKEARGS:N-DNO_PIC:N-DNO_SHARED} \
2266 TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH}
2267 # For 'everything' we want to produce native binaries (hence -target to
2268 # be MACHINE) that themselves generate TARGET.TARGET_ARCH binaries.
2269 # TARGET/TARGET_ARCH are still passed along from user.
2271 # Use the toolchain we create as an external toolchain.
2272 .if ${USING_SYSTEM_COMPILER} == "yes" || ${XCC:N${CCACHE_BIN}:M/*}
2273 NXBMAKE+= XCC="${XCC}" \
2277 NXBMAKE+= XCC="${NXBOBJTOP}/tmp/usr/bin/cc" \
2278 XCXX="${NXBOBJTOP}/tmp/usr/bin/c++" \
2279 XCPP="${NXBOBJTOP}/tmp/usr/bin/cpp"
2281 NXBMAKE+= ${NXBMAKEENV} ${MAKE} -f Makefile.inc1 ${NXBMAKEARGS} \
2282 TARGET=${NXB_TARGET} TARGET_ARCH=${NXB_TARGET_ARCH} \
2283 TARGET_TRIPLE=${MACHINE_TRIPLE:Q}
2284 # NXBDIRS is improperly based on MACHINE rather than NXB_TARGET. Need to
2285 # invoke a sub-make to reevaluate MK_GCC, etc, for NXBDIRS.
2286 NXBMAKE+= SUBDIR_OVERRIDE='$${NXBDIRS:M*}'
2287 # Need to avoid the -isystem logic when using clang as an external toolchain
2288 # even if the TARGET being built for wants GCC.
2289 NXBMAKE+= WANT_COMPILER_TYPE='$${X_COMPILER_TYPE}'
2290 native-xtools: .PHONY
2291 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _cleanobj MK_GCC=yes
2292 # Build the bootstrap/host/cross tools that produce native binaries
2293 # Pass along MK_GCC=yes to ensure GCC-needed build tools are built.
2294 # We don't quite know what the NXB_TARGET wants so just build it.
2295 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} kernel-toolchain MK_GCC=yes
2296 # Populate includes/libraries sysroot that produce native binaries.
2297 # This is split out from 'toolchain' above mostly so that target LLVM
2298 # libraries have a proper LLVM_DEFAULT_TARGET_TRIPLE without
2299 # polluting the cross-compiler build. The LLVM/GCC libs are skipped
2300 # here to avoid the problem but are kept in 'toolchain' so that
2301 # needed build tools are built.
2302 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes MK_CLANG=no MK_GCC=no
2303 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries MK_CLANG=no MK_GCC=no
2304 # Clean out improper TARGET=MACHINE files
2305 ${_+_}cd ${.CURDIR}/gnu/usr.bin/cc/cc_tools; ${NXBTMAKE} cleandir
2306 .if !defined(NO_OBJWALK)
2307 ${_+_}cd ${.CURDIR}; ${NXBMAKE} _obj
2309 ${_+_}cd ${.CURDIR}; ${NXBMAKE} everything
2310 @echo ">> native-xtools done. Use 'make native-xtools-install' to install to a given DESTDIR"
2312 native-xtools-install: .PHONY
2313 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
2314 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2315 -p ${NXBDESTDIR}/usr >/dev/null
2316 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2317 -p ${NXBDESTDIR}/usr/include >/dev/null
2318 ${_+_}cd ${.CURDIR}; ${NXBMAKE} \
2319 DESTDIR=${NXBDESTDIR} \
2324 # hierarchy - ensure that all the needed directories are present
2326 hierarchy hier: .MAKE .PHONY
2327 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
2330 # libraries - build all libraries, and install them under ${DESTDIR}.
2332 # The list of libraries with dependents (${_prebuild_libs}) and their
2333 # interdependencies (__L) are built automatically by the
2334 # ${.CURDIR}/tools/make_libdeps.sh script.
2336 libraries: .MAKE .PHONY
2337 ${_+_}cd ${.CURDIR}; \
2338 ${MAKE} -f Makefile.inc1 _prereq_libs; \
2339 ${MAKE} -f Makefile.inc1 _startup_libs; \
2340 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
2341 ${MAKE} -f Makefile.inc1 _generic_libs
2344 # static libgcc.a prerequisite for shared libc
2346 _prereq_libs= lib/libcompiler_rt
2347 .if ${MK_SSP} != "no"
2348 _prereq_libs+= gnu/lib/libssp/libssp_nonshared
2351 # These dependencies are not automatically generated:
2353 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
2354 # all shared libraries for ELF.
2356 _startup_libs= gnu/lib/csu
2357 _startup_libs+= lib/csu
2358 _startup_libs+= lib/libcompiler_rt
2359 _startup_libs+= lib/libc
2360 _startup_libs+= lib/libc_nonshared
2361 .if ${MK_LIBCPLUSPLUS} != "no"
2362 _startup_libs+= lib/libcxxrt
2365 .if ${MK_LLVM_LIBUNWIND} != "no"
2366 _prereq_libs+= lib/libgcc_eh lib/libgcc_s
2367 _startup_libs+= lib/libgcc_eh lib/libgcc_s
2369 lib/libgcc_s__L: lib/libc__L
2370 lib/libgcc_s__L: lib/libc_nonshared__L
2371 .if ${MK_LIBCPLUSPLUS} != "no"
2372 lib/libcxxrt__L: lib/libgcc_s__L
2375 .else # MK_LLVM_LIBUNWIND == no
2377 _prereq_libs+= gnu/lib/libgcc
2378 _startup_libs+= gnu/lib/libgcc
2380 gnu/lib/libgcc__L: lib/libc__L
2381 gnu/lib/libgcc__L: lib/libc_nonshared__L
2382 .if ${MK_LIBCPLUSPLUS} != "no"
2383 lib/libcxxrt__L: gnu/lib/libgcc__L
2387 _prebuild_libs= ${_kerberos5_lib_libasn1} \
2388 ${_kerberos5_lib_libhdb} \
2389 ${_kerberos5_lib_libheimbase} \
2390 ${_kerberos5_lib_libheimntlm} \
2392 ${_kerberos5_lib_libheimipcc} \
2393 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
2394 ${_kerberos5_lib_libroken} \
2395 ${_kerberos5_lib_libwind} \
2396 lib/libbz2 ${_libcom_err} lib/libcrypt \
2397 lib/libelf lib/libexpat \
2400 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
2402 lib/ncurses/ncurses lib/ncurses/ncursesw \
2403 lib/libopie lib/libpam/libpam ${_lib_libthr} \
2404 ${_lib_libradius} lib/libsbuf lib/libtacplus \
2406 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
2407 ${_cddl_lib_libuutil} \
2408 ${_cddl_lib_libavl} \
2409 ${_cddl_lib_libzfs_core} \
2410 ${_cddl_lib_libctf} \
2411 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
2412 ${_secure_lib_libcrypto} ${_lib_libldns} \
2413 ${_secure_lib_libssh} ${_secure_lib_libssl}
2415 .if ${MK_GNUCXX} != "no"
2416 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
2417 gnu/lib/libstdc++__L: lib/msun__L
2418 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
2421 .if ${MK_DIALOG} != "no"
2422 _prebuild_libs+= gnu/lib/libdialog
2423 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2426 .if ${MK_LIBCPLUSPLUS} != "no"
2427 _prebuild_libs+= lib/libc++
2430 lib/libgeom__L: lib/libexpat__L
2431 lib/libkvm__L: lib/libelf__L
2433 .if ${MK_LIBTHR} != "no"
2434 _lib_libthr= lib/libthr
2437 .if ${MK_RADIUS_SUPPORT} != "no"
2438 _lib_libradius= lib/libradius
2441 .if ${MK_OFED} != "no"
2443 # The OFED libraries are built in four steps
2444 # as reflected below, due to interdependencies.
2446 # NOTE: Depending on contrib/ofed/include is only needed for
2447 # the lib32 compat build.
2450 contrib/ofed/include \
2451 contrib/ofed/usr.lib/0 \
2452 contrib/ofed/usr.lib/1 \
2453 contrib/ofed/usr.lib/2 \
2454 contrib/ofed/usr.lib/3
2456 contrib/ofed/usr.lib/0__L: contrib/ofed/include__L lib/libthr__L
2457 contrib/ofed/usr.lib/1__L: contrib/ofed/usr.lib/0__L
2458 contrib/ofed/usr.lib/2__L: contrib/ofed/usr.lib/1__L
2459 contrib/ofed/usr.lib/3__L: contrib/ofed/usr.lib/2__L
2462 .if ${MK_CASPER} != "no"
2463 _lib_casper= lib/libcasper
2466 lib/libpjdlog__L: lib/libutil__L
2467 lib/libcasper__L: lib/libnv__L
2468 lib/liblzma__L: lib/libthr__L
2470 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
2471 .if ${MK_IPFILTER} != "no"
2472 _generic_libs+= sbin/ipf/libipf
2474 .for _DIR in ${LOCAL_LIB_DIRS}
2475 .if ${_DIR} == ".WAIT" || (empty(_generic_libs:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
2476 _generic_libs+= ${_DIR}
2480 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2482 .if ${MK_CDDL} != "no"
2483 _cddl_lib_libumem= cddl/lib/libumem
2484 _cddl_lib_libnvpair= cddl/lib/libnvpair
2485 _cddl_lib_libavl= cddl/lib/libavl
2486 _cddl_lib_libuutil= cddl/lib/libuutil
2487 .if ${MK_ZFS} != "no"
2488 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2489 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2491 _cddl_lib_libctf= cddl/lib/libctf
2493 cddl/lib/libctf__L: lib/libz__L
2495 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
2496 # on select architectures though (see cddl/lib/Makefile)
2497 .if ${MACHINE_CPUARCH} != "sparc64"
2498 _prebuild_libs+= lib/libprocstat lib/libproc lib/librtld_db
2499 lib/libprocstat__L: lib/libelf__L lib/libkvm__L lib/libutil__L
2500 lib/libproc__L: lib/libprocstat__L
2501 lib/librtld_db__L: lib/libprocstat__L
2504 .if ${MK_CRYPT} != "no"
2505 .if ${MK_OPENSSL} != "no"
2506 _secure_lib_libcrypto= secure/lib/libcrypto
2507 _secure_lib_libssl= secure/lib/libssl
2508 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2509 .if ${MK_LDNS} != "no"
2510 _lib_libldns= lib/libldns
2511 lib/libldns__L: secure/lib/libcrypto__L
2513 .if ${MK_OPENSSH} != "no"
2514 _secure_lib_libssh= secure/lib/libssh
2515 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2516 .if ${MK_LDNS} != "no"
2517 secure/lib/libssh__L: lib/libldns__L
2519 .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no"
2520 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2521 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2522 lib/libmd__L kerberos5/lib/libroken__L
2526 _secure_lib= secure/lib
2529 .if ${MK_KERBEROS} != "no"
2530 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2531 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2532 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2533 kerberos5/lib/libwind__L lib/libsqlite3__L
2534 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2535 kerberos5/lib/libroken__L lib/libcom_err__L
2536 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2537 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2538 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2539 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2540 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2541 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2542 kerberos5/lib/libroken__L: lib/libcrypt__L
2543 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2544 kerberos5/lib/libheimbase__L: lib/libthr__L
2545 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2548 lib/libsqlite3__L: lib/libthr__L
2550 .if ${MK_GSSAPI} != "no"
2551 _lib_libgssapi= lib/libgssapi
2554 .if ${MK_KERBEROS} != "no"
2555 _kerberos5_lib= kerberos5/lib
2556 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2557 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2558 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2559 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2560 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2561 _kerberos5_lib_libroken= kerberos5/lib/libroken
2562 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2563 _libsqlite3= lib/libsqlite3
2564 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2565 _kerberos5_lib_libwind= kerberos5/lib/libwind
2566 _libcom_err= lib/libcom_err
2569 .if ${MK_NIS} != "no"
2570 _lib_libypclnt= lib/libypclnt
2573 .if ${MK_OPENSSL} == "no"
2574 lib/libradius__L: lib/libmd__L
2578 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2579 .if ${MK_CXX} != "no"
2580 .if ${MK_LIBCPLUSPLUS} != "no"
2581 lib/libproc__L: lib/libcxxrt__L
2582 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2583 lib/libproc__L: gnu/lib/libsupc++__L
2587 .for _lib in ${_prereq_libs}
2588 ${_lib}__PL: .PHONY .MAKE
2589 .if exists(${.CURDIR}/${_lib})
2590 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2591 cd ${.CURDIR}/${_lib}; \
2592 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
2593 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2594 DIRPRFX=${_lib}/ all; \
2595 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2596 DIRPRFX=${_lib}/ install
2600 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
2601 ${_lib}__L: .PHONY .MAKE
2602 .if exists(${.CURDIR}/${_lib})
2603 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2604 cd ${.CURDIR}/${_lib}; \
2605 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
2606 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2607 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2611 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2612 _startup_libs: ${_startup_libs:S/$/__L/}
2613 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2614 _generic_libs: ${_generic_libs:S/$/__L/}
2616 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2617 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2618 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2619 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2620 # parallel. This is safe for the world stage of buildworld though since it has
2621 # already built libraries in a proper order and installed includes into
2622 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2623 # avoid trashing a system if it crashes mid-install.
2624 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2628 .include <bsd.subdir.mk>
2630 .if make(check-old) || make(check-old-dirs) || \
2631 make(check-old-files) || make(check-old-libs) || \
2632 make(delete-old) || make(delete-old-dirs) || \
2633 make(delete-old-files) || make(delete-old-libs)
2636 # check for / delete old files section
2639 .include "ObsoleteFiles.inc"
2641 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2642 else you can not start such an application. Consult UPDATING for more \
2643 information regarding how to cope with the removal/revision bump of a \
2646 .if !defined(BATCH_DELETE_OLD_FILES)
2652 delete-old-files: .PHONY
2653 @echo ">>> Removing old files (only deletes safe to delete libs)"
2654 # Ask for every old file if the user really wants to remove it.
2655 # It's annoying, but better safe than sorry.
2656 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2657 # argument list will get too long. Using .for/.endfor make "loops" will make
2658 # the Makefile parser segfault.
2661 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2662 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2663 while read file; do \
2664 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2665 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2666 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2668 for ext in debug symbols; do \
2669 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2670 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2671 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2676 # Remove catpages without corresponding manpages.
2678 find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \
2679 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2680 while read catpage; do \
2682 if [ ! -e "$${manpage}" ]; then \
2683 rm ${RM_I} $${catpage} <&3; \
2686 @echo ">>> Old files removed"
2688 check-old-files: .PHONY
2689 @echo ">>> Checking for old files"
2691 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2692 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2693 while read file; do \
2694 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2695 echo "${DESTDIR}/$${file}"; \
2697 for ext in debug symbols; do \
2698 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2699 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2703 # Check for catpages without corresponding manpages.
2704 @find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \
2705 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2706 while read catpage; do \
2708 if [ ! -e "$${manpage}" ]; then \
2713 delete-old-libs: .PHONY
2714 @echo ">>> Removing old libraries"
2715 @echo "${OLD_LIBS_MESSAGE}" | fmt
2718 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2719 -V OLD_LIBS | xargs -n1 | \
2720 while read file; do \
2721 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2722 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2723 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2725 for ext in debug symbols; do \
2726 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2727 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2728 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2733 @echo ">>> Old libraries removed"
2735 check-old-libs: .PHONY
2736 @echo ">>> Checking for old libraries"
2738 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2739 -V OLD_LIBS | xargs -n1 | \
2740 while read file; do \
2741 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2742 echo "${DESTDIR}/$${file}"; \
2744 for ext in debug symbols; do \
2745 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2746 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2751 delete-old-dirs: .PHONY
2752 @echo ">>> Removing old directories"
2754 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2755 -V OLD_DIRS | xargs -n1 | sort -r | \
2756 while read dir; do \
2757 if [ -d "${DESTDIR}/$${dir}" ]; then \
2758 rmdir -v "${DESTDIR}/$${dir}" || true; \
2759 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2760 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2762 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2763 rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \
2764 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2765 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2768 @echo ">>> Old directories removed"
2770 check-old-dirs: .PHONY
2771 @echo ">>> Checking for old directories"
2773 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2774 -V OLD_DIRS | xargs -n1 | \
2775 while read dir; do \
2776 if [ -d "${DESTDIR}/$${dir}" ]; then \
2777 echo "${DESTDIR}/$${dir}"; \
2778 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2779 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2781 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2782 echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \
2783 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2784 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2788 delete-old: delete-old-files delete-old-dirs .PHONY
2789 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2791 check-old: check-old-files check-old-libs check-old-dirs .PHONY
2792 @echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
2793 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2798 # showconfig - show build configuration.
2801 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes; \
2802 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes) 2>&1 | grep ^MK_ | sort -u
2804 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2805 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2807 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2808 .if exists(${KERNCONFDIR}/${KERNCONF})
2809 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2810 '${KERNCONFDIR}/${KERNCONF}' ; echo
2816 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2817 DTBOUTPUTPATH= ${.CURDIR}
2821 # Build 'standalone' Device Tree Blob
2824 @PATH=${TMPPATH} MACHINE=${TARGET} \
2825 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2826 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2831 # In the following, the first 'rm' in a series will usually remove all
2832 # files and directories. If it does not, then there are probably some
2833 # files with file flags set, so this unsets them and tries the 'rm' a
2834 # second time. There are situations where this target will be cleaning
2835 # some directories via more than one method, but that duplication is
2836 # needed to correctly handle all the possible situations. Removing all
2837 # files without file flags set in the first 'rm' instance saves time,
2838 # because 'chflags' will need to operate on fewer files afterwards.
2840 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2841 # created by bsd.obj.mk, except that we don't want to .include that file
2842 # in this makefile. We don't do a cleandir walk if MK_AUTO_OBJ is yes
2843 # since it is not possible for files to land in the wrong place.
2845 .if make(cleanworld)
2846 BW_CANONICALOBJDIR:=${OBJTOP}/
2847 .elif make(cleanuniverse)
2848 BW_CANONICALOBJDIR:=${OBJROOT}
2849 .if ${MK_UNIFIED_OBJDIR} == "no"
2850 .error ${.TARGETS} only supported with WITH_UNIFIED_OBJDIR enabled.
2853 cleanworld cleanuniverse: .PHONY
2854 .if !empty(BW_CANONICALOBJDIR) && exists(${BW_CANONICALOBJDIR}) && \
2855 ${.CURDIR:tA} != ${BW_CANONICALOBJDIR:tA}
2856 -rm -rf ${BW_CANONICALOBJDIR}*
2857 -chflags -R 0 ${BW_CANONICALOBJDIR}
2858 rm -rf ${BW_CANONICALOBJDIR}*
2860 .if make(cleanworld) && ${MK_AUTO_OBJ} == "no" && \
2861 (empty(BW_CANONICALOBJDIR) || ${.CURDIR:tA} == ${BW_CANONICALOBJDIR:tA})
2862 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2863 # To be safe in this case, fall back to a 'make cleandir'
2864 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2868 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2869 XDEV_CPUTYPE?=${CPUTYPE}
2871 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2874 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2875 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2876 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2877 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2878 CPUTYPE=${XDEV_CPUTYPE}
2880 XDDIR=${TARGET_ARCH}-freebsd
2883 .error XDTP variable should be an absolute path
2886 CDBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/xdev/
2887 CDBOBJTOP= ${CDBOBJROOT}${XDDIR}
2889 INSTALL="sh ${.CURDIR}/tools/install.sh"
2891 TOOLS_PREFIX=${XDTP}
2893 OBJTOP=${CDBOBJTOP:Q} \
2894 OBJROOT=${CDBOBJROOT:Q}
2895 CD2MAKEARGS= ${CDMAKEARGS}
2897 .if ${WANT_COMPILER_TYPE} == gcc || \
2898 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
2899 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
2900 # won't set header path and -L is used to ensure the base library path
2901 # is added before the port PREFIX library path.
2902 CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib
2903 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
2904 # combined with --sysroot.
2905 CD2CFLAGS+= -B${XDDESTDIR}/usr/lib
2906 # Force using libc++ for external GCC.
2907 .if defined(X_COMPILER_TYPE) && \
2908 ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
2909 CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \
2913 CD2CFLAGS+= --sysroot=${XDDESTDIR}/
2914 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \
2915 CPP="${CPP} ${CD2CFLAGS}" \
2916 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2918 CDTMP= ${OBJTOP}/${XDDIR}/tmp
2919 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${CDMAKEARGS} ${NOFUN}
2920 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} \
2921 ${MAKE} ${CD2MAKEARGS} ${NOFUN}
2922 .if ${MK_META_MODE} != "no"
2923 # Don't rebuild build-tools targets during normal build.
2924 CD2MAKE+= BUILD_TOOLS_META=.NOMETA
2926 XDDESTDIR=${DESTDIR}${XDTP}
2928 .ORDER: xdev-build xdev-install xdev-links
2929 xdev: xdev-build xdev-install .PHONY
2931 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2932 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
2934 _xb-worldtmp: .PHONY
2935 mkdir -p ${CDTMP}/usr
2936 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2937 -p ${CDTMP}/usr >/dev/null
2939 _xb-bootstrap-tools: .PHONY
2944 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2945 cd ${.CURDIR}/${_tool}; \
2946 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
2947 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2948 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2951 _xb-build-tools: .PHONY
2952 ${_+_}@cd ${.CURDIR}; \
2953 ${CDBENV} ${MAKE} ${CDMAKEARGS} -f Makefile.inc1 ${NOFUN} build-tools
2964 _xb-cross-tools: .PHONY
2965 .for _tool in ${XDEVDIRS}
2966 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2967 cd ${.CURDIR}/${_tool}; \
2968 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
2969 ${CDMAKE} DIRPRFX=${_tool}/ all
2973 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2974 mkdir -p ${XDDESTDIR}
2975 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2976 -p ${XDDESTDIR} >/dev/null
2977 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2978 -p ${XDDESTDIR}/usr >/dev/null
2979 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2980 -p ${XDDESTDIR}/usr/include >/dev/null
2981 .if defined(LIBCOMPAT)
2982 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2983 -p ${XDDESTDIR}/usr >/dev/null
2985 .if ${MK_TESTS} != "no"
2986 mkdir -p ${XDDESTDIR}${TESTSBASE}
2987 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2988 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2991 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2992 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
2994 _xi-cross-tools: .PHONY
2995 @echo "_xi-cross-tools"
2996 .for _tool in ${XDEVDIRS}
2997 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2998 cd ${.CURDIR}/${_tool}; \
2999 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
3002 _xi-includes: .PHONY
3003 .if !defined(NO_OBJWALK)
3004 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 _obj \
3005 DESTDIR=${XDDESTDIR}
3007 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
3008 DESTDIR=${XDDESTDIR}
3010 _xi-libraries: .PHONY
3011 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
3012 DESTDIR=${XDDESTDIR}
3015 ${_+_}cd ${XDDESTDIR}/usr/bin; \
3016 mkdir -p ../../../../usr/bin; \
3018 ln -sf ../../${XDTP}/usr/bin/$$i \
3019 ../../../../usr/bin/${XDDIR}-$$i; \
3020 ln -sf ../../${XDTP}/usr/bin/$$i \
3021 ../../../../usr/bin/${XDDIR}${_REVISION}-$$i; \