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}
553 # External compiler needs sysroot and target flags.
554 .if ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
555 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
556 BFLAGS+= -B${WORLDTMP}/usr/bin
558 .if ${TARGET} == "arm"
559 .if ${TARGET_ARCH:Marmv6*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
560 TARGET_ABI= gnueabihf
565 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
566 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
567 # won't set header path and -L is used to ensure the base library path
568 # is added before the port PREFIX library path.
569 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
570 # Force using libc++ for external GCC.
571 # XXX: This should be checking MK_GNUCXX == no
572 .if ${X_COMPILER_VERSION} >= 40800
573 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
574 -nostdinc++ -L${WORLDTMP}/../lib/libc++
578 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd12.0
579 XCFLAGS+= -target ${TARGET_TRIPLE}
581 XCFLAGS+= --sysroot=${WORLDTMP}
582 .endif # ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
588 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
589 ${TARGET_ARCH} == "powerpc64")
591 .include "Makefile.libcompat"
592 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH} == "armv6"
594 .include "Makefile.libcompat"
597 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
599 IMAKEENV= ${CROSSENV}
600 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
601 ${IMAKE_INSTALL} ${IMAKE_MTREE}
602 .if empty(.MAKEFLAGS:M-n)
603 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
604 LD_LIBRARY_PATH=${INSTALLTMP} \
605 PATH_LOCALE=${INSTALLTMP}/locale
606 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
608 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
610 .if defined(DB_FROM_SRC)
611 INSTALLFLAGS+= -N ${.CURDIR}/etc
612 MTREEFLAGS+= -N ${.CURDIR}/etc
614 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
615 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
617 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
618 IMAKE+= -DNO_ROOT METALOG=${METALOG}
619 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
622 .if defined(BUILD_PKGS)
623 INSTALLFLAGS+= -h sha256
625 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
626 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
627 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
631 KMAKEENV= ${WMAKEENV}
632 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
637 # Attempt to rebuild the entire system, with reasonable chance of
638 # success, regardless of how old your existing system is.
641 .if ${.CURDIR:C/[^,]//g} != ""
642 # The m4 build of sendmail files doesn't like it if ',' is used
643 # anywhere in the path of it's files.
645 @echo "*** Error: path to source tree contains a comma ','"
650 @echo "--------------------------------------------------------------"
651 @echo ">>> Rebuilding the temporary build tree"
652 @echo "--------------------------------------------------------------"
653 .if !defined(NO_CLEAN)
655 .if defined(LIBCOMPAT)
656 rm -rf ${LIBCOMPATTMP}
659 rm -rf ${WORLDTMP}/legacy/usr/include
660 # XXX - These can depend on any header file.
661 rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c
662 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
665 lib lib/casper usr legacy/bin legacy/usr
666 mkdir -p ${WORLDTMP}/${_dir}
668 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
669 -p ${WORLDTMP}/legacy/usr >/dev/null
670 .if ${MK_GROFF} != "no"
671 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
672 -p ${WORLDTMP}/legacy/usr >/dev/null
674 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
675 -p ${WORLDTMP}/legacy/usr/include >/dev/null
676 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
677 -p ${WORLDTMP}/usr >/dev/null
678 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
679 -p ${WORLDTMP}/usr/include >/dev/null
680 ln -sf ${.CURDIR}/sys ${WORLDTMP}
681 .if ${MK_DEBUG_FILES} != "no"
682 # We could instead disable debug files for these build stages
683 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
684 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
685 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
686 -p ${WORLDTMP}/usr/lib >/dev/null
688 .if defined(LIBCOMPAT)
689 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
690 -p ${WORLDTMP}/usr >/dev/null
691 .if ${MK_DEBUG_FILES} != "no"
692 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
693 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
694 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
695 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
698 .if ${MK_TESTS} != "no"
699 mkdir -p ${WORLDTMP}${TESTSBASE}
700 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
701 -p ${WORLDTMP}${TESTSBASE} >/dev/null
702 .if ${MK_DEBUG_FILES} != "no"
703 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
704 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
705 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
708 .for _mtree in ${LOCAL_MTREE}
709 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
713 @echo "--------------------------------------------------------------"
714 @echo ">>> stage 1.1: legacy release compatibility shims"
715 @echo "--------------------------------------------------------------"
716 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
719 @echo "--------------------------------------------------------------"
720 @echo ">>> stage 1.2: bootstrap tools"
721 @echo "--------------------------------------------------------------"
722 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
724 .if !defined(NO_CLEAN)
726 @echo "--------------------------------------------------------------"
727 @echo ">>> stage 2.1: cleaning up the object tree"
728 @echo "--------------------------------------------------------------"
729 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
730 .if defined(LIBCOMPAT)
731 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
736 @echo "--------------------------------------------------------------"
737 @echo ">>> stage 2.2: rebuilding the object tree"
738 @echo "--------------------------------------------------------------"
739 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
742 @echo "--------------------------------------------------------------"
743 @echo ">>> stage 2.3: build tools"
744 @echo "--------------------------------------------------------------"
745 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
748 @echo "--------------------------------------------------------------"
749 @echo ">>> stage 3: cross tools"
750 @echo "--------------------------------------------------------------"
751 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
752 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
755 @echo "--------------------------------------------------------------"
756 @echo ">>> stage 4.1: building includes"
757 @echo "--------------------------------------------------------------"
758 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
759 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
760 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
761 MK_INCLUDES=yes includes
762 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
763 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
767 @echo "--------------------------------------------------------------"
768 @echo ">>> stage 4.2: building libraries"
769 @echo "--------------------------------------------------------------"
770 ${_+_}cd ${.CURDIR}; \
771 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
772 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
775 @echo "--------------------------------------------------------------"
776 @echo ">>> stage 4.3: building everything"
777 @echo "--------------------------------------------------------------"
778 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
781 WMAKE_TGTS+= _worldtmp _legacy
782 .if empty(SUBDIR_OVERRIDE)
783 WMAKE_TGTS+= _bootstrap-tools
785 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
786 WMAKE_TGTS+= _includes _libraries
787 WMAKE_TGTS+= everything
788 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
789 WMAKE_TGTS+= build${libcompat}
792 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
793 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
795 buildworld_prologue: .PHONY
796 @echo "--------------------------------------------------------------"
797 @echo ">>> World build started on `LC_ALL=C date`"
798 @echo "--------------------------------------------------------------"
800 buildworld_epilogue: .PHONY
802 @echo "--------------------------------------------------------------"
803 @echo ">>> World build completed on `LC_ALL=C date`"
804 @echo "--------------------------------------------------------------"
807 # We need to have this as a target because the indirection between Makefile
808 # and Makefile.inc1 causes the correct PATH to be used, rather than a
809 # modification of the current environment's PATH. In addition, we need
810 # to quote multiword values.
813 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
815 .if ${.TARGETS:Mbuildenv}
816 .if ${.MAKEFLAGS:M-j}
817 .error The buildenv target is incompatible with -j
820 BUILDENV_DIR?= ${.CURDIR}
822 @echo Entering world for ${TARGET_ARCH}:${TARGET}
823 .if ${BUILDENV_SHELL:M*zsh*}
824 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
826 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
829 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
830 toolchain: ${TOOLCHAIN_TGTS} .PHONY
831 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries} .PHONY
836 # Checks to be sure system is ready for installworld/installkernel.
838 installcheck: _installcheck_world _installcheck_kernel .PHONY
839 _installcheck_world: .PHONY
840 _installcheck_kernel: .PHONY
843 # Require DESTDIR to be set if installing for a different architecture or
844 # using the user/group database in the source tree.
846 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
848 .if !make(distributeworld)
849 _installcheck_world: __installcheck_DESTDIR
850 _installcheck_kernel: __installcheck_DESTDIR
851 __installcheck_DESTDIR: .PHONY
852 .if !defined(DESTDIR) || empty(DESTDIR)
853 @echo "ERROR: Please set DESTDIR!"; \
859 .if !defined(DB_FROM_SRC)
861 # Check for missing UIDs/GIDs.
863 CHECK_UIDS= auditdistd
865 .if ${MK_SENDMAIL} != "no"
871 CHECK_GIDS+= proxy authpf
873 .if ${MK_UNBOUND} != "no"
877 _installcheck_world: __installcheck_UGID
878 __installcheck_UGID: .PHONY
879 .for uid in ${CHECK_UIDS}
880 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
881 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
885 .for gid in ${CHECK_GIDS}
886 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
887 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
894 # Required install tools to be saved in a scratch dir for safety.
896 .if ${MK_ZONEINFO} != "no"
897 _zoneinfo= zic tzsetup
900 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
901 date echo egrep find grep id install ${_install-info} \
902 ln make mkdir mtree mv pwd_mkdb \
903 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
906 # Needed for share/man
907 .if ${MK_MAN_UTILS} != "no"
914 # Distributes everything compiled by a `buildworld'.
918 # Installs everything compiled by a 'buildworld'.
921 # Non-base distributions produced by the base system
922 EXTRA_DISTRIBUTIONS= doc
923 .if defined(LIBCOMPAT)
924 EXTRA_DISTRIBUTIONS+= lib${libcompat}
926 .if ${MK_TESTS} != "no"
927 EXTRA_DISTRIBUTIONS+= tests
931 .if ${MK_DEBUG_FILES} != "no"
932 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
935 MTREE_MAGIC?= mtree 2.0
937 distributeworld installworld stageworld: _installcheck_world .PHONY
938 mkdir -p ${INSTALLTMP}
939 progs=$$(for prog in ${ITOOLS}; do \
940 if progpath=`which $$prog`; then \
943 echo "Required tool $$prog not found in PATH." >&2; \
947 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
948 while read line; do \
950 if [ "$$2 $$3" != "not found" ]; then \
953 echo "Required library $$1 not found." >&2; \
957 cp $$libs $$progs ${INSTALLTMP}
958 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
960 -mkdir -p ${METALOG:H}
961 echo "#${MTREE_MAGIC}" > ${METALOG}
963 .if make(distributeworld)
964 .for dist in ${EXTRA_DISTRIBUTIONS}
965 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
966 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
967 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
968 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
969 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
970 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
971 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
972 .if ${MK_DEBUG_FILES} != "no"
973 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
974 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
976 .if defined(LIBCOMPAT)
977 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
978 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
979 .if ${MK_DEBUG_FILES} != "no"
980 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
981 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
984 .if ${MK_TESTS} != "no" && ${dist} == "tests"
985 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
986 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
987 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
988 .if ${MK_DEBUG_FILES} != "no"
989 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
990 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
994 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
995 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
996 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
997 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
998 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
999 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1000 .if defined(LIBCOMPAT)
1001 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
1002 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1006 -mkdir ${DESTDIR}/${DISTDIR}/base
1007 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1008 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1009 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1010 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1012 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1013 ${IMAKEENV} rm -rf ${INSTALLTMP}
1014 .if make(distributeworld)
1015 .for dist in ${EXTRA_DISTRIBUTIONS}
1016 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
1018 .if defined(NO_ROOT)
1019 .for dist in base ${EXTRA_DISTRIBUTIONS}
1020 @# For each file that exists in this dist, print the corresponding
1021 @# line from the METALOG. This relies on the fact that
1022 @# a line containing only the filename will sort immediately before
1023 @# the relevant mtree line.
1024 cd ${DESTDIR}/${DISTDIR}; \
1025 find ./${dist} | sort -u ${METALOG} - | \
1026 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1027 ${DESTDIR}/${DISTDIR}/${dist}.meta
1029 .for dist in ${DEBUG_DISTRIBUTIONS}
1030 @# For each file that exists in this dist, print the corresponding
1031 @# line from the METALOG. This relies on the fact that
1032 @# a line containing only the filename will sort immediately before
1033 @# the relevant mtree line.
1034 cd ${DESTDIR}/${DISTDIR}; \
1035 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1036 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1037 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1042 packageworld: .PHONY
1043 .for dist in base ${EXTRA_DISTRIBUTIONS}
1044 .if defined(NO_ROOT)
1045 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1046 tar cvf - --exclude usr/lib/debug \
1047 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1048 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1050 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1051 tar cvf - --exclude usr/lib/debug . | \
1052 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1056 .for dist in ${DEBUG_DISTRIBUTIONS}
1057 . if defined(NO_ROOT)
1058 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1059 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1060 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1062 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1063 tar cvLf - usr/lib/debug | \
1064 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1071 # If you have a build server, you can NFS mount the source and obj directories
1072 # and do a 'make reinstall' on the *client* to install new binaries from the
1073 # most recent server build.
1075 restage reinstall: .MAKE .PHONY
1076 @echo "--------------------------------------------------------------"
1077 @echo ">>> Making hierarchy"
1078 @echo "--------------------------------------------------------------"
1079 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1080 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1082 @echo "--------------------------------------------------------------"
1083 @echo ">>> Making distribution"
1084 @echo "--------------------------------------------------------------"
1085 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1086 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
1089 @echo "--------------------------------------------------------------"
1090 @echo ">>> Installing everything"
1091 @echo "--------------------------------------------------------------"
1092 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1093 .if defined(LIBCOMPAT)
1094 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1097 redistribute: .MAKE .PHONY
1098 @echo "--------------------------------------------------------------"
1099 @echo ">>> Distributing everything"
1100 @echo "--------------------------------------------------------------"
1101 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1102 .if defined(LIBCOMPAT)
1103 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1104 DISTRIBUTION=lib${libcompat}
1107 distrib-dirs distribution: .MAKE .PHONY
1108 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1109 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1110 .if make(distribution)
1111 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1112 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1113 METALOG=${METALOG} MK_TESTS=no installconfig
1117 # buildkernel and installkernel
1119 # Which kernels to build and/or install is specified by setting
1120 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1121 # Only the existing (depending TARGET) config files are used
1122 # for building kernels and only the first of these is designated
1123 # as the one being installed.
1125 # Note that we have to use TARGET instead of TARGET_ARCH when
1126 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1127 # be set to cross-build, we have to make sure TARGET is set
1130 .if defined(KERNFAST)
1134 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1135 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1136 KERNCONF=${KERNFAST}
1139 .if ${TARGET_ARCH} == "powerpc64"
1140 KERNCONF?= GENERIC64
1144 INSTKERNNAME?= kernel
1146 KERNSRCDIR?= ${.CURDIR}/sys
1147 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1148 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1149 KERNCONFDIR?= ${KRNLCONFDIR}
1153 .if defined(NO_INSTALLKERNEL)
1154 # All of the BUILDKERNELS loops start at index 1.
1155 BUILDKERNELS+= dummy
1157 .for _kernel in ${KERNCONF}
1158 .if exists(${KERNCONFDIR}/${_kernel})
1159 BUILDKERNELS+= ${_kernel}
1160 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1161 INSTALLKERNEL= ${_kernel}
1166 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1171 # Builds all kernels defined by BUILDKERNELS.
1173 buildkernel: .MAKE .PHONY
1174 .if empty(BUILDKERNELS:Ndummy)
1175 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1179 .for _kernel in ${BUILDKERNELS:Ndummy}
1180 @echo "--------------------------------------------------------------"
1181 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1182 @echo "--------------------------------------------------------------"
1183 @echo "===> ${_kernel}"
1184 mkdir -p ${KRNLOBJDIR}
1185 .if !defined(NO_KERNELCONFIG)
1187 @echo "--------------------------------------------------------------"
1188 @echo ">>> stage 1: configuring the kernel"
1189 @echo "--------------------------------------------------------------"
1190 cd ${KRNLCONFDIR}; \
1192 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1193 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1195 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1197 @echo "--------------------------------------------------------------"
1198 @echo ">>> stage 2.1: cleaning up the object tree"
1199 @echo "--------------------------------------------------------------"
1200 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1202 .if !defined(NO_KERNELOBJ)
1204 @echo "--------------------------------------------------------------"
1205 @echo ">>> stage 2.2: rebuilding the object tree"
1206 @echo "--------------------------------------------------------------"
1207 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1210 @echo "--------------------------------------------------------------"
1211 @echo ">>> stage 2.3: build tools"
1212 @echo "--------------------------------------------------------------"
1213 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1215 @echo "--------------------------------------------------------------"
1216 @echo ">>> stage 3.1: building everything"
1217 @echo "--------------------------------------------------------------"
1218 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1219 @echo "--------------------------------------------------------------"
1220 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1221 @echo "--------------------------------------------------------------"
1224 NO_INSTALLEXTRAKERNELS?= yes
1227 # installkernel, etc.
1229 # Install the kernel defined by INSTALLKERNEL
1231 installkernel installkernel.debug \
1232 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1233 .if !defined(NO_INSTALLKERNEL)
1234 .if empty(INSTALLKERNEL)
1235 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1238 @echo "--------------------------------------------------------------"
1239 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1240 @echo "--------------------------------------------------------------"
1241 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1242 ${CROSSENV} PATH=${TMPPATH} \
1243 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1245 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1246 .for _kernel in ${BUILDKERNELS:[2..-1]}
1247 @echo "--------------------------------------------------------------"
1248 @echo ">>> Installing kernel ${_kernel}"
1249 @echo "--------------------------------------------------------------"
1250 cd ${KRNLOBJDIR}/${_kernel}; \
1251 ${CROSSENV} PATH=${TMPPATH} \
1252 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1256 distributekernel distributekernel.debug: .PHONY
1257 .if !defined(NO_INSTALLKERNEL)
1258 .if empty(INSTALLKERNEL)
1259 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1262 mkdir -p ${DESTDIR}/${DISTDIR}
1263 .if defined(NO_ROOT)
1264 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1266 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1267 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1268 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1269 DESTDIR=${INSTALL_DDIR}/kernel \
1270 ${.TARGET:S/distributekernel/install/}
1271 .if defined(NO_ROOT)
1272 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1273 ${DESTDIR}/${DISTDIR}/kernel.meta
1276 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1277 .for _kernel in ${BUILDKERNELS:[2..-1]}
1278 .if defined(NO_ROOT)
1279 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1281 cd ${KRNLOBJDIR}/${_kernel}; \
1282 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1283 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1284 KERNEL=${INSTKERNNAME}.${_kernel} \
1285 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1286 ${.TARGET:S/distributekernel/install/}
1287 .if defined(NO_ROOT)
1288 @sed -e "s|^./kernel.${_kernel}|.|" \
1289 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1290 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1295 packagekernel: .PHONY
1296 .if defined(NO_ROOT)
1297 .if !defined(NO_INSTALLKERNEL)
1298 cd ${DESTDIR}/${DISTDIR}/kernel; \
1299 tar cvf - --exclude '*.debug' \
1300 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1301 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1303 cd ${DESTDIR}/${DISTDIR}/kernel; \
1304 tar cvf - --include '*/*/*.debug' \
1305 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1306 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1307 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1308 .for _kernel in ${BUILDKERNELS:[2..-1]}
1309 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1310 tar cvf - --exclude '*.debug' \
1311 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1312 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1313 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1314 tar cvf - --include '*/*/*.debug' \
1315 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1316 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1320 .if !defined(NO_INSTALLKERNEL)
1321 cd ${DESTDIR}/${DISTDIR}/kernel; \
1322 tar cvf - --exclude '*.debug' . | \
1323 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1325 cd ${DESTDIR}/${DISTDIR}/kernel; \
1326 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1327 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1328 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1329 .for _kernel in ${BUILDKERNELS:[2..-1]}
1330 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1331 tar cvf - --exclude '*.debug' . | \
1332 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1333 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1334 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1335 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1341 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1343 PORTSDIR?= /usr/ports
1344 WSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/worldstage
1345 KSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/kernelstage
1346 REPODIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/repo
1347 PKGSIGNKEY?= # empty
1349 .ORDER: stage-packages create-packages
1350 .ORDER: create-packages create-world-packages
1351 .ORDER: create-packages create-kernel-packages
1352 .ORDER: create-packages sign-packages
1354 _pkgbootstrap: .PHONY
1355 .if !exists(${LOCALBASE}/sbin/pkg)
1356 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1360 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1363 rm -rf /tmp/ports.${TARGET} || :
1364 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
1365 PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} WSTAGEDIR=${WSTAGEDIR} \
1366 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1368 real-packages: stage-packages create-packages sign-packages .PHONY
1370 stage-packages: .PHONY
1371 @mkdir -p ${REPODIR} ${WSTAGEDIR} ${KSTAGEDIR}
1372 ${_+_}@cd ${.CURDIR}; \
1373 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT -B stageworld ; \
1374 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT -B stagekernel
1376 create-packages: _pkgbootstrap .PHONY
1377 @mkdir -p ${REPODIR}
1378 ${_+_}@cd ${.CURDIR}; \
1379 ${MAKE} DESTDIR=${WSTAGEDIR} \
1380 PKG_VERSION=${PKG_VERSION} create-world-packages ; \
1381 ${MAKE} DESTDIR=${KSTAGEDIR} \
1382 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1383 create-kernel-packages
1385 create-world-packages: _pkgbootstrap .PHONY
1386 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1387 @cd ${WSTAGEDIR} ; \
1388 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1389 ${WSTAGEDIR}/METALOG
1390 @for plist in ${WSTAGEDIR}/*.plist; do \
1391 plist=$${plist##*/} ; \
1392 pkgname=$${plist%.plist} ; \
1393 sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \
1394 -s ${SRCDIR} -u ${WSTAGEDIR}/$${pkgname}.ucl ; \
1396 @for plist in ${WSTAGEDIR}/*.plist; do \
1397 plist=$${plist##*/} ; \
1398 pkgname=$${plist%.plist} ; \
1400 /^name/ { printf("===> Creating %s-", $$2); next } \
1401 /^version/ { print $$2; next } \
1402 ' ${WSTAGEDIR}/$${pkgname}.ucl ; \
1403 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1404 create -M ${WSTAGEDIR}/$${pkgname}.ucl \
1405 -p ${WSTAGEDIR}/$${pkgname}.plist \
1407 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} ; \
1410 create-kernel-packages: _pkgbootstrap .PHONY
1411 .if exists(${KSTAGEDIR}/kernel.meta)
1412 .for flavor in "" -debug
1413 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1414 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1415 -v kernel=yes -v _kernconf=${INSTALLKERNEL} \
1416 ${KSTAGEDIR}/kernel.meta ; \
1417 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1418 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1419 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1420 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1421 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1422 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1423 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1424 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1425 ${SRCDIR}/release/packages/kernel.ucl \
1426 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1428 /name/ { printf("===> Creating %s-", $$2); next } \
1429 /version/ {print $$2; next } ' \
1430 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1431 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1432 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1433 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1434 -r ${KSTAGEDIR}/${DISTDIR} \
1435 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1438 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1439 .for _kernel in ${BUILDKERNELS:[2..-1]}
1440 .if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1441 .for flavor in "" -debug
1442 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1443 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1444 -v kernel=yes -v _kernconf=${_kernel} \
1445 ${KSTAGEDIR}/kernel.${_kernel}.meta ; \
1446 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1447 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1448 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1449 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1450 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1451 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1452 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1453 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1454 ${SRCDIR}/release/packages/kernel.ucl \
1455 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1457 /name/ { printf("===> Creating %s-", $$2); next } \
1458 /version/ {print $$2; next } ' \
1459 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1460 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1461 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1462 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1463 -r ${KSTAGEDIR}/kernel.${_kernel} \
1464 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1470 sign-packages: _pkgbootstrap .PHONY
1471 @[ -L "${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1472 unlink ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1473 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1474 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1475 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1477 ln -s ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1478 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest
1484 # Run test suite on installed world.
1487 @if [ ! -x ${LOCALBASE}/bin/kyua ]; then \
1488 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1491 ${_+_}${LOCALBASE}/bin/kyua test -k ${TESTSBASE}/Kyuafile
1497 # Build the API documentation with doxygen
1500 @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1501 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1504 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1509 # Update the source tree(s), by running svn/svnup to update to the
1513 .if defined(SVN_UPDATE)
1514 @echo "--------------------------------------------------------------"
1515 @echo ">>> Updating ${.CURDIR} using Subversion"
1516 @echo "--------------------------------------------------------------"
1517 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1521 # ------------------------------------------------------------------------
1523 # From here onwards are utility targets used by the 'make world' and
1524 # related targets. If your 'world' breaks, you may like to try to fix
1525 # the problem and manually run the following targets to attempt to
1526 # complete the build. Beware, this is *not* guaranteed to work, you
1527 # need to have a pretty good grip on the current state of the system
1528 # to attempt to manually finish it. If in doubt, 'make world' again.
1532 # legacy: Build compatibility shims for the next three targets. This is a
1533 # minimal set of tools and shims necessary to compensate for older systems
1534 # which don't have the APIs required by the targets built in bootstrap-tools,
1535 # build-tools or cross-tools.
1538 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1539 # r296685 fix cross-endian objcopy
1540 .if ${BOOTSTRAPPING} < 1100102
1541 _elftoolchain_libs= lib/libelf lib/libdwarf
1545 .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
1546 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
1549 .for _tool in tools/build ${_elftoolchain_libs}
1550 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1551 cd ${.CURDIR}/${_tool}; \
1552 ${MAKE} DIRPRFX=${_tool}/ obj; \
1553 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1554 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
1555 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
1556 DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1560 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1561 # are built to build other binaries in the system. However, the focus of these
1562 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1563 # libraries, augmented by -legacy.
1565 _bt= _bootstrap-tools
1567 .if ${MK_GAMES} != "no"
1568 _strfile= usr.bin/fortune/strfile
1571 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1572 _gperf= gnu/usr.bin/gperf
1575 .if ${MK_GROFF} != "no"
1576 _groff= gnu/usr.bin/groff \
1580 .if ${MK_VT} != "no"
1581 _vtfontcvt= usr.bin/vtfontcvt
1584 .if ${BOOTSTRAPPING} < 900002
1588 .if ${BOOTSTRAPPING} < 1000033
1589 _libopenbsd= lib/libopenbsd
1593 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1594 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1597 .if ${BOOTSTRAPPING} < 1000026
1598 _nmtree= lib/libnetbsd \
1601 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1604 .if ${BOOTSTRAPPING} < 1000027
1608 # r264059 support for status=
1609 .if ${BOOTSTRAPPING} < 1100017
1613 # r277259 crunchide: Correct 64-bit section header offset
1614 # r281674 crunchide: always include both 32- and 64-bit ELF support
1615 .if ${BOOTSTRAPPING} < 1100078
1616 _crunchide= usr.sbin/crunch/crunchide
1619 # r285986 crunchen: use STRIPBIN rather than STRIP
1620 # 1100113: Support MK_AUTO_OBJ
1621 .if ${BOOTSTRAPPING} < 1100078 || \
1622 (${MK_AUTO_OBJ} == "yes" && ${BOOTSTRAPPING} < 1100114)
1623 _crunchgen= usr.sbin/crunch/crunchgen
1626 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1630 # r296926 -P keymap search path, MFC to stable/10 in r298297
1631 .if ${BOOTSTRAPPING} < 1003501 || \
1632 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
1633 _kbdcontrol= usr.sbin/kbdcontrol
1639 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1641 .if ${MK_BSNMP} != "no"
1642 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1645 # We need to build tblgen when we're building clang either as
1646 # the bootstrap compiler, or as the part of the normal build.
1647 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1649 lib/clang/libllvmsupport \
1650 lib/clang/libllvmtablegen \
1651 usr.bin/clang/llvm-tblgen \
1652 usr.bin/clang/clang-tblgen
1654 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1655 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1658 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1661 .if ${MK_GPL_DTC} != "no"
1662 _dtc= gnu/usr.bin/dtc
1665 .if ${MK_KERBEROS} != "no"
1666 _kerberos5_bootstrap_tools= \
1667 kerberos5/tools/make-roken \
1668 kerberos5/lib/libroken \
1669 kerberos5/lib/libvers \
1670 kerberos5/tools/asn1_compile \
1671 kerberos5/tools/slc \
1674 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1677 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
1678 .if ${MK_MANDOCDB} != "no" && ${BOOTSTRAPPING} < 1100075
1679 _libopenbsd?= lib/libopenbsd
1680 _makewhatis= lib/libsqlite3 \
1682 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1685 bootstrap-tools: .PHONY
1687 # Please document (add comment) why something is in 'bootstrap-tools'.
1688 # Try to bound the building of the bootstrap-tool to just the
1689 # FreeBSD versions that need the tool built at this stage of the build.
1692 ${_kerberos5_bootstrap_tools} \
1717 ${_bt}-${_tool}: .PHONY .MAKE
1718 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1719 cd ${.CURDIR}/${_tool}; \
1720 ${MAKE} DIRPRFX=${_tool}/ obj; \
1721 ${MAKE} DIRPRFX=${_tool}/ all; \
1722 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1724 bootstrap-tools: ${_bt}-${_tool}
1728 # build-tools: Build special purpose build tools
1730 .if !defined(NO_SHARE)
1731 _share= share/syscons/scrnmaps
1734 .if ${MK_GCC} != "no"
1735 _gcc_tools= gnu/usr.bin/cc/cc_tools
1738 .if ${MK_RESCUE} != "no"
1739 # rescue includes programs that have build-tools targets
1740 _rescue=rescue/rescue
1746 ${LOCAL_TOOL_DIRS} \
1747 lib/ncurses/ncurses \
1748 lib/ncurses/ncursesw \
1753 usr.bin/mkesdb_static \
1754 usr.bin/mkcsmapper_static \
1756 build-tools_${_tool}: .PHONY
1757 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1758 cd ${.CURDIR}/${_tool}; \
1759 ${MAKE} DIRPRFX=${_tool}/ obj; \
1760 ${MAKE} DIRPRFX=${_tool}/ build-tools
1761 build-tools: build-tools_${_tool}
1765 build-tools_${_tool}: .PHONY
1766 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \
1767 cd ${.CURDIR}/${_tool}; \
1768 ${MAKE} DIRPRFX=${_tool}/ obj; \
1769 ${MAKE} DIRPRFX=${_tool}/ all
1770 build-tools: build-tools_${_tool}
1774 # kernel-tools: Build kernel-building tools
1776 kernel-tools: .PHONY
1777 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1778 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1779 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1782 # cross-tools: All the tools needed to build the rest of the system after
1783 # we get done with the earlier stages. It is the last set of tools needed
1784 # to begin building the target binaries.
1786 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1787 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1788 _btxld= usr.sbin/btxld
1792 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1793 # resulting from missing bug fixes or ELF Toolchain updates.
1794 .if ${MK_CDDL} != "no"
1795 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1796 cddl/usr.bin/ctfmerge
1799 # If we're given an XAS, don't build binutils.
1800 .if ${XAS:M/*} == ""
1801 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1802 _binutils= gnu/usr.bin/binutils
1804 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1805 _elftctools= lib/libelftc \
1811 # These are not required by the build, but can be useful for developers who
1812 # cross-build on a FreeBSD 10 host:
1813 _elftctools+= usr.bin/addr2line
1815 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1816 # If cross-building with an external binutils we still need to build strip for
1817 # the target (for at least crunchide).
1818 _elftctools= lib/libelftc \
1823 .if ${MK_CLANG_BOOTSTRAP} != "no"
1824 _clang= usr.bin/clang
1825 _clang_libs= lib/clang
1827 .if ${MK_GCC_BOOTSTRAP} != "no"
1830 .if ${MK_USB} != "no"
1831 _usb_tools= sys/boot/usb/tools
1834 cross-tools: .MAKE .PHONY
1836 ${LOCAL_XTOOL_DIRS} \
1845 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1846 cd ${.CURDIR}/${_tool}; \
1847 ${MAKE} DIRPRFX=${_tool}/ obj; \
1848 ${MAKE} DIRPRFX=${_tool}/ all; \
1849 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1852 NXBDESTDIR= ${OBJTREE}/nxb-bin
1853 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1854 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1855 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1856 NXBMAKE= ${NXBENV} ${MAKE} \
1857 LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \
1858 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1859 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1860 MK_GDB=no MK_TESTS=no \
1862 MK_HTML=no NO_LINT=yes MK_MAN=no \
1863 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1864 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1865 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1866 MK_LLDB=no MK_DEBUG_FILES=no
1868 # native-xtools is the current target for qemu-user cross builds of ports
1869 # via poudriere and the imgact_binmisc kernel module.
1870 # For non-clang enabled targets that are still using the in tree gcc
1871 # we must build a gperf binary for one instance of its Makefiles. On
1872 # clang-enabled systems, the gperf binary is obsolete.
1873 native-xtools: .PHONY
1874 .if ${MK_GCC_BOOTSTRAP} != "no"
1875 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1876 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \
1877 cd ${.CURDIR}/${_gperf}; \
1878 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1879 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1880 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1882 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1883 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1884 -p ${NXBDESTDIR}/usr >/dev/null
1885 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1886 -p ${NXBDESTDIR}/usr/include >/dev/null
1887 .if ${MK_DEBUG_FILES} != "no"
1888 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1889 -p ${NXBDESTDIR}/usr/lib >/dev/null
1950 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1951 cd ${.CURDIR}/${_tool}; \
1952 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1953 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1954 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1958 # hierarchy - ensure that all the needed directories are present
1960 hierarchy hier: .MAKE .PHONY
1961 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1964 # libraries - build all libraries, and install them under ${DESTDIR}.
1966 # The list of libraries with dependents (${_prebuild_libs}) and their
1967 # interdependencies (__L) are built automatically by the
1968 # ${.CURDIR}/tools/make_libdeps.sh script.
1970 libraries: .MAKE .PHONY
1971 ${_+_}cd ${.CURDIR}; \
1972 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1973 ${MAKE} -f Makefile.inc1 _startup_libs; \
1974 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1975 ${MAKE} -f Makefile.inc1 _generic_libs
1978 # static libgcc.a prerequisite for shared libc
1980 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1982 # These dependencies are not automatically generated:
1984 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1985 # all shared libraries for ELF.
1987 _startup_libs= gnu/lib/csu
1988 _startup_libs+= lib/csu
1989 _startup_libs+= gnu/lib/libgcc
1990 _startup_libs+= lib/libcompiler_rt
1991 _startup_libs+= lib/libc
1992 _startup_libs+= lib/libc_nonshared
1993 .if ${MK_LIBCPLUSPLUS} != "no"
1994 _startup_libs+= lib/libcxxrt
1997 gnu/lib/libgcc__L: lib/libc__L
1998 gnu/lib/libgcc__L: lib/libc_nonshared__L
1999 .if ${MK_LIBCPLUSPLUS} != "no"
2000 lib/libcxxrt__L: gnu/lib/libgcc__L
2003 _prebuild_libs= ${_kerberos5_lib_libasn1} \
2004 ${_kerberos5_lib_libhdb} \
2005 ${_kerberos5_lib_libheimbase} \
2006 ${_kerberos5_lib_libheimntlm} \
2008 ${_kerberos5_lib_libheimipcc} \
2009 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
2010 ${_kerberos5_lib_libroken} \
2011 ${_kerberos5_lib_libwind} \
2012 lib/libbz2 ${_libcom_err} lib/libcrypt \
2013 lib/libelf lib/libexpat \
2016 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
2018 lib/ncurses/ncurses lib/ncurses/ncursesw \
2019 lib/libopie lib/libpam/libpam ${_lib_libthr} \
2020 ${_lib_libradius} lib/libsbuf lib/libtacplus \
2022 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
2023 ${_cddl_lib_libuutil} \
2024 ${_cddl_lib_libavl} \
2025 ${_cddl_lib_libzfs_core} \
2026 ${_cddl_lib_libctf} \
2027 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
2028 ${_secure_lib_libcrypto} ${_lib_libldns} \
2029 ${_secure_lib_libssh} ${_secure_lib_libssl} \
2032 .if ${MK_GNUCXX} != "no"
2033 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
2034 gnu/lib/libstdc++__L: lib/msun__L
2035 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
2038 .if ${MK_LIBCPLUSPLUS} != "no"
2039 _prebuild_libs+= lib/libc++
2042 lib/libgeom__L: lib/libexpat__L
2043 lib/libkvm__L: lib/libelf__L
2045 .if ${MK_LIBTHR} != "no"
2046 _lib_libthr= lib/libthr
2049 .if ${MK_RADIUS_SUPPORT} != "no"
2050 _lib_libradius= lib/libradius
2053 .if ${MK_OFED} != "no"
2054 _ofed_lib= contrib/ofed/usr.lib
2055 _prebuild_libs+= contrib/ofed/usr.lib/libosmcomp
2056 _prebuild_libs+= contrib/ofed/usr.lib/libopensm
2057 _prebuild_libs+= contrib/ofed/usr.lib/libibcommon
2058 _prebuild_libs+= contrib/ofed/usr.lib/libibverbs
2059 _prebuild_libs+= contrib/ofed/usr.lib/libibumad
2061 contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
2062 contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
2063 contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
2066 .if ${MK_CASPER} != "no"
2067 _lib_casper= lib/libcasper
2070 lib/libpjdlog__L: lib/libutil__L
2071 lib/libcasper__L: lib/libnv__L
2072 lib/liblzma__L: lib/libthr__L
2074 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
2075 .for _DIR in ${LOCAL_LIB_DIRS}
2076 .if exists(${.CURDIR}/${_DIR}/Makefile) && empty(_generic_libs:M${_DIR})
2077 _generic_libs+= ${_DIR}
2081 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2083 .if ${MK_CDDL} != "no"
2084 _cddl_lib_libumem= cddl/lib/libumem
2085 _cddl_lib_libnvpair= cddl/lib/libnvpair
2086 _cddl_lib_libavl= cddl/lib/libavl
2087 _cddl_lib_libuutil= cddl/lib/libuutil
2088 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2089 _cddl_lib_libctf= cddl/lib/libctf
2091 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2092 cddl/lib/libzfs__L: lib/libgeom__L
2093 cddl/lib/libctf__L: lib/libz__L
2095 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
2096 # on select architectures though (see cddl/lib/Makefile)
2097 .if ${MACHINE_CPUARCH} != "sparc64"
2098 _prebuild_libs+= lib/libprocstat lib/libproc lib/librtld_db
2099 lib/libprocstat__L: lib/libelf__L lib/libkvm__L lib/libutil__L
2100 lib/libproc__L: lib/libprocstat__L
2101 lib/librtld_db__L: lib/libprocstat__L
2104 .if ${MK_CRYPT} != "no"
2105 .if ${MK_OPENSSL} != "no"
2106 _secure_lib_libcrypto= secure/lib/libcrypto
2107 _secure_lib_libssl= secure/lib/libssl
2108 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2109 .if ${MK_LDNS} != "no"
2110 _lib_libldns= lib/libldns
2111 lib/libldns__L: secure/lib/libcrypto__L
2113 .if ${MK_OPENSSH} != "no"
2114 _secure_lib_libssh= secure/lib/libssh
2115 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2116 .if ${MK_LDNS} != "no"
2117 secure/lib/libssh__L: lib/libldns__L
2119 .if ${MK_KERBEROS_SUPPORT} != "no"
2120 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2121 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2122 lib/libmd__L kerberos5/lib/libroken__L
2126 _secure_lib= secure/lib
2129 .if ${MK_KERBEROS} != "no"
2130 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2131 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2132 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2133 kerberos5/lib/libwind__L lib/libsqlite3__L
2134 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2135 kerberos5/lib/libroken__L lib/libcom_err__L
2136 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2137 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2138 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2139 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2140 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2141 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2142 kerberos5/lib/libroken__L: lib/libcrypt__L
2143 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2144 kerberos5/lib/libheimbase__L: lib/libthr__L
2145 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2148 lib/libsqlite3__L: lib/libthr__L
2150 .if ${MK_GSSAPI} != "no"
2151 _lib_libgssapi= lib/libgssapi
2154 .if ${MK_KERBEROS} != "no"
2155 _kerberos5_lib= kerberos5/lib
2156 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2157 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2158 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2159 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2160 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2161 _kerberos5_lib_libroken= kerberos5/lib/libroken
2162 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2163 _libsqlite3= lib/libsqlite3
2164 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2165 _kerberos5_lib_libwind= kerberos5/lib/libwind
2166 _libcom_err= lib/libcom_err
2169 .if ${MK_NIS} != "no"
2170 _lib_libypclnt= lib/libypclnt
2173 .if ${MK_OPENSSL} == "no"
2174 lib/libradius__L: lib/libmd__L
2178 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2179 .if ${MK_CXX} != "no"
2180 .if ${MK_LIBCPLUSPLUS} != "no"
2181 lib/libproc__L: lib/libcxxrt__L
2182 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2183 lib/libproc__L: gnu/lib/libsupc++__L
2187 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2189 .for _lib in ${_prereq_libs}
2190 ${_lib}__PL: .PHONY .MAKE
2191 .if exists(${.CURDIR}/${_lib})
2192 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2193 cd ${.CURDIR}/${_lib}; \
2194 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2195 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2196 DIRPRFX=${_lib}/ all; \
2197 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2198 DIRPRFX=${_lib}/ install
2202 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
2203 ${_lib}__L: .PHONY .MAKE
2204 .if exists(${.CURDIR}/${_lib})
2205 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2206 cd ${.CURDIR}/${_lib}; \
2207 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2208 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2209 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2213 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2214 _startup_libs: ${_startup_libs:S/$/__L/}
2215 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2216 _generic_libs: ${_generic_libs:S/$/__L/}
2218 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2219 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2220 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2221 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2222 # parallel. This is safe for the world stage of buildworld though since it has
2223 # already built libraries in a proper order and installed includes into
2224 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2225 # avoid trashing a system if it crashes mid-install.
2226 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2230 .include <bsd.subdir.mk>
2232 .if make(check-old) || make(check-old-dirs) || \
2233 make(check-old-files) || make(check-old-libs) || \
2234 make(delete-old) || make(delete-old-dirs) || \
2235 make(delete-old-files) || make(delete-old-libs)
2238 # check for / delete old files section
2241 .include "ObsoleteFiles.inc"
2243 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2244 else you can not start such an application. Consult UPDATING for more \
2245 information regarding how to cope with the removal/revision bump of a \
2248 .if !defined(BATCH_DELETE_OLD_FILES)
2254 delete-old-files: .PHONY
2255 @echo ">>> Removing old files (only deletes safe to delete libs)"
2256 # Ask for every old file if the user really wants to remove it.
2257 # It's annoying, but better safe than sorry.
2258 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2259 # argument list will get too long. Using .for/.endfor make "loops" will make
2260 # the Makefile parser segfault.
2263 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2264 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2265 while read file; do \
2266 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2267 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2268 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2270 for ext in debug symbols; do \
2271 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2272 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2273 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2278 # Remove catpages without corresponding manpages.
2280 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2281 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2282 while read catpage; do \
2284 if [ ! -e "$${manpage}" ]; then \
2285 rm ${RM_I} $${catpage} <&3; \
2288 @echo ">>> Old files removed"
2290 check-old-files: .PHONY
2291 @echo ">>> Checking for old files"
2293 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2294 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2295 while read file; do \
2296 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2297 echo "${DESTDIR}/$${file}"; \
2299 for ext in debug symbols; do \
2300 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2301 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2305 # Check for catpages without corresponding manpages.
2306 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2307 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2308 while read catpage; do \
2310 if [ ! -e "$${manpage}" ]; then \
2315 delete-old-libs: .PHONY
2316 @echo ">>> Removing old libraries"
2317 @echo "${OLD_LIBS_MESSAGE}" | fmt
2320 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2321 -V OLD_LIBS | xargs -n1 | \
2322 while read file; do \
2323 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2324 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2325 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2327 for ext in debug symbols; do \
2328 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2329 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2330 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2335 @echo ">>> Old libraries removed"
2337 check-old-libs: .PHONY
2338 @echo ">>> Checking for old libraries"
2340 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2341 -V OLD_LIBS | xargs -n1 | \
2342 while read file; do \
2343 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2344 echo "${DESTDIR}/$${file}"; \
2346 for ext in debug symbols; do \
2347 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2348 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2353 delete-old-dirs: .PHONY
2354 @echo ">>> Removing old directories"
2356 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2357 -V OLD_DIRS | xargs -n1 | sort -r | \
2358 while read dir; do \
2359 if [ -d "${DESTDIR}/$${dir}" ]; then \
2360 rmdir -v "${DESTDIR}/$${dir}" || true; \
2361 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2362 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2365 @echo ">>> Old directories removed"
2367 check-old-dirs: .PHONY
2368 @echo ">>> Checking for old directories"
2370 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2371 -V OLD_DIRS | xargs -n1 | \
2372 while read dir; do \
2373 if [ -d "${DESTDIR}/$${dir}" ]; then \
2374 echo "${DESTDIR}/$${dir}"; \
2375 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2376 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2380 delete-old: delete-old-files delete-old-dirs .PHONY
2381 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2383 check-old: check-old-files check-old-libs check-old-dirs .PHONY
2384 @echo "To remove old files and directories run '${MAKE} delete-old'."
2385 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2390 # showconfig - show build configuration.
2393 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2394 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2396 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2397 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2399 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2400 .if exists(${KERNCONFDIR}/${KERNCONF})
2401 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2402 '${KERNCONFDIR}/${KERNCONF}' ; echo
2408 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2409 DTBOUTPUTPATH= ${.CURDIR}
2413 # Build 'standalone' Device Tree Blob
2416 @PATH=${TMPPATH} MACHINE=${TARGET} \
2417 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2418 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2423 # In the following, the first 'rm' in a series will usually remove all
2424 # files and directories. If it does not, then there are probably some
2425 # files with file flags set, so this unsets them and tries the 'rm' a
2426 # second time. There are situations where this target will be cleaning
2427 # some directories via more than one method, but that duplication is
2428 # needed to correctly handle all the possible situations. Removing all
2429 # files without file flags set in the first 'rm' instance saves time,
2430 # because 'chflags' will need to operate on fewer files afterwards.
2432 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2433 # created by bsd.obj.mk, except that we don't want to .include that file
2436 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2438 .if exists(${BW_CANONICALOBJDIR}/)
2439 -rm -rf ${BW_CANONICALOBJDIR}/*
2440 -chflags -R 0 ${BW_CANONICALOBJDIR}
2441 rm -rf ${BW_CANONICALOBJDIR}/*
2443 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2444 # To be safe in this case, fall back to a 'make cleandir'
2445 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2448 .if defined(TARGET) && defined(TARGET_ARCH)
2450 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2451 XDEV_CPUTYPE?=${CPUTYPE}
2453 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2456 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2457 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2458 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2459 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2460 CPUTYPE=${XDEV_CPUTYPE}
2462 XDDIR=${TARGET_ARCH}-freebsd
2465 .error XDTP variable should be an absolute path
2468 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2469 INSTALL="sh ${.CURDIR}/tools/install.sh"
2471 TOOLS_PREFIX=${XDTP}
2472 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2473 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2474 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2475 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2476 CPP="${CPP} ${CD2CFLAGS}" \
2477 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2479 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2480 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2481 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2482 XDDESTDIR=${DESTDIR}/${XDTP}
2484 OSREL!= uname -r | sed -e 's/[-(].*//'
2487 .ORDER: xdev-build xdev-install xdev-links
2488 xdev: xdev-build xdev-install .PHONY
2490 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2491 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
2493 _xb-worldtmp: .PHONY
2494 mkdir -p ${CDTMP}/usr
2495 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2496 -p ${CDTMP}/usr >/dev/null
2498 _xb-bootstrap-tools: .PHONY
2502 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2503 cd ${.CURDIR}/${_tool}; \
2504 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2505 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2506 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2509 _xb-build-tools: .PHONY
2510 ${_+_}@cd ${.CURDIR}; \
2511 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2513 _xb-cross-tools: .PHONY
2521 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2522 cd ${.CURDIR}/${_tool}; \
2523 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2524 ${CDMAKE} DIRPRFX=${_tool}/ all
2528 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2529 mkdir -p ${XDDESTDIR}
2530 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2531 -p ${XDDESTDIR} >/dev/null
2532 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2533 -p ${XDDESTDIR}/usr >/dev/null
2534 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2535 -p ${XDDESTDIR}/usr/include >/dev/null
2536 .if defined(LIBCOMPAT)
2537 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2538 -p ${XDDESTDIR}/usr >/dev/null
2540 .if ${MK_TESTS} != "no"
2541 mkdir -p ${XDDESTDIR}${TESTSBASE}
2542 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2543 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2546 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2547 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
2549 _xi-cross-tools: .PHONY
2550 @echo "_xi-cross-tools"
2558 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2559 cd ${.CURDIR}/${_tool}; \
2560 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2563 _xi-includes: .PHONY
2564 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2565 DESTDIR=${XDDESTDIR}
2567 _xi-libraries: .PHONY
2568 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2569 DESTDIR=${XDDESTDIR}
2572 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2573 mkdir -p ../../../../usr/bin; \
2575 ln -sf ../../${XDTP}/usr/bin/$$i \
2576 ../../../../usr/bin/${XDDIR}-$$i; \
2577 ln -sf ../../${XDTP}/usr/bin/$$i \
2578 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2581 xdev xdev-build xdev-install xdev-links: .PHONY
2582 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"