4 # Make command line options:
5 # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6 # -DNO_CLEAN do not clean at all
7 # -DDB_FROM_SRC use the user/group databases in src/etc instead of
8 # the system database when installing.
9 # -DNO_SHARE do not go into share subdir
10 # -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,OBJ}
11 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
12 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
13 # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
14 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
15 # -DNO_ROOT install without using root privilege
16 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
17 # -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects
18 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
19 # LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list
20 # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
21 # LOCAL_MTREE="list of mtree files" to process to allow local directories
22 # to be created before files are installed
23 # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
25 # LOCAL_XTOOL_DIRS="list of dirs" to add additional dirs to the
27 # METALOG="path to metadata log" to write permission and ownership
28 # when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
29 # TARGET="machine" to crossbuild world for a different machine type
30 # TARGET_ARCH= may be required when a TARGET supports multiple endians
31 # BUILDENV_SHELL= shell to launch for the buildenv target (def:${SHELL})
32 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
33 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
34 # SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
35 # All libraries and includes, and some build tools will still build.
38 # The intended user-driven targets are:
39 # buildworld - rebuild *everything*, including glue to help do upgrades
40 # installworld- install everything built by "buildworld"
41 # checkworld - run test suite on installed world
42 # doxygen - build API documentation of the kernel
43 # update - convenient way to update your source tree (eg: svn/svnup)
45 # Standard targets (not defined here) are documented in the makefiles in
46 # /usr/share/mk. These include:
47 # obj depend all install clean cleandepend cleanobj
49 .if !defined(TARGET) || !defined(TARGET_ARCH)
50 .error "Both TARGET and TARGET_ARCH must be defined."
54 LOCALBASE?= /usr/local
56 # Cross toolchain changes must be in effect before bsd.compiler.mk
57 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
58 .if defined(CROSS_TOOLCHAIN)
59 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
60 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
62 .if defined(CROSS_TOOLCHAIN_PREFIX)
63 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
66 XCOMPILERS= CC CXX CPP
67 .for COMPILER in ${XCOMPILERS}
68 .if defined(CROSS_COMPILER_PREFIX)
69 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
71 X${COMPILER}?= ${${COMPILER}}
74 # If a full path to an external cross compiler is given, don't build
76 .if ${XCC:N${CCACHE_BIN}:M/*}
77 MK_CLANG_BOOTSTRAP= no
81 MAKEOBJDIRPREFIX?= /usr/obj
82 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
83 OBJTREE= ${MAKEOBJDIRPREFIX}
85 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
88 # Pull in compiler metadata from buildworld/toolchain if possible to avoid
89 # running CC from bsd.compiler.mk.
90 .if make(installworld) || make(install)
91 .-include "${OBJTREE}${.CURDIR}/compiler-metadata.mk"
94 # Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early.
95 .include <bsd.compiler.mk>
96 .include "share/mk/src.opts.mk"
98 # Check if there is a local compiler that can satisfy as an external compiler.
99 # Which compiler is expected to be used?
100 .if ${MK_CLANG_BOOTSTRAP} == "yes"
101 WANT_COMPILER_TYPE= clang
102 .elif ${MK_GCC_BOOTSTRAP} == "yes"
103 WANT_COMPILER_TYPE= gcc
107 .if !defined(WANT_COMPILER_FREEBSD_VERSION)
108 .if ${WANT_COMPILER_TYPE} == "clang"
109 WANT_COMPILER_FREEBSD_VERSION_FILE= lib/clang/freebsd_cc_version.h
110 WANT_COMPILER_FREEBSD_VERSION!= \
111 awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
112 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
113 WANT_COMPILER_VERSION_FILE= lib/clang/include/clang/Basic/Version.inc
114 WANT_COMPILER_VERSION!= \
115 awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
116 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
117 .elif ${WANT_COMPILER_TYPE} == "gcc"
118 WANT_COMPILER_FREEBSD_VERSION_FILE= gnu/usr.bin/cc/cc_tools/freebsd-native.h
119 WANT_COMPILER_FREEBSD_VERSION!= \
120 awk '$$2 == "FBSD_CC_VER" {printf("%d\n", $$3)}' \
121 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
122 WANT_COMPILER_VERSION_FILE= contrib/gcc/BASE-VER
123 WANT_COMPILER_VERSION!= \
124 awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3}' \
125 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
127 .export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION
128 .endif # !defined(WANT_COMPILER_FREEBSD_VERSION)
129 # It needs to be the same revision as we would build for the bootstrap.
130 # If the expected vs CC is different then we can't skip.
131 # GCC cannot be used for cross-arch yet. For clang we pass -target later if
132 # TARGET_ARCH!=MACHINE_ARCH.
133 .if ${MK_SYSTEM_COMPILER} == "yes" && \
134 (${MK_CLANG_BOOTSTRAP} == "yes" || ${MK_GCC_BOOTSTRAP} == "yes") && \
135 !make(showconfig) && !make(native-xtools) && !make(xdev*) && \
136 ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE} && \
137 (${COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \
138 ${COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \
139 ${COMPILER_FREEBSD_VERSION} == ${WANT_COMPILER_FREEBSD_VERSION}
140 # Everything matches, disable the bootstrap compiler.
141 MK_CLANG_BOOTSTRAP= no
143 USING_SYSTEM_COMPILER= yes
144 .endif # ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE}
145 USING_SYSTEM_COMPILER?= no
146 TEST_SYSTEM_COMPILER_VARS= \
147 USING_SYSTEM_COMPILER MK_SYSTEM_COMPILER \
148 MK_CROSS_COMPILER MK_CLANG_BOOTSTRAP MK_GCC_BOOTSTRAP \
149 WANT_COMPILER_TYPE WANT_COMPILER_VERSION WANT_COMPILER_VERSION_FILE \
150 WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \
151 CC COMPILER_TYPE COMPILER_FEATURES COMPILER_VERSION \
152 COMPILER_FREEBSD_VERSION
153 test-system-compiler: .PHONY
154 .for v in ${TEST_SYSTEM_COMPILER_VARS}
155 ${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}"
157 .if ${USING_SYSTEM_COMPILER} == "yes" && \
158 (make(buildworld) || make(buildkernel) || make(kernel-toolchain) || \
159 make(toolchain) || make(_cross-tools))
160 .info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler.
163 # For installworld need to ensure that the looked-up compiler metadata is
164 # passed along rather than trying to run cc from the restricted
166 .if ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
167 .if !defined(X_COMPILER_TYPE)
168 CROSSENV+= COMPILER_VERSION=${COMPILER_VERSION} \
169 COMPILER_TYPE=${COMPILER_TYPE} \
170 COMPILER_FEATURES=${COMPILER_FEATURES} \
171 COMPILER_FREEBSD_VERSION=${COMPILER_FREEBSD_VERSION}
173 CROSSENV+= COMPILER_VERSION=${X_COMPILER_VERSION} \
174 COMPILER_FEATURES=${X_COMPILER_FEATURES} \
175 COMPILER_TYPE=${X_COMPILER_TYPE} \
176 COMPILER_FREEBSD_VERSION=${X_COMPILER_FREEBSD_VERSION}
179 # Store some compiler metadata for use in installworld where we don't
180 # want to invoke CC at all.
181 _COMPILER_METADATA_VARS= COMPILER_VERSION \
184 COMPILER_FREEBSD_VERSION
185 compiler-metadata.mk: .PHONY .META
187 @echo ".info Using cached compiler metadata from build at $$(hostname) on $$(date)" \
189 .for v in ${_COMPILER_METADATA_VARS}
190 @echo "${v}=${${v}}" >> ${.TARGET}
192 @echo ".export ${_COMPILER_METADATA_VARS}" >> ${.TARGET}
194 # Handle external binutils.
195 .if defined(CROSS_TOOLCHAIN_PREFIX)
196 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
198 # If we do not have a bootstrap binutils (because the in-tree one does not
199 # support the target architecture), provide a default cross-binutils prefix.
200 # This allows riscv64 builds, for example, to automatically use the
201 # riscv64-binutils port or package.
202 .if !make(showconfig)
203 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
204 ${MK_LLD_BOOTSTRAP} == "no" && \
205 !defined(CROSS_BINUTILS_PREFIX)
206 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
207 .if !exists(${CROSS_BINUTILS_PREFIX})
208 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
212 XBINUTILS= AS AR LD NM OBJCOPY RANLIB SIZE STRINGS
213 .for BINUTIL in ${XBINUTILS}
214 .if defined(CROSS_BINUTILS_PREFIX) && \
215 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
216 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
218 X${BINUTIL}?= ${${BINUTIL}}
223 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
224 # keep the users system reasonably usable. For static->dynamic root upgrades,
225 # we don't want to install a dynamic binary without rtld and the needed
226 # libraries. More commonly, for dynamic root, we don't want to install a
227 # binary that requires a newer library version that hasn't been installed yet.
228 # This ordering is not a guarantee though. The only guarantee of a working
229 # system here would require fine-grained ordering of all components based
230 # on their dependencies.
231 .if !empty(SUBDIR_OVERRIDE)
232 SUBDIR= ${SUBDIR_OVERRIDE}
235 .if !defined(NO_ROOT) && (make(installworld) || make(install))
236 # Ensure libraries are installed before progressing.
240 .if ${MK_CDDL} != "no"
244 .if ${MK_KERBEROS} != "no"
247 .if ${MK_RESCUE} != "no"
251 .if ${MK_CRYPT} != "no"
254 .if !defined(NO_SHARE)
257 SUBDIR+=sys usr.bin usr.sbin
258 .if ${MK_TESTS} != "no"
261 .if ${MK_OFED} != "no"
265 # Local directories are last, since it is nice to at least get the base
266 # system rebuilt before you do them.
267 .for _DIR in ${LOCAL_DIRS}
268 .if exists(${.CURDIR}/${_DIR}/Makefile)
272 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
273 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
274 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
275 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
276 _REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
278 .for _DIR in ${LOCAL_LIB_DIRS}
279 .if empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
284 # We must do etc/ last as it hooks into building the man whatis file
285 # by calling 'makedb' in share/man. This is only relevant for
286 # install/distribute so they build the whatis file after every manpage is
288 .if make(installworld) || make(install)
293 .endif # !empty(SUBDIR_OVERRIDE)
296 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
299 .if defined(NO_CLEANDIR)
300 CLEANDIR= clean cleandepend
305 .if ${MK_META_MODE} == "yes"
306 # If filemon is used then we can rely on the build being incremental-safe.
307 # The .meta files will also track the build command and rebuild should
309 .if empty(.MAKE.MODE:Mnofilemon)
313 .if defined(NO_OBJ) || ${MK_AUTO_OBJ} == "yes"
322 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
324 .if empty(SHELL:M*csh*)
325 BUILDENV_SHELL?=${SHELL}
327 BUILDENV_SHELL?=/bin/sh
330 .if !defined(SVN) || empty(SVN)
331 . for _P in /usr/bin /usr/local/bin
332 . for _S in svn svnlite
333 . if exists(${_P}/${_S})
341 .if !defined(OSRELDATE)
342 .if exists(/usr/include/osreldate.h)
343 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
344 /usr/include/osreldate.h
351 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
352 .if !defined(_REVISION)
353 _REVISION!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V REVISION
356 .if !defined(_BRANCH)
357 _BRANCH!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V BRANCH
360 .if !defined(SRCRELDATE)
361 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
362 ${SRCDIR}/sys/sys/param.h
365 .if !defined(VERSION)
366 VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
370 .if !defined(PKG_VERSION)
371 .if ${_BRANCH:MSTABLE*} || ${_BRANCH:MCURRENT*} || ${_BRANCH:MALPHA*}
372 TIMENOW= %Y%m%d%H%M%S
373 EXTRA_REVISION= .s${TIMENOW:gmtime}
376 EXTRA_REVISION= _${_BRANCH:C/.*-p([0-9]+$)/\1/}
378 PKG_VERSION= ${_REVISION}${EXTRA_REVISION}
381 KNOWN_ARCHES?= aarch64/arm64 \
404 .if ${TARGET} == ${TARGET_ARCH}
407 _t= ${TARGET_ARCH}/${TARGET}
410 .if empty(KNOWN_ARCHES:M${_t})
411 .error Unknown target ${TARGET_ARCH}:${TARGET}.
415 .if ${TARGET} == ${MACHINE}
416 TARGET_CPUTYPE?=${CPUTYPE}
421 .if !empty(TARGET_CPUTYPE)
422 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
424 _TARGET_CPUTYPE=dummy
426 _CPUTYPE!= MK_AUTO_OBJ=no MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
427 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
428 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
429 .error CPUTYPE global should be set with ?=.
432 BUILD_ARCH!= uname -p
433 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
434 .error To cross-build, set TARGET_ARCH.
437 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
438 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
439 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
440 STRICTTMPPATH= ${BPATH}:${XPATH}
441 TMPPATH= ${STRICTTMPPATH}:${PATH}
444 # Avoid running mktemp(1) unless actually needed.
445 # It may not be functional, e.g., due to new ABI
446 # when in the middle of installing over this system.
448 .if make(distributeworld) || make(installworld) || make(stageworld)
449 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
452 .if make(stagekernel) || make(distributekernel)
458 # Building a world goes through the following stages
460 # 1. legacy stage [BMAKE]
461 # This stage is responsible for creating compatibility
462 # shims that are needed by the bootstrap-tools,
463 # build-tools and cross-tools stages. These are generally
464 # APIs that tools from one of those three stages need to
465 # build that aren't present on the host.
466 # 1. bootstrap-tools stage [BMAKE]
467 # This stage is responsible for creating programs that
468 # are needed for backward compatibility reasons. They
469 # are not built as cross-tools.
470 # 2. build-tools stage [TMAKE]
471 # This stage is responsible for creating the object
472 # tree and building any tools that are needed during
473 # the build process. Some programs are listed during
474 # this phase because they build binaries to generate
475 # files needed to build these programs. This stage also
476 # builds the 'build-tools' target rather than 'all'.
477 # 3. cross-tools stage [XMAKE]
478 # This stage is responsible for creating any tools that
479 # are needed for building the system. A cross-compiler is one
480 # of them. This differs from build tools in two ways:
481 # 1. the 'all' target is built rather than 'build-tools'
482 # 2. these tools are installed into TMPPATH for stage 4.
483 # 4. world stage [WMAKE]
484 # This stage actually builds the world.
485 # 5. install stage (optional) [IMAKE]
486 # This stage installs a previously built world.
490 # Keep these in sync -- see below for special case exception
491 MINIMUM_SUPPORTED_OSREL?= 900044
492 MINIMUM_SUPPORTED_REL?= 9.1
494 # Common environment for world related stages
495 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
496 MACHINE_ARCH=${TARGET_ARCH} \
498 CPUTYPE=${TARGET_CPUTYPE}
499 .if ${MK_META_MODE} != "no"
500 # Don't rebuild build-tools targets during normal build.
501 CROSSENV+= BUILD_TOOLS_META=.NOMETA
503 .if ${MK_GROFF} != "no"
504 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
505 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
506 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
508 .if defined(TARGET_CFLAGS)
509 CROSSENV+= ${TARGET_CFLAGS}
512 # bootstrap-tools stage
513 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
514 TOOLS_PREFIX=${WORLDTMP} \
515 PATH=${BPATH}:${PATH} \
516 WORLDTMP=${WORLDTMP} \
517 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
518 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
520 BOOTSTRAPPING=${OSRELDATE} \
522 MK_HTML=no NO_LINT=yes MK_MAN=no \
523 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
524 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
525 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
526 MK_LLDB=no MK_TESTS=no \
529 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
530 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
534 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
535 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
536 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
538 BOOTSTRAPPING=${OSRELDATE} \
541 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
542 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
543 MK_LLDB=no MK_TESTS=no
546 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
547 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
548 MK_GDB=no MK_TESTS=no
551 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
552 PATH=${BPATH}:${PATH} \
554 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
555 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
557 BOOTSTRAPPING=${OSRELDATE} \
559 MK_HTML=no -DNO_LINT MK_MAN=no \
560 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
561 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
564 WMAKEENV= ${CROSSENV} \
565 INSTALL="sh ${.CURDIR}/tools/install.sh" \
569 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
571 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
574 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
575 CPP="${XCPP} ${XCFLAGS}" \
576 AS="${XAS}" AR="${XAR}" LD="${XLD}" LLVM_LINK="${XLLVM_LINK}" \
577 NM=${XNM} OBJCOPY="${XOBJCOPY}" \
578 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
581 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
582 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
583 # directory, but the compiler will look in the right place for its
584 # tools so we don't need to tell it where to look.
585 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
589 # The internal bootstrap compiler has a default sysroot set by TOOLS_PREFIX
590 # and target set by TARGET/TARGET_ARCH. However, there are several needs to
591 # always pass an explicit --sysroot and -target.
592 # - External compiler needs sysroot and target flags.
593 # - External ld needs sysroot.
594 # - To be clear about the use of a sysroot when using the internal compiler.
595 # - Easier debugging.
596 # - Allowing WITH_SYSTEM_COMPILER+WITH_META_MODE to work together due to
597 # the flip-flopping build command when sometimes using external and
598 # sometimes using internal.
599 # - Allow using lld which has no support for default paths.
600 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
601 BFLAGS+= -B${WORLDTMP}/usr/bin
603 .if ${TARGET} == "arm"
604 .if ${TARGET_ARCH:Marmv6*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
605 TARGET_ABI= gnueabihf
610 .if ${WANT_COMPILER_TYPE} == gcc || \
611 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
612 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
613 # won't set header path and -L is used to ensure the base library path
614 # is added before the port PREFIX library path.
615 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
616 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
617 # combined with --sysroot.
618 XCFLAGS+= -B${WORLDTMP}/usr/lib
619 # Force using libc++ for external GCC.
620 # XXX: This should be checking MK_GNUCXX == no
621 .if ${X_COMPILER_VERSION} >= 40800
622 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
625 .elif ${WANT_COMPILER_TYPE} == clang || \
626 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang)
628 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd12.0
629 XCFLAGS+= -target ${TARGET_TRIPLE}
631 XCFLAGS+= --sysroot=${WORLDTMP}
637 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
638 ${TARGET_ARCH} == "powerpc64" || ${TARGET_ARCH:Mmips64*} != "")
640 .include "Makefile.libcompat"
641 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH} == "armv6"
643 .include "Makefile.libcompat"
646 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
648 IMAKEENV= ${CROSSENV}
649 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
650 ${IMAKE_INSTALL} ${IMAKE_MTREE}
651 .if empty(.MAKEFLAGS:M-n)
652 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
653 LD_LIBRARY_PATH=${INSTALLTMP} \
654 PATH_LOCALE=${INSTALLTMP}/locale
655 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
657 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
659 .if defined(DB_FROM_SRC)
660 INSTALLFLAGS+= -N ${.CURDIR}/etc
661 MTREEFLAGS+= -N ${.CURDIR}/etc
663 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
664 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
666 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
667 IMAKE+= -DNO_ROOT METALOG=${METALOG}
668 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
671 .if defined(BUILD_PKGS)
672 INSTALLFLAGS+= -h sha256
674 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
675 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
676 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
680 KMAKEENV= ${WMAKEENV}
681 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
686 # Attempt to rebuild the entire system, with reasonable chance of
687 # success, regardless of how old your existing system is.
690 .if ${.CURDIR:C/[^,]//g} != ""
691 # The m4 build of sendmail files doesn't like it if ',' is used
692 # anywhere in the path of it's files.
694 @echo "*** Error: path to source tree contains a comma ','"
699 @echo "--------------------------------------------------------------"
700 @echo ">>> Rebuilding the temporary build tree"
701 @echo "--------------------------------------------------------------"
702 .if !defined(NO_CLEAN)
704 .if defined(LIBCOMPAT)
705 rm -rf ${LIBCOMPATTMP}
708 rm -rf ${WORLDTMP}/legacy/usr/include
711 lib lib/casper usr legacy/bin legacy/usr
712 mkdir -p ${WORLDTMP}/${_dir}
714 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
715 -p ${WORLDTMP}/legacy/usr >/dev/null
716 .if ${MK_GROFF} != "no"
717 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
718 -p ${WORLDTMP}/legacy/usr >/dev/null
720 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
721 -p ${WORLDTMP}/legacy/usr/include >/dev/null
722 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
723 -p ${WORLDTMP}/usr >/dev/null
724 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
725 -p ${WORLDTMP}/usr/include >/dev/null
726 ln -sf ${.CURDIR}/sys ${WORLDTMP}
727 .if ${MK_DEBUG_FILES} != "no"
728 # We could instead disable debug files for these build stages
729 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
730 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
731 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
732 -p ${WORLDTMP}/usr/lib >/dev/null
734 .if defined(LIBCOMPAT)
735 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
736 -p ${WORLDTMP}/usr >/dev/null
737 .if ${MK_DEBUG_FILES} != "no"
738 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
739 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
740 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
741 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
744 .if ${MK_TESTS} != "no"
745 mkdir -p ${WORLDTMP}${TESTSBASE}
746 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
747 -p ${WORLDTMP}${TESTSBASE} >/dev/null
748 .if ${MK_DEBUG_FILES} != "no"
749 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
750 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
751 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
754 .for _mtree in ${LOCAL_MTREE}
755 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
759 @echo "--------------------------------------------------------------"
760 @echo ">>> stage 1.1: legacy release compatibility shims"
761 @echo "--------------------------------------------------------------"
762 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
765 @echo "--------------------------------------------------------------"
766 @echo ">>> stage 1.2: bootstrap tools"
767 @echo "--------------------------------------------------------------"
768 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
770 .if !defined(NO_CLEAN)
772 @echo "--------------------------------------------------------------"
773 @echo ">>> stage 2.1: cleaning up the object tree"
774 @echo "--------------------------------------------------------------"
775 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
776 .if defined(LIBCOMPAT)
777 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
782 @echo "--------------------------------------------------------------"
783 @echo ">>> stage 2.2: rebuilding the object tree"
784 @echo "--------------------------------------------------------------"
785 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
788 @echo "--------------------------------------------------------------"
789 @echo ">>> stage 2.3: build tools"
790 @echo "--------------------------------------------------------------"
791 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
794 @echo "--------------------------------------------------------------"
795 @echo ">>> stage 3: cross tools"
796 @echo "--------------------------------------------------------------"
797 @rm -f ${.OBJDIR}/compiler-metadata.mk
798 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
799 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
802 @echo "--------------------------------------------------------------"
803 @echo ">>> stage 3.1: recording compiler metadata"
804 @echo "--------------------------------------------------------------"
805 ${_+_}cd ${.CURDIR}; ${WMAKE} compiler-metadata.mk
808 @echo "--------------------------------------------------------------"
809 @echo ">>> stage 4.1: building includes"
810 @echo "--------------------------------------------------------------"
811 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
812 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
813 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
814 MK_INCLUDES=yes includes
815 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
816 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
820 @echo "--------------------------------------------------------------"
821 @echo ">>> stage 4.2: building libraries"
822 @echo "--------------------------------------------------------------"
823 ${_+_}cd ${.CURDIR}; \
824 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
825 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
828 @echo "--------------------------------------------------------------"
829 @echo ">>> stage 4.3: building everything"
830 @echo "--------------------------------------------------------------"
831 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
834 WMAKE_TGTS+= _worldtmp _legacy
835 .if empty(SUBDIR_OVERRIDE)
836 WMAKE_TGTS+= _bootstrap-tools
838 WMAKE_TGTS+= _cleanobj
842 WMAKE_TGTS+= _build-tools _cross-tools
843 WMAKE_TGTS+= _compiler-metadata
844 WMAKE_TGTS+= _includes _libraries
845 WMAKE_TGTS+= everything
846 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
847 WMAKE_TGTS+= build${libcompat}
850 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
851 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
853 buildworld_prologue: .PHONY
854 @echo "--------------------------------------------------------------"
855 @echo ">>> World build started on `LC_ALL=C date`"
856 @echo "--------------------------------------------------------------"
858 buildworld_epilogue: .PHONY
860 @echo "--------------------------------------------------------------"
861 @echo ">>> World build completed on `LC_ALL=C date`"
862 @echo "--------------------------------------------------------------"
865 # We need to have this as a target because the indirection between Makefile
866 # and Makefile.inc1 causes the correct PATH to be used, rather than a
867 # modification of the current environment's PATH. In addition, we need
868 # to quote multiword values.
871 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
873 .if ${.TARGETS:Mbuildenv}
874 .if ${.MAKEFLAGS:M-j}
875 .error The buildenv target is incompatible with -j
878 BUILDENV_DIR?= ${.CURDIR}
880 @echo Entering world for ${TARGET_ARCH}:${TARGET}
881 .if ${BUILDENV_SHELL:M*zsh*}
882 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
884 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
887 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
888 toolchain: ${TOOLCHAIN_TGTS} .PHONY
889 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries} .PHONY
894 # Checks to be sure system is ready for installworld/installkernel.
896 installcheck: _installcheck_world _installcheck_kernel .PHONY
897 _installcheck_world: .PHONY
898 _installcheck_kernel: .PHONY
901 # Require DESTDIR to be set if installing for a different architecture or
902 # using the user/group database in the source tree.
904 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
906 .if !make(distributeworld)
907 _installcheck_world: __installcheck_DESTDIR
908 _installcheck_kernel: __installcheck_DESTDIR
909 __installcheck_DESTDIR: .PHONY
910 .if !defined(DESTDIR) || empty(DESTDIR)
911 @echo "ERROR: Please set DESTDIR!"; \
917 .if !defined(DB_FROM_SRC)
919 # Check for missing UIDs/GIDs.
921 CHECK_UIDS= auditdistd
923 .if ${MK_SENDMAIL} != "no"
929 CHECK_GIDS+= proxy authpf
931 .if ${MK_UNBOUND} != "no"
935 _installcheck_world: __installcheck_UGID
936 __installcheck_UGID: .PHONY
937 .for uid in ${CHECK_UIDS}
938 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
939 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
943 .for gid in ${CHECK_GIDS}
944 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
945 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
952 # Required install tools to be saved in a scratch dir for safety.
954 .if ${MK_ZONEINFO} != "no"
955 _zoneinfo= zic tzsetup
958 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
959 date echo egrep find grep id install ${_install-info} \
960 ln make mkdir mtree mv pwd_mkdb \
961 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
964 # Needed for share/man
965 .if ${MK_MAN_UTILS} != "no"
972 # Distributes everything compiled by a `buildworld'.
976 # Installs everything compiled by a 'buildworld'.
979 # Non-base distributions produced by the base system
980 EXTRA_DISTRIBUTIONS= doc
981 .if defined(LIBCOMPAT)
982 EXTRA_DISTRIBUTIONS+= lib${libcompat}
984 .if ${MK_TESTS} != "no"
985 EXTRA_DISTRIBUTIONS+= tests
989 .if ${MK_DEBUG_FILES} != "no"
990 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
993 MTREE_MAGIC?= mtree 2.0
995 distributeworld installworld stageworld: _installcheck_world .PHONY
996 mkdir -p ${INSTALLTMP}
997 progs=$$(for prog in ${ITOOLS}; do \
998 if progpath=`which $$prog`; then \
1001 echo "Required tool $$prog not found in PATH." >&2; \
1005 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
1006 while read line; do \
1008 if [ "$$2 $$3" != "not found" ]; then \
1011 echo "Required library $$1 not found." >&2; \
1015 cp $$libs $$progs ${INSTALLTMP}
1016 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
1017 .if defined(NO_ROOT)
1018 -mkdir -p ${METALOG:H}
1019 echo "#${MTREE_MAGIC}" > ${METALOG}
1021 .if make(distributeworld)
1022 .for dist in ${EXTRA_DISTRIBUTIONS}
1023 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
1024 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1025 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
1026 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1027 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1028 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1029 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
1030 .if ${MK_DEBUG_FILES} != "no"
1031 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1032 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
1034 .if defined(LIBCOMPAT)
1035 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1036 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1037 .if ${MK_DEBUG_FILES} != "no"
1038 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1039 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
1042 .if ${MK_TESTS} != "no" && ${dist} == "tests"
1043 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
1044 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1045 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
1046 .if ${MK_DEBUG_FILES} != "no"
1047 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1048 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
1051 .if defined(NO_ROOT)
1052 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1053 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1054 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1055 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1056 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1057 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1058 .if defined(LIBCOMPAT)
1059 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
1060 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1064 -mkdir ${DESTDIR}/${DISTDIR}/base
1065 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1066 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1067 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1068 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1070 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1071 ${IMAKEENV} rm -rf ${INSTALLTMP}
1072 .if make(distributeworld)
1073 .for dist in ${EXTRA_DISTRIBUTIONS}
1074 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete
1076 .if defined(NO_ROOT)
1077 .for dist in base ${EXTRA_DISTRIBUTIONS}
1078 @# For each file that exists in this dist, print the corresponding
1079 @# line from the METALOG. This relies on the fact that
1080 @# a line containing only the filename will sort immediately before
1081 @# the relevant mtree line.
1082 cd ${DESTDIR}/${DISTDIR}; \
1083 find ./${dist} | sort -u ${METALOG} - | \
1084 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1085 ${DESTDIR}/${DISTDIR}/${dist}.meta
1087 .for dist in ${DEBUG_DISTRIBUTIONS}
1088 @# For each file that exists in this dist, print the corresponding
1089 @# line from the METALOG. This relies on the fact that
1090 @# a line containing only the filename will sort immediately before
1091 @# the relevant mtree line.
1092 cd ${DESTDIR}/${DISTDIR}; \
1093 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1094 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1095 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1100 packageworld: .PHONY
1101 .for dist in base ${EXTRA_DISTRIBUTIONS}
1102 .if defined(NO_ROOT)
1103 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1104 tar cvf - --exclude usr/lib/debug \
1105 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1106 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1108 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1109 tar cvf - --exclude usr/lib/debug . | \
1110 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1114 .for dist in ${DEBUG_DISTRIBUTIONS}
1115 . if defined(NO_ROOT)
1116 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1117 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1118 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1120 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1121 tar cvLf - usr/lib/debug | \
1122 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1129 # If you have a build server, you can NFS mount the source and obj directories
1130 # and do a 'make reinstall' on the *client* to install new binaries from the
1131 # most recent server build.
1133 restage reinstall: .MAKE .PHONY
1134 @echo "--------------------------------------------------------------"
1135 @echo ">>> Making hierarchy"
1136 @echo "--------------------------------------------------------------"
1137 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1138 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1140 @echo "--------------------------------------------------------------"
1141 @echo ">>> Making distribution"
1142 @echo "--------------------------------------------------------------"
1143 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1144 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
1147 @echo "--------------------------------------------------------------"
1148 @echo ">>> Installing everything"
1149 @echo "--------------------------------------------------------------"
1150 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1151 .if defined(LIBCOMPAT)
1152 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1155 redistribute: .MAKE .PHONY
1156 @echo "--------------------------------------------------------------"
1157 @echo ">>> Distributing everything"
1158 @echo "--------------------------------------------------------------"
1159 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1160 .if defined(LIBCOMPAT)
1161 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1162 DISTRIBUTION=lib${libcompat}
1165 distrib-dirs distribution: .MAKE .PHONY
1166 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1167 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1168 .if make(distribution)
1169 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1170 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1171 METALOG=${METALOG} MK_TESTS=no installconfig
1175 # buildkernel and installkernel
1177 # Which kernels to build and/or install is specified by setting
1178 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1179 # Only the existing (depending TARGET) config files are used
1180 # for building kernels and only the first of these is designated
1181 # as the one being installed.
1183 # Note that we have to use TARGET instead of TARGET_ARCH when
1184 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1185 # be set to cross-build, we have to make sure TARGET is set
1188 .if defined(KERNFAST)
1192 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1193 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1194 KERNCONF=${KERNFAST}
1197 .if ${TARGET_ARCH} == "powerpc64"
1198 KERNCONF?= GENERIC64
1202 INSTKERNNAME?= kernel
1204 KERNSRCDIR?= ${.CURDIR}/sys
1205 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1206 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1207 KERNCONFDIR?= ${KRNLCONFDIR}
1211 .if defined(NO_INSTALLKERNEL)
1212 # All of the BUILDKERNELS loops start at index 1.
1213 BUILDKERNELS+= dummy
1215 .for _kernel in ${KERNCONF}
1216 .if exists(${KERNCONFDIR}/${_kernel})
1217 BUILDKERNELS+= ${_kernel}
1218 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1219 INSTALLKERNEL= ${_kernel}
1224 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1229 # Builds all kernels defined by BUILDKERNELS.
1231 buildkernel: .MAKE .PHONY
1232 .if empty(BUILDKERNELS:Ndummy)
1233 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1237 .for _kernel in ${BUILDKERNELS:Ndummy}
1238 @echo "--------------------------------------------------------------"
1239 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1240 @echo "--------------------------------------------------------------"
1241 @echo "===> ${_kernel}"
1242 mkdir -p ${KRNLOBJDIR}
1243 .if !defined(NO_KERNELCONFIG)
1245 @echo "--------------------------------------------------------------"
1246 @echo ">>> stage 1: configuring the kernel"
1247 @echo "--------------------------------------------------------------"
1248 cd ${KRNLCONFDIR}; \
1250 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1251 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1253 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1255 @echo "--------------------------------------------------------------"
1256 @echo ">>> stage 2.1: cleaning up the object tree"
1257 @echo "--------------------------------------------------------------"
1258 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1260 .if !defined(NO_KERNELOBJ)
1262 @echo "--------------------------------------------------------------"
1263 @echo ">>> stage 2.2: rebuilding the object tree"
1264 @echo "--------------------------------------------------------------"
1265 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1268 @echo "--------------------------------------------------------------"
1269 @echo ">>> stage 2.3: build tools"
1270 @echo "--------------------------------------------------------------"
1271 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1273 @echo "--------------------------------------------------------------"
1274 @echo ">>> stage 3.1: building everything"
1275 @echo "--------------------------------------------------------------"
1276 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1277 @echo "--------------------------------------------------------------"
1278 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1279 @echo "--------------------------------------------------------------"
1282 NO_INSTALLEXTRAKERNELS?= yes
1285 # installkernel, etc.
1287 # Install the kernel defined by INSTALLKERNEL
1289 installkernel installkernel.debug \
1290 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1291 .if !defined(NO_INSTALLKERNEL)
1292 .if empty(INSTALLKERNEL)
1293 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1296 @echo "--------------------------------------------------------------"
1297 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1298 @echo "--------------------------------------------------------------"
1299 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1300 ${CROSSENV} PATH=${TMPPATH} \
1301 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1303 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1304 .for _kernel in ${BUILDKERNELS:[2..-1]}
1305 @echo "--------------------------------------------------------------"
1306 @echo ">>> Installing kernel ${_kernel}"
1307 @echo "--------------------------------------------------------------"
1308 cd ${KRNLOBJDIR}/${_kernel}; \
1309 ${CROSSENV} PATH=${TMPPATH} \
1310 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1314 distributekernel distributekernel.debug: .PHONY
1315 .if !defined(NO_INSTALLKERNEL)
1316 .if empty(INSTALLKERNEL)
1317 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1320 mkdir -p ${DESTDIR}/${DISTDIR}
1321 .if defined(NO_ROOT)
1322 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1324 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1325 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1326 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1327 DESTDIR=${INSTALL_DDIR}/kernel \
1328 ${.TARGET:S/distributekernel/install/}
1329 .if defined(NO_ROOT)
1330 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1331 ${DESTDIR}/${DISTDIR}/kernel.meta
1334 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1335 .for _kernel in ${BUILDKERNELS:[2..-1]}
1336 .if defined(NO_ROOT)
1337 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1339 cd ${KRNLOBJDIR}/${_kernel}; \
1340 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1341 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1342 KERNEL=${INSTKERNNAME}.${_kernel} \
1343 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1344 ${.TARGET:S/distributekernel/install/}
1345 .if defined(NO_ROOT)
1346 @sed -e "s|^./kernel.${_kernel}|.|" \
1347 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1348 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1353 packagekernel: .PHONY
1354 .if defined(NO_ROOT)
1355 .if !defined(NO_INSTALLKERNEL)
1356 cd ${DESTDIR}/${DISTDIR}/kernel; \
1357 tar cvf - --exclude '*.debug' \
1358 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1359 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1361 cd ${DESTDIR}/${DISTDIR}/kernel; \
1362 tar cvf - --include '*/*/*.debug' \
1363 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1364 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1365 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1366 .for _kernel in ${BUILDKERNELS:[2..-1]}
1367 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1368 tar cvf - --exclude '*.debug' \
1369 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1370 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1371 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1372 tar cvf - --include '*/*/*.debug' \
1373 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1374 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1378 .if !defined(NO_INSTALLKERNEL)
1379 cd ${DESTDIR}/${DISTDIR}/kernel; \
1380 tar cvf - --exclude '*.debug' . | \
1381 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1383 cd ${DESTDIR}/${DISTDIR}/kernel; \
1384 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1385 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1386 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1387 .for _kernel in ${BUILDKERNELS:[2..-1]}
1388 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1389 tar cvf - --exclude '*.debug' . | \
1390 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1391 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1392 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1393 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1399 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1401 PORTSDIR?= /usr/ports
1402 WSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/worldstage
1403 KSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/kernelstage
1404 REPODIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/repo
1405 PKGSIGNKEY?= # empty
1407 .ORDER: stage-packages create-packages
1408 .ORDER: create-packages create-world-packages
1409 .ORDER: create-packages create-kernel-packages
1410 .ORDER: create-packages sign-packages
1412 _pkgbootstrap: .PHONY
1413 .if !exists(${LOCALBASE}/sbin/pkg)
1414 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1418 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1421 rm -rf /tmp/ports.${TARGET} || :
1422 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
1423 PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \
1424 WSTAGEDIR=${WSTAGEDIR} \
1425 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1427 real-packages: stage-packages create-packages sign-packages .PHONY
1429 stage-packages: .PHONY
1430 @mkdir -p ${REPODIR} ${WSTAGEDIR} ${KSTAGEDIR}
1431 ${_+_}@cd ${.CURDIR}; \
1432 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT -B stageworld ; \
1433 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT -B stagekernel
1435 create-packages: _pkgbootstrap .PHONY
1436 @mkdir -p ${REPODIR}
1437 ${_+_}@cd ${.CURDIR}; \
1438 ${MAKE} DESTDIR=${WSTAGEDIR} \
1439 PKG_VERSION=${PKG_VERSION} create-world-packages ; \
1440 ${MAKE} DESTDIR=${KSTAGEDIR} \
1441 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1442 create-kernel-packages
1444 create-world-packages: _pkgbootstrap .PHONY
1445 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1446 @cd ${WSTAGEDIR} ; \
1447 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1448 ${WSTAGEDIR}/METALOG
1449 @for plist in ${WSTAGEDIR}/*.plist; do \
1450 plist=$${plist##*/} ; \
1451 pkgname=$${plist%.plist} ; \
1452 sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \
1453 -s ${SRCDIR} -u ${WSTAGEDIR}/$${pkgname}.ucl ; \
1455 @for plist in ${WSTAGEDIR}/*.plist; do \
1456 plist=$${plist##*/} ; \
1457 pkgname=$${plist%.plist} ; \
1459 /^name/ { printf("===> Creating %s-", $$2); next } \
1460 /^version/ { print $$2; next } \
1461 ' ${WSTAGEDIR}/$${pkgname}.ucl ; \
1462 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1463 create -M ${WSTAGEDIR}/$${pkgname}.ucl \
1464 -p ${WSTAGEDIR}/$${pkgname}.plist \
1466 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} ; \
1469 create-kernel-packages: _pkgbootstrap .PHONY
1470 .if exists(${KSTAGEDIR}/kernel.meta)
1471 .for flavor in "" -debug
1472 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1473 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1474 -v kernel=yes -v _kernconf=${INSTALLKERNEL} \
1475 ${KSTAGEDIR}/kernel.meta ; \
1476 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1477 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1478 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1479 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1480 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1481 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1482 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1483 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1484 ${SRCDIR}/release/packages/kernel.ucl \
1485 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1487 /name/ { printf("===> Creating %s-", $$2); next } \
1488 /version/ {print $$2; next } ' \
1489 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1490 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1491 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1492 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1493 -r ${KSTAGEDIR}/${DISTDIR} \
1494 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1497 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1498 .for _kernel in ${BUILDKERNELS:[2..-1]}
1499 .if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1500 .for flavor in "" -debug
1501 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1502 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1503 -v kernel=yes -v _kernconf=${_kernel} \
1504 ${KSTAGEDIR}/kernel.${_kernel}.meta ; \
1505 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1506 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1507 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1508 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1509 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1510 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1511 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1512 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1513 ${SRCDIR}/release/packages/kernel.ucl \
1514 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1516 /name/ { printf("===> Creating %s-", $$2); next } \
1517 /version/ {print $$2; next } ' \
1518 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1519 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1520 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1521 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1522 -r ${KSTAGEDIR}/kernel.${_kernel} \
1523 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1529 sign-packages: _pkgbootstrap .PHONY
1530 @[ -L "${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1531 unlink ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1532 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1533 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1534 ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1536 cd ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI); \
1537 ln -s ${PKG_VERSION} latest
1543 # Run test suite on installed world.
1546 @if [ ! -x "${LOCALBASE}/bin/kyua" ]; then \
1547 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1550 ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile
1556 # Build the API documentation with doxygen
1559 @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \
1560 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1563 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1568 # Update the source tree(s), by running svn/svnup to update to the
1572 .if defined(SVN_UPDATE)
1573 @echo "--------------------------------------------------------------"
1574 @echo ">>> Updating ${.CURDIR} using Subversion"
1575 @echo "--------------------------------------------------------------"
1576 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1580 # ------------------------------------------------------------------------
1582 # From here onwards are utility targets used by the 'make world' and
1583 # related targets. If your 'world' breaks, you may like to try to fix
1584 # the problem and manually run the following targets to attempt to
1585 # complete the build. Beware, this is *not* guaranteed to work, you
1586 # need to have a pretty good grip on the current state of the system
1587 # to attempt to manually finish it. If in doubt, 'make world' again.
1591 # legacy: Build compatibility shims for the next three targets. This is a
1592 # minimal set of tools and shims necessary to compensate for older systems
1593 # which don't have the APIs required by the targets built in bootstrap-tools,
1594 # build-tools or cross-tools.
1597 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1598 # r296685 fix cross-endian objcopy
1599 .if ${BOOTSTRAPPING} < 1100102
1600 _elftoolchain_libs= lib/libelf lib/libdwarf
1604 # Temporary special case for automatically detecting the clang compiler issue
1605 # Note: 9.x didn't have FreeBSD_version bumps often enough, so you may need to
1606 # set BOOTSTRAPPING to 0 if you're stable/9 tree post-dates r286035 but is before
1607 # the version bump in r296219 (from July 29, 2015 -> Feb 29, 2016).
1608 .if ${BOOTSTRAPPING} != 0 && \
1609 ${WANT_COMPILER_TYPE} == "clang" && ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} < 30601
1610 .if ${BOOTSTRAPPING} > 10000000 && ${BOOTSTRAPPING} < 1002501
1611 @echo "ERROR: Source upgrades from stable/10 prior to r286033 are not supported."; false
1612 .elif ${BOOTSTRAPPING} > 9000000 && ${BOOTSTRAPPING} < 903509
1613 @echo "ERROR: Source upgrades from stable/9 prior to r286035 are not supported."; false
1616 .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
1617 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
1621 .for _tool in tools/build ${_elftoolchain_libs}
1622 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1623 cd ${.CURDIR}/${_tool}; \
1624 if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
1625 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1626 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
1627 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
1628 DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1632 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1633 # are built to build other binaries in the system. However, the focus of these
1634 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1635 # libraries, augmented by -legacy.
1637 _bt= _bootstrap-tools
1639 .if ${MK_GAMES} != "no"
1640 _strfile= usr.bin/fortune/strfile
1643 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1644 _gperf= gnu/usr.bin/gperf
1647 .if ${MK_SHAREDOCS} != "no" && ${MK_GROFF} != "no"
1648 _groff= gnu/usr.bin/groff \
1652 .if ${MK_VT} != "no"
1653 _vtfontcvt= usr.bin/vtfontcvt
1656 .if ${BOOTSTRAPPING} < 1000033
1657 _libopenbsd= lib/libopenbsd
1661 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1662 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1665 # r245440 mtree -N support added
1666 # r313404 requires sha384.h for libnetbsd, added to libmd in r292782
1667 .if ${BOOTSTRAPPING} < 1100093
1668 _nmtree= lib/libmd \
1672 ${_bt}-lib/libnetbsd: ${_bt}-lib/libmd
1673 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1676 # r246097: log addition login.conf.db, passwd, pwd.db, and spwd.db with cat -l
1677 .if ${BOOTSTRAPPING} < 1000027
1681 # r277259 crunchide: Correct 64-bit section header offset
1682 # r281674 crunchide: always include both 32- and 64-bit ELF support
1683 .if ${BOOTSTRAPPING} < 1100078
1684 _crunchide= usr.sbin/crunch/crunchide
1687 # r285986 crunchen: use STRIPBIN rather than STRIP
1688 # 1100113: Support MK_AUTO_OBJ
1689 # 1200006: META_MODE fixes
1690 .if ${BOOTSTRAPPING} < 1100078 || \
1691 (${MK_AUTO_OBJ} == "yes" && ${BOOTSTRAPPING} < 1100114) || \
1692 (${MK_META_MODE} == "yes" && ${BOOTSTRAPPING} < 1200006)
1693 _crunchgen= usr.sbin/crunch/crunchgen
1696 # r296926 -P keymap search path, MFC to stable/10 in r298297
1697 .if ${BOOTSTRAPPING} < 1003501 || \
1698 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
1699 _kbdcontrol= usr.sbin/kbdcontrol
1705 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1707 .if ${MK_BSNMP} != "no"
1708 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1711 # We need to build tblgen when we're building clang or lld, either as
1712 # bootstrap tools, or as the part of the normal build.
1713 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
1714 ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no"
1716 lib/clang/libllvmminimal \
1717 usr.bin/clang/llvm-tblgen \
1718 usr.bin/clang/clang-tblgen
1720 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal
1721 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal
1724 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1727 .if ${MK_GPL_DTC} != "no"
1728 _dtc= gnu/usr.bin/dtc
1731 .if ${MK_KERBEROS} != "no"
1732 _kerberos5_bootstrap_tools= \
1733 kerberos5/tools/make-roken \
1734 kerberos5/lib/libroken \
1735 kerberos5/lib/libvers \
1736 kerberos5/tools/asn1_compile \
1737 kerberos5/tools/slc \
1740 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1743 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
1744 _libopenbsd?= lib/libopenbsd
1745 _makewhatis= usr.bin/mandoc
1746 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
1748 bootstrap-tools: .PHONY
1750 # Please document (add comment) why something is in 'bootstrap-tools'.
1751 # Try to bound the building of the bootstrap-tool to just the
1752 # FreeBSD versions that need the tool built at this stage of the build.
1755 ${_kerberos5_bootstrap_tools} \
1777 ${_bt}-${_tool}: .PHONY .MAKE
1778 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1779 cd ${.CURDIR}/${_tool}; \
1780 if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
1781 ${MAKE} DIRPRFX=${_tool}/ all; \
1782 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1784 bootstrap-tools: ${_bt}-${_tool}
1788 # build-tools: Build special purpose build tools
1790 .if !defined(NO_SHARE)
1791 _share= share/syscons/scrnmaps
1794 .if ${MK_GCC} != "no"
1795 _gcc_tools= gnu/usr.bin/cc/cc_tools
1798 .if ${MK_RESCUE} != "no"
1799 # rescue includes programs that have build-tools targets
1800 _rescue=rescue/rescue
1806 ${LOCAL_TOOL_DIRS} \
1807 lib/ncurses/ncurses \
1808 lib/ncurses/ncursesw \
1813 usr.bin/mkesdb_static \
1814 usr.bin/mkcsmapper_static \
1816 build-tools_${_tool}: .PHONY
1817 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1818 cd ${.CURDIR}/${_tool}; \
1819 if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
1820 ${MAKE} DIRPRFX=${_tool}/ build-tools
1821 build-tools: build-tools_${_tool}
1825 build-tools_${_tool}: .PHONY
1826 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \
1827 cd ${.CURDIR}/${_tool}; \
1828 if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
1829 ${MAKE} DIRPRFX=${_tool}/ all
1830 build-tools: build-tools_${_tool}
1834 # kernel-tools: Build kernel-building tools
1836 kernel-tools: .PHONY
1837 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1838 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1839 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1842 # cross-tools: All the tools needed to build the rest of the system after
1843 # we get done with the earlier stages. It is the last set of tools needed
1844 # to begin building the target binaries.
1846 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1847 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1848 _btxld= usr.sbin/btxld
1852 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1853 # resulting from missing bug fixes or ELF Toolchain updates.
1854 .if ${MK_CDDL} != "no"
1855 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1856 cddl/usr.bin/ctfmerge
1859 # If we're given an XAS, don't build binutils.
1860 .if ${XAS:M/*} == ""
1861 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1862 _binutils= gnu/usr.bin/binutils
1864 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1865 _elftctools= lib/libelftc \
1871 # These are not required by the build, but can be useful for developers who
1872 # cross-build on a FreeBSD 10 host:
1873 _elftctools+= usr.bin/addr2line
1875 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1876 # If cross-building with an external binutils we still need to build strip for
1877 # the target (for at least crunchide).
1878 _elftctools= lib/libelftc \
1883 .if ${MK_CLANG_BOOTSTRAP} != "no"
1884 _clang= usr.bin/clang
1886 .if ${MK_LLD_BOOTSTRAP} != "no"
1887 _lld= usr.bin/clang/lld
1889 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no"
1890 _clang_libs= lib/clang
1892 .if ${MK_GCC_BOOTSTRAP} != "no"
1893 _gcc= gnu/usr.bin/cc
1895 .if ${MK_USB} != "no"
1896 _usb_tools= sys/boot/usb/tools
1899 cross-tools: .MAKE .PHONY
1901 ${LOCAL_XTOOL_DIRS} \
1911 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1912 cd ${.CURDIR}/${_tool}; \
1913 if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
1914 ${MAKE} DIRPRFX=${_tool}/ all; \
1915 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1918 NXBDESTDIR= ${OBJTREE}/nxb-bin
1919 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1921 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1922 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1923 NXBMAKE= ${NXBENV} ${MAKE} \
1924 LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \
1925 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1926 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1927 MK_GDB=no MK_TESTS=no \
1929 MK_HTML=no NO_LINT=yes MK_MAN=no \
1930 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1931 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1932 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1933 MK_LLDB=no MK_DEBUG_FILES=no
1935 # native-xtools is the current target for qemu-user cross builds of ports
1936 # via poudriere and the imgact_binmisc kernel module.
1937 # For non-clang enabled targets that are still using the in tree gcc
1938 # we must build a gperf binary for one instance of its Makefiles. On
1939 # clang-enabled systems, the gperf binary is obsolete.
1940 native-xtools: .PHONY
1941 .if ${MK_GCC_BOOTSTRAP} != "no"
1942 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1943 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \
1944 cd ${.CURDIR}/${_gperf}; \
1945 if [ -z "${NO_OBJ}" ]; then ${NXBMAKE} DIRPRFX=${_gperf}/ obj; fi; \
1946 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1947 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1949 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1950 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1951 -p ${NXBDESTDIR}/usr >/dev/null
1952 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1953 -p ${NXBDESTDIR}/usr/include >/dev/null
1954 .if ${MK_DEBUG_FILES} != "no"
1955 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1956 -p ${NXBDESTDIR}/usr/lib >/dev/null
2019 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2020 cd ${.CURDIR}/${_tool}; \
2021 if [ -z "${NO_OBJ}" ]; then ${NXBMAKE} DIRPRFX=${_tool}/ obj; fi; \
2022 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
2023 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
2027 # hierarchy - ensure that all the needed directories are present
2029 hierarchy hier: .MAKE .PHONY
2030 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
2033 # libraries - build all libraries, and install them under ${DESTDIR}.
2035 # The list of libraries with dependents (${_prebuild_libs}) and their
2036 # interdependencies (__L) are built automatically by the
2037 # ${.CURDIR}/tools/make_libdeps.sh script.
2039 libraries: .MAKE .PHONY
2040 ${_+_}cd ${.CURDIR}; \
2041 ${MAKE} -f Makefile.inc1 _prereq_libs; \
2042 ${MAKE} -f Makefile.inc1 _startup_libs; \
2043 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
2044 ${MAKE} -f Makefile.inc1 _generic_libs
2047 # static libgcc.a prerequisite for shared libc
2049 _prereq_libs= lib/libcompiler_rt
2050 .if ${MK_SSP} != "no"
2051 _prereq_libs+= gnu/lib/libssp/libssp_nonshared
2054 # These dependencies are not automatically generated:
2056 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
2057 # all shared libraries for ELF.
2059 _startup_libs= gnu/lib/csu
2060 _startup_libs+= lib/csu
2061 _startup_libs+= lib/libcompiler_rt
2062 _startup_libs+= lib/libc
2063 _startup_libs+= lib/libc_nonshared
2064 .if ${MK_LIBCPLUSPLUS} != "no"
2065 _startup_libs+= lib/libcxxrt
2068 .if ${MK_LLVM_LIBUNWIND} != "no"
2069 _prereq_libs+= lib/libgcc_eh lib/libgcc_s
2070 _startup_libs+= lib/libgcc_eh lib/libgcc_s
2072 lib/libgcc_s__L: lib/libc__L
2073 lib/libgcc_s__L: lib/libc_nonshared__L
2074 .if ${MK_LIBCPLUSPLUS} != "no"
2075 lib/libcxxrt__L: lib/libgcc_s__L
2078 .else # MK_LLVM_LIBUNWIND == no
2080 _prereq_libs+= gnu/lib/libgcc
2081 _startup_libs+= gnu/lib/libgcc
2083 gnu/lib/libgcc__L: lib/libc__L
2084 gnu/lib/libgcc__L: lib/libc_nonshared__L
2085 .if ${MK_LIBCPLUSPLUS} != "no"
2086 lib/libcxxrt__L: gnu/lib/libgcc__L
2090 _prebuild_libs= ${_kerberos5_lib_libasn1} \
2091 ${_kerberos5_lib_libhdb} \
2092 ${_kerberos5_lib_libheimbase} \
2093 ${_kerberos5_lib_libheimntlm} \
2095 ${_kerberos5_lib_libheimipcc} \
2096 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
2097 ${_kerberos5_lib_libroken} \
2098 ${_kerberos5_lib_libwind} \
2099 lib/libbz2 ${_libcom_err} lib/libcrypt \
2100 lib/libelf lib/libexpat \
2103 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
2105 lib/ncurses/ncurses lib/ncurses/ncursesw \
2106 lib/libopie lib/libpam/libpam ${_lib_libthr} \
2107 ${_lib_libradius} lib/libsbuf lib/libtacplus \
2109 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
2110 ${_cddl_lib_libuutil} \
2111 ${_cddl_lib_libavl} \
2112 ${_cddl_lib_libzfs_core} \
2113 ${_cddl_lib_libctf} \
2114 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
2115 ${_secure_lib_libcrypto} ${_lib_libldns} \
2116 ${_secure_lib_libssh} ${_secure_lib_libssl}
2118 .if ${MK_GNUCXX} != "no"
2119 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
2120 gnu/lib/libstdc++__L: lib/msun__L
2121 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
2124 .if ${MK_DIALOG} != "no"
2125 _prebuild_libs+= gnu/lib/libdialog
2126 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2129 .if ${MK_LIBCPLUSPLUS} != "no"
2130 _prebuild_libs+= lib/libc++
2133 lib/libgeom__L: lib/libexpat__L
2134 lib/libkvm__L: lib/libelf__L
2136 .if ${MK_LIBTHR} != "no"
2137 _lib_libthr= lib/libthr
2140 .if ${MK_RADIUS_SUPPORT} != "no"
2141 _lib_libradius= lib/libradius
2144 .if ${MK_OFED} != "no"
2145 _ofed_lib= contrib/ofed/usr.lib
2146 _prebuild_libs+= contrib/ofed/usr.lib/libosmcomp
2147 _prebuild_libs+= contrib/ofed/usr.lib/libopensm
2148 _prebuild_libs+= contrib/ofed/usr.lib/libibcommon
2149 _prebuild_libs+= contrib/ofed/usr.lib/libibverbs
2150 _prebuild_libs+= contrib/ofed/usr.lib/libibumad
2152 contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
2153 contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
2154 contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
2157 .if ${MK_CASPER} != "no"
2158 _lib_casper= lib/libcasper
2161 lib/libpjdlog__L: lib/libutil__L
2162 lib/libcasper__L: lib/libnv__L
2163 lib/liblzma__L: lib/libthr__L
2165 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
2166 .for _DIR in ${LOCAL_LIB_DIRS}
2167 .if exists(${.CURDIR}/${_DIR}/Makefile) && empty(_generic_libs:M${_DIR})
2168 _generic_libs+= ${_DIR}
2172 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2174 .if ${MK_CDDL} != "no"
2175 _cddl_lib_libumem= cddl/lib/libumem
2176 _cddl_lib_libnvpair= cddl/lib/libnvpair
2177 _cddl_lib_libavl= cddl/lib/libavl
2178 _cddl_lib_libuutil= cddl/lib/libuutil
2179 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2180 _cddl_lib_libctf= cddl/lib/libctf
2182 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2183 cddl/lib/libzfs__L: lib/libgeom__L
2184 cddl/lib/libctf__L: lib/libz__L
2186 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
2187 # on select architectures though (see cddl/lib/Makefile)
2188 .if ${MACHINE_CPUARCH} != "sparc64"
2189 _prebuild_libs+= lib/libprocstat lib/libproc lib/librtld_db
2190 lib/libprocstat__L: lib/libelf__L lib/libkvm__L lib/libutil__L
2191 lib/libproc__L: lib/libprocstat__L
2192 lib/librtld_db__L: lib/libprocstat__L
2195 .if ${MK_CRYPT} != "no"
2196 .if ${MK_OPENSSL} != "no"
2197 _secure_lib_libcrypto= secure/lib/libcrypto
2198 _secure_lib_libssl= secure/lib/libssl
2199 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2200 .if ${MK_LDNS} != "no"
2201 _lib_libldns= lib/libldns
2202 lib/libldns__L: secure/lib/libcrypto__L
2204 .if ${MK_OPENSSH} != "no"
2205 _secure_lib_libssh= secure/lib/libssh
2206 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2207 .if ${MK_LDNS} != "no"
2208 secure/lib/libssh__L: lib/libldns__L
2210 .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no"
2211 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2212 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2213 lib/libmd__L kerberos5/lib/libroken__L
2217 _secure_lib= secure/lib
2220 .if ${MK_KERBEROS} != "no"
2221 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2222 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2223 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2224 kerberos5/lib/libwind__L lib/libsqlite3__L
2225 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2226 kerberos5/lib/libroken__L lib/libcom_err__L
2227 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2228 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2229 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2230 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2231 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2232 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2233 kerberos5/lib/libroken__L: lib/libcrypt__L
2234 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2235 kerberos5/lib/libheimbase__L: lib/libthr__L
2236 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2239 lib/libsqlite3__L: lib/libthr__L
2241 .if ${MK_GSSAPI} != "no"
2242 _lib_libgssapi= lib/libgssapi
2245 .if ${MK_KERBEROS} != "no"
2246 _kerberos5_lib= kerberos5/lib
2247 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2248 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2249 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2250 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2251 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2252 _kerberos5_lib_libroken= kerberos5/lib/libroken
2253 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2254 _libsqlite3= lib/libsqlite3
2255 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2256 _kerberos5_lib_libwind= kerberos5/lib/libwind
2257 _libcom_err= lib/libcom_err
2260 .if ${MK_NIS} != "no"
2261 _lib_libypclnt= lib/libypclnt
2264 .if ${MK_OPENSSL} == "no"
2265 lib/libradius__L: lib/libmd__L
2269 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2270 .if ${MK_CXX} != "no"
2271 .if ${MK_LIBCPLUSPLUS} != "no"
2272 lib/libproc__L: lib/libcxxrt__L
2273 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2274 lib/libproc__L: gnu/lib/libsupc++__L
2278 .for _lib in ${_prereq_libs}
2279 ${_lib}__PL: .PHONY .MAKE
2280 .if exists(${.CURDIR}/${_lib})
2281 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2282 cd ${.CURDIR}/${_lib}; \
2283 if [ -z "${NO_OBJ}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
2284 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2285 DIRPRFX=${_lib}/ all; \
2286 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2287 DIRPRFX=${_lib}/ install
2291 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
2292 ${_lib}__L: .PHONY .MAKE
2293 .if exists(${.CURDIR}/${_lib})
2294 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2295 cd ${.CURDIR}/${_lib}; \
2296 if [ -z "${NO_OBJ}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
2297 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2298 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2302 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2303 _startup_libs: ${_startup_libs:S/$/__L/}
2304 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2305 _generic_libs: ${_generic_libs:S/$/__L/}
2307 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2308 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2309 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2310 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2311 # parallel. This is safe for the world stage of buildworld though since it has
2312 # already built libraries in a proper order and installed includes into
2313 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2314 # avoid trashing a system if it crashes mid-install.
2315 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2319 .include <bsd.subdir.mk>
2321 .if make(check-old) || make(check-old-dirs) || \
2322 make(check-old-files) || make(check-old-libs) || \
2323 make(delete-old) || make(delete-old-dirs) || \
2324 make(delete-old-files) || make(delete-old-libs)
2327 # check for / delete old files section
2330 .include "ObsoleteFiles.inc"
2332 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2333 else you can not start such an application. Consult UPDATING for more \
2334 information regarding how to cope with the removal/revision bump of a \
2337 .if !defined(BATCH_DELETE_OLD_FILES)
2343 delete-old-files: .PHONY
2344 @echo ">>> Removing old files (only deletes safe to delete libs)"
2345 # Ask for every old file if the user really wants to remove it.
2346 # It's annoying, but better safe than sorry.
2347 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2348 # argument list will get too long. Using .for/.endfor make "loops" will make
2349 # the Makefile parser segfault.
2352 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2353 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2354 while read file; do \
2355 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2356 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2357 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2359 for ext in debug symbols; do \
2360 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2361 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2362 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2367 # Remove catpages without corresponding manpages.
2369 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2370 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2371 while read catpage; do \
2373 if [ ! -e "$${manpage}" ]; then \
2374 rm ${RM_I} $${catpage} <&3; \
2377 @echo ">>> Old files removed"
2379 check-old-files: .PHONY
2380 @echo ">>> Checking for old files"
2382 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2383 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2384 while read file; do \
2385 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2386 echo "${DESTDIR}/$${file}"; \
2388 for ext in debug symbols; do \
2389 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2390 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2394 # Check for catpages without corresponding manpages.
2395 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2396 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2397 while read catpage; do \
2399 if [ ! -e "$${manpage}" ]; then \
2404 delete-old-libs: .PHONY
2405 @echo ">>> Removing old libraries"
2406 @echo "${OLD_LIBS_MESSAGE}" | fmt
2409 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2410 -V OLD_LIBS | xargs -n1 | \
2411 while read file; do \
2412 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2413 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2414 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2416 for ext in debug symbols; do \
2417 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2418 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2419 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2424 @echo ">>> Old libraries removed"
2426 check-old-libs: .PHONY
2427 @echo ">>> Checking for old libraries"
2429 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2430 -V OLD_LIBS | xargs -n1 | \
2431 while read file; do \
2432 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2433 echo "${DESTDIR}/$${file}"; \
2435 for ext in debug symbols; do \
2436 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2437 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2442 delete-old-dirs: .PHONY
2443 @echo ">>> Removing old directories"
2445 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2446 -V OLD_DIRS | xargs -n1 | sort -r | \
2447 while read dir; do \
2448 if [ -d "${DESTDIR}/$${dir}" ]; then \
2449 rmdir -v "${DESTDIR}/$${dir}" || true; \
2450 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2451 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2453 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2454 rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \
2455 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2456 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2459 @echo ">>> Old directories removed"
2461 check-old-dirs: .PHONY
2462 @echo ">>> Checking for old directories"
2464 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2465 -V OLD_DIRS | xargs -n1 | \
2466 while read dir; do \
2467 if [ -d "${DESTDIR}/$${dir}" ]; then \
2468 echo "${DESTDIR}/$${dir}"; \
2469 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2470 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2472 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2473 echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \
2474 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2475 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2479 delete-old: delete-old-files delete-old-dirs .PHONY
2480 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2482 check-old: check-old-files check-old-libs check-old-dirs .PHONY
2483 @echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
2484 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2489 # showconfig - show build configuration.
2492 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2493 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2495 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2496 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2498 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2499 .if exists(${KERNCONFDIR}/${KERNCONF})
2500 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2501 '${KERNCONFDIR}/${KERNCONF}' ; echo
2507 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2508 DTBOUTPUTPATH= ${.CURDIR}
2512 # Build 'standalone' Device Tree Blob
2515 @PATH=${TMPPATH} MACHINE=${TARGET} \
2516 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2517 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2522 # In the following, the first 'rm' in a series will usually remove all
2523 # files and directories. If it does not, then there are probably some
2524 # files with file flags set, so this unsets them and tries the 'rm' a
2525 # second time. There are situations where this target will be cleaning
2526 # some directories via more than one method, but that duplication is
2527 # needed to correctly handle all the possible situations. Removing all
2528 # files without file flags set in the first 'rm' instance saves time,
2529 # because 'chflags' will need to operate on fewer files afterwards.
2531 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2532 # created by bsd.obj.mk, except that we don't want to .include that file
2535 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2537 .if exists(${BW_CANONICALOBJDIR}/)
2538 -rm -rf ${BW_CANONICALOBJDIR}/*
2539 -chflags -R 0 ${BW_CANONICALOBJDIR}
2540 rm -rf ${BW_CANONICALOBJDIR}/*
2542 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2543 # To be safe in this case, fall back to a 'make cleandir'
2544 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2547 .if defined(TARGET) && defined(TARGET_ARCH)
2549 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2550 XDEV_CPUTYPE?=${CPUTYPE}
2552 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2555 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2556 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2557 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2558 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2559 CPUTYPE=${XDEV_CPUTYPE}
2561 XDDIR=${TARGET_ARCH}-freebsd
2564 .error XDTP variable should be an absolute path
2567 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2568 INSTALL="sh ${.CURDIR}/tools/install.sh"
2570 TOOLS_PREFIX=${XDTP}
2572 .if ${WANT_COMPILER_TYPE} == gcc || \
2573 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
2574 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
2575 # won't set header path and -L is used to ensure the base library path
2576 # is added before the port PREFIX library path.
2577 CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib
2578 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
2579 # combined with --sysroot.
2580 CD2CFLAGS+= -B${XDDESTDIR}/usr/lib
2581 # Force using libc++ for external GCC.
2582 # XXX: This should be checking MK_GNUCXX == no
2583 .if ${X_COMPILER_VERSION} >= 40800
2584 CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \
2588 CD2CFLAGS+= --sysroot=${XDDESTDIR}/
2589 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \
2590 CPP="${CPP} ${CD2CFLAGS}" \
2591 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2593 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2594 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2595 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2596 .if ${MK_META_MODE} != "no"
2597 # Don't rebuild build-tools targets during normal build.
2598 CD2MAKE+= BUILD_TOOLS_META=.NOMETA
2600 XDDESTDIR=${DESTDIR}/${XDTP}
2602 OSREL!= uname -r | sed -e 's/[-(].*//'
2605 .ORDER: xdev-build xdev-install xdev-links
2606 xdev: xdev-build xdev-install .PHONY
2608 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2609 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
2611 _xb-worldtmp: .PHONY
2612 mkdir -p ${CDTMP}/usr
2613 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2614 -p ${CDTMP}/usr >/dev/null
2616 _xb-bootstrap-tools: .PHONY
2621 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2622 cd ${.CURDIR}/${_tool}; \
2623 if [ -z "${NO_OBJ}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
2624 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2625 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2628 _xb-build-tools: .PHONY
2629 ${_+_}@cd ${.CURDIR}; \
2630 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2632 _xb-cross-tools: .PHONY
2640 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2641 cd ${.CURDIR}/${_tool}; \
2642 if [ -z "${NO_OBJ}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
2643 ${CDMAKE} DIRPRFX=${_tool}/ all
2647 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2648 mkdir -p ${XDDESTDIR}
2649 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2650 -p ${XDDESTDIR} >/dev/null
2651 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2652 -p ${XDDESTDIR}/usr >/dev/null
2653 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2654 -p ${XDDESTDIR}/usr/include >/dev/null
2655 .if defined(LIBCOMPAT)
2656 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2657 -p ${XDDESTDIR}/usr >/dev/null
2659 .if ${MK_TESTS} != "no"
2660 mkdir -p ${XDDESTDIR}${TESTSBASE}
2661 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2662 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2665 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2666 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
2668 _xi-cross-tools: .PHONY
2669 @echo "_xi-cross-tools"
2677 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2678 cd ${.CURDIR}/${_tool}; \
2679 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2682 _xi-includes: .PHONY
2683 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2684 DESTDIR=${XDDESTDIR}
2686 _xi-libraries: .PHONY
2687 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2688 DESTDIR=${XDDESTDIR}
2691 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2692 mkdir -p ../../../../usr/bin; \
2694 ln -sf ../../${XDTP}/usr/bin/$$i \
2695 ../../../../usr/bin/${XDDIR}-$$i; \
2696 ln -sf ../../${XDTP}/usr/bin/$$i \
2697 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2700 xdev xdev-build xdev-install xdev-links: .PHONY
2701 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"