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 # METALOG="path to metadata log" to write permission and ownership
26 # when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
27 # TARGET="machine" to crossbuild world for a different machine type
28 # TARGET_ARCH= may be required when a TARGET supports multiple endians
29 # BUILDENV_SHELL= shell to launch for the buildenv target (def:${SHELL})
30 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
31 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
32 # SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
33 # All libraries and includes, and some build tools will still build.
36 # The intended user-driven targets are:
37 # buildworld - rebuild *everything*, including glue to help do upgrades
38 # installworld- install everything built by "buildworld"
39 # checkworld - run test suite on installed world
40 # doxygen - build API documentation of the kernel
41 # update - convenient way to update your source tree (eg: svn/svnup)
43 # Standard targets (not defined here) are documented in the makefiles in
44 # /usr/share/mk. These include:
45 # obj depend all install clean cleandepend cleanobj
47 .if !defined(TARGET) || !defined(TARGET_ARCH)
48 .error "Both TARGET and TARGET_ARCH must be defined."
51 LOCALBASE?= /usr/local
53 # Cross toolchain changes must be in effect before bsd.compiler.mk
54 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
55 .if defined(CROSS_TOOLCHAIN)
56 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
57 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
59 .if defined(CROSS_TOOLCHAIN_PREFIX)
60 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
61 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
63 # If we do not have a bootstrap binutils (because the in-tree one does not
64 # support the target architecture), provide a default cross-binutils prefix.
65 # This allows aarch64 builds, for example, to automatically use the
66 # aarch64-binutils port or package.
68 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
69 !defined(CROSS_BINUTILS_PREFIX)
70 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
71 .if !exists(${CROSS_BINUTILS_PREFIX})
72 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
77 XCOMPILERS= CC CXX CPP
78 .for COMPILER in ${XCOMPILERS}
79 .if defined(CROSS_COMPILER_PREFIX)
80 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
82 X${COMPILER}?= ${${COMPILER}}
85 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
86 .for BINUTIL in ${XBINUTILS}
87 .if defined(CROSS_BINUTILS_PREFIX) && \
88 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
89 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
91 X${BINUTIL}?= ${${BINUTIL}}
94 # If a full path to an external cross compiler is given, don't build
96 .if ${XCC:N${CCACHE_BIN}:M/*}
100 .include <bsd.compiler.mk> # don't depend on src.opts.mk doing it
101 .include "share/mk/src.opts.mk"
103 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
104 # keep the users system reasonably usable. For static->dynamic root upgrades,
105 # we don't want to install a dynamic binary without rtld and the needed
106 # libraries. More commonly, for dynamic root, we don't want to install a
107 # binary that requires a newer library version that hasn't been installed yet.
108 # This ordering is not a guarantee though. The only guarantee of a working
109 # system here would require fine-grained ordering of all components based
110 # on their dependencies.
112 .if !empty(SUBDIR_OVERRIDE)
113 SUBDIR= ${SUBDIR_OVERRIDE}
116 .if !defined(NO_ROOT) && (make(installworld) || make(install))
117 # Ensure libraries are installed before progressing.
121 .if ${MK_CDDL} != "no"
125 .if ${MK_KERBEROS} != "no"
128 .if ${MK_RESCUE} != "no"
132 .if ${MK_CRYPT} != "no"
135 .if !defined(NO_SHARE)
138 SUBDIR+=sys usr.bin usr.sbin
139 .if ${MK_TESTS} != "no"
142 .if ${MK_OFED} != "no"
146 # Local directories are last, since it is nice to at least get the base
147 # system rebuilt before you do them.
148 .for _DIR in ${LOCAL_DIRS}
149 .if exists(${.CURDIR}/${_DIR}/Makefile)
153 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
154 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
155 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
156 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
157 _REDUNDENT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
159 .for _DIR in ${LOCAL_LIB_DIRS}
160 .if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
163 .warning ${_DIR} not added to SUBDIR list. See UPDATING 20141121.
167 # We must do etc/ last as it hooks into building the man whatis file
168 # by calling 'makedb' in share/man. This is only relevant for
169 # install/distribute so they build the whatis file after every manpage is
171 .if make(installworld) || make(install)
176 .endif # !empty(SUBDIR_OVERRIDE)
179 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
182 .if defined(NO_CLEANDIR)
183 CLEANDIR= clean cleandepend
188 .if ${MK_META_MODE} == "yes"
189 # If filemon is used then we can rely on the build being incremental-safe.
190 # The .meta files will also track the build command and rebuild should
192 .if empty(.MAKE.MODE:Mnofilemon)
198 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
200 .if empty(SHELL:M*csh*)
201 BUILDENV_SHELL?=${SHELL}
203 BUILDENV_SHELL?=/bin/sh
206 .if !defined(SVN) || empty(SVN)
207 . for _P in /usr/bin /usr/local/bin
208 . for _S in svn svnlite
209 . if exists(${_P}/${_S})
217 MAKEOBJDIRPREFIX?= /usr/obj
218 .if !defined(OSRELDATE)
219 .if exists(/usr/include/osreldate.h)
220 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
221 /usr/include/osreldate.h
228 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
229 .if !defined(_REVISION)
230 _REVISION!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V REVISION
233 .if !defined(_BRANCH)
234 _BRANCH!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V BRANCH
237 .if !defined(SRCRELDATE)
238 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
239 ${SRCDIR}/sys/sys/param.h
242 .if !defined(VERSION)
243 VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
247 .if !defined(PKG_VERSION)
248 .if ${_BRANCH:MSTABLE*} || ${_BRANCH:MCURRENT*}
249 TIMENOW= %Y%m%d%H%M%S
250 EXTRA_REVISION= .s${TIMENOW:gmtime}
253 EXTRA_REVISION= _${_BRANCH:C/.*-p([0-9]+$)/\1/}
255 PKG_VERSION= ${_REVISION}${EXTRA_REVISION}
258 KNOWN_ARCHES?= aarch64/arm64 \
276 .if ${TARGET} == ${TARGET_ARCH}
279 _t= ${TARGET_ARCH}/${TARGET}
282 .if empty(KNOWN_ARCHES:M${_t})
283 .error Unknown target ${TARGET_ARCH}:${TARGET}.
287 .if ${TARGET} == ${MACHINE}
288 TARGET_CPUTYPE?=${CPUTYPE}
293 .if !empty(TARGET_CPUTYPE)
294 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
296 _TARGET_CPUTYPE=dummy
298 _CPUTYPE!= MK_AUTO_OBJ=no MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
299 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
300 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
301 .error CPUTYPE global should be set with ?=.
304 BUILD_ARCH!= uname -p
305 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
306 .error To cross-build, set TARGET_ARCH.
309 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
310 OBJTREE= ${MAKEOBJDIRPREFIX}
312 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
314 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
315 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
316 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
317 STRICTTMPPATH= ${BPATH}:${XPATH}
318 TMPPATH= ${STRICTTMPPATH}:${PATH}
321 # Avoid running mktemp(1) unless actually needed.
322 # It may not be functional, e.g., due to new ABI
323 # when in the middle of installing over this system.
325 .if make(distributeworld) || make(installworld) || make(stageworld)
326 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
329 .if make(stagekernel) || make(distributekernel)
335 # Building a world goes through the following stages
337 # 1. legacy stage [BMAKE]
338 # This stage is responsible for creating compatibility
339 # shims that are needed by the bootstrap-tools,
340 # build-tools and cross-tools stages. These are generally
341 # APIs that tools from one of those three stages need to
342 # build that aren't present on the host.
343 # 1. bootstrap-tools stage [BMAKE]
344 # This stage is responsible for creating programs that
345 # are needed for backward compatibility reasons. They
346 # are not built as cross-tools.
347 # 2. build-tools stage [TMAKE]
348 # This stage is responsible for creating the object
349 # tree and building any tools that are needed during
350 # the build process. Some programs are listed during
351 # this phase because they build binaries to generate
352 # files needed to build these programs. This stage also
353 # builds the 'build-tools' target rather than 'all'.
354 # 3. cross-tools stage [XMAKE]
355 # This stage is responsible for creating any tools that
356 # are needed for building the system. A cross-compiler is one
357 # of them. This differs from build tools in two ways:
358 # 1. the 'all' target is built rather than 'build-tools'
359 # 2. these tools are installed into TMPPATH for stage 4.
360 # 4. world stage [WMAKE]
361 # This stage actually builds the world.
362 # 5. install stage (optional) [IMAKE]
363 # This stage installs a previously built world.
368 # Common environment for world related stages
369 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
370 MACHINE_ARCH=${TARGET_ARCH} \
372 CPUTYPE=${TARGET_CPUTYPE}
373 .if ${MK_META_MODE} != "no"
374 # Don't rebuild build-tools targets during normal build.
375 CROSSENV+= BUILD_TOOLS_META=.NOMETA_CMP
377 .if ${MK_GROFF} != "no"
378 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
379 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
380 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
382 .if defined(TARGET_CFLAGS)
383 CROSSENV+= ${TARGET_CFLAGS}
386 # bootstrap-tools stage
387 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
388 TOOLS_PREFIX=${WORLDTMP} \
389 PATH=${BPATH}:${PATH} \
390 WORLDTMP=${WORLDTMP} \
391 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
392 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
394 BOOTSTRAPPING=${OSRELDATE} \
396 MK_HTML=no NO_LINT=yes MK_MAN=no \
397 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
398 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
399 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
400 MK_LLDB=no MK_TESTS=no \
403 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
404 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
408 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
409 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
410 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
412 BOOTSTRAPPING=${OSRELDATE} \
415 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
416 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
417 MK_LLDB=no MK_TESTS=no
420 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
421 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
422 MK_GDB=no MK_TESTS=no
425 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
426 PATH=${BPATH}:${PATH} \
428 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
429 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
431 BOOTSTRAPPING=${OSRELDATE} \
433 MK_HTML=no -DNO_LINT MK_MAN=no \
434 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
435 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
438 WMAKEENV= ${CROSSENV} \
439 INSTALL="sh ${.CURDIR}/tools/install.sh" \
443 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
445 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
448 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
449 CPP="${XCPP} ${XCFLAGS}" \
450 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
451 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
452 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
455 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
456 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
457 # directory, but the compiler will look in the right place for its
458 # tools so we don't need to tell it where to look.
459 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
462 # External compiler needs sysroot and target flags.
463 .if ${MK_CROSS_COMPILER} == "no" || \
464 (${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no")
465 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
466 BFLAGS+= -B${WORLDTMP}/usr/bin
468 .if ${TARGET} == "arm"
469 .if ${TARGET_ARCH:Marmv6*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
470 TARGET_ABI= gnueabihf
475 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
476 # GCC requires -isystem and -L when using a cross-compiler.
477 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
478 # Force using libc++ for external GCC.
479 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
480 -nostdinc++ -L${WORLDTMP}/../lib/libc++
483 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
484 XCFLAGS+= -target ${TARGET_TRIPLE}
486 XCFLAGS+= --sysroot=${WORLDTMP}
488 .endif # ${MK_CROSS_COMPILER} == "no"
494 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
495 ${TARGET_ARCH} == "powerpc64")
497 .include "Makefile.libcompat"
498 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH} == "armv6"
500 .include "Makefile.libcompat"
503 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
505 IMAKEENV= ${CROSSENV}
506 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
507 ${IMAKE_INSTALL} ${IMAKE_MTREE}
508 .if empty(.MAKEFLAGS:M-n)
509 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
510 LD_LIBRARY_PATH=${INSTALLTMP} \
511 PATH_LOCALE=${INSTALLTMP}/locale
512 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
514 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
516 .if defined(DB_FROM_SRC)
517 INSTALLFLAGS+= -N ${.CURDIR}/etc
518 MTREEFLAGS+= -N ${.CURDIR}/etc
520 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
521 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
523 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
524 IMAKE+= -DNO_ROOT METALOG=${METALOG}
525 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
528 .if defined(BUILD_PKGS)
529 INSTALLFLAGS+= -h sha256
531 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
532 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
533 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
537 KMAKEENV= ${WMAKEENV}
538 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
539 .if ${MK_META_MODE} == "yes"
540 # meta mode normally is disallowed when building from curdir==objdir, but we
541 # want to allow it for the kernel build.
542 KMAKEENV+= META_MODE="${.MAKE.MODE} curdirOk=yes"
548 # Attempt to rebuild the entire system, with reasonable chance of
549 # success, regardless of how old your existing system is.
552 .if ${.CURDIR:C/[^,]//g} != ""
553 # The m4 build of sendmail files doesn't like it if ',' is used
554 # anywhere in the path of it's files.
556 @echo "*** Error: path to source tree contains a comma ','"
561 @echo "--------------------------------------------------------------"
562 @echo ">>> Rebuilding the temporary build tree"
563 @echo "--------------------------------------------------------------"
564 .if !defined(NO_CLEAN)
566 .if defined(LIBCOMPAT)
567 rm -rf ${LIBCOMPATTMP}
570 rm -rf ${WORLDTMP}/legacy/usr/include
571 # XXX - These can depend on any header file.
572 rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c
573 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
576 lib lib/casper usr legacy/bin legacy/usr
577 mkdir -p ${WORLDTMP}/${_dir}
579 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
580 -p ${WORLDTMP}/legacy/usr >/dev/null
581 .if ${MK_GROFF} != "no"
582 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
583 -p ${WORLDTMP}/legacy/usr >/dev/null
585 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
586 -p ${WORLDTMP}/usr >/dev/null
587 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
588 -p ${WORLDTMP}/usr/include >/dev/null
589 ln -sf ${.CURDIR}/sys ${WORLDTMP}
590 .if ${MK_DEBUG_FILES} != "no"
591 # We could instead disable debug files for these build stages
592 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
593 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
594 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
595 -p ${WORLDTMP}/usr/lib >/dev/null
597 .if defined(LIBCOMPAT)
598 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
599 -p ${WORLDTMP}/usr >/dev/null
600 .if ${MK_DEBUG_FILES} != "no"
601 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
602 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
603 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
604 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
607 .if ${MK_TESTS} != "no"
608 mkdir -p ${WORLDTMP}${TESTSBASE}
609 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
610 -p ${WORLDTMP}${TESTSBASE} >/dev/null
611 .if ${MK_DEBUG_FILES} != "no"
612 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
613 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
614 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
617 .for _mtree in ${LOCAL_MTREE}
618 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
622 @echo "--------------------------------------------------------------"
623 @echo ">>> stage 1.1: legacy release compatibility shims"
624 @echo "--------------------------------------------------------------"
625 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
628 @echo "--------------------------------------------------------------"
629 @echo ">>> stage 1.2: bootstrap tools"
630 @echo "--------------------------------------------------------------"
631 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
633 .if !defined(NO_CLEAN)
635 @echo "--------------------------------------------------------------"
636 @echo ">>> stage 2.1: cleaning up the object tree"
637 @echo "--------------------------------------------------------------"
638 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
639 .if defined(LIBCOMPAT)
640 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
645 @echo "--------------------------------------------------------------"
646 @echo ">>> stage 2.2: rebuilding the object tree"
647 @echo "--------------------------------------------------------------"
648 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
651 @echo "--------------------------------------------------------------"
652 @echo ">>> stage 2.3: build tools"
653 @echo "--------------------------------------------------------------"
654 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
657 @echo "--------------------------------------------------------------"
658 @echo ">>> stage 3: cross tools"
659 @echo "--------------------------------------------------------------"
660 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
661 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
664 @echo "--------------------------------------------------------------"
665 @echo ">>> stage 4.1: building includes"
666 @echo "--------------------------------------------------------------"
667 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
668 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
669 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
670 MK_INCLUDES=yes includes
671 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
672 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
676 @echo "--------------------------------------------------------------"
677 @echo ">>> stage 4.2: building libraries"
678 @echo "--------------------------------------------------------------"
679 ${_+_}cd ${.CURDIR}; \
680 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
681 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
684 @echo "--------------------------------------------------------------"
685 @echo ">>> stage 4.3: building everything"
686 @echo "--------------------------------------------------------------"
687 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
690 WMAKE_TGTS+= _worldtmp _legacy
691 .if empty(SUBDIR_OVERRIDE)
692 WMAKE_TGTS+= _bootstrap-tools
694 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
695 WMAKE_TGTS+= _includes _libraries
696 WMAKE_TGTS+= everything
697 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
698 WMAKE_TGTS+= build${libcompat}
701 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
702 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
704 buildworld_prologue: .PHONY
705 @echo "--------------------------------------------------------------"
706 @echo ">>> World build started on `LC_ALL=C date`"
707 @echo "--------------------------------------------------------------"
709 buildworld_epilogue: .PHONY
711 @echo "--------------------------------------------------------------"
712 @echo ">>> World build completed on `LC_ALL=C date`"
713 @echo "--------------------------------------------------------------"
716 # We need to have this as a target because the indirection between Makefile
717 # and Makefile.inc1 causes the correct PATH to be used, rather than a
718 # modification of the current environment's PATH. In addition, we need
719 # to quote multiword values.
722 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
724 .if ${.TARGETS:Mbuildenv}
725 .if ${.MAKEFLAGS:M-j}
726 .error The buildenv target is incompatible with -j
729 BUILDENV_DIR?= ${.CURDIR}
731 @echo Entering world for ${TARGET_ARCH}:${TARGET}
732 .if ${BUILDENV_SHELL:M*zsh*}
733 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
735 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
738 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
739 toolchain: ${TOOLCHAIN_TGTS} .PHONY
740 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries} .PHONY
745 # Checks to be sure system is ready for installworld/installkernel.
747 installcheck: _installcheck_world _installcheck_kernel .PHONY
748 _installcheck_world: .PHONY
749 _installcheck_kernel: .PHONY
752 # Require DESTDIR to be set if installing for a different architecture or
753 # using the user/group database in the source tree.
755 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
757 .if !make(distributeworld)
758 _installcheck_world: __installcheck_DESTDIR
759 _installcheck_kernel: __installcheck_DESTDIR
760 __installcheck_DESTDIR: .PHONY
761 .if !defined(DESTDIR) || empty(DESTDIR)
762 @echo "ERROR: Please set DESTDIR!"; \
768 .if !defined(DB_FROM_SRC)
770 # Check for missing UIDs/GIDs.
772 CHECK_UIDS= auditdistd
774 .if ${MK_SENDMAIL} != "no"
780 CHECK_GIDS+= proxy authpf
782 .if ${MK_UNBOUND} != "no"
786 _installcheck_world: __installcheck_UGID
787 __installcheck_UGID: .PHONY
788 .for uid in ${CHECK_UIDS}
789 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
790 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
794 .for gid in ${CHECK_GIDS}
795 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
796 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
803 # Required install tools to be saved in a scratch dir for safety.
805 .if ${MK_ZONEINFO} != "no"
806 _zoneinfo= zic tzsetup
809 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
810 date echo egrep find grep id install ${_install-info} \
811 ln make mkdir mtree mv pwd_mkdb \
812 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
815 # Needed for share/man
816 .if ${MK_MAN} != "no"
823 # Distributes everything compiled by a `buildworld'.
827 # Installs everything compiled by a 'buildworld'.
830 # Non-base distributions produced by the base system
831 EXTRA_DISTRIBUTIONS= doc
832 .if defined(LIBCOMPAT)
833 EXTRA_DISTRIBUTIONS+= lib${libcompat}
835 .if ${MK_TESTS} != "no"
836 EXTRA_DISTRIBUTIONS+= tests
840 .if ${MK_DEBUG_FILES} != "no"
841 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
844 MTREE_MAGIC?= mtree 2.0
846 distributeworld installworld stageworld: _installcheck_world .PHONY
847 mkdir -p ${INSTALLTMP}
848 progs=$$(for prog in ${ITOOLS}; do \
849 if progpath=`which $$prog`; then \
852 echo "Required tool $$prog not found in PATH." >&2; \
856 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
857 while read line; do \
859 if [ "$$2 $$3" != "not found" ]; then \
862 echo "Required library $$1 not found." >&2; \
866 cp $$libs $$progs ${INSTALLTMP}
867 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
869 -mkdir -p ${METALOG:H}
870 echo "#${MTREE_MAGIC}" > ${METALOG}
872 .if make(distributeworld)
873 .for dist in ${EXTRA_DISTRIBUTIONS}
874 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
875 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
876 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
877 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
878 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
879 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
880 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
881 .if ${MK_DEBUG_FILES} != "no"
882 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
883 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
885 .if defined(LIBCOMPAT)
886 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
887 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
888 .if ${MK_DEBUG_FILES} != "no"
889 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
890 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
893 .if ${MK_TESTS} != "no" && ${dist} == "tests"
894 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
895 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
896 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
897 .if ${MK_DEBUG_FILES} != "no"
898 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
899 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
903 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
904 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
905 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
906 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
907 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
908 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
909 .if defined(LIBCOMPAT)
910 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
911 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
915 -mkdir ${DESTDIR}/${DISTDIR}/base
916 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
917 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
918 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
919 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
921 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
922 ${IMAKEENV} rm -rf ${INSTALLTMP}
923 .if make(distributeworld)
924 .for dist in ${EXTRA_DISTRIBUTIONS}
925 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
928 .for dist in base ${EXTRA_DISTRIBUTIONS}
929 @# For each file that exists in this dist, print the corresponding
930 @# line from the METALOG. This relies on the fact that
931 @# a line containing only the filename will sort immediately before
932 @# the relevant mtree line.
933 cd ${DESTDIR}/${DISTDIR}; \
934 find ./${dist} | sort -u ${METALOG} - | \
935 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
936 ${DESTDIR}/${DISTDIR}/${dist}.meta
938 .for dist in ${DEBUG_DISTRIBUTIONS}
939 @# For each file that exists in this dist, print the corresponding
940 @# line from the METALOG. This relies on the fact that
941 @# a line containing only the filename will sort immediately before
942 @# the relevant mtree line.
943 cd ${DESTDIR}/${DISTDIR}; \
944 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
945 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
946 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
952 .for dist in base ${EXTRA_DISTRIBUTIONS}
954 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
955 tar cvf - --exclude usr/lib/debug \
956 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
957 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
959 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
960 tar cvf - --exclude usr/lib/debug . | \
961 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
965 .for dist in ${DEBUG_DISTRIBUTIONS}
966 . if defined(NO_ROOT)
967 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
968 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
969 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
971 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
972 tar cvLf - usr/lib/debug | \
973 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
980 # If you have a build server, you can NFS mount the source and obj directories
981 # and do a 'make reinstall' on the *client* to install new binaries from the
982 # most recent server build.
984 restage reinstall: .MAKE .PHONY
985 @echo "--------------------------------------------------------------"
986 @echo ">>> Making hierarchy"
987 @echo "--------------------------------------------------------------"
988 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
989 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
991 @echo "--------------------------------------------------------------"
992 @echo ">>> Making distribution"
993 @echo "--------------------------------------------------------------"
994 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
995 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
998 @echo "--------------------------------------------------------------"
999 @echo ">>> Installing everything"
1000 @echo "--------------------------------------------------------------"
1001 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1002 .if defined(LIBCOMPAT)
1003 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1006 redistribute: .MAKE .PHONY
1007 @echo "--------------------------------------------------------------"
1008 @echo ">>> Distributing everything"
1009 @echo "--------------------------------------------------------------"
1010 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1011 .if defined(LIBCOMPAT)
1012 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1013 DISTRIBUTION=lib${libcompat}
1016 distrib-dirs distribution: .MAKE .PHONY
1017 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1018 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1019 .if make(distribution)
1020 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1021 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1022 METALOG=${METALOG} MK_TESTS=no installconfig
1026 # buildkernel and installkernel
1028 # Which kernels to build and/or install is specified by setting
1029 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1030 # Only the existing (depending TARGET) config files are used
1031 # for building kernels and only the first of these is designated
1032 # as the one being installed.
1034 # Note that we have to use TARGET instead of TARGET_ARCH when
1035 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1036 # be set to cross-build, we have to make sure TARGET is set
1039 .if defined(KERNFAST)
1043 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1044 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1045 KERNCONF=${KERNFAST}
1048 .if ${TARGET_ARCH} == "powerpc64"
1049 KERNCONF?= GENERIC64
1053 INSTKERNNAME?= kernel
1055 KERNSRCDIR?= ${.CURDIR}/sys
1056 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1057 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1058 KERNCONFDIR?= ${KRNLCONFDIR}
1062 .if defined(NO_INSTALLKERNEL)
1063 # All of the BUILDKERNELS loops start at index 1.
1064 BUILDKERNELS+= dummy
1066 .for _kernel in ${KERNCONF}
1067 .if exists(${KERNCONFDIR}/${_kernel})
1068 BUILDKERNELS+= ${_kernel}
1069 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1070 INSTALLKERNEL= ${_kernel}
1075 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1080 # Builds all kernels defined by BUILDKERNELS.
1082 buildkernel: .MAKE .PHONY
1083 .if empty(BUILDKERNELS:Ndummy)
1084 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1088 .for _kernel in ${BUILDKERNELS:Ndummy}
1089 @echo "--------------------------------------------------------------"
1090 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1091 @echo "--------------------------------------------------------------"
1092 @echo "===> ${_kernel}"
1093 mkdir -p ${KRNLOBJDIR}
1094 .if !defined(NO_KERNELCONFIG)
1096 @echo "--------------------------------------------------------------"
1097 @echo ">>> stage 1: configuring the kernel"
1098 @echo "--------------------------------------------------------------"
1099 cd ${KRNLCONFDIR}; \
1101 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1102 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1104 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1106 @echo "--------------------------------------------------------------"
1107 @echo ">>> stage 2.1: cleaning up the object tree"
1108 @echo "--------------------------------------------------------------"
1109 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1111 .if !defined(NO_KERNELOBJ)
1113 @echo "--------------------------------------------------------------"
1114 @echo ">>> stage 2.2: rebuilding the object tree"
1115 @echo "--------------------------------------------------------------"
1116 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1119 @echo "--------------------------------------------------------------"
1120 @echo ">>> stage 2.3: build tools"
1121 @echo "--------------------------------------------------------------"
1122 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1124 @echo "--------------------------------------------------------------"
1125 @echo ">>> stage 3.1: building everything"
1126 @echo "--------------------------------------------------------------"
1127 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1128 @echo "--------------------------------------------------------------"
1129 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1130 @echo "--------------------------------------------------------------"
1133 NO_INSTALLEXTRAKERNELS?= yes
1136 # installkernel, etc.
1138 # Install the kernel defined by INSTALLKERNEL
1140 installkernel installkernel.debug \
1141 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1142 .if !defined(NO_INSTALLKERNEL)
1143 .if empty(INSTALLKERNEL)
1144 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1147 @echo "--------------------------------------------------------------"
1148 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1149 @echo "--------------------------------------------------------------"
1150 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1151 ${CROSSENV} PATH=${TMPPATH} \
1152 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1154 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1155 .for _kernel in ${BUILDKERNELS:[2..-1]}
1156 @echo "--------------------------------------------------------------"
1157 @echo ">>> Installing kernel ${_kernel}"
1158 @echo "--------------------------------------------------------------"
1159 cd ${KRNLOBJDIR}/${_kernel}; \
1160 ${CROSSENV} PATH=${TMPPATH} \
1161 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1165 distributekernel distributekernel.debug: .PHONY
1166 .if !defined(NO_INSTALLKERNEL)
1167 .if empty(INSTALLKERNEL)
1168 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1171 mkdir -p ${DESTDIR}/${DISTDIR}
1172 .if defined(NO_ROOT)
1173 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1175 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1176 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1177 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1178 DESTDIR=${INSTALL_DDIR}/kernel \
1179 ${.TARGET:S/distributekernel/install/}
1180 .if defined(NO_ROOT)
1181 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1182 ${DESTDIR}/${DISTDIR}/kernel.meta
1185 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1186 .for _kernel in ${BUILDKERNELS:[2..-1]}
1187 .if defined(NO_ROOT)
1188 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1190 cd ${KRNLOBJDIR}/${_kernel}; \
1191 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1192 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1193 KERNEL=${INSTKERNNAME}.${_kernel} \
1194 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1195 ${.TARGET:S/distributekernel/install/}
1196 .if defined(NO_ROOT)
1197 @sed -e "s|^./kernel.${_kernel}|.|" \
1198 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1199 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1204 packagekernel: .PHONY
1205 .if defined(NO_ROOT)
1206 .if !defined(NO_INSTALLKERNEL)
1207 cd ${DESTDIR}/${DISTDIR}/kernel; \
1208 tar cvf - --exclude '*.debug' \
1209 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1210 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1212 cd ${DESTDIR}/${DISTDIR}/kernel; \
1213 tar cvf - --include '*/*/*.debug' \
1214 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1215 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1216 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1217 .for _kernel in ${BUILDKERNELS:[2..-1]}
1218 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1219 tar cvf - --exclude '*.debug' \
1220 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1221 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1222 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1223 tar cvf - --include '*/*/*.debug' \
1224 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1225 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1229 .if !defined(NO_INSTALLKERNEL)
1230 cd ${DESTDIR}/${DISTDIR}/kernel; \
1231 tar cvf - --exclude '*.debug' . | \
1232 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1234 cd ${DESTDIR}/${DISTDIR}/kernel; \
1235 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1236 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1237 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1238 .for _kernel in ${BUILDKERNELS:[2..-1]}
1239 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1240 tar cvf - --exclude '*.debug' . | \
1241 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1242 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1243 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1244 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1250 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1252 PORTSDIR?= /usr/ports
1253 WSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/worldstage
1254 KSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/kernelstage
1255 REPODIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/repo
1256 PKGSIGNKEY?= # empty
1258 .ORDER: stage-packages create-packages
1259 .ORDER: create-packages create-world-packages
1260 .ORDER: create-packages create-kernel-packages
1261 .ORDER: create-packages sign-packages
1263 _pkgbootstrap: .PHONY
1264 .if !exists(${LOCALBASE}/sbin/pkg)
1265 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1269 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1272 rm -rf /tmp/ports.${TARGET} || :
1273 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
1274 PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} WSTAGEDIR=${WSTAGEDIR} \
1275 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1277 real-packages: stage-packages create-packages sign-packages .PHONY
1279 stage-packages: .PHONY
1280 @mkdir -p ${REPODIR} ${WSTAGEDIR} ${KSTAGEDIR}
1281 ${_+_}@cd ${.CURDIR}; \
1282 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT -B stageworld ; \
1283 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT -B stagekernel
1285 create-packages: _pkgbootstrap .PHONY
1286 @mkdir -p ${REPODIR}
1287 ${_+_}@cd ${.CURDIR}; \
1288 ${MAKE} DESTDIR=${WSTAGEDIR} \
1289 PKG_VERSION=${PKG_VERSION} create-world-packages ; \
1290 ${MAKE} DESTDIR=${KSTAGEDIR} \
1291 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1292 create-kernel-packages
1294 create-world-packages: _pkgbootstrap .PHONY
1295 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1296 @cd ${WSTAGEDIR} ; \
1297 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1298 ${WSTAGEDIR}/METALOG
1299 @for plist in ${WSTAGEDIR}/*.plist; do \
1300 plist=$${plist##*/} ; \
1301 pkgname=$${plist%.plist} ; \
1302 sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \
1303 -s ${SRCDIR} -u ${WSTAGEDIR}/$${pkgname}.ucl ; \
1305 @for plist in ${WSTAGEDIR}/*.plist; do \
1306 plist=$${plist##*/} ; \
1307 pkgname=$${plist%.plist} ; \
1309 /^name/ { printf("===> Creating %s-", $$2); next } \
1310 /^version/ { print $$2; next } \
1311 ' ${WSTAGEDIR}/$${pkgname}.ucl ; \
1312 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1313 create -M ${WSTAGEDIR}/$${pkgname}.ucl \
1314 -p ${WSTAGEDIR}/$${pkgname}.plist \
1316 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} ; \
1319 create-kernel-packages: _pkgbootstrap .PHONY
1320 .if exists(${KSTAGEDIR}/kernel.meta)
1321 .for flavor in "" -debug
1322 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1323 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1324 -v kernel=yes -v _kernconf=${INSTALLKERNEL} \
1325 ${KSTAGEDIR}/kernel.meta ; \
1326 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1327 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1328 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1329 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1330 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1331 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1332 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1333 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1334 ${SRCDIR}/release/packages/kernel.ucl \
1335 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1337 /name/ { printf("===> Creating %s-", $$2); next } \
1338 /version/ {print $$2; next } ' \
1339 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1340 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1341 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1342 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1343 -r ${KSTAGEDIR}/${DISTDIR} \
1344 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1347 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1348 .for _kernel in ${BUILDKERNELS:[2..-1]}
1349 .if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1350 .for flavor in "" -debug
1351 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1352 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1353 -v kernel=yes -v _kernconf=${_kernel} \
1354 ${KSTAGEDIR}/kernel.${_kernel}.meta ; \
1355 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1356 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1357 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1358 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1359 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1360 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1361 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1362 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1363 ${SRCDIR}/release/packages/kernel.ucl \
1364 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1366 /name/ { printf("===> Creating %s-", $$2); next } \
1367 /version/ {print $$2; next } ' \
1368 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1369 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1370 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1371 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1372 -r ${KSTAGEDIR}/kernel.${_kernel} \
1373 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1379 sign-packages: _pkgbootstrap .PHONY
1380 @[ -L "${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1381 unlink ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1382 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1383 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1384 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1386 ln -s ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1387 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest
1393 # Run test suite on installed world.
1396 @if [ ! -x ${LOCALBASE}/bin/kyua ]; then \
1397 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1400 ${_+_}${LOCALBASE}/bin/kyua test -k ${TESTSBASE}/Kyuafile
1406 # Build the API documentation with doxygen
1409 @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1410 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1413 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1418 # Update the source tree(s), by running svn/svnup to update to the
1422 .if defined(SVN_UPDATE)
1423 @echo "--------------------------------------------------------------"
1424 @echo ">>> Updating ${.CURDIR} using Subversion"
1425 @echo "--------------------------------------------------------------"
1426 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1430 # ------------------------------------------------------------------------
1432 # From here onwards are utility targets used by the 'make world' and
1433 # related targets. If your 'world' breaks, you may like to try to fix
1434 # the problem and manually run the following targets to attempt to
1435 # complete the build. Beware, this is *not* guaranteed to work, you
1436 # need to have a pretty good grip on the current state of the system
1437 # to attempt to manually finish it. If in doubt, 'make world' again.
1441 # legacy: Build compatibility shims for the next three targets. This is a
1442 # minimal set of tools and shims necessary to compensate for older systems
1443 # which don't have the APIs required by the targets built in bootstrap-tools,
1444 # build-tools or cross-tools.
1447 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1448 # r296685 fix cross-endian objcopy
1449 .if ${BOOTSTRAPPING} < 1100102
1450 _elftoolchain_libs= lib/libelf lib/libdwarf
1454 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1455 @echo "ERROR: Source upgrades from versions prior to 8.0 are not supported."; \
1458 .for _tool in tools/build ${_elftoolchain_libs}
1459 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1460 cd ${.CURDIR}/${_tool}; \
1461 ${MAKE} DIRPRFX=${_tool}/ obj; \
1462 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1463 ${MAKE} DIRPRFX=${_tool}/ all; \
1464 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1468 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1469 # are built to build other binaries in the system. However, the focus of these
1470 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1471 # libraries, augmented by -legacy.
1473 _bt= _bootstrap-tools
1475 .if ${MK_GAMES} != "no"
1476 _strfile= usr.bin/fortune/strfile
1479 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1480 _gperf= gnu/usr.bin/gperf
1483 .if ${MK_GROFF} != "no"
1484 _groff= gnu/usr.bin/groff \
1488 .if ${MK_VT} != "no"
1489 _vtfontcvt= usr.bin/vtfontcvt
1492 .if ${BOOTSTRAPPING} < 900002
1496 .if ${BOOTSTRAPPING} < 1000033
1497 _libopenbsd= lib/libopenbsd
1501 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1502 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1505 .if ${BOOTSTRAPPING} < 1000026
1506 _nmtree= lib/libnetbsd \
1509 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1512 .if ${BOOTSTRAPPING} < 1000027
1516 # r264059 support for status=
1517 .if ${BOOTSTRAPPING} < 1100017
1521 # r277259 crunchide: Correct 64-bit section header offset
1522 # r281674 crunchide: always include both 32- and 64-bit ELF support
1523 # r285986 crunchen: use STRIPBIN rather than STRIP
1524 .if ${BOOTSTRAPPING} < 1100078
1525 _crunch= usr.sbin/crunch
1528 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1532 # r296926 -P keymap search path, MFC to stable/10 in r298297
1533 .if ${BOOTSTRAPPING} < 1003501 || \
1534 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
1535 _kbdcontrol= usr.sbin/kbdcontrol
1541 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1543 .if ${MK_BSNMP} != "no"
1544 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1547 # We need to build tblgen when we're building clang either as
1548 # the bootstrap compiler, or as the part of the normal build.
1549 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1551 lib/clang/libllvmsupport \
1552 lib/clang/libllvmtablegen \
1553 usr.bin/clang/llvm-tblgen \
1554 usr.bin/clang/clang-tblgen
1556 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1557 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1560 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1563 .if ${MK_GPL_DTC} != "no"
1564 _dtc= gnu/usr.bin/dtc
1567 .if ${MK_KERBEROS} != "no"
1568 _kerberos5_bootstrap_tools= \
1569 kerberos5/tools/make-roken \
1570 kerberos5/lib/libroken \
1571 kerberos5/lib/libvers \
1572 kerberos5/tools/asn1_compile \
1573 kerberos5/tools/slc \
1576 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1579 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
1580 .if ${MK_MANDOCDB} != "no" && ${BOOTSTRAPPING} < 1100075
1581 _libopenbsd?= lib/libopenbsd
1582 _makewhatis= lib/libsqlite3 \
1584 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1587 bootstrap-tools: .PHONY
1589 # Please document (add comment) why something is in 'bootstrap-tools'.
1590 # Try to bound the building of the bootstrap-tool to just the
1591 # FreeBSD versions that need the tool built at this stage of the build.
1594 ${_kerberos5_bootstrap_tools} \
1618 ${_bt}-${_tool}: .PHONY .MAKE
1619 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1620 cd ${.CURDIR}/${_tool}; \
1621 ${MAKE} DIRPRFX=${_tool}/ obj; \
1622 ${MAKE} DIRPRFX=${_tool}/ all; \
1623 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1625 bootstrap-tools: ${_bt}-${_tool}
1629 # build-tools: Build special purpose build tools
1631 .if !defined(NO_SHARE)
1632 _share= share/syscons/scrnmaps
1635 .if ${MK_GCC} != "no"
1636 _gcc_tools= gnu/usr.bin/cc/cc_tools
1639 .if ${MK_RESCUE} != "no"
1640 # rescue includes programs that have build-tools targets
1641 _rescue=rescue/rescue
1647 ${LOCAL_TOOL_DIRS} \
1648 lib/ncurses/ncurses \
1649 lib/ncurses/ncursesw \
1654 usr.bin/mkesdb_static \
1655 usr.bin/mkcsmapper_static \
1657 build-tools_${_tool}: .PHONY
1658 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1659 cd ${.CURDIR}/${_tool}; \
1660 ${MAKE} DIRPRFX=${_tool}/ obj; \
1661 ${MAKE} DIRPRFX=${_tool}/ build-tools
1662 build-tools: build-tools_${_tool}
1666 build-tools_${_tool}: .PHONY
1667 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \
1668 cd ${.CURDIR}/${_tool}; \
1669 ${MAKE} DIRPRFX=${_tool}/ obj; \
1670 ${MAKE} DIRPRFX=${_tool}/ all
1671 build-tools: build-tools_${_tool}
1675 # kernel-tools: Build kernel-building tools
1677 kernel-tools: .PHONY
1678 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1679 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1680 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1683 # cross-tools: All the tools needed to build the rest of the system after
1684 # we get done with the earlier stages. It is the last set of tools needed
1685 # to begin building the target binaries.
1687 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1688 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1689 _btxld= usr.sbin/btxld
1693 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1694 # resulting from missing bug fixes or ELF Toolchain updates.
1695 .if ${MK_CDDL} != "no"
1696 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1697 cddl/usr.bin/ctfmerge
1700 # If we're given an XAS, don't build binutils.
1701 .if ${XAS:M/*} == ""
1702 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1703 _binutils= gnu/usr.bin/binutils
1705 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1706 _elftctools= lib/libelftc \
1712 # These are not required by the build, but can be useful for developers who
1713 # cross-build on a FreeBSD 10 host:
1714 _elftctools+= usr.bin/addr2line
1716 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1717 # If cross-building with an external binutils we still need to build strip for
1718 # the target (for at least crunchide).
1719 _elftctools= lib/libelftc \
1724 .if ${MK_CROSS_COMPILER} != "no"
1725 .if ${MK_CLANG_BOOTSTRAP} != "no"
1726 _clang= usr.bin/clang
1727 _clang_libs= lib/clang
1729 .if ${MK_GCC_BOOTSTRAP} != "no"
1733 .if ${MK_USB} != "no"
1734 _usb_tools= sys/boot/usb/tools
1737 cross-tools: .MAKE .PHONY
1748 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1749 cd ${.CURDIR}/${_tool}; \
1750 ${MAKE} DIRPRFX=${_tool}/ obj; \
1751 ${MAKE} DIRPRFX=${_tool}/ all; \
1752 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1755 NXBDESTDIR= ${OBJTREE}/nxb-bin
1756 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1757 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1758 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1759 NXBMAKE= ${NXBENV} ${MAKE} \
1760 LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \
1761 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1762 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1763 MK_GDB=no MK_TESTS=no \
1765 MK_HTML=no NO_LINT=yes MK_MAN=no \
1766 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1767 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1768 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1769 MK_LLDB=no MK_DEBUG_FILES=no
1771 # native-xtools is the current target for qemu-user cross builds of ports
1772 # via poudriere and the imgact_binmisc kernel module.
1773 # For non-clang enabled targets that are still using the in tree gcc
1774 # we must build a gperf binary for one instance of its Makefiles. On
1775 # clang-enabled systems, the gperf binary is obsolete.
1776 native-xtools: .PHONY
1777 .if ${MK_GCC_BOOTSTRAP} != "no"
1778 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1779 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \
1780 cd ${.CURDIR}/${_gperf}; \
1781 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1782 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1783 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1785 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1786 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1787 -p ${NXBDESTDIR}/usr >/dev/null
1788 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1789 -p ${NXBDESTDIR}/usr/include >/dev/null
1790 .if ${MK_DEBUG_FILES} != "no"
1791 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1792 -p ${NXBDESTDIR}/usr/lib >/dev/null
1853 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1854 cd ${.CURDIR}/${_tool}; \
1855 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1856 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1857 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1861 # hierarchy - ensure that all the needed directories are present
1863 hierarchy hier: .MAKE .PHONY
1864 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1867 # libraries - build all libraries, and install them under ${DESTDIR}.
1869 # The list of libraries with dependents (${_prebuild_libs}) and their
1870 # interdependencies (__L) are built automatically by the
1871 # ${.CURDIR}/tools/make_libdeps.sh script.
1873 libraries: .MAKE .PHONY
1874 ${_+_}cd ${.CURDIR}; \
1875 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1876 ${MAKE} -f Makefile.inc1 _startup_libs; \
1877 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1878 ${MAKE} -f Makefile.inc1 _generic_libs
1881 # static libgcc.a prerequisite for shared libc
1883 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1885 # These dependencies are not automatically generated:
1887 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1888 # all shared libraries for ELF.
1890 _startup_libs= gnu/lib/csu
1891 _startup_libs+= lib/csu
1892 _startup_libs+= gnu/lib/libgcc
1893 _startup_libs+= lib/libcompiler_rt
1894 _startup_libs+= lib/libc
1895 _startup_libs+= lib/libc_nonshared
1896 .if ${MK_LIBCPLUSPLUS} != "no"
1897 _startup_libs+= lib/libcxxrt
1900 gnu/lib/libgcc__L: lib/libc__L
1901 gnu/lib/libgcc__L: lib/libc_nonshared__L
1902 .if ${MK_LIBCPLUSPLUS} != "no"
1903 lib/libcxxrt__L: gnu/lib/libgcc__L
1906 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1907 ${_kerberos5_lib_libhdb} \
1908 ${_kerberos5_lib_libheimbase} \
1909 ${_kerberos5_lib_libheimntlm} \
1911 ${_kerberos5_lib_libheimipcc} \
1912 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1913 ${_kerberos5_lib_libroken} \
1914 ${_kerberos5_lib_libwind} \
1915 lib/libbz2 ${_libcom_err} lib/libcrypt \
1916 lib/libelf lib/libexpat \
1919 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1921 lib/ncurses/ncurses lib/ncurses/ncursesw \
1922 lib/libopie lib/libpam/libpam ${_lib_libthr} \
1923 ${_lib_libradius} lib/libsbuf lib/libtacplus \
1925 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1926 ${_cddl_lib_libuutil} \
1927 ${_cddl_lib_libavl} \
1928 ${_cddl_lib_libzfs_core} \
1929 ${_cddl_lib_libctf} \
1930 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1931 ${_secure_lib_libcrypto} ${_lib_libldns} \
1932 ${_secure_lib_libssh} ${_secure_lib_libssl} \
1935 .if ${MK_GNUCXX} != "no"
1936 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1937 gnu/lib/libstdc++__L: lib/msun__L
1938 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1941 .if ${MK_LIBCPLUSPLUS} != "no"
1942 _prebuild_libs+= lib/libc++
1945 lib/libgeom__L: lib/libexpat__L
1946 lib/libkvm__L: lib/libelf__L
1948 .if ${MK_LIBTHR} != "no"
1949 _lib_libthr= lib/libthr
1952 .if ${MK_RADIUS_SUPPORT} != "no"
1953 _lib_libradius= lib/libradius
1956 .if ${MK_OFED} != "no"
1957 _ofed_lib= contrib/ofed/usr.lib
1958 _prebuild_libs+= contrib/ofed/usr.lib/libosmcomp
1959 _prebuild_libs+= contrib/ofed/usr.lib/libopensm
1960 _prebuild_libs+= contrib/ofed/usr.lib/libibcommon
1961 _prebuild_libs+= contrib/ofed/usr.lib/libibverbs
1962 _prebuild_libs+= contrib/ofed/usr.lib/libibumad
1964 contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
1965 contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
1966 contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
1969 .if ${MK_CASPER} != "no"
1970 _lib_casper= lib/libcasper
1973 lib/libpjdlog__L: lib/libutil__L
1974 lib/libcasper__L: lib/libnv__L
1975 lib/liblzma__L: lib/libthr__L
1977 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1978 .for _DIR in ${LOCAL_LIB_DIRS}
1979 .if exists(${.CURDIR}/${_DIR}/Makefile) && empty(_generic_libs:M${_DIR})
1980 _generic_libs+= ${_DIR}
1984 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1986 .if ${MK_CDDL} != "no"
1987 _cddl_lib_libumem= cddl/lib/libumem
1988 _cddl_lib_libnvpair= cddl/lib/libnvpair
1989 _cddl_lib_libavl= cddl/lib/libavl
1990 _cddl_lib_libuutil= cddl/lib/libuutil
1991 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1992 _cddl_lib_libctf= cddl/lib/libctf
1994 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1995 cddl/lib/libzfs__L: lib/libgeom__L
1996 cddl/lib/libctf__L: lib/libz__L
1998 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
1999 # on select architectures though (see cddl/lib/Makefile)
2000 .if ${MACHINE_CPUARCH} != "sparc64"
2001 _prebuild_libs+= lib/libproc lib/librtld_db
2004 .if ${MK_CRYPT} != "no"
2005 .if ${MK_OPENSSL} != "no"
2006 _secure_lib_libcrypto= secure/lib/libcrypto
2007 _secure_lib_libssl= secure/lib/libssl
2008 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2009 .if ${MK_LDNS} != "no"
2010 _lib_libldns= lib/libldns
2011 lib/libldns__L: secure/lib/libcrypto__L
2013 .if ${MK_OPENSSH} != "no"
2014 _secure_lib_libssh= secure/lib/libssh
2015 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2016 .if ${MK_LDNS} != "no"
2017 secure/lib/libssh__L: lib/libldns__L
2019 .if ${MK_KERBEROS_SUPPORT} != "no"
2020 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2021 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2022 lib/libmd__L kerberos5/lib/libroken__L
2026 _secure_lib= secure/lib
2029 .if ${MK_KERBEROS} != "no"
2030 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2031 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2032 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2033 kerberos5/lib/libwind__L lib/libsqlite3__L
2034 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2035 kerberos5/lib/libroken__L lib/libcom_err__L
2036 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2037 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2038 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2039 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2040 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2041 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2042 kerberos5/lib/libroken__L: lib/libcrypt__L
2043 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2044 kerberos5/lib/libheimbase__L: lib/libthr__L
2045 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2048 lib/libsqlite3__L: lib/libthr__L
2050 .if ${MK_GSSAPI} != "no"
2051 _lib_libgssapi= lib/libgssapi
2054 .if ${MK_KERBEROS} != "no"
2055 _kerberos5_lib= kerberos5/lib
2056 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2057 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2058 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2059 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2060 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2061 _kerberos5_lib_libroken= kerberos5/lib/libroken
2062 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2063 _libsqlite3= lib/libsqlite3
2064 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2065 _kerberos5_lib_libwind= kerberos5/lib/libwind
2066 _libcom_err= lib/libcom_err
2069 .if ${MK_NIS} != "no"
2070 _lib_libypclnt= lib/libypclnt
2073 .if ${MK_OPENSSL} == "no"
2074 lib/libradius__L: lib/libmd__L
2078 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2079 .if ${MK_CXX} != "no"
2080 .if ${MK_LIBCPLUSPLUS} != "no"
2081 lib/libproc__L: lib/libcxxrt__L
2082 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2083 lib/libproc__L: gnu/lib/libsupc++__L
2087 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2089 .for _lib in ${_prereq_libs}
2090 ${_lib}__PL: .PHONY .MAKE
2091 .if exists(${.CURDIR}/${_lib})
2092 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2093 cd ${.CURDIR}/${_lib}; \
2094 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2095 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2096 DIRPRFX=${_lib}/ all; \
2097 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2098 DIRPRFX=${_lib}/ install
2102 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
2103 ${_lib}__L: .PHONY .MAKE
2104 .if exists(${.CURDIR}/${_lib})
2105 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2106 cd ${.CURDIR}/${_lib}; \
2107 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2108 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2109 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2113 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2114 _startup_libs: ${_startup_libs:S/$/__L/}
2115 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2116 _generic_libs: ${_generic_libs:S/$/__L/}
2118 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2119 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2120 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2121 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2122 # parallel. This is safe for the world stage of buildworld though since it has
2123 # already built libraries in a proper order and installed includes into
2124 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2125 # avoid trashing a system if it crashes mid-install.
2126 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2130 .include <bsd.subdir.mk>
2132 .if make(check-old) || make(check-old-dirs) || \
2133 make(check-old-files) || make(check-old-libs) || \
2134 make(delete-old) || make(delete-old-dirs) || \
2135 make(delete-old-files) || make(delete-old-libs)
2138 # check for / delete old files section
2141 .include "ObsoleteFiles.inc"
2143 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2144 else you can not start such an application. Consult UPDATING for more \
2145 information regarding how to cope with the removal/revision bump of a \
2148 .if !defined(BATCH_DELETE_OLD_FILES)
2154 delete-old-files: .PHONY
2155 @echo ">>> Removing old files (only deletes safe to delete libs)"
2156 # Ask for every old file if the user really wants to remove it.
2157 # It's annoying, but better safe than sorry.
2158 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2159 # argument list will get too long. Using .for/.endfor make "loops" will make
2160 # the Makefile parser segfault.
2163 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2164 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2165 while read file; do \
2166 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2167 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2168 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2170 for ext in debug symbols; do \
2171 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2172 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2173 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2178 # Remove catpages without corresponding manpages.
2180 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2181 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2182 while read catpage; do \
2184 if [ ! -e "$${manpage}" ]; then \
2185 rm ${RM_I} $${catpage} <&3; \
2188 @echo ">>> Old files removed"
2190 check-old-files: .PHONY
2191 @echo ">>> Checking for old files"
2193 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2194 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2195 while read file; do \
2196 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2197 echo "${DESTDIR}/$${file}"; \
2199 for ext in debug symbols; do \
2200 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2201 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2205 # Check for catpages without corresponding manpages.
2206 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2207 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2208 while read catpage; do \
2210 if [ ! -e "$${manpage}" ]; then \
2215 delete-old-libs: .PHONY
2216 @echo ">>> Removing old libraries"
2217 @echo "${OLD_LIBS_MESSAGE}" | fmt
2220 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2221 -V OLD_LIBS | xargs -n1 | \
2222 while read file; do \
2223 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2224 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2225 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2227 for ext in debug symbols; do \
2228 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2229 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2230 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2235 @echo ">>> Old libraries removed"
2237 check-old-libs: .PHONY
2238 @echo ">>> Checking for old libraries"
2240 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2241 -V OLD_LIBS | xargs -n1 | \
2242 while read file; do \
2243 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2244 echo "${DESTDIR}/$${file}"; \
2246 for ext in debug symbols; do \
2247 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2248 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2253 delete-old-dirs: .PHONY
2254 @echo ">>> Removing old directories"
2256 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2257 -V OLD_DIRS | xargs -n1 | sort -r | \
2258 while read dir; do \
2259 if [ -d "${DESTDIR}/$${dir}" ]; then \
2260 rmdir -v "${DESTDIR}/$${dir}" || true; \
2261 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2262 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2265 @echo ">>> Old directories removed"
2267 check-old-dirs: .PHONY
2268 @echo ">>> Checking for old directories"
2270 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2271 -V OLD_DIRS | xargs -n1 | \
2272 while read dir; do \
2273 if [ -d "${DESTDIR}/$${dir}" ]; then \
2274 echo "${DESTDIR}/$${dir}"; \
2275 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2276 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2280 delete-old: delete-old-files delete-old-dirs .PHONY
2281 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2283 check-old: check-old-files check-old-libs check-old-dirs .PHONY
2284 @echo "To remove old files and directories run '${MAKE} delete-old'."
2285 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2290 # showconfig - show build configuration.
2293 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2294 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2296 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2297 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2299 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2300 .if exists(${KERNCONFDIR}/${KERNCONF})
2301 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2302 '${KERNCONFDIR}/${KERNCONF}' ; echo
2308 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2309 DTBOUTPUTPATH= ${.CURDIR}
2313 # Build 'standalone' Device Tree Blob
2316 @PATH=${TMPPATH} MACHINE=${TARGET} \
2317 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2318 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2323 # In the following, the first 'rm' in a series will usually remove all
2324 # files and directories. If it does not, then there are probably some
2325 # files with file flags set, so this unsets them and tries the 'rm' a
2326 # second time. There are situations where this target will be cleaning
2327 # some directories via more than one method, but that duplication is
2328 # needed to correctly handle all the possible situations. Removing all
2329 # files without file flags set in the first 'rm' instance saves time,
2330 # because 'chflags' will need to operate on fewer files afterwards.
2332 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2333 # created by bsd.obj.mk, except that we don't want to .include that file
2336 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2338 .if exists(${BW_CANONICALOBJDIR}/)
2339 -rm -rf ${BW_CANONICALOBJDIR}/*
2340 -chflags -R 0 ${BW_CANONICALOBJDIR}
2341 rm -rf ${BW_CANONICALOBJDIR}/*
2343 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2344 # To be safe in this case, fall back to a 'make cleandir'
2345 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2348 .if defined(TARGET) && defined(TARGET_ARCH)
2350 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2351 XDEV_CPUTYPE?=${CPUTYPE}
2353 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2356 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2357 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2358 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2359 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2360 CPUTYPE=${XDEV_CPUTYPE}
2362 XDDIR=${TARGET_ARCH}-freebsd
2365 .error XDTP variable should be an absolute path
2368 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2369 INSTALL="sh ${.CURDIR}/tools/install.sh"
2371 TOOLS_PREFIX=${XDTP}
2372 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2373 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2374 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2375 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2376 CPP="${CPP} ${CD2CFLAGS}" \
2377 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2379 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2380 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2381 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2382 XDDESTDIR=${DESTDIR}/${XDTP}
2384 OSREL!= uname -r | sed -e 's/[-(].*//'
2387 .ORDER: xdev-build xdev-install xdev-links
2388 xdev: xdev-build xdev-install .PHONY
2390 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2391 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
2393 _xb-worldtmp: .PHONY
2394 mkdir -p ${CDTMP}/usr
2395 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2396 -p ${CDTMP}/usr >/dev/null
2398 _xb-bootstrap-tools: .PHONY
2402 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2403 cd ${.CURDIR}/${_tool}; \
2404 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2405 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2406 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2409 _xb-build-tools: .PHONY
2410 ${_+_}@cd ${.CURDIR}; \
2411 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2413 _xb-cross-tools: .PHONY
2421 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2422 cd ${.CURDIR}/${_tool}; \
2423 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2424 ${CDMAKE} DIRPRFX=${_tool}/ all
2428 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2429 mkdir -p ${XDDESTDIR}
2430 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2431 -p ${XDDESTDIR} >/dev/null
2432 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2433 -p ${XDDESTDIR}/usr >/dev/null
2434 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2435 -p ${XDDESTDIR}/usr/include >/dev/null
2436 .if defined(LIBCOMPAT)
2437 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2438 -p ${XDDESTDIR}/usr >/dev/null
2440 .if ${MK_TESTS} != "no"
2441 mkdir -p ${XDDESTDIR}${TESTSBASE}
2442 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2443 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2446 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2447 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
2449 _xi-cross-tools: .PHONY
2450 @echo "_xi-cross-tools"
2458 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2459 cd ${.CURDIR}/${_tool}; \
2460 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2463 _xi-includes: .PHONY
2464 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2465 DESTDIR=${XDDESTDIR}
2467 _xi-libraries: .PHONY
2468 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2469 DESTDIR=${XDDESTDIR}
2472 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2473 mkdir -p ../../../../usr/bin; \
2475 ln -sf ../../${XDTP}/usr/bin/$$i \
2476 ../../../../usr/bin/${XDDIR}-$$i; \
2477 ln -sf ../../${XDTP}/usr/bin/$$i \
2478 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2481 xdev xdev-build xdev-install xdev-links: .PHONY
2482 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"