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
147 .if ${MK_META_MODE} == "yes"
148 # If filemon is used then we can rely on the build being incremental-safe.
149 # The .meta files will also track the build command and rebuild should
151 .if empty(.MAKE.MODE:Mnofilemon)
157 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
159 .if empty(SHELL:M*csh*)
160 BUILDENV_SHELL?=${SHELL}
162 BUILDENV_SHELL?=/bin/sh
165 .if !defined(SVN) || empty(SVN)
166 . for _P in /usr/bin /usr/local/bin
167 . for _S in svn svnlite
168 . if exists(${_P}/${_S})
176 MAKEOBJDIRPREFIX?= /usr/obj
177 .if !defined(OSRELDATE)
178 .if exists(/usr/include/osreldate.h)
179 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
180 /usr/include/osreldate.h
187 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
188 .if !defined(VERSION)
189 REVISION!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V REVISION
190 BRANCH!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V BRANCH
191 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
192 ${SRCDIR}/sys/sys/param.h
193 VERSION= FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
197 .if !defined(PKG_VERSION)
198 .if ${BRANCH:MSTABLE*} || ${BRANCH:MCURRENT*}
199 TIMENOW= %Y%m%d%H%M%S
200 EXTRA_REVISION= .s${TIMENOW:gmtime}
203 EXTRA_REVISION= _${BRANCH:C/.*-p([0-9]+$)/\1/}
205 PKG_VERSION= ${REVISION}${EXTRA_REVISION}
208 KNOWN_ARCHES?= aarch64/arm64 \
227 .if ${TARGET} == ${TARGET_ARCH}
230 _t= ${TARGET_ARCH}/${TARGET}
233 .if empty(KNOWN_ARCHES:M${_t})
234 .error Unknown target ${TARGET_ARCH}:${TARGET}.
238 .if ${TARGET} == ${MACHINE}
239 TARGET_CPUTYPE?=${CPUTYPE}
244 .if !empty(TARGET_CPUTYPE)
245 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
247 _TARGET_CPUTYPE=dummy
249 _CPUTYPE!= MK_AUTO_OBJ=no MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
250 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
251 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
252 .error CPUTYPE global should be set with ?=.
255 BUILD_ARCH!= uname -p
256 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
257 .error To cross-build, set TARGET_ARCH.
260 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
261 OBJTREE= ${MAKEOBJDIRPREFIX}
263 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
265 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
266 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
267 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
268 STRICTTMPPATH= ${BPATH}:${XPATH}
269 TMPPATH= ${STRICTTMPPATH}:${PATH}
272 # Avoid running mktemp(1) unless actually needed.
273 # It may not be functional, e.g., due to new ABI
274 # when in the middle of installing over this system.
276 .if make(distributeworld) || make(installworld) || make(stageworld)
277 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
280 .if make(stagekernel) || make(distributekernel)
286 # Building a world goes through the following stages
288 # 1. legacy stage [BMAKE]
289 # This stage is responsible for creating compatibility
290 # shims that are needed by the bootstrap-tools,
291 # build-tools and cross-tools stages. These are generally
292 # APIs that tools from one of those three stages need to
293 # build that aren't present on the host.
294 # 1. bootstrap-tools stage [BMAKE]
295 # This stage is responsible for creating programs that
296 # are needed for backward compatibility reasons. They
297 # are not built as cross-tools.
298 # 2. build-tools stage [TMAKE]
299 # This stage is responsible for creating the object
300 # tree and building any tools that are needed during
301 # the build process. Some programs are listed during
302 # this phase because they build binaries to generate
303 # files needed to build these programs. This stage also
304 # builds the 'build-tools' target rather than 'all'.
305 # 3. cross-tools stage [XMAKE]
306 # This stage is responsible for creating any tools that
307 # are needed for building the system. A cross-compiler is one
308 # of them. This differs from build tools in two ways:
309 # 1. the 'all' target is built rather than 'build-tools'
310 # 2. these tools are installed into TMPPATH for stage 4.
311 # 4. world stage [WMAKE]
312 # This stage actually builds the world.
313 # 5. install stage (optional) [IMAKE]
314 # This stage installs a previously built world.
319 # Common environment for world related stages
320 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
321 MACHINE_ARCH=${TARGET_ARCH} \
323 CPUTYPE=${TARGET_CPUTYPE}
324 .if ${MK_META_MODE} != "no"
325 # Don't rebuild build-tools targets during normal build.
326 CROSSENV+= BUILD_TOOLS_META=.NOMETA_CMP
328 .if ${MK_GROFF} != "no"
329 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
330 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
331 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
333 .if defined(TARGET_CFLAGS)
334 CROSSENV+= ${TARGET_CFLAGS}
337 # bootstrap-tools stage
338 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
339 TOOLS_PREFIX=${WORLDTMP} \
340 PATH=${BPATH}:${PATH} \
341 WORLDTMP=${WORLDTMP} \
342 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
343 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
345 BOOTSTRAPPING=${OSRELDATE} \
347 MK_HTML=no NO_LINT=yes MK_MAN=no \
348 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
349 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
350 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
351 MK_LLDB=no MK_TESTS=no \
354 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
355 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
359 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
360 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
361 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
363 BOOTSTRAPPING=${OSRELDATE} \
366 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
367 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
368 MK_LLDB=no MK_TESTS=no
371 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
372 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
373 MK_GDB=no MK_TESTS=no
376 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
377 PATH=${BPATH}:${PATH} \
379 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
380 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
382 BOOTSTRAPPING=${OSRELDATE} \
384 MK_HTML=no -DNO_LINT MK_MAN=no \
385 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
386 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
389 WMAKEENV= ${CROSSENV} \
390 INSTALL="sh ${.CURDIR}/tools/install.sh" \
394 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
396 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
399 .if defined(CROSS_TOOLCHAIN_PREFIX)
400 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
401 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
404 # If we do not have a bootstrap binutils (because the in-tree one does not
405 # support the target architecture), provide a default cross-binutils prefix.
406 # This allows aarch64 builds, for example, to automatically use the
407 # aarch64-binutils port or package.
408 .if !make(showconfig)
409 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
410 !defined(CROSS_BINUTILS_PREFIX)
411 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
412 .if !exists(${CROSS_BINUTILS_PREFIX})
413 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
418 XCOMPILERS= CC CXX CPP
419 .for COMPILER in ${XCOMPILERS}
420 .if defined(CROSS_COMPILER_PREFIX)
421 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
423 X${COMPILER}?= ${${COMPILER}}
426 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
427 .for BINUTIL in ${XBINUTILS}
428 .if defined(CROSS_BINUTILS_PREFIX) && \
429 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
430 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
432 X${BINUTIL}?= ${${BINUTIL}}
435 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
436 CPP="${XCPP} ${XCFLAGS}" \
437 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
438 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
439 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
442 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
443 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
444 # directory, but the compiler will look in the right place for its
445 # tools so we don't need to tell it where to look.
446 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
449 # External compiler needs sysroot and target flags.
450 .if ${XCC:N${CCACHE_BIN}:M/*} || ${MK_CROSS_COMPILER} == "no"
451 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
452 BFLAGS+= -B${WORLDTMP}/usr/bin
454 .if ${TARGET} == "arm"
455 .if ${TARGET_ARCH:M*hf*} != ""
456 TARGET_ABI= gnueabihf
461 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
462 # GCC requires -isystem and -L when using a cross-compiler.
463 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
464 # Force using libc++ for external GCC.
465 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
466 -nostdinc++ -L${WORLDTMP}/../lib/libc++
469 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
470 XCFLAGS+= -target ${TARGET_TRIPLE}
472 XCFLAGS+= --sysroot=${WORLDTMP}
474 .endif # ${XCC:M/*} || ${MK_CROSS_COMPILER} == "no"
480 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
481 ${TARGET_ARCH} == "powerpc64")
483 .include "Makefile.libcompat"
484 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH} == "armv6"
486 .include "Makefile.libcompat"
489 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
491 IMAKEENV= ${CROSSENV}
492 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
493 ${IMAKE_INSTALL} ${IMAKE_MTREE}
494 .if empty(.MAKEFLAGS:M-n)
495 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
496 LD_LIBRARY_PATH=${INSTALLTMP} \
497 PATH_LOCALE=${INSTALLTMP}/locale
498 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
500 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
502 .if defined(DB_FROM_SRC)
503 INSTALLFLAGS+= -N ${.CURDIR}/etc
504 MTREEFLAGS+= -N ${.CURDIR}/etc
506 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
507 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
509 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
510 IMAKE+= -DNO_ROOT METALOG=${METALOG}
511 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
514 .if defined(BUILD_PKGS)
515 INSTALLFLAGS+= -h sha256
517 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
518 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
519 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
523 KMAKEENV= ${WMAKEENV}
524 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
529 # Attempt to rebuild the entire system, with reasonable chance of
530 # success, regardless of how old your existing system is.
533 .if ${.CURDIR:C/[^,]//g} != ""
534 # The m4 build of sendmail files doesn't like it if ',' is used
535 # anywhere in the path of it's files.
537 @echo "*** Error: path to source tree contains a comma ','"
542 @echo "--------------------------------------------------------------"
543 @echo ">>> Rebuilding the temporary build tree"
544 @echo "--------------------------------------------------------------"
545 .if !defined(NO_CLEAN)
547 .if defined(LIBCOMPAT)
548 rm -rf ${LIBCOMPATTMP}
551 rm -rf ${WORLDTMP}/legacy/usr/include
552 # XXX - These can depend on any header file.
553 rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c
554 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
557 lib lib/casper usr legacy/bin legacy/usr
558 mkdir -p ${WORLDTMP}/${_dir}
560 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
561 -p ${WORLDTMP}/legacy/usr >/dev/null
562 .if ${MK_GROFF} != "no"
563 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
564 -p ${WORLDTMP}/legacy/usr >/dev/null
566 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
567 -p ${WORLDTMP}/usr >/dev/null
568 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
569 -p ${WORLDTMP}/usr/include >/dev/null
570 ln -sf ${.CURDIR}/sys ${WORLDTMP}
571 .if ${MK_DEBUG_FILES} != "no"
572 # We could instead disable debug files for these build stages
573 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
574 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
575 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
576 -p ${WORLDTMP}/usr/lib >/dev/null
578 .if defined(LIBCOMPAT)
579 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
580 -p ${WORLDTMP}/usr >/dev/null
581 .if ${MK_DEBUG_FILES} != "no"
582 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
583 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
584 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
585 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
588 .if ${MK_TESTS} != "no"
589 mkdir -p ${WORLDTMP}${TESTSBASE}
590 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
591 -p ${WORLDTMP}${TESTSBASE} >/dev/null
592 .if ${MK_DEBUG_FILES} != "no"
593 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
594 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
595 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
598 .for _mtree in ${LOCAL_MTREE}
599 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
603 @echo "--------------------------------------------------------------"
604 @echo ">>> stage 1.1: legacy release compatibility shims"
605 @echo "--------------------------------------------------------------"
606 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
609 @echo "--------------------------------------------------------------"
610 @echo ">>> stage 1.2: bootstrap tools"
611 @echo "--------------------------------------------------------------"
612 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
614 .if !defined(NO_CLEAN)
616 @echo "--------------------------------------------------------------"
617 @echo ">>> stage 2.1: cleaning up the object tree"
618 @echo "--------------------------------------------------------------"
619 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
620 .if defined(LIBCOMPAT)
621 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
626 @echo "--------------------------------------------------------------"
627 @echo ">>> stage 2.2: rebuilding the object tree"
628 @echo "--------------------------------------------------------------"
629 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
632 @echo "--------------------------------------------------------------"
633 @echo ">>> stage 2.3: build tools"
634 @echo "--------------------------------------------------------------"
635 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
638 @echo "--------------------------------------------------------------"
639 @echo ">>> stage 3: cross tools"
640 @echo "--------------------------------------------------------------"
641 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
642 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
645 @echo "--------------------------------------------------------------"
646 @echo ">>> stage 4.1: building includes"
647 @echo "--------------------------------------------------------------"
648 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
649 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
650 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
651 MK_INCLUDES=yes includes
652 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
653 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
657 @echo "--------------------------------------------------------------"
658 @echo ">>> stage 4.2: building libraries"
659 @echo "--------------------------------------------------------------"
660 ${_+_}cd ${.CURDIR}; \
661 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
662 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
665 @echo "--------------------------------------------------------------"
666 @echo ">>> stage 4.3: building everything"
667 @echo "--------------------------------------------------------------"
668 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
671 WMAKE_TGTS+= _worldtmp _legacy
672 .if empty(SUBDIR_OVERRIDE)
673 WMAKE_TGTS+= _bootstrap-tools
675 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
676 WMAKE_TGTS+= _includes _libraries
677 WMAKE_TGTS+= everything
678 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
679 WMAKE_TGTS+= build${libcompat}
682 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
683 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
685 buildworld_prologue: .PHONY
686 @echo "--------------------------------------------------------------"
687 @echo ">>> World build started on `LC_ALL=C date`"
688 @echo "--------------------------------------------------------------"
690 buildworld_epilogue: .PHONY
692 @echo "--------------------------------------------------------------"
693 @echo ">>> World build completed on `LC_ALL=C date`"
694 @echo "--------------------------------------------------------------"
697 # We need to have this as a target because the indirection between Makefile
698 # and Makefile.inc1 causes the correct PATH to be used, rather than a
699 # modification of the current environment's PATH. In addition, we need
700 # to quote multiword values.
703 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
705 .if ${.TARGETS:Mbuildenv}
706 .if ${.MAKEFLAGS:M-j}
707 .error The buildenv target is incompatible with -j
710 BUILDENV_DIR?= ${.CURDIR}
712 @echo Entering world for ${TARGET_ARCH}:${TARGET}
713 .if ${BUILDENV_SHELL:M*zsh*}
714 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
716 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
719 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
720 toolchain: ${TOOLCHAIN_TGTS}
721 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
726 # Checks to be sure system is ready for installworld/installkernel.
728 installcheck: _installcheck_world _installcheck_kernel .PHONY
729 _installcheck_world: .PHONY
730 _installcheck_kernel: .PHONY
733 # Require DESTDIR to be set if installing for a different architecture or
734 # using the user/group database in the source tree.
736 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
738 .if !make(distributeworld)
739 _installcheck_world: __installcheck_DESTDIR
740 _installcheck_kernel: __installcheck_DESTDIR
741 __installcheck_DESTDIR: .PHONY
742 .if !defined(DESTDIR) || empty(DESTDIR)
743 @echo "ERROR: Please set DESTDIR!"; \
749 .if !defined(DB_FROM_SRC)
751 # Check for missing UIDs/GIDs.
753 CHECK_UIDS= auditdistd
755 .if ${MK_SENDMAIL} != "no"
761 CHECK_GIDS+= proxy authpf
763 .if ${MK_UNBOUND} != "no"
767 _installcheck_world: __installcheck_UGID
768 __installcheck_UGID: .PHONY
769 .for uid in ${CHECK_UIDS}
770 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
771 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
775 .for gid in ${CHECK_GIDS}
776 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
777 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
784 # Required install tools to be saved in a scratch dir for safety.
786 .if ${MK_ZONEINFO} != "no"
787 _zoneinfo= zic tzsetup
790 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
791 date echo egrep find grep id install ${_install-info} \
792 ln make mkdir mtree mv pwd_mkdb \
793 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
796 # Needed for share/man
797 .if ${MK_MAN} != "no"
804 # Distributes everything compiled by a `buildworld'.
808 # Installs everything compiled by a 'buildworld'.
811 # Non-base distributions produced by the base system
812 EXTRA_DISTRIBUTIONS= doc
813 .if defined(LIBCOMPAT)
814 EXTRA_DISTRIBUTIONS+= lib${libcompat}
816 .if ${MK_TESTS} != "no"
817 EXTRA_DISTRIBUTIONS+= tests
821 .if ${MK_DEBUG_FILES} != "no"
822 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
825 MTREE_MAGIC?= mtree 2.0
827 distributeworld installworld stageworld: _installcheck_world
828 mkdir -p ${INSTALLTMP}
829 progs=$$(for prog in ${ITOOLS}; do \
830 if progpath=`which $$prog`; then \
833 echo "Required tool $$prog not found in PATH." >&2; \
837 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
838 while read line; do \
840 if [ "$$2 $$3" != "not found" ]; then \
843 echo "Required library $$1 not found." >&2; \
847 cp $$libs $$progs ${INSTALLTMP}
848 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
850 -mkdir -p ${METALOG:H}
851 echo "#${MTREE_MAGIC}" > ${METALOG}
853 .if make(distributeworld)
854 .for dist in ${EXTRA_DISTRIBUTIONS}
855 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
856 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
857 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
858 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
859 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
860 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
861 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
862 .if ${MK_DEBUG_FILES} != "no"
863 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
864 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
866 .if defined(LIBCOMPAT)
867 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
868 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
869 .if ${MK_DEBUG_FILES} != "no"
870 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
871 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
874 .if ${MK_TESTS} != "no" && ${dist} == "tests"
875 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
876 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
877 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
878 .if ${MK_DEBUG_FILES} != "no"
879 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
880 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
884 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
885 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
886 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
887 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
888 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
889 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
890 .if defined(LIBCOMPAT)
891 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
892 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
896 -mkdir ${DESTDIR}/${DISTDIR}/base
897 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
898 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
899 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
900 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
902 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
903 ${IMAKEENV} rm -rf ${INSTALLTMP}
904 .if make(distributeworld)
905 .for dist in ${EXTRA_DISTRIBUTIONS}
906 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
909 .for dist in base ${EXTRA_DISTRIBUTIONS}
910 @# For each file that exists in this dist, print the corresponding
911 @# line from the METALOG. This relies on the fact that
912 @# a line containing only the filename will sort immediatly before
913 @# the relevant mtree line.
914 cd ${DESTDIR}/${DISTDIR}; \
915 find ./${dist} | sort -u ${METALOG} - | \
916 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
917 ${DESTDIR}/${DISTDIR}/${dist}.meta
919 .for dist in ${DEBUG_DISTRIBUTIONS}
920 @# For each file that exists in this dist, print the corresponding
921 @# line from the METALOG. This relies on the fact that
922 @# a line containing only the filename will sort immediatly before
923 @# the relevant mtree line.
924 cd ${DESTDIR}/${DISTDIR}; \
925 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
926 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
927 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
933 .for dist in base ${EXTRA_DISTRIBUTIONS}
935 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
936 tar cvf - --exclude usr/lib/debug \
937 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
938 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
940 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
941 tar cvf - --exclude usr/lib/debug . | \
942 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
946 .for dist in ${DEBUG_DISTRIBUTIONS}
947 . if defined(NO_ROOT)
948 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
949 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
950 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
952 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
953 tar cvLf - usr/lib/debug | \
954 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
961 # If you have a build server, you can NFS mount the source and obj directories
962 # and do a 'make reinstall' on the *client* to install new binaries from the
963 # most recent server build.
965 reinstall: .MAKE .PHONY
966 @echo "--------------------------------------------------------------"
967 @echo ">>> Making hierarchy"
968 @echo "--------------------------------------------------------------"
969 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
970 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
972 @echo "--------------------------------------------------------------"
973 @echo ">>> Installing everything"
974 @echo "--------------------------------------------------------------"
975 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
976 .if defined(LIBCOMPAT)
977 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
980 restage: .MAKE .PHONY
981 @echo "--------------------------------------------------------------"
982 @echo ">>> Making hierarchy"
983 @echo "--------------------------------------------------------------"
984 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
985 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy distribution
987 @echo "--------------------------------------------------------------"
988 @echo ">>> Installing everything"
989 @echo "--------------------------------------------------------------"
990 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
991 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
992 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
995 redistribute: .MAKE .PHONY
996 @echo "--------------------------------------------------------------"
997 @echo ">>> Distributing everything"
998 @echo "--------------------------------------------------------------"
999 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1000 .if defined(LIBCOMPAT)
1001 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1002 DISTRIBUTION=lib${libcompat}
1005 distrib-dirs distribution: .MAKE .PHONY
1006 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1007 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1008 .if make(distribution)
1009 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1010 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1011 METALOG=${METALOG} MK_TESTS=no installconfig
1015 # buildkernel and installkernel
1017 # Which kernels to build and/or install is specified by setting
1018 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1019 # Only the existing (depending TARGET) config files are used
1020 # for building kernels and only the first of these is designated
1021 # as the one being installed.
1023 # Note that we have to use TARGET instead of TARGET_ARCH when
1024 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1025 # be set to cross-build, we have to make sure TARGET is set
1028 .if defined(KERNFAST)
1032 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1033 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1034 KERNCONF=${KERNFAST}
1037 .if ${TARGET_ARCH} == "powerpc64"
1038 KERNCONF?= GENERIC64
1042 INSTKERNNAME?= kernel
1044 KERNSRCDIR?= ${.CURDIR}/sys
1045 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1046 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1047 KERNCONFDIR?= ${KRNLCONFDIR}
1051 .if defined(NO_INSTALLKERNEL)
1052 # All of the BUILDKERNELS loops start at index 1.
1053 BUILDKERNELS+= dummy
1055 .for _kernel in ${KERNCONF}
1056 .if exists(${KERNCONFDIR}/${_kernel})
1057 BUILDKERNELS+= ${_kernel}
1058 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1059 INSTALLKERNEL= ${_kernel}
1064 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1069 # Builds all kernels defined by BUILDKERNELS.
1071 buildkernel: .MAKE .PHONY
1072 .if empty(BUILDKERNELS:Ndummy)
1073 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1077 .for _kernel in ${BUILDKERNELS:Ndummy}
1078 @echo "--------------------------------------------------------------"
1079 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1080 @echo "--------------------------------------------------------------"
1081 @echo "===> ${_kernel}"
1082 mkdir -p ${KRNLOBJDIR}
1083 .if !defined(NO_KERNELCONFIG)
1085 @echo "--------------------------------------------------------------"
1086 @echo ">>> stage 1: configuring the kernel"
1087 @echo "--------------------------------------------------------------"
1088 cd ${KRNLCONFDIR}; \
1090 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1091 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1093 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1095 @echo "--------------------------------------------------------------"
1096 @echo ">>> stage 2.1: cleaning up the object tree"
1097 @echo "--------------------------------------------------------------"
1098 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1100 .if !defined(NO_KERNELOBJ)
1102 @echo "--------------------------------------------------------------"
1103 @echo ">>> stage 2.2: rebuilding the object tree"
1104 @echo "--------------------------------------------------------------"
1105 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1108 @echo "--------------------------------------------------------------"
1109 @echo ">>> stage 2.3: build tools"
1110 @echo "--------------------------------------------------------------"
1111 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1113 @echo "--------------------------------------------------------------"
1114 @echo ">>> stage 3.1: building everything"
1115 @echo "--------------------------------------------------------------"
1116 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1117 @echo "--------------------------------------------------------------"
1118 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1119 @echo "--------------------------------------------------------------"
1123 # installkernel, etc.
1125 # Install the kernel defined by INSTALLKERNEL
1127 installkernel installkernel.debug \
1128 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1129 .if !defined(NO_INSTALLKERNEL)
1130 .if empty(INSTALLKERNEL)
1131 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1134 @echo "--------------------------------------------------------------"
1135 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1136 @echo "--------------------------------------------------------------"
1137 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1138 ${CROSSENV} PATH=${TMPPATH} \
1139 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1141 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1142 .for _kernel in ${BUILDKERNELS:[2..-1]}
1143 @echo "--------------------------------------------------------------"
1144 @echo ">>> Installing kernel ${_kernel}"
1145 @echo "--------------------------------------------------------------"
1146 cd ${KRNLOBJDIR}/${_kernel}; \
1147 ${CROSSENV} PATH=${TMPPATH} \
1148 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1152 distributekernel distributekernel.debug: .PHONY
1153 .if !defined(NO_INSTALLKERNEL)
1154 .if empty(INSTALLKERNEL)
1155 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1158 mkdir -p ${DESTDIR}/${DISTDIR}
1159 .if defined(NO_ROOT)
1160 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1162 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1163 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1164 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1165 DESTDIR=${INSTALL_DDIR}/kernel \
1166 ${.TARGET:S/distributekernel/install/}
1167 .if defined(NO_ROOT)
1168 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1169 ${DESTDIR}/${DISTDIR}/kernel.meta
1172 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1173 .for _kernel in ${BUILDKERNELS:[2..-1]}
1174 .if defined(NO_ROOT)
1175 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1177 cd ${KRNLOBJDIR}/${_kernel}; \
1178 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1179 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1180 KERNEL=${INSTKERNNAME}.${_kernel} \
1181 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1182 ${.TARGET:S/distributekernel/install/}
1183 .if defined(NO_ROOT)
1184 @sed -e "s|^./kernel.${_kernel}|.|" \
1185 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1186 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1191 packagekernel: .PHONY
1192 .if defined(NO_ROOT)
1193 .if !defined(NO_INSTALLKERNEL)
1194 cd ${DESTDIR}/${DISTDIR}/kernel; \
1195 tar cvf - --exclude '*.debug' \
1196 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1197 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1199 cd ${DESTDIR}/${DISTDIR}/kernel; \
1200 tar cvf - --include '*/*/*.debug' \
1201 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1202 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1203 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1204 .for _kernel in ${BUILDKERNELS:[2..-1]}
1205 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1206 tar cvf - --exclude '*.debug' \
1207 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1208 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1209 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1210 tar cvf - --include '*/*/*.debug' \
1211 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1212 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1216 .if !defined(NO_INSTALLKERNEL)
1217 cd ${DESTDIR}/${DISTDIR}/kernel; \
1218 tar cvf - --exclude '*.debug' . | \
1219 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1221 cd ${DESTDIR}/${DISTDIR}/kernel; \
1222 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1223 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1224 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1225 .for _kernel in ${BUILDKERNELS:[2..-1]}
1226 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1227 tar cvf - --exclude '*.debug' . | \
1228 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1229 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1230 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1231 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1237 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1239 PORTSDIR?= /usr/ports
1240 WSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/worldstage
1241 KSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/kernelstage
1242 REPODIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/repo
1243 PKGSIGNKEY?= # empty
1245 .ORDER: stage-packages create-packages
1246 .ORDER: create-packages create-world-packages
1247 .ORDER: create-packages create-kernel-packages
1248 .ORDER: create-packages sign-packages
1250 _pkgbootstrap: .PHONY
1251 .if !exists(${LOCALBASE}/sbin/pkg)
1252 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1256 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1259 rm -rf /tmp/ports.${TARGET} || :
1260 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${REVISION} \
1261 PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} WSTAGEDIR=${WSTAGEDIR} \
1262 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1264 real-packages: stage-packages create-packages sign-packages .PHONY
1266 stage-packages: .PHONY
1267 @mkdir -p ${REPODIR} ${WSTAGEDIR} ${KSTAGEDIR}
1268 ${_+_}@cd ${.CURDIR}; \
1269 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT -B stageworld ; \
1270 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT -B stagekernel
1272 create-packages: _pkgbootstrap .PHONY
1273 @mkdir -p ${REPODIR}
1274 ${_+_}@cd ${.CURDIR}; \
1275 ${MAKE} DESTDIR=${WSTAGEDIR} \
1276 PKG_VERSION=${PKG_VERSION} create-world-packages ; \
1277 ${MAKE} DESTDIR=${KSTAGEDIR} \
1278 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1279 create-kernel-packages
1281 create-world-packages: _pkgbootstrap .PHONY
1282 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1283 @cd ${WSTAGEDIR} ; \
1284 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1285 ${WSTAGEDIR}/METALOG
1286 @for plist in ${WSTAGEDIR}/*.plist; do \
1287 plist=$${plist##*/} ; \
1288 pkgname=$${plist%.plist} ; \
1289 sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \
1290 -s ${SRCDIR} -u ${WSTAGEDIR}/$${pkgname}.ucl ; \
1292 @for plist in ${WSTAGEDIR}/*.plist; do \
1293 plist=$${plist##*/} ; \
1294 pkgname=$${plist%.plist} ; \
1296 /^name/ { printf("===> Creating %s-", $$2); next } \
1297 /^version/ { print $$2; next } \
1298 ' ${WSTAGEDIR}/$${pkgname}.ucl ; \
1299 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1300 create -M ${WSTAGEDIR}/$${pkgname}.ucl \
1301 -p ${WSTAGEDIR}/$${pkgname}.plist \
1303 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} ; \
1306 create-kernel-packages: _pkgbootstrap .PHONY
1307 .if exists(${KSTAGEDIR}/kernel.meta)
1308 .for flavor in "" -debug
1309 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1310 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1311 -v kernel=yes -v _kernconf=${INSTALLKERNEL} \
1312 ${KSTAGEDIR}/kernel.meta ; \
1313 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1314 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1315 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1316 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1317 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1318 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1319 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1320 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1321 ${SRCDIR}/release/packages/kernel.ucl \
1322 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1324 /name/ { printf("===> Creating %s-", $$2); next } \
1325 /version/ {print $$2; next } ' \
1326 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1327 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1328 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1329 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1330 -r ${KSTAGEDIR}/${DISTDIR} \
1331 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1334 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1335 .for _kernel in ${BUILDKERNELS:[2..-1]}
1336 .if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1337 .for flavor in "" -debug
1338 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1339 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1340 -v kernel=yes -v _kernconf=${_kernel} \
1341 ${KSTAGEDIR}/kernel.${_kernel}.meta ; \
1342 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1343 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1344 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1345 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1346 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1347 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1348 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1349 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1350 ${SRCDIR}/release/packages/kernel.ucl \
1351 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1353 /name/ { printf("===> Creating %s-", $$2); next } \
1354 /version/ {print $$2; next } ' \
1355 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1356 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1357 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1358 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1359 -r ${KSTAGEDIR}/kernel.${_kernel} \
1360 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1366 sign-packages: _pkgbootstrap .PHONY
1367 @[ -L "${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1368 unlink ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1369 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1370 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1371 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1373 ln -s ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1374 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest
1380 # Run test suite on installed world.
1383 @if [ ! -x ${LOCALBASE}/bin/kyua ]; then \
1384 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1387 ${_+_}${LOCALBASE}/bin/kyua test -k ${TESTSBASE}/Kyuafile
1393 # Build the API documentation with doxygen
1396 @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1397 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1400 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1405 # Update the source tree(s), by running svn/svnup to update to the
1409 .if defined(SVN_UPDATE)
1410 @echo "--------------------------------------------------------------"
1411 @echo ">>> Updating ${.CURDIR} using Subversion"
1412 @echo "--------------------------------------------------------------"
1413 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1417 # ------------------------------------------------------------------------
1419 # From here onwards are utility targets used by the 'make world' and
1420 # related targets. If your 'world' breaks, you may like to try to fix
1421 # the problem and manually run the following targets to attempt to
1422 # complete the build. Beware, this is *not* guaranteed to work, you
1423 # need to have a pretty good grip on the current state of the system
1424 # to attempt to manually finish it. If in doubt, 'make world' again.
1428 # legacy: Build compatibility shims for the next three targets. This is a
1429 # minimal set of tools and shims necessary to compensate for older systems
1430 # which don't have the APIs required by the targets built in bootstrap-tools,
1431 # build-tools or cross-tools.
1434 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1435 # r296685 fix cross-endian objcopy
1436 .if ${BOOTSTRAPPING} < 1100102
1437 _elftoolchain_libs= lib/libelf lib/libdwarf
1441 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1442 @echo "ERROR: Source upgrades from versions prior to 8.0 are not supported."; \
1445 .for _tool in tools/build ${_elftoolchain_libs}
1446 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1447 cd ${.CURDIR}/${_tool}; \
1448 ${MAKE} DIRPRFX=${_tool}/ obj; \
1449 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1450 ${MAKE} DIRPRFX=${_tool}/ all; \
1451 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1455 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1456 # are built to build other binaries in the system. However, the focus of these
1457 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1458 # libraries, augmented by -legacy.
1460 _bt= _bootstrap-tools
1462 .if ${MK_GAMES} != "no"
1463 _strfile= usr.bin/fortune/strfile
1466 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1467 _gperf= gnu/usr.bin/gperf
1470 .if ${MK_GROFF} != "no"
1471 _groff= gnu/usr.bin/groff \
1475 .if ${MK_VT} != "no"
1476 _vtfontcvt= usr.bin/vtfontcvt
1479 .if ${BOOTSTRAPPING} < 900002
1483 .if ${BOOTSTRAPPING} < 1000033
1484 _libopenbsd= lib/libopenbsd
1488 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1489 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1492 .if ${BOOTSTRAPPING} < 1000026
1493 _nmtree= lib/libnetbsd \
1496 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1499 .if ${BOOTSTRAPPING} < 1000027
1503 # r264059 support for status=
1504 .if ${BOOTSTRAPPING} < 1100017
1508 # r277259 crunchide: Correct 64-bit section header offset
1509 # r281674 crunchide: always include both 32- and 64-bit ELF support
1510 # r285986 crunchen: use STRIPBIN rather than STRIP
1511 .if ${BOOTSTRAPPING} < 1100078
1512 _crunch= usr.sbin/crunch
1515 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1519 # r296926 -P keymap search path, MFC to stable/10 in r298297
1520 .if ${BOOTSTRAPPING} < 1003501 || \
1521 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
1522 _kbdcontrol= usr.sbin/kbdcontrol
1528 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1530 .if ${MK_BSNMP} != "no"
1531 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1534 # We need to build tblgen when we're building clang either as
1535 # the bootstrap compiler, or as the part of the normal build.
1536 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1538 lib/clang/libllvmsupport \
1539 lib/clang/libllvmtablegen \
1540 usr.bin/clang/llvm-tblgen \
1541 usr.bin/clang/clang-tblgen
1543 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1544 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1547 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1550 .if ${MK_GPL_DTC} != "no"
1551 _dtc= gnu/usr.bin/dtc
1554 .if ${MK_KERBEROS} != "no"
1555 _kerberos5_bootstrap_tools= \
1556 kerberos5/tools/make-roken \
1557 kerberos5/lib/libroken \
1558 kerberos5/lib/libvers \
1559 kerberos5/tools/asn1_compile \
1560 kerberos5/tools/slc \
1563 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1566 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
1567 .if ${MK_MANDOCDB} != "no" && ${BOOTSTRAPPING} < 1100075
1568 _libopenbsd?= lib/libopenbsd
1569 _makewhatis= lib/libsqlite3 \
1571 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1574 bootstrap-tools: .PHONY
1576 # Please document (add comment) why something is in 'bootstrap-tools'.
1577 # Try to bound the building of the bootstrap-tool to just the
1578 # FreeBSD versions that need the tool built at this stage of the build.
1581 ${_kerberos5_bootstrap_tools} \
1605 ${_bt}-${_tool}: .PHONY .MAKE
1606 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1607 cd ${.CURDIR}/${_tool}; \
1608 ${MAKE} DIRPRFX=${_tool}/ obj; \
1609 ${MAKE} DIRPRFX=${_tool}/ all; \
1610 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1612 bootstrap-tools: ${_bt}-${_tool}
1616 # build-tools: Build special purpose build tools
1618 .if !defined(NO_SHARE)
1619 _share= share/syscons/scrnmaps
1622 .if ${MK_GCC} != "no"
1623 _gcc_tools= gnu/usr.bin/cc/cc_tools
1626 .if ${MK_RESCUE} != "no"
1627 # rescue includes programs that have build-tools targets
1628 _rescue=rescue/rescue
1634 ${LOCAL_TOOL_DIRS} \
1635 lib/ncurses/ncurses \
1636 lib/ncurses/ncursesw \
1641 usr.bin/mkesdb_static \
1642 usr.bin/mkcsmapper_static \
1644 build-tools_${_tool}: .PHONY
1645 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1646 cd ${.CURDIR}/${_tool}; \
1647 ${MAKE} DIRPRFX=${_tool}/ obj; \
1648 ${MAKE} DIRPRFX=${_tool}/ build-tools
1649 build-tools: build-tools_${_tool}
1653 build-tools_${_tool}: .PHONY
1654 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \
1655 cd ${.CURDIR}/${_tool}; \
1656 ${MAKE} DIRPRFX=${_tool}/ obj; \
1657 ${MAKE} DIRPRFX=${_tool}/ all
1658 build-tools: build-tools_${_tool}
1662 # kernel-tools: Build kernel-building tools
1664 kernel-tools: .PHONY
1665 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1666 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1667 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1670 # cross-tools: All the tools needed to build the rest of the system after
1671 # we get done with the earlier stages. It is the last set of tools needed
1672 # to begin building the target binaries.
1674 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1675 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1676 _btxld= usr.sbin/btxld
1680 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1681 # resulting from missing bug fixes or ELF Toolchain updates.
1682 .if ${MK_CDDL} != "no"
1683 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1684 cddl/usr.bin/ctfmerge
1687 # If we're given an XAS, don't build binutils.
1688 .if ${XAS:M/*} == ""
1689 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1690 _binutils= gnu/usr.bin/binutils
1692 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1693 _elftctools= lib/libelftc \
1699 # These are not required by the build, but can be useful for developers who
1700 # cross-build on a FreeBSD 10 host:
1701 _elftctools+= usr.bin/addr2line
1703 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1704 # If cross-building with an external binutils we still need to build strip for
1705 # the target (for at least crunchide).
1706 _elftctools= lib/libelftc \
1711 # If an full path to an external cross compiler is given, don't build
1713 .if ${XCC:N${CCACHE_BIN}:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1714 .if ${MK_CLANG_BOOTSTRAP} != "no"
1715 _clang= usr.bin/clang
1716 _clang_libs= lib/clang
1718 .if ${MK_GCC_BOOTSTRAP} != "no"
1722 .if ${MK_USB} != "no"
1723 _usb_tools= sys/boot/usb/tools
1726 cross-tools: .MAKE .PHONY
1737 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1738 cd ${.CURDIR}/${_tool}; \
1739 ${MAKE} DIRPRFX=${_tool}/ obj; \
1740 ${MAKE} DIRPRFX=${_tool}/ all; \
1741 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1744 NXBDESTDIR= ${OBJTREE}/nxb-bin
1745 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1746 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1747 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1748 NXBMAKE= ${NXBENV} ${MAKE} \
1749 LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \
1750 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1751 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1752 MK_GDB=no MK_TESTS=no \
1754 MK_HTML=no NO_LINT=yes MK_MAN=no \
1755 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1756 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1757 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1758 MK_LLDB=no MK_DEBUG_FILES=no
1760 # native-xtools is the current target for qemu-user cross builds of ports
1761 # via poudriere and the imgact_binmisc kernel module.
1762 # For non-clang enabled targets that are still using the in tree gcc
1763 # we must build a gperf binary for one instance of its Makefiles. On
1764 # clang-enabled systems, the gperf binary is obsolete.
1765 native-xtools: .PHONY
1766 .if ${MK_GCC_BOOTSTRAP} != "no"
1767 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1768 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \
1769 cd ${.CURDIR}/${_gperf}; \
1770 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1771 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1772 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1774 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1775 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1776 -p ${NXBDESTDIR}/usr >/dev/null
1777 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1778 -p ${NXBDESTDIR}/usr/include >/dev/null
1779 .if ${MK_DEBUG_FILES} != "no"
1780 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1781 -p ${NXBDESTDIR}/usr/lib >/dev/null
1842 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1843 cd ${.CURDIR}/${_tool}; \
1844 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1845 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1846 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1850 # hierarchy - ensure that all the needed directories are present
1852 hierarchy hier: .MAKE .PHONY
1853 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1856 # libraries - build all libraries, and install them under ${DESTDIR}.
1858 # The list of libraries with dependents (${_prebuild_libs}) and their
1859 # interdependencies (__L) are built automatically by the
1860 # ${.CURDIR}/tools/make_libdeps.sh script.
1862 libraries: .MAKE .PHONY
1863 ${_+_}cd ${.CURDIR}; \
1864 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1865 ${MAKE} -f Makefile.inc1 _startup_libs; \
1866 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1867 ${MAKE} -f Makefile.inc1 _generic_libs
1870 # static libgcc.a prerequisite for shared libc
1872 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1874 # These dependencies are not automatically generated:
1876 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1877 # all shared libraries for ELF.
1879 _startup_libs= gnu/lib/csu
1880 _startup_libs+= lib/csu
1881 _startup_libs+= gnu/lib/libgcc
1882 _startup_libs+= lib/libcompiler_rt
1883 _startup_libs+= lib/libc
1884 _startup_libs+= lib/libc_nonshared
1885 .if ${MK_LIBCPLUSPLUS} != "no"
1886 _startup_libs+= lib/libcxxrt
1889 gnu/lib/libgcc__L: lib/libc__L
1890 gnu/lib/libgcc__L: lib/libc_nonshared__L
1891 .if ${MK_LIBCPLUSPLUS} != "no"
1892 lib/libcxxrt__L: gnu/lib/libgcc__L
1895 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1896 ${_kerberos5_lib_libhdb} \
1897 ${_kerberos5_lib_libheimbase} \
1898 ${_kerberos5_lib_libheimntlm} \
1900 ${_kerberos5_lib_libheimipcc} \
1901 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1902 ${_kerberos5_lib_libroken} \
1903 ${_kerberos5_lib_libwind} \
1904 lib/libbz2 ${_libcom_err} lib/libcrypt \
1905 lib/libelf lib/libexpat \
1908 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1910 lib/ncurses/ncurses lib/ncurses/ncursesw \
1911 lib/libopie lib/libpam/libpam ${_lib_libthr} \
1912 ${_lib_libradius} lib/libsbuf lib/libtacplus \
1914 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1915 ${_cddl_lib_libuutil} \
1916 ${_cddl_lib_libavl} \
1917 ${_cddl_lib_libzfs_core} \
1918 ${_cddl_lib_libctf} \
1919 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1920 ${_secure_lib_libcrypto} ${_lib_libldns} \
1921 ${_secure_lib_libssh} ${_secure_lib_libssl} \
1924 .if ${MK_GNUCXX} != "no"
1925 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1926 gnu/lib/libstdc++__L: lib/msun__L
1927 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1930 .if ${MK_LIBCPLUSPLUS} != "no"
1931 _prebuild_libs+= lib/libc++
1934 lib/libgeom__L: lib/libexpat__L
1935 lib/libkvm__L: lib/libelf__L
1937 .if ${MK_LIBTHR} != "no"
1938 _lib_libthr= lib/libthr
1941 .if ${MK_RADIUS_SUPPORT} != "no"
1942 _lib_libradius= lib/libradius
1945 .if ${MK_OFED} != "no"
1946 _ofed_lib= contrib/ofed/usr.lib
1947 _prebuild_libs+= contrib/ofed/usr.lib/libosmcomp
1948 _prebuild_libs+= contrib/ofed/usr.lib/libopensm
1949 _prebuild_libs+= contrib/ofed/usr.lib/libibcommon
1950 _prebuild_libs+= contrib/ofed/usr.lib/libibverbs
1951 _prebuild_libs+= contrib/ofed/usr.lib/libibumad
1953 contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
1954 contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
1955 contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
1958 .if ${MK_CASPER} != "no"
1959 _lib_casper= lib/libcasper
1962 lib/libpjdlog__L: lib/libutil__L
1963 lib/libcasper__L: lib/libnv__L
1964 lib/liblzma__L: lib/libthr__L
1966 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1967 .for _DIR in ${LOCAL_LIB_DIRS}
1968 .if exists(${.CURDIR}/${_DIR}/Makefile) && empty(_generic_libs:M${_DIR})
1969 _generic_libs+= ${_DIR}
1973 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1975 .if ${MK_CDDL} != "no"
1976 _cddl_lib_libumem= cddl/lib/libumem
1977 _cddl_lib_libnvpair= cddl/lib/libnvpair
1978 _cddl_lib_libavl= cddl/lib/libavl
1979 _cddl_lib_libuutil= cddl/lib/libuutil
1980 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1981 _cddl_lib_libctf= cddl/lib/libctf
1983 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1984 cddl/lib/libzfs__L: lib/libgeom__L
1985 cddl/lib/libctf__L: lib/libz__L
1987 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
1988 # on select architectures though (see cddl/lib/Makefile)
1989 .if ${MACHINE_CPUARCH} != "sparc64"
1990 _prebuild_libs+= lib/libproc lib/librtld_db
1993 .if ${MK_CRYPT} != "no"
1994 .if ${MK_OPENSSL} != "no"
1995 _secure_lib_libcrypto= secure/lib/libcrypto
1996 _secure_lib_libssl= secure/lib/libssl
1997 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1998 .if ${MK_LDNS} != "no"
1999 _lib_libldns= lib/libldns
2000 lib/libldns__L: secure/lib/libcrypto__L
2002 .if ${MK_OPENSSH} != "no"
2003 _secure_lib_libssh= secure/lib/libssh
2004 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2005 .if ${MK_LDNS} != "no"
2006 secure/lib/libssh__L: lib/libldns__L
2008 .if ${MK_KERBEROS_SUPPORT} != "no"
2009 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2010 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2011 lib/libmd__L kerberos5/lib/libroken__L
2015 _secure_lib= secure/lib
2018 .if ${MK_KERBEROS} != "no"
2019 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2020 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2021 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2022 kerberos5/lib/libwind__L lib/libsqlite3__L
2023 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2024 kerberos5/lib/libroken__L lib/libcom_err__L
2025 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2026 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2027 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2028 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2029 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2030 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2031 kerberos5/lib/libroken__L: lib/libcrypt__L
2032 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2033 kerberos5/lib/libheimbase__L: lib/libthr__L
2034 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2037 lib/libsqlite3__L: lib/libthr__L
2039 .if ${MK_GSSAPI} != "no"
2040 _lib_libgssapi= lib/libgssapi
2043 .if ${MK_KERBEROS} != "no"
2044 _kerberos5_lib= kerberos5/lib
2045 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2046 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2047 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2048 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2049 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2050 _kerberos5_lib_libroken= kerberos5/lib/libroken
2051 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2052 _libsqlite3= lib/libsqlite3
2053 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2054 _kerberos5_lib_libwind= kerberos5/lib/libwind
2055 _libcom_err= lib/libcom_err
2058 .if ${MK_NIS} != "no"
2059 _lib_libypclnt= lib/libypclnt
2062 .if ${MK_OPENSSL} == "no"
2063 lib/libradius__L: lib/libmd__L
2067 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2068 .if ${MK_CXX} != "no"
2069 .if ${MK_LIBCPLUSPLUS} != "no"
2070 lib/libproc__L: lib/libcxxrt__L
2071 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2072 lib/libproc__L: gnu/lib/libsupc++__L
2076 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2078 .for _lib in ${_prereq_libs}
2079 ${_lib}__PL: .PHONY .MAKE
2080 .if exists(${.CURDIR}/${_lib})
2081 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2082 cd ${.CURDIR}/${_lib}; \
2083 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2084 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2085 DIRPRFX=${_lib}/ all; \
2086 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2087 DIRPRFX=${_lib}/ install
2091 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
2092 ${_lib}__L: .PHONY .MAKE
2093 .if exists(${.CURDIR}/${_lib})
2094 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2095 cd ${.CURDIR}/${_lib}; \
2096 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2097 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2098 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2102 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2103 _startup_libs: ${_startup_libs:S/$/__L/}
2104 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2105 _generic_libs: ${_generic_libs:S/$/__L/}
2107 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2108 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2109 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2110 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2111 # parallel. This is safe for the world stage of buildworld though since it has
2112 # already built libraries in a proper order and installed includes into
2113 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2114 # avoid trashing a system if it crashes mid-install.
2115 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2119 .include <bsd.subdir.mk>
2121 .if make(check-old) || make(check-old-dirs) || \
2122 make(check-old-files) || make(check-old-libs) || \
2123 make(delete-old) || make(delete-old-dirs) || \
2124 make(delete-old-files) || make(delete-old-libs)
2127 # check for / delete old files section
2130 .include "ObsoleteFiles.inc"
2132 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2133 else you can not start such an application. Consult UPDATING for more \
2134 information regarding how to cope with the removal/revision bump of a \
2137 .if !defined(BATCH_DELETE_OLD_FILES)
2143 delete-old-files: .PHONY
2144 @echo ">>> Removing old files (only deletes safe to delete libs)"
2145 # Ask for every old file if the user really wants to remove it.
2146 # It's annoying, but better safe than sorry.
2147 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2148 # argument list will get too long. Using .for/.endfor make "loops" will make
2149 # the Makefile parser segfault.
2152 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2153 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2154 while read file; do \
2155 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2156 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2157 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2159 for ext in debug symbols; do \
2160 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2161 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2162 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2167 # Remove catpages without corresponding manpages.
2169 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2170 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2171 while read catpage; do \
2173 if [ ! -e "$${manpage}" ]; then \
2174 rm ${RM_I} $${catpage} <&3; \
2177 @echo ">>> Old files removed"
2179 check-old-files: .PHONY
2180 @echo ">>> Checking for old files"
2182 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2183 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2184 while read file; do \
2185 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2186 echo "${DESTDIR}/$${file}"; \
2188 for ext in debug symbols; do \
2189 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2190 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2194 # Check for catpages without corresponding manpages.
2195 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2196 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2197 while read catpage; do \
2199 if [ ! -e "$${manpage}" ]; then \
2204 delete-old-libs: .PHONY
2205 @echo ">>> Removing old libraries"
2206 @echo "${OLD_LIBS_MESSAGE}" | fmt
2209 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2210 -V OLD_LIBS | xargs -n1 | \
2211 while read file; do \
2212 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2213 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2214 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2216 for ext in debug symbols; do \
2217 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2218 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2219 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2224 @echo ">>> Old libraries removed"
2226 check-old-libs: .PHONY
2227 @echo ">>> Checking for old libraries"
2229 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2230 -V OLD_LIBS | xargs -n1 | \
2231 while read file; do \
2232 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2233 echo "${DESTDIR}/$${file}"; \
2235 for ext in debug symbols; do \
2236 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2237 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2242 delete-old-dirs: .PHONY
2243 @echo ">>> Removing old directories"
2245 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2246 -V OLD_DIRS | xargs -n1 | sort -r | \
2247 while read dir; do \
2248 if [ -d "${DESTDIR}/$${dir}" ]; then \
2249 rmdir -v "${DESTDIR}/$${dir}" || true; \
2250 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2251 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2254 @echo ">>> Old directories removed"
2256 check-old-dirs: .PHONY
2257 @echo ">>> Checking for old directories"
2259 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2260 -V OLD_DIRS | xargs -n1 | \
2261 while read dir; do \
2262 if [ -d "${DESTDIR}/$${dir}" ]; then \
2263 echo "${DESTDIR}/$${dir}"; \
2264 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2265 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2269 delete-old: delete-old-files delete-old-dirs .PHONY
2270 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2272 check-old: check-old-files check-old-libs check-old-dirs .PHONY
2273 @echo "To remove old files and directories run '${MAKE} delete-old'."
2274 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2279 # showconfig - show build configuration.
2282 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2283 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2285 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2286 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2288 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2289 .if exists(${KERNCONFDIR}/${KERNCONF})
2290 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2291 '${KERNCONFDIR}/${KERNCONF}' ; echo
2297 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2298 DTBOUTPUTPATH= ${.CURDIR}
2302 # Build 'standalone' Device Tree Blob
2305 @PATH=${TMPPATH} MACHINE=${TARGET} \
2306 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2307 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2312 # In the following, the first 'rm' in a series will usually remove all
2313 # files and directories. If it does not, then there are probably some
2314 # files with file flags set, so this unsets them and tries the 'rm' a
2315 # second time. There are situations where this target will be cleaning
2316 # some directories via more than one method, but that duplication is
2317 # needed to correctly handle all the possible situations. Removing all
2318 # files without file flags set in the first 'rm' instance saves time,
2319 # because 'chflags' will need to operate on fewer files afterwards.
2321 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2322 # created by bsd.obj.mk, except that we don't want to .include that file
2325 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2327 .if exists(${BW_CANONICALOBJDIR}/)
2328 -rm -rf ${BW_CANONICALOBJDIR}/*
2329 -chflags -R 0 ${BW_CANONICALOBJDIR}
2330 rm -rf ${BW_CANONICALOBJDIR}/*
2332 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2333 # To be safe in this case, fall back to a 'make cleandir'
2334 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2337 .if defined(TARGET) && defined(TARGET_ARCH)
2339 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2340 XDEV_CPUTYPE?=${CPUTYPE}
2342 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2345 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2346 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2347 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2348 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2349 CPUTYPE=${XDEV_CPUTYPE}
2351 XDDIR=${TARGET_ARCH}-freebsd
2354 .error XDTP variable should be an absolute path
2357 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2358 INSTALL="sh ${.CURDIR}/tools/install.sh"
2360 TOOLS_PREFIX=${XDTP}
2361 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2362 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2363 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2364 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2365 CPP="${CPP} ${CD2CFLAGS}" \
2366 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2368 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2369 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2370 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2371 XDDESTDIR=${DESTDIR}/${XDTP}
2373 OSREL!= uname -r | sed -e 's/[-(].*//'
2376 .ORDER: xdev-build xdev-install xdev-links
2377 xdev: xdev-build xdev-install .PHONY
2379 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2380 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
2382 _xb-worldtmp: .PHONY
2383 mkdir -p ${CDTMP}/usr
2384 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2385 -p ${CDTMP}/usr >/dev/null
2387 _xb-bootstrap-tools: .PHONY
2391 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2392 cd ${.CURDIR}/${_tool}; \
2393 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2394 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2395 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2398 _xb-build-tools: .PHONY
2399 ${_+_}@cd ${.CURDIR}; \
2400 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2402 _xb-cross-tools: .PHONY
2410 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2411 cd ${.CURDIR}/${_tool}; \
2412 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2413 ${CDMAKE} DIRPRFX=${_tool}/ all
2417 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2418 mkdir -p ${XDDESTDIR}
2419 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2420 -p ${XDDESTDIR} >/dev/null
2421 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2422 -p ${XDDESTDIR}/usr >/dev/null
2423 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2424 -p ${XDDESTDIR}/usr/include >/dev/null
2425 .if defined(LIBCOMPAT)
2426 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2427 -p ${XDDESTDIR}/usr >/dev/null
2429 .if ${MK_TESTS} != "no"
2430 mkdir -p ${XDDESTDIR}${TESTSBASE}
2431 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2432 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2435 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2436 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
2438 _xi-cross-tools: .PHONY
2439 @echo "_xi-cross-tools"
2447 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2448 cd ${.CURDIR}/${_tool}; \
2449 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2452 _xi-includes: .PHONY
2453 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2454 DESTDIR=${XDDESTDIR}
2456 _xi-libraries: .PHONY
2457 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2458 DESTDIR=${XDDESTDIR}
2461 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2462 mkdir -p ../../../../usr/bin; \
2464 ln -sf ../../${XDTP}/usr/bin/$$i \
2465 ../../../../usr/bin/${XDDIR}-$$i; \
2466 ln -sf ../../${XDTP}/usr/bin/$$i \
2467 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2470 xdev xdev-build xdev-install xdev-links: .PHONY
2471 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"