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 .include <bsd.compiler.mk> # don't depend on src.opts.mk doing it
60 .include "share/mk/src.opts.mk"
62 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
63 # keep the users system reasonably usable. For static->dynamic root upgrades,
64 # we don't want to install a dynamic binary without rtld and the needed
65 # libraries. More commonly, for dynamic root, we don't want to install a
66 # binary that requires a newer library version that hasn't been installed yet.
67 # This ordering is not a guarantee though. The only guarantee of a working
68 # system here would require fine-grained ordering of all components based
69 # on their dependencies.
71 .if !empty(SUBDIR_OVERRIDE)
72 SUBDIR= ${SUBDIR_OVERRIDE}
75 .if !defined(NO_ROOT) && (make(installworld) || make(install))
76 # Ensure libraries are installed before progressing.
80 .if ${MK_CDDL} != "no"
84 .if ${MK_KERBEROS} != "no"
87 .if ${MK_RESCUE} != "no"
91 .if ${MK_CRYPT} != "no"
94 .if !defined(NO_SHARE)
97 SUBDIR+=sys usr.bin usr.sbin
98 .if ${MK_TESTS} != "no"
101 .if ${MK_OFED} != "no"
105 # Local directories are last, since it is nice to at least get the base
106 # system rebuilt before you do them.
107 .for _DIR in ${LOCAL_DIRS}
108 .if exists(${.CURDIR}/${_DIR}/Makefile)
112 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
113 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
114 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
115 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
116 _REDUNDENT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
118 .for _DIR in ${LOCAL_LIB_DIRS}
119 .if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
122 .warning ${_DIR} not added to SUBDIR list. See UPDATING 20141121.
126 # We must do etc/ last as it hooks into building the man whatis file
127 # by calling 'makedb' in share/man. This is only relevant for
128 # install/distribute so they build the whatis file after every manpage is
130 .if make(installworld) || make(install)
135 .endif # !empty(SUBDIR_OVERRIDE)
138 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
141 .if defined(NO_CLEANDIR)
142 CLEANDIR= clean cleandepend
148 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
150 .if empty(SHELL:M*csh*)
151 BUILDENV_SHELL?=${SHELL}
153 BUILDENV_SHELL?=/bin/sh
156 SVN?= /usr/local/bin/svn
159 MAKEOBJDIRPREFIX?= /usr/obj
160 .if !defined(OSRELDATE)
161 .if exists(/usr/include/osreldate.h)
162 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
163 /usr/include/osreldate.h
170 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
171 .if !defined(VERSION)
172 REVISION!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V REVISION
173 BRANCH!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V BRANCH
174 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
175 ${SRCDIR}/sys/sys/param.h
176 VERSION= FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
180 .if !defined(PKG_VERSION)
181 REVISION!= ${MAKE} -C ${SRCDIR}/release -V REVISION
182 BRANCH!= ${MAKE} -C ${SRCDIR}/release -V BRANCH
183 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
184 ${SRCDIR}/sys/sys/param.h
185 .if ${BRANCH:MSTABLE*} || ${BRANCH:MCURRENT*}
186 TIMENOW= %Y%m%d%H%M%S
187 EXTRA_REVISION= .s${TIMENOW:gmtime}
190 EXTRA_REVISION= _${BRANCH:C/.*-p([0-9]+$)/\1/}
192 PKG_VERSION= ${REVISION}${EXTRA_REVISION}
195 KNOWN_ARCHES?= aarch64/arm64 \
214 .if ${TARGET} == ${TARGET_ARCH}
217 _t= ${TARGET_ARCH}/${TARGET}
220 .if empty(KNOWN_ARCHES:M${_t})
221 .error Unknown target ${TARGET_ARCH}:${TARGET}.
225 .if ${TARGET} == ${MACHINE}
226 TARGET_CPUTYPE?=${CPUTYPE}
231 .if !empty(TARGET_CPUTYPE)
232 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
234 _TARGET_CPUTYPE=dummy
236 _CPUTYPE!= MK_AUTO_OBJ=no MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
237 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
238 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
239 .error CPUTYPE global should be set with ?=.
242 BUILD_ARCH!= uname -p
243 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
244 .error To cross-build, set TARGET_ARCH.
247 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
248 OBJTREE= ${MAKEOBJDIRPREFIX}
250 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
252 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
253 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
254 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
255 STRICTTMPPATH= ${BPATH}:${XPATH}
256 TMPPATH= ${STRICTTMPPATH}:${PATH}
259 # Avoid running mktemp(1) unless actually needed.
260 # It may not be functional, e.g., due to new ABI
261 # when in the middle of installing over this system.
263 .if make(distributeworld) || make(installworld) || make(stageworld)
264 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
267 .if make(stagekernel) || make(distributekernel)
273 # Building a world goes through the following stages
275 # 1. legacy stage [BMAKE]
276 # This stage is responsible for creating compatibility
277 # shims that are needed by the bootstrap-tools,
278 # build-tools and cross-tools stages. These are generally
279 # APIs that tools from one of those three stages need to
280 # build that aren't present on the host.
281 # 1. bootstrap-tools stage [BMAKE]
282 # This stage is responsible for creating programs that
283 # are needed for backward compatibility reasons. They
284 # are not built as cross-tools.
285 # 2. build-tools stage [TMAKE]
286 # This stage is responsible for creating the object
287 # tree and building any tools that are needed during
288 # the build process. Some programs are listed during
289 # this phase because they build binaries to generate
290 # files needed to build these programs. This stage also
291 # builds the 'build-tools' target rather than 'all'.
292 # 3. cross-tools stage [XMAKE]
293 # This stage is responsible for creating any tools that
294 # are needed for building the system. A cross-compiler is one
295 # of them. This differs from build tools in two ways:
296 # 1. the 'all' target is built rather than 'build-tools'
297 # 2. these tools are installed into TMPPATH for stage 4.
298 # 4. world stage [WMAKE]
299 # This stage actually builds the world.
300 # 5. install stage (optional) [IMAKE]
301 # This stage installs a previously built world.
306 # Common environment for world related stages
307 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
308 MACHINE_ARCH=${TARGET_ARCH} \
310 CPUTYPE=${TARGET_CPUTYPE}
311 .if ${MK_GROFF} != "no"
312 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
313 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
314 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
316 .if defined(TARGET_CFLAGS)
317 CROSSENV+= ${TARGET_CFLAGS}
320 # bootstrap-tools stage
321 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
322 PATH=${BPATH}:${PATH} \
323 WORLDTMP=${WORLDTMP} \
324 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
325 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
327 BOOTSTRAPPING=${OSRELDATE} \
329 MK_HTML=no NO_LINT=yes MK_MAN=no \
330 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
331 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
332 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
333 MK_LLDB=no MK_TESTS=no \
336 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
337 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
341 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
342 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
343 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
345 BOOTSTRAPPING=${OSRELDATE} \
348 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
349 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
350 MK_LLDB=no MK_TESTS=no
353 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
354 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
355 MK_GDB=no MK_TESTS=no
358 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
359 PATH=${BPATH}:${PATH} \
361 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
362 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
364 BOOTSTRAPPING=${OSRELDATE} \
366 MK_HTML=no -DNO_LINT MK_MAN=no \
367 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
368 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
371 WMAKEENV= ${CROSSENV} \
372 INSTALL="sh ${.CURDIR}/tools/install.sh" \
376 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
378 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
381 .if defined(CROSS_TOOLCHAIN_PREFIX)
382 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
383 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
386 # If we do not have a bootstrap binutils (because the in-tree one does not
387 # support the target architecture), provide a default cross-binutils prefix.
388 # This allows aarch64 builds, for example, to automatically use the
389 # aarch64-binutils port or package.
390 .if !make(showconfig)
391 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
392 !defined(CROSS_BINUTILS_PREFIX)
393 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
394 .if !exists(${CROSS_BINUTILS_PREFIX})
395 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
400 XCOMPILERS= CC CXX CPP
401 .for COMPILER in ${XCOMPILERS}
402 .if defined(CROSS_COMPILER_PREFIX)
403 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
405 X${COMPILER}?= ${${COMPILER}}
408 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
409 .for BINUTIL in ${XBINUTILS}
410 .if defined(CROSS_BINUTILS_PREFIX) && \
411 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
412 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
414 X${BINUTIL}?= ${${BINUTIL}}
417 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
418 CPP="${XCPP} ${XCFLAGS}" \
419 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
420 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
421 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
424 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
425 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
426 # directory, but the compiler will look in the right place for its
427 # tools so we don't need to tell it where to look.
428 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
431 # External compiler needs sysroot and target flags.
432 .if ${XCC:N${CCACHE_BIN}:M/*} || ${MK_CROSS_COMPILER} == "no"
433 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
434 BFLAGS+= -B${WORLDTMP}/usr/bin
436 .if ${TARGET} == "arm"
437 .if ${TARGET_ARCH:M*hf*} != ""
438 TARGET_ABI= gnueabihf
443 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
444 # GCC requires -isystem and -L when using a cross-compiler.
445 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
446 # Force using libc++ for external GCC.
447 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
448 -nostdinc++ -L${WORLDTMP}/../lib/libc++
451 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
452 XCFLAGS+= -target ${TARGET_TRIPLE}
454 XCFLAGS+= --sysroot=${WORLDTMP}
456 .endif # ${XCC:M/*} || ${MK_CROSS_COMPILER} == "no"
462 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
463 ${TARGET_ARCH} == "powerpc64")
465 .include "Makefile.libcompat"
466 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH} == "armv6"
468 .include "Makefile.libcompat"
471 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
473 IMAKEENV= ${CROSSENV}
474 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
475 ${IMAKE_INSTALL} ${IMAKE_MTREE}
476 .if empty(.MAKEFLAGS:M-n)
477 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
478 LD_LIBRARY_PATH=${INSTALLTMP} \
479 PATH_LOCALE=${INSTALLTMP}/locale
480 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
482 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
484 .if defined(DB_FROM_SRC)
485 INSTALLFLAGS+= -N ${.CURDIR}/etc
486 MTREEFLAGS+= -N ${.CURDIR}/etc
488 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
489 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
491 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
492 IMAKE+= -DNO_ROOT METALOG=${METALOG}
493 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
496 .if defined(BUILD_PKGS)
497 INSTALLFLAGS+= -h sha256
499 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
500 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
501 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
505 KMAKEENV= ${WMAKEENV}
506 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
511 # Attempt to rebuild the entire system, with reasonable chance of
512 # success, regardless of how old your existing system is.
515 .if ${.CURDIR:C/[^,]//g} != ""
516 # The m4 build of sendmail files doesn't like it if ',' is used
517 # anywhere in the path of it's files.
519 @echo "*** Error: path to source tree contains a comma ','"
524 @echo "--------------------------------------------------------------"
525 @echo ">>> Rebuilding the temporary build tree"
526 @echo "--------------------------------------------------------------"
527 .if !defined(NO_CLEAN)
529 .if defined(LIBCOMPAT)
530 rm -rf ${LIBCOMPATTMP}
533 rm -rf ${WORLDTMP}/legacy/usr/include
534 # XXX - These can depend on any header file.
535 rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c
536 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
539 lib lib/casper usr legacy/bin legacy/usr
540 mkdir -p ${WORLDTMP}/${_dir}
542 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
543 -p ${WORLDTMP}/legacy/usr >/dev/null
544 .if ${MK_GROFF} != "no"
545 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
546 -p ${WORLDTMP}/legacy/usr >/dev/null
548 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
549 -p ${WORLDTMP}/usr >/dev/null
550 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
551 -p ${WORLDTMP}/usr/include >/dev/null
552 ln -sf ${.CURDIR}/sys ${WORLDTMP}
553 .if ${MK_DEBUG_FILES} != "no"
554 # We could instead disable debug files for these build stages
555 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
556 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
557 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
558 -p ${WORLDTMP}/usr/lib >/dev/null
560 .if defined(LIBCOMPAT)
561 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
562 -p ${WORLDTMP}/usr >/dev/null
563 .if ${MK_DEBUG_FILES} != "no"
564 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
565 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
566 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
567 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
570 .if ${MK_TESTS} != "no"
571 mkdir -p ${WORLDTMP}${TESTSBASE}
572 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
573 -p ${WORLDTMP}${TESTSBASE} >/dev/null
574 .if ${MK_DEBUG_FILES} != "no"
575 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
576 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
577 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
580 .for _mtree in ${LOCAL_MTREE}
581 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
585 @echo "--------------------------------------------------------------"
586 @echo ">>> stage 1.1: legacy release compatibility shims"
587 @echo "--------------------------------------------------------------"
588 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
591 @echo "--------------------------------------------------------------"
592 @echo ">>> stage 1.2: bootstrap tools"
593 @echo "--------------------------------------------------------------"
594 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
596 .if !defined(NO_CLEAN)
598 @echo "--------------------------------------------------------------"
599 @echo ">>> stage 2.1: cleaning up the object tree"
600 @echo "--------------------------------------------------------------"
601 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
602 .if defined(LIBCOMPAT)
603 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
608 @echo "--------------------------------------------------------------"
609 @echo ">>> stage 2.2: rebuilding the object tree"
610 @echo "--------------------------------------------------------------"
611 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
614 @echo "--------------------------------------------------------------"
615 @echo ">>> stage 2.3: build tools"
616 @echo "--------------------------------------------------------------"
617 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
620 @echo "--------------------------------------------------------------"
621 @echo ">>> stage 3: cross tools"
622 @echo "--------------------------------------------------------------"
623 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
624 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
627 @echo "--------------------------------------------------------------"
628 @echo ">>> stage 4.1: building includes"
629 @echo "--------------------------------------------------------------"
630 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
631 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
632 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
633 MK_INCLUDES=yes includes
634 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
635 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
639 @echo "--------------------------------------------------------------"
640 @echo ">>> stage 4.2: building libraries"
641 @echo "--------------------------------------------------------------"
642 ${_+_}cd ${.CURDIR}; \
643 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
644 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
647 @echo "--------------------------------------------------------------"
648 @echo ">>> stage 4.3: building everything"
649 @echo "--------------------------------------------------------------"
650 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
653 WMAKE_TGTS+= _worldtmp _legacy
654 .if empty(SUBDIR_OVERRIDE)
655 WMAKE_TGTS+= _bootstrap-tools
657 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
658 WMAKE_TGTS+= _includes _libraries
659 WMAKE_TGTS+= everything
660 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
661 WMAKE_TGTS+= build${libcompat}
664 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
665 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
668 @echo "--------------------------------------------------------------"
669 @echo ">>> World build started on `LC_ALL=C date`"
670 @echo "--------------------------------------------------------------"
674 @echo "--------------------------------------------------------------"
675 @echo ">>> World build completed on `LC_ALL=C date`"
676 @echo "--------------------------------------------------------------"
679 # We need to have this as a target because the indirection between Makefile
680 # and Makefile.inc1 causes the correct PATH to be used, rather than a
681 # modification of the current environment's PATH. In addition, we need
682 # to quote multiword values.
685 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
687 .if ${.TARGETS:Mbuildenv}
688 .if ${.MAKEFLAGS:M-j}
689 .error The buildenv target is incompatible with -j
692 BUILDENV_DIR?= ${.CURDIR}
694 @echo Entering world for ${TARGET_ARCH}:${TARGET}
695 .if ${BUILDENV_SHELL:M*zsh*}
696 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
698 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
701 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
702 toolchain: ${TOOLCHAIN_TGTS}
703 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
708 # Checks to be sure system is ready for installworld/installkernel.
710 installcheck: _installcheck_world _installcheck_kernel
712 _installcheck_kernel:
715 # Require DESTDIR to be set if installing for a different architecture or
716 # using the user/group database in the source tree.
718 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
720 .if !make(distributeworld)
721 _installcheck_world: __installcheck_DESTDIR
722 _installcheck_kernel: __installcheck_DESTDIR
723 __installcheck_DESTDIR:
724 .if !defined(DESTDIR) || empty(DESTDIR)
725 @echo "ERROR: Please set DESTDIR!"; \
731 .if !defined(DB_FROM_SRC)
733 # Check for missing UIDs/GIDs.
735 CHECK_UIDS= auditdistd
737 .if ${MK_SENDMAIL} != "no"
743 CHECK_GIDS+= proxy authpf
745 .if ${MK_UNBOUND} != "no"
749 _installcheck_world: __installcheck_UGID
751 .for uid in ${CHECK_UIDS}
752 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
753 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
757 .for gid in ${CHECK_GIDS}
758 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
759 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
766 # Required install tools to be saved in a scratch dir for safety.
768 .if ${MK_ZONEINFO} != "no"
769 _zoneinfo= zic tzsetup
772 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
773 date echo egrep find grep id install ${_install-info} \
774 ln make mkdir mtree mv pwd_mkdb \
775 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
778 # Needed for share/man
779 .if ${MK_MAN} != "no"
786 # Distributes everything compiled by a `buildworld'.
790 # Installs everything compiled by a 'buildworld'.
793 # Non-base distributions produced by the base system
794 EXTRA_DISTRIBUTIONS= doc
795 .if defined(LIBCOMPAT)
796 EXTRA_DISTRIBUTIONS+= lib${libcompat}
798 .if ${MK_TESTS} != "no"
799 EXTRA_DISTRIBUTIONS+= tests
803 .if ${MK_DEBUG_FILES} != "no"
804 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
807 MTREE_MAGIC?= mtree 2.0
809 distributeworld installworld stageworld: _installcheck_world
810 mkdir -p ${INSTALLTMP}
811 progs=$$(for prog in ${ITOOLS}; do \
812 if progpath=`which $$prog`; then \
815 echo "Required tool $$prog not found in PATH." >&2; \
819 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
820 while read line; do \
822 if [ "$$2 $$3" != "not found" ]; then \
825 echo "Required library $$1 not found." >&2; \
829 cp $$libs $$progs ${INSTALLTMP}
830 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
832 -mkdir -p ${METALOG:H}
833 echo "#${MTREE_MAGIC}" > ${METALOG}
835 .if make(distributeworld)
836 .for dist in ${EXTRA_DISTRIBUTIONS}
837 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
838 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
839 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
840 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
841 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
842 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
843 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
844 .if ${MK_DEBUG_FILES} != "no"
845 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
846 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
848 .if defined(LIBCOMPAT)
849 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
850 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
851 .if ${MK_DEBUG_FILES} != "no"
852 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
853 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
856 .if ${MK_TESTS} != "no" && ${dist} == "tests"
857 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
858 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
859 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
860 .if ${MK_DEBUG_FILES} != "no"
861 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
862 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
866 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
867 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
868 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
869 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
870 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
871 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
872 .if defined(LIBCOMPAT)
873 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
874 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
878 -mkdir ${DESTDIR}/${DISTDIR}/base
879 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
880 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
881 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
882 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
884 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
885 ${IMAKEENV} rm -rf ${INSTALLTMP}
886 .if make(distributeworld)
887 .for dist in ${EXTRA_DISTRIBUTIONS}
888 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
891 .for dist in base ${EXTRA_DISTRIBUTIONS}
892 @# For each file that exists in this dist, print the corresponding
893 @# line from the METALOG. This relies on the fact that
894 @# a line containing only the filename will sort immediatly before
895 @# the relevant mtree line.
896 cd ${DESTDIR}/${DISTDIR}; \
897 find ./${dist} | sort -u ${METALOG} - | \
898 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
899 ${DESTDIR}/${DISTDIR}/${dist}.meta
901 .for dist in ${DEBUG_DISTRIBUTIONS}
902 @# For each file that exists in this dist, print the corresponding
903 @# line from the METALOG. This relies on the fact that
904 @# a line containing only the filename will sort immediatly before
905 @# the relevant mtree line.
906 cd ${DESTDIR}/${DISTDIR}; \
907 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
908 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
909 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
915 .for dist in base ${EXTRA_DISTRIBUTIONS}
917 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
918 tar cvf - --exclude usr/lib/debug \
919 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
920 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
922 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
923 tar cvf - --exclude usr/lib/debug . | \
924 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
928 .for dist in ${DEBUG_DISTRIBUTIONS}
929 . if defined(NO_ROOT)
930 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
931 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
932 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
934 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
935 tar cvLf - usr/lib/debug | \
936 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
943 # If you have a build server, you can NFS mount the source and obj directories
944 # and do a 'make reinstall' on the *client* to install new binaries from the
945 # most recent server build.
947 reinstall: .MAKE .PHONY
948 @echo "--------------------------------------------------------------"
949 @echo ">>> Making hierarchy"
950 @echo "--------------------------------------------------------------"
951 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
952 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
954 @echo "--------------------------------------------------------------"
955 @echo ">>> Installing everything"
956 @echo "--------------------------------------------------------------"
957 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
958 .if defined(LIBCOMPAT)
959 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
962 restage: .MAKE .PHONY
963 @echo "--------------------------------------------------------------"
964 @echo ">>> Making hierarchy"
965 @echo "--------------------------------------------------------------"
966 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
967 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy distribution
969 @echo "--------------------------------------------------------------"
970 @echo ">>> Installing everything"
971 @echo "--------------------------------------------------------------"
972 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
973 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
974 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
977 redistribute: .MAKE .PHONY
978 @echo "--------------------------------------------------------------"
979 @echo ">>> Distributing everything"
980 @echo "--------------------------------------------------------------"
981 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
982 .if defined(LIBCOMPAT)
983 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
984 DISTRIBUTION=lib${libcompat}
987 distrib-dirs distribution: .MAKE .PHONY
988 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
989 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
990 .if make(distribution)
991 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
992 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
993 METALOG=${METALOG} MK_TESTS=no installconfig
997 # buildkernel and installkernel
999 # Which kernels to build and/or install is specified by setting
1000 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1001 # Only the existing (depending TARGET) config files are used
1002 # for building kernels and only the first of these is designated
1003 # as the one being installed.
1005 # Note that we have to use TARGET instead of TARGET_ARCH when
1006 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1007 # be set to cross-build, we have to make sure TARGET is set
1010 .if defined(KERNFAST)
1014 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1015 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1016 KERNCONF=${KERNFAST}
1019 .if ${TARGET_ARCH} == "powerpc64"
1020 KERNCONF?= GENERIC64
1024 INSTKERNNAME?= kernel
1026 KERNSRCDIR?= ${.CURDIR}/sys
1027 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1028 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1029 KERNCONFDIR?= ${KRNLCONFDIR}
1033 .if defined(NO_INSTALLKERNEL)
1034 # All of the BUILDKERNELS loops start at index 1.
1035 BUILDKERNELS+= dummy
1037 .for _kernel in ${KERNCONF}
1038 .if exists(${KERNCONFDIR}/${_kernel})
1039 BUILDKERNELS+= ${_kernel}
1040 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1041 INSTALLKERNEL= ${_kernel}
1046 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1051 # Builds all kernels defined by BUILDKERNELS.
1053 buildkernel: .MAKE .PHONY
1054 .if empty(BUILDKERNELS:Ndummy)
1055 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1059 .for _kernel in ${BUILDKERNELS:Ndummy}
1060 @echo "--------------------------------------------------------------"
1061 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1062 @echo "--------------------------------------------------------------"
1063 @echo "===> ${_kernel}"
1064 mkdir -p ${KRNLOBJDIR}
1065 .if !defined(NO_KERNELCONFIG)
1067 @echo "--------------------------------------------------------------"
1068 @echo ">>> stage 1: configuring the kernel"
1069 @echo "--------------------------------------------------------------"
1070 cd ${KRNLCONFDIR}; \
1072 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1073 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1075 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1077 @echo "--------------------------------------------------------------"
1078 @echo ">>> stage 2.1: cleaning up the object tree"
1079 @echo "--------------------------------------------------------------"
1080 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1082 .if !defined(NO_KERNELOBJ)
1084 @echo "--------------------------------------------------------------"
1085 @echo ">>> stage 2.2: rebuilding the object tree"
1086 @echo "--------------------------------------------------------------"
1087 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1090 @echo "--------------------------------------------------------------"
1091 @echo ">>> stage 2.3: build tools"
1092 @echo "--------------------------------------------------------------"
1093 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1095 @echo "--------------------------------------------------------------"
1096 @echo ">>> stage 3.1: building everything"
1097 @echo "--------------------------------------------------------------"
1098 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1099 @echo "--------------------------------------------------------------"
1100 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1101 @echo "--------------------------------------------------------------"
1105 # installkernel, etc.
1107 # Install the kernel defined by INSTALLKERNEL
1109 installkernel installkernel.debug \
1110 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1111 .if !defined(NO_INSTALLKERNEL)
1112 .if empty(INSTALLKERNEL)
1113 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1116 @echo "--------------------------------------------------------------"
1117 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1118 @echo "--------------------------------------------------------------"
1119 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1120 ${CROSSENV} PATH=${TMPPATH} \
1121 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1123 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1124 .for _kernel in ${BUILDKERNELS:[2..-1]}
1125 @echo "--------------------------------------------------------------"
1126 @echo ">>> Installing kernel ${_kernel}"
1127 @echo "--------------------------------------------------------------"
1128 cd ${KRNLOBJDIR}/${_kernel}; \
1129 ${CROSSENV} PATH=${TMPPATH} \
1130 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1134 distributekernel distributekernel.debug:
1135 .if !defined(NO_INSTALLKERNEL)
1136 .if empty(INSTALLKERNEL)
1137 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1140 mkdir -p ${DESTDIR}/${DISTDIR}
1141 .if defined(NO_ROOT)
1142 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1144 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1145 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1146 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1147 DESTDIR=${INSTALL_DDIR}/kernel \
1148 ${.TARGET:S/distributekernel/install/}
1149 .if defined(NO_ROOT)
1150 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1151 ${DESTDIR}/${DISTDIR}/kernel.meta
1154 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1155 .for _kernel in ${BUILDKERNELS:[2..-1]}
1156 .if defined(NO_ROOT)
1157 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1159 cd ${KRNLOBJDIR}/${_kernel}; \
1160 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1161 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1162 KERNEL=${INSTKERNNAME}.${_kernel} \
1163 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1164 ${.TARGET:S/distributekernel/install/}
1165 .if defined(NO_ROOT)
1166 @sed -e "s|^./kernel.${_kernel}|.|" \
1167 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1168 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1174 .if defined(NO_ROOT)
1175 .if !defined(NO_INSTALLKERNEL)
1176 cd ${DESTDIR}/${DISTDIR}/kernel; \
1177 tar cvf - --exclude '*.debug' \
1178 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1179 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1181 cd ${DESTDIR}/${DISTDIR}/kernel; \
1182 tar cvf - --include '*/*/*.debug' \
1183 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1184 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1185 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1186 .for _kernel in ${BUILDKERNELS:[2..-1]}
1187 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1188 tar cvf - --exclude '*.debug' \
1189 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1190 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1191 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1192 tar cvf - --include '*/*/*.debug' \
1193 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1194 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1198 .if !defined(NO_INSTALLKERNEL)
1199 cd ${DESTDIR}/${DISTDIR}/kernel; \
1200 tar cvf - --exclude '*.debug' . | \
1201 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1203 cd ${DESTDIR}/${DISTDIR}/kernel; \
1204 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1205 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1206 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1207 .for _kernel in ${BUILDKERNELS:[2..-1]}
1208 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1209 tar cvf - --exclude '*.debug' . | \
1210 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1211 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1212 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1213 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1219 ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1221 PORTSDIR?= /usr/ports
1222 WSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/worldstage
1223 KSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/kernelstage
1224 REPODIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/repo
1225 PKGSIGNKEY?= # empty
1228 .if !exists(${LOCALBASE}/sbin/pkg)
1229 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1233 ${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1236 rm -rf /tmp/ports.${TARGET} || :
1237 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${REVISION} \
1238 PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} WSTAGEDIR=${WSTAGEDIR} \
1239 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1241 real-packages: stage-packages create-packages sign-packages
1244 @mkdir -p ${REPODIR} ${WSTAGEDIR} ${KSTAGEDIR}
1245 ${_+_}@cd ${.CURDIR}; \
1246 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT -B stageworld ; \
1247 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT -B stagekernel
1249 create-packages: _pkgbootstrap
1250 @mkdir -p ${REPODIR}
1251 ${_+_}@cd ${.CURDIR}; \
1252 ${MAKE} DESTDIR=${WSTAGEDIR} \
1253 PKG_VERSION=${PKG_VERSION} create-world-packages ; \
1254 ${MAKE} DESTDIR=${KSTAGEDIR} \
1255 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1256 create-kernel-packages
1258 create-world-packages: _pkgbootstrap
1259 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1260 @cd ${WSTAGEDIR} ; \
1261 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1262 ${WSTAGEDIR}/METALOG
1263 @for plist in ${WSTAGEDIR}/*.plist; do \
1264 plist=$${plist##*/} ; \
1265 pkgname=$${plist%.plist} ; \
1266 sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \
1267 -s ${SRCDIR} -u ${WSTAGEDIR}/$${pkgname}.ucl ; \
1269 @for plist in ${WSTAGEDIR}/*.plist; do \
1270 plist=$${plist##*/} ; \
1271 pkgname=$${plist%.plist} ; \
1273 /^name/ { printf("===> Creating %s-", $$2); next } \
1274 /^version/ { print $$2; next } \
1275 ' ${WSTAGEDIR}/$${pkgname}.ucl ; \
1276 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1277 create -M ${WSTAGEDIR}/$${pkgname}.ucl \
1278 -p ${WSTAGEDIR}/$${pkgname}.plist \
1280 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} ; \
1283 create-kernel-packages: _pkgbootstrap
1284 .if exists(${KSTAGEDIR}/kernel.meta)
1285 .for flavor in "" -debug
1286 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1287 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1288 -v kernel=yes -v _kernconf=${INSTALLKERNEL} \
1289 ${KSTAGEDIR}/kernel.meta ; \
1290 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1291 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1292 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1293 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1294 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1295 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1296 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1297 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1298 ${SRCDIR}/release/packages/kernel.ucl \
1299 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1301 /name/ { printf("===> Creating %s-", $$2); next } \
1302 /version/ {print $$2; next } ' \
1303 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1304 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1305 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1306 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1307 -r ${KSTAGEDIR}/${DISTDIR} \
1308 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1311 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1312 .for _kernel in ${BUILDKERNELS:[2..-1]}
1313 .if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1314 .for flavor in "" -debug
1315 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1316 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1317 -v kernel=yes -v _kernconf=${_kernel} \
1318 ${KSTAGEDIR}/kernel.${_kernel}.meta ; \
1319 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1320 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1321 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1322 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1323 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1324 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1325 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1326 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1327 ${SRCDIR}/release/packages/kernel.ucl \
1328 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1330 /name/ { printf("===> Creating %s-", $$2); next } \
1331 /version/ {print $$2; next } ' \
1332 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1333 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1334 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1335 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1336 -r ${KSTAGEDIR}/kernel.${_kernel} \
1337 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1343 sign-packages: _pkgbootstrap
1344 @[ -L "${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1345 unlink ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1346 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1347 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1348 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1350 ln -s ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1351 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest
1357 # Run test suite on installed world.
1360 @if [ ! -x ${LOCALBASE}/bin/kyua ]; then \
1361 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1364 ${_+_}${LOCALBASE}/bin/kyua test -k ${TESTSBASE}/Kyuafile
1370 # Build the API documentation with doxygen
1373 @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1374 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1377 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1382 # Update the source tree(s), by running svn/svnup to update to the
1386 .if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1387 @echo "--------------------------------------------------------------"
1388 @echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1389 @echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1390 @echo "--------------------------------------------------------------"
1393 .if defined(SVN_UPDATE)
1394 @echo "--------------------------------------------------------------"
1395 @echo ">>> Updating ${.CURDIR} using Subversion"
1396 @echo "--------------------------------------------------------------"
1397 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1401 # ------------------------------------------------------------------------
1403 # From here onwards are utility targets used by the 'make world' and
1404 # related targets. If your 'world' breaks, you may like to try to fix
1405 # the problem and manually run the following targets to attempt to
1406 # complete the build. Beware, this is *not* guaranteed to work, you
1407 # need to have a pretty good grip on the current state of the system
1408 # to attempt to manually finish it. If in doubt, 'make world' again.
1412 # legacy: Build compatibility shims for the next three targets. This is a
1413 # minimal set of tools and shims necessary to compensate for older systems
1414 # which don't have the APIs required by the targets built in bootstrap-tools,
1415 # build-tools or cross-tools.
1418 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1419 # r296685 fix cross-endian objcopy
1420 .if ${BOOTSTRAPPING} < 1100102
1421 _elftoolchain_libs= lib/libelf lib/libdwarf
1425 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1426 @echo "ERROR: Source upgrades from versions prior to 8.0 are not supported."; \
1429 .for _tool in tools/build ${_elftoolchain_libs}
1430 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1431 cd ${.CURDIR}/${_tool}; \
1432 ${MAKE} DIRPRFX=${_tool}/ obj; \
1433 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1434 ${MAKE} DIRPRFX=${_tool}/ all; \
1435 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1439 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1440 # are built to build other binaries in the system. However, the focus of these
1441 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1442 # libraries, augmented by -legacy.
1444 _bt= _bootstrap-tools
1446 .if ${MK_GAMES} != "no"
1447 _strfile= usr.bin/fortune/strfile
1450 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1451 _gperf= gnu/usr.bin/gperf
1454 .if ${MK_GROFF} != "no"
1455 _groff= gnu/usr.bin/groff \
1459 .if ${MK_VT} != "no"
1460 _vtfontcvt= usr.bin/vtfontcvt
1463 .if ${BOOTSTRAPPING} < 900002
1467 .if ${BOOTSTRAPPING} < 1000033
1468 _libopenbsd= lib/libopenbsd
1472 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1473 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1476 .if ${BOOTSTRAPPING} < 1000026
1477 _nmtree= lib/libnetbsd \
1480 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1483 .if ${BOOTSTRAPPING} < 1000027
1487 # r264059 support for status=
1488 .if ${BOOTSTRAPPING} < 1100017
1492 # r277259 crunchide: Correct 64-bit section header offset
1493 # r281674 crunchide: always include both 32- and 64-bit ELF support
1494 # r285986 crunchen: use STRIPBIN rather than STRIP
1495 .if ${BOOTSTRAPPING} < 1100078
1496 _crunch= usr.sbin/crunch
1499 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1503 # r296926 -P keymap search path
1504 .if ${BOOTSTRAPPING} < 1100103
1505 _kbdcontrol= usr.sbin/kbdcontrol
1511 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1513 .if ${MK_BSNMP} != "no"
1514 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1517 # We need to build tblgen when we're building clang either as
1518 # the bootstrap compiler, or as the part of the normal build.
1519 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1521 lib/clang/libllvmsupport \
1522 lib/clang/libllvmtablegen \
1523 usr.bin/clang/llvm-tblgen \
1524 usr.bin/clang/clang-tblgen
1526 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1527 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1530 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1533 .if ${MK_GPL_DTC} != "no"
1534 _dtc= gnu/usr.bin/dtc
1537 .if ${MK_KERBEROS} != "no"
1538 _kerberos5_bootstrap_tools= \
1539 kerberos5/tools/make-roken \
1540 kerberos5/lib/libroken \
1541 kerberos5/lib/libvers \
1542 kerberos5/tools/asn1_compile \
1543 kerberos5/tools/slc \
1546 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1549 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
1550 .if ${MK_MANDOCDB} != "no" && ${BOOTSTRAPPING} < 1100075
1551 _libopenbsd?= lib/libopenbsd
1552 _makewhatis= lib/libsqlite3 \
1554 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1557 bootstrap-tools: .PHONY
1559 # Please document (add comment) why something is in 'bootstrap-tools'.
1560 # Try to bound the building of the bootstrap-tool to just the
1561 # FreeBSD versions that need the tool built at this stage of the build.
1564 ${_kerberos5_bootstrap_tools} \
1588 ${_bt}-${_tool}: .PHONY .MAKE
1589 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1590 cd ${.CURDIR}/${_tool}; \
1591 ${MAKE} DIRPRFX=${_tool}/ obj; \
1592 ${MAKE} DIRPRFX=${_tool}/ all; \
1593 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1595 bootstrap-tools: ${_bt}-${_tool}
1599 # build-tools: Build special purpose build tools
1601 .if !defined(NO_SHARE)
1602 _share= share/syscons/scrnmaps
1605 .if ${MK_GCC} != "no"
1606 _gcc_tools= gnu/usr.bin/cc/cc_tools
1609 .if ${MK_RESCUE} != "no"
1610 # rescue includes programs that have build-tools targets
1611 _rescue=rescue/rescue
1617 ${LOCAL_TOOL_DIRS} \
1618 lib/ncurses/ncurses \
1619 lib/ncurses/ncursesw \
1624 usr.bin/mkesdb_static \
1625 usr.bin/mkcsmapper_static \
1627 build-tools_${_tool}: .PHONY
1628 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1629 cd ${.CURDIR}/${_tool}; \
1630 ${MAKE} DIRPRFX=${_tool}/ obj; \
1631 ${MAKE} DIRPRFX=${_tool}/ build-tools
1632 build-tools: build-tools_${_tool}
1636 build-tools_${_tool}: .PHONY
1637 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \
1638 cd ${.CURDIR}/${_tool}; \
1639 ${MAKE} DIRPRFX=${_tool}/ obj; \
1640 ${MAKE} DIRPRFX=${_tool}/ all
1641 build-tools: build-tools_${_tool}
1645 # kernel-tools: Build kernel-building tools
1648 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1649 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1650 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1653 # cross-tools: All the tools needed to build the rest of the system after
1654 # we get done with the earlier stages. It is the last set of tools needed
1655 # to begin building the target binaries.
1657 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1658 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1659 _btxld= usr.sbin/btxld
1663 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1664 # resulting from missing bug fixes or ELF Toolchain updates.
1665 .if ${MK_CDDL} != "no"
1666 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1667 cddl/usr.bin/ctfmerge
1670 # If we're given an XAS, don't build binutils.
1671 .if ${XAS:M/*} == ""
1672 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1673 _binutils= gnu/usr.bin/binutils
1675 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1676 _elftctools= lib/libelftc \
1682 # These are not required by the build, but can be useful for developers who
1683 # cross-build on a FreeBSD 10 host:
1684 _elftctools+= usr.bin/addr2line
1686 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1687 # If cross-building with an external binutils we still need to build strip for
1688 # the target (for at least crunchide).
1689 _elftctools= lib/libelftc \
1694 # If an full path to an external cross compiler is given, don't build
1696 .if ${XCC:N${CCACHE_BIN}:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1697 .if ${MK_CLANG_BOOTSTRAP} != "no"
1698 _clang= usr.bin/clang
1699 _clang_libs= lib/clang
1701 .if ${MK_GCC_BOOTSTRAP} != "no"
1705 .if ${MK_USB} != "no"
1706 _usb_tools= sys/boot/usb/tools
1709 cross-tools: .MAKE .PHONY
1720 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1721 cd ${.CURDIR}/${_tool}; \
1722 ${MAKE} DIRPRFX=${_tool}/ obj; \
1723 ${MAKE} DIRPRFX=${_tool}/ all; \
1724 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1727 NXBDESTDIR= ${OBJTREE}/nxb-bin
1728 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1729 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1730 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1731 NXBMAKE= ${NXBENV} ${MAKE} \
1732 LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \
1733 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1734 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1735 MK_GDB=no MK_TESTS=no \
1737 MK_HTML=no NO_LINT=yes MK_MAN=no \
1738 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1739 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1740 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1741 MK_LLDB=no MK_DEBUG_FILES=no
1743 # native-xtools is the current target for qemu-user cross builds of ports
1744 # via poudriere and the imgact_binmisc kernel module.
1745 # For non-clang enabled targets that are still using the in tree gcc
1746 # we must build a gperf binary for one instance of its Makefiles. On
1747 # clang-enabled systems, the gperf binary is obsolete.
1748 native-xtools: .PHONY
1749 .if ${MK_GCC_BOOTSTRAP} != "no"
1750 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1751 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \
1752 cd ${.CURDIR}/${_gperf}; \
1753 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1754 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1755 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1757 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1758 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1759 -p ${NXBDESTDIR}/usr >/dev/null
1760 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1761 -p ${NXBDESTDIR}/usr/include >/dev/null
1762 .if ${MK_DEBUG_FILES} != "no"
1763 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1764 -p ${NXBDESTDIR}/usr/lib >/dev/null
1825 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1826 cd ${.CURDIR}/${_tool}; \
1827 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1828 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1829 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1833 # hierarchy - ensure that all the needed directories are present
1835 hierarchy hier: .MAKE .PHONY
1836 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1839 # libraries - build all libraries, and install them under ${DESTDIR}.
1841 # The list of libraries with dependents (${_prebuild_libs}) and their
1842 # interdependencies (__L) are built automatically by the
1843 # ${.CURDIR}/tools/make_libdeps.sh script.
1845 libraries: .MAKE .PHONY
1846 ${_+_}cd ${.CURDIR}; \
1847 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1848 ${MAKE} -f Makefile.inc1 _startup_libs; \
1849 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1850 ${MAKE} -f Makefile.inc1 _generic_libs
1853 # static libgcc.a prerequisite for shared libc
1855 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1857 # These dependencies are not automatically generated:
1859 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1860 # all shared libraries for ELF.
1862 _startup_libs= gnu/lib/csu
1863 _startup_libs+= lib/csu
1864 _startup_libs+= gnu/lib/libgcc
1865 _startup_libs+= lib/libcompiler_rt
1866 _startup_libs+= lib/libc
1867 _startup_libs+= lib/libc_nonshared
1868 .if ${MK_LIBCPLUSPLUS} != "no"
1869 _startup_libs+= lib/libcxxrt
1872 gnu/lib/libgcc__L: lib/libc__L
1873 gnu/lib/libgcc__L: lib/libc_nonshared__L
1874 .if ${MK_LIBCPLUSPLUS} != "no"
1875 lib/libcxxrt__L: gnu/lib/libgcc__L
1878 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1879 ${_kerberos5_lib_libhdb} \
1880 ${_kerberos5_lib_libheimbase} \
1881 ${_kerberos5_lib_libheimntlm} \
1883 ${_kerberos5_lib_libheimipcc} \
1884 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1885 ${_kerberos5_lib_libroken} \
1886 ${_kerberos5_lib_libwind} \
1887 lib/libbz2 ${_libcom_err} lib/libcrypt \
1888 lib/libelf lib/libexpat \
1891 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1893 lib/ncurses/ncurses lib/ncurses/ncursesw \
1894 lib/libopie lib/libpam ${_lib_libthr} \
1895 ${_lib_libradius} lib/libsbuf lib/libtacplus \
1897 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1898 ${_cddl_lib_libuutil} \
1899 ${_cddl_lib_libavl} \
1900 ${_cddl_lib_libzfs_core} \
1901 ${_cddl_lib_libctf} \
1902 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1903 ${_secure_lib_libcrypto} ${_lib_libldns} \
1904 ${_secure_lib_libssh} ${_secure_lib_libssl} \
1906 .if ${MK_GNUCXX} != "no"
1907 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1908 gnu/lib/libstdc++__L: lib/msun__L
1909 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1912 .if ${MK_LIBCPLUSPLUS} != "no"
1913 _prebuild_libs+= lib/libc++
1916 lib/libgeom__L: lib/libexpat__L
1917 lib/libkvm__L: lib/libelf__L
1919 .if ${MK_LIBTHR} != "no"
1920 _lib_libthr= lib/libthr
1923 .if ${MK_RADIUS_SUPPORT} != "no"
1924 _lib_libradius= lib/libradius
1927 .if ${MK_OFED} != "no"
1928 _ofed_lib= contrib/ofed/usr.lib
1929 _prebuild_libs+= contrib/ofed/usr.lib/libosmcomp
1930 _prebuild_libs+= contrib/ofed/usr.lib/libopensm
1931 _prebuild_libs+= contrib/ofed/usr.lib/libibcommon
1932 _prebuild_libs+= contrib/ofed/usr.lib/libibverbs
1933 _prebuild_libs+= contrib/ofed/usr.lib/libibumad
1935 contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
1936 contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
1937 contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
1940 .if ${MK_CASPER} != "no"
1941 _lib_casper= lib/libcasper
1944 lib/libpjdlog__L: lib/libutil__L
1945 lib/libcasper__L: lib/libnv__L
1946 lib/liblzma__L: lib/libthr__L
1948 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1949 .for _DIR in ${LOCAL_LIB_DIRS}
1950 .if exists(${.CURDIR}/${_DIR}/Makefile) && empty(_generic_libs:M${_DIR})
1951 _generic_libs+= ${_DIR}
1955 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1957 .if ${MK_CDDL} != "no"
1958 _cddl_lib_libumem= cddl/lib/libumem
1959 _cddl_lib_libnvpair= cddl/lib/libnvpair
1960 _cddl_lib_libavl= cddl/lib/libavl
1961 _cddl_lib_libuutil= cddl/lib/libuutil
1962 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1963 _cddl_lib_libctf= cddl/lib/libctf
1965 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1966 cddl/lib/libzfs__L: lib/libgeom__L
1967 cddl/lib/libctf__L: lib/libz__L
1969 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
1970 # on select architectures though (see cddl/lib/Makefile)
1971 .if ${MACHINE_CPUARCH} != "sparc64"
1972 _prebuild_libs+= lib/libproc lib/librtld_db
1975 .if ${MK_CRYPT} != "no"
1976 .if ${MK_OPENSSL} != "no"
1977 _secure_lib_libcrypto= secure/lib/libcrypto
1978 _secure_lib_libssl= secure/lib/libssl
1979 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1980 .if ${MK_LDNS} != "no"
1981 _lib_libldns= lib/libldns
1982 lib/libldns__L: secure/lib/libcrypto__L
1984 .if ${MK_OPENSSH} != "no"
1985 _secure_lib_libssh= secure/lib/libssh
1986 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1987 .if ${MK_LDNS} != "no"
1988 secure/lib/libssh__L: lib/libldns__L
1990 .if ${MK_KERBEROS_SUPPORT} != "no"
1991 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1992 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1993 lib/libmd__L kerberos5/lib/libroken__L
1997 _secure_lib= secure/lib
2000 .if ${MK_KERBEROS} != "no"
2001 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2002 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2003 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2004 kerberos5/lib/libwind__L lib/libsqlite3__L
2005 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2006 kerberos5/lib/libroken__L lib/libcom_err__L
2007 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2008 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2009 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2010 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2011 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2012 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2013 kerberos5/lib/libroken__L: lib/libcrypt__L
2014 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2015 kerberos5/lib/libheimbase__L: lib/libthr__L
2016 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2019 lib/libsqlite3__L: lib/libthr__L
2021 .if ${MK_GSSAPI} != "no"
2022 _lib_libgssapi= lib/libgssapi
2025 .if ${MK_KERBEROS} != "no"
2026 _kerberos5_lib= kerberos5/lib
2027 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2028 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2029 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2030 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2031 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2032 _kerberos5_lib_libroken= kerberos5/lib/libroken
2033 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2034 _libsqlite3= lib/libsqlite3
2035 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2036 _kerberos5_lib_libwind= kerberos5/lib/libwind
2037 _libcom_err= lib/libcom_err
2040 .if ${MK_NIS} != "no"
2041 _lib_libypclnt= lib/libypclnt
2044 .if ${MK_OPENSSL} == "no"
2045 lib/libradius__L: lib/libmd__L
2049 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2050 .if ${MK_CXX} != "no"
2051 .if ${MK_LIBCPLUSPLUS} != "no"
2052 lib/libproc__L: lib/libcxxrt__L
2053 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2054 lib/libproc__L: gnu/lib/libsupc++__L
2058 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2060 .for _lib in ${_prereq_libs}
2061 ${_lib}__PL: .PHONY .MAKE
2062 .if exists(${.CURDIR}/${_lib})
2063 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2064 cd ${.CURDIR}/${_lib}; \
2065 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2066 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2067 DIRPRFX=${_lib}/ all; \
2068 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2069 DIRPRFX=${_lib}/ install
2073 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
2074 ${_lib}__L: .PHONY .MAKE
2075 .if exists(${.CURDIR}/${_lib})
2076 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2077 cd ${.CURDIR}/${_lib}; \
2078 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2079 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2080 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2084 # libpam is special: we need to build static PAM modules before
2085 # static PAM library, and dynamic PAM library before dynamic PAM
2087 lib/libpam__L: .PHONY .MAKE
2088 ${_+_}@${ECHODIR} "===> lib/libpam (obj,all,install)"; \
2089 cd ${.CURDIR}/lib/libpam; \
2090 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj; \
2091 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2092 -D_NO_LIBPAM_SO_YET all; \
2093 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2094 -D_NO_LIBPAM_SO_YET install
2096 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2097 _startup_libs: ${_startup_libs:S/$/__L/}
2098 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2099 _generic_libs: ${_generic_libs:S/$/__L/}
2101 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2102 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2103 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2104 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2105 # parallel. This is safe for the world stage of buildworld though since it has
2106 # already built libraries in a proper order and installed includes into
2107 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2108 # avoid trashing a system if it crashes mid-install.
2109 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2113 .include <bsd.subdir.mk>
2115 .if make(check-old) || make(check-old-dirs) || \
2116 make(check-old-files) || make(check-old-libs) || \
2117 make(delete-old) || make(delete-old-dirs) || \
2118 make(delete-old-files) || make(delete-old-libs)
2121 # check for / delete old files section
2124 .include "ObsoleteFiles.inc"
2126 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2127 else you can not start such an application. Consult UPDATING for more \
2128 information regarding how to cope with the removal/revision bump of a \
2131 .if !defined(BATCH_DELETE_OLD_FILES)
2138 @echo ">>> Removing old files (only deletes safe to delete libs)"
2139 # Ask for every old file if the user really wants to remove it.
2140 # It's annoying, but better safe than sorry.
2141 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2142 # argument list will get too long. Using .for/.endfor make "loops" will make
2143 # the Makefile parser segfault.
2146 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2147 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2148 while read file; do \
2149 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2150 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2151 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2153 for ext in debug symbols; do \
2154 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2155 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2156 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2161 # Remove catpages without corresponding manpages.
2163 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2164 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2165 while read catpage; do \
2167 if [ ! -e "$${manpage}" ]; then \
2168 rm ${RM_I} $${catpage} <&3; \
2171 @echo ">>> Old files removed"
2174 @echo ">>> Checking for old files"
2176 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2177 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2178 while read file; do \
2179 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2180 echo "${DESTDIR}/$${file}"; \
2182 for ext in debug symbols; do \
2183 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2184 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2188 # Check for catpages without corresponding manpages.
2189 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2190 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2191 while read catpage; do \
2193 if [ ! -e "$${manpage}" ]; then \
2199 @echo ">>> Removing old libraries"
2200 @echo "${OLD_LIBS_MESSAGE}" | fmt
2203 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2204 -V OLD_LIBS | xargs -n1 | \
2205 while read file; do \
2206 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2207 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2208 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2210 for ext in debug symbols; do \
2211 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2212 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2213 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2218 @echo ">>> Old libraries removed"
2221 @echo ">>> Checking for old libraries"
2223 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2224 -V OLD_LIBS | xargs -n1 | \
2225 while read file; do \
2226 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2227 echo "${DESTDIR}/$${file}"; \
2229 for ext in debug symbols; do \
2230 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2231 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2237 @echo ">>> Removing old directories"
2239 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2240 -V OLD_DIRS | xargs -n1 | sort -r | \
2241 while read dir; do \
2242 if [ -d "${DESTDIR}/$${dir}" ]; then \
2243 rmdir -v "${DESTDIR}/$${dir}" || true; \
2244 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2245 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2248 @echo ">>> Old directories removed"
2251 @echo ">>> Checking for old directories"
2253 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2254 -V OLD_DIRS | xargs -n1 | \
2255 while read dir; do \
2256 if [ -d "${DESTDIR}/$${dir}" ]; then \
2257 echo "${DESTDIR}/$${dir}"; \
2258 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2259 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2263 delete-old: delete-old-files delete-old-dirs
2264 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2266 check-old: check-old-files check-old-libs check-old-dirs
2267 @echo "To remove old files and directories run '${MAKE} delete-old'."
2268 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2273 # showconfig - show build configuration.
2276 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2277 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2279 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2280 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2282 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2283 .if exists(${KERNCONFDIR}/${KERNCONF})
2284 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2285 '${KERNCONFDIR}/${KERNCONF}' ; echo
2291 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2292 DTBOUTPUTPATH= ${.CURDIR}
2296 # Build 'standalone' Device Tree Blob
2299 @PATH=${TMPPATH} MACHINE=${TARGET} \
2300 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2301 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2306 # In the following, the first 'rm' in a series will usually remove all
2307 # files and directories. If it does not, then there are probably some
2308 # files with file flags set, so this unsets them and tries the 'rm' a
2309 # second time. There are situations where this target will be cleaning
2310 # some directories via more than one method, but that duplication is
2311 # needed to correctly handle all the possible situations. Removing all
2312 # files without file flags set in the first 'rm' instance saves time,
2313 # because 'chflags' will need to operate on fewer files afterwards.
2315 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2316 # created by bsd.obj.mk, except that we don't want to .include that file
2319 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2321 .if exists(${BW_CANONICALOBJDIR}/)
2322 -rm -rf ${BW_CANONICALOBJDIR}/*
2323 -chflags -R 0 ${BW_CANONICALOBJDIR}
2324 rm -rf ${BW_CANONICALOBJDIR}/*
2326 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2327 # To be safe in this case, fall back to a 'make cleandir'
2328 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2331 .if defined(TARGET) && defined(TARGET_ARCH)
2333 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2334 XDEV_CPUTYPE?=${CPUTYPE}
2336 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2339 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2340 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2341 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2342 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2343 CPUTYPE=${XDEV_CPUTYPE}
2345 XDDIR=${TARGET_ARCH}-freebsd
2348 .error XDTP variable should be an absolute path
2351 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2352 INSTALL="sh ${.CURDIR}/tools/install.sh"
2354 TOOLS_PREFIX=${XDTP}
2355 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2356 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2357 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2358 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2359 CPP="${CPP} ${CD2CFLAGS}" \
2360 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2362 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2363 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2364 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2365 XDDESTDIR=${DESTDIR}/${XDTP}
2367 OSREL!= uname -r | sed -e 's/[-(].*//'
2370 .ORDER: xdev-build xdev-install xdev-links
2371 xdev: xdev-build xdev-install
2373 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2374 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2376 _xb-worldtmp: .PHONY
2377 mkdir -p ${CDTMP}/usr
2378 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2379 -p ${CDTMP}/usr >/dev/null
2381 _xb-bootstrap-tools: .PHONY
2385 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2386 cd ${.CURDIR}/${_tool}; \
2387 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2388 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2389 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2392 _xb-build-tools: .PHONY
2393 ${_+_}@cd ${.CURDIR}; \
2394 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2396 _xb-cross-tools: .PHONY
2404 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2405 cd ${.CURDIR}/${_tool}; \
2406 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2407 ${CDMAKE} DIRPRFX=${_tool}/ all
2411 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2412 mkdir -p ${XDDESTDIR}
2413 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2414 -p ${XDDESTDIR} >/dev/null
2415 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2416 -p ${XDDESTDIR}/usr >/dev/null
2417 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2418 -p ${XDDESTDIR}/usr/include >/dev/null
2419 .if defined(LIBCOMPAT)
2420 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2421 -p ${XDDESTDIR}/usr >/dev/null
2423 .if ${MK_TESTS} != "no"
2424 mkdir -p ${XDDESTDIR}${TESTSBASE}
2425 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2426 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2429 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2430 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2432 _xi-cross-tools: .PHONY
2433 @echo "_xi-cross-tools"
2441 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2442 cd ${.CURDIR}/${_tool}; \
2443 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2446 _xi-includes: .PHONY
2447 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2448 DESTDIR=${XDDESTDIR}
2450 _xi-libraries: .PHONY
2451 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2452 DESTDIR=${XDDESTDIR}
2455 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2456 mkdir -p ../../../../usr/bin; \
2458 ln -sf ../../${XDTP}/usr/bin/$$i \
2459 ../../../../usr/bin/${XDDIR}-$$i; \
2460 ln -sf ../../${XDTP}/usr/bin/$$i \
2461 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2464 xdev xdev-build xdev-install xdev-links:
2465 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"