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.
89 .include <bsd.compiler.mk>
90 .include "share/mk/src.opts.mk"
92 # Check if there is a local compiler that can satisfy as an external compiler.
93 # Which compiler is expected to be used?
94 .if ${MK_CLANG_BOOTSTRAP} == "yes"
95 WANT_COMPILER_TYPE= clang
96 .elif ${MK_GCC_BOOTSTRAP} == "yes"
97 WANT_COMPILER_TYPE= gcc
101 .if !defined(WANT_COMPILER_FREEBSD_VERSION)
102 .if ${WANT_COMPILER_TYPE} == "clang"
103 WANT_COMPILER_FREEBSD_VERSION_FILE= lib/clang/freebsd_cc_version.h
104 WANT_COMPILER_FREEBSD_VERSION!= \
105 awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
106 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
107 WANT_COMPILER_VERSION_FILE= lib/clang/include/clang/Basic/Version.inc
108 WANT_COMPILER_VERSION!= \
109 awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
110 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
111 .elif ${WANT_COMPILER_TYPE} == "gcc"
112 WANT_COMPILER_FREEBSD_VERSION_FILE= gnu/usr.bin/cc/cc_tools/freebsd-native.h
113 WANT_COMPILER_FREEBSD_VERSION!= \
114 awk '$$2 == "FBSD_CC_VER" {printf("%d\n", $$3)}' \
115 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
116 WANT_COMPILER_VERSION_FILE= contrib/gcc/BASE-VER
117 WANT_COMPILER_VERSION!= \
118 awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3}' \
119 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
121 .export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION
122 .endif # !defined(WANT_COMPILER_FREEBSD_VERSION)
123 # It needs to be the same revision as we would build for the bootstrap.
124 # If the expected vs CC is different then we can't skip.
125 # GCC cannot be used for cross-arch yet. For clang we pass -target later if
126 # TARGET_ARCH!=MACHINE_ARCH.
127 .if ${MK_SYSTEM_COMPILER} == "yes" && \
128 (${MK_CLANG_BOOTSTRAP} == "yes" || ${MK_GCC_BOOTSTRAP} == "yes") && \
129 !make(showconfig) && !make(xdev*) && \
130 ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE} && \
131 (${COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \
132 ${COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \
133 ${COMPILER_FREEBSD_VERSION} == ${WANT_COMPILER_FREEBSD_VERSION}
134 # Everything matches, disable the bootstrap compiler.
135 MK_CLANG_BOOTSTRAP= no
137 USING_SYSTEM_COMPILER= yes
138 .endif # ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE}
139 USING_SYSTEM_COMPILER?= no
140 TEST_SYSTEM_COMPILER_VARS= \
141 USING_SYSTEM_COMPILER MK_SYSTEM_COMPILER \
142 MK_CROSS_COMPILER MK_CLANG_BOOTSTRAP MK_GCC_BOOTSTRAP \
143 WANT_COMPILER_TYPE WANT_COMPILER_VERSION WANT_COMPILER_VERSION_FILE \
144 WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \
145 CC COMPILER_TYPE COMPILER_FEATURES COMPILER_VERSION \
146 COMPILER_FREEBSD_VERSION \
147 LINKER_TYPE LINKER_VERSION
148 test-system-compiler: .PHONY
149 .for v in ${TEST_SYSTEM_COMPILER_VARS}
150 ${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}"
152 .if ${USING_SYSTEM_COMPILER} == "yes" && \
153 (make(buildworld) || make(buildkernel) || make(kernel-toolchain) || \
154 make(toolchain) || make(_cross-tools))
155 .info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler.
158 # For installworld need to ensure that the looked-up compiler metadata is
159 # passed along rather than trying to run cc from the restricted
161 .if ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
162 .if !defined(X_COMPILER_TYPE)
163 CROSSENV+= COMPILER_VERSION=${COMPILER_VERSION} \
164 COMPILER_TYPE=${COMPILER_TYPE} \
165 COMPILER_FEATURES=${COMPILER_FEATURES} \
166 COMPILER_FREEBSD_VERSION=${COMPILER_FREEBSD_VERSION}
168 CROSSENV+= COMPILER_VERSION=${X_COMPILER_VERSION} \
169 COMPILER_FEATURES=${X_COMPILER_FEATURES} \
170 COMPILER_TYPE=${X_COMPILER_TYPE} \
171 COMPILER_FREEBSD_VERSION=${X_COMPILER_FREEBSD_VERSION}
174 # Store some compiler metadata for use in installworld where we don't
175 # want to invoke CC at all.
176 _COMPILER_METADATA_VARS= COMPILER_VERSION \
179 COMPILER_FREEBSD_VERSION \
182 compiler-metadata.mk: .PHONY .META
184 @echo ".info Using cached compiler metadata from build at $$(hostname) on $$(date)" \
186 .for v in ${_COMPILER_METADATA_VARS}
187 @echo "${v}=${${v}}" >> ${.TARGET}
189 @echo ".export ${_COMPILER_METADATA_VARS}" >> ${.TARGET}
191 # Handle external binutils.
192 .if defined(CROSS_TOOLCHAIN_PREFIX)
193 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
195 # If we do not have a bootstrap binutils (because the in-tree one does not
196 # support the target architecture), provide a default cross-binutils prefix.
197 # This allows riscv64 builds, for example, to automatically use the
198 # riscv64-binutils port or package.
199 .if !make(showconfig)
200 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
201 ${MK_LLD_BOOTSTRAP} == "no" && \
202 !defined(CROSS_BINUTILS_PREFIX)
203 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
204 .if !exists(${CROSS_BINUTILS_PREFIX})
205 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
209 XBINUTILS= AS AR LD NM OBJCOPY RANLIB SIZE STRINGS
210 .for BINUTIL in ${XBINUTILS}
211 .if defined(CROSS_BINUTILS_PREFIX) && \
212 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
213 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
215 X${BINUTIL}?= ${${BINUTIL}}
220 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
221 # keep the users system reasonably usable. For static->dynamic root upgrades,
222 # we don't want to install a dynamic binary without rtld and the needed
223 # libraries. More commonly, for dynamic root, we don't want to install a
224 # binary that requires a newer library version that hasn't been installed yet.
225 # This ordering is not a guarantee though. The only guarantee of a working
226 # system here would require fine-grained ordering of all components based
227 # on their dependencies.
228 .if !empty(SUBDIR_OVERRIDE)
229 SUBDIR= ${SUBDIR_OVERRIDE}
232 .if !defined(NO_ROOT) && (make(installworld) || make(install))
233 # Ensure libraries are installed before progressing.
237 .if ${MK_CDDL} != "no"
241 .if ${MK_KERBEROS} != "no"
244 .if ${MK_RESCUE} != "no"
248 .if ${MK_CRYPT} != "no"
251 .if !defined(NO_SHARE)
254 .if ${MK_BOOT} != "no"
257 SUBDIR+=sys usr.bin usr.sbin
258 .if ${MK_TESTS} != "no"
261 .if ${MK_OFED} != "no"
265 # Local directories are built in parallel with the base system directories.
266 # Users may insert a .WAIT directive at the beginning or elsewhere within
267 # the LOCAL_DIRS and LOCAL_LIB_DIRS lists as needed.
268 .for _DIR in ${LOCAL_DIRS}
269 .if ${_DIR} == ".WAIT" || exists(${.CURDIR}/${_DIR}/Makefile)
273 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
274 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
275 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
276 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
277 _REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
279 .for _DIR in ${LOCAL_LIB_DIRS}
280 .if ${_DIR} == ".WAIT" || (empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
285 # We must do etc/ last as it hooks into building the man whatis file
286 # by calling 'makedb' in share/man. This is only relevant for
287 # install/distribute so they build the whatis file after every manpage is
289 .if make(installworld) || make(install)
294 .endif # !empty(SUBDIR_OVERRIDE)
297 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
300 .if defined(NO_CLEANDIR)
301 CLEANDIR= clean cleandepend
306 .if defined(WORLDFAST)
311 .if ${MK_META_MODE} == "yes"
312 # If filemon is used then we can rely on the build being incremental-safe.
313 # The .meta files will also track the build command and rebuild should
315 .if empty(.MAKE.MODE:Mnofilemon)
319 .if defined(NO_OBJWALK) || ${MK_AUTO_OBJ} == "yes"
323 .if !defined(NO_OBJWALK)
328 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
330 .if empty(SHELL:M*csh*)
331 BUILDENV_SHELL?=${SHELL}
333 BUILDENV_SHELL?=/bin/sh
336 .if !defined(SVN) || empty(SVN)
337 . for _P in /usr/bin /usr/local/bin
338 . for _S in svn svnlite
339 . if exists(${_P}/${_S})
346 .if !defined(VCS_REVISION) && empty(VCS_REVISION)
347 _VCS_REVISION?= $$(eval ${SVNVERSION_CMD} ${SRCDIR})
348 . if !empty(_VCS_REVISION)
349 VCS_REVISION= $$(echo r${_VCS_REVISION})
353 .if !defined(OSRELDATE)
354 .if exists(/usr/include/osreldate.h)
355 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
356 /usr/include/osreldate.h
363 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
364 .if !defined(_REVISION)
365 _REVISION!= ${MAKE} -C ${SRCDIR}/release MK_AUTO_OBJ=no -V REVISION
368 .if !defined(_BRANCH)
369 _BRANCH!= ${MAKE} -C ${SRCDIR}/release MK_AUTO_OBJ=no -V BRANCH
372 .if !defined(SRCRELDATE)
373 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
374 ${SRCDIR}/sys/sys/param.h
377 .if !defined(VERSION)
378 VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
382 .if !defined(PKG_VERSION)
383 .if ${_BRANCH:MSTABLE*} || ${_BRANCH:MCURRENT*} || ${_BRANCH:MALPHA*}
384 TIMENOW= %Y%m%d%H%M%S
385 EXTRA_REVISION= .s${TIMENOW:gmtime}
388 EXTRA_REVISION= _${_BRANCH:C/.*-p([0-9]+$)/\1/}
390 PKG_VERSION= ${_REVISION}${EXTRA_REVISION}
393 KNOWN_ARCHES?= aarch64/arm64 \
417 .if ${TARGET} == ${TARGET_ARCH}
420 _t= ${TARGET_ARCH}/${TARGET}
423 .if empty(KNOWN_ARCHES:M${_t})
424 .error Unknown target ${TARGET_ARCH}:${TARGET}.
428 .if ${TARGET} == ${MACHINE}
429 TARGET_CPUTYPE?=${CPUTYPE}
434 .if !empty(TARGET_CPUTYPE)
435 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
437 _TARGET_CPUTYPE=dummy
439 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} -f /dev/null \
440 -m ${.CURDIR}/share/mk MK_AUTO_OBJ=no -V CPUTYPE
441 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
442 .error CPUTYPE global should be set with ?=.
445 BUILD_ARCH!= uname -p
446 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
447 .error To cross-build, set TARGET_ARCH.
450 WORLDTMP?= ${OBJTOP}/tmp
451 BPATH= ${CCACHE_WRAPPER_PATH_PFX}${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
452 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
453 STRICTTMPPATH= ${BPATH}:${XPATH}
454 TMPPATH= ${STRICTTMPPATH}:${PATH}
457 # Avoid running mktemp(1) unless actually needed.
458 # It may not be functional, e.g., due to new ABI
459 # when in the middle of installing over this system.
461 .if make(distributeworld) || make(installworld) || make(stageworld)
462 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
465 .if make(stagekernel) || make(distributekernel)
471 # Building a world goes through the following stages
473 # 1. legacy stage [BMAKE]
474 # This stage is responsible for creating compatibility
475 # shims that are needed by the bootstrap-tools,
476 # build-tools and cross-tools stages. These are generally
477 # APIs that tools from one of those three stages need to
478 # build that aren't present on the host.
479 # 1. bootstrap-tools stage [BMAKE]
480 # This stage is responsible for creating programs that
481 # are needed for backward compatibility reasons. They
482 # are not built as cross-tools.
483 # 2. build-tools stage [TMAKE]
484 # This stage is responsible for creating the object
485 # tree and building any tools that are needed during
486 # the build process. Some programs are listed during
487 # this phase because they build binaries to generate
488 # files needed to build these programs. This stage also
489 # builds the 'build-tools' target rather than 'all'.
490 # 3. cross-tools stage [XMAKE]
491 # This stage is responsible for creating any tools that
492 # are needed for building the system. A cross-compiler is one
493 # of them. This differs from build tools in two ways:
494 # 1. the 'all' target is built rather than 'build-tools'
495 # 2. these tools are installed into TMPPATH for stage 4.
496 # 4. world stage [WMAKE]
497 # This stage actually builds the world.
498 # 5. install stage (optional) [IMAKE]
499 # This stage installs a previously built world.
503 # Keep these in sync -- see below for special case exception
504 MINIMUM_SUPPORTED_OSREL?= 900044
505 MINIMUM_SUPPORTED_REL?= 9.1
507 # Common environment for world related stages
509 MACHINE_ARCH=${TARGET_ARCH} \
511 CPUTYPE=${TARGET_CPUTYPE}
512 .if ${MK_META_MODE} != "no"
513 # Don't rebuild build-tools targets during normal build.
514 CROSSENV+= BUILD_TOOLS_META=.NOMETA
516 .if defined(TARGET_CFLAGS)
517 CROSSENV+= ${TARGET_CFLAGS}
520 # bootstrap-tools stage
521 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
522 TOOLS_PREFIX=${WORLDTMP} \
523 PATH=${BPATH}:${PATH} \
524 WORLDTMP=${WORLDTMP} \
525 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
526 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
528 OBJTOP='${WORLDTMP}/obj-tools' \
529 OBJROOT='$${OBJTOP}/' \
531 BOOTSTRAPPING=${OSRELDATE} \
532 BWPHASE=${.TARGET:C,^_,,} \
534 MK_HTML=no NO_LINT=yes MK_MAN=no \
535 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
536 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
537 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
538 MK_LLDB=no MK_TESTS=no \
542 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
547 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
548 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
550 BOOTSTRAPPING=${OSRELDATE} \
551 BWPHASE=${.TARGET:C,^_,,} \
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
559 # TOOLS_PREFIX set in BMAKE
561 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
562 MK_GDB=no MK_LLD_IS_LD=${MK_LLD_BOOTSTRAP} MK_TESTS=no
565 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
566 PATH=${BPATH}:${PATH} \
568 KTMAKE= TOOLS_PREFIX=${WORLDTMP} \
569 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
571 OBJTOP='${WORLDTMP}/obj-kernel-tools' \
572 OBJROOT='$${OBJTOP}/' \
574 BOOTSTRAPPING=${OSRELDATE} \
576 MK_HTML=no -DNO_LINT MK_MAN=no \
577 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
578 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
581 WMAKEENV= ${CROSSENV} \
582 INSTALL="sh ${.CURDIR}/tools/install.sh" \
587 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
589 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
592 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
593 CPP="${XCPP} ${XCFLAGS}" \
594 AS="${XAS}" AR="${XAR}" LD="${XLD}" LLVM_LINK="${XLLVM_LINK}" \
595 NM=${XNM} OBJCOPY="${XOBJCOPY}" \
596 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
599 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
600 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
601 # directory, but the compiler will look in the right place for its
602 # tools so we don't need to tell it where to look.
603 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
607 # The internal bootstrap compiler has a default sysroot set by TOOLS_PREFIX
608 # and target set by TARGET/TARGET_ARCH. However, there are several needs to
609 # always pass an explicit --sysroot and -target.
610 # - External compiler needs sysroot and target flags.
611 # - External ld needs sysroot.
612 # - To be clear about the use of a sysroot when using the internal compiler.
613 # - Easier debugging.
614 # - Allowing WITH_SYSTEM_COMPILER+WITH_META_MODE to work together due to
615 # the flip-flopping build command when sometimes using external and
616 # sometimes using internal.
617 # - Allow using lld which has no support for default paths.
618 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
619 BFLAGS+= -B${WORLDTMP}/usr/bin
621 .if ${TARGET} == "arm"
622 .if ${TARGET_ARCH:Marmv[67]*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
623 TARGET_ABI= gnueabihf
628 .if ${WANT_COMPILER_TYPE} == gcc || \
629 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
630 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
631 # won't set header path and -L is used to ensure the base library path
632 # is added before the port PREFIX library path.
633 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
634 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
635 # combined with --sysroot.
636 XCFLAGS+= -B${WORLDTMP}/usr/lib
637 # Force using libc++ for external GCC.
638 .if ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
639 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
642 .elif ${WANT_COMPILER_TYPE} == clang || \
643 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang)
644 MACHINE_ABI?= unknown
645 MACHINE_TRIPLE?=${MACHINE_ARCH:S/amd64/x86_64/:C/hf$//:S/mipsn32/mips64/}-${MACHINE_ABI}-freebsd12.0
647 TARGET_TRIPLE?= ${TARGET_ARCH:S/amd64/x86_64/:C/hf$//:S/mipsn32/mips64/}-${TARGET_ABI}-freebsd12.0
648 XCFLAGS+= -target ${TARGET_TRIPLE}
650 XCFLAGS+= --sysroot=${WORLDTMP}
656 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
657 ${TARGET_ARCH} == "powerpc64" || ${TARGET_ARCH:Mmips64*} != "")
659 .include "Makefile.libcompat"
660 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH:Marmv[67]*} != ""
662 .include "Makefile.libcompat"
665 # META_MODE normally ignores host file changes since every build updates
666 # timestamps (see NO_META_IGNORE_HOST in sys.mk). There are known times
667 # when the ABI breaks though that we want to force rebuilding WORLDTMP
668 # to get updated host tools.
669 .if ${MK_META_MODE} == "yes" && defined(NO_CLEAN) && \
670 !defined(NO_META_IGNORE_HOST) && !defined(NO_META_IGNORE_HOST_HEADERS) && \
672 # r318736 - ino64 major ABI breakage
673 META_MODE_BAD_ABI_VERS+= 1200031
675 .if !defined(OBJDIR_HOST_OSRELDATE)
676 .if exists(${OBJTOP}/host-osreldate.h)
677 OBJDIR_HOST_OSRELDATE!= \
678 awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
679 ${OBJTOP}/host-osreldate.h
680 .elif exists(${WORLDTMP}/usr/include/osreldate.h)
681 OBJDIR_HOST_OSRELDATE= 0
683 .export OBJDIR_HOST_OSRELDATE
686 # Note that this logic is the opposite of normal BOOTSTRAP handling. We want
687 # to compare the WORLDTMP's OSRELDATE to the host's OSRELDATE. If the WORLDTMP
688 # is older than the ABI-breakage OSRELDATE of the HOST then we rebuild.
689 .if defined(OBJDIR_HOST_OSRELDATE)
690 .for _ver in ${META_MODE_BAD_ABI_VERS}
691 .if ${OSRELDATE} >= ${_ver} && ${OBJDIR_HOST_OSRELDATE} < ${_ver}
692 _meta_mode_need_rebuild= ${_ver}
695 .if defined(_meta_mode_need_rebuild)
696 .info META_MODE: Rebuilding host tools due to ABI breakage in __FreeBSD_version ${_meta_mode_need_rebuild}.
697 NO_META_IGNORE_HOST_HEADERS= 1
698 .export NO_META_IGNORE_HOST_HEADERS
699 .endif # defined(_meta_mode_need_rebuild)
700 .endif # defined(OBJDIR_HOST_OSRELDATE)
701 .endif # ${MK_META_MODE} == "yes" && defined(NO_CLEAN) ...
702 # This is only used for META_MODE+filemon to track what the oldest
703 # __FreeBSD_version is in WORLDTMP. This purposely does NOT have
704 # a make dependency on /usr/include/osreldate.h as the file should
705 # only be copied when it is missing or meta mode determines it has changed.
706 # Since host files are normally ignored without NO_META_IGNORE_HOST
707 # the file will never be updated unless that flag is specified. This
708 # allows tracking the oldest osreldate to force rebuilds via
709 # META_MODE_BADABI_REVS above.
710 host-osreldate.h: # DO NOT ADD /usr/include/osreldate.h here
711 @cp -f /usr/include/osreldate.h ${.TARGET}
713 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
714 BWPHASE=${.TARGET:C,^_,,} \
717 IMAKEENV= ${CROSSENV}
718 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
719 ${IMAKE_INSTALL} ${IMAKE_MTREE}
720 .if empty(.MAKEFLAGS:M-n)
721 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
722 LD_LIBRARY_PATH=${INSTALLTMP} \
723 PATH_LOCALE=${INSTALLTMP}/locale
724 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
726 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
728 .if defined(DB_FROM_SRC)
729 INSTALLFLAGS+= -N ${.CURDIR}/etc
730 MTREEFLAGS+= -N ${.CURDIR}/etc
732 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
733 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
735 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
736 METALOG:= ${METALOG:C,//+,/,g}
737 IMAKE+= -DNO_ROOT METALOG=${METALOG}
738 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
741 .if defined(BUILD_PKGS)
742 INSTALLFLAGS+= -h sha256
744 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
745 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
746 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
750 KMAKEENV= ${WMAKEENV:NSYSROOT=*}
751 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
756 # Attempt to rebuild the entire system, with reasonable chance of
757 # success, regardless of how old your existing system is.
759 _sanity_check: .PHONY .MAKE
760 .if ${.CURDIR:C/[^,]//g} != ""
761 # The m4 build of sendmail files doesn't like it if ',' is used
762 # anywhere in the path of it's files.
764 @echo "*** Error: path to source tree contains a comma ','"
767 .elif ${.CURDIR:M*\:*} != ""
768 # Using ':' leaks into PATH and breaks finding cross-tools.
770 @echo "*** Error: path to source tree contains a colon ':'"
775 # Our current approach to dependency tracking cannot cope with certain source
776 # tree changes, particularly with respect to removing source files and
777 # replacing generated files. Handle these cases here in an ad-hoc fashion.
778 _cleanobj_fast_depend_hack: .PHONY
779 # Syscall stubs rewritten in C
780 # Date SVN Rev Syscalls
781 # 20160829 r305012 ptrace
782 # 20170624 r320278 fstat fstatat fstatfs getdirentries getfsstat statfs
783 .for f in fstat fstatat fstatfs getdirentries getfsstat ptrace statfs
784 .if exists(${OBJTOP}/lib/libc/.depend.${f}.o)
785 @if egrep -qw '${f}\.[sS]' \
786 ${OBJTOP}/lib/libc/.depend.${f}.o; then \
787 echo Removing stale dependencies for ${f} syscall wrappers; \
788 rm -f ${OBJTOP}/lib/libc/.depend.${f}.* \
789 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \
793 # 20170607 remove stale dependencies for utimens* wrappers removed in r319663
794 .for f in futimens utimensat
795 .if exists(${OBJTOP}/lib/libc/.depend.${f}.o)
796 @if egrep -q '/${f}.c' \
797 ${OBJTOP}/lib/libc/.depend.${f}.o; then \
798 echo Removing stale dependencies for ${f} syscall wrappers; \
799 rm -f ${OBJTOP}/lib/libc/.depend.${f}.* \
800 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \
804 # 20170523 remove stale generated asm files for functions which are no longer
805 # syscalls after r302092 (pipe) and r318736 (others)
806 .for f in getdents lstat mknod pipe stat
807 .if exists(${OBJTOP}/lib/libc/${f}.s) || \
808 exists(${OBJTOP}/lib/libc/${f}.S)
809 @echo Removing stale generated ${f} syscall files
810 @rm -f ${OBJTOP}/lib/libc/${f}.* \
811 ${OBJTOP}/lib/libc/.depend.${f}.* \
812 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/${f}.*} \
813 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}
819 @echo "--------------------------------------------------------------"
820 @echo ">>> Rebuilding the temporary build tree"
821 @echo "--------------------------------------------------------------"
822 .if !defined(NO_CLEAN)
825 .if exists(${WORLDTMP})
826 @echo ">>> Deleting stale files in build tree..."
827 ${_+_}cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \
828 delete-old delete-old-libs >/dev/null
830 rm -rf ${WORLDTMP}/legacy/usr/include
831 .if ${USING_SYSTEM_COMPILER} == "yes"
833 if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \
834 inum=$$(stat -f %i ${WORLDTMP}/usr/bin/${cc}); \
835 find ${WORLDTMP}/usr/bin -inum $${inum} -delete; \
838 .endif # ${USING_SYSTEM_COMPILER} == "yes"
839 .endif # !defined(NO_CLEAN)
840 @mkdir -p ${WORLDTMP}
841 @touch ${WORLDTMP}/${.TARGET}
844 lib lib/casper usr legacy/bin legacy/usr
845 mkdir -p ${WORLDTMP}/${_dir}
847 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
848 -p ${WORLDTMP}/legacy/usr >/dev/null
849 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
850 -p ${WORLDTMP}/legacy/usr/include >/dev/null
851 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
852 -p ${WORLDTMP}/usr >/dev/null
853 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
854 -p ${WORLDTMP}/usr/include >/dev/null
855 ln -sf ${.CURDIR}/sys ${WORLDTMP}
856 .if ${MK_DEBUG_FILES} != "no"
857 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
858 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
859 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
860 -p ${WORLDTMP}/usr/lib >/dev/null
862 .for _mtree in ${LOCAL_MTREE}
863 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
867 @echo "--------------------------------------------------------------"
868 @echo ">>> stage 1.1: legacy release compatibility shims"
869 @echo "--------------------------------------------------------------"
870 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
873 @echo "--------------------------------------------------------------"
874 @echo ">>> stage 1.2: bootstrap tools"
875 @echo "--------------------------------------------------------------"
876 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
878 .if !defined(NO_CLEAN)
880 @echo "--------------------------------------------------------------"
881 @echo ">>> stage 2.1: cleaning up the object tree"
882 @echo "--------------------------------------------------------------"
883 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
884 .if defined(LIBCOMPAT)
885 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
888 ${_+_}cd ${.CURDIR}; ${WMAKE} _cleanobj_fast_depend_hack
889 .endif # !defined(NO_CLEAN)
892 @echo "--------------------------------------------------------------"
893 @echo ">>> stage 2.2: rebuilding the object tree"
894 @echo "--------------------------------------------------------------"
895 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
898 @echo "--------------------------------------------------------------"
899 @echo ">>> stage 2.3: build tools"
900 @echo "--------------------------------------------------------------"
901 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
904 @echo "--------------------------------------------------------------"
905 @echo ">>> stage 3: cross tools"
906 @echo "--------------------------------------------------------------"
907 @rm -f ${OBJTOP}/compiler-metadata.mk
908 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
909 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
912 @echo "--------------------------------------------------------------"
913 @echo ">>> stage 3.1: recording build metadata"
914 @echo "--------------------------------------------------------------"
915 ${_+_}cd ${.CURDIR}; ${WMAKE} compiler-metadata.mk
916 ${_+_}cd ${.CURDIR}; ${WMAKE} host-osreldate.h
919 @echo "--------------------------------------------------------------"
920 @echo ">>> stage 4.1: building includes"
921 @echo "--------------------------------------------------------------"
922 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
923 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
924 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
925 MK_INCLUDES=yes includes
926 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
927 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
931 @echo "--------------------------------------------------------------"
932 @echo ">>> stage 4.2: building libraries"
933 @echo "--------------------------------------------------------------"
934 ${_+_}cd ${.CURDIR}; \
935 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
936 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
939 @echo "--------------------------------------------------------------"
940 @echo ">>> stage 4.3: building everything"
941 @echo "--------------------------------------------------------------"
942 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
945 .if !defined(WORLDFAST)
946 WMAKE_TGTS+= _sanity_check _worldtmp _legacy
947 .if empty(SUBDIR_OVERRIDE)
948 WMAKE_TGTS+= _bootstrap-tools
950 WMAKE_TGTS+= _cleanobj
951 .if !defined(NO_OBJWALK)
954 WMAKE_TGTS+= _build-tools _cross-tools
955 WMAKE_TGTS+= _build-metadata
956 WMAKE_TGTS+= _includes
958 .if !defined(NO_LIBS)
959 WMAKE_TGTS+= _libraries
961 WMAKE_TGTS+= everything
962 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
963 WMAKE_TGTS+= build${libcompat}
966 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
967 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
969 buildworld_prologue: .PHONY
970 @echo "--------------------------------------------------------------"
971 @echo ">>> World build started on `LC_ALL=C date`"
972 @echo "--------------------------------------------------------------"
974 buildworld_epilogue: .PHONY
976 @echo "--------------------------------------------------------------"
977 @echo ">>> World build completed on `LC_ALL=C date`"
978 @echo "--------------------------------------------------------------"
981 # We need to have this as a target because the indirection between Makefile
982 # and Makefile.inc1 causes the correct PATH to be used, rather than a
983 # modification of the current environment's PATH. In addition, we need
984 # to quote multiword values.
987 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
989 .if ${.TARGETS:Mbuildenv}
990 .if ${.MAKEFLAGS:M-j}
991 .error The buildenv target is incompatible with -j
994 BUILDENV_DIR?= ${.CURDIR}
996 # Note: make will report any errors the shell reports. This can
997 # be odd if the last command in an interactive shell generates an
998 # error or is terminated by SIGINT. These reported errors look bad,
999 # but are harmless. Allowing them also allows BUIDLENV_SHELL to
1000 # be a complex command whose status will be returned to the caller.
1001 # Some scripts in tools rely on this behavior to report build errors.
1004 @echo Entering world for ${TARGET_ARCH}:${TARGET}
1005 .if ${BUILDENV_SHELL:M*zsh*}
1006 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
1008 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL}
1010 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
1011 toolchain: ${TOOLCHAIN_TGTS} .PHONY
1012 KERNEL_TOOLCHAIN_TGTS= ${TOOLCHAIN_TGTS:N_obj:N_cleanobj:N_includes:N_libraries}
1013 .if make(kernel-toolchain)
1014 .ORDER: ${KERNEL_TOOLCHAIN_TGTS}
1016 kernel-toolchain: ${KERNEL_TOOLCHAIN_TGTS} .PHONY
1021 # Checks to be sure system is ready for installworld/installkernel.
1023 installcheck: _installcheck_world _installcheck_kernel .PHONY
1024 _installcheck_world: .PHONY
1025 _installcheck_kernel: .PHONY
1028 # Require DESTDIR to be set if installing for a different architecture or
1029 # using the user/group database in the source tree.
1031 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
1032 defined(DB_FROM_SRC)
1033 .if !make(distributeworld)
1034 _installcheck_world: __installcheck_DESTDIR
1035 _installcheck_kernel: __installcheck_DESTDIR
1036 __installcheck_DESTDIR: .PHONY
1037 .if !defined(DESTDIR) || empty(DESTDIR)
1038 @echo "ERROR: Please set DESTDIR!"; \
1044 .if !defined(DB_FROM_SRC)
1046 # Check for missing UIDs/GIDs.
1048 CHECK_UIDS= auditdistd
1050 .if ${MK_SENDMAIL} != "no"
1054 .if ${MK_PF} != "no"
1056 CHECK_GIDS+= proxy authpf
1058 .if ${MK_UNBOUND} != "no"
1059 CHECK_UIDS+= unbound
1060 CHECK_GIDS+= unbound
1062 _installcheck_world: __installcheck_UGID
1063 __installcheck_UGID: .PHONY
1064 .for uid in ${CHECK_UIDS}
1065 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
1066 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
1070 .for gid in ${CHECK_GIDS}
1071 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
1072 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
1078 # If installing over the running system (DESTDIR is / or unset) and the install
1079 # includes rescue, try running rescue from the objdir as a sanity check. If
1080 # rescue is not functional (e.g., because it depends on a system call not
1081 # supported by the currently running kernel), abort the installation.
1083 .if !make(distributeworld) && ${MK_RESCUE} != "no" && \
1084 (empty(DESTDIR) || ${DESTDIR} == "/") && empty(BYPASS_INSTALLCHECK_SH)
1085 _installcheck_world: __installcheck_sh_check
1086 __installcheck_sh_check: .PHONY
1087 @if [ "`${OBJTOP}/rescue/rescue/rescue sh -c 'echo OK'`" != \
1089 echo "rescue/sh check failed, installation aborted" >&2; \
1095 # Required install tools to be saved in a scratch dir for safety.
1097 .if ${MK_ZONEINFO} != "no"
1098 _zoneinfo= zic tzsetup
1101 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
1102 date echo egrep find grep id install ${_install-info} \
1103 ln make mkdir mtree mv pwd_mkdb \
1104 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
1107 # Needed for share/man
1108 .if ${MK_MAN_UTILS} != "no"
1115 # Distributes everything compiled by a `buildworld'.
1119 # Installs everything compiled by a 'buildworld'.
1122 # Non-base distributions produced by the base system
1123 EXTRA_DISTRIBUTIONS= doc
1124 .if defined(LIBCOMPAT)
1125 EXTRA_DISTRIBUTIONS+= lib${libcompat}
1127 .if ${MK_TESTS} != "no"
1128 EXTRA_DISTRIBUTIONS+= tests
1131 DEBUG_DISTRIBUTIONS=
1132 .if ${MK_DEBUG_FILES} != "no"
1133 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
1136 MTREE_MAGIC?= mtree 2.0
1138 distributeworld installworld stageworld: _installcheck_world .PHONY
1139 mkdir -p ${INSTALLTMP}
1140 progs=$$(for prog in ${ITOOLS}; do \
1141 if progpath=`which $$prog`; then \
1144 echo "Required tool $$prog not found in PATH." >&2; \
1148 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
1149 while read line; do \
1151 if [ "$$2 $$3" != "not found" ]; then \
1154 echo "Required library $$1 not found." >&2; \
1158 cp $$libs $$progs ${INSTALLTMP}
1159 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
1160 .if defined(NO_ROOT)
1161 -mkdir -p ${METALOG:H}
1162 echo "#${MTREE_MAGIC}" > ${METALOG}
1164 .if make(distributeworld)
1165 .for dist in ${EXTRA_DISTRIBUTIONS}
1166 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
1167 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1168 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
1169 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1170 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1171 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1172 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
1173 .if ${MK_DEBUG_FILES} != "no"
1174 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1175 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
1177 .if defined(LIBCOMPAT)
1178 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1179 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1180 .if ${MK_DEBUG_FILES} != "no"
1181 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1182 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
1185 .if ${MK_TESTS} != "no" && ${dist} == "tests"
1186 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
1187 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1188 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
1189 .if ${MK_DEBUG_FILES} != "no"
1190 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1191 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
1194 .if defined(NO_ROOT)
1195 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1196 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1197 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1198 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1199 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1200 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1201 .if defined(LIBCOMPAT)
1202 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
1203 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1207 -mkdir ${DESTDIR}/${DISTDIR}/base
1208 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1209 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1210 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1211 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1213 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1214 ${IMAKEENV} rm -rf ${INSTALLTMP}
1215 .if make(distributeworld)
1216 .for dist in ${EXTRA_DISTRIBUTIONS}
1217 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete
1219 .if defined(NO_ROOT)
1220 .for dist in base ${EXTRA_DISTRIBUTIONS}
1221 @# For each file that exists in this dist, print the corresponding
1222 @# line from the METALOG. This relies on the fact that
1223 @# a line containing only the filename will sort immediately before
1224 @# the relevant mtree line.
1225 cd ${DESTDIR}/${DISTDIR}; \
1226 find ./${dist} | sort -u ${METALOG} - | \
1227 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1228 ${DESTDIR}/${DISTDIR}/${dist}.meta
1230 .for dist in ${DEBUG_DISTRIBUTIONS}
1231 @# For each file that exists in this dist, print the corresponding
1232 @# line from the METALOG. This relies on the fact that
1233 @# a line containing only the filename will sort immediately before
1234 @# the relevant mtree line.
1235 cd ${DESTDIR}/${DISTDIR}; \
1236 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1237 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1238 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1243 packageworld: .PHONY
1244 .for dist in base ${EXTRA_DISTRIBUTIONS}
1245 .if defined(NO_ROOT)
1246 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1247 tar cvf - --exclude usr/lib/debug \
1248 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1249 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1251 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1252 tar cvf - --exclude usr/lib/debug . | \
1253 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1257 .for dist in ${DEBUG_DISTRIBUTIONS}
1258 . if defined(NO_ROOT)
1259 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1260 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1261 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1263 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1264 tar cvLf - usr/lib/debug | \
1265 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1272 # If you have a build server, you can NFS mount the source and obj directories
1273 # and do a 'make reinstall' on the *client* to install new binaries from the
1274 # most recent server build.
1276 restage reinstall: .MAKE .PHONY
1277 @echo "--------------------------------------------------------------"
1278 @echo ">>> Making hierarchy"
1279 @echo "--------------------------------------------------------------"
1280 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1281 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1283 @echo "--------------------------------------------------------------"
1284 @echo ">>> Making distribution"
1285 @echo "--------------------------------------------------------------"
1286 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1287 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
1290 @echo "--------------------------------------------------------------"
1291 @echo ">>> Installing everything"
1292 @echo "--------------------------------------------------------------"
1293 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1294 .if defined(LIBCOMPAT)
1295 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1298 redistribute: .MAKE .PHONY
1299 @echo "--------------------------------------------------------------"
1300 @echo ">>> Distributing everything"
1301 @echo "--------------------------------------------------------------"
1302 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1303 .if defined(LIBCOMPAT)
1304 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1305 DISTRIBUTION=lib${libcompat}
1308 distrib-dirs distribution: .MAKE .PHONY
1309 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1310 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1311 .if make(distribution)
1312 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1313 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1314 METALOG=${METALOG} MK_TESTS=no installconfig
1318 # buildkernel and installkernel
1320 # Which kernels to build and/or install is specified by setting
1321 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1322 # Only the existing (depending TARGET) config files are used
1323 # for building kernels and only the first of these is designated
1324 # as the one being installed.
1326 # Note that we have to use TARGET instead of TARGET_ARCH when
1327 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1328 # be set to cross-build, we have to make sure TARGET is set
1331 .if defined(KERNFAST)
1335 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1336 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1337 KERNCONF=${KERNFAST}
1340 .if ${TARGET_ARCH} == "powerpc64"
1341 KERNCONF?= GENERIC64
1345 INSTKERNNAME?= kernel
1347 KERNSRCDIR?= ${.CURDIR}/sys
1348 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1349 KRNLOBJDIR= ${OBJTOP}${KERNSRCDIR:C,^${.CURDIR},,}
1350 KERNCONFDIR?= ${KRNLCONFDIR}
1354 .if defined(NO_INSTALLKERNEL)
1355 # All of the BUILDKERNELS loops start at index 1.
1356 BUILDKERNELS+= dummy
1358 .for _kernel in ${KERNCONF}
1359 .if exists(${KERNCONFDIR}/${_kernel})
1360 BUILDKERNELS+= ${_kernel}
1361 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1362 INSTALLKERNEL= ${_kernel}
1365 .if make(buildkernel)
1366 .error Missing KERNCONF ${KERNCONFDIR}/${_kernel}
1371 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1376 # Builds all kernels defined by BUILDKERNELS.
1378 buildkernel: .MAKE .PHONY
1379 .if empty(BUILDKERNELS:Ndummy)
1380 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1384 .for _kernel in ${BUILDKERNELS:Ndummy}
1385 @echo "--------------------------------------------------------------"
1386 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1387 @echo "--------------------------------------------------------------"
1388 @echo "===> ${_kernel}"
1389 mkdir -p ${KRNLOBJDIR}
1390 .if !defined(NO_KERNELCONFIG)
1392 @echo "--------------------------------------------------------------"
1393 @echo ">>> stage 1: configuring the kernel"
1394 @echo "--------------------------------------------------------------"
1395 cd ${KRNLCONFDIR}; \
1397 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1398 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1400 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1402 @echo "--------------------------------------------------------------"
1403 @echo ">>> stage 2.1: cleaning up the object tree"
1404 @echo "--------------------------------------------------------------"
1405 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1407 .if !defined(NO_KERNELOBJ)
1409 @echo "--------------------------------------------------------------"
1410 @echo ">>> stage 2.2: rebuilding the object tree"
1411 @echo "--------------------------------------------------------------"
1412 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1415 @echo "--------------------------------------------------------------"
1416 @echo ">>> stage 2.3: build tools"
1417 @echo "--------------------------------------------------------------"
1418 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1420 @echo "--------------------------------------------------------------"
1421 @echo ">>> stage 3.1: building everything"
1422 @echo "--------------------------------------------------------------"
1423 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1424 @echo "--------------------------------------------------------------"
1425 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1426 @echo "--------------------------------------------------------------"
1429 NO_INSTALLEXTRAKERNELS?= yes
1432 # installkernel, etc.
1434 # Install the kernel defined by INSTALLKERNEL
1436 installkernel installkernel.debug \
1437 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1438 .if !defined(NO_INSTALLKERNEL)
1439 .if empty(INSTALLKERNEL)
1440 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1443 @echo "--------------------------------------------------------------"
1444 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1445 @echo "--------------------------------------------------------------"
1446 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1447 ${CROSSENV} PATH=${TMPPATH} \
1448 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1450 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1451 .for _kernel in ${BUILDKERNELS:[2..-1]}
1452 @echo "--------------------------------------------------------------"
1453 @echo ">>> Installing kernel ${_kernel}"
1454 @echo "--------------------------------------------------------------"
1455 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
1456 ${CROSSENV} PATH=${TMPPATH} \
1457 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1461 distributekernel distributekernel.debug: .PHONY
1462 .if !defined(NO_INSTALLKERNEL)
1463 .if empty(INSTALLKERNEL)
1464 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1467 mkdir -p ${DESTDIR}/${DISTDIR}
1468 .if defined(NO_ROOT)
1469 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1471 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1472 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1473 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1474 DESTDIR=${INSTALL_DDIR}/kernel \
1475 ${.TARGET:S/distributekernel/install/}
1476 .if defined(NO_ROOT)
1477 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1478 ${DESTDIR}/${DISTDIR}/kernel.meta
1481 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1482 .for _kernel in ${BUILDKERNELS:[2..-1]}
1483 .if defined(NO_ROOT)
1484 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1486 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
1487 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1488 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1489 KERNEL=${INSTKERNNAME}.${_kernel} \
1490 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1491 ${.TARGET:S/distributekernel/install/}
1492 .if defined(NO_ROOT)
1493 @sed -e "s|^./kernel.${_kernel}|.|" \
1494 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1495 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1500 packagekernel: .PHONY
1501 .if defined(NO_ROOT)
1502 .if !defined(NO_INSTALLKERNEL)
1503 cd ${DESTDIR}/${DISTDIR}/kernel; \
1504 tar cvf - --exclude '*.debug' \
1505 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1506 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1508 .if ${MK_DEBUG_FILES} != "no"
1509 cd ${DESTDIR}/${DISTDIR}/kernel; \
1510 tar cvf - --include '*/*/*.debug' \
1511 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1512 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1514 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1515 .for _kernel in ${BUILDKERNELS:[2..-1]}
1516 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1517 tar cvf - --exclude '*.debug' \
1518 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1519 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1520 .if ${MK_DEBUG_FILES} != "no"
1521 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1522 tar cvf - --include '*/*/*.debug' \
1523 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1524 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1529 .if !defined(NO_INSTALLKERNEL)
1530 cd ${DESTDIR}/${DISTDIR}/kernel; \
1531 tar cvf - --exclude '*.debug' . | \
1532 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1534 .if ${MK_DEBUG_FILES} != "no"
1535 cd ${DESTDIR}/${DISTDIR}/kernel; \
1536 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1537 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1539 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1540 .for _kernel in ${BUILDKERNELS:[2..-1]}
1541 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1542 tar cvf - --exclude '*.debug' . | \
1543 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1544 .if ${MK_DEBUG_FILES} != "no"
1545 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1546 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1547 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1554 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1556 PORTSDIR?= /usr/ports
1557 WSTAGEDIR?= ${OBJTOP}/worldstage
1558 KSTAGEDIR?= ${OBJTOP}/kernelstage
1559 REPODIR?= ${OBJROOT}repo
1560 PKGSIGNKEY?= # empty
1562 .ORDER: stage-packages create-packages
1563 .ORDER: create-packages create-world-packages
1564 .ORDER: create-packages create-kernel-packages
1565 .ORDER: create-packages sign-packages
1567 _pkgbootstrap: .PHONY
1568 .if !exists(${LOCALBASE}/sbin/pkg)
1569 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1573 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1576 rm -rf /tmp/ports.${TARGET} || :
1577 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
1578 PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \
1579 WSTAGEDIR=${WSTAGEDIR} \
1580 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1582 real-packages: stage-packages create-packages sign-packages .PHONY
1584 stage-packages-world: .PHONY
1585 @mkdir -p ${WSTAGEDIR}
1586 ${_+_}@cd ${.CURDIR}; \
1587 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT stageworld
1589 stage-packages-kernel: .PHONY
1590 @mkdir -p ${KSTAGEDIR}
1591 ${_+_}@cd ${.CURDIR}; \
1592 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT stagekernel
1594 stage-packages: .PHONY stage-packages-world stage-packages-kernel
1597 @mkdir -p ${REPODIR}
1599 create-packages-world: _pkgbootstrap _repodir .PHONY
1600 ${_+_}@cd ${.CURDIR}; \
1601 ${MAKE} -f Makefile.inc1 \
1602 DESTDIR=${WSTAGEDIR} \
1603 PKG_VERSION=${PKG_VERSION} create-world-packages
1605 create-packages-kernel: _pkgbootstrap _repodir .PHONY
1606 ${_+_}@cd ${.CURDIR}; \
1607 ${MAKE} -f Makefile.inc1 \
1608 DESTDIR=${KSTAGEDIR} \
1609 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1610 create-kernel-packages
1612 create-packages: .PHONY create-packages-world create-packages-kernel
1614 create-world-packages: _pkgbootstrap .PHONY
1615 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1616 @cd ${WSTAGEDIR} ; \
1617 env -i LC_COLLATE=C sort ${WSTAGEDIR}/METALOG | \
1618 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk
1619 @for plist in ${WSTAGEDIR}/*.plist; do \
1620 plist=$${plist##*/} ; \
1621 pkgname=$${plist%.plist} ; \
1622 echo "_PKGS+= $${pkgname}" ; \
1623 done > ${WSTAGEDIR}/packages.mk
1624 ${_+_}@cd ${.CURDIR}; \
1625 ${MAKE} -f Makefile.inc1 create-world-packages-jobs \
1628 .if make(create-world-packages-jobs)
1629 .include "${WSTAGEDIR}/packages.mk"
1632 create-world-packages-jobs: .PHONY
1633 .for pkgname in ${_PKGS}
1634 create-world-packages-jobs: create-world-package-${pkgname}
1635 create-world-package-${pkgname}: .PHONY
1636 @sh ${SRCDIR}/release/packages/generate-ucl.sh -o ${pkgname} \
1637 -s ${SRCDIR} -u ${WSTAGEDIR}/${pkgname}.ucl
1639 /^name/ { printf("===> Creating %s-", $$2); next } \
1640 /^version/ { print $$2; next } \
1641 ' ${WSTAGEDIR}/${pkgname}.ucl
1642 @if [ "${pkgname}" == "runtime" ]; then \
1643 sed -i '' -e "s/%VCS_REVISION%/${VCS_REVISION}/" ${WSTAGEDIR}/${pkgname}.ucl ; \
1645 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1646 create -M ${WSTAGEDIR}/${pkgname}.ucl \
1647 -p ${WSTAGEDIR}/${pkgname}.plist \
1649 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1652 create-kernel-packages: .PHONY
1653 _default_flavor= -default
1654 .if exists(${KSTAGEDIR}/kernel.meta)
1655 . if ${MK_DEBUG_FILES} != "no"
1658 . for flavor in "" ${_debug}
1659 create-kernel-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}
1660 create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY
1661 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1662 env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.meta | \
1663 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1664 -v kernel=yes -v _kernconf=${INSTALLKERNEL} ; \
1665 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1666 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1667 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1668 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1669 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1670 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1671 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1672 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1673 -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \
1674 ${SRCDIR}/release/packages/kernel.ucl \
1675 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1677 /name/ { printf("===> Creating %s-", $$2); next } \
1678 /version/ {print $$2; next } ' \
1679 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1680 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1681 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1682 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1683 -r ${KSTAGEDIR}/${DISTDIR} \
1684 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1687 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1688 . for _kernel in ${BUILDKERNELS:[2..-1]}
1689 . if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1690 . if ${MK_DEBUG_FILES} != "no"
1693 . for flavor in "" ${_debug}
1694 create-kernel-packages: create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}
1695 create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}: _pkgbootstrap .PHONY
1696 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1697 env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.${_kernel}.meta | \
1698 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1699 -v kernel=yes -v _kernconf=${_kernel} ; \
1700 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1701 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1702 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1703 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1704 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1705 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1706 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1707 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1708 -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \
1709 ${SRCDIR}/release/packages/kernel.ucl \
1710 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1712 /name/ { printf("===> Creating %s-", $$2); next } \
1713 /version/ {print $$2; next } ' \
1714 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1715 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1716 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1717 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1718 -r ${KSTAGEDIR}/kernel.${_kernel} \
1719 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1725 sign-packages: _pkgbootstrap .PHONY
1726 @[ -L "${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1727 unlink ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1728 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1729 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1730 ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1732 cd ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI); \
1733 ln -s ${PKG_VERSION} latest
1739 # Run test suite on installed world.
1742 @if [ ! -x "${LOCALBASE}/bin/kyua" ]; then \
1743 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1746 ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile
1752 # Build the API documentation with doxygen
1755 @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \
1756 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1759 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1764 # Update the source tree(s), by running svn/svnup to update to the
1768 .if defined(SVN_UPDATE)
1769 @echo "--------------------------------------------------------------"
1770 @echo ">>> Updating ${.CURDIR} using Subversion"
1771 @echo "--------------------------------------------------------------"
1772 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1776 # ------------------------------------------------------------------------
1778 # From here onwards are utility targets used by the 'make world' and
1779 # related targets. If your 'world' breaks, you may like to try to fix
1780 # the problem and manually run the following targets to attempt to
1781 # complete the build. Beware, this is *not* guaranteed to work, you
1782 # need to have a pretty good grip on the current state of the system
1783 # to attempt to manually finish it. If in doubt, 'make world' again.
1787 # legacy: Build compatibility shims for the next three targets. This is a
1788 # minimal set of tools and shims necessary to compensate for older systems
1789 # which don't have the APIs required by the targets built in bootstrap-tools,
1790 # build-tools or cross-tools.
1793 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1794 # r296685 fix cross-endian objcopy
1795 # r310724 fixed PR 215350, a crash in libdwarf with objects built by GCC 6.2.
1796 .if ${BOOTSTRAPPING} < 1200020
1797 _elftoolchain_libs= lib/libelf lib/libdwarf
1801 # Temporary special case for automatically detecting the clang compiler issue
1802 # Note: 9.x didn't have FreeBSD_version bumps often enough, so you may need to
1803 # set BOOTSTRAPPING to 0 if you're stable/9 tree post-dates r286035 but is before
1804 # the version bump in r296219 (from July 29, 2015 -> Feb 29, 2016).
1805 .if ${BOOTSTRAPPING} != 0 && \
1806 ${WANT_COMPILER_TYPE} == "clang" && ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} < 30601
1807 .if ${BOOTSTRAPPING} > 10000000 && ${BOOTSTRAPPING} < 1002501
1808 @echo "ERROR: Source upgrades from stable/10 prior to r286033 are not supported."; false
1809 .elif ${BOOTSTRAPPING} > 9000000 && ${BOOTSTRAPPING} < 903509
1810 @echo "ERROR: Source upgrades from stable/9 prior to r286035 are not supported."; false
1813 .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
1814 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
1818 .for _tool in tools/build ${_elftoolchain_libs}
1819 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1820 cd ${.CURDIR}/${_tool}; \
1821 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
1822 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy includes; \
1823 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
1824 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
1825 DESTDIR=${WORLDTMP}/legacy install
1829 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1830 # are built to build other binaries in the system. However, the focus of these
1831 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1832 # libraries, augmented by -legacy.
1834 _bt= _bootstrap-tools
1836 .if ${MK_GAMES} != "no"
1837 _strfile= usr.bin/fortune/strfile
1840 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1841 _gperf= gnu/usr.bin/gperf
1844 .if ${MK_VT} != "no"
1845 _vtfontcvt= usr.bin/vtfontcvt
1848 .if ${BOOTSTRAPPING} < 1000033
1852 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1853 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1856 # r245440 mtree -N support added
1857 # r313404 requires sha384.h for libnetbsd, added to libmd in r292782
1858 .if ${BOOTSTRAPPING} < 1100093
1859 _nmtree= lib/libmd \
1863 ${_bt}-lib/libnetbsd: ${_bt}-lib/libmd
1864 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1867 # r246097: log addition login.conf.db, passwd, pwd.db, and spwd.db with cat -l
1868 .if ${BOOTSTRAPPING} < 1000027
1872 # r277259 crunchide: Correct 64-bit section header offset
1873 # r281674 crunchide: always include both 32- and 64-bit ELF support
1874 .if ${BOOTSTRAPPING} < 1100078
1875 _crunchide= usr.sbin/crunch/crunchide
1878 # r285986 crunchen: use STRIPBIN rather than STRIP
1879 # 1100113: Support MK_AUTO_OBJ
1880 # 1200006: META_MODE fixes
1881 .if ${BOOTSTRAPPING} < 1100078 || \
1882 (${MK_AUTO_OBJ} == "yes" && ${BOOTSTRAPPING} < 1100114) || \
1883 (${MK_META_MODE} == "yes" && ${BOOTSTRAPPING} < 1200006)
1884 _crunchgen= usr.sbin/crunch/crunchgen
1887 # r296926 -P keymap search path, MFC to stable/10 in r298297
1888 .if ${BOOTSTRAPPING} < 1003501 || \
1889 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
1890 _kbdcontrol= usr.sbin/kbdcontrol
1896 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1898 .if ${MK_BSNMP} != "no"
1899 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1902 # We need to build tblgen when we're building clang or lld, either as
1903 # bootstrap tools, or as the part of the normal build.
1904 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
1905 ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no"
1907 lib/clang/libllvmminimal \
1908 usr.bin/clang/llvm-tblgen \
1909 usr.bin/clang/clang-tblgen
1911 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal
1912 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal
1915 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1918 .if ${MK_GPL_DTC} != "no"
1919 _dtc= gnu/usr.bin/dtc
1922 .if ${MK_KERBEROS} != "no"
1923 _kerberos5_bootstrap_tools= \
1924 kerberos5/tools/make-roken \
1925 kerberos5/lib/libroken \
1926 kerberos5/lib/libvers \
1927 kerberos5/tools/asn1_compile \
1928 kerberos5/tools/slc \
1931 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1934 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
1936 bootstrap-tools: .PHONY
1938 # Please document (add comment) why something is in 'bootstrap-tools'.
1939 # Try to bound the building of the bootstrap-tool to just the
1940 # FreeBSD versions that need the tool built at this stage of the build.
1943 ${_kerberos5_bootstrap_tools} \
1964 ${_bt}-${_tool}: .PHONY .MAKE
1965 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1966 cd ${.CURDIR}/${_tool}; \
1967 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
1968 ${MAKE} DIRPRFX=${_tool}/ all; \
1969 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy install
1971 bootstrap-tools: ${_bt}-${_tool}
1975 # build-tools: Build special purpose build tools
1977 .if !defined(NO_SHARE)
1978 _share= share/syscons/scrnmaps
1981 .if ${MK_GCC} != "no"
1982 _gcc_tools= gnu/usr.bin/cc/cc_tools
1985 .if ${MK_RESCUE} != "no"
1986 # rescue includes programs that have build-tools targets
1987 _rescue=rescue/rescue
1990 .if ${MK_TCSH} != "no"
1993 .if ${MK_FILE} != "no"
1994 _libmagic=lib/libmagic
1997 # kernel-toolchain skips _cleanobj, so handle cleaning up previous
1998 # build-tools directories if needed.
1999 .if !defined(NO_CLEAN) && make(kernel-toolchain)
2000 _bt_clean= ${CLEANDIR}
2006 ${LOCAL_TOOL_DIRS} \
2007 lib/ncurses/ncurses \
2008 lib/ncurses/ncursesw \
2013 usr.bin/mkesdb_static \
2014 usr.bin/mkcsmapper_static \
2015 usr.bin/vi/catalog \
2017 build-tools_${_tool}: .PHONY
2018 ${_+_}@${ECHODIR} "===> ${_tool} (${_bt_clean:D${_bt_clean},}obj,build-tools)"; \
2019 cd ${.CURDIR}/${_tool}; \
2020 if [ -n "${_bt_clean}" ]; then ${MAKE} DIRPRFX=${_tool}/ ${_bt_clean}; fi; \
2021 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2022 ${MAKE} DIRPRFX=${_tool}/ build-tools
2023 build-tools: build-tools_${_tool}
2027 # kernel-tools: Build kernel-building tools
2029 kernel-tools: .PHONY
2030 mkdir -p ${WORLDTMP}/usr
2031 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2032 -p ${WORLDTMP}/usr >/dev/null
2035 # cross-tools: All the tools needed to build the rest of the system after
2036 # we get done with the earlier stages. It is the last set of tools needed
2037 # to begin building the target binaries.
2039 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
2040 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
2041 _btxld= usr.sbin/btxld
2045 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
2046 # resulting from missing bug fixes or ELF Toolchain updates.
2047 .if ${MK_CDDL} != "no"
2048 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
2049 cddl/usr.bin/ctfmerge
2052 # If we're given an XAS, don't build binutils.
2053 .if ${XAS:M/*} == ""
2054 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
2055 _binutils= gnu/usr.bin/binutils
2057 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
2058 _elftctools= lib/libelftc \
2064 # These are not required by the build, but can be useful for developers who
2065 # cross-build on a FreeBSD 10 host:
2066 _elftctools+= usr.bin/addr2line
2068 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
2069 # If cross-building with an external binutils we still need to build strip for
2070 # the target (for at least crunchide).
2071 _elftctools= lib/libelftc \
2076 .if ${MK_CLANG_BOOTSTRAP} != "no"
2077 _clang= usr.bin/clang
2079 .if ${MK_LLD_BOOTSTRAP} != "no"
2080 _lld= usr.bin/clang/lld
2082 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no"
2083 _clang_libs= lib/clang
2085 .if ${MK_GCC_BOOTSTRAP} != "no"
2086 _gcc= gnu/usr.bin/cc
2088 .if ${MK_USB} != "no"
2089 _usb_tools= stand/usb/tools
2092 cross-tools: .MAKE .PHONY
2094 ${LOCAL_XTOOL_DIRS} \
2104 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2105 cd ${.CURDIR}/${_tool}; \
2106 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2107 ${MAKE} DIRPRFX=${_tool}/ all; \
2108 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP} install
2112 # native-xtools is the current target for qemu-user cross builds of ports
2113 # via poudriere and the imgact_binmisc kernel module.
2114 # This target merely builds a toolchan/sysroot, then builds the tools it wants
2115 # with the options it wants in a special MAKEOBJDIRPREFIX, using the toolchain
2116 # already built. It then installs the static tools to NXBDESTDIR for Poudriere
2119 NXBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/nxb/
2120 NXBOBJTOP= ${NXBOBJROOT}${NXB_TARGET}.${NXB_TARGET_ARCH}
2123 .error NXTP variable should be an absolute path
2125 NXBDESTDIR?= ${DESTDIR}${NXTP}
2127 # This is the list of tools to be built/installed as static and where
2128 # appropriate to build for the given TARGET.TARGET_ARCH.
2190 SUBDIR_DEPEND_usr.bin/clang= lib/clang
2191 .if ${MK_CLANG} != "no"
2193 NXBDIRS+= usr.bin/clang
2195 .if ${MK_GCC} != "no"
2196 NXBDIRS+= gnu/usr.bin/cc
2198 .if ${MK_BINUTILS} != "no"
2199 NXBDIRS+= gnu/usr.bin/binutils
2201 # XXX: native-xtools passes along ${NXBDIRS} in SUBDIR_OVERRIDE that needs
2202 # to be evaluated after NXBDIRS is set.
2203 .if make(install) && !empty(SUBDIR_OVERRIDE)
2204 SUBDIR= ${SUBDIR_OVERRIDE}
2208 OBJTOP=${NXBOBJTOP:Q} \
2209 OBJROOT=${NXBOBJROOT:Q} \
2215 MK_CLANG_EXTRAS=no \
2233 .if make(native-xtools*) && \
2234 (!defined(NXB_TARGET) || !defined(NXB_TARGET_ARCH))
2235 .error Missing NXB_TARGET / NXB_TARGET_ARCH
2237 # For 'toolchain' we want to produce native binaries that themselves generate
2239 NXBTMAKE= ${NXBMAKEENV} ${MAKE} ${NXBMAKEARGS:N-DNO_PIC:N-DNO_SHARED} \
2240 TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH}
2241 # For 'everything' we want to produce native binaries (hence -target to
2242 # be MACHINE) that themselves generate TARGET.TARGET_ARCH binaries.
2243 # TARGET/TARGET_ARCH are still passed along from user.
2245 # Use the toolchain we create as an external toolchain.
2246 .if ${USING_SYSTEM_COMPILER} == "yes" || ${XCC:N${CCACHE_BIN}:M/*}
2247 NXBMAKE+= XCC="${XCC}" \
2251 NXBMAKE+= XCC="${NXBOBJTOP}/tmp/usr/bin/cc" \
2252 XCXX="${NXBOBJTOP}/tmp/usr/bin/c++" \
2253 XCPP="${NXBOBJTOP}/tmp/usr/bin/cpp"
2255 NXBMAKE+= ${NXBMAKEENV} ${MAKE} -f Makefile.inc1 ${NXBMAKEARGS} \
2256 TARGET=${NXB_TARGET} TARGET_ARCH=${NXB_TARGET_ARCH} \
2257 TARGET_TRIPLE=${MACHINE_TRIPLE:Q}
2258 # NXBDIRS is improperly based on MACHINE rather than NXB_TARGET. Need to
2259 # invoke a sub-make to reevaluate MK_GCC, etc, for NXBDIRS.
2260 NXBMAKE+= SUBDIR_OVERRIDE='$${NXBDIRS:M*}'
2261 # Need to avoid the -isystem logic when using clang as an external toolchain
2262 # even if the TARGET being built for wants GCC.
2263 NXBMAKE+= WANT_COMPILER_TYPE='$${X_COMPILER_TYPE}'
2264 native-xtools: .PHONY
2265 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _cleanobj MK_GCC=yes
2266 # Build the bootstrap/host/cross tools that produce native binaries
2267 # Pass along MK_GCC=yes to ensure GCC-needed build tools are built.
2268 # We don't quite know what the NXB_TARGET wants so just build it.
2269 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} kernel-toolchain MK_GCC=yes
2270 # Populate includes/libraries sysroot that produce native binaries.
2271 # This is split out from 'toolchain' above mostly so that target LLVM
2272 # libraries have a proper LLVM_DEFAULT_TARGET_TRIPLE without
2273 # polluting the cross-compiler build. The LLVM/GCC libs are skipped
2274 # here to avoid the problem but are kept in 'toolchain' so that
2275 # needed build tools are built.
2276 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes MK_CLANG=no MK_GCC=no
2277 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries MK_CLANG=no MK_GCC=no
2278 # Clean out improper TARGET=MACHINE files
2279 ${_+_}cd ${.CURDIR}/gnu/usr.bin/cc/cc_tools; ${NXBTMAKE} cleandir
2280 .if !defined(NO_OBJWALK)
2281 ${_+_}cd ${.CURDIR}; ${NXBMAKE} _obj
2283 ${_+_}cd ${.CURDIR}; ${NXBMAKE} everything
2284 @echo ">> native-xtools done. Use 'make native-xtools-install' to install to a given DESTDIR"
2286 native-xtools-install: .PHONY
2287 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
2288 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2289 -p ${NXBDESTDIR}/usr >/dev/null
2290 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2291 -p ${NXBDESTDIR}/usr/include >/dev/null
2292 ${_+_}cd ${.CURDIR}; ${NXBMAKE} \
2293 DESTDIR=${NXBDESTDIR} \
2298 # hierarchy - ensure that all the needed directories are present
2300 hierarchy hier: .MAKE .PHONY
2301 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
2304 # libraries - build all libraries, and install them under ${DESTDIR}.
2306 # The list of libraries with dependents (${_prebuild_libs}) and their
2307 # interdependencies (__L) are built automatically by the
2308 # ${.CURDIR}/tools/make_libdeps.sh script.
2310 libraries: .MAKE .PHONY
2311 ${_+_}cd ${.CURDIR}; \
2312 ${MAKE} -f Makefile.inc1 _prereq_libs; \
2313 ${MAKE} -f Makefile.inc1 _startup_libs; \
2314 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
2315 ${MAKE} -f Makefile.inc1 _generic_libs
2318 # static libgcc.a prerequisite for shared libc
2320 _prereq_libs= lib/libcompiler_rt
2321 .if ${MK_SSP} != "no"
2322 _prereq_libs+= gnu/lib/libssp/libssp_nonshared
2325 # These dependencies are not automatically generated:
2327 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
2328 # all shared libraries for ELF.
2330 _startup_libs= gnu/lib/csu
2331 _startup_libs+= lib/csu
2332 _startup_libs+= lib/libcompiler_rt
2333 _startup_libs+= lib/libc
2334 _startup_libs+= lib/libc_nonshared
2335 .if ${MK_LIBCPLUSPLUS} != "no"
2336 _startup_libs+= lib/libcxxrt
2339 .if ${MK_LLVM_LIBUNWIND} != "no"
2340 _prereq_libs+= lib/libgcc_eh lib/libgcc_s
2341 _startup_libs+= lib/libgcc_eh lib/libgcc_s
2343 lib/libgcc_s__L: lib/libc__L
2344 lib/libgcc_s__L: lib/libc_nonshared__L
2345 .if ${MK_LIBCPLUSPLUS} != "no"
2346 lib/libcxxrt__L: lib/libgcc_s__L
2349 .else # MK_LLVM_LIBUNWIND == no
2351 _prereq_libs+= gnu/lib/libgcc
2352 _startup_libs+= gnu/lib/libgcc
2354 gnu/lib/libgcc__L: lib/libc__L
2355 gnu/lib/libgcc__L: lib/libc_nonshared__L
2356 .if ${MK_LIBCPLUSPLUS} != "no"
2357 lib/libcxxrt__L: gnu/lib/libgcc__L
2361 _prebuild_libs= ${_kerberos5_lib_libasn1} \
2362 ${_kerberos5_lib_libhdb} \
2363 ${_kerberos5_lib_libheimbase} \
2364 ${_kerberos5_lib_libheimntlm} \
2366 ${_kerberos5_lib_libheimipcc} \
2367 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
2368 ${_kerberos5_lib_libroken} \
2369 ${_kerberos5_lib_libwind} \
2370 lib/libbz2 ${_libcom_err} lib/libcrypt \
2371 lib/libelf lib/libexpat \
2374 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
2376 lib/ncurses/ncurses lib/ncurses/ncursesw \
2377 lib/libopie lib/libpam/libpam ${_lib_libthr} \
2378 ${_lib_libradius} lib/libsbuf lib/libtacplus \
2380 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
2381 ${_cddl_lib_libuutil} \
2382 ${_cddl_lib_libavl} \
2383 ${_cddl_lib_libzfs_core} \
2384 ${_cddl_lib_libctf} \
2385 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
2386 ${_secure_lib_libcrypto} ${_lib_libldns} \
2387 ${_secure_lib_libssh} ${_secure_lib_libssl}
2389 .if ${MK_GNUCXX} != "no"
2390 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
2391 gnu/lib/libstdc++__L: lib/msun__L
2392 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
2395 .if ${MK_DIALOG} != "no"
2396 _prebuild_libs+= gnu/lib/libdialog
2397 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2400 .if ${MK_LIBCPLUSPLUS} != "no"
2401 _prebuild_libs+= lib/libc++
2404 lib/libgeom__L: lib/libexpat__L
2405 lib/libkvm__L: lib/libelf__L
2407 .if ${MK_LIBTHR} != "no"
2408 _lib_libthr= lib/libthr
2411 .if ${MK_RADIUS_SUPPORT} != "no"
2412 _lib_libradius= lib/libradius
2415 .if ${MK_OFED} != "no"
2417 # The OFED libraries are built in four steps
2418 # as reflected below, due to interdependencies.
2420 # NOTE: Depending on contrib/ofed/include is only needed for
2421 # the lib32 compat build.
2424 contrib/ofed/include \
2425 contrib/ofed/usr.lib/0 \
2426 contrib/ofed/usr.lib/1 \
2427 contrib/ofed/usr.lib/2 \
2428 contrib/ofed/usr.lib/3
2430 contrib/ofed/usr.lib/0__L: contrib/ofed/include__L lib/libthr__L
2431 contrib/ofed/usr.lib/1__L: contrib/ofed/usr.lib/0__L
2432 contrib/ofed/usr.lib/2__L: contrib/ofed/usr.lib/1__L
2433 contrib/ofed/usr.lib/3__L: contrib/ofed/usr.lib/2__L
2436 .if ${MK_CASPER} != "no"
2437 _lib_casper= lib/libcasper
2440 lib/libpjdlog__L: lib/libutil__L
2441 lib/libcasper__L: lib/libnv__L
2442 lib/liblzma__L: lib/libthr__L
2444 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
2445 .if ${MK_IPFILTER} != "no"
2446 _generic_libs+= sbin/ipf/libipf
2448 .for _DIR in ${LOCAL_LIB_DIRS}
2449 .if ${_DIR} == ".WAIT" || (empty(_generic_libs:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
2450 _generic_libs+= ${_DIR}
2454 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2456 .if ${MK_CDDL} != "no"
2457 _cddl_lib_libumem= cddl/lib/libumem
2458 _cddl_lib_libnvpair= cddl/lib/libnvpair
2459 _cddl_lib_libavl= cddl/lib/libavl
2460 _cddl_lib_libuutil= cddl/lib/libuutil
2461 .if ${MK_ZFS} != "no"
2462 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2463 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2465 _cddl_lib_libctf= cddl/lib/libctf
2467 cddl/lib/libctf__L: lib/libz__L
2469 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
2470 # on select architectures though (see cddl/lib/Makefile)
2471 .if ${MACHINE_CPUARCH} != "sparc64"
2472 _prebuild_libs+= lib/libprocstat lib/libproc lib/librtld_db
2473 lib/libprocstat__L: lib/libelf__L lib/libkvm__L lib/libutil__L
2474 lib/libproc__L: lib/libprocstat__L
2475 lib/librtld_db__L: lib/libprocstat__L
2478 .if ${MK_CRYPT} != "no"
2479 .if ${MK_OPENSSL} != "no"
2480 _secure_lib_libcrypto= secure/lib/libcrypto
2481 _secure_lib_libssl= secure/lib/libssl
2482 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2483 .if ${MK_LDNS} != "no"
2484 _lib_libldns= lib/libldns
2485 lib/libldns__L: secure/lib/libcrypto__L
2487 .if ${MK_OPENSSH} != "no"
2488 _secure_lib_libssh= secure/lib/libssh
2489 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2490 .if ${MK_LDNS} != "no"
2491 secure/lib/libssh__L: lib/libldns__L
2493 .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no"
2494 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2495 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2496 lib/libmd__L kerberos5/lib/libroken__L
2500 _secure_lib= secure/lib
2503 .if ${MK_KERBEROS} != "no"
2504 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2505 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2506 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2507 kerberos5/lib/libwind__L lib/libsqlite3__L
2508 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2509 kerberos5/lib/libroken__L lib/libcom_err__L
2510 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2511 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2512 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2513 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2514 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2515 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2516 kerberos5/lib/libroken__L: lib/libcrypt__L
2517 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2518 kerberos5/lib/libheimbase__L: lib/libthr__L
2519 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2522 lib/libsqlite3__L: lib/libthr__L
2524 .if ${MK_GSSAPI} != "no"
2525 _lib_libgssapi= lib/libgssapi
2528 .if ${MK_KERBEROS} != "no"
2529 _kerberos5_lib= kerberos5/lib
2530 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2531 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2532 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2533 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2534 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2535 _kerberos5_lib_libroken= kerberos5/lib/libroken
2536 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2537 _libsqlite3= lib/libsqlite3
2538 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2539 _kerberos5_lib_libwind= kerberos5/lib/libwind
2540 _libcom_err= lib/libcom_err
2543 .if ${MK_NIS} != "no"
2544 _lib_libypclnt= lib/libypclnt
2547 .if ${MK_OPENSSL} == "no"
2548 lib/libradius__L: lib/libmd__L
2552 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2553 .if ${MK_CXX} != "no"
2554 .if ${MK_LIBCPLUSPLUS} != "no"
2555 lib/libproc__L: lib/libcxxrt__L
2556 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2557 lib/libproc__L: gnu/lib/libsupc++__L
2561 .for _lib in ${_prereq_libs}
2562 ${_lib}__PL: .PHONY .MAKE
2563 .if exists(${.CURDIR}/${_lib})
2564 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2565 cd ${.CURDIR}/${_lib}; \
2566 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
2567 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2568 DIRPRFX=${_lib}/ all; \
2569 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2570 DIRPRFX=${_lib}/ install
2574 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
2575 ${_lib}__L: .PHONY .MAKE
2576 .if exists(${.CURDIR}/${_lib})
2577 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2578 cd ${.CURDIR}/${_lib}; \
2579 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
2580 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2581 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2585 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2586 _startup_libs: ${_startup_libs:S/$/__L/}
2587 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2588 _generic_libs: ${_generic_libs:S/$/__L/}
2590 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2591 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2592 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2593 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2594 # parallel. This is safe for the world stage of buildworld though since it has
2595 # already built libraries in a proper order and installed includes into
2596 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2597 # avoid trashing a system if it crashes mid-install.
2598 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2602 .include <bsd.subdir.mk>
2604 .if make(check-old) || make(check-old-dirs) || \
2605 make(check-old-files) || make(check-old-libs) || \
2606 make(delete-old) || make(delete-old-dirs) || \
2607 make(delete-old-files) || make(delete-old-libs)
2610 # check for / delete old files section
2613 .include "ObsoleteFiles.inc"
2615 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2616 else you can not start such an application. Consult UPDATING for more \
2617 information regarding how to cope with the removal/revision bump of a \
2620 .if !defined(BATCH_DELETE_OLD_FILES)
2626 delete-old-files: .PHONY
2627 @echo ">>> Removing old files (only deletes safe to delete libs)"
2628 # Ask for every old file if the user really wants to remove it.
2629 # It's annoying, but better safe than sorry.
2630 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2631 # argument list will get too long. Using .for/.endfor make "loops" will make
2632 # the Makefile parser segfault.
2635 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2636 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2637 while read file; do \
2638 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2639 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2640 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2642 for ext in debug symbols; do \
2643 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2644 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2645 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2650 # Remove catpages without corresponding manpages.
2652 find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \
2653 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2654 while read catpage; do \
2656 if [ ! -e "$${manpage}" ]; then \
2657 rm ${RM_I} $${catpage} <&3; \
2660 @echo ">>> Old files removed"
2662 check-old-files: .PHONY
2663 @echo ">>> Checking for old files"
2665 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2666 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2667 while read file; do \
2668 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2669 echo "${DESTDIR}/$${file}"; \
2671 for ext in debug symbols; do \
2672 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2673 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2677 # Check for 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 \
2687 delete-old-libs: .PHONY
2688 @echo ">>> Removing old libraries"
2689 @echo "${OLD_LIBS_MESSAGE}" | fmt
2692 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2693 -V OLD_LIBS | xargs -n1 | \
2694 while read file; do \
2695 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2696 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2697 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2699 for ext in debug symbols; do \
2700 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2701 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2702 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2707 @echo ">>> Old libraries removed"
2709 check-old-libs: .PHONY
2710 @echo ">>> Checking for old libraries"
2712 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2713 -V OLD_LIBS | xargs -n1 | \
2714 while read file; do \
2715 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2716 echo "${DESTDIR}/$${file}"; \
2718 for ext in debug symbols; do \
2719 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2720 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2725 delete-old-dirs: .PHONY
2726 @echo ">>> Removing old directories"
2728 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2729 -V OLD_DIRS | xargs -n1 | sort -r | \
2730 while read dir; do \
2731 if [ -d "${DESTDIR}/$${dir}" ]; then \
2732 rmdir -v "${DESTDIR}/$${dir}" || true; \
2733 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2734 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2736 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2737 rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \
2738 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2739 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2742 @echo ">>> Old directories removed"
2744 check-old-dirs: .PHONY
2745 @echo ">>> Checking for old directories"
2747 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2748 -V OLD_DIRS | xargs -n1 | \
2749 while read dir; do \
2750 if [ -d "${DESTDIR}/$${dir}" ]; then \
2751 echo "${DESTDIR}/$${dir}"; \
2752 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2753 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2755 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2756 echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \
2757 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2758 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2762 delete-old: delete-old-files delete-old-dirs .PHONY
2763 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2765 check-old: check-old-files check-old-libs check-old-dirs .PHONY
2766 @echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
2767 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2772 # showconfig - show build configuration.
2775 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes; \
2776 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes) 2>&1 | grep ^MK_ | sort -u
2778 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2779 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2781 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2782 .if exists(${KERNCONFDIR}/${KERNCONF})
2783 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2784 '${KERNCONFDIR}/${KERNCONF}' ; echo
2790 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2791 DTBOUTPUTPATH= ${.CURDIR}
2795 # Build 'standalone' Device Tree Blob
2798 @PATH=${TMPPATH} MACHINE=${TARGET} \
2799 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2800 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2805 # In the following, the first 'rm' in a series will usually remove all
2806 # files and directories. If it does not, then there are probably some
2807 # files with file flags set, so this unsets them and tries the 'rm' a
2808 # second time. There are situations where this target will be cleaning
2809 # some directories via more than one method, but that duplication is
2810 # needed to correctly handle all the possible situations. Removing all
2811 # files without file flags set in the first 'rm' instance saves time,
2812 # because 'chflags' will need to operate on fewer files afterwards.
2814 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2815 # created by bsd.obj.mk, except that we don't want to .include that file
2816 # in this makefile. We don't do a cleandir walk if MK_AUTO_OBJ is yes
2817 # since it is not possible for files to land in the wrong place.
2819 .if make(cleanworld)
2820 BW_CANONICALOBJDIR:=${OBJTOP}/
2821 .elif make(cleanuniverse)
2822 BW_CANONICALOBJDIR:=${OBJROOT}
2823 .if ${MK_UNIFIED_OBJDIR} == "no"
2824 .error ${.TARGETS} only supported with WITH_UNIFIED_OBJDIR enabled.
2827 cleanworld cleanuniverse: .PHONY
2828 .if !empty(BW_CANONICALOBJDIR) && exists(${BW_CANONICALOBJDIR}) && \
2829 ${.CURDIR:tA} != ${BW_CANONICALOBJDIR:tA}
2830 -rm -rf ${BW_CANONICALOBJDIR}*
2831 -chflags -R 0 ${BW_CANONICALOBJDIR}
2832 rm -rf ${BW_CANONICALOBJDIR}*
2834 .if make(cleanworld) && ${MK_AUTO_OBJ} == "no" && \
2835 (empty(BW_CANONICALOBJDIR) || ${.CURDIR:tA} == ${BW_CANONICALOBJDIR:tA})
2836 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2837 # To be safe in this case, fall back to a 'make cleandir'
2838 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2842 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2843 XDEV_CPUTYPE?=${CPUTYPE}
2845 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2848 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2849 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2850 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2851 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2852 CPUTYPE=${XDEV_CPUTYPE}
2854 XDDIR=${TARGET_ARCH}-freebsd
2857 .error XDTP variable should be an absolute path
2860 CDBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/xdev/
2861 CDBOBJTOP= ${CDBOBJROOT}${XDDIR}
2863 INSTALL="sh ${.CURDIR}/tools/install.sh"
2865 TOOLS_PREFIX=${XDTP}
2867 OBJTOP=${CDBOBJTOP:Q} \
2868 OBJROOT=${CDBOBJROOT:Q}
2869 CD2MAKEARGS= ${CDMAKEARGS}
2871 .if ${WANT_COMPILER_TYPE} == gcc || \
2872 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
2873 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
2874 # won't set header path and -L is used to ensure the base library path
2875 # is added before the port PREFIX library path.
2876 CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib
2877 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
2878 # combined with --sysroot.
2879 CD2CFLAGS+= -B${XDDESTDIR}/usr/lib
2880 # Force using libc++ for external GCC.
2881 .if ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
2882 CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \
2886 CD2CFLAGS+= --sysroot=${XDDESTDIR}/
2887 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \
2888 CPP="${CPP} ${CD2CFLAGS}" \
2889 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2891 CDTMP= ${OBJTOP}/${XDDIR}/tmp
2892 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${CDMAKEARGS} ${NOFUN}
2893 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} \
2894 ${MAKE} ${CD2MAKEARGS} ${NOFUN}
2895 .if ${MK_META_MODE} != "no"
2896 # Don't rebuild build-tools targets during normal build.
2897 CD2MAKE+= BUILD_TOOLS_META=.NOMETA
2899 XDDESTDIR=${DESTDIR}${XDTP}
2901 .ORDER: xdev-build xdev-install xdev-links
2902 xdev: xdev-build xdev-install .PHONY
2904 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2905 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
2907 _xb-worldtmp: .PHONY
2908 mkdir -p ${CDTMP}/usr
2909 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2910 -p ${CDTMP}/usr >/dev/null
2912 _xb-bootstrap-tools: .PHONY
2917 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2918 cd ${.CURDIR}/${_tool}; \
2919 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
2920 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2921 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2924 _xb-build-tools: .PHONY
2925 ${_+_}@cd ${.CURDIR}; \
2926 ${CDBENV} ${MAKE} ${CDMAKEARGS} -f Makefile.inc1 ${NOFUN} build-tools
2937 _xb-cross-tools: .PHONY
2938 .for _tool in ${XDEVDIRS}
2939 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2940 cd ${.CURDIR}/${_tool}; \
2941 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
2942 ${CDMAKE} DIRPRFX=${_tool}/ all
2946 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2947 mkdir -p ${XDDESTDIR}
2948 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2949 -p ${XDDESTDIR} >/dev/null
2950 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2951 -p ${XDDESTDIR}/usr >/dev/null
2952 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2953 -p ${XDDESTDIR}/usr/include >/dev/null
2954 .if defined(LIBCOMPAT)
2955 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2956 -p ${XDDESTDIR}/usr >/dev/null
2958 .if ${MK_TESTS} != "no"
2959 mkdir -p ${XDDESTDIR}${TESTSBASE}
2960 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2961 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2964 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2965 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
2967 _xi-cross-tools: .PHONY
2968 @echo "_xi-cross-tools"
2969 .for _tool in ${XDEVDIRS}
2970 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2971 cd ${.CURDIR}/${_tool}; \
2972 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2975 _xi-includes: .PHONY
2976 .if !defined(NO_OBJWALK)
2977 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 _obj \
2978 DESTDIR=${XDDESTDIR}
2980 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2981 DESTDIR=${XDDESTDIR}
2983 _xi-libraries: .PHONY
2984 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2985 DESTDIR=${XDDESTDIR}
2988 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2989 mkdir -p ../../../../usr/bin; \
2991 ln -sf ../../${XDTP}/usr/bin/$$i \
2992 ../../../../usr/bin/${XDDIR}-$$i; \
2993 ln -sf ../../${XDTP}/usr/bin/$$i \
2994 ../../../../usr/bin/${XDDIR}${_REVISION}-$$i; \