4 # Make command line options:
5 # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6 # -DNO_CLEAN do not clean at all
7 # -DDB_FROM_SRC use the user/group databases in src/etc instead of
8 # the system database when installing.
9 # -DNO_SHARE do not go into share subdir
10 # -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,OBJ}
11 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
12 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
13 # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
14 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
15 # -DNO_ROOT install without using root privilege
16 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
17 # -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects
18 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
19 # LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list
20 # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
21 # LOCAL_MTREE="list of mtree files" to process to allow local directories
22 # to be created before files are installed
23 # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
25 # LOCAL_XTOOL_DIRS="list of dirs" to add additional dirs to the
27 # METALOG="path to metadata log" to write permission and ownership
28 # when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
29 # TARGET="machine" to crossbuild world for a different machine type
30 # TARGET_ARCH= may be required when a TARGET supports multiple endians
31 # BUILDENV_SHELL= shell to launch for the buildenv target (def:${SHELL})
32 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
33 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
34 # SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
35 # All libraries and includes, and some build tools will still build.
38 # The intended user-driven targets are:
39 # buildworld - rebuild *everything*, including glue to help do upgrades
40 # installworld- install everything built by "buildworld"
41 # checkworld - run test suite on installed world
42 # doxygen - build API documentation of the kernel
43 # update - convenient way to update your source tree (eg: svn/svnup)
45 # Standard targets (not defined here) are documented in the makefiles in
46 # /usr/share/mk. These include:
47 # obj depend all install clean cleandepend cleanobj
49 .if !defined(TARGET) || !defined(TARGET_ARCH)
50 .error "Both TARGET and TARGET_ARCH must be defined."
54 LOCALBASE?= /usr/local
56 # Cross toolchain changes must be in effect before bsd.compiler.mk
57 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
58 .if defined(CROSS_TOOLCHAIN)
59 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
60 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
62 .if defined(CROSS_TOOLCHAIN_PREFIX)
63 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
66 XCOMPILERS= CC CXX CPP
67 .for COMPILER in ${XCOMPILERS}
68 .if defined(CROSS_COMPILER_PREFIX)
69 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
71 X${COMPILER}?= ${${COMPILER}}
74 # If a full path to an external cross compiler is given, don't build
76 .if ${XCC:N${CCACHE_BIN}:M/*}
77 MK_CLANG_BOOTSTRAP= no
81 # Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early.
82 .include <bsd.compiler.mk>
83 .include "share/mk/src.opts.mk"
85 # Check if there is a local compiler that can satisfy as an external compiler.
86 # Which compiler is expected to be used?
87 .if ${MK_CLANG_BOOTSTRAP} == "yes"
88 WANT_COMPILER_TYPE= clang
89 .elif ${MK_GCC_BOOTSTRAP} == "yes"
90 WANT_COMPILER_TYPE= gcc
94 .if !defined(WANT_COMPILER_FREEBSD_VERSION)
95 .if ${WANT_COMPILER_TYPE} == "clang"
96 WANT_COMPILER_FREEBSD_VERSION_FILE= lib/clang/freebsd_cc_version.h
97 WANT_COMPILER_FREEBSD_VERSION!= \
98 awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
99 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
100 WANT_COMPILER_VERSION_FILE= lib/clang/include/clang/Basic/Version.inc
101 WANT_COMPILER_VERSION!= \
102 awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
103 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
104 .elif ${WANT_COMPILER_TYPE} == "gcc"
105 WANT_COMPILER_FREEBSD_VERSION_FILE= gnu/usr.bin/cc/cc_tools/freebsd-native.h
106 WANT_COMPILER_FREEBSD_VERSION!= \
107 awk '$$2 == "FBSD_CC_VER" {printf("%d\n", $$3)}' \
108 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
109 WANT_COMPILER_VERSION_FILE= contrib/gcc/BASE-VER
110 WANT_COMPILER_VERSION!= \
111 awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3}' \
112 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
114 .export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION
115 .endif # !defined(WANT_COMPILER_FREEBSD_VERSION)
116 # It needs to be the same revision as we would build for the bootstrap.
117 # If the expected vs CC is different then we can't skip.
118 # GCC cannot be used for cross-arch yet. For clang we pass -target later if
119 # TARGET_ARCH!=MACHINE_ARCH.
120 .if ${MK_SYSTEM_COMPILER} == "yes" && \
121 (${MK_CLANG_BOOTSTRAP} == "yes" || ${MK_GCC_BOOTSTRAP} == "yes") && \
122 !make(showconfig) && !make(native-xtools) && !make(xdev*) && \
123 ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE} && \
124 (${COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \
125 ${COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \
126 ${COMPILER_FREEBSD_VERSION} == ${WANT_COMPILER_FREEBSD_VERSION}
127 # Everything matches, disable the bootstrap compiler.
128 MK_CLANG_BOOTSTRAP= no
130 USING_SYSTEM_COMPILER= yes
131 .endif # ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE}
132 USING_SYSTEM_COMPILER?= no
133 TEST_SYSTEM_COMPILER_VARS= \
134 USING_SYSTEM_COMPILER MK_SYSTEM_COMPILER \
135 MK_CROSS_COMPILER MK_CLANG_BOOTSTRAP MK_GCC_BOOTSTRAP \
136 WANT_COMPILER_TYPE WANT_COMPILER_VERSION WANT_COMPILER_VERSION_FILE \
137 WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \
138 CC COMPILER_TYPE COMPILER_VERSION COMPILER_FREEBSD_VERSION
139 test-system-compiler: .PHONY
140 .for v in ${TEST_SYSTEM_COMPILER_VARS}
141 ${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}"
143 .if ${USING_SYSTEM_COMPILER} == "yes" && \
144 (make(buildworld) || make(buildkernel) || make(kernel-toolchain) || \
145 make(toolchain) || make(_cross-tools))
146 .info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler.
149 # For installworld need to ensure that the looked-up compiler metadata is
150 # passed along rather than trying to run cc from the restricted
152 .if ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
153 .if !defined(X_COMPILER_TYPE)
154 CROSSENV+= COMPILER_VERSION=${COMPILER_VERSION} \
155 COMPILER_TYPE=${COMPILER_TYPE} \
156 COMPILER_FREEBSD_VERSION=${COMPILER_FREEBSD_VERSION}
158 CROSSENV+= COMPILER_VERSION=${X_COMPILER_VERSION} \
159 COMPILER_TYPE=${X_COMPILER_TYPE} \
160 COMPILER_FREEBSD_VERSION=${X_COMPILER_FREEBSD_VERSION}
164 # Handle external binutils.
165 .if defined(CROSS_TOOLCHAIN_PREFIX)
166 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
168 # If we do not have a bootstrap binutils (because the in-tree one does not
169 # support the target architecture), provide a default cross-binutils prefix.
170 # This allows aarch64 builds, for example, to automatically use the
171 # aarch64-binutils port or package.
172 .if !make(showconfig)
173 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
174 !defined(CROSS_BINUTILS_PREFIX)
175 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
176 .if !exists(${CROSS_BINUTILS_PREFIX})
177 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
181 XBINUTILS= AS AR LD NM OBJCOPY RANLIB SIZE STRINGS
182 .for BINUTIL in ${XBINUTILS}
183 .if defined(CROSS_BINUTILS_PREFIX) && \
184 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
185 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
187 X${BINUTIL}?= ${${BINUTIL}}
192 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
193 # keep the users system reasonably usable. For static->dynamic root upgrades,
194 # we don't want to install a dynamic binary without rtld and the needed
195 # libraries. More commonly, for dynamic root, we don't want to install a
196 # binary that requires a newer library version that hasn't been installed yet.
197 # This ordering is not a guarantee though. The only guarantee of a working
198 # system here would require fine-grained ordering of all components based
199 # on their dependencies.
200 .if !empty(SUBDIR_OVERRIDE)
201 SUBDIR= ${SUBDIR_OVERRIDE}
204 .if !defined(NO_ROOT) && (make(installworld) || make(install))
205 # Ensure libraries are installed before progressing.
209 .if ${MK_CDDL} != "no"
213 .if ${MK_KERBEROS} != "no"
216 .if ${MK_RESCUE} != "no"
220 .if ${MK_CRYPT} != "no"
223 .if !defined(NO_SHARE)
226 SUBDIR+=sys usr.bin usr.sbin
227 .if ${MK_TESTS} != "no"
230 .if ${MK_OFED} != "no"
234 # Local directories are last, since it is nice to at least get the base
235 # system rebuilt before you do them.
236 .for _DIR in ${LOCAL_DIRS}
237 .if exists(${.CURDIR}/${_DIR}/Makefile)
241 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
242 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
243 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
244 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
245 _REDUNDENT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
247 .for _DIR in ${LOCAL_LIB_DIRS}
248 .if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
251 .warning ${_DIR} not added to SUBDIR list. See UPDATING 20141121.
255 # We must do etc/ last as it hooks into building the man whatis file
256 # by calling 'makedb' in share/man. This is only relevant for
257 # install/distribute so they build the whatis file after every manpage is
259 .if make(installworld) || make(install)
264 .endif # !empty(SUBDIR_OVERRIDE)
267 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
270 .if defined(NO_CLEANDIR)
271 CLEANDIR= clean cleandepend
276 .if ${MK_META_MODE} == "yes"
277 # If filemon is used then we can rely on the build being incremental-safe.
278 # The .meta files will also track the build command and rebuild should
280 .if empty(.MAKE.MODE:Mnofilemon)
286 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
288 .if empty(SHELL:M*csh*)
289 BUILDENV_SHELL?=${SHELL}
291 BUILDENV_SHELL?=/bin/sh
294 .if !defined(SVN) || empty(SVN)
295 . for _P in /usr/bin /usr/local/bin
296 . for _S in svn svnlite
297 . if exists(${_P}/${_S})
305 MAKEOBJDIRPREFIX?= /usr/obj
306 .if !defined(OSRELDATE)
307 .if exists(/usr/include/osreldate.h)
308 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
309 /usr/include/osreldate.h
316 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
317 .if !defined(_REVISION)
318 _REVISION!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V REVISION
321 .if !defined(_BRANCH)
322 _BRANCH!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V BRANCH
325 .if !defined(SRCRELDATE)
326 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
327 ${SRCDIR}/sys/sys/param.h
330 .if !defined(VERSION)
331 VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
335 .if !defined(PKG_VERSION)
336 .if ${_BRANCH:MSTABLE*} || ${_BRANCH:MCURRENT*} || ${_BRANCH:MALPHA*}
337 TIMENOW= %Y%m%d%H%M%S
338 EXTRA_REVISION= .s${TIMENOW:gmtime}
341 EXTRA_REVISION= _${_BRANCH:C/.*-p([0-9]+$)/\1/}
343 PKG_VERSION= ${_REVISION}${EXTRA_REVISION}
346 KNOWN_ARCHES?= aarch64/arm64 \
364 .if ${TARGET} == ${TARGET_ARCH}
367 _t= ${TARGET_ARCH}/${TARGET}
370 .if empty(KNOWN_ARCHES:M${_t})
371 .error Unknown target ${TARGET_ARCH}:${TARGET}.
375 .if ${TARGET} == ${MACHINE}
376 TARGET_CPUTYPE?=${CPUTYPE}
381 .if !empty(TARGET_CPUTYPE)
382 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
384 _TARGET_CPUTYPE=dummy
386 _CPUTYPE!= MK_AUTO_OBJ=no MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
387 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
388 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
389 .error CPUTYPE global should be set with ?=.
392 BUILD_ARCH!= uname -p
393 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
394 .error To cross-build, set TARGET_ARCH.
397 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
398 OBJTREE= ${MAKEOBJDIRPREFIX}
400 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
402 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
403 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
404 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
405 STRICTTMPPATH= ${BPATH}:${XPATH}
406 TMPPATH= ${STRICTTMPPATH}:${PATH}
409 # Avoid running mktemp(1) unless actually needed.
410 # It may not be functional, e.g., due to new ABI
411 # when in the middle of installing over this system.
413 .if make(distributeworld) || make(installworld) || make(stageworld)
414 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
417 .if make(stagekernel) || make(distributekernel)
423 # Building a world goes through the following stages
425 # 1. legacy stage [BMAKE]
426 # This stage is responsible for creating compatibility
427 # shims that are needed by the bootstrap-tools,
428 # build-tools and cross-tools stages. These are generally
429 # APIs that tools from one of those three stages need to
430 # build that aren't present on the host.
431 # 1. bootstrap-tools stage [BMAKE]
432 # This stage is responsible for creating programs that
433 # are needed for backward compatibility reasons. They
434 # are not built as cross-tools.
435 # 2. build-tools stage [TMAKE]
436 # This stage is responsible for creating the object
437 # tree and building any tools that are needed during
438 # the build process. Some programs are listed during
439 # this phase because they build binaries to generate
440 # files needed to build these programs. This stage also
441 # builds the 'build-tools' target rather than 'all'.
442 # 3. cross-tools stage [XMAKE]
443 # This stage is responsible for creating any tools that
444 # are needed for building the system. A cross-compiler is one
445 # of them. This differs from build tools in two ways:
446 # 1. the 'all' target is built rather than 'build-tools'
447 # 2. these tools are installed into TMPPATH for stage 4.
448 # 4. world stage [WMAKE]
449 # This stage actually builds the world.
450 # 5. install stage (optional) [IMAKE]
451 # This stage installs a previously built world.
456 MINIMUM_SUPPORTED_OSREL?= 900044
457 MINIMUM_SUPPORTED_REL?= 9.1
459 # Common environment for world related stages
460 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
461 MACHINE_ARCH=${TARGET_ARCH} \
463 CPUTYPE=${TARGET_CPUTYPE}
464 .if ${MK_META_MODE} != "no"
465 # Don't rebuild build-tools targets during normal build.
466 CROSSENV+= BUILD_TOOLS_META=.NOMETA_CMP
468 .if ${MK_GROFF} != "no"
469 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
470 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
471 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
473 .if defined(TARGET_CFLAGS)
474 CROSSENV+= ${TARGET_CFLAGS}
477 # bootstrap-tools stage
478 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
479 TOOLS_PREFIX=${WORLDTMP} \
480 PATH=${BPATH}:${PATH} \
481 WORLDTMP=${WORLDTMP} \
482 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
483 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
485 BOOTSTRAPPING=${OSRELDATE} \
487 MK_HTML=no NO_LINT=yes MK_MAN=no \
488 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
489 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
490 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
491 MK_LLDB=no MK_TESTS=no \
494 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
495 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
499 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
500 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
501 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
503 BOOTSTRAPPING=${OSRELDATE} \
506 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
507 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
508 MK_LLDB=no MK_TESTS=no
511 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
512 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
513 MK_GDB=no MK_TESTS=no
516 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
517 PATH=${BPATH}:${PATH} \
519 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
520 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
522 BOOTSTRAPPING=${OSRELDATE} \
524 MK_HTML=no -DNO_LINT MK_MAN=no \
525 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
526 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
529 WMAKEENV= ${CROSSENV} \
530 INSTALL="sh ${.CURDIR}/tools/install.sh" \
534 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
536 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
539 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
540 CPP="${XCPP} ${XCFLAGS}" \
541 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
542 OBJCOPY="${XOBJCOPY}" \
543 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
546 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
547 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
548 # directory, but the compiler will look in the right place for its
549 # tools so we don't need to tell it where to look.
550 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
554 # The internal bootstrap compiler has a default sysroot set by TOOLS_PREFIX
555 # and target set by TARGET/TARGET_ARCH. However, there are several needs to
556 # always pass an explicit --sysroot and -target.
557 # - External compiler needs sysroot and target flags.
558 # - External ld needs sysroot.
559 # - To be clear about the use of a sysroot when using the internal compiler.
560 # - Easier debugging.
561 # - Allowing WITH_SYSTEM_COMPILER+WITH_META_MODE to work together due to
562 # the flip-flopping build command when sometimes using external and
563 # sometimes using internal.
564 # - Allow using lld which has no support for default paths.
565 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
566 BFLAGS+= -B${WORLDTMP}/usr/bin
568 .if ${TARGET} == "arm"
569 .if ${TARGET_ARCH:Marmv6*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
570 TARGET_ABI= gnueabihf
575 .if ${WANT_COMPILER_TYPE} == gcc || \
576 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
577 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
578 # won't set header path and -L is used to ensure the base library path
579 # is added before the port PREFIX library path.
580 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
581 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
582 # combined with --sysroot.
583 XCFLAGS+= -B${WORLDTMP}/usr/lib
584 # Force using libc++ for external GCC.
585 # XXX: This should be checking MK_GNUCXX == no
586 .if ${X_COMPILER_VERSION} >= 40800
587 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
588 -nostdinc++ -L${WORLDTMP}/../lib/libc++
590 .elif ${WANT_COMPILER_TYPE} == clang || \
591 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang)
593 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd12.0
594 XCFLAGS+= -target ${TARGET_TRIPLE}
596 XCFLAGS+= --sysroot=${WORLDTMP}
602 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
603 ${TARGET_ARCH} == "powerpc64")
605 .include "Makefile.libcompat"
606 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH} == "armv6"
608 .include "Makefile.libcompat"
611 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
613 IMAKEENV= ${CROSSENV}
614 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
615 ${IMAKE_INSTALL} ${IMAKE_MTREE}
616 .if empty(.MAKEFLAGS:M-n)
617 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
618 LD_LIBRARY_PATH=${INSTALLTMP} \
619 PATH_LOCALE=${INSTALLTMP}/locale
620 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
622 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
624 .if defined(DB_FROM_SRC)
625 INSTALLFLAGS+= -N ${.CURDIR}/etc
626 MTREEFLAGS+= -N ${.CURDIR}/etc
628 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
629 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
631 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
632 IMAKE+= -DNO_ROOT METALOG=${METALOG}
633 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
636 .if defined(BUILD_PKGS)
637 INSTALLFLAGS+= -h sha256
639 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
640 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
641 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
645 KMAKEENV= ${WMAKEENV}
646 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
651 # Attempt to rebuild the entire system, with reasonable chance of
652 # success, regardless of how old your existing system is.
655 .if ${.CURDIR:C/[^,]//g} != ""
656 # The m4 build of sendmail files doesn't like it if ',' is used
657 # anywhere in the path of it's files.
659 @echo "*** Error: path to source tree contains a comma ','"
664 @echo "--------------------------------------------------------------"
665 @echo ">>> Rebuilding the temporary build tree"
666 @echo "--------------------------------------------------------------"
667 .if !defined(NO_CLEAN)
669 .if defined(LIBCOMPAT)
670 rm -rf ${LIBCOMPATTMP}
673 rm -rf ${WORLDTMP}/legacy/usr/include
674 # XXX - These can depend on any header file.
675 rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c
676 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
679 lib lib/casper usr legacy/bin legacy/usr
680 mkdir -p ${WORLDTMP}/${_dir}
682 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
683 -p ${WORLDTMP}/legacy/usr >/dev/null
684 .if ${MK_GROFF} != "no"
685 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
686 -p ${WORLDTMP}/legacy/usr >/dev/null
688 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
689 -p ${WORLDTMP}/legacy/usr/include >/dev/null
690 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
691 -p ${WORLDTMP}/usr >/dev/null
692 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
693 -p ${WORLDTMP}/usr/include >/dev/null
694 ln -sf ${.CURDIR}/sys ${WORLDTMP}
695 .if ${MK_DEBUG_FILES} != "no"
696 # We could instead disable debug files for these build stages
697 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
698 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
699 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
700 -p ${WORLDTMP}/usr/lib >/dev/null
702 .if defined(LIBCOMPAT)
703 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
704 -p ${WORLDTMP}/usr >/dev/null
705 .if ${MK_DEBUG_FILES} != "no"
706 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
707 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
708 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
709 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
712 .if ${MK_TESTS} != "no"
713 mkdir -p ${WORLDTMP}${TESTSBASE}
714 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
715 -p ${WORLDTMP}${TESTSBASE} >/dev/null
716 .if ${MK_DEBUG_FILES} != "no"
717 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
718 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
719 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
722 .for _mtree in ${LOCAL_MTREE}
723 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
727 @echo "--------------------------------------------------------------"
728 @echo ">>> stage 1.1: legacy release compatibility shims"
729 @echo "--------------------------------------------------------------"
730 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
733 @echo "--------------------------------------------------------------"
734 @echo ">>> stage 1.2: bootstrap tools"
735 @echo "--------------------------------------------------------------"
736 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
738 .if !defined(NO_CLEAN)
740 @echo "--------------------------------------------------------------"
741 @echo ">>> stage 2.1: cleaning up the object tree"
742 @echo "--------------------------------------------------------------"
743 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
744 .if defined(LIBCOMPAT)
745 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
750 @echo "--------------------------------------------------------------"
751 @echo ">>> stage 2.2: rebuilding the object tree"
752 @echo "--------------------------------------------------------------"
753 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
756 @echo "--------------------------------------------------------------"
757 @echo ">>> stage 2.3: build tools"
758 @echo "--------------------------------------------------------------"
759 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
762 @echo "--------------------------------------------------------------"
763 @echo ">>> stage 3: cross tools"
764 @echo "--------------------------------------------------------------"
765 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
766 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
769 @echo "--------------------------------------------------------------"
770 @echo ">>> stage 4.1: building includes"
771 @echo "--------------------------------------------------------------"
772 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
773 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
774 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
775 MK_INCLUDES=yes includes
776 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
777 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
781 @echo "--------------------------------------------------------------"
782 @echo ">>> stage 4.2: building libraries"
783 @echo "--------------------------------------------------------------"
784 ${_+_}cd ${.CURDIR}; \
785 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
786 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
789 @echo "--------------------------------------------------------------"
790 @echo ">>> stage 4.3: building everything"
791 @echo "--------------------------------------------------------------"
792 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
795 WMAKE_TGTS+= _worldtmp _legacy
796 .if empty(SUBDIR_OVERRIDE)
797 WMAKE_TGTS+= _bootstrap-tools
799 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
800 WMAKE_TGTS+= _includes _libraries
801 WMAKE_TGTS+= everything
802 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
803 WMAKE_TGTS+= build${libcompat}
806 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
807 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
809 buildworld_prologue: .PHONY
810 @echo "--------------------------------------------------------------"
811 @echo ">>> World build started on `LC_ALL=C date`"
812 @echo "--------------------------------------------------------------"
814 buildworld_epilogue: .PHONY
816 @echo "--------------------------------------------------------------"
817 @echo ">>> World build completed on `LC_ALL=C date`"
818 @echo "--------------------------------------------------------------"
821 # We need to have this as a target because the indirection between Makefile
822 # and Makefile.inc1 causes the correct PATH to be used, rather than a
823 # modification of the current environment's PATH. In addition, we need
824 # to quote multiword values.
827 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
829 .if ${.TARGETS:Mbuildenv}
830 .if ${.MAKEFLAGS:M-j}
831 .error The buildenv target is incompatible with -j
834 BUILDENV_DIR?= ${.CURDIR}
836 @echo Entering world for ${TARGET_ARCH}:${TARGET}
837 .if ${BUILDENV_SHELL:M*zsh*}
838 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
840 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
843 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
844 toolchain: ${TOOLCHAIN_TGTS} .PHONY
845 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries} .PHONY
850 # Checks to be sure system is ready for installworld/installkernel.
852 installcheck: _installcheck_world _installcheck_kernel .PHONY
853 _installcheck_world: .PHONY
854 _installcheck_kernel: .PHONY
857 # Require DESTDIR to be set if installing for a different architecture or
858 # using the user/group database in the source tree.
860 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
862 .if !make(distributeworld)
863 _installcheck_world: __installcheck_DESTDIR
864 _installcheck_kernel: __installcheck_DESTDIR
865 __installcheck_DESTDIR: .PHONY
866 .if !defined(DESTDIR) || empty(DESTDIR)
867 @echo "ERROR: Please set DESTDIR!"; \
873 .if !defined(DB_FROM_SRC)
875 # Check for missing UIDs/GIDs.
877 CHECK_UIDS= auditdistd
879 .if ${MK_SENDMAIL} != "no"
885 CHECK_GIDS+= proxy authpf
887 .if ${MK_UNBOUND} != "no"
891 _installcheck_world: __installcheck_UGID
892 __installcheck_UGID: .PHONY
893 .for uid in ${CHECK_UIDS}
894 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
895 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
899 .for gid in ${CHECK_GIDS}
900 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
901 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
908 # Required install tools to be saved in a scratch dir for safety.
910 .if ${MK_ZONEINFO} != "no"
911 _zoneinfo= zic tzsetup
914 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
915 date echo egrep find grep id install ${_install-info} \
916 ln make mkdir mtree mv pwd_mkdb \
917 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
920 # Needed for share/man
921 .if ${MK_MAN_UTILS} != "no"
928 # Distributes everything compiled by a `buildworld'.
932 # Installs everything compiled by a 'buildworld'.
935 # Non-base distributions produced by the base system
936 EXTRA_DISTRIBUTIONS= doc
937 .if defined(LIBCOMPAT)
938 EXTRA_DISTRIBUTIONS+= lib${libcompat}
940 .if ${MK_TESTS} != "no"
941 EXTRA_DISTRIBUTIONS+= tests
945 .if ${MK_DEBUG_FILES} != "no"
946 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
949 MTREE_MAGIC?= mtree 2.0
951 distributeworld installworld stageworld: _installcheck_world .PHONY
952 mkdir -p ${INSTALLTMP}
953 progs=$$(for prog in ${ITOOLS}; do \
954 if progpath=`which $$prog`; then \
957 echo "Required tool $$prog not found in PATH." >&2; \
961 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
962 while read line; do \
964 if [ "$$2 $$3" != "not found" ]; then \
967 echo "Required library $$1 not found." >&2; \
971 cp $$libs $$progs ${INSTALLTMP}
972 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
974 -mkdir -p ${METALOG:H}
975 echo "#${MTREE_MAGIC}" > ${METALOG}
977 .if make(distributeworld)
978 .for dist in ${EXTRA_DISTRIBUTIONS}
979 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
980 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
981 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
982 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
983 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
984 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
985 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
986 .if ${MK_DEBUG_FILES} != "no"
987 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
988 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
990 .if defined(LIBCOMPAT)
991 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
992 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
993 .if ${MK_DEBUG_FILES} != "no"
994 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
995 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
998 .if ${MK_TESTS} != "no" && ${dist} == "tests"
999 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
1000 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1001 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
1002 .if ${MK_DEBUG_FILES} != "no"
1003 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1004 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
1007 .if defined(NO_ROOT)
1008 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1009 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1010 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1011 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1012 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1013 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1014 .if defined(LIBCOMPAT)
1015 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
1016 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1020 -mkdir ${DESTDIR}/${DISTDIR}/base
1021 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1022 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1023 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1024 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1026 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1027 ${IMAKEENV} rm -rf ${INSTALLTMP}
1028 .if make(distributeworld)
1029 .for dist in ${EXTRA_DISTRIBUTIONS}
1030 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete
1032 .if defined(NO_ROOT)
1033 .for dist in base ${EXTRA_DISTRIBUTIONS}
1034 @# For each file that exists in this dist, print the corresponding
1035 @# line from the METALOG. This relies on the fact that
1036 @# a line containing only the filename will sort immediately before
1037 @# the relevant mtree line.
1038 cd ${DESTDIR}/${DISTDIR}; \
1039 find ./${dist} | sort -u ${METALOG} - | \
1040 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1041 ${DESTDIR}/${DISTDIR}/${dist}.meta
1043 .for dist in ${DEBUG_DISTRIBUTIONS}
1044 @# For each file that exists in this dist, print the corresponding
1045 @# line from the METALOG. This relies on the fact that
1046 @# a line containing only the filename will sort immediately before
1047 @# the relevant mtree line.
1048 cd ${DESTDIR}/${DISTDIR}; \
1049 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1050 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1051 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1056 packageworld: .PHONY
1057 .for dist in base ${EXTRA_DISTRIBUTIONS}
1058 .if defined(NO_ROOT)
1059 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1060 tar cvf - --exclude usr/lib/debug \
1061 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1062 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1064 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1065 tar cvf - --exclude usr/lib/debug . | \
1066 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1070 .for dist in ${DEBUG_DISTRIBUTIONS}
1071 . if defined(NO_ROOT)
1072 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1073 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1074 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1076 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1077 tar cvLf - usr/lib/debug | \
1078 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1085 # If you have a build server, you can NFS mount the source and obj directories
1086 # and do a 'make reinstall' on the *client* to install new binaries from the
1087 # most recent server build.
1089 restage reinstall: .MAKE .PHONY
1090 @echo "--------------------------------------------------------------"
1091 @echo ">>> Making hierarchy"
1092 @echo "--------------------------------------------------------------"
1093 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1094 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1096 @echo "--------------------------------------------------------------"
1097 @echo ">>> Making distribution"
1098 @echo "--------------------------------------------------------------"
1099 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1100 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
1103 @echo "--------------------------------------------------------------"
1104 @echo ">>> Installing everything"
1105 @echo "--------------------------------------------------------------"
1106 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1107 .if defined(LIBCOMPAT)
1108 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1111 redistribute: .MAKE .PHONY
1112 @echo "--------------------------------------------------------------"
1113 @echo ">>> Distributing everything"
1114 @echo "--------------------------------------------------------------"
1115 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1116 .if defined(LIBCOMPAT)
1117 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1118 DISTRIBUTION=lib${libcompat}
1121 distrib-dirs distribution: .MAKE .PHONY
1122 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1123 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1124 .if make(distribution)
1125 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1126 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1127 METALOG=${METALOG} MK_TESTS=no installconfig
1131 # buildkernel and installkernel
1133 # Which kernels to build and/or install is specified by setting
1134 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1135 # Only the existing (depending TARGET) config files are used
1136 # for building kernels and only the first of these is designated
1137 # as the one being installed.
1139 # Note that we have to use TARGET instead of TARGET_ARCH when
1140 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1141 # be set to cross-build, we have to make sure TARGET is set
1144 .if defined(KERNFAST)
1148 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1149 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1150 KERNCONF=${KERNFAST}
1153 .if ${TARGET_ARCH} == "powerpc64"
1154 KERNCONF?= GENERIC64
1158 INSTKERNNAME?= kernel
1160 KERNSRCDIR?= ${.CURDIR}/sys
1161 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1162 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1163 KERNCONFDIR?= ${KRNLCONFDIR}
1167 .if defined(NO_INSTALLKERNEL)
1168 # All of the BUILDKERNELS loops start at index 1.
1169 BUILDKERNELS+= dummy
1171 .for _kernel in ${KERNCONF}
1172 .if exists(${KERNCONFDIR}/${_kernel})
1173 BUILDKERNELS+= ${_kernel}
1174 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1175 INSTALLKERNEL= ${_kernel}
1180 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1185 # Builds all kernels defined by BUILDKERNELS.
1187 buildkernel: .MAKE .PHONY
1188 .if empty(BUILDKERNELS:Ndummy)
1189 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1193 .for _kernel in ${BUILDKERNELS:Ndummy}
1194 @echo "--------------------------------------------------------------"
1195 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1196 @echo "--------------------------------------------------------------"
1197 @echo "===> ${_kernel}"
1198 mkdir -p ${KRNLOBJDIR}
1199 .if !defined(NO_KERNELCONFIG)
1201 @echo "--------------------------------------------------------------"
1202 @echo ">>> stage 1: configuring the kernel"
1203 @echo "--------------------------------------------------------------"
1204 cd ${KRNLCONFDIR}; \
1206 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1207 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1209 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1211 @echo "--------------------------------------------------------------"
1212 @echo ">>> stage 2.1: cleaning up the object tree"
1213 @echo "--------------------------------------------------------------"
1214 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1216 .if !defined(NO_KERNELOBJ)
1218 @echo "--------------------------------------------------------------"
1219 @echo ">>> stage 2.2: rebuilding the object tree"
1220 @echo "--------------------------------------------------------------"
1221 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1224 @echo "--------------------------------------------------------------"
1225 @echo ">>> stage 2.3: build tools"
1226 @echo "--------------------------------------------------------------"
1227 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1229 @echo "--------------------------------------------------------------"
1230 @echo ">>> stage 3.1: building everything"
1231 @echo "--------------------------------------------------------------"
1232 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1233 @echo "--------------------------------------------------------------"
1234 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1235 @echo "--------------------------------------------------------------"
1238 NO_INSTALLEXTRAKERNELS?= yes
1241 # installkernel, etc.
1243 # Install the kernel defined by INSTALLKERNEL
1245 installkernel installkernel.debug \
1246 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1247 .if !defined(NO_INSTALLKERNEL)
1248 .if empty(INSTALLKERNEL)
1249 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1252 @echo "--------------------------------------------------------------"
1253 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1254 @echo "--------------------------------------------------------------"
1255 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1256 ${CROSSENV} PATH=${TMPPATH} \
1257 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1259 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1260 .for _kernel in ${BUILDKERNELS:[2..-1]}
1261 @echo "--------------------------------------------------------------"
1262 @echo ">>> Installing kernel ${_kernel}"
1263 @echo "--------------------------------------------------------------"
1264 cd ${KRNLOBJDIR}/${_kernel}; \
1265 ${CROSSENV} PATH=${TMPPATH} \
1266 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1270 distributekernel distributekernel.debug: .PHONY
1271 .if !defined(NO_INSTALLKERNEL)
1272 .if empty(INSTALLKERNEL)
1273 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1276 mkdir -p ${DESTDIR}/${DISTDIR}
1277 .if defined(NO_ROOT)
1278 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1280 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1281 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1282 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1283 DESTDIR=${INSTALL_DDIR}/kernel \
1284 ${.TARGET:S/distributekernel/install/}
1285 .if defined(NO_ROOT)
1286 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1287 ${DESTDIR}/${DISTDIR}/kernel.meta
1290 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1291 .for _kernel in ${BUILDKERNELS:[2..-1]}
1292 .if defined(NO_ROOT)
1293 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1295 cd ${KRNLOBJDIR}/${_kernel}; \
1296 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1297 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1298 KERNEL=${INSTKERNNAME}.${_kernel} \
1299 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1300 ${.TARGET:S/distributekernel/install/}
1301 .if defined(NO_ROOT)
1302 @sed -e "s|^./kernel.${_kernel}|.|" \
1303 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1304 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1309 packagekernel: .PHONY
1310 .if defined(NO_ROOT)
1311 .if !defined(NO_INSTALLKERNEL)
1312 cd ${DESTDIR}/${DISTDIR}/kernel; \
1313 tar cvf - --exclude '*.debug' \
1314 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1315 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1317 cd ${DESTDIR}/${DISTDIR}/kernel; \
1318 tar cvf - --include '*/*/*.debug' \
1319 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1320 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1321 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1322 .for _kernel in ${BUILDKERNELS:[2..-1]}
1323 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1324 tar cvf - --exclude '*.debug' \
1325 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1326 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1327 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1328 tar cvf - --include '*/*/*.debug' \
1329 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1330 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1334 .if !defined(NO_INSTALLKERNEL)
1335 cd ${DESTDIR}/${DISTDIR}/kernel; \
1336 tar cvf - --exclude '*.debug' . | \
1337 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1339 cd ${DESTDIR}/${DISTDIR}/kernel; \
1340 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1341 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1342 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1343 .for _kernel in ${BUILDKERNELS:[2..-1]}
1344 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1345 tar cvf - --exclude '*.debug' . | \
1346 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1347 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1348 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1349 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1355 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1357 PORTSDIR?= /usr/ports
1358 WSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/worldstage
1359 KSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/kernelstage
1360 REPODIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/repo
1361 PKGSIGNKEY?= # empty
1363 .ORDER: stage-packages create-packages
1364 .ORDER: create-packages create-world-packages
1365 .ORDER: create-packages create-kernel-packages
1366 .ORDER: create-packages sign-packages
1368 _pkgbootstrap: .PHONY
1369 .if !exists(${LOCALBASE}/sbin/pkg)
1370 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1374 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1377 rm -rf /tmp/ports.${TARGET} || :
1378 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
1379 PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} WSTAGEDIR=${WSTAGEDIR} \
1380 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1382 real-packages: stage-packages create-packages sign-packages .PHONY
1384 stage-packages: .PHONY
1385 @mkdir -p ${REPODIR} ${WSTAGEDIR} ${KSTAGEDIR}
1386 ${_+_}@cd ${.CURDIR}; \
1387 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT -B stageworld ; \
1388 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT -B stagekernel
1390 create-packages: _pkgbootstrap .PHONY
1391 @mkdir -p ${REPODIR}
1392 ${_+_}@cd ${.CURDIR}; \
1393 ${MAKE} DESTDIR=${WSTAGEDIR} \
1394 PKG_VERSION=${PKG_VERSION} create-world-packages ; \
1395 ${MAKE} DESTDIR=${KSTAGEDIR} \
1396 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1397 create-kernel-packages
1399 create-world-packages: _pkgbootstrap .PHONY
1400 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1401 @cd ${WSTAGEDIR} ; \
1402 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1403 ${WSTAGEDIR}/METALOG
1404 @for plist in ${WSTAGEDIR}/*.plist; do \
1405 plist=$${plist##*/} ; \
1406 pkgname=$${plist%.plist} ; \
1407 sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \
1408 -s ${SRCDIR} -u ${WSTAGEDIR}/$${pkgname}.ucl ; \
1410 @for plist in ${WSTAGEDIR}/*.plist; do \
1411 plist=$${plist##*/} ; \
1412 pkgname=$${plist%.plist} ; \
1414 /^name/ { printf("===> Creating %s-", $$2); next } \
1415 /^version/ { print $$2; next } \
1416 ' ${WSTAGEDIR}/$${pkgname}.ucl ; \
1417 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1418 create -M ${WSTAGEDIR}/$${pkgname}.ucl \
1419 -p ${WSTAGEDIR}/$${pkgname}.plist \
1421 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} ; \
1424 create-kernel-packages: _pkgbootstrap .PHONY
1425 .if exists(${KSTAGEDIR}/kernel.meta)
1426 .for flavor in "" -debug
1427 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1428 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1429 -v kernel=yes -v _kernconf=${INSTALLKERNEL} \
1430 ${KSTAGEDIR}/kernel.meta ; \
1431 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1432 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1433 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1434 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1435 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1436 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1437 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1438 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1439 ${SRCDIR}/release/packages/kernel.ucl \
1440 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1442 /name/ { printf("===> Creating %s-", $$2); next } \
1443 /version/ {print $$2; next } ' \
1444 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1445 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1446 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1447 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1448 -r ${KSTAGEDIR}/${DISTDIR} \
1449 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1452 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1453 .for _kernel in ${BUILDKERNELS:[2..-1]}
1454 .if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1455 .for flavor in "" -debug
1456 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1457 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1458 -v kernel=yes -v _kernconf=${_kernel} \
1459 ${KSTAGEDIR}/kernel.${_kernel}.meta ; \
1460 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1461 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1462 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1463 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1464 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1465 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1466 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1467 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1468 ${SRCDIR}/release/packages/kernel.ucl \
1469 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1471 /name/ { printf("===> Creating %s-", $$2); next } \
1472 /version/ {print $$2; next } ' \
1473 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1474 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1475 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1476 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1477 -r ${KSTAGEDIR}/kernel.${_kernel} \
1478 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1484 sign-packages: _pkgbootstrap .PHONY
1485 @[ -L "${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1486 unlink ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1487 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1488 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1489 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1491 ln -s ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1492 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest
1498 # Run test suite on installed world.
1501 @if [ ! -x ${LOCALBASE}/bin/kyua ]; then \
1502 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1505 ${_+_}${LOCALBASE}/bin/kyua test -k ${TESTSBASE}/Kyuafile
1511 # Build the API documentation with doxygen
1514 @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1515 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1518 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1523 # Update the source tree(s), by running svn/svnup to update to the
1527 .if defined(SVN_UPDATE)
1528 @echo "--------------------------------------------------------------"
1529 @echo ">>> Updating ${.CURDIR} using Subversion"
1530 @echo "--------------------------------------------------------------"
1531 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1535 # ------------------------------------------------------------------------
1537 # From here onwards are utility targets used by the 'make world' and
1538 # related targets. If your 'world' breaks, you may like to try to fix
1539 # the problem and manually run the following targets to attempt to
1540 # complete the build. Beware, this is *not* guaranteed to work, you
1541 # need to have a pretty good grip on the current state of the system
1542 # to attempt to manually finish it. If in doubt, 'make world' again.
1546 # legacy: Build compatibility shims for the next three targets. This is a
1547 # minimal set of tools and shims necessary to compensate for older systems
1548 # which don't have the APIs required by the targets built in bootstrap-tools,
1549 # build-tools or cross-tools.
1552 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1553 # r296685 fix cross-endian objcopy
1554 .if ${BOOTSTRAPPING} < 1100102
1555 _elftoolchain_libs= lib/libelf lib/libdwarf
1559 .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
1560 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
1563 .for _tool in tools/build ${_elftoolchain_libs}
1564 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1565 cd ${.CURDIR}/${_tool}; \
1566 ${MAKE} DIRPRFX=${_tool}/ obj; \
1567 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1568 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
1569 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
1570 DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1574 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1575 # are built to build other binaries in the system. However, the focus of these
1576 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1577 # libraries, augmented by -legacy.
1579 _bt= _bootstrap-tools
1581 .if ${MK_GAMES} != "no"
1582 _strfile= usr.bin/fortune/strfile
1585 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1586 _gperf= gnu/usr.bin/gperf
1589 .if ${MK_GROFF} != "no"
1590 _groff= gnu/usr.bin/groff \
1594 .if ${MK_VT} != "no"
1595 _vtfontcvt= usr.bin/vtfontcvt
1598 .if ${BOOTSTRAPPING} < 1000033
1599 _libopenbsd= lib/libopenbsd
1603 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1604 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1607 .if ${BOOTSTRAPPING} < 1000026
1608 _nmtree= lib/libnetbsd \
1611 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1614 .if ${BOOTSTRAPPING} < 1000027
1618 # r264059 support for status=
1619 .if ${BOOTSTRAPPING} < 1100017
1623 # r277259 crunchide: Correct 64-bit section header offset
1624 # r281674 crunchide: always include both 32- and 64-bit ELF support
1625 .if ${BOOTSTRAPPING} < 1100078
1626 _crunchide= usr.sbin/crunch/crunchide
1629 # r285986 crunchen: use STRIPBIN rather than STRIP
1630 # 1100113: Support MK_AUTO_OBJ
1631 # 1200006: META_MODE fixes
1632 .if ${BOOTSTRAPPING} < 1100078 || \
1633 (${MK_AUTO_OBJ} == "yes" && ${BOOTSTRAPPING} < 1100114) || \
1634 (${MK_META_MODE} == "yes" && ${BOOTSTRAPPING} < 1200006)
1635 _crunchgen= usr.sbin/crunch/crunchgen
1638 # r296926 -P keymap search path, MFC to stable/10 in r298297
1639 .if ${BOOTSTRAPPING} < 1003501 || \
1640 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
1641 _kbdcontrol= usr.sbin/kbdcontrol
1647 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1649 .if ${MK_BSNMP} != "no"
1650 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1653 # We need to build tblgen when we're building clang either as
1654 # the bootstrap compiler, or as the part of the normal build.
1655 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1657 lib/clang/libllvmsupport \
1658 lib/clang/libllvmtablegen \
1659 usr.bin/clang/llvm-tblgen \
1660 usr.bin/clang/clang-tblgen
1662 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1663 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1666 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1669 .if ${MK_GPL_DTC} != "no"
1670 _dtc= gnu/usr.bin/dtc
1673 .if ${MK_KERBEROS} != "no"
1674 _kerberos5_bootstrap_tools= \
1675 kerberos5/tools/make-roken \
1676 kerberos5/lib/libroken \
1677 kerberos5/lib/libvers \
1678 kerberos5/tools/asn1_compile \
1679 kerberos5/tools/slc \
1682 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1685 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
1686 .if ${MK_MANDOCDB} != "no" && ${BOOTSTRAPPING} < 1100075
1687 _libopenbsd?= lib/libopenbsd
1688 _makewhatis= lib/libsqlite3 \
1690 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1693 bootstrap-tools: .PHONY
1695 # Please document (add comment) why something is in 'bootstrap-tools'.
1696 # Try to bound the building of the bootstrap-tool to just the
1697 # FreeBSD versions that need the tool built at this stage of the build.
1700 ${_kerberos5_bootstrap_tools} \
1723 ${_bt}-${_tool}: .PHONY .MAKE
1724 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1725 cd ${.CURDIR}/${_tool}; \
1726 ${MAKE} DIRPRFX=${_tool}/ obj; \
1727 ${MAKE} DIRPRFX=${_tool}/ all; \
1728 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1730 bootstrap-tools: ${_bt}-${_tool}
1734 # build-tools: Build special purpose build tools
1736 .if !defined(NO_SHARE)
1737 _share= share/syscons/scrnmaps
1740 .if ${MK_GCC} != "no"
1741 _gcc_tools= gnu/usr.bin/cc/cc_tools
1744 .if ${MK_RESCUE} != "no"
1745 # rescue includes programs that have build-tools targets
1746 _rescue=rescue/rescue
1752 ${LOCAL_TOOL_DIRS} \
1753 lib/ncurses/ncurses \
1754 lib/ncurses/ncursesw \
1759 usr.bin/mkesdb_static \
1760 usr.bin/mkcsmapper_static \
1762 build-tools_${_tool}: .PHONY
1763 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1764 cd ${.CURDIR}/${_tool}; \
1765 ${MAKE} DIRPRFX=${_tool}/ obj; \
1766 ${MAKE} DIRPRFX=${_tool}/ build-tools
1767 build-tools: build-tools_${_tool}
1771 build-tools_${_tool}: .PHONY
1772 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \
1773 cd ${.CURDIR}/${_tool}; \
1774 ${MAKE} DIRPRFX=${_tool}/ obj; \
1775 ${MAKE} DIRPRFX=${_tool}/ all
1776 build-tools: build-tools_${_tool}
1780 # kernel-tools: Build kernel-building tools
1782 kernel-tools: .PHONY
1783 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1784 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1785 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1788 # cross-tools: All the tools needed to build the rest of the system after
1789 # we get done with the earlier stages. It is the last set of tools needed
1790 # to begin building the target binaries.
1792 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1793 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1794 _btxld= usr.sbin/btxld
1798 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1799 # resulting from missing bug fixes or ELF Toolchain updates.
1800 .if ${MK_CDDL} != "no"
1801 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1802 cddl/usr.bin/ctfmerge
1805 # If we're given an XAS, don't build binutils.
1806 .if ${XAS:M/*} == ""
1807 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1808 _binutils= gnu/usr.bin/binutils
1810 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1811 _elftctools= lib/libelftc \
1817 # These are not required by the build, but can be useful for developers who
1818 # cross-build on a FreeBSD 10 host:
1819 _elftctools+= usr.bin/addr2line
1821 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1822 # If cross-building with an external binutils we still need to build strip for
1823 # the target (for at least crunchide).
1824 _elftctools= lib/libelftc \
1829 .if ${MK_CLANG_BOOTSTRAP} != "no"
1830 _clang= usr.bin/clang
1831 _clang_libs= lib/clang
1833 .if ${MK_GCC_BOOTSTRAP} != "no"
1836 .if ${MK_USB} != "no"
1837 _usb_tools= sys/boot/usb/tools
1840 cross-tools: .MAKE .PHONY
1842 ${LOCAL_XTOOL_DIRS} \
1851 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1852 cd ${.CURDIR}/${_tool}; \
1853 ${MAKE} DIRPRFX=${_tool}/ obj; \
1854 ${MAKE} DIRPRFX=${_tool}/ all; \
1855 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1858 NXBDESTDIR= ${OBJTREE}/nxb-bin
1859 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1860 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1861 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1862 NXBMAKE= ${NXBENV} ${MAKE} \
1863 LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \
1864 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1865 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1866 MK_GDB=no MK_TESTS=no \
1868 MK_HTML=no NO_LINT=yes MK_MAN=no \
1869 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1870 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1871 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1872 MK_LLDB=no MK_DEBUG_FILES=no
1874 # native-xtools is the current target for qemu-user cross builds of ports
1875 # via poudriere and the imgact_binmisc kernel module.
1876 # For non-clang enabled targets that are still using the in tree gcc
1877 # we must build a gperf binary for one instance of its Makefiles. On
1878 # clang-enabled systems, the gperf binary is obsolete.
1879 native-xtools: .PHONY
1880 .if ${MK_GCC_BOOTSTRAP} != "no"
1881 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1882 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \
1883 cd ${.CURDIR}/${_gperf}; \
1884 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1885 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1886 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1888 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1889 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1890 -p ${NXBDESTDIR}/usr >/dev/null
1891 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1892 -p ${NXBDESTDIR}/usr/include >/dev/null
1893 .if ${MK_DEBUG_FILES} != "no"
1894 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1895 -p ${NXBDESTDIR}/usr/lib >/dev/null
1956 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1957 cd ${.CURDIR}/${_tool}; \
1958 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1959 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1960 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1964 # hierarchy - ensure that all the needed directories are present
1966 hierarchy hier: .MAKE .PHONY
1967 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1970 # libraries - build all libraries, and install them under ${DESTDIR}.
1972 # The list of libraries with dependents (${_prebuild_libs}) and their
1973 # interdependencies (__L) are built automatically by the
1974 # ${.CURDIR}/tools/make_libdeps.sh script.
1976 libraries: .MAKE .PHONY
1977 ${_+_}cd ${.CURDIR}; \
1978 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1979 ${MAKE} -f Makefile.inc1 _startup_libs; \
1980 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1981 ${MAKE} -f Makefile.inc1 _generic_libs
1984 # static libgcc.a prerequisite for shared libc
1986 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1988 # These dependencies are not automatically generated:
1990 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1991 # all shared libraries for ELF.
1993 _startup_libs= gnu/lib/csu
1994 _startup_libs+= lib/csu
1995 _startup_libs+= gnu/lib/libgcc
1996 _startup_libs+= lib/libcompiler_rt
1997 _startup_libs+= lib/libc
1998 _startup_libs+= lib/libc_nonshared
1999 .if ${MK_LIBCPLUSPLUS} != "no"
2000 _startup_libs+= lib/libcxxrt
2003 gnu/lib/libgcc__L: lib/libc__L
2004 gnu/lib/libgcc__L: lib/libc_nonshared__L
2005 .if ${MK_LIBCPLUSPLUS} != "no"
2006 lib/libcxxrt__L: gnu/lib/libgcc__L
2009 _prebuild_libs= ${_kerberos5_lib_libasn1} \
2010 ${_kerberos5_lib_libhdb} \
2011 ${_kerberos5_lib_libheimbase} \
2012 ${_kerberos5_lib_libheimntlm} \
2014 ${_kerberos5_lib_libheimipcc} \
2015 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
2016 ${_kerberos5_lib_libroken} \
2017 ${_kerberos5_lib_libwind} \
2018 lib/libbz2 ${_libcom_err} lib/libcrypt \
2019 lib/libelf lib/libexpat \
2022 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
2024 lib/ncurses/ncurses lib/ncurses/ncursesw \
2025 lib/libopie lib/libpam/libpam ${_lib_libthr} \
2026 ${_lib_libradius} lib/libsbuf lib/libtacplus \
2028 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
2029 ${_cddl_lib_libuutil} \
2030 ${_cddl_lib_libavl} \
2031 ${_cddl_lib_libzfs_core} \
2032 ${_cddl_lib_libctf} \
2033 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
2034 ${_secure_lib_libcrypto} ${_lib_libldns} \
2035 ${_secure_lib_libssh} ${_secure_lib_libssl} \
2038 .if ${MK_GNUCXX} != "no"
2039 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
2040 gnu/lib/libstdc++__L: lib/msun__L
2041 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
2044 .if ${MK_LIBCPLUSPLUS} != "no"
2045 _prebuild_libs+= lib/libc++
2048 lib/libgeom__L: lib/libexpat__L
2049 lib/libkvm__L: lib/libelf__L
2051 .if ${MK_LIBTHR} != "no"
2052 _lib_libthr= lib/libthr
2055 .if ${MK_RADIUS_SUPPORT} != "no"
2056 _lib_libradius= lib/libradius
2059 .if ${MK_OFED} != "no"
2060 _ofed_lib= contrib/ofed/usr.lib
2061 _prebuild_libs+= contrib/ofed/usr.lib/libosmcomp
2062 _prebuild_libs+= contrib/ofed/usr.lib/libopensm
2063 _prebuild_libs+= contrib/ofed/usr.lib/libibcommon
2064 _prebuild_libs+= contrib/ofed/usr.lib/libibverbs
2065 _prebuild_libs+= contrib/ofed/usr.lib/libibumad
2067 contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
2068 contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
2069 contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
2072 .if ${MK_CASPER} != "no"
2073 _lib_casper= lib/libcasper
2076 lib/libpjdlog__L: lib/libutil__L
2077 lib/libcasper__L: lib/libnv__L
2078 lib/liblzma__L: lib/libthr__L
2080 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
2081 .for _DIR in ${LOCAL_LIB_DIRS}
2082 .if exists(${.CURDIR}/${_DIR}/Makefile) && empty(_generic_libs:M${_DIR})
2083 _generic_libs+= ${_DIR}
2087 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2089 .if ${MK_CDDL} != "no"
2090 _cddl_lib_libumem= cddl/lib/libumem
2091 _cddl_lib_libnvpair= cddl/lib/libnvpair
2092 _cddl_lib_libavl= cddl/lib/libavl
2093 _cddl_lib_libuutil= cddl/lib/libuutil
2094 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2095 _cddl_lib_libctf= cddl/lib/libctf
2097 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2098 cddl/lib/libzfs__L: lib/libgeom__L
2099 cddl/lib/libctf__L: lib/libz__L
2101 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
2102 # on select architectures though (see cddl/lib/Makefile)
2103 .if ${MACHINE_CPUARCH} != "sparc64"
2104 _prebuild_libs+= lib/libprocstat lib/libproc lib/librtld_db
2105 lib/libprocstat__L: lib/libelf__L lib/libkvm__L lib/libutil__L
2106 lib/libproc__L: lib/libprocstat__L
2107 lib/librtld_db__L: lib/libprocstat__L
2110 .if ${MK_CRYPT} != "no"
2111 .if ${MK_OPENSSL} != "no"
2112 _secure_lib_libcrypto= secure/lib/libcrypto
2113 _secure_lib_libssl= secure/lib/libssl
2114 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2115 .if ${MK_LDNS} != "no"
2116 _lib_libldns= lib/libldns
2117 lib/libldns__L: secure/lib/libcrypto__L
2119 .if ${MK_OPENSSH} != "no"
2120 _secure_lib_libssh= secure/lib/libssh
2121 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2122 .if ${MK_LDNS} != "no"
2123 secure/lib/libssh__L: lib/libldns__L
2125 .if ${MK_KERBEROS_SUPPORT} != "no"
2126 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2127 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2128 lib/libmd__L kerberos5/lib/libroken__L
2132 _secure_lib= secure/lib
2135 .if ${MK_KERBEROS} != "no"
2136 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2137 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2138 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2139 kerberos5/lib/libwind__L lib/libsqlite3__L
2140 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2141 kerberos5/lib/libroken__L lib/libcom_err__L
2142 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2143 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2144 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2145 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2146 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2147 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2148 kerberos5/lib/libroken__L: lib/libcrypt__L
2149 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2150 kerberos5/lib/libheimbase__L: lib/libthr__L
2151 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2154 lib/libsqlite3__L: lib/libthr__L
2156 .if ${MK_GSSAPI} != "no"
2157 _lib_libgssapi= lib/libgssapi
2160 .if ${MK_KERBEROS} != "no"
2161 _kerberos5_lib= kerberos5/lib
2162 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2163 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2164 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2165 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2166 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2167 _kerberos5_lib_libroken= kerberos5/lib/libroken
2168 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2169 _libsqlite3= lib/libsqlite3
2170 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2171 _kerberos5_lib_libwind= kerberos5/lib/libwind
2172 _libcom_err= lib/libcom_err
2175 .if ${MK_NIS} != "no"
2176 _lib_libypclnt= lib/libypclnt
2179 .if ${MK_OPENSSL} == "no"
2180 lib/libradius__L: lib/libmd__L
2184 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2185 .if ${MK_CXX} != "no"
2186 .if ${MK_LIBCPLUSPLUS} != "no"
2187 lib/libproc__L: lib/libcxxrt__L
2188 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2189 lib/libproc__L: gnu/lib/libsupc++__L
2193 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2195 .for _lib in ${_prereq_libs}
2196 ${_lib}__PL: .PHONY .MAKE
2197 .if exists(${.CURDIR}/${_lib})
2198 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2199 cd ${.CURDIR}/${_lib}; \
2200 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2201 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2202 DIRPRFX=${_lib}/ all; \
2203 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2204 DIRPRFX=${_lib}/ install
2208 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
2209 ${_lib}__L: .PHONY .MAKE
2210 .if exists(${.CURDIR}/${_lib})
2211 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2212 cd ${.CURDIR}/${_lib}; \
2213 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2214 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2215 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2219 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2220 _startup_libs: ${_startup_libs:S/$/__L/}
2221 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2222 _generic_libs: ${_generic_libs:S/$/__L/}
2224 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2225 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2226 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2227 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2228 # parallel. This is safe for the world stage of buildworld though since it has
2229 # already built libraries in a proper order and installed includes into
2230 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2231 # avoid trashing a system if it crashes mid-install.
2232 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2236 .include <bsd.subdir.mk>
2238 .if make(check-old) || make(check-old-dirs) || \
2239 make(check-old-files) || make(check-old-libs) || \
2240 make(delete-old) || make(delete-old-dirs) || \
2241 make(delete-old-files) || make(delete-old-libs)
2244 # check for / delete old files section
2247 .include "ObsoleteFiles.inc"
2249 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2250 else you can not start such an application. Consult UPDATING for more \
2251 information regarding how to cope with the removal/revision bump of a \
2254 .if !defined(BATCH_DELETE_OLD_FILES)
2260 delete-old-files: .PHONY
2261 @echo ">>> Removing old files (only deletes safe to delete libs)"
2262 # Ask for every old file if the user really wants to remove it.
2263 # It's annoying, but better safe than sorry.
2264 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2265 # argument list will get too long. Using .for/.endfor make "loops" will make
2266 # the Makefile parser segfault.
2269 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2270 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2271 while read file; do \
2272 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2273 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2274 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2276 for ext in debug symbols; do \
2277 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2278 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2279 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2284 # Remove catpages without corresponding manpages.
2286 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2287 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2288 while read catpage; do \
2290 if [ ! -e "$${manpage}" ]; then \
2291 rm ${RM_I} $${catpage} <&3; \
2294 @echo ">>> Old files removed"
2296 check-old-files: .PHONY
2297 @echo ">>> Checking for old files"
2299 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2300 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2301 while read file; do \
2302 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2303 echo "${DESTDIR}/$${file}"; \
2305 for ext in debug symbols; do \
2306 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2307 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2311 # Check for catpages without corresponding manpages.
2312 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2313 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2314 while read catpage; do \
2316 if [ ! -e "$${manpage}" ]; then \
2321 delete-old-libs: .PHONY
2322 @echo ">>> Removing old libraries"
2323 @echo "${OLD_LIBS_MESSAGE}" | fmt
2326 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2327 -V OLD_LIBS | xargs -n1 | \
2328 while read file; do \
2329 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2330 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2331 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2333 for ext in debug symbols; do \
2334 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2335 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2336 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2341 @echo ">>> Old libraries removed"
2343 check-old-libs: .PHONY
2344 @echo ">>> Checking for old libraries"
2346 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2347 -V OLD_LIBS | xargs -n1 | \
2348 while read file; do \
2349 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2350 echo "${DESTDIR}/$${file}"; \
2352 for ext in debug symbols; do \
2353 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2354 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2359 delete-old-dirs: .PHONY
2360 @echo ">>> Removing old directories"
2362 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2363 -V OLD_DIRS | xargs -n1 | sort -r | \
2364 while read dir; do \
2365 if [ -d "${DESTDIR}/$${dir}" ]; then \
2366 rmdir -v "${DESTDIR}/$${dir}" || true; \
2367 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2368 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2371 @echo ">>> Old directories removed"
2373 check-old-dirs: .PHONY
2374 @echo ">>> Checking for old directories"
2376 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2377 -V OLD_DIRS | xargs -n1 | \
2378 while read dir; do \
2379 if [ -d "${DESTDIR}/$${dir}" ]; then \
2380 echo "${DESTDIR}/$${dir}"; \
2381 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2382 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2386 delete-old: delete-old-files delete-old-dirs .PHONY
2387 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2389 check-old: check-old-files check-old-libs check-old-dirs .PHONY
2390 @echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
2391 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2396 # showconfig - show build configuration.
2399 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2400 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2402 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2403 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2405 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2406 .if exists(${KERNCONFDIR}/${KERNCONF})
2407 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2408 '${KERNCONFDIR}/${KERNCONF}' ; echo
2414 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2415 DTBOUTPUTPATH= ${.CURDIR}
2419 # Build 'standalone' Device Tree Blob
2422 @PATH=${TMPPATH} MACHINE=${TARGET} \
2423 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2424 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2429 # In the following, the first 'rm' in a series will usually remove all
2430 # files and directories. If it does not, then there are probably some
2431 # files with file flags set, so this unsets them and tries the 'rm' a
2432 # second time. There are situations where this target will be cleaning
2433 # some directories via more than one method, but that duplication is
2434 # needed to correctly handle all the possible situations. Removing all
2435 # files without file flags set in the first 'rm' instance saves time,
2436 # because 'chflags' will need to operate on fewer files afterwards.
2438 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2439 # created by bsd.obj.mk, except that we don't want to .include that file
2442 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2444 .if exists(${BW_CANONICALOBJDIR}/)
2445 -rm -rf ${BW_CANONICALOBJDIR}/*
2446 -chflags -R 0 ${BW_CANONICALOBJDIR}
2447 rm -rf ${BW_CANONICALOBJDIR}/*
2449 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2450 # To be safe in this case, fall back to a 'make cleandir'
2451 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2454 .if defined(TARGET) && defined(TARGET_ARCH)
2456 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2457 XDEV_CPUTYPE?=${CPUTYPE}
2459 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2462 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2463 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2464 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2465 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2466 CPUTYPE=${XDEV_CPUTYPE}
2468 XDDIR=${TARGET_ARCH}-freebsd
2471 .error XDTP variable should be an absolute path
2474 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2475 INSTALL="sh ${.CURDIR}/tools/install.sh"
2477 TOOLS_PREFIX=${XDTP}
2478 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2479 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2480 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2481 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2482 CPP="${CPP} ${CD2CFLAGS}" \
2483 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2485 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2486 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2487 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2488 XDDESTDIR=${DESTDIR}/${XDTP}
2490 OSREL!= uname -r | sed -e 's/[-(].*//'
2493 .ORDER: xdev-build xdev-install xdev-links
2494 xdev: xdev-build xdev-install .PHONY
2496 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2497 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
2499 _xb-worldtmp: .PHONY
2500 mkdir -p ${CDTMP}/usr
2501 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2502 -p ${CDTMP}/usr >/dev/null
2504 _xb-bootstrap-tools: .PHONY
2508 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2509 cd ${.CURDIR}/${_tool}; \
2510 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2511 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2512 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2515 _xb-build-tools: .PHONY
2516 ${_+_}@cd ${.CURDIR}; \
2517 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2519 _xb-cross-tools: .PHONY
2527 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2528 cd ${.CURDIR}/${_tool}; \
2529 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2530 ${CDMAKE} DIRPRFX=${_tool}/ all
2534 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2535 mkdir -p ${XDDESTDIR}
2536 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2537 -p ${XDDESTDIR} >/dev/null
2538 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2539 -p ${XDDESTDIR}/usr >/dev/null
2540 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2541 -p ${XDDESTDIR}/usr/include >/dev/null
2542 .if defined(LIBCOMPAT)
2543 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2544 -p ${XDDESTDIR}/usr >/dev/null
2546 .if ${MK_TESTS} != "no"
2547 mkdir -p ${XDDESTDIR}${TESTSBASE}
2548 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2549 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2552 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2553 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
2555 _xi-cross-tools: .PHONY
2556 @echo "_xi-cross-tools"
2564 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2565 cd ${.CURDIR}/${_tool}; \
2566 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2569 _xi-includes: .PHONY
2570 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2571 DESTDIR=${XDDESTDIR}
2573 _xi-libraries: .PHONY
2574 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2575 DESTDIR=${XDDESTDIR}
2578 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2579 mkdir -p ../../../../usr/bin; \
2581 ln -sf ../../${XDTP}/usr/bin/$$i \
2582 ../../../../usr/bin/${XDDIR}-$$i; \
2583 ln -sf ../../${XDTP}/usr/bin/$$i \
2584 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2587 xdev xdev-build xdev-install xdev-links: .PHONY
2588 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"