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 .if exists(${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk)
60 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
61 .elif exists(${CROSS_TOOLCHAIN})
62 .include "${CROSS_TOOLCHAIN}"
64 .error CROSS_TOOLCHAIN ${CROSS_TOOLCHAIN} not found
66 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
68 .if defined(CROSS_TOOLCHAIN_PREFIX)
69 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
72 XCOMPILERS= CC CXX CPP
73 .for COMPILER in ${XCOMPILERS}
74 .if defined(CROSS_COMPILER_PREFIX)
75 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
77 X${COMPILER}?= ${${COMPILER}}
80 # If a full path to an external cross compiler is given, don't build
82 .if ${XCC:N${CCACHE_BIN}:M/*}
83 MK_CLANG_BOOTSTRAP= no
87 # Pull in compiler metadata from buildworld/toolchain if possible to avoid
88 # running CC from bsd.compiler.mk.
89 .if make(installworld) || make(install) || make(distributeworld) || \
91 .-include "${OBJTOP}/compiler-metadata.mk"
94 # Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early. Pull it from the
95 # tree to be friendlier to foreign OS builds. It's safe to do so unconditionally
96 # here since we will always have the right make, unlike in src/Makefile
97 .include "share/mk/bsd.compiler.mk"
98 .include "share/mk/src.opts.mk"
100 # Check if there is a local compiler that can satisfy as an external compiler.
101 # Which compiler is expected to be used?
102 .if ${MK_CLANG_BOOTSTRAP} == "yes"
103 WANT_COMPILER_TYPE= clang
104 .elif ${MK_GCC_BOOTSTRAP} == "yes"
105 WANT_COMPILER_TYPE= gcc
109 .if !defined(WANT_COMPILER_FREEBSD_VERSION)
110 .if ${WANT_COMPILER_TYPE} == "clang"
111 WANT_COMPILER_FREEBSD_VERSION_FILE= lib/clang/freebsd_cc_version.h
112 WANT_COMPILER_FREEBSD_VERSION!= \
113 awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
114 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
115 WANT_COMPILER_VERSION_FILE= lib/clang/include/clang/Basic/Version.inc
116 WANT_COMPILER_VERSION!= \
117 awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
118 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
119 .elif ${WANT_COMPILER_TYPE} == "gcc"
120 WANT_COMPILER_FREEBSD_VERSION_FILE= gnu/usr.bin/cc/cc_tools/freebsd-native.h
121 WANT_COMPILER_FREEBSD_VERSION!= \
122 awk '$$2 == "FBSD_CC_VER" {printf("%d\n", $$3)}' \
123 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
124 WANT_COMPILER_VERSION_FILE= contrib/gcc/BASE-VER
125 WANT_COMPILER_VERSION!= \
126 awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3}' \
127 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
129 .export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION
130 .endif # !defined(WANT_COMPILER_FREEBSD_VERSION)
131 # It needs to be the same revision as we would build for the bootstrap.
132 # If the expected vs CC is different then we can't skip.
133 # GCC cannot be used for cross-arch yet. For clang we pass -target later if
134 # TARGET_ARCH!=MACHINE_ARCH.
135 .if ${MK_SYSTEM_COMPILER} == "yes" && \
136 (${MK_CLANG_BOOTSTRAP} == "yes" || ${MK_GCC_BOOTSTRAP} == "yes") && \
137 !make(showconfig) && !make(xdev*) && \
138 ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE} && \
139 (${COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \
140 ${COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \
141 ${COMPILER_FREEBSD_VERSION} == ${WANT_COMPILER_FREEBSD_VERSION}
142 # Everything matches, disable the bootstrap compiler.
143 MK_CLANG_BOOTSTRAP= no
145 USING_SYSTEM_COMPILER= yes
146 .endif # ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE}
147 USING_SYSTEM_COMPILER?= no
148 TEST_SYSTEM_COMPILER_VARS= \
149 USING_SYSTEM_COMPILER MK_SYSTEM_COMPILER \
150 MK_CROSS_COMPILER MK_CLANG_BOOTSTRAP MK_GCC_BOOTSTRAP \
151 WANT_COMPILER_TYPE WANT_COMPILER_VERSION WANT_COMPILER_VERSION_FILE \
152 WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \
153 CC COMPILER_TYPE COMPILER_FEATURES COMPILER_VERSION \
154 COMPILER_FREEBSD_VERSION \
155 X_COMPILER_TYPE X_COMPILER_FEATURES X_COMPILER_VERSION \
156 X_COMPILER_FREEBSD_VERSION \
157 LINKER_TYPE LINKER_FEATURES LINKER_VERSION \
158 X_LINKER_TYPE X_LINKER_FEATURES X_LINKER_VERSION
159 test-system-compiler: .PHONY
160 .for v in ${TEST_SYSTEM_COMPILER_VARS}
161 ${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}"
163 .if ${USING_SYSTEM_COMPILER} == "yes" && \
164 (make(buildworld) || make(buildkernel) || make(kernel-toolchain) || \
165 make(toolchain) || make(_cross-tools))
166 .info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler.
169 # For installworld need to ensure that the looked-up compiler metadata is
170 # passed along rather than trying to run cc from the restricted
172 .if ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
173 .if !defined(X_COMPILER_TYPE)
174 CROSSENV+= COMPILER_VERSION=${COMPILER_VERSION} \
175 COMPILER_TYPE=${COMPILER_TYPE} \
176 COMPILER_FEATURES="${COMPILER_FEATURES}" \
177 COMPILER_FREEBSD_VERSION=${COMPILER_FREEBSD_VERSION}
179 CROSSENV+= COMPILER_VERSION=${X_COMPILER_VERSION} \
180 COMPILER_FEATURES="${X_COMPILER_FEATURES}" \
181 COMPILER_TYPE=${X_COMPILER_TYPE} \
182 COMPILER_FREEBSD_VERSION=${X_COMPILER_FREEBSD_VERSION}
185 # Store some compiler metadata for use in installworld where we don't
186 # want to invoke CC at all.
187 _COMPILER_METADATA_VARS= COMPILER_VERSION \
190 COMPILER_FREEBSD_VERSION \
194 compiler-metadata.mk: .PHONY .META
196 @echo ".info Using cached compiler metadata from build at $$(hostname) on $$(date)" \
198 .for v in ${_COMPILER_METADATA_VARS}
199 @echo "${v}=${${v}}" >> ${.TARGET}
201 @echo ".export ${_COMPILER_METADATA_VARS}" >> ${.TARGET}
203 # Handle external binutils.
204 .if defined(CROSS_TOOLCHAIN_PREFIX)
205 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
207 # If we do not have a bootstrap binutils (because the in-tree one does not
208 # support the target architecture), provide a default cross-binutils prefix.
209 # This allows riscv64 builds, for example, to automatically use the
210 # riscv64-binutils port or package.
211 .if !make(showconfig)
212 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
213 ${MK_LLD_BOOTSTRAP} == "no" && \
214 !defined(CROSS_BINUTILS_PREFIX)
215 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
216 .if !exists(${CROSS_BINUTILS_PREFIX})
217 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
221 XBINUTILS= AS AR LD NM OBJCOPY RANLIB SIZE STRINGS
222 .for BINUTIL in ${XBINUTILS}
223 .if defined(CROSS_BINUTILS_PREFIX) && \
224 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
225 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
227 X${BINUTIL}?= ${${BINUTIL}}
232 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
233 # keep the users system reasonably usable. For static->dynamic root upgrades,
234 # we don't want to install a dynamic binary without rtld and the needed
235 # libraries. More commonly, for dynamic root, we don't want to install a
236 # binary that requires a newer library version that hasn't been installed yet.
237 # This ordering is not a guarantee though. The only guarantee of a working
238 # system here would require fine-grained ordering of all components based
239 # on their dependencies.
240 .if !empty(SUBDIR_OVERRIDE)
241 SUBDIR= ${SUBDIR_OVERRIDE}
244 .if !defined(NO_ROOT) && (make(installworld) || make(install))
245 # Ensure libraries are installed before progressing.
249 .if ${MK_CDDL} != "no"
253 .if ${MK_KERBEROS} != "no"
256 .if ${MK_RESCUE} != "no"
260 .if ${MK_CRYPT} != "no"
263 .if !defined(NO_SHARE)
266 .if ${MK_BOOT} != "no"
269 SUBDIR+=sys usr.bin usr.sbin
270 .if ${MK_TESTS} != "no"
273 .if ${MK_OFED} != "no"
277 # Local directories are built in parallel with the base system directories.
278 # Users may insert a .WAIT directive at the beginning or elsewhere within
279 # the LOCAL_DIRS and LOCAL_LIB_DIRS lists as needed.
280 .for _DIR in ${LOCAL_DIRS}
281 .if ${_DIR} == ".WAIT" || exists(${.CURDIR}/${_DIR}/Makefile)
285 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
286 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
287 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
288 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
289 _REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
291 .for _DIR in ${LOCAL_LIB_DIRS}
292 .if ${_DIR} == ".WAIT" || (empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
297 # We must do etc/ last as it hooks into building the man whatis file
298 # by calling 'makedb' in share/man. This is only relevant for
299 # install/distribute so they build the whatis file after every manpage is
301 .if make(installworld) || make(install)
306 .endif # !empty(SUBDIR_OVERRIDE)
309 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
312 .if defined(NO_CLEANDIR)
313 CLEANDIR= clean cleandepend
318 .if defined(WORLDFAST)
323 .if ${MK_META_MODE} == "yes"
324 # If filemon is used then we can rely on the build being incremental-safe.
325 # The .meta files will also track the build command and rebuild should
327 .if empty(.MAKE.MODE:Mnofilemon)
331 .if defined(NO_OBJWALK) || ${MK_AUTO_OBJ} == "yes"
335 .if !defined(NO_OBJWALK)
340 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
342 .if empty(SHELL:M*csh*)
343 BUILDENV_SHELL?=${SHELL}
345 BUILDENV_SHELL?=/bin/sh
348 .if !defined(SVN_CMD) || empty(SVN_CMD)
349 . for _P in /usr/bin /usr/local/bin
350 . for _S in svn svnlite
351 . if exists(${_P}/${_S})
359 .if !defined(VCS_REVISION) || empty(VCS_REVISION)
360 .if !defined(SVNVERSION_CMD) || empty(SVNVERSION_CMD)
361 . for _D in ${PATH:S,:, ,g}
362 . if exists(${_D}/svnversion)
363 SVNVERSION_CMD?=${_D}/svnversion
365 . if exists(${_D}/svnliteversion)
366 SVNVERSION_CMD?=${_D}/svnliteversion
370 _VCS_REVISION?= $$(eval ${SVNVERSION_CMD} ${SRCDIR})
371 . if !empty(_VCS_REVISION)
372 VCS_REVISION= $$(echo r${_VCS_REVISION})
377 .if !defined(OSRELDATE)
378 .if exists(/usr/include/osreldate.h)
379 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
380 /usr/include/osreldate.h
387 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
388 .if !defined(_REVISION)
389 _REVISION!= ${MAKE} -C ${SRCDIR}/release MK_AUTO_OBJ=no -V REVISION
392 .if !defined(_BRANCH)
393 _BRANCH!= ${MAKE} -C ${SRCDIR}/release MK_AUTO_OBJ=no -V BRANCH
396 .if !defined(SRCRELDATE)
397 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
398 ${SRCDIR}/sys/sys/param.h
401 .if !defined(VERSION)
402 VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
406 .if !defined(PKG_VERSION)
407 .if ${_BRANCH:MSTABLE*} || ${_BRANCH:MCURRENT*} || ${_BRANCH:MALPHA*}
408 TIMENOW= %Y%m%d%H%M%S
409 EXTRA_REVISION= .s${TIMENOW:gmtime}
412 EXTRA_REVISION= _${_BRANCH:C/.*-p([0-9]+$)/\1/}
414 PKG_VERSION= ${_REVISION}${EXTRA_REVISION}
417 KNOWN_ARCHES?= aarch64/arm64 \
441 .if ${TARGET} == ${TARGET_ARCH}
444 _t= ${TARGET_ARCH}/${TARGET}
447 .if empty(KNOWN_ARCHES:M${_t})
448 .error Unknown target ${TARGET_ARCH}:${TARGET}.
452 .if ${TARGET} == ${MACHINE}
453 TARGET_CPUTYPE?=${CPUTYPE}
458 .if !empty(TARGET_CPUTYPE)
459 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
461 _TARGET_CPUTYPE=dummy
463 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} -f /dev/null \
464 -m ${.CURDIR}/share/mk MK_AUTO_OBJ=no -V CPUTYPE
465 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
466 .error CPUTYPE global should be set with ?=.
469 BUILD_ARCH!= uname -p
470 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
471 .error To cross-build, set TARGET_ARCH.
474 WORLDTMP?= ${OBJTOP}/tmp
475 BPATH= ${CCACHE_WRAPPER_PATH_PFX}${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
476 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
477 STRICTTMPPATH= ${BPATH}:${XPATH}
478 TMPPATH= ${STRICTTMPPATH}:${PATH}
481 # Avoid running mktemp(1) unless actually needed.
482 # It may not be functional, e.g., due to new ABI
483 # when in the middle of installing over this system.
485 .if make(distributeworld) || make(installworld) || make(stageworld)
486 INSTALLTMP!= mktemp -d -u -t install
489 .if make(stagekernel) || make(distributekernel)
495 # Building a world goes through the following stages
497 # 1. legacy stage [BMAKE]
498 # This stage is responsible for creating compatibility
499 # shims that are needed by the bootstrap-tools,
500 # build-tools and cross-tools stages. These are generally
501 # APIs that tools from one of those three stages need to
502 # build that aren't present on the host.
503 # 1. bootstrap-tools stage [BMAKE]
504 # This stage is responsible for creating programs that
505 # are needed for backward compatibility reasons. They
506 # are not built as cross-tools.
507 # 2. build-tools stage [TMAKE]
508 # This stage is responsible for creating the object
509 # tree and building any tools that are needed during
510 # the build process. Some programs are listed during
511 # this phase because they build binaries to generate
512 # files needed to build these programs. This stage also
513 # builds the 'build-tools' target rather than 'all'.
514 # 3. cross-tools stage [XMAKE]
515 # This stage is responsible for creating any tools that
516 # are needed for building the system. A cross-compiler is one
517 # of them. This differs from build tools in two ways:
518 # 1. the 'all' target is built rather than 'build-tools'
519 # 2. these tools are installed into TMPPATH for stage 4.
520 # 4. world stage [WMAKE]
521 # This stage actually builds the world.
522 # 5. install stage (optional) [IMAKE]
523 # This stage installs a previously built world.
528 MINIMUM_SUPPORTED_OSREL?= 1002501
529 MINIMUM_SUPPORTED_REL?= 10.3
531 # Common environment for world related stages
533 MACHINE_ARCH=${TARGET_ARCH} \
535 CPUTYPE=${TARGET_CPUTYPE}
536 .if ${MK_META_MODE} != "no"
537 # Don't rebuild build-tools targets during normal build.
538 CROSSENV+= BUILD_TOOLS_META=.NOMETA
540 .if defined(TARGET_CFLAGS)
541 CROSSENV+= ${TARGET_CFLAGS}
544 # bootstrap-tools stage
545 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
546 TOOLS_PREFIX=${WORLDTMP} \
547 PATH=${BPATH}:${PATH} \
548 WORLDTMP=${WORLDTMP} \
549 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
550 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
552 OBJTOP='${WORLDTMP}/obj-tools' \
553 OBJROOT='$${OBJTOP}/' \
555 BOOTSTRAPPING=${OSRELDATE} \
556 BWPHASE=${.TARGET:C,^_,,} \
558 MK_HTML=no NO_LINT=yes MK_MAN=no \
559 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
560 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
561 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
562 MK_LLDB=no MK_TESTS=no \
563 MK_LLD=${MK_LLD_BOOTSTRAP} \
567 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
572 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
573 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
575 BOOTSTRAPPING=${OSRELDATE} \
576 BWPHASE=${.TARGET:C,^_,,} \
579 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
580 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
581 MK_LLDB=no MK_TESTS=no
584 # TOOLS_PREFIX set in BMAKE
586 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
587 MK_GDB=no MK_LLD_IS_LD=${MK_LLD_BOOTSTRAP} MK_TESTS=no
590 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
591 PATH=${BPATH}:${PATH} \
593 KTMAKE= TOOLS_PREFIX=${WORLDTMP} \
594 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
596 OBJTOP='${WORLDTMP}/obj-kernel-tools' \
597 OBJROOT='$${OBJTOP}/' \
599 BOOTSTRAPPING=${OSRELDATE} \
601 MK_HTML=no -DNO_LINT MK_MAN=no \
602 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
603 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
606 WMAKEENV= ${CROSSENV} \
607 INSTALL="sh ${.CURDIR}/tools/install.sh" \
612 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
614 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
617 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
618 CPP="${XCPP} ${XCFLAGS}" \
619 AS="${XAS}" AR="${XAR}" LD="${XLD}" LLVM_LINK="${XLLVM_LINK}" \
620 NM=${XNM} OBJCOPY="${XOBJCOPY}" \
621 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
624 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
625 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
626 # directory, but the compiler will look in the right place for its
627 # tools so we don't need to tell it where to look.
628 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
632 # The internal bootstrap compiler has a default sysroot set by TOOLS_PREFIX
633 # and target set by TARGET/TARGET_ARCH. However, there are several needs to
634 # always pass an explicit --sysroot and -target.
635 # - External compiler needs sysroot and target flags.
636 # - External ld needs sysroot.
637 # - To be clear about the use of a sysroot when using the internal compiler.
638 # - Easier debugging.
639 # - Allowing WITH_SYSTEM_COMPILER+WITH_META_MODE to work together due to
640 # the flip-flopping build command when sometimes using external and
641 # sometimes using internal.
642 # - Allow using lld which has no support for default paths.
643 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
644 BFLAGS+= -B${WORLDTMP}/usr/bin
646 .if ${TARGET} == "arm"
647 .if ${TARGET_ARCH:Marmv[67]*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
648 TARGET_ABI= gnueabihf
653 .if ${WANT_COMPILER_TYPE} == gcc || \
654 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
655 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
656 # won't set header path and -L is used to ensure the base library path
657 # is added before the port PREFIX library path.
658 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
659 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
660 # combined with --sysroot.
661 XCFLAGS+= -B${WORLDTMP}/usr/lib
662 # Force using libc++ for external GCC.
663 .if defined(X_COMPILER_TYPE) && \
664 ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
665 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
668 .elif ${WANT_COMPILER_TYPE} == clang || \
669 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang)
670 MACHINE_ABI?= unknown
671 MACHINE_TRIPLE?=${MACHINE_ARCH:S/amd64/x86_64/:C/hf$//:S/mipsn32/mips64/}-${MACHINE_ABI}-freebsd12.0
673 TARGET_TRIPLE?= ${TARGET_ARCH:S/amd64/x86_64/:C/hf$//:S/mipsn32/mips64/}-${TARGET_ABI}-freebsd12.0
674 XCFLAGS+= -target ${TARGET_TRIPLE}
676 XCFLAGS+= --sysroot=${WORLDTMP}
682 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
683 ${TARGET_ARCH} == "powerpc64" || ${TARGET_ARCH:Mmips64*} != "")
685 .include "Makefile.libcompat"
686 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH:Marmv[67]*} != ""
688 .include "Makefile.libcompat"
691 # META_MODE normally ignores host file changes since every build updates
692 # timestamps (see NO_META_IGNORE_HOST in sys.mk). There are known times
693 # when the ABI breaks though that we want to force rebuilding WORLDTMP
694 # to get updated host tools.
695 .if ${MK_META_MODE} == "yes" && defined(NO_CLEAN) && \
696 !defined(NO_META_IGNORE_HOST) && !defined(NO_META_IGNORE_HOST_HEADERS) && \
698 # r318736 - ino64 major ABI breakage
699 META_MODE_BAD_ABI_VERS+= 1200031
701 .if !defined(OBJDIR_HOST_OSRELDATE)
702 .if exists(${OBJTOP}/host-osreldate.h)
703 OBJDIR_HOST_OSRELDATE!= \
704 awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
705 ${OBJTOP}/host-osreldate.h
706 .elif exists(${WORLDTMP}/usr/include/osreldate.h)
707 OBJDIR_HOST_OSRELDATE= 0
709 .export OBJDIR_HOST_OSRELDATE
712 # Note that this logic is the opposite of normal BOOTSTRAP handling. We want
713 # to compare the WORLDTMP's OSRELDATE to the host's OSRELDATE. If the WORLDTMP
714 # is older than the ABI-breakage OSRELDATE of the HOST then we rebuild.
715 .if defined(OBJDIR_HOST_OSRELDATE)
716 .for _ver in ${META_MODE_BAD_ABI_VERS}
717 .if ${OSRELDATE} >= ${_ver} && ${OBJDIR_HOST_OSRELDATE} < ${_ver}
718 _meta_mode_need_rebuild= ${_ver}
721 .if defined(_meta_mode_need_rebuild)
722 .info META_MODE: Rebuilding host tools due to ABI breakage in __FreeBSD_version ${_meta_mode_need_rebuild}.
723 NO_META_IGNORE_HOST_HEADERS= 1
724 .export NO_META_IGNORE_HOST_HEADERS
725 .endif # defined(_meta_mode_need_rebuild)
726 .endif # defined(OBJDIR_HOST_OSRELDATE)
727 .endif # ${MK_META_MODE} == "yes" && defined(NO_CLEAN) ...
728 # This is only used for META_MODE+filemon to track what the oldest
729 # __FreeBSD_version is in WORLDTMP. This purposely does NOT have
730 # a make dependency on /usr/include/osreldate.h as the file should
731 # only be copied when it is missing or meta mode determines it has changed.
732 # Since host files are normally ignored without NO_META_IGNORE_HOST
733 # the file will never be updated unless that flag is specified. This
734 # allows tracking the oldest osreldate to force rebuilds via
735 # META_MODE_BADABI_REVS above.
736 host-osreldate.h: # DO NOT ADD /usr/include/osreldate.h here
737 @cp -f /usr/include/osreldate.h ${.TARGET}
739 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
740 BWPHASE=${.TARGET:C,^_,,} \
743 IMAKEENV= ${CROSSENV}
744 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
745 ${IMAKE_INSTALL} ${IMAKE_MTREE}
746 .if empty(.MAKEFLAGS:M-n)
747 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
748 LD_LIBRARY_PATH=${INSTALLTMP} \
749 PATH_LOCALE=${INSTALLTMP}/locale
750 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
752 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
754 .if defined(DB_FROM_SRC)
755 INSTALLFLAGS+= -N ${.CURDIR}/etc
756 MTREEFLAGS+= -N ${.CURDIR}/etc
758 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
759 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
761 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
762 METALOG:= ${METALOG:C,//+,/,g}
763 IMAKE+= -DNO_ROOT METALOG=${METALOG}
764 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
767 .if defined(BUILD_PKGS)
768 INSTALLFLAGS+= -h sha256
770 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
771 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
772 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
776 KMAKEENV= ${WMAKEENV:NSYSROOT=*}
777 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
782 # Attempt to rebuild the entire system, with reasonable chance of
783 # success, regardless of how old your existing system is.
785 _sanity_check: .PHONY .MAKE
786 .if ${.CURDIR:C/[^,]//g} != ""
787 # The m4 build of sendmail files doesn't like it if ',' is used
788 # anywhere in the path of it's files.
790 @echo "*** Error: path to source tree contains a comma ','"
793 .elif ${.CURDIR:M*\:*} != ""
794 # Using ':' leaks into PATH and breaks finding cross-tools.
796 @echo "*** Error: path to source tree contains a colon ':'"
801 # Our current approach to dependency tracking cannot cope with certain source
802 # tree changes, particularly with respect to removing source files and
803 # replacing generated files. Handle these cases here in an ad-hoc fashion.
804 _cleanobj_fast_depend_hack: .PHONY
805 # Syscall stubs rewritten in C and obsolete MD assembly implementations
806 # Date SVN Rev Syscalls
807 # 20170624 r320278 fstat fstatat fstatfs getdirentries getfsstat statfs
808 # 20180404 r332048 sigreturn
809 # 20180405 r332080 shmat
810 # 20180406 r332119 setlogin
811 # 20180411 r332443 exect
812 # 20180525 r334224 vadvise
813 .for f in exect fstat fstatat fstatfs getdirentries getfsstat setlogin shmat sigreturn statfs vadvise
814 .if exists(${OBJTOP}/lib/libc/.depend.${f}.o)
815 @if egrep -qw '${f}\.[sS]' \
816 ${OBJTOP}/lib/libc/.depend.${f}.o; then \
817 echo Removing stale dependencies for ${f} syscall wrappers; \
818 rm -f ${OBJTOP}/lib/libc/.depend.${f}.* \
819 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \
823 # 20170607 remove stale dependencies for utimens* wrappers removed in r319663
824 .for f in futimens utimensat
825 .if exists(${OBJTOP}/lib/libc/.depend.${f}.o)
826 @if egrep -q '/${f}.c' \
827 ${OBJTOP}/lib/libc/.depend.${f}.o; then \
828 echo Removing stale dependencies for ${f} syscall wrappers; \
829 rm -f ${OBJTOP}/lib/libc/.depend.${f}.* \
830 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \
834 # 20170523 remove stale generated asm files for functions which are no longer
835 # syscalls after r302092 (pipe) and r318736 (others)
836 .for f in getdents lstat mknod pipe stat
837 .if exists(${OBJTOP}/lib/libc/${f}.s) || \
838 exists(${OBJTOP}/lib/libc/${f}.S)
839 @echo Removing stale generated ${f} syscall files
840 @rm -f ${OBJTOP}/lib/libc/${f}.* \
841 ${OBJTOP}/lib/libc/.depend.${f}.* \
842 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/${f}.*} \
843 ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}
849 @echo "--------------------------------------------------------------"
850 @echo ">>> Rebuilding the temporary build tree"
851 @echo "--------------------------------------------------------------"
852 .if !defined(NO_CLEAN)
855 .if exists(${WORLDTMP})
856 @echo ">>> Deleting stale files in build tree..."
857 ${_+_}cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \
858 delete-old delete-old-libs >/dev/null
860 rm -rf ${WORLDTMP}/legacy/usr/include
861 .if ${USING_SYSTEM_COMPILER} == "yes"
863 if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \
864 inum=$$(stat -f %i ${WORLDTMP}/usr/bin/${cc}); \
865 find ${WORLDTMP}/usr/bin -inum $${inum} -delete; \
868 .endif # ${USING_SYSTEM_COMPILER} == "yes"
869 .endif # !defined(NO_CLEAN)
870 @mkdir -p ${WORLDTMP}
871 @touch ${WORLDTMP}/${.TARGET}
874 lib lib/casper usr legacy/bin legacy/usr
875 mkdir -p ${WORLDTMP}/${_dir}
877 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
878 -p ${WORLDTMP}/legacy/usr >/dev/null
879 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
880 -p ${WORLDTMP}/legacy/usr/include >/dev/null
881 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
882 -p ${WORLDTMP}/usr >/dev/null
883 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
884 -p ${WORLDTMP}/usr/include >/dev/null
885 ln -sf ${.CURDIR}/sys ${WORLDTMP}
886 .if ${MK_DEBUG_FILES} != "no"
887 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
888 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
889 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
890 -p ${WORLDTMP}/usr/lib >/dev/null
892 .for _mtree in ${LOCAL_MTREE}
893 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
897 @echo "--------------------------------------------------------------"
898 @echo ">>> stage 1.1: legacy release compatibility shims"
899 @echo "--------------------------------------------------------------"
900 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
903 @echo "--------------------------------------------------------------"
904 @echo ">>> stage 1.2: bootstrap tools"
905 @echo "--------------------------------------------------------------"
906 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
908 .if !defined(NO_CLEAN)
910 @echo "--------------------------------------------------------------"
911 @echo ">>> stage 2.1: cleaning up the object tree"
912 @echo "--------------------------------------------------------------"
913 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
914 .if defined(LIBCOMPAT)
915 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
918 ${_+_}cd ${.CURDIR}; ${WMAKE} _cleanobj_fast_depend_hack
919 .endif # !defined(NO_CLEAN)
922 @echo "--------------------------------------------------------------"
923 @echo ">>> stage 2.2: rebuilding the object tree"
924 @echo "--------------------------------------------------------------"
925 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
928 @echo "--------------------------------------------------------------"
929 @echo ">>> stage 2.3: build tools"
930 @echo "--------------------------------------------------------------"
931 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
934 @echo "--------------------------------------------------------------"
935 @echo ">>> stage 3: cross tools"
936 @echo "--------------------------------------------------------------"
937 @rm -f ${OBJTOP}/compiler-metadata.mk
938 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
939 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
942 @echo "--------------------------------------------------------------"
943 @echo ">>> stage 3.1: recording build metadata"
944 @echo "--------------------------------------------------------------"
945 ${_+_}cd ${.CURDIR}; ${WMAKE} compiler-metadata.mk
946 ${_+_}cd ${.CURDIR}; ${WMAKE} host-osreldate.h
949 @echo "--------------------------------------------------------------"
950 @echo ">>> stage 4.1: building includes"
951 @echo "--------------------------------------------------------------"
952 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
953 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
954 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
955 MK_INCLUDES=yes includes
956 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
957 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
961 @echo "--------------------------------------------------------------"
962 @echo ">>> stage 4.2: building libraries"
963 @echo "--------------------------------------------------------------"
964 ${_+_}cd ${.CURDIR}; \
965 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
966 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
969 @echo "--------------------------------------------------------------"
970 @echo ">>> stage 4.3: building everything"
971 @echo "--------------------------------------------------------------"
972 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
975 .if !defined(WORLDFAST)
976 WMAKE_TGTS+= _sanity_check _worldtmp _legacy
977 .if empty(SUBDIR_OVERRIDE)
978 WMAKE_TGTS+= _bootstrap-tools
980 WMAKE_TGTS+= _cleanobj
981 .if !defined(NO_OBJWALK)
984 WMAKE_TGTS+= _build-tools _cross-tools
985 WMAKE_TGTS+= _build-metadata
986 WMAKE_TGTS+= _includes
988 .if !defined(NO_LIBS)
989 WMAKE_TGTS+= _libraries
991 WMAKE_TGTS+= everything
992 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
993 WMAKE_TGTS+= build${libcompat}
996 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
997 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
999 buildworld_prologue: .PHONY
1000 @echo "--------------------------------------------------------------"
1001 @echo ">>> World build started on `LC_ALL=C date`"
1002 @echo "--------------------------------------------------------------"
1004 buildworld_epilogue: .PHONY
1006 @echo "--------------------------------------------------------------"
1007 @echo ">>> World build completed on `LC_ALL=C date`"
1008 @echo "--------------------------------------------------------------"
1011 # We need to have this as a target because the indirection between Makefile
1012 # and Makefile.inc1 causes the correct PATH to be used, rather than a
1013 # modification of the current environment's PATH. In addition, we need
1014 # to quote multiword values.
1016 buildenvvars: .PHONY
1017 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
1019 .if ${.TARGETS:Mbuildenv}
1020 .if ${.MAKEFLAGS:M-j}
1021 .error The buildenv target is incompatible with -j
1024 BUILDENV_DIR?= ${.CURDIR}
1026 # Note: make will report any errors the shell reports. This can
1027 # be odd if the last command in an interactive shell generates an
1028 # error or is terminated by SIGINT. These reported errors look bad,
1029 # but are harmless. Allowing them also allows BUIDLENV_SHELL to
1030 # be a complex command whose status will be returned to the caller.
1031 # Some scripts in tools rely on this behavior to report build errors.
1034 @echo Entering world for ${TARGET_ARCH}:${TARGET}
1035 .if ${BUILDENV_SHELL:M*zsh*}
1036 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
1038 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL}
1040 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
1041 toolchain: ${TOOLCHAIN_TGTS} .PHONY
1042 KERNEL_TOOLCHAIN_TGTS= ${TOOLCHAIN_TGTS:N_obj:N_cleanobj:N_includes:N_libraries}
1043 .if make(kernel-toolchain)
1044 .ORDER: ${KERNEL_TOOLCHAIN_TGTS}
1046 kernel-toolchain: ${KERNEL_TOOLCHAIN_TGTS} .PHONY
1051 # Checks to be sure system is ready for installworld/installkernel.
1053 installcheck: _installcheck_world _installcheck_kernel .PHONY
1054 _installcheck_world: .PHONY
1055 _installcheck_kernel: .PHONY
1058 # Require DESTDIR to be set if installing for a different architecture or
1059 # using the user/group database in the source tree.
1061 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
1062 defined(DB_FROM_SRC)
1063 .if !make(distributeworld)
1064 _installcheck_world: __installcheck_DESTDIR
1065 _installcheck_kernel: __installcheck_DESTDIR
1066 __installcheck_DESTDIR: .PHONY
1067 .if !defined(DESTDIR) || empty(DESTDIR)
1068 @echo "ERROR: Please set DESTDIR!"; \
1074 .if !defined(DB_FROM_SRC)
1076 # Check for missing UIDs/GIDs.
1078 CHECK_UIDS= auditdistd
1080 .if ${MK_SENDMAIL} != "no"
1084 .if ${MK_PF} != "no"
1086 CHECK_GIDS+= proxy authpf
1088 .if ${MK_UNBOUND} != "no"
1089 CHECK_UIDS+= unbound
1090 CHECK_GIDS+= unbound
1092 _installcheck_world: __installcheck_UGID
1093 __installcheck_UGID: .PHONY
1094 .for uid in ${CHECK_UIDS}
1095 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
1096 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
1100 .for gid in ${CHECK_GIDS}
1101 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
1102 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
1108 # If installing over the running system (DESTDIR is / or unset) and the install
1109 # includes rescue, try running rescue from the objdir as a sanity check. If
1110 # rescue is not functional (e.g., because it depends on a system call not
1111 # supported by the currently running kernel), abort the installation.
1113 .if !make(distributeworld) && ${MK_RESCUE} != "no" && \
1114 (empty(DESTDIR) || ${DESTDIR} == "/") && empty(BYPASS_INSTALLCHECK_SH)
1115 _installcheck_world: __installcheck_sh_check
1116 __installcheck_sh_check: .PHONY
1117 @if [ "`${OBJTOP}/rescue/rescue/rescue sh -c 'echo OK'`" != \
1119 echo "rescue/sh check failed, installation aborted" >&2; \
1125 # Required install tools to be saved in a scratch dir for safety.
1127 .if ${MK_ZONEINFO} != "no"
1128 _zoneinfo= zic tzsetup
1131 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
1132 date echo egrep find grep id install ${_install-info} \
1133 ln make mkdir mtree mv pwd_mkdb \
1134 rm sed services_mkdb sh sort strip sysctl test true uname wc ${_zoneinfo} \
1137 # Needed for share/man
1138 .if ${MK_MAN_UTILS} != "no"
1145 # Distributes everything compiled by a `buildworld'.
1149 # Installs everything compiled by a 'buildworld'.
1152 # Non-base distributions produced by the base system
1153 EXTRA_DISTRIBUTIONS= doc
1154 .if defined(LIBCOMPAT)
1155 EXTRA_DISTRIBUTIONS+= lib${libcompat}
1157 .if ${MK_TESTS} != "no"
1158 EXTRA_DISTRIBUTIONS+= tests
1161 DEBUG_DISTRIBUTIONS=
1162 .if ${MK_DEBUG_FILES} != "no"
1163 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
1166 MTREE_MAGIC?= mtree 2.0
1168 distributeworld installworld stageworld: _installcheck_world .PHONY
1169 mkdir -p ${INSTALLTMP}
1170 progs=$$(for prog in ${ITOOLS}; do \
1171 if progpath=`which $$prog`; then \
1174 echo "Required tool $$prog not found in PATH." >&2; \
1178 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
1179 while read line; do \
1181 if [ "$$2 $$3" != "not found" ]; then \
1184 echo "Required library $$1 not found." >&2; \
1188 cp $$libs $$progs ${INSTALLTMP}
1189 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
1190 .if defined(NO_ROOT)
1191 -mkdir -p ${METALOG:H}
1192 echo "#${MTREE_MAGIC}" > ${METALOG}
1194 .if make(distributeworld)
1195 .for dist in ${EXTRA_DISTRIBUTIONS}
1196 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
1197 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1198 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
1199 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1200 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1201 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1202 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
1203 .if ${MK_DEBUG_FILES} != "no"
1204 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1205 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
1207 .if defined(LIBCOMPAT)
1208 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1209 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1210 .if ${MK_DEBUG_FILES} != "no"
1211 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1212 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
1215 .if ${MK_TESTS} != "no" && ${dist} == "tests"
1216 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
1217 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1218 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
1219 .if ${MK_DEBUG_FILES} != "no"
1220 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1221 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
1224 .if defined(NO_ROOT)
1225 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1226 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1227 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1228 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1229 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1230 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1231 .if defined(LIBCOMPAT)
1232 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
1233 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1237 -mkdir ${DESTDIR}/${DISTDIR}/base
1238 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1239 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1240 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1241 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1243 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1244 ${IMAKEENV} rm -rf ${INSTALLTMP}
1245 .if make(distributeworld)
1246 .for dist in ${EXTRA_DISTRIBUTIONS}
1247 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete
1249 .if defined(NO_ROOT)
1250 .for dist in base ${EXTRA_DISTRIBUTIONS}
1251 @# For each file that exists in this dist, print the corresponding
1252 @# line from the METALOG. This relies on the fact that
1253 @# a line containing only the filename will sort immediately before
1254 @# the relevant mtree line.
1255 cd ${DESTDIR}/${DISTDIR}; \
1256 find ./${dist} | sort -u ${METALOG} - | \
1257 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1258 ${DESTDIR}/${DISTDIR}/${dist}.meta
1260 .for dist in ${DEBUG_DISTRIBUTIONS}
1261 @# For each file that exists in this dist, print the corresponding
1262 @# line from the METALOG. This relies on the fact that
1263 @# a line containing only the filename will sort immediately before
1264 @# the relevant mtree line.
1265 cd ${DESTDIR}/${DISTDIR}; \
1266 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1267 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1268 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1273 packageworld: .PHONY
1274 .for dist in base ${EXTRA_DISTRIBUTIONS}
1275 .if defined(NO_ROOT)
1276 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1277 tar cvf - --exclude usr/lib/debug \
1278 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1279 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1281 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1282 tar cvf - --exclude usr/lib/debug . | \
1283 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1287 .for dist in ${DEBUG_DISTRIBUTIONS}
1288 . if defined(NO_ROOT)
1289 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1290 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1291 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1293 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1294 tar cvLf - usr/lib/debug | \
1295 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1302 # If you have a build server, you can NFS mount the source and obj directories
1303 # and do a 'make reinstall' on the *client* to install new binaries from the
1304 # most recent server build.
1306 restage reinstall: .MAKE .PHONY
1307 @echo "--------------------------------------------------------------"
1308 @echo ">>> Making hierarchy"
1309 @echo "--------------------------------------------------------------"
1310 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1311 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1313 @echo "--------------------------------------------------------------"
1314 @echo ">>> Making distribution"
1315 @echo "--------------------------------------------------------------"
1316 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1317 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
1320 @echo "--------------------------------------------------------------"
1321 @echo ">>> Installing everything"
1322 @echo "--------------------------------------------------------------"
1323 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1324 .if defined(LIBCOMPAT)
1325 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1328 redistribute: .MAKE .PHONY
1329 @echo "--------------------------------------------------------------"
1330 @echo ">>> Distributing everything"
1331 @echo "--------------------------------------------------------------"
1332 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1333 .if defined(LIBCOMPAT)
1334 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1335 DISTRIBUTION=lib${libcompat}
1338 distrib-dirs distribution: .MAKE .PHONY
1339 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1340 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1341 .if make(distribution)
1342 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1343 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1344 METALOG=${METALOG} MK_TESTS=no installconfig
1348 # buildkernel and installkernel
1350 # Which kernels to build and/or install is specified by setting
1351 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1352 # Only the existing (depending TARGET) config files are used
1353 # for building kernels and only the first of these is designated
1354 # as the one being installed.
1356 # Note that we have to use TARGET instead of TARGET_ARCH when
1357 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1358 # be set to cross-build, we have to make sure TARGET is set
1361 .if defined(KERNFAST)
1365 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1366 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1367 KERNCONF=${KERNFAST}
1370 .if ${TARGET_ARCH} == "powerpc64"
1371 KERNCONF?= GENERIC64
1375 INSTKERNNAME?= kernel
1377 KERNSRCDIR?= ${.CURDIR}/sys
1378 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1379 KRNLOBJDIR= ${OBJTOP}${KERNSRCDIR:C,^${.CURDIR},,}
1380 KERNCONFDIR?= ${KRNLCONFDIR}
1384 .if defined(NO_INSTALLKERNEL)
1385 # All of the BUILDKERNELS loops start at index 1.
1386 BUILDKERNELS+= dummy
1388 .for _kernel in ${KERNCONF}
1389 .if exists(${KERNCONFDIR}/${_kernel})
1390 BUILDKERNELS+= ${_kernel}
1391 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1392 INSTALLKERNEL= ${_kernel}
1395 .if make(buildkernel)
1396 .error Missing KERNCONF ${KERNCONFDIR}/${_kernel}
1401 _cleankernobj_fast_depend_hack: .PHONY
1402 # 20180320 remove stale generated assym.s after renaming to .inc in r331254
1403 .if exists(${OBJTOP}/sys/${KERNCONF}/assym.s)
1404 @echo Removing stale generated assym files
1405 @rm -f ${OBJTOP}/sys/${KERNCONF}/assym.* \
1406 ${OBJTOP}/sys/${KERNCONF}/.depend.assym.*
1409 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1414 # Builds all kernels defined by BUILDKERNELS.
1416 buildkernel: .MAKE .PHONY
1417 .if empty(BUILDKERNELS:Ndummy)
1418 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1422 .for _kernel in ${BUILDKERNELS:Ndummy}
1423 @echo "--------------------------------------------------------------"
1424 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1425 @echo "--------------------------------------------------------------"
1426 @echo "===> ${_kernel}"
1427 mkdir -p ${KRNLOBJDIR}
1428 .if !defined(NO_KERNELCONFIG)
1430 @echo "--------------------------------------------------------------"
1431 @echo ">>> stage 1: configuring the kernel"
1432 @echo "--------------------------------------------------------------"
1433 cd ${KRNLCONFDIR}; \
1435 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1436 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1438 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1440 @echo "--------------------------------------------------------------"
1441 @echo ">>> stage 2.1: cleaning up the object tree"
1442 @echo "--------------------------------------------------------------"
1443 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1445 ${_+_}cd ${.CURDIR}; ${WMAKE} _cleankernobj_fast_depend_hack
1447 .if !defined(NO_KERNELOBJ)
1449 @echo "--------------------------------------------------------------"
1450 @echo ">>> stage 2.2: rebuilding the object tree"
1451 @echo "--------------------------------------------------------------"
1452 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1455 @echo "--------------------------------------------------------------"
1456 @echo ">>> stage 2.3: build tools"
1457 @echo "--------------------------------------------------------------"
1458 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1460 @echo "--------------------------------------------------------------"
1461 @echo ">>> stage 3.1: building everything"
1462 @echo "--------------------------------------------------------------"
1463 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1464 @echo "--------------------------------------------------------------"
1465 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1466 @echo "--------------------------------------------------------------"
1469 NO_INSTALLEXTRAKERNELS?= yes
1472 # installkernel, etc.
1474 # Install the kernel defined by INSTALLKERNEL
1476 installkernel installkernel.debug \
1477 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1478 .if !defined(NO_INSTALLKERNEL)
1479 .if empty(INSTALLKERNEL)
1480 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1483 @echo "--------------------------------------------------------------"
1484 @echo ">>> Installing kernel ${INSTALLKERNEL} on $$(LC_ALL=C date)"
1485 @echo "--------------------------------------------------------------"
1486 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1487 ${CROSSENV} PATH=${TMPPATH} \
1488 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1489 @echo "--------------------------------------------------------------"
1490 @echo ">>> Installing kernel ${INSTALLKERNEL} completed on $$(LC_ALL=C date)"
1491 @echo "--------------------------------------------------------------"
1493 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1494 .for _kernel in ${BUILDKERNELS:[2..-1]}
1495 @echo "--------------------------------------------------------------"
1496 @echo ">>> Installing kernel ${_kernel} $$(LC_ALL=C date)"
1497 @echo "--------------------------------------------------------------"
1498 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
1499 ${CROSSENV} PATH=${TMPPATH} \
1500 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1501 @echo "--------------------------------------------------------------"
1502 @echo ">>> Installing kernel ${_kernel} completed on $$(LC_ALL=C date)"
1503 @echo "--------------------------------------------------------------"
1507 distributekernel distributekernel.debug: .PHONY
1508 .if !defined(NO_INSTALLKERNEL)
1509 .if empty(INSTALLKERNEL)
1510 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1513 mkdir -p ${DESTDIR}/${DISTDIR}
1514 .if defined(NO_ROOT)
1515 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1517 ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1518 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1519 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1520 DESTDIR=${INSTALL_DDIR}/kernel \
1521 ${.TARGET:S/distributekernel/install/}
1522 .if defined(NO_ROOT)
1523 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1524 ${DESTDIR}/${DISTDIR}/kernel.meta
1527 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1528 .for _kernel in ${BUILDKERNELS:[2..-1]}
1529 .if defined(NO_ROOT)
1530 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1532 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
1533 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1534 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1535 KERNEL=${INSTKERNNAME}.${_kernel} \
1536 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1537 ${.TARGET:S/distributekernel/install/}
1538 .if defined(NO_ROOT)
1539 @sed -e "s|^./kernel.${_kernel}|.|" \
1540 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1541 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1546 packagekernel: .PHONY
1547 .if defined(NO_ROOT)
1548 .if !defined(NO_INSTALLKERNEL)
1549 cd ${DESTDIR}/${DISTDIR}/kernel; \
1550 tar cvf - --exclude '*.debug' \
1551 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1552 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1554 .if ${MK_DEBUG_FILES} != "no"
1555 cd ${DESTDIR}/${DISTDIR}/kernel; \
1556 tar cvf - --include '*/*/*.debug' \
1557 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1558 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1560 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1561 .for _kernel in ${BUILDKERNELS:[2..-1]}
1562 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1563 tar cvf - --exclude '*.debug' \
1564 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1565 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1566 .if ${MK_DEBUG_FILES} != "no"
1567 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1568 tar cvf - --include '*/*/*.debug' \
1569 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1570 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1575 .if !defined(NO_INSTALLKERNEL)
1576 cd ${DESTDIR}/${DISTDIR}/kernel; \
1577 tar cvf - --exclude '*.debug' . | \
1578 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1580 .if ${MK_DEBUG_FILES} != "no"
1581 cd ${DESTDIR}/${DISTDIR}/kernel; \
1582 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1583 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1585 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1586 .for _kernel in ${BUILDKERNELS:[2..-1]}
1587 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1588 tar cvf - --exclude '*.debug' . | \
1589 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1590 .if ${MK_DEBUG_FILES} != "no"
1591 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1592 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1593 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1600 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1602 PORTSDIR?= /usr/ports
1603 WSTAGEDIR?= ${OBJTOP}/worldstage
1604 KSTAGEDIR?= ${OBJTOP}/kernelstage
1605 REPODIR?= ${OBJROOT}repo
1606 PKGSIGNKEY?= # empty
1608 .ORDER: stage-packages create-packages
1609 .ORDER: create-packages create-world-packages
1610 .ORDER: create-packages create-kernel-packages
1611 .ORDER: create-packages sign-packages
1613 _pkgbootstrap: .PHONY
1614 .if !exists(${LOCALBASE}/sbin/pkg)
1615 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1619 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1622 rm -rf /tmp/ports.${TARGET} || :
1623 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
1624 PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \
1625 WSTAGEDIR=${WSTAGEDIR} \
1626 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1628 real-packages: stage-packages create-packages sign-packages .PHONY
1630 stage-packages-world: .PHONY
1631 @mkdir -p ${WSTAGEDIR}
1632 ${_+_}@cd ${.CURDIR}; \
1633 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT stageworld
1635 stage-packages-kernel: .PHONY
1636 @mkdir -p ${KSTAGEDIR}
1637 ${_+_}@cd ${.CURDIR}; \
1638 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT stagekernel
1640 stage-packages: .PHONY stage-packages-world stage-packages-kernel
1643 @mkdir -p ${REPODIR}
1645 create-packages-world: _pkgbootstrap _repodir .PHONY
1646 ${_+_}@cd ${.CURDIR}; \
1647 ${MAKE} -f Makefile.inc1 \
1648 DESTDIR=${WSTAGEDIR} \
1649 PKG_VERSION=${PKG_VERSION} create-world-packages
1651 create-packages-kernel: _pkgbootstrap _repodir .PHONY
1652 ${_+_}@cd ${.CURDIR}; \
1653 ${MAKE} -f Makefile.inc1 \
1654 DESTDIR=${KSTAGEDIR} \
1655 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1656 create-kernel-packages
1658 create-packages: .PHONY create-packages-world create-packages-kernel
1660 create-world-packages: _pkgbootstrap .PHONY
1661 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1662 @cd ${WSTAGEDIR} ; \
1663 env -i LC_COLLATE=C sort ${WSTAGEDIR}/METALOG | \
1664 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk
1665 @for plist in ${WSTAGEDIR}/*.plist; do \
1666 plist=$${plist##*/} ; \
1667 pkgname=$${plist%.plist} ; \
1668 echo "_PKGS+= $${pkgname}" ; \
1669 done > ${WSTAGEDIR}/packages.mk
1670 ${_+_}@cd ${.CURDIR}; \
1671 ${MAKE} -f Makefile.inc1 create-world-packages-jobs \
1674 .if make(create-world-packages-jobs)
1675 .include "${WSTAGEDIR}/packages.mk"
1678 create-world-packages-jobs: .PHONY
1679 .for pkgname in ${_PKGS}
1680 create-world-packages-jobs: create-world-package-${pkgname}
1681 create-world-package-${pkgname}: .PHONY
1682 @sh ${SRCDIR}/release/packages/generate-ucl.sh -o ${pkgname} \
1683 -s ${SRCDIR} -u ${WSTAGEDIR}/${pkgname}.ucl
1685 /^name/ { printf("===> Creating %s-", $$2); next } \
1686 /^version/ { print $$2; next } \
1687 ' ${WSTAGEDIR}/${pkgname}.ucl
1688 @if [ "${pkgname}" == "runtime" ]; then \
1689 sed -i '' -e "s/%VCS_REVISION%/${VCS_REVISION}/" ${WSTAGEDIR}/${pkgname}.ucl ; \
1691 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1692 create -M ${WSTAGEDIR}/${pkgname}.ucl \
1693 -p ${WSTAGEDIR}/${pkgname}.plist \
1695 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1698 create-kernel-packages: .PHONY
1699 _default_flavor= -default
1700 .if exists(${KSTAGEDIR}/kernel.meta)
1701 . if ${MK_DEBUG_FILES} != "no"
1704 . for flavor in "" ${_debug}
1705 create-kernel-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}
1706 create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY
1707 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1708 env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.meta | \
1709 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1710 -v kernel=yes -v _kernconf=${INSTALLKERNEL} ; \
1711 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1712 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1713 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1714 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1715 -e "s/%KERNELDIR%/kernel/" \
1716 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1717 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1718 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1719 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1720 -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \
1721 ${SRCDIR}/release/packages/kernel.ucl \
1722 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1724 /name/ { printf("===> Creating %s-", $$2); next } \
1725 /version/ {print $$2; next } ' \
1726 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1727 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1728 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1729 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1730 -r ${KSTAGEDIR}/${DISTDIR} \
1731 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1734 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1735 . for _kernel in ${BUILDKERNELS:[2..-1]}
1736 . if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1737 . if ${MK_DEBUG_FILES} != "no"
1740 . for flavor in "" ${_debug}
1741 create-kernel-packages: create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}
1742 create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}: _pkgbootstrap .PHONY
1743 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1744 env -i LC_COLLATE=C sort ${KSTAGEDIR}/kernel.${_kernel}.meta | \
1745 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1746 -v kernel=yes -v _kernconf=${_kernel} ; \
1747 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1748 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1749 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1750 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1751 -e "s/%KERNELDIR%/kernel.${_kernel}/" \
1752 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1753 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1754 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1755 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1756 -e "s/ %VCS_REVISION%/${VCS_REVISION}/" \
1757 ${SRCDIR}/release/packages/kernel.ucl \
1758 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1760 /name/ { printf("===> Creating %s-", $$2); next } \
1761 /version/ {print $$2; next } ' \
1762 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1763 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1764 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1765 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1766 -r ${KSTAGEDIR}/kernel.${_kernel} \
1767 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1773 sign-packages: _pkgbootstrap .PHONY
1774 @[ -L "${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1775 unlink ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1776 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1777 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1778 ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1780 cd ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI); \
1781 ln -s ${PKG_VERSION} latest
1787 # Run test suite on installed world.
1790 @if [ ! -x "${LOCALBASE}/bin/kyua" ]; then \
1791 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1794 ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile
1800 # Build the API documentation with doxygen
1803 @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \
1804 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1807 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1812 # Update the source tree(s), by running svn/svnup to update to the
1816 .if defined(SVN_UPDATE)
1817 @echo "--------------------------------------------------------------"
1818 @echo ">>> Updating ${.CURDIR} using Subversion"
1819 @echo "--------------------------------------------------------------"
1820 @(cd ${.CURDIR}; ${SVN_CMD} update ${SVNFLAGS})
1824 # ------------------------------------------------------------------------
1826 # From here onwards are utility targets used by the 'make world' and
1827 # related targets. If your 'world' breaks, you may like to try to fix
1828 # the problem and manually run the following targets to attempt to
1829 # complete the build. Beware, this is *not* guaranteed to work, you
1830 # need to have a pretty good grip on the current state of the system
1831 # to attempt to manually finish it. If in doubt, 'make world' again.
1835 # legacy: Build compatibility shims for the next three targets. This is a
1836 # minimal set of tools and shims necessary to compensate for older systems
1837 # which don't have the APIs required by the targets built in bootstrap-tools,
1838 # build-tools or cross-tools.
1841 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1842 # r296685 fix cross-endian objcopy
1843 # r310724 fixed PR 215350, a crash in libdwarf with objects built by GCC 6.2.
1844 .if ${BOOTSTRAPPING} < 1200020
1845 _elftoolchain_libs= lib/libelf lib/libdwarf
1849 .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
1850 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
1854 .for _tool in tools/build ${_elftoolchain_libs}
1855 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1856 cd ${.CURDIR}/${_tool}; \
1857 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
1858 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy includes; \
1859 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
1860 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
1861 DESTDIR=${WORLDTMP}/legacy install
1865 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1866 # are built to build other binaries in the system. However, the focus of these
1867 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1868 # libraries, augmented by -legacy.
1870 _bt= _bootstrap-tools
1872 .if ${MK_GAMES} != "no"
1873 _strfile= usr.bin/fortune/strfile
1876 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1877 _gperf= gnu/usr.bin/gperf
1880 .if ${MK_VT} != "no"
1881 _vtfontcvt= usr.bin/vtfontcvt
1884 .if ${BOOTSTRAPPING} < 1000033
1888 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1889 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1892 # r245440 mtree -N support added
1893 # r313404 requires sha384.h for libnetbsd, added to libmd in r292782
1894 .if ${BOOTSTRAPPING} < 1100093
1895 _nmtree= lib/libmd \
1899 ${_bt}-lib/libnetbsd: ${_bt}-lib/libmd
1900 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1903 # r246097: log addition login.conf.db, passwd, pwd.db, and spwd.db with cat -l
1904 .if ${BOOTSTRAPPING} < 1000027
1908 # r277259 crunchide: Correct 64-bit section header offset
1909 # r281674 crunchide: always include both 32- and 64-bit ELF support
1910 .if ${BOOTSTRAPPING} < 1100078
1911 _crunchide= usr.sbin/crunch/crunchide
1914 # r285986 crunchen: use STRIPBIN rather than STRIP
1915 # 1100113: Support MK_AUTO_OBJ
1916 # 1200006: META_MODE fixes
1917 .if ${BOOTSTRAPPING} < 1100078 || \
1918 (${MK_AUTO_OBJ} == "yes" && ${BOOTSTRAPPING} < 1100114) || \
1919 (${MK_META_MODE} == "yes" && ${BOOTSTRAPPING} < 1200006)
1920 _crunchgen= usr.sbin/crunch/crunchgen
1923 # r296926 -P keymap search path, MFC to stable/10 in r298297
1924 .if ${BOOTSTRAPPING} < 1003501 || \
1925 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
1926 _kbdcontrol= usr.sbin/kbdcontrol
1932 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1934 .if ${MK_BSNMP} != "no"
1935 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1938 # We need to build tblgen when we're building clang or lld, either as
1939 # bootstrap tools, or as the part of the normal build.
1940 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
1941 ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no"
1943 lib/clang/libllvmminimal \
1944 usr.bin/clang/llvm-tblgen \
1945 usr.bin/clang/clang-tblgen
1947 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal
1948 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal
1951 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1954 .if ${MK_GPL_DTC} != "no"
1955 _dtc= gnu/usr.bin/dtc
1958 .if ${MK_KERBEROS} != "no"
1959 _kerberos5_bootstrap_tools= \
1960 kerberos5/tools/make-roken \
1961 kerberos5/lib/libroken \
1962 kerberos5/lib/libvers \
1963 kerberos5/tools/asn1_compile \
1964 kerberos5/tools/slc \
1967 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1970 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
1972 bootstrap-tools: .PHONY
1974 # Please document (add comment) why something is in 'bootstrap-tools'.
1975 # Try to bound the building of the bootstrap-tool to just the
1976 # FreeBSD versions that need the tool built at this stage of the build.
1979 ${_kerberos5_bootstrap_tools} \
2000 ${_bt}-${_tool}: .PHONY .MAKE
2001 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2002 cd ${.CURDIR}/${_tool}; \
2003 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2004 ${MAKE} DIRPRFX=${_tool}/ all; \
2005 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy install
2007 bootstrap-tools: ${_bt}-${_tool}
2011 # build-tools: Build special purpose build tools
2013 .if !defined(NO_SHARE) && ${MK_SYSCONS} != "no"
2014 _share= share/syscons/scrnmaps
2017 .if ${MK_GCC} != "no"
2018 _gcc_tools= gnu/usr.bin/cc/cc_tools
2021 .if ${MK_RESCUE} != "no"
2022 # rescue includes programs that have build-tools targets
2023 _rescue=rescue/rescue
2026 .if ${MK_TCSH} != "no"
2029 .if ${MK_FILE} != "no"
2030 _libmagic=lib/libmagic
2033 .if ${MACHINE_CPUARCH} == "amd64"
2034 _jevents=lib/libpmc/pmu-events
2037 # kernel-toolchain skips _cleanobj, so handle cleaning up previous
2038 # build-tools directories if needed.
2039 .if !defined(NO_CLEAN) && make(kernel-toolchain)
2040 _bt_clean= ${CLEANDIR}
2046 ${LOCAL_TOOL_DIRS} \
2048 lib/ncurses/ncurses \
2049 lib/ncurses/ncursesw \
2054 usr.bin/mkesdb_static \
2055 usr.bin/mkcsmapper_static \
2056 usr.bin/vi/catalog \
2058 build-tools_${_tool}: .PHONY
2059 ${_+_}@${ECHODIR} "===> ${_tool} (${_bt_clean:D${_bt_clean},}obj,build-tools)"; \
2060 cd ${.CURDIR}/${_tool}; \
2061 if [ -n "${_bt_clean}" ]; then ${MAKE} DIRPRFX=${_tool}/ ${_bt_clean}; fi; \
2062 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2063 ${MAKE} DIRPRFX=${_tool}/ build-tools
2064 build-tools: build-tools_${_tool}
2068 # kernel-tools: Build kernel-building tools
2070 kernel-tools: .PHONY
2071 mkdir -p ${WORLDTMP}/usr
2072 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2073 -p ${WORLDTMP}/usr >/dev/null
2076 # cross-tools: All the tools needed to build the rest of the system after
2077 # we get done with the earlier stages. It is the last set of tools needed
2078 # to begin building the target binaries.
2080 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
2081 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
2082 _btxld= usr.sbin/btxld
2086 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
2087 # resulting from missing bug fixes or ELF Toolchain updates.
2088 .if ${MK_CDDL} != "no"
2089 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
2090 cddl/usr.bin/ctfmerge
2093 # If we're given an XAS, don't build binutils.
2094 .if ${XAS:M/*} == ""
2095 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
2096 _binutils= gnu/usr.bin/binutils
2098 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
2099 _elftctools= lib/libelftc \
2105 # These are not required by the build, but can be useful for developers who
2106 # cross-build on a FreeBSD 10 host:
2107 _elftctools+= usr.bin/addr2line
2109 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
2110 # If cross-building with an external binutils we still need to build strip for
2111 # the target (for at least crunchide).
2112 _elftctools= lib/libelftc \
2117 .if ${MK_CLANG_BOOTSTRAP} != "no"
2118 _clang= usr.bin/clang
2120 .if ${MK_LLD_BOOTSTRAP} != "no"
2121 _lld= usr.bin/clang/lld
2123 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no"
2124 _clang_libs= lib/clang
2126 .if ${MK_GCC_BOOTSTRAP} != "no"
2127 _gcc= gnu/usr.bin/cc
2129 .if ${MK_USB} != "no"
2130 _usb_tools= stand/usb/tools
2133 cross-tools: .MAKE .PHONY
2135 ${LOCAL_XTOOL_DIRS} \
2145 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2146 cd ${.CURDIR}/${_tool}; \
2147 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
2148 ${MAKE} DIRPRFX=${_tool}/ all; \
2149 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP} install
2153 # native-xtools is the current target for qemu-user cross builds of ports
2154 # via poudriere and the imgact_binmisc kernel module.
2155 # This target merely builds a toolchan/sysroot, then builds the tools it wants
2156 # with the options it wants in a special MAKEOBJDIRPREFIX, using the toolchain
2157 # already built. It then installs the static tools to NXBDESTDIR for Poudriere
2160 NXBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/nxb/
2161 NXBOBJTOP= ${NXBOBJROOT}${NXB_TARGET}.${NXB_TARGET_ARCH}
2164 .error NXTP variable should be an absolute path
2166 NXBDESTDIR?= ${DESTDIR}${NXTP}
2168 # This is the list of tools to be built/installed as static and where
2169 # appropriate to build for the given TARGET.TARGET_ARCH.
2231 SUBDIR_DEPEND_usr.bin/clang= lib/clang
2232 .if ${MK_CLANG} != "no"
2234 NXBDIRS+= usr.bin/clang
2236 .if ${MK_GCC} != "no"
2237 NXBDIRS+= gnu/usr.bin/cc
2239 .if ${MK_BINUTILS} != "no"
2240 NXBDIRS+= gnu/usr.bin/binutils
2242 # XXX: native-xtools passes along ${NXBDIRS} in SUBDIR_OVERRIDE that needs
2243 # to be evaluated after NXBDIRS is set.
2244 .if make(install) && !empty(SUBDIR_OVERRIDE)
2245 SUBDIR= ${SUBDIR_OVERRIDE}
2249 OBJTOP=${NXBOBJTOP:Q} \
2250 OBJROOT=${NXBOBJROOT:Q} \
2256 MK_CLANG_EXTRAS=no \
2274 .if make(native-xtools*) && \
2275 (!defined(NXB_TARGET) || !defined(NXB_TARGET_ARCH))
2276 .error Missing NXB_TARGET / NXB_TARGET_ARCH
2278 # For 'toolchain' we want to produce native binaries that themselves generate
2280 NXBTMAKE= ${NXBMAKEENV} ${MAKE} ${NXBMAKEARGS:N-DNO_PIC:N-DNO_SHARED} \
2281 TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH}
2282 # For 'everything' we want to produce native binaries (hence -target to
2283 # be MACHINE) that themselves generate TARGET.TARGET_ARCH binaries.
2284 # TARGET/TARGET_ARCH are still passed along from user.
2286 # Use the toolchain we create as an external toolchain.
2287 .if ${USING_SYSTEM_COMPILER} == "yes" || ${XCC:N${CCACHE_BIN}:M/*}
2288 NXBMAKE+= XCC="${XCC}" \
2292 NXBMAKE+= XCC="${NXBOBJTOP}/tmp/usr/bin/cc" \
2293 XCXX="${NXBOBJTOP}/tmp/usr/bin/c++" \
2294 XCPP="${NXBOBJTOP}/tmp/usr/bin/cpp"
2296 NXBMAKE+= ${NXBMAKEENV} ${MAKE} -f Makefile.inc1 ${NXBMAKEARGS} \
2297 TARGET=${NXB_TARGET} TARGET_ARCH=${NXB_TARGET_ARCH} \
2298 TARGET_TRIPLE=${MACHINE_TRIPLE:Q}
2299 # NXBDIRS is improperly based on MACHINE rather than NXB_TARGET. Need to
2300 # invoke a sub-make to reevaluate MK_GCC, etc, for NXBDIRS.
2301 NXBMAKE+= SUBDIR_OVERRIDE='$${NXBDIRS:M*}'
2302 # Need to avoid the -isystem logic when using clang as an external toolchain
2303 # even if the TARGET being built for wants GCC.
2304 NXBMAKE+= WANT_COMPILER_TYPE='$${X_COMPILER_TYPE}'
2305 native-xtools: .PHONY
2306 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _cleanobj MK_GCC=yes
2307 # Build the bootstrap/host/cross tools that produce native binaries
2308 # Pass along MK_GCC=yes to ensure GCC-needed build tools are built.
2309 # We don't quite know what the NXB_TARGET wants so just build it.
2310 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} kernel-toolchain MK_GCC=yes
2311 # Populate includes/libraries sysroot that produce native binaries.
2312 # This is split out from 'toolchain' above mostly so that target LLVM
2313 # libraries have a proper LLVM_DEFAULT_TARGET_TRIPLE without
2314 # polluting the cross-compiler build. The LLVM/GCC libs are skipped
2315 # here to avoid the problem but are kept in 'toolchain' so that
2316 # needed build tools are built.
2317 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes MK_CLANG=no MK_GCC=no
2318 ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries MK_CLANG=no MK_GCC=no
2319 # Clean out improper TARGET=MACHINE files
2320 ${_+_}cd ${.CURDIR}/gnu/usr.bin/cc/cc_tools; ${NXBTMAKE} cleandir
2321 .if !defined(NO_OBJWALK)
2322 ${_+_}cd ${.CURDIR}; ${NXBMAKE} _obj
2324 ${_+_}cd ${.CURDIR}; ${NXBMAKE} everything
2325 @echo ">> native-xtools done. Use 'make native-xtools-install' to install to a given DESTDIR"
2327 native-xtools-install: .PHONY
2328 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
2329 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2330 -p ${NXBDESTDIR}/usr >/dev/null
2331 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2332 -p ${NXBDESTDIR}/usr/include >/dev/null
2333 ${_+_}cd ${.CURDIR}; ${NXBMAKE} \
2334 DESTDIR=${NXBDESTDIR} \
2339 # hierarchy - ensure that all the needed directories are present
2341 hierarchy hier: .MAKE .PHONY
2342 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
2345 # libraries - build all libraries, and install them under ${DESTDIR}.
2347 # The list of libraries with dependents (${_prebuild_libs}) and their
2348 # interdependencies (__L) are built automatically by the
2349 # ${.CURDIR}/tools/make_libdeps.sh script.
2351 libraries: .MAKE .PHONY
2352 ${_+_}cd ${.CURDIR}; \
2353 ${MAKE} -f Makefile.inc1 _prereq_libs; \
2354 ${MAKE} -f Makefile.inc1 _startup_libs; \
2355 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
2356 ${MAKE} -f Makefile.inc1 _generic_libs
2359 # static libgcc.a prerequisite for shared libc
2361 _prereq_libs= lib/libcompiler_rt
2362 .if ${MK_SSP} != "no"
2363 _prereq_libs+= gnu/lib/libssp/libssp_nonshared
2366 # These dependencies are not automatically generated:
2368 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
2369 # all shared libraries for ELF.
2371 _startup_libs= gnu/lib/csu
2372 _startup_libs+= lib/csu
2373 _startup_libs+= lib/libcompiler_rt
2374 _startup_libs+= lib/libc
2375 _startup_libs+= lib/libc_nonshared
2376 .if ${MK_LIBCPLUSPLUS} != "no"
2377 _startup_libs+= lib/libcxxrt
2380 .if ${MK_LLVM_LIBUNWIND} != "no"
2381 _prereq_libs+= lib/libgcc_eh lib/libgcc_s
2382 _startup_libs+= lib/libgcc_eh lib/libgcc_s
2384 lib/libgcc_s__L: lib/libc__L
2385 lib/libgcc_s__L: lib/libc_nonshared__L
2386 .if ${MK_LIBCPLUSPLUS} != "no"
2387 lib/libcxxrt__L: lib/libgcc_s__L
2390 .else # MK_LLVM_LIBUNWIND == no
2392 _prereq_libs+= gnu/lib/libgcc
2393 _startup_libs+= gnu/lib/libgcc
2395 gnu/lib/libgcc__L: lib/libc__L
2396 gnu/lib/libgcc__L: lib/libc_nonshared__L
2397 .if ${MK_LIBCPLUSPLUS} != "no"
2398 lib/libcxxrt__L: gnu/lib/libgcc__L
2402 _prebuild_libs= ${_kerberos5_lib_libasn1} \
2403 ${_kerberos5_lib_libhdb} \
2404 ${_kerberos5_lib_libheimbase} \
2405 ${_kerberos5_lib_libheimntlm} \
2407 ${_kerberos5_lib_libheimipcc} \
2408 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
2409 ${_kerberos5_lib_libroken} \
2410 ${_kerberos5_lib_libwind} \
2411 lib/libbz2 ${_libcom_err} lib/libcrypt \
2412 lib/libelf lib/libexpat \
2415 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
2417 lib/ncurses/ncurses lib/ncurses/ncursesw \
2418 lib/libopie lib/libpam/libpam ${_lib_libthr} \
2419 ${_lib_libradius} lib/libsbuf lib/libtacplus \
2421 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
2422 ${_cddl_lib_libuutil} \
2423 ${_cddl_lib_libavl} \
2424 ${_cddl_lib_libzfs_core} \
2425 ${_cddl_lib_libctf} \
2426 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
2427 ${_secure_lib_libcrypto} ${_lib_libldns} \
2428 ${_secure_lib_libssh} ${_secure_lib_libssl}
2430 .if ${MK_GNUCXX} != "no"
2431 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
2432 gnu/lib/libstdc++__L: lib/msun__L
2433 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
2436 .if ${MK_DIALOG} != "no"
2437 _prebuild_libs+= gnu/lib/libdialog
2438 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2441 .if ${MK_LIBCPLUSPLUS} != "no"
2442 _prebuild_libs+= lib/libc++
2445 lib/libgeom__L: lib/libexpat__L
2446 lib/libkvm__L: lib/libelf__L
2448 .if ${MK_LIBTHR} != "no"
2449 _lib_libthr= lib/libthr
2452 .if ${MK_RADIUS_SUPPORT} != "no"
2453 _lib_libradius= lib/libradius
2456 .if ${MK_OFED} != "no"
2458 # The OFED libraries are built in four steps
2459 # as reflected below, due to interdependencies.
2461 # NOTE: Depending on contrib/ofed/include is only needed for
2462 # the lib32 compat build.
2465 contrib/ofed/include \
2466 contrib/ofed/usr.lib/0 \
2467 contrib/ofed/usr.lib/1 \
2468 contrib/ofed/usr.lib/2 \
2469 contrib/ofed/usr.lib/3
2471 contrib/ofed/usr.lib/0__L: contrib/ofed/include__L lib/libthr__L
2472 contrib/ofed/usr.lib/1__L: contrib/ofed/usr.lib/0__L
2473 contrib/ofed/usr.lib/2__L: contrib/ofed/usr.lib/1__L
2474 contrib/ofed/usr.lib/3__L: contrib/ofed/usr.lib/2__L
2477 .if ${MK_CASPER} != "no"
2478 _lib_casper= lib/libcasper
2481 lib/libpjdlog__L: lib/libutil__L
2482 lib/libcasper__L: lib/libnv__L
2483 lib/liblzma__L: lib/libthr__L
2485 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
2486 .if ${MK_IPFILTER} != "no"
2487 _generic_libs+= sbin/ipf/libipf
2489 .for _DIR in ${LOCAL_LIB_DIRS}
2490 .if ${_DIR} == ".WAIT" || (empty(_generic_libs:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
2491 _generic_libs+= ${_DIR}
2495 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2497 .if ${MK_CDDL} != "no"
2498 _cddl_lib_libumem= cddl/lib/libumem
2499 _cddl_lib_libnvpair= cddl/lib/libnvpair
2500 _cddl_lib_libavl= cddl/lib/libavl
2501 _cddl_lib_libuutil= cddl/lib/libuutil
2502 .if ${MK_ZFS} != "no"
2503 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2504 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2506 _cddl_lib_libctf= cddl/lib/libctf
2508 cddl/lib/libctf__L: lib/libz__L
2510 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
2511 # on select architectures though (see cddl/lib/Makefile)
2512 .if ${MACHINE_CPUARCH} != "sparc64"
2513 _prebuild_libs+= lib/libprocstat lib/libproc lib/librtld_db
2514 lib/libprocstat__L: lib/libelf__L lib/libkvm__L lib/libutil__L
2515 lib/libproc__L: lib/libprocstat__L
2516 lib/librtld_db__L: lib/libprocstat__L
2519 .if ${MK_CRYPT} != "no"
2520 .if ${MK_OPENSSL} != "no"
2521 _secure_lib_libcrypto= secure/lib/libcrypto
2522 _secure_lib_libssl= secure/lib/libssl
2523 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2524 .if ${MK_LDNS} != "no"
2525 _lib_libldns= lib/libldns
2526 lib/libldns__L: secure/lib/libcrypto__L
2528 .if ${MK_OPENSSH} != "no"
2529 _secure_lib_libssh= secure/lib/libssh
2530 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2531 .if ${MK_LDNS} != "no"
2532 secure/lib/libssh__L: lib/libldns__L
2534 .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no"
2535 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2536 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2537 lib/libmd__L kerberos5/lib/libroken__L
2541 _secure_lib= secure/lib
2544 .if ${MK_KERBEROS} != "no"
2545 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2546 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2547 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2548 kerberos5/lib/libwind__L lib/libsqlite3__L
2549 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2550 kerberos5/lib/libroken__L lib/libcom_err__L
2551 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2552 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2553 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2554 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2555 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2556 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2557 kerberos5/lib/libroken__L: lib/libcrypt__L
2558 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2559 kerberos5/lib/libheimbase__L: lib/libthr__L
2560 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2563 lib/libsqlite3__L: lib/libthr__L
2565 .if ${MK_GSSAPI} != "no"
2566 _lib_libgssapi= lib/libgssapi
2569 .if ${MK_KERBEROS} != "no"
2570 _kerberos5_lib= kerberos5/lib
2571 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2572 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2573 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2574 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2575 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2576 _kerberos5_lib_libroken= kerberos5/lib/libroken
2577 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2578 _libsqlite3= lib/libsqlite3
2579 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2580 _kerberos5_lib_libwind= kerberos5/lib/libwind
2581 _libcom_err= lib/libcom_err
2584 .if ${MK_NIS} != "no"
2585 _lib_libypclnt= lib/libypclnt
2588 .if ${MK_OPENSSL} == "no"
2589 lib/libradius__L: lib/libmd__L
2593 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2594 .if ${MK_CXX} != "no"
2595 .if ${MK_LIBCPLUSPLUS} != "no"
2596 lib/libproc__L: lib/libcxxrt__L
2597 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2598 lib/libproc__L: gnu/lib/libsupc++__L
2602 .for _lib in ${_prereq_libs}
2603 ${_lib}__PL: .PHONY .MAKE
2604 .if exists(${.CURDIR}/${_lib})
2605 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2606 cd ${.CURDIR}/${_lib}; \
2607 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
2608 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2609 DIRPRFX=${_lib}/ all; \
2610 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2611 DIRPRFX=${_lib}/ install
2615 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
2616 ${_lib}__L: .PHONY .MAKE
2617 .if exists(${.CURDIR}/${_lib})
2618 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2619 cd ${.CURDIR}/${_lib}; \
2620 if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
2621 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2622 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2626 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2627 _startup_libs: ${_startup_libs:S/$/__L/}
2628 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2629 _generic_libs: ${_generic_libs:S/$/__L/}
2631 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2632 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2633 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2634 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2635 # parallel. This is safe for the world stage of buildworld though since it has
2636 # already built libraries in a proper order and installed includes into
2637 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2638 # avoid trashing a system if it crashes mid-install.
2639 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2643 .include <bsd.subdir.mk>
2645 .if make(check-old) || make(check-old-dirs) || \
2646 make(check-old-files) || make(check-old-libs) || \
2647 make(delete-old) || make(delete-old-dirs) || \
2648 make(delete-old-files) || make(delete-old-libs)
2651 # check for / delete old files section
2654 .include "ObsoleteFiles.inc"
2656 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2657 else you can not start such an application. Consult UPDATING for more \
2658 information regarding how to cope with the removal/revision bump of a \
2661 .if !defined(BATCH_DELETE_OLD_FILES)
2667 delete-old-files: .PHONY
2668 @echo ">>> Removing old files (only deletes safe to delete libs)"
2669 # Ask for every old file if the user really wants to remove it.
2670 # It's annoying, but better safe than sorry.
2671 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2672 # argument list will get too long. Using .for/.endfor make "loops" will make
2673 # the Makefile parser segfault.
2676 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2677 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2678 while read file; do \
2679 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2680 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2681 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2683 for ext in debug symbols; do \
2684 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2685 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2686 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2691 # Remove catpages without corresponding manpages.
2693 find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \
2694 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2695 while read catpage; do \
2697 if [ ! -e "$${manpage}" ]; then \
2698 rm ${RM_I} $${catpage} <&3; \
2701 @echo ">>> Old files removed"
2703 check-old-files: .PHONY
2704 @echo ">>> Checking for old files"
2706 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2707 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2708 while read file; do \
2709 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2710 echo "${DESTDIR}/$${file}"; \
2712 for ext in debug symbols; do \
2713 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2714 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2718 # Check for catpages without corresponding manpages.
2719 @find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \
2720 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2721 while read catpage; do \
2723 if [ ! -e "$${manpage}" ]; then \
2728 delete-old-libs: .PHONY
2729 @echo ">>> Removing old libraries"
2730 @echo "${OLD_LIBS_MESSAGE}" | fmt
2733 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2734 -V OLD_LIBS | xargs -n1 | \
2735 while read file; do \
2736 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2737 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2738 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2740 for ext in debug symbols; do \
2741 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2742 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2743 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2748 @echo ">>> Old libraries removed"
2750 check-old-libs: .PHONY
2751 @echo ">>> Checking for old libraries"
2753 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2754 -V OLD_LIBS | xargs -n1 | \
2755 while read file; do \
2756 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2757 echo "${DESTDIR}/$${file}"; \
2759 for ext in debug symbols; do \
2760 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2761 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2766 delete-old-dirs: .PHONY
2767 @echo ">>> Removing old directories"
2769 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2770 -V OLD_DIRS | xargs -n1 | sort -r | \
2771 while read dir; do \
2772 if [ -d "${DESTDIR}/$${dir}" ]; then \
2773 rmdir -v "${DESTDIR}/$${dir}" || true; \
2774 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2775 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2777 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2778 rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \
2779 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2780 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2783 @echo ">>> Old directories removed"
2785 check-old-dirs: .PHONY
2786 @echo ">>> Checking for old directories"
2788 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2789 -V OLD_DIRS | xargs -n1 | \
2790 while read dir; do \
2791 if [ -d "${DESTDIR}/$${dir}" ]; then \
2792 echo "${DESTDIR}/$${dir}"; \
2793 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2794 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2796 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2797 echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \
2798 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2799 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2803 delete-old: delete-old-files delete-old-dirs .PHONY
2804 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2806 check-old: check-old-files check-old-libs check-old-dirs .PHONY
2807 @echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
2808 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2813 # showconfig - show build configuration.
2816 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes; \
2817 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes) 2>&1 | grep ^MK_ | sort -u
2819 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2820 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2822 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2823 .if exists(${KERNCONFDIR}/${KERNCONF})
2824 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2825 '${KERNCONFDIR}/${KERNCONF}' ; echo
2831 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2832 DTBOUTPUTPATH= ${.CURDIR}
2836 # Build 'standalone' Device Tree Blob
2839 @PATH=${TMPPATH} MACHINE=${TARGET} \
2840 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2841 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2846 # In the following, the first 'rm' in a series will usually remove all
2847 # files and directories. If it does not, then there are probably some
2848 # files with file flags set, so this unsets them and tries the 'rm' a
2849 # second time. There are situations where this target will be cleaning
2850 # some directories via more than one method, but that duplication is
2851 # needed to correctly handle all the possible situations. Removing all
2852 # files without file flags set in the first 'rm' instance saves time,
2853 # because 'chflags' will need to operate on fewer files afterwards.
2855 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2856 # created by bsd.obj.mk, except that we don't want to .include that file
2857 # in this makefile. We don't do a cleandir walk if MK_AUTO_OBJ is yes
2858 # since it is not possible for files to land in the wrong place.
2860 .if make(cleanworld)
2861 BW_CANONICALOBJDIR:=${OBJTOP}/
2862 .elif make(cleanuniverse)
2863 BW_CANONICALOBJDIR:=${OBJROOT}
2864 .if ${MK_UNIFIED_OBJDIR} == "no"
2865 .error ${.TARGETS} only supported with WITH_UNIFIED_OBJDIR enabled.
2868 cleanworld cleanuniverse: .PHONY
2869 .if !empty(BW_CANONICALOBJDIR) && exists(${BW_CANONICALOBJDIR}) && \
2870 ${.CURDIR:tA} != ${BW_CANONICALOBJDIR:tA}
2871 -rm -rf ${BW_CANONICALOBJDIR}*
2872 -chflags -R 0 ${BW_CANONICALOBJDIR}
2873 rm -rf ${BW_CANONICALOBJDIR}*
2875 .if make(cleanworld) && ${MK_AUTO_OBJ} == "no" && \
2876 (empty(BW_CANONICALOBJDIR) || ${.CURDIR:tA} == ${BW_CANONICALOBJDIR:tA})
2877 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2878 # To be safe in this case, fall back to a 'make cleandir'
2879 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2883 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2884 XDEV_CPUTYPE?=${CPUTYPE}
2886 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2889 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2890 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2891 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2892 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2893 CPUTYPE=${XDEV_CPUTYPE}
2895 XDDIR=${TARGET_ARCH}-freebsd
2898 .error XDTP variable should be an absolute path
2901 CDBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/xdev/
2902 CDBOBJTOP= ${CDBOBJROOT}${XDDIR}
2904 INSTALL="sh ${.CURDIR}/tools/install.sh"
2906 TOOLS_PREFIX=${XDTP}
2908 OBJTOP=${CDBOBJTOP:Q} \
2909 OBJROOT=${CDBOBJROOT:Q}
2910 CD2MAKEARGS= ${CDMAKEARGS}
2912 .if ${WANT_COMPILER_TYPE} == gcc || \
2913 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
2914 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
2915 # won't set header path and -L is used to ensure the base library path
2916 # is added before the port PREFIX library path.
2917 CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib
2918 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
2919 # combined with --sysroot.
2920 CD2CFLAGS+= -B${XDDESTDIR}/usr/lib
2921 # Force using libc++ for external GCC.
2922 .if defined(X_COMPILER_TYPE) && \
2923 ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
2924 CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \
2928 CD2CFLAGS+= --sysroot=${XDDESTDIR}/
2929 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \
2930 CPP="${CPP} ${CD2CFLAGS}" \
2931 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2933 CDTMP= ${OBJTOP}/${XDDIR}/tmp
2934 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${CDMAKEARGS} ${NOFUN}
2935 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} \
2936 ${MAKE} ${CD2MAKEARGS} ${NOFUN}
2937 .if ${MK_META_MODE} != "no"
2938 # Don't rebuild build-tools targets during normal build.
2939 CD2MAKE+= BUILD_TOOLS_META=.NOMETA
2941 XDDESTDIR=${DESTDIR}${XDTP}
2943 .ORDER: xdev-build xdev-install xdev-links
2944 xdev: xdev-build xdev-install .PHONY
2946 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2947 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
2949 _xb-worldtmp: .PHONY
2950 mkdir -p ${CDTMP}/usr
2951 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2952 -p ${CDTMP}/usr >/dev/null
2954 _xb-bootstrap-tools: .PHONY
2959 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2960 cd ${.CURDIR}/${_tool}; \
2961 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
2962 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2963 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2966 _xb-build-tools: .PHONY
2967 ${_+_}@cd ${.CURDIR}; \
2968 ${CDBENV} ${MAKE} ${CDMAKEARGS} -f Makefile.inc1 ${NOFUN} build-tools
2979 _xb-cross-tools: .PHONY
2980 .for _tool in ${XDEVDIRS}
2981 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2982 cd ${.CURDIR}/${_tool}; \
2983 if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
2984 ${CDMAKE} DIRPRFX=${_tool}/ all
2988 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2989 mkdir -p ${XDDESTDIR}
2990 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2991 -p ${XDDESTDIR} >/dev/null
2992 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2993 -p ${XDDESTDIR}/usr >/dev/null
2994 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2995 -p ${XDDESTDIR}/usr/include >/dev/null
2996 .if defined(LIBCOMPAT)
2997 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2998 -p ${XDDESTDIR}/usr >/dev/null
3000 .if ${MK_TESTS} != "no"
3001 mkdir -p ${XDDESTDIR}${TESTSBASE}
3002 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
3003 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
3006 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
3007 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
3009 _xi-cross-tools: .PHONY
3010 @echo "_xi-cross-tools"
3011 .for _tool in ${XDEVDIRS}
3012 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
3013 cd ${.CURDIR}/${_tool}; \
3014 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
3017 _xi-includes: .PHONY
3018 .if !defined(NO_OBJWALK)
3019 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 _obj \
3020 DESTDIR=${XDDESTDIR}
3022 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
3023 DESTDIR=${XDDESTDIR}
3025 _xi-libraries: .PHONY
3026 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
3027 DESTDIR=${XDDESTDIR}
3030 ${_+_}cd ${XDDESTDIR}/usr/bin; \
3031 mkdir -p ../../../../usr/bin; \
3033 ln -sf ../../${XDTP}/usr/bin/$$i \
3034 ../../../../usr/bin/${XDDIR}-$$i; \
3035 ln -sf ../../${XDTP}/usr/bin/$$i \
3036 ../../../../usr/bin/${XDDIR}${_REVISION}-$$i; \