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 riscv64 builds, for example, to automatically use the
171 # riscv64-binutils port or package.
172 .if !make(showconfig)
173 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
174 ${MK_LLD_BOOTSTRAP} == "no" && \
175 !defined(CROSS_BINUTILS_PREFIX)
176 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
177 .if !exists(${CROSS_BINUTILS_PREFIX})
178 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
182 XBINUTILS= AS AR LD NM OBJCOPY RANLIB SIZE STRINGS
183 .for BINUTIL in ${XBINUTILS}
184 .if defined(CROSS_BINUTILS_PREFIX) && \
185 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
186 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
188 X${BINUTIL}?= ${${BINUTIL}}
193 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
194 # keep the users system reasonably usable. For static->dynamic root upgrades,
195 # we don't want to install a dynamic binary without rtld and the needed
196 # libraries. More commonly, for dynamic root, we don't want to install a
197 # binary that requires a newer library version that hasn't been installed yet.
198 # This ordering is not a guarantee though. The only guarantee of a working
199 # system here would require fine-grained ordering of all components based
200 # on their dependencies.
201 .if !empty(SUBDIR_OVERRIDE)
202 SUBDIR= ${SUBDIR_OVERRIDE}
205 .if !defined(NO_ROOT) && (make(installworld) || make(install))
206 # Ensure libraries are installed before progressing.
210 .if ${MK_CDDL} != "no"
214 .if ${MK_KERBEROS} != "no"
217 .if ${MK_RESCUE} != "no"
221 .if ${MK_CRYPT} != "no"
224 .if !defined(NO_SHARE)
227 SUBDIR+=sys usr.bin usr.sbin
228 .if ${MK_TESTS} != "no"
231 .if ${MK_OFED} != "no"
235 # Local directories are last, since it is nice to at least get the base
236 # system rebuilt before you do them.
237 .for _DIR in ${LOCAL_DIRS}
238 .if exists(${.CURDIR}/${_DIR}/Makefile)
242 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
243 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
244 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
245 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
246 _REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
248 .for _DIR in ${LOCAL_LIB_DIRS}
249 .if empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
254 # We must do etc/ last as it hooks into building the man whatis file
255 # by calling 'makedb' in share/man. This is only relevant for
256 # install/distribute so they build the whatis file after every manpage is
258 .if make(installworld) || make(install)
263 .endif # !empty(SUBDIR_OVERRIDE)
266 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
269 .if defined(NO_CLEANDIR)
270 CLEANDIR= clean cleandepend
275 .if ${MK_META_MODE} == "yes"
276 # If filemon is used then we can rely on the build being incremental-safe.
277 # The .meta files will also track the build command and rebuild should
279 .if empty(.MAKE.MODE:Mnofilemon)
285 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
287 .if empty(SHELL:M*csh*)
288 BUILDENV_SHELL?=${SHELL}
290 BUILDENV_SHELL?=/bin/sh
293 .if !defined(SVN) || empty(SVN)
294 . for _P in /usr/bin /usr/local/bin
295 . for _S in svn svnlite
296 . if exists(${_P}/${_S})
304 MAKEOBJDIRPREFIX?= /usr/obj
305 .if !defined(OSRELDATE)
306 .if exists(/usr/include/osreldate.h)
307 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
308 /usr/include/osreldate.h
315 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
316 .if !defined(_REVISION)
317 _REVISION!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V REVISION
320 .if !defined(_BRANCH)
321 _BRANCH!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V BRANCH
324 .if !defined(SRCRELDATE)
325 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
326 ${SRCDIR}/sys/sys/param.h
329 .if !defined(VERSION)
330 VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
334 .if !defined(PKG_VERSION)
335 .if ${_BRANCH:MSTABLE*} || ${_BRANCH:MCURRENT*} || ${_BRANCH:MALPHA*}
336 TIMENOW= %Y%m%d%H%M%S
337 EXTRA_REVISION= .s${TIMENOW:gmtime}
340 EXTRA_REVISION= _${_BRANCH:C/.*-p([0-9]+$)/\1/}
342 PKG_VERSION= ${_REVISION}${EXTRA_REVISION}
345 KNOWN_ARCHES?= aarch64/arm64 \
368 .if ${TARGET} == ${TARGET_ARCH}
371 _t= ${TARGET_ARCH}/${TARGET}
374 .if empty(KNOWN_ARCHES:M${_t})
375 .error Unknown target ${TARGET_ARCH}:${TARGET}.
379 .if ${TARGET} == ${MACHINE}
380 TARGET_CPUTYPE?=${CPUTYPE}
385 .if !empty(TARGET_CPUTYPE)
386 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
388 _TARGET_CPUTYPE=dummy
390 _CPUTYPE!= MK_AUTO_OBJ=no MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
391 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
392 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
393 .error CPUTYPE global should be set with ?=.
396 BUILD_ARCH!= uname -p
397 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
398 .error To cross-build, set TARGET_ARCH.
401 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
402 OBJTREE= ${MAKEOBJDIRPREFIX}
404 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
406 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
407 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
408 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
409 STRICTTMPPATH= ${BPATH}:${XPATH}
410 TMPPATH= ${STRICTTMPPATH}:${PATH}
413 # Avoid running mktemp(1) unless actually needed.
414 # It may not be functional, e.g., due to new ABI
415 # when in the middle of installing over this system.
417 .if make(distributeworld) || make(installworld) || make(stageworld)
418 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
421 .if make(stagekernel) || make(distributekernel)
427 # Building a world goes through the following stages
429 # 1. legacy stage [BMAKE]
430 # This stage is responsible for creating compatibility
431 # shims that are needed by the bootstrap-tools,
432 # build-tools and cross-tools stages. These are generally
433 # APIs that tools from one of those three stages need to
434 # build that aren't present on the host.
435 # 1. bootstrap-tools stage [BMAKE]
436 # This stage is responsible for creating programs that
437 # are needed for backward compatibility reasons. They
438 # are not built as cross-tools.
439 # 2. build-tools stage [TMAKE]
440 # This stage is responsible for creating the object
441 # tree and building any tools that are needed during
442 # the build process. Some programs are listed during
443 # this phase because they build binaries to generate
444 # files needed to build these programs. This stage also
445 # builds the 'build-tools' target rather than 'all'.
446 # 3. cross-tools stage [XMAKE]
447 # This stage is responsible for creating any tools that
448 # are needed for building the system. A cross-compiler is one
449 # of them. This differs from build tools in two ways:
450 # 1. the 'all' target is built rather than 'build-tools'
451 # 2. these tools are installed into TMPPATH for stage 4.
452 # 4. world stage [WMAKE]
453 # This stage actually builds the world.
454 # 5. install stage (optional) [IMAKE]
455 # This stage installs a previously built world.
459 # Keep these in sync -- see below for special case exception
460 MINIMUM_SUPPORTED_OSREL?= 900044
461 MINIMUM_SUPPORTED_REL?= 9.1
463 # Common environment for world related stages
464 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
465 MACHINE_ARCH=${TARGET_ARCH} \
467 CPUTYPE=${TARGET_CPUTYPE}
468 .if ${MK_META_MODE} != "no"
469 # Don't rebuild build-tools targets during normal build.
470 CROSSENV+= BUILD_TOOLS_META=.NOMETA
472 .if ${MK_GROFF} != "no"
473 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
474 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
475 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
477 .if defined(TARGET_CFLAGS)
478 CROSSENV+= ${TARGET_CFLAGS}
481 # bootstrap-tools stage
482 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
483 TOOLS_PREFIX=${WORLDTMP} \
484 PATH=${BPATH}:${PATH} \
485 WORLDTMP=${WORLDTMP} \
486 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
487 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
489 BOOTSTRAPPING=${OSRELDATE} \
491 MK_HTML=no NO_LINT=yes MK_MAN=no \
492 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
493 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
494 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
495 MK_LLDB=no MK_TESTS=no \
498 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
499 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
503 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
504 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
505 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
507 BOOTSTRAPPING=${OSRELDATE} \
510 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
511 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
512 MK_LLDB=no MK_TESTS=no
515 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
516 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
517 MK_GDB=no MK_TESTS=no
520 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
521 PATH=${BPATH}:${PATH} \
523 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
524 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
526 BOOTSTRAPPING=${OSRELDATE} \
528 MK_HTML=no -DNO_LINT MK_MAN=no \
529 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
530 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
533 WMAKEENV= ${CROSSENV} \
534 INSTALL="sh ${.CURDIR}/tools/install.sh" \
538 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
540 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
543 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
544 CPP="${XCPP} ${XCFLAGS}" \
545 AS="${XAS}" AR="${XAR}" LD="${XLD}" LLVM_LINK="${XLLVM_LINK}" \
546 NM=${XNM} OBJCOPY="${XOBJCOPY}" \
547 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
550 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
551 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
552 # directory, but the compiler will look in the right place for its
553 # tools so we don't need to tell it where to look.
554 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
558 # The internal bootstrap compiler has a default sysroot set by TOOLS_PREFIX
559 # and target set by TARGET/TARGET_ARCH. However, there are several needs to
560 # always pass an explicit --sysroot and -target.
561 # - External compiler needs sysroot and target flags.
562 # - External ld needs sysroot.
563 # - To be clear about the use of a sysroot when using the internal compiler.
564 # - Easier debugging.
565 # - Allowing WITH_SYSTEM_COMPILER+WITH_META_MODE to work together due to
566 # the flip-flopping build command when sometimes using external and
567 # sometimes using internal.
568 # - Allow using lld which has no support for default paths.
569 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
570 BFLAGS+= -B${WORLDTMP}/usr/bin
572 .if ${TARGET} == "arm"
573 .if ${TARGET_ARCH:Marmv6*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
574 TARGET_ABI= gnueabihf
579 .if ${WANT_COMPILER_TYPE} == gcc || \
580 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
581 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
582 # won't set header path and -L is used to ensure the base library path
583 # is added before the port PREFIX library path.
584 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
585 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
586 # combined with --sysroot.
587 XCFLAGS+= -B${WORLDTMP}/usr/lib
588 # Force using libc++ for external GCC.
589 # XXX: This should be checking MK_GNUCXX == no
590 .if ${X_COMPILER_VERSION} >= 40800
591 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
594 .elif ${WANT_COMPILER_TYPE} == clang || \
595 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang)
597 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd12.0
598 XCFLAGS+= -target ${TARGET_TRIPLE}
600 XCFLAGS+= --sysroot=${WORLDTMP}
606 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
607 ${TARGET_ARCH} == "powerpc64") || ${TARGET_ARCH:Mmips64*} != ""
609 .include "Makefile.libcompat"
610 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH} == "armv6"
612 .include "Makefile.libcompat"
615 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
617 IMAKEENV= ${CROSSENV}
618 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
619 ${IMAKE_INSTALL} ${IMAKE_MTREE}
620 .if empty(.MAKEFLAGS:M-n)
621 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
622 LD_LIBRARY_PATH=${INSTALLTMP} \
623 PATH_LOCALE=${INSTALLTMP}/locale
624 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
626 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
628 .if defined(DB_FROM_SRC)
629 INSTALLFLAGS+= -N ${.CURDIR}/etc
630 MTREEFLAGS+= -N ${.CURDIR}/etc
632 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
633 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
635 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
636 IMAKE+= -DNO_ROOT METALOG=${METALOG}
637 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
640 .if defined(BUILD_PKGS)
641 INSTALLFLAGS+= -h sha256
643 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
644 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
645 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
649 KMAKEENV= ${WMAKEENV}
650 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
655 # Attempt to rebuild the entire system, with reasonable chance of
656 # success, regardless of how old your existing system is.
659 .if ${.CURDIR:C/[^,]//g} != ""
660 # The m4 build of sendmail files doesn't like it if ',' is used
661 # anywhere in the path of it's files.
663 @echo "*** Error: path to source tree contains a comma ','"
668 @echo "--------------------------------------------------------------"
669 @echo ">>> Rebuilding the temporary build tree"
670 @echo "--------------------------------------------------------------"
671 .if !defined(NO_CLEAN)
673 .if defined(LIBCOMPAT)
674 rm -rf ${LIBCOMPATTMP}
677 rm -rf ${WORLDTMP}/legacy/usr/include
680 lib lib/casper usr legacy/bin legacy/usr
681 mkdir -p ${WORLDTMP}/${_dir}
683 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
684 -p ${WORLDTMP}/legacy/usr >/dev/null
685 .if ${MK_GROFF} != "no"
686 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
687 -p ${WORLDTMP}/legacy/usr >/dev/null
689 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
690 -p ${WORLDTMP}/legacy/usr/include >/dev/null
691 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
692 -p ${WORLDTMP}/usr >/dev/null
693 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
694 -p ${WORLDTMP}/usr/include >/dev/null
695 ln -sf ${.CURDIR}/sys ${WORLDTMP}
696 .if ${MK_DEBUG_FILES} != "no"
697 # We could instead disable debug files for these build stages
698 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
699 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
700 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
701 -p ${WORLDTMP}/usr/lib >/dev/null
703 .if defined(LIBCOMPAT)
704 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
705 -p ${WORLDTMP}/usr >/dev/null
706 .if ${MK_DEBUG_FILES} != "no"
707 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
708 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
709 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
710 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
713 .if ${MK_TESTS} != "no"
714 mkdir -p ${WORLDTMP}${TESTSBASE}
715 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
716 -p ${WORLDTMP}${TESTSBASE} >/dev/null
717 .if ${MK_DEBUG_FILES} != "no"
718 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
719 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
720 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
723 .for _mtree in ${LOCAL_MTREE}
724 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
728 @echo "--------------------------------------------------------------"
729 @echo ">>> stage 1.1: legacy release compatibility shims"
730 @echo "--------------------------------------------------------------"
731 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
734 @echo "--------------------------------------------------------------"
735 @echo ">>> stage 1.2: bootstrap tools"
736 @echo "--------------------------------------------------------------"
737 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
739 .if !defined(NO_CLEAN)
741 @echo "--------------------------------------------------------------"
742 @echo ">>> stage 2.1: cleaning up the object tree"
743 @echo "--------------------------------------------------------------"
744 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
745 .if defined(LIBCOMPAT)
746 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
751 @echo "--------------------------------------------------------------"
752 @echo ">>> stage 2.2: rebuilding the object tree"
753 @echo "--------------------------------------------------------------"
754 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
757 @echo "--------------------------------------------------------------"
758 @echo ">>> stage 2.3: build tools"
759 @echo "--------------------------------------------------------------"
760 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
763 @echo "--------------------------------------------------------------"
764 @echo ">>> stage 3: cross tools"
765 @echo "--------------------------------------------------------------"
766 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
767 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
770 @echo "--------------------------------------------------------------"
771 @echo ">>> stage 4.1: building includes"
772 @echo "--------------------------------------------------------------"
773 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
774 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
775 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
776 MK_INCLUDES=yes includes
777 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
778 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
782 @echo "--------------------------------------------------------------"
783 @echo ">>> stage 4.2: building libraries"
784 @echo "--------------------------------------------------------------"
785 ${_+_}cd ${.CURDIR}; \
786 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
787 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
790 @echo "--------------------------------------------------------------"
791 @echo ">>> stage 4.3: building everything"
792 @echo "--------------------------------------------------------------"
793 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
796 WMAKE_TGTS+= _worldtmp _legacy
797 .if empty(SUBDIR_OVERRIDE)
798 WMAKE_TGTS+= _bootstrap-tools
800 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
801 WMAKE_TGTS+= _includes _libraries
802 WMAKE_TGTS+= everything
803 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
804 WMAKE_TGTS+= build${libcompat}
807 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
808 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
810 buildworld_prologue: .PHONY
811 @echo "--------------------------------------------------------------"
812 @echo ">>> World build started on `LC_ALL=C date`"
813 @echo "--------------------------------------------------------------"
815 buildworld_epilogue: .PHONY
817 @echo "--------------------------------------------------------------"
818 @echo ">>> World build completed on `LC_ALL=C date`"
819 @echo "--------------------------------------------------------------"
822 # We need to have this as a target because the indirection between Makefile
823 # and Makefile.inc1 causes the correct PATH to be used, rather than a
824 # modification of the current environment's PATH. In addition, we need
825 # to quote multiword values.
828 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
830 .if ${.TARGETS:Mbuildenv}
831 .if ${.MAKEFLAGS:M-j}
832 .error The buildenv target is incompatible with -j
835 BUILDENV_DIR?= ${.CURDIR}
837 @echo Entering world for ${TARGET_ARCH}:${TARGET}
838 .if ${BUILDENV_SHELL:M*zsh*}
839 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
841 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
844 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
845 toolchain: ${TOOLCHAIN_TGTS} .PHONY
846 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries} .PHONY
851 # Checks to be sure system is ready for installworld/installkernel.
853 installcheck: _installcheck_world _installcheck_kernel .PHONY
854 _installcheck_world: .PHONY
855 _installcheck_kernel: .PHONY
858 # Require DESTDIR to be set if installing for a different architecture or
859 # using the user/group database in the source tree.
861 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
863 .if !make(distributeworld)
864 _installcheck_world: __installcheck_DESTDIR
865 _installcheck_kernel: __installcheck_DESTDIR
866 __installcheck_DESTDIR: .PHONY
867 .if !defined(DESTDIR) || empty(DESTDIR)
868 @echo "ERROR: Please set DESTDIR!"; \
874 .if !defined(DB_FROM_SRC)
876 # Check for missing UIDs/GIDs.
878 CHECK_UIDS= auditdistd
880 .if ${MK_SENDMAIL} != "no"
886 CHECK_GIDS+= proxy authpf
888 .if ${MK_UNBOUND} != "no"
892 _installcheck_world: __installcheck_UGID
893 __installcheck_UGID: .PHONY
894 .for uid in ${CHECK_UIDS}
895 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
896 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
900 .for gid in ${CHECK_GIDS}
901 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
902 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
909 # Required install tools to be saved in a scratch dir for safety.
911 .if ${MK_ZONEINFO} != "no"
912 _zoneinfo= zic tzsetup
915 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
916 date echo egrep find grep id install ${_install-info} \
917 ln make mkdir mtree mv pwd_mkdb \
918 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
921 # Needed for share/man
922 .if ${MK_MAN_UTILS} != "no"
929 # Distributes everything compiled by a `buildworld'.
933 # Installs everything compiled by a 'buildworld'.
936 # Non-base distributions produced by the base system
937 EXTRA_DISTRIBUTIONS= doc
938 .if defined(LIBCOMPAT)
939 EXTRA_DISTRIBUTIONS+= lib${libcompat}
941 .if ${MK_TESTS} != "no"
942 EXTRA_DISTRIBUTIONS+= tests
946 .if ${MK_DEBUG_FILES} != "no"
947 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
950 MTREE_MAGIC?= mtree 2.0
952 distributeworld installworld stageworld: _installcheck_world .PHONY
953 mkdir -p ${INSTALLTMP}
954 progs=$$(for prog in ${ITOOLS}; do \
955 if progpath=`which $$prog`; then \
958 echo "Required tool $$prog not found in PATH." >&2; \
962 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
963 while read line; do \
965 if [ "$$2 $$3" != "not found" ]; then \
968 echo "Required library $$1 not found." >&2; \
972 cp $$libs $$progs ${INSTALLTMP}
973 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
975 -mkdir -p ${METALOG:H}
976 echo "#${MTREE_MAGIC}" > ${METALOG}
978 .if make(distributeworld)
979 .for dist in ${EXTRA_DISTRIBUTIONS}
980 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
981 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
982 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
983 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
984 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
985 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
986 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
987 .if ${MK_DEBUG_FILES} != "no"
988 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
989 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
991 .if defined(LIBCOMPAT)
992 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
993 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
994 .if ${MK_DEBUG_FILES} != "no"
995 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
996 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
999 .if ${MK_TESTS} != "no" && ${dist} == "tests"
1000 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
1001 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1002 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
1003 .if ${MK_DEBUG_FILES} != "no"
1004 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1005 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
1008 .if defined(NO_ROOT)
1009 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1010 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1011 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1012 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1013 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1014 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1015 .if defined(LIBCOMPAT)
1016 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
1017 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1021 -mkdir ${DESTDIR}/${DISTDIR}/base
1022 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1023 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1024 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1025 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1027 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1028 ${IMAKEENV} rm -rf ${INSTALLTMP}
1029 .if make(distributeworld)
1030 .for dist in ${EXTRA_DISTRIBUTIONS}
1031 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete
1033 .if defined(NO_ROOT)
1034 .for dist in base ${EXTRA_DISTRIBUTIONS}
1035 @# For each file that exists in this dist, print the corresponding
1036 @# line from the METALOG. This relies on the fact that
1037 @# a line containing only the filename will sort immediately before
1038 @# the relevant mtree line.
1039 cd ${DESTDIR}/${DISTDIR}; \
1040 find ./${dist} | sort -u ${METALOG} - | \
1041 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1042 ${DESTDIR}/${DISTDIR}/${dist}.meta
1044 .for dist in ${DEBUG_DISTRIBUTIONS}
1045 @# For each file that exists in this dist, print the corresponding
1046 @# line from the METALOG. This relies on the fact that
1047 @# a line containing only the filename will sort immediately before
1048 @# the relevant mtree line.
1049 cd ${DESTDIR}/${DISTDIR}; \
1050 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1051 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1052 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1057 packageworld: .PHONY
1058 .for dist in base ${EXTRA_DISTRIBUTIONS}
1059 .if defined(NO_ROOT)
1060 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1061 tar cvf - --exclude usr/lib/debug \
1062 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1063 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1065 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1066 tar cvf - --exclude usr/lib/debug . | \
1067 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1071 .for dist in ${DEBUG_DISTRIBUTIONS}
1072 . if defined(NO_ROOT)
1073 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1074 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1075 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1077 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1078 tar cvLf - usr/lib/debug | \
1079 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1086 # If you have a build server, you can NFS mount the source and obj directories
1087 # and do a 'make reinstall' on the *client* to install new binaries from the
1088 # most recent server build.
1090 restage reinstall: .MAKE .PHONY
1091 @echo "--------------------------------------------------------------"
1092 @echo ">>> Making hierarchy"
1093 @echo "--------------------------------------------------------------"
1094 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1095 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1097 @echo "--------------------------------------------------------------"
1098 @echo ">>> Making distribution"
1099 @echo "--------------------------------------------------------------"
1100 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1101 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
1104 @echo "--------------------------------------------------------------"
1105 @echo ">>> Installing everything"
1106 @echo "--------------------------------------------------------------"
1107 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1108 .if defined(LIBCOMPAT)
1109 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1112 redistribute: .MAKE .PHONY
1113 @echo "--------------------------------------------------------------"
1114 @echo ">>> Distributing everything"
1115 @echo "--------------------------------------------------------------"
1116 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1117 .if defined(LIBCOMPAT)
1118 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1119 DISTRIBUTION=lib${libcompat}
1122 distrib-dirs distribution: .MAKE .PHONY
1123 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1124 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1125 .if make(distribution)
1126 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1127 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1128 METALOG=${METALOG} MK_TESTS=no installconfig
1132 # buildkernel and installkernel
1134 # Which kernels to build and/or install is specified by setting
1135 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1136 # Only the existing (depending TARGET) config files are used
1137 # for building kernels and only the first of these is designated
1138 # as the one being installed.
1140 # Note that we have to use TARGET instead of TARGET_ARCH when
1141 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1142 # be set to cross-build, we have to make sure TARGET is set
1145 .if defined(KERNFAST)
1149 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1150 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1151 KERNCONF=${KERNFAST}
1154 .if ${TARGET_ARCH} == "powerpc64"
1155 KERNCONF?= GENERIC64
1159 INSTKERNNAME?= kernel
1161 KERNSRCDIR?= ${.CURDIR}/sys
1162 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1163 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1164 KERNCONFDIR?= ${KRNLCONFDIR}
1168 .if defined(NO_INSTALLKERNEL)
1169 # All of the BUILDKERNELS loops start at index 1.
1170 BUILDKERNELS+= dummy
1172 .for _kernel in ${KERNCONF}
1173 .if exists(${KERNCONFDIR}/${_kernel})
1174 BUILDKERNELS+= ${_kernel}
1175 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1176 INSTALLKERNEL= ${_kernel}
1181 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1186 # Builds all kernels defined by BUILDKERNELS.
1188 buildkernel: .MAKE .PHONY
1189 .if empty(BUILDKERNELS:Ndummy)
1190 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1194 .for _kernel in ${BUILDKERNELS:Ndummy}
1195 @echo "--------------------------------------------------------------"
1196 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1197 @echo "--------------------------------------------------------------"
1198 @echo "===> ${_kernel}"
1199 mkdir -p ${KRNLOBJDIR}
1200 .if !defined(NO_KERNELCONFIG)
1202 @echo "--------------------------------------------------------------"
1203 @echo ">>> stage 1: configuring the kernel"
1204 @echo "--------------------------------------------------------------"
1205 cd ${KRNLCONFDIR}; \
1207 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1208 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1210 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1212 @echo "--------------------------------------------------------------"
1213 @echo ">>> stage 2.1: cleaning up the object tree"
1214 @echo "--------------------------------------------------------------"
1215 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1217 .if !defined(NO_KERNELOBJ)
1219 @echo "--------------------------------------------------------------"
1220 @echo ">>> stage 2.2: rebuilding the object tree"
1221 @echo "--------------------------------------------------------------"
1222 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1225 @echo "--------------------------------------------------------------"
1226 @echo ">>> stage 2.3: build tools"
1227 @echo "--------------------------------------------------------------"
1228 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1230 @echo "--------------------------------------------------------------"
1231 @echo ">>> stage 3.1: building everything"
1232 @echo "--------------------------------------------------------------"
1233 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1234 @echo "--------------------------------------------------------------"
1235 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1236 @echo "--------------------------------------------------------------"
1239 NO_INSTALLEXTRAKERNELS?= yes
1242 # installkernel, etc.
1244 # Install the kernel defined by INSTALLKERNEL
1246 installkernel installkernel.debug \
1247 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1248 .if !defined(NO_INSTALLKERNEL)
1249 .if empty(INSTALLKERNEL)
1250 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1253 @echo "--------------------------------------------------------------"
1254 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1255 @echo "--------------------------------------------------------------"
1256 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1257 ${CROSSENV} PATH=${TMPPATH} \
1258 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1260 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1261 .for _kernel in ${BUILDKERNELS:[2..-1]}
1262 @echo "--------------------------------------------------------------"
1263 @echo ">>> Installing kernel ${_kernel}"
1264 @echo "--------------------------------------------------------------"
1265 cd ${KRNLOBJDIR}/${_kernel}; \
1266 ${CROSSENV} PATH=${TMPPATH} \
1267 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1271 distributekernel distributekernel.debug: .PHONY
1272 .if !defined(NO_INSTALLKERNEL)
1273 .if empty(INSTALLKERNEL)
1274 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1277 mkdir -p ${DESTDIR}/${DISTDIR}
1278 .if defined(NO_ROOT)
1279 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1281 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1282 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1283 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1284 DESTDIR=${INSTALL_DDIR}/kernel \
1285 ${.TARGET:S/distributekernel/install/}
1286 .if defined(NO_ROOT)
1287 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1288 ${DESTDIR}/${DISTDIR}/kernel.meta
1291 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1292 .for _kernel in ${BUILDKERNELS:[2..-1]}
1293 .if defined(NO_ROOT)
1294 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1296 cd ${KRNLOBJDIR}/${_kernel}; \
1297 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1298 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1299 KERNEL=${INSTKERNNAME}.${_kernel} \
1300 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1301 ${.TARGET:S/distributekernel/install/}
1302 .if defined(NO_ROOT)
1303 @sed -e "s|^./kernel.${_kernel}|.|" \
1304 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1305 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1310 packagekernel: .PHONY
1311 .if defined(NO_ROOT)
1312 .if !defined(NO_INSTALLKERNEL)
1313 cd ${DESTDIR}/${DISTDIR}/kernel; \
1314 tar cvf - --exclude '*.debug' \
1315 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1316 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1318 cd ${DESTDIR}/${DISTDIR}/kernel; \
1319 tar cvf - --include '*/*/*.debug' \
1320 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1321 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1322 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1323 .for _kernel in ${BUILDKERNELS:[2..-1]}
1324 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1325 tar cvf - --exclude '*.debug' \
1326 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1327 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1328 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1329 tar cvf - --include '*/*/*.debug' \
1330 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1331 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1335 .if !defined(NO_INSTALLKERNEL)
1336 cd ${DESTDIR}/${DISTDIR}/kernel; \
1337 tar cvf - --exclude '*.debug' . | \
1338 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1340 cd ${DESTDIR}/${DISTDIR}/kernel; \
1341 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1342 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1343 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1344 .for _kernel in ${BUILDKERNELS:[2..-1]}
1345 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1346 tar cvf - --exclude '*.debug' . | \
1347 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1348 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1349 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1350 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1356 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1358 PORTSDIR?= /usr/ports
1359 WSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/worldstage
1360 KSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/kernelstage
1361 REPODIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/repo
1362 PKGSIGNKEY?= # empty
1364 .ORDER: stage-packages create-packages
1365 .ORDER: create-packages create-world-packages
1366 .ORDER: create-packages create-kernel-packages
1367 .ORDER: create-packages sign-packages
1369 _pkgbootstrap: .PHONY
1370 .if !exists(${LOCALBASE}/sbin/pkg)
1371 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1375 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1378 rm -rf /tmp/ports.${TARGET} || :
1379 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
1380 PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \
1381 WSTAGEDIR=${WSTAGEDIR} \
1382 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1384 real-packages: stage-packages create-packages sign-packages .PHONY
1386 stage-packages: .PHONY
1387 @mkdir -p ${REPODIR} ${WSTAGEDIR} ${KSTAGEDIR}
1388 ${_+_}@cd ${.CURDIR}; \
1389 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT -B stageworld ; \
1390 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT -B stagekernel
1392 create-packages: _pkgbootstrap .PHONY
1393 @mkdir -p ${REPODIR}
1394 ${_+_}@cd ${.CURDIR}; \
1395 ${MAKE} DESTDIR=${WSTAGEDIR} \
1396 PKG_VERSION=${PKG_VERSION} create-world-packages ; \
1397 ${MAKE} DESTDIR=${KSTAGEDIR} \
1398 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1399 create-kernel-packages
1401 create-world-packages: _pkgbootstrap .PHONY
1402 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1403 @cd ${WSTAGEDIR} ; \
1404 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1405 ${WSTAGEDIR}/METALOG
1406 @for plist in ${WSTAGEDIR}/*.plist; do \
1407 plist=$${plist##*/} ; \
1408 pkgname=$${plist%.plist} ; \
1409 sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \
1410 -s ${SRCDIR} -u ${WSTAGEDIR}/$${pkgname}.ucl ; \
1412 @for plist in ${WSTAGEDIR}/*.plist; do \
1413 plist=$${plist##*/} ; \
1414 pkgname=$${plist%.plist} ; \
1416 /^name/ { printf("===> Creating %s-", $$2); next } \
1417 /^version/ { print $$2; next } \
1418 ' ${WSTAGEDIR}/$${pkgname}.ucl ; \
1419 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1420 create -M ${WSTAGEDIR}/$${pkgname}.ucl \
1421 -p ${WSTAGEDIR}/$${pkgname}.plist \
1423 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} ; \
1426 create-kernel-packages: _pkgbootstrap .PHONY
1427 .if exists(${KSTAGEDIR}/kernel.meta)
1428 .for flavor in "" -debug
1429 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1430 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1431 -v kernel=yes -v _kernconf=${INSTALLKERNEL} \
1432 ${KSTAGEDIR}/kernel.meta ; \
1433 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1434 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1435 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1436 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1437 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1438 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1439 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1440 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1441 ${SRCDIR}/release/packages/kernel.ucl \
1442 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1444 /name/ { printf("===> Creating %s-", $$2); next } \
1445 /version/ {print $$2; next } ' \
1446 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1447 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1448 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1449 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1450 -r ${KSTAGEDIR}/${DISTDIR} \
1451 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1454 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1455 .for _kernel in ${BUILDKERNELS:[2..-1]}
1456 .if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1457 .for flavor in "" -debug
1458 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1459 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1460 -v kernel=yes -v _kernconf=${_kernel} \
1461 ${KSTAGEDIR}/kernel.${_kernel}.meta ; \
1462 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1463 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1464 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1465 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1466 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1467 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1468 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1469 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1470 ${SRCDIR}/release/packages/kernel.ucl \
1471 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1473 /name/ { printf("===> Creating %s-", $$2); next } \
1474 /version/ {print $$2; next } ' \
1475 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1476 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1477 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1478 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1479 -r ${KSTAGEDIR}/kernel.${_kernel} \
1480 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1486 sign-packages: _pkgbootstrap .PHONY
1487 @[ -L "${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1488 unlink ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1489 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1490 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1491 ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1493 ln -s ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1494 ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest
1500 # Run test suite on installed world.
1503 @if [ ! -x "${LOCALBASE}/bin/kyua" ]; then \
1504 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1507 ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile
1513 # Build the API documentation with doxygen
1516 @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \
1517 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1520 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1525 # Update the source tree(s), by running svn/svnup to update to the
1529 .if defined(SVN_UPDATE)
1530 @echo "--------------------------------------------------------------"
1531 @echo ">>> Updating ${.CURDIR} using Subversion"
1532 @echo "--------------------------------------------------------------"
1533 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1537 # ------------------------------------------------------------------------
1539 # From here onwards are utility targets used by the 'make world' and
1540 # related targets. If your 'world' breaks, you may like to try to fix
1541 # the problem and manually run the following targets to attempt to
1542 # complete the build. Beware, this is *not* guaranteed to work, you
1543 # need to have a pretty good grip on the current state of the system
1544 # to attempt to manually finish it. If in doubt, 'make world' again.
1548 # legacy: Build compatibility shims for the next three targets. This is a
1549 # minimal set of tools and shims necessary to compensate for older systems
1550 # which don't have the APIs required by the targets built in bootstrap-tools,
1551 # build-tools or cross-tools.
1554 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1555 # r296685 fix cross-endian objcopy
1556 .if ${BOOTSTRAPPING} < 1100102
1557 _elftoolchain_libs= lib/libelf lib/libdwarf
1561 # Temporary special case for automatically detecting the clang compiler issue
1562 # Note: 9.x didn't have FreeBSD_version bumps often enough, so you may need to
1563 # set BOOTSTRAPPING to 0 if you're stable/9 tree post-dates r286035 but is before
1564 # the version bump in r296219 (from July 29, 2015 -> Feb 29, 2016).
1565 .if ${BOOTSTRAPPING} != 0 && \
1566 ${WANT_COMPILER_TYPE} == "clang" && ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} < 30601
1567 .if ${BOOTSTRAPPING} > 10000000 && ${BOOTSTRAPPING} < 1002501
1568 @echo "ERROR: Source upgrades from stable/10 prior to r286033 are not supported."; false
1569 .elif ${BOOTSTRAPPING} > 9000000 && ${BOOTSTRAPPING} < 903509
1570 @echo "ERROR: Source upgrades from stable/9 prior to r286035 are not supported."; false
1573 .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
1574 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
1578 .for _tool in tools/build ${_elftoolchain_libs}
1579 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1580 cd ${.CURDIR}/${_tool}; \
1581 ${MAKE} DIRPRFX=${_tool}/ obj; \
1582 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1583 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
1584 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
1585 DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1589 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1590 # are built to build other binaries in the system. However, the focus of these
1591 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1592 # libraries, augmented by -legacy.
1594 _bt= _bootstrap-tools
1596 .if ${MK_GAMES} != "no"
1597 _strfile= usr.bin/fortune/strfile
1600 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1601 _gperf= gnu/usr.bin/gperf
1604 .if ${MK_SHAREDOCS} != "no" && ${MK_GROFF} != "no"
1605 _groff= gnu/usr.bin/groff \
1609 .if ${MK_VT} != "no"
1610 _vtfontcvt= usr.bin/vtfontcvt
1613 .if ${BOOTSTRAPPING} < 1000033
1614 _libopenbsd= lib/libopenbsd
1618 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1619 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1622 # r245440 mtree -N support added
1623 # r313404 requires sha384.h for libnetbsd, added to libmd in r292782
1624 .if ${BOOTSTRAPPING} < 1100093
1625 _nmtree= lib/libmd \
1629 ${_bt}-lib/libnetbsd: ${_bt}-lib/libmd
1630 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1633 # r246097: log addition login.conf.db, passwd, pwd.db, and spwd.db with cat -l
1634 .if ${BOOTSTRAPPING} < 1000027
1638 # r277259 crunchide: Correct 64-bit section header offset
1639 # r281674 crunchide: always include both 32- and 64-bit ELF support
1640 .if ${BOOTSTRAPPING} < 1100078
1641 _crunchide= usr.sbin/crunch/crunchide
1644 # r285986 crunchen: use STRIPBIN rather than STRIP
1645 # 1100113: Support MK_AUTO_OBJ
1646 # 1200006: META_MODE fixes
1647 .if ${BOOTSTRAPPING} < 1100078 || \
1648 (${MK_AUTO_OBJ} == "yes" && ${BOOTSTRAPPING} < 1100114) || \
1649 (${MK_META_MODE} == "yes" && ${BOOTSTRAPPING} < 1200006)
1650 _crunchgen= usr.sbin/crunch/crunchgen
1653 # r296926 -P keymap search path, MFC to stable/10 in r298297
1654 .if ${BOOTSTRAPPING} < 1003501 || \
1655 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
1656 _kbdcontrol= usr.sbin/kbdcontrol
1662 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1664 .if ${MK_BSNMP} != "no"
1665 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1668 # We need to build tblgen when we're building clang or lld, either as
1669 # bootstrap tools, or as the part of the normal build.
1670 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
1671 ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no"
1673 lib/clang/libllvmminimal \
1674 usr.bin/clang/llvm-tblgen \
1675 usr.bin/clang/clang-tblgen
1677 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal
1678 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal
1681 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1684 .if ${MK_GPL_DTC} != "no"
1685 _dtc= gnu/usr.bin/dtc
1688 .if ${MK_KERBEROS} != "no"
1689 _kerberos5_bootstrap_tools= \
1690 kerberos5/tools/make-roken \
1691 kerberos5/lib/libroken \
1692 kerberos5/lib/libvers \
1693 kerberos5/tools/asn1_compile \
1694 kerberos5/tools/slc \
1697 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1700 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
1701 _libopenbsd?= lib/libopenbsd
1702 _makewhatis= usr.bin/mandoc
1703 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
1705 bootstrap-tools: .PHONY
1707 # Please document (add comment) why something is in 'bootstrap-tools'.
1708 # Try to bound the building of the bootstrap-tool to just the
1709 # FreeBSD versions that need the tool built at this stage of the build.
1712 ${_kerberos5_bootstrap_tools} \
1734 ${_bt}-${_tool}: .PHONY .MAKE
1735 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1736 cd ${.CURDIR}/${_tool}; \
1737 ${MAKE} DIRPRFX=${_tool}/ obj; \
1738 ${MAKE} DIRPRFX=${_tool}/ all; \
1739 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1741 bootstrap-tools: ${_bt}-${_tool}
1745 # build-tools: Build special purpose build tools
1747 .if !defined(NO_SHARE)
1748 _share= share/syscons/scrnmaps
1751 .if ${MK_GCC} != "no"
1752 _gcc_tools= gnu/usr.bin/cc/cc_tools
1755 .if ${MK_RESCUE} != "no"
1756 # rescue includes programs that have build-tools targets
1757 _rescue=rescue/rescue
1763 ${LOCAL_TOOL_DIRS} \
1764 lib/ncurses/ncurses \
1765 lib/ncurses/ncursesw \
1770 usr.bin/mkesdb_static \
1771 usr.bin/mkcsmapper_static \
1773 build-tools_${_tool}: .PHONY
1774 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1775 cd ${.CURDIR}/${_tool}; \
1776 ${MAKE} DIRPRFX=${_tool}/ obj; \
1777 ${MAKE} DIRPRFX=${_tool}/ build-tools
1778 build-tools: build-tools_${_tool}
1782 build-tools_${_tool}: .PHONY
1783 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \
1784 cd ${.CURDIR}/${_tool}; \
1785 ${MAKE} DIRPRFX=${_tool}/ obj; \
1786 ${MAKE} DIRPRFX=${_tool}/ all
1787 build-tools: build-tools_${_tool}
1791 # kernel-tools: Build kernel-building tools
1793 kernel-tools: .PHONY
1794 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1795 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1796 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1799 # cross-tools: All the tools needed to build the rest of the system after
1800 # we get done with the earlier stages. It is the last set of tools needed
1801 # to begin building the target binaries.
1803 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1804 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1805 _btxld= usr.sbin/btxld
1809 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1810 # resulting from missing bug fixes or ELF Toolchain updates.
1811 .if ${MK_CDDL} != "no"
1812 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1813 cddl/usr.bin/ctfmerge
1816 # If we're given an XAS, don't build binutils.
1817 .if ${XAS:M/*} == ""
1818 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1819 _binutils= gnu/usr.bin/binutils
1821 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1822 _elftctools= lib/libelftc \
1828 # These are not required by the build, but can be useful for developers who
1829 # cross-build on a FreeBSD 10 host:
1830 _elftctools+= usr.bin/addr2line
1832 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1833 # If cross-building with an external binutils we still need to build strip for
1834 # the target (for at least crunchide).
1835 _elftctools= lib/libelftc \
1840 .if ${MK_CLANG_BOOTSTRAP} != "no"
1841 _clang= usr.bin/clang
1843 .if ${MK_LLD_BOOTSTRAP} != "no"
1844 _lld= usr.bin/clang/lld
1846 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no"
1847 _clang_libs= lib/clang
1849 .if ${MK_GCC_BOOTSTRAP} != "no"
1850 _gcc= gnu/usr.bin/cc
1852 .if ${MK_USB} != "no"
1853 _usb_tools= sys/boot/usb/tools
1856 cross-tools: .MAKE .PHONY
1858 ${LOCAL_XTOOL_DIRS} \
1868 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1869 cd ${.CURDIR}/${_tool}; \
1870 ${MAKE} DIRPRFX=${_tool}/ obj; \
1871 ${MAKE} DIRPRFX=${_tool}/ all; \
1872 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1875 NXBDESTDIR= ${OBJTREE}/nxb-bin
1876 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1878 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1879 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1880 NXBMAKE= ${NXBENV} ${MAKE} \
1881 LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \
1882 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1883 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1884 MK_GDB=no MK_TESTS=no \
1886 MK_HTML=no NO_LINT=yes MK_MAN=no \
1887 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1888 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1889 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1890 MK_LLDB=no MK_DEBUG_FILES=no
1892 # native-xtools is the current target for qemu-user cross builds of ports
1893 # via poudriere and the imgact_binmisc kernel module.
1894 # For non-clang enabled targets that are still using the in tree gcc
1895 # we must build a gperf binary for one instance of its Makefiles. On
1896 # clang-enabled systems, the gperf binary is obsolete.
1897 native-xtools: .PHONY
1898 .if ${MK_GCC_BOOTSTRAP} != "no"
1899 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1900 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \
1901 cd ${.CURDIR}/${_gperf}; \
1902 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1903 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1904 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1906 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1907 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1908 -p ${NXBDESTDIR}/usr >/dev/null
1909 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1910 -p ${NXBDESTDIR}/usr/include >/dev/null
1911 .if ${MK_DEBUG_FILES} != "no"
1912 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1913 -p ${NXBDESTDIR}/usr/lib >/dev/null
1976 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1977 cd ${.CURDIR}/${_tool}; \
1978 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1979 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1980 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1984 # hierarchy - ensure that all the needed directories are present
1986 hierarchy hier: .MAKE .PHONY
1987 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1990 # libraries - build all libraries, and install them under ${DESTDIR}.
1992 # The list of libraries with dependents (${_prebuild_libs}) and their
1993 # interdependencies (__L) are built automatically by the
1994 # ${.CURDIR}/tools/make_libdeps.sh script.
1996 libraries: .MAKE .PHONY
1997 ${_+_}cd ${.CURDIR}; \
1998 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1999 ${MAKE} -f Makefile.inc1 _startup_libs; \
2000 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
2001 ${MAKE} -f Makefile.inc1 _generic_libs
2004 # static libgcc.a prerequisite for shared libc
2006 _prereq_libs= lib/libcompiler_rt
2007 .if ${MK_SSP} != "no"
2008 _prereq_libs+= gnu/lib/libssp/libssp_nonshared
2011 # These dependencies are not automatically generated:
2013 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
2014 # all shared libraries for ELF.
2016 _startup_libs= gnu/lib/csu
2017 _startup_libs+= lib/csu
2018 _startup_libs+= lib/libcompiler_rt
2019 _startup_libs+= lib/libc
2020 _startup_libs+= lib/libc_nonshared
2021 .if ${MK_LIBCPLUSPLUS} != "no"
2022 _startup_libs+= lib/libcxxrt
2025 .if ${MK_LLVM_LIBUNWIND} != "no"
2026 _prereq_libs+= lib/libgcc_eh lib/libgcc_s
2027 _startup_libs+= lib/libgcc_eh lib/libgcc_s
2029 lib/libgcc_s__L: lib/libc__L
2030 lib/libgcc_s__L: lib/libc_nonshared__L
2031 .if ${MK_LIBCPLUSPLUS} != "no"
2032 lib/libcxxrt__L: lib/libgcc_s__L
2035 .else # MK_LLVM_LIBUNWIND == no
2037 _prereq_libs+= gnu/lib/libgcc
2038 _startup_libs+= gnu/lib/libgcc
2040 gnu/lib/libgcc__L: lib/libc__L
2041 gnu/lib/libgcc__L: lib/libc_nonshared__L
2042 .if ${MK_LIBCPLUSPLUS} != "no"
2043 lib/libcxxrt__L: gnu/lib/libgcc__L
2047 _prebuild_libs= ${_kerberos5_lib_libasn1} \
2048 ${_kerberos5_lib_libhdb} \
2049 ${_kerberos5_lib_libheimbase} \
2050 ${_kerberos5_lib_libheimntlm} \
2052 ${_kerberos5_lib_libheimipcc} \
2053 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
2054 ${_kerberos5_lib_libroken} \
2055 ${_kerberos5_lib_libwind} \
2056 lib/libbz2 ${_libcom_err} lib/libcrypt \
2057 lib/libelf lib/libexpat \
2060 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
2062 lib/ncurses/ncurses lib/ncurses/ncursesw \
2063 lib/libopie lib/libpam/libpam ${_lib_libthr} \
2064 ${_lib_libradius} lib/libsbuf lib/libtacplus \
2066 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
2067 ${_cddl_lib_libuutil} \
2068 ${_cddl_lib_libavl} \
2069 ${_cddl_lib_libzfs_core} \
2070 ${_cddl_lib_libctf} \
2071 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
2072 ${_secure_lib_libcrypto} ${_lib_libldns} \
2073 ${_secure_lib_libssh} ${_secure_lib_libssl}
2075 .if ${MK_GNUCXX} != "no"
2076 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
2077 gnu/lib/libstdc++__L: lib/msun__L
2078 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
2081 .if ${MK_DIALOG} != "no"
2082 _prebuild_libs+= gnu/lib/libdialog
2083 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2086 .if ${MK_LIBCPLUSPLUS} != "no"
2087 _prebuild_libs+= lib/libc++
2090 lib/libgeom__L: lib/libexpat__L
2091 lib/libkvm__L: lib/libelf__L
2093 .if ${MK_LIBTHR} != "no"
2094 _lib_libthr= lib/libthr
2097 .if ${MK_RADIUS_SUPPORT} != "no"
2098 _lib_libradius= lib/libradius
2101 .if ${MK_OFED} != "no"
2102 _ofed_lib= contrib/ofed/usr.lib
2103 _prebuild_libs+= contrib/ofed/usr.lib/libosmcomp
2104 _prebuild_libs+= contrib/ofed/usr.lib/libopensm
2105 _prebuild_libs+= contrib/ofed/usr.lib/libibcommon
2106 _prebuild_libs+= contrib/ofed/usr.lib/libibverbs
2107 _prebuild_libs+= contrib/ofed/usr.lib/libibumad
2109 contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
2110 contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
2111 contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
2114 .if ${MK_CASPER} != "no"
2115 _lib_casper= lib/libcasper
2118 lib/libpjdlog__L: lib/libutil__L
2119 lib/libcasper__L: lib/libnv__L
2120 lib/liblzma__L: lib/libthr__L
2122 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
2123 .for _DIR in ${LOCAL_LIB_DIRS}
2124 .if exists(${.CURDIR}/${_DIR}/Makefile) && empty(_generic_libs:M${_DIR})
2125 _generic_libs+= ${_DIR}
2129 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2131 .if ${MK_CDDL} != "no"
2132 _cddl_lib_libumem= cddl/lib/libumem
2133 _cddl_lib_libnvpair= cddl/lib/libnvpair
2134 _cddl_lib_libavl= cddl/lib/libavl
2135 _cddl_lib_libuutil= cddl/lib/libuutil
2136 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2137 _cddl_lib_libctf= cddl/lib/libctf
2139 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2140 cddl/lib/libzfs__L: lib/libgeom__L
2141 cddl/lib/libctf__L: lib/libz__L
2143 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
2144 # on select architectures though (see cddl/lib/Makefile)
2145 .if ${MACHINE_CPUARCH} != "sparc64"
2146 _prebuild_libs+= lib/libprocstat lib/libproc lib/librtld_db
2147 lib/libprocstat__L: lib/libelf__L lib/libkvm__L lib/libutil__L
2148 lib/libproc__L: lib/libprocstat__L
2149 lib/librtld_db__L: lib/libprocstat__L
2152 .if ${MK_CRYPT} != "no"
2153 .if ${MK_OPENSSL} != "no"
2154 _secure_lib_libcrypto= secure/lib/libcrypto
2155 _secure_lib_libssl= secure/lib/libssl
2156 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2157 .if ${MK_LDNS} != "no"
2158 _lib_libldns= lib/libldns
2159 lib/libldns__L: secure/lib/libcrypto__L
2161 .if ${MK_OPENSSH} != "no"
2162 _secure_lib_libssh= secure/lib/libssh
2163 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2164 .if ${MK_LDNS} != "no"
2165 secure/lib/libssh__L: lib/libldns__L
2167 .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no"
2168 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2169 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2170 lib/libmd__L kerberos5/lib/libroken__L
2174 _secure_lib= secure/lib
2177 .if ${MK_KERBEROS} != "no"
2178 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2179 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2180 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2181 kerberos5/lib/libwind__L lib/libsqlite3__L
2182 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2183 kerberos5/lib/libroken__L lib/libcom_err__L
2184 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2185 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2186 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2187 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2188 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2189 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2190 kerberos5/lib/libroken__L: lib/libcrypt__L
2191 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2192 kerberos5/lib/libheimbase__L: lib/libthr__L
2193 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2196 lib/libsqlite3__L: lib/libthr__L
2198 .if ${MK_GSSAPI} != "no"
2199 _lib_libgssapi= lib/libgssapi
2202 .if ${MK_KERBEROS} != "no"
2203 _kerberos5_lib= kerberos5/lib
2204 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2205 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2206 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2207 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2208 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2209 _kerberos5_lib_libroken= kerberos5/lib/libroken
2210 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2211 _libsqlite3= lib/libsqlite3
2212 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2213 _kerberos5_lib_libwind= kerberos5/lib/libwind
2214 _libcom_err= lib/libcom_err
2217 .if ${MK_NIS} != "no"
2218 _lib_libypclnt= lib/libypclnt
2221 .if ${MK_OPENSSL} == "no"
2222 lib/libradius__L: lib/libmd__L
2226 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2227 .if ${MK_CXX} != "no"
2228 .if ${MK_LIBCPLUSPLUS} != "no"
2229 lib/libproc__L: lib/libcxxrt__L
2230 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2231 lib/libproc__L: gnu/lib/libsupc++__L
2235 .for _lib in ${_prereq_libs}
2236 ${_lib}__PL: .PHONY .MAKE
2237 .if exists(${.CURDIR}/${_lib})
2238 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2239 cd ${.CURDIR}/${_lib}; \
2240 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2241 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2242 DIRPRFX=${_lib}/ all; \
2243 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2244 DIRPRFX=${_lib}/ install
2248 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
2249 ${_lib}__L: .PHONY .MAKE
2250 .if exists(${.CURDIR}/${_lib})
2251 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2252 cd ${.CURDIR}/${_lib}; \
2253 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2254 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2255 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2259 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2260 _startup_libs: ${_startup_libs:S/$/__L/}
2261 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2262 _generic_libs: ${_generic_libs:S/$/__L/}
2264 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2265 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2266 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2267 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2268 # parallel. This is safe for the world stage of buildworld though since it has
2269 # already built libraries in a proper order and installed includes into
2270 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2271 # avoid trashing a system if it crashes mid-install.
2272 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2276 .include <bsd.subdir.mk>
2278 .if make(check-old) || make(check-old-dirs) || \
2279 make(check-old-files) || make(check-old-libs) || \
2280 make(delete-old) || make(delete-old-dirs) || \
2281 make(delete-old-files) || make(delete-old-libs)
2284 # check for / delete old files section
2287 .include "ObsoleteFiles.inc"
2289 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2290 else you can not start such an application. Consult UPDATING for more \
2291 information regarding how to cope with the removal/revision bump of a \
2294 .if !defined(BATCH_DELETE_OLD_FILES)
2300 delete-old-files: .PHONY
2301 @echo ">>> Removing old files (only deletes safe to delete libs)"
2302 # Ask for every old file if the user really wants to remove it.
2303 # It's annoying, but better safe than sorry.
2304 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2305 # argument list will get too long. Using .for/.endfor make "loops" will make
2306 # the Makefile parser segfault.
2309 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2310 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2311 while read file; do \
2312 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2313 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2314 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2316 for ext in debug symbols; do \
2317 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2318 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2319 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2324 # Remove catpages without corresponding manpages.
2326 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2327 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2328 while read catpage; do \
2330 if [ ! -e "$${manpage}" ]; then \
2331 rm ${RM_I} $${catpage} <&3; \
2334 @echo ">>> Old files removed"
2336 check-old-files: .PHONY
2337 @echo ">>> Checking for old files"
2339 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2340 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2341 while read file; do \
2342 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2343 echo "${DESTDIR}/$${file}"; \
2345 for ext in debug symbols; do \
2346 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2347 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2351 # Check for catpages without corresponding manpages.
2352 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2353 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2354 while read catpage; do \
2356 if [ ! -e "$${manpage}" ]; then \
2361 delete-old-libs: .PHONY
2362 @echo ">>> Removing old libraries"
2363 @echo "${OLD_LIBS_MESSAGE}" | fmt
2366 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2367 -V OLD_LIBS | xargs -n1 | \
2368 while read file; do \
2369 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2370 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2371 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2373 for ext in debug symbols; do \
2374 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2375 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2376 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2381 @echo ">>> Old libraries removed"
2383 check-old-libs: .PHONY
2384 @echo ">>> Checking for old libraries"
2386 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2387 -V OLD_LIBS | xargs -n1 | \
2388 while read file; do \
2389 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2390 echo "${DESTDIR}/$${file}"; \
2392 for ext in debug symbols; do \
2393 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2394 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2399 delete-old-dirs: .PHONY
2400 @echo ">>> Removing old directories"
2402 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2403 -V OLD_DIRS | xargs -n1 | sort -r | \
2404 while read dir; do \
2405 if [ -d "${DESTDIR}/$${dir}" ]; then \
2406 rmdir -v "${DESTDIR}/$${dir}" || true; \
2407 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2408 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2410 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2411 rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \
2412 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2413 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2416 @echo ">>> Old directories removed"
2418 check-old-dirs: .PHONY
2419 @echo ">>> Checking for old directories"
2421 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2422 -V OLD_DIRS | xargs -n1 | \
2423 while read dir; do \
2424 if [ -d "${DESTDIR}/$${dir}" ]; then \
2425 echo "${DESTDIR}/$${dir}"; \
2426 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2427 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2429 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2430 echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \
2431 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2432 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2436 delete-old: delete-old-files delete-old-dirs .PHONY
2437 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2439 check-old: check-old-files check-old-libs check-old-dirs .PHONY
2440 @echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
2441 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2446 # showconfig - show build configuration.
2449 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2450 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2452 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2453 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2455 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2456 .if exists(${KERNCONFDIR}/${KERNCONF})
2457 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2458 '${KERNCONFDIR}/${KERNCONF}' ; echo
2464 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2465 DTBOUTPUTPATH= ${.CURDIR}
2469 # Build 'standalone' Device Tree Blob
2472 @PATH=${TMPPATH} MACHINE=${TARGET} \
2473 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2474 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2479 # In the following, the first 'rm' in a series will usually remove all
2480 # files and directories. If it does not, then there are probably some
2481 # files with file flags set, so this unsets them and tries the 'rm' a
2482 # second time. There are situations where this target will be cleaning
2483 # some directories via more than one method, but that duplication is
2484 # needed to correctly handle all the possible situations. Removing all
2485 # files without file flags set in the first 'rm' instance saves time,
2486 # because 'chflags' will need to operate on fewer files afterwards.
2488 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2489 # created by bsd.obj.mk, except that we don't want to .include that file
2492 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2494 .if exists(${BW_CANONICALOBJDIR}/)
2495 -rm -rf ${BW_CANONICALOBJDIR}/*
2496 -chflags -R 0 ${BW_CANONICALOBJDIR}
2497 rm -rf ${BW_CANONICALOBJDIR}/*
2499 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2500 # To be safe in this case, fall back to a 'make cleandir'
2501 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2504 .if defined(TARGET) && defined(TARGET_ARCH)
2506 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2507 XDEV_CPUTYPE?=${CPUTYPE}
2509 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2512 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2513 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2514 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2515 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2516 CPUTYPE=${XDEV_CPUTYPE}
2518 XDDIR=${TARGET_ARCH}-freebsd
2521 .error XDTP variable should be an absolute path
2524 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2525 INSTALL="sh ${.CURDIR}/tools/install.sh"
2527 TOOLS_PREFIX=${XDTP}
2529 .if ${WANT_COMPILER_TYPE} == gcc || \
2530 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
2531 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
2532 # won't set header path and -L is used to ensure the base library path
2533 # is added before the port PREFIX library path.
2534 CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib
2535 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
2536 # combined with --sysroot.
2537 CD2CFLAGS+= -B${XDDESTDIR}/usr/lib
2538 # Force using libc++ for external GCC.
2539 # XXX: This should be checking MK_GNUCXX == no
2540 .if ${X_COMPILER_VERSION} >= 40800
2541 CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \
2545 CD2CFLAGS+= --sysroot=${XDDESTDIR}/
2546 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \
2547 CPP="${CPP} ${CD2CFLAGS}" \
2548 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2550 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2551 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2552 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2553 .if ${MK_META_MODE} != "no"
2554 # Don't rebuild build-tools targets during normal build.
2555 CD2MAKE+= BUILD_TOOLS_META=.NOMETA
2557 XDDESTDIR=${DESTDIR}/${XDTP}
2559 OSREL!= uname -r | sed -e 's/[-(].*//'
2562 .ORDER: xdev-build xdev-install xdev-links
2563 xdev: xdev-build xdev-install .PHONY
2565 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2566 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
2568 _xb-worldtmp: .PHONY
2569 mkdir -p ${CDTMP}/usr
2570 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2571 -p ${CDTMP}/usr >/dev/null
2573 _xb-bootstrap-tools: .PHONY
2578 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2579 cd ${.CURDIR}/${_tool}; \
2580 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2581 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2582 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2585 _xb-build-tools: .PHONY
2586 ${_+_}@cd ${.CURDIR}; \
2587 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2589 _xb-cross-tools: .PHONY
2597 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2598 cd ${.CURDIR}/${_tool}; \
2599 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2600 ${CDMAKE} DIRPRFX=${_tool}/ all
2604 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2605 mkdir -p ${XDDESTDIR}
2606 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2607 -p ${XDDESTDIR} >/dev/null
2608 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2609 -p ${XDDESTDIR}/usr >/dev/null
2610 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2611 -p ${XDDESTDIR}/usr/include >/dev/null
2612 .if defined(LIBCOMPAT)
2613 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2614 -p ${XDDESTDIR}/usr >/dev/null
2616 .if ${MK_TESTS} != "no"
2617 mkdir -p ${XDDESTDIR}${TESTSBASE}
2618 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2619 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2622 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2623 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
2625 _xi-cross-tools: .PHONY
2626 @echo "_xi-cross-tools"
2634 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2635 cd ${.CURDIR}/${_tool}; \
2636 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2639 _xi-includes: .PHONY
2640 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2641 DESTDIR=${XDDESTDIR}
2643 _xi-libraries: .PHONY
2644 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2645 DESTDIR=${XDDESTDIR}
2648 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2649 mkdir -p ../../../../usr/bin; \
2651 ln -sf ../../${XDTP}/usr/bin/$$i \
2652 ../../../../usr/bin/${XDDIR}-$$i; \
2653 ln -sf ../../${XDTP}/usr/bin/$$i \
2654 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2657 xdev xdev-build xdev-install xdev-links: .PHONY
2658 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"