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,DEPEND,OBJ}
11 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
12 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
13 # -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
14 # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
15 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
16 # -DNO_ROOT install without using root privilege
17 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
18 # -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects
19 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
20 # LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list
21 # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
22 # LOCAL_MTREE="list of mtree files" to process to allow local directories
23 # to be created before files are installed
24 # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
26 # METALOG="path to metadata log" to write permission and ownership
27 # when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
28 # TARGET="machine" to crossbuild world for a different machine type
29 # TARGET_ARCH= may be required when a TARGET supports multiple endians
30 # BUILDENV_SHELL= shell to launch for the buildenv target (def:${SHELL})
31 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
32 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
33 # SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
34 # All libraries and includes, and some build tools will still build.
37 # The intended user-driven targets are:
38 # buildworld - rebuild *everything*, including glue to help do upgrades
39 # installworld- install everything built by "buildworld"
40 # checkworld - run test suite on installed world
41 # doxygen - build API documentation of the kernel
42 # update - convenient way to update your source tree (eg: svn/svnup)
44 # Standard targets (not defined here) are documented in the makefiles in
45 # /usr/share/mk. These include:
46 # obj depend all install clean cleandepend cleanobj
48 .if !defined(TARGET) || !defined(TARGET_ARCH)
49 .error "Both TARGET and TARGET_ARCH must be defined."
52 LOCALBASE?= /usr/local
54 # Cross toolchain changes must be in effect before bsd.compiler.mk
55 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
56 .if defined(CROSS_TOOLCHAIN)
57 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
58 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
60 .include <bsd.compiler.mk> # don't depend on src.opts.mk doing it
61 .include "share/mk/src.opts.mk"
63 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
64 # keep the users system reasonably usable. For static->dynamic root upgrades,
65 # we don't want to install a dynamic binary without rtld and the needed
66 # libraries. More commonly, for dynamic root, we don't want to install a
67 # binary that requires a newer library version that hasn't been installed yet.
68 # This ordering is not a guarantee though. The only guarantee of a working
69 # system here would require fine-grained ordering of all components based
70 # on their dependencies.
72 .if !empty(SUBDIR_OVERRIDE)
73 SUBDIR= ${SUBDIR_OVERRIDE}
76 .if !defined(NO_ROOT) && (make(installworld) || make(install))
77 # Ensure libraries are installed before progressing.
81 .if ${MK_CDDL} != "no"
85 .if ${MK_KERBEROS} != "no"
88 .if ${MK_RESCUE} != "no"
92 .if ${MK_CRYPT} != "no"
95 .if !defined(NO_SHARE)
98 SUBDIR+=sys usr.bin usr.sbin
99 .if ${MK_TESTS} != "no"
102 .if ${MK_OFED} != "no"
106 # Local directories are last, since it is nice to at least get the base
107 # system rebuilt before you do them.
108 .for _DIR in ${LOCAL_DIRS}
109 .if exists(${.CURDIR}/${_DIR}/Makefile)
113 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
114 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
115 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
116 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
117 _REDUNDENT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
119 .for _DIR in ${LOCAL_LIB_DIRS}
120 .if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
123 .warning ${_DIR} not added to SUBDIR list. See UPDATING 20141121.
127 # We must do etc/ last as it hooks into building the man whatis file
128 # by calling 'makedb' in share/man. This is only relevant for
129 # install/distribute so they build the whatis file after every manpage is
131 .if make(installworld) || make(install)
136 .endif # !empty(SUBDIR_OVERRIDE)
139 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
142 .if defined(NO_CLEANDIR)
143 CLEANDIR= clean cleandepend
148 # FAST_DEPEND can skip depend tree-walks.
149 .if ${MK_FAST_DEPEND} == "yes"
153 # Ensure shell checks later have a value.
154 .if defined(NO_DEPEND)
159 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
161 .if empty(SHELL:M*csh*)
162 BUILDENV_SHELL?=${SHELL}
164 BUILDENV_SHELL?=/bin/sh
167 SVN?= /usr/local/bin/svn
170 MAKEOBJDIRPREFIX?= /usr/obj
171 .if !defined(OSRELDATE)
172 .if exists(/usr/include/osreldate.h)
173 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
174 /usr/include/osreldate.h
181 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
182 .if !defined(VERSION)
183 REVISION!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V REVISION
184 BRANCH!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V BRANCH
185 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
186 ${SRCDIR}/sys/sys/param.h
187 VERSION= FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
191 .if !defined(PKG_VERSION)
192 REVISION!= ${MAKE} -C ${SRCDIR}/release -V REVISION
193 BRANCH!= ${MAKE} -C ${SRCDIR}/release -V BRANCH
194 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
195 ${SRCDIR}/sys/sys/param.h
196 .if ${BRANCH:MSTABLE*} || ${BRANCH:MCURRENT*}
197 TIMENOW= %Y%m%d%H%M%S
198 EXTRA_REVISION= .s${TIMENOW:gmtime}
201 EXTRA_REVISION= _${BRANCH:C/.*-p([0-9]+$)/\1/}
203 PKG_VERSION= ${REVISION}${EXTRA_REVISION}
206 KNOWN_ARCHES?= aarch64/arm64 \
225 .if ${TARGET} == ${TARGET_ARCH}
228 _t= ${TARGET_ARCH}/${TARGET}
231 .if empty(KNOWN_ARCHES:M${_t})
232 .error Unknown target ${TARGET_ARCH}:${TARGET}.
236 .if ${TARGET} == ${MACHINE}
237 TARGET_CPUTYPE?=${CPUTYPE}
242 .if !empty(TARGET_CPUTYPE)
243 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
245 _TARGET_CPUTYPE=dummy
247 _CPUTYPE!= MK_AUTO_OBJ=no MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
248 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
249 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
250 .error CPUTYPE global should be set with ?=.
253 BUILD_ARCH!= uname -p
254 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
255 .error To cross-build, set TARGET_ARCH.
258 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
259 OBJTREE= ${MAKEOBJDIRPREFIX}
261 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
263 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
264 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
265 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
266 STRICTTMPPATH= ${BPATH}:${XPATH}
267 TMPPATH= ${STRICTTMPPATH}:${PATH}
270 # Avoid running mktemp(1) unless actually needed.
271 # It may not be functional, e.g., due to new ABI
272 # when in the middle of installing over this system.
274 .if make(distributeworld) || make(installworld) || make(stageworld)
275 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
278 .if make(stagekernel) || make(distributekernel)
284 # Building a world goes through the following stages
286 # 1. legacy stage [BMAKE]
287 # This stage is responsible for creating compatibility
288 # shims that are needed by the bootstrap-tools,
289 # build-tools and cross-tools stages. These are generally
290 # APIs that tools from one of those three stages need to
291 # build that aren't present on the host.
292 # 1. bootstrap-tools stage [BMAKE]
293 # This stage is responsible for creating programs that
294 # are needed for backward compatibility reasons. They
295 # are not built as cross-tools.
296 # 2. build-tools stage [TMAKE]
297 # This stage is responsible for creating the object
298 # tree and building any tools that are needed during
299 # the build process. Some programs are listed during
300 # this phase because they build binaries to generate
301 # files needed to build these programs. This stage also
302 # builds the 'build-tools' target rather than 'all'.
303 # 3. cross-tools stage [XMAKE]
304 # This stage is responsible for creating any tools that
305 # are needed for building the system. A cross-compiler is one
306 # of them. This differs from build tools in two ways:
307 # 1. the 'all' target is built rather than 'build-tools'
308 # 2. these tools are installed into TMPPATH for stage 4.
309 # 4. world stage [WMAKE]
310 # This stage actually builds the world.
311 # 5. install stage (optional) [IMAKE]
312 # This stage installs a previously built world.
317 # Common environment for world related stages
318 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
319 MACHINE_ARCH=${TARGET_ARCH} \
321 CPUTYPE=${TARGET_CPUTYPE}
322 .if ${MK_GROFF} != "no"
323 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
324 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
325 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
327 .if defined(TARGET_CFLAGS)
328 CROSSENV+= ${TARGET_CFLAGS}
331 # bootstrap-tools stage
332 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
333 PATH=${BPATH}:${PATH} \
334 WORLDTMP=${WORLDTMP} \
335 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
336 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
338 BOOTSTRAPPING=${OSRELDATE} \
340 MK_HTML=no NO_LINT=yes MK_MAN=no \
341 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
342 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
343 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
344 MK_LLDB=no MK_TESTS=no \
347 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
348 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
352 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
353 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
354 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
356 BOOTSTRAPPING=${OSRELDATE} \
359 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
360 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
361 MK_LLDB=no MK_TESTS=no
364 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
365 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
366 MK_GDB=no MK_TESTS=no
369 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
370 PATH=${BPATH}:${PATH} \
372 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
373 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
375 BOOTSTRAPPING=${OSRELDATE} \
377 MK_HTML=no -DNO_LINT MK_MAN=no \
378 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
379 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
382 WMAKEENV= ${CROSSENV} \
384 INSTALL="sh ${.CURDIR}/tools/install.sh" \
388 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
390 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
393 .if defined(CROSS_TOOLCHAIN_PREFIX)
394 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
395 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
398 # If we do not have a bootstrap binutils (because the in-tree one does not
399 # support the target architecture), provide a default cross-binutils prefix.
400 # This allows aarch64 builds, for example, to automatically use the
401 # aarch64-binutils port or package.
402 .if !make(showconfig)
403 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
404 !defined(CROSS_BINUTILS_PREFIX)
405 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
406 .if !exists(${CROSS_BINUTILS_PREFIX})
407 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
412 XCOMPILERS= CC CXX CPP
413 .for COMPILER in ${XCOMPILERS}
414 .if defined(CROSS_COMPILER_PREFIX)
415 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
417 X${COMPILER}?= ${${COMPILER}}
420 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
421 .for BINUTIL in ${XBINUTILS}
422 .if defined(CROSS_BINUTILS_PREFIX) && \
423 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
424 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
426 X${BINUTIL}?= ${${BINUTIL}}
429 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
430 DEPFLAGS="${DEPFLAGS}" \
431 CPP="${XCPP} ${XCFLAGS}" \
432 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
433 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
434 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
437 .if ${XCC:N${CCACHE_BIN}:M/*}
438 .if defined(CROSS_BINUTILS_PREFIX)
439 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
440 # directory, but the compiler will look in the right place for it's
441 # tools so we don't need to tell it where to look.
442 .if exists(${CROSS_BINUTILS_PREFIX})
443 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
446 BFLAGS+= -B${WORLDTMP}/usr/bin
448 .if ${TARGET} == "arm"
449 .if ${TARGET_ARCH:M*hf*} != ""
450 TARGET_ABI= gnueabihf
455 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
456 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
457 XCXXFLAGS+= -I${WORLDTMP}/usr/include/c++/v1 -std=gnu++11 -L${WORLDTMP}/../lib/libc++
458 # XXX: DEPFLAGS is a workaround for not properly passing CXXFLAGS to sub-makes
459 # due to CXX="${XCXX} ${XCXXFLAGS}". bsd.dep.mk does use CXXFLAGS when
460 # building C++ files so this can come out if passing CXXFLAGS down is fixed.
461 DEPFLAGS+= -I${WORLDTMP}/usr/include/c++/v1
464 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
465 XCFLAGS+= -target ${TARGET_TRIPLE}
467 XCFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
468 XCXXFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
470 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
471 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
473 XCXXFLAGS+= ${BFLAGS}
477 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
478 ${TARGET_ARCH} == "powerpc64")
480 .include "Makefile.libcompat"
481 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH} == "armv6"
483 .include "Makefile.libcompat"
486 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
488 IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*}
489 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
490 ${IMAKE_INSTALL} ${IMAKE_MTREE}
491 .if empty(.MAKEFLAGS:M-n)
492 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
493 LD_LIBRARY_PATH=${INSTALLTMP} \
494 PATH_LOCALE=${INSTALLTMP}/locale
495 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
497 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
499 .if defined(DB_FROM_SRC)
500 INSTALLFLAGS+= -N ${.CURDIR}/etc
501 MTREEFLAGS+= -N ${.CURDIR}/etc
503 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
504 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
506 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
507 IMAKE+= -DNO_ROOT METALOG=${METALOG}
508 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
511 .if defined(BUILD_PKGS)
512 INSTALLFLAGS+= -h sha256
514 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
515 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
516 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
520 KMAKEENV= ${WMAKEENV}
521 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
526 # Attempt to rebuild the entire system, with reasonable chance of
527 # success, regardless of how old your existing system is.
530 .if ${.CURDIR:C/[^,]//g} != ""
531 # The m4 build of sendmail files doesn't like it if ',' is used
532 # anywhere in the path of it's files.
534 @echo "*** Error: path to source tree contains a comma ','"
539 @echo "--------------------------------------------------------------"
540 @echo ">>> Rebuilding the temporary build tree"
541 @echo "--------------------------------------------------------------"
542 .if !defined(NO_CLEAN)
544 .if defined(LIBCOMPAT)
545 rm -rf ${LIBCOMPATTMP}
548 rm -rf ${WORLDTMP}/legacy/usr/include
549 # XXX - These can depend on any header file.
550 rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c
551 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
554 lib lib/casper usr legacy/bin legacy/usr
555 mkdir -p ${WORLDTMP}/${_dir}
557 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
558 -p ${WORLDTMP}/legacy/usr >/dev/null
559 .if ${MK_GROFF} != "no"
560 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
561 -p ${WORLDTMP}/legacy/usr >/dev/null
563 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
564 -p ${WORLDTMP}/usr >/dev/null
565 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
566 -p ${WORLDTMP}/usr/include >/dev/null
567 ln -sf ${.CURDIR}/sys ${WORLDTMP}
568 .if ${MK_DEBUG_FILES} != "no"
569 # We could instead disable debug files for these build stages
570 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
571 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
572 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
573 -p ${WORLDTMP}/usr/lib >/dev/null
575 .if defined(LIBCOMPAT)
576 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
577 -p ${WORLDTMP}/usr >/dev/null
578 .if ${MK_DEBUG_FILES} != "no"
579 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
580 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
581 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
582 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
585 .if ${MK_TESTS} != "no"
586 mkdir -p ${WORLDTMP}${TESTSBASE}
587 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
588 -p ${WORLDTMP}${TESTSBASE} >/dev/null
589 .if ${MK_DEBUG_FILES} != "no"
590 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
591 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
592 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
595 .for _mtree in ${LOCAL_MTREE}
596 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
600 @echo "--------------------------------------------------------------"
601 @echo ">>> stage 1.1: legacy release compatibility shims"
602 @echo "--------------------------------------------------------------"
603 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
606 @echo "--------------------------------------------------------------"
607 @echo ">>> stage 1.2: bootstrap tools"
608 @echo "--------------------------------------------------------------"
609 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
611 .if !defined(NO_CLEAN)
613 @echo "--------------------------------------------------------------"
614 @echo ">>> stage 2.1: cleaning up the object tree"
615 @echo "--------------------------------------------------------------"
616 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
617 .if defined(LIBCOMPAT)
618 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
623 @echo "--------------------------------------------------------------"
624 @echo ">>> stage 2.2: rebuilding the object tree"
625 @echo "--------------------------------------------------------------"
626 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
629 @echo "--------------------------------------------------------------"
630 @echo ">>> stage 2.3: build tools"
631 @echo "--------------------------------------------------------------"
632 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
635 @echo "--------------------------------------------------------------"
636 @echo ">>> stage 3: cross tools"
637 @echo "--------------------------------------------------------------"
638 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
639 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
642 @echo "--------------------------------------------------------------"
643 @echo ">>> stage 4.1: building includes"
644 @echo "--------------------------------------------------------------"
645 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
646 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
647 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
649 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
650 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks includes
654 @echo "--------------------------------------------------------------"
655 @echo ">>> stage 4.2: building libraries"
656 @echo "--------------------------------------------------------------"
657 ${_+_}cd ${.CURDIR}; \
658 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
659 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
662 @echo "--------------------------------------------------------------"
663 @echo ">>> stage 4.3: make dependencies"
664 @echo "--------------------------------------------------------------"
665 ${_+_}cd ${.CURDIR}; ${WMAKE} depend
668 @echo "--------------------------------------------------------------"
669 @echo ">>> stage 4.4: building everything"
670 @echo "--------------------------------------------------------------"
671 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
674 WMAKE_TGTS+= _worldtmp _legacy
675 .if empty(SUBDIR_OVERRIDE)
676 WMAKE_TGTS+= _bootstrap-tools
678 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
679 WMAKE_TGTS+= _includes _libraries
680 .if !defined(NO_DEPEND)
683 WMAKE_TGTS+= everything
684 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
685 WMAKE_TGTS+= build${libcompat}
688 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
689 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
692 @echo "--------------------------------------------------------------"
693 @echo ">>> World build started on `LC_ALL=C date`"
694 @echo "--------------------------------------------------------------"
698 @echo "--------------------------------------------------------------"
699 @echo ">>> World build completed on `LC_ALL=C date`"
700 @echo "--------------------------------------------------------------"
703 # We need to have this as a target because the indirection between Makefile
704 # and Makefile.inc1 causes the correct PATH to be used, rather than a
705 # modification of the current environment's PATH. In addition, we need
706 # to quote multiword values.
709 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
711 .if ${.TARGETS:Mbuildenv}
712 .if ${.MAKEFLAGS:M-j}
713 .error The buildenv target is incompatible with -j
716 BUILDENV_DIR?= ${.CURDIR}
718 @echo Entering world for ${TARGET_ARCH}:${TARGET}
719 .if ${BUILDENV_SHELL:M*zsh*}
720 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
722 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
725 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild${libcompat}}
726 toolchain: ${TOOLCHAIN_TGTS}
727 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
732 # Checks to be sure system is ready for installworld/installkernel.
734 installcheck: _installcheck_world _installcheck_kernel
736 _installcheck_kernel:
739 # Require DESTDIR to be set if installing for a different architecture or
740 # using the user/group database in the source tree.
742 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
744 .if !make(distributeworld)
745 _installcheck_world: __installcheck_DESTDIR
746 _installcheck_kernel: __installcheck_DESTDIR
747 __installcheck_DESTDIR:
748 .if !defined(DESTDIR) || empty(DESTDIR)
749 @echo "ERROR: Please set DESTDIR!"; \
755 .if !defined(DB_FROM_SRC)
757 # Check for missing UIDs/GIDs.
759 CHECK_UIDS= auditdistd
761 .if ${MK_SENDMAIL} != "no"
767 CHECK_GIDS+= proxy authpf
769 .if ${MK_UNBOUND} != "no"
773 _installcheck_world: __installcheck_UGID
775 .for uid in ${CHECK_UIDS}
776 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
777 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
781 .for gid in ${CHECK_GIDS}
782 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
783 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
790 # Required install tools to be saved in a scratch dir for safety.
792 .if ${MK_ZONEINFO} != "no"
793 _zoneinfo= zic tzsetup
796 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
797 date echo egrep find grep id install ${_install-info} \
798 ln make mkdir mtree mv pwd_mkdb \
799 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
802 # Needed for share/man
803 .if ${MK_MAN} != "no"
810 # Distributes everything compiled by a `buildworld'.
814 # Installs everything compiled by a 'buildworld'.
817 # Non-base distributions produced by the base system
818 EXTRA_DISTRIBUTIONS= doc
819 .if defined(LIBCOMPAT)
820 EXTRA_DISTRIBUTIONS+= lib${libcompat}
822 .if ${MK_TESTS} != "no"
823 EXTRA_DISTRIBUTIONS+= tests
827 .if ${MK_DEBUG_FILES} != "no"
828 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
831 MTREE_MAGIC?= mtree 2.0
833 distributeworld installworld stageworld: _installcheck_world
834 mkdir -p ${INSTALLTMP}
835 progs=$$(for prog in ${ITOOLS}; do \
836 if progpath=`which $$prog`; then \
839 echo "Required tool $$prog not found in PATH." >&2; \
843 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
844 while read line; do \
846 if [ "$$2 $$3" != "not found" ]; then \
849 echo "Required library $$1 not found." >&2; \
853 cp $$libs $$progs ${INSTALLTMP}
854 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
856 -mkdir -p ${METALOG:H}
857 echo "#${MTREE_MAGIC}" > ${METALOG}
859 .if make(distributeworld)
860 .for dist in ${EXTRA_DISTRIBUTIONS}
861 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
862 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
863 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
864 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
865 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
866 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
867 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
868 .if ${MK_DEBUG_FILES} != "no"
869 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
870 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
872 .if defined(LIBCOMPAT)
873 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
874 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
875 .if ${MK_DEBUG_FILES} != "no"
876 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
877 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
880 .if ${MK_TESTS} != "no" && ${dist} == "tests"
881 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
882 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
883 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
884 .if ${MK_DEBUG_FILES} != "no"
885 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
886 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
890 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
891 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
892 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
893 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
894 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
895 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
896 .if defined(LIBCOMPAT)
897 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
898 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
902 -mkdir ${DESTDIR}/${DISTDIR}/base
903 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
904 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
905 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
906 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
908 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
909 ${IMAKEENV} rm -rf ${INSTALLTMP}
910 .if make(distributeworld)
911 .for dist in ${EXTRA_DISTRIBUTIONS}
912 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
915 .for dist in base ${EXTRA_DISTRIBUTIONS}
916 @# For each file that exists in this dist, print the corresponding
917 @# line from the METALOG. This relies on the fact that
918 @# a line containing only the filename will sort immediatly before
919 @# the relevant mtree line.
920 cd ${DESTDIR}/${DISTDIR}; \
921 find ./${dist} | sort -u ${METALOG} - | \
922 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
923 ${DESTDIR}/${DISTDIR}/${dist}.meta
925 .for dist in ${DEBUG_DISTRIBUTIONS}
926 @# For each file that exists in this dist, print the corresponding
927 @# line from the METALOG. This relies on the fact that
928 @# a line containing only the filename will sort immediatly before
929 @# the relevant mtree line.
930 cd ${DESTDIR}/${DISTDIR}; \
931 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
932 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
933 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
939 .for dist in base ${EXTRA_DISTRIBUTIONS}
941 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
942 tar cvf - --exclude usr/lib/debug \
943 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
944 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
946 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
947 tar cvf - --exclude usr/lib/debug . | \
948 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
952 .for dist in ${DEBUG_DISTRIBUTIONS}
953 . if defined(NO_ROOT)
954 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
955 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
956 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
958 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
959 tar cvLf - usr/lib/debug | \
960 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
967 # If you have a build server, you can NFS mount the source and obj directories
968 # and do a 'make reinstall' on the *client* to install new binaries from the
969 # most recent server build.
971 reinstall: .MAKE .PHONY
972 @echo "--------------------------------------------------------------"
973 @echo ">>> Making hierarchy"
974 @echo "--------------------------------------------------------------"
975 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
976 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
978 @echo "--------------------------------------------------------------"
979 @echo ">>> Installing everything"
980 @echo "--------------------------------------------------------------"
981 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
982 .if defined(LIBCOMPAT)
983 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
986 restage: .MAKE .PHONY
987 @echo "--------------------------------------------------------------"
988 @echo ">>> Making hierarchy"
989 @echo "--------------------------------------------------------------"
990 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
991 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy distribution
993 @echo "--------------------------------------------------------------"
994 @echo ">>> Installing everything"
995 @echo "--------------------------------------------------------------"
996 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
997 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
998 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
1001 redistribute: .MAKE .PHONY
1002 @echo "--------------------------------------------------------------"
1003 @echo ">>> Distributing everything"
1004 @echo "--------------------------------------------------------------"
1005 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1006 .if defined(LIBCOMPAT)
1007 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1008 DISTRIBUTION=lib${libcompat}
1011 distrib-dirs distribution: .MAKE .PHONY
1012 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1013 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1014 .if make(distribution)
1015 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1016 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1017 METALOG=${METALOG} MK_TESTS=no installconfig
1021 # buildkernel and installkernel
1023 # Which kernels to build and/or install is specified by setting
1024 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1025 # Only the existing (depending TARGET) config files are used
1026 # for building kernels and only the first of these is designated
1027 # as the one being installed.
1029 # Note that we have to use TARGET instead of TARGET_ARCH when
1030 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1031 # be set to cross-build, we have to make sure TARGET is set
1034 .if defined(KERNFAST)
1039 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1040 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1041 KERNCONF=${KERNFAST}
1044 .if ${TARGET_ARCH} == "powerpc64"
1045 KERNCONF?= GENERIC64
1049 INSTKERNNAME?= kernel
1051 KERNSRCDIR?= ${.CURDIR}/sys
1052 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1053 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1054 KERNCONFDIR?= ${KRNLCONFDIR}
1058 .if defined(NO_INSTALLKERNEL)
1059 # All of the BUILDKERNELS loops start at index 1.
1060 BUILDKERNELS+= dummy
1062 .for _kernel in ${KERNCONF}
1063 .if exists(${KERNCONFDIR}/${_kernel})
1064 BUILDKERNELS+= ${_kernel}
1065 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1066 INSTALLKERNEL= ${_kernel}
1071 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1076 # Builds all kernels defined by BUILDKERNELS.
1078 buildkernel: .MAKE .PHONY
1079 .if empty(BUILDKERNELS:Ndummy)
1080 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1084 .for _kernel in ${BUILDKERNELS:Ndummy}
1085 @echo "--------------------------------------------------------------"
1086 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1087 @echo "--------------------------------------------------------------"
1088 @echo "===> ${_kernel}"
1089 mkdir -p ${KRNLOBJDIR}
1090 .if !defined(NO_KERNELCONFIG)
1092 @echo "--------------------------------------------------------------"
1093 @echo ">>> stage 1: configuring the kernel"
1094 @echo "--------------------------------------------------------------"
1095 cd ${KRNLCONFDIR}; \
1097 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1098 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1100 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1102 @echo "--------------------------------------------------------------"
1103 @echo ">>> stage 2.1: cleaning up the object tree"
1104 @echo "--------------------------------------------------------------"
1105 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1107 .if !defined(NO_KERNELOBJ)
1109 @echo "--------------------------------------------------------------"
1110 @echo ">>> stage 2.2: rebuilding the object tree"
1111 @echo "--------------------------------------------------------------"
1112 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1115 @echo "--------------------------------------------------------------"
1116 @echo ">>> stage 2.3: build tools"
1117 @echo "--------------------------------------------------------------"
1118 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1119 .if !defined(NO_KERNELDEPEND)
1121 @echo "--------------------------------------------------------------"
1122 @echo ">>> stage 3.1: making dependencies"
1123 @echo "--------------------------------------------------------------"
1124 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
1127 @echo "--------------------------------------------------------------"
1128 @echo ">>> stage 3.2: building everything"
1129 @echo "--------------------------------------------------------------"
1130 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1131 @echo "--------------------------------------------------------------"
1132 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1133 @echo "--------------------------------------------------------------"
1137 # installkernel, etc.
1139 # Install the kernel defined by INSTALLKERNEL
1141 installkernel installkernel.debug \
1142 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1143 .if !defined(NO_INSTALLKERNEL)
1144 .if empty(INSTALLKERNEL)
1145 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1148 @echo "--------------------------------------------------------------"
1149 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1150 @echo "--------------------------------------------------------------"
1151 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1152 ${CROSSENV} PATH=${TMPPATH} \
1153 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1155 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1156 .for _kernel in ${BUILDKERNELS:[2..-1]}
1157 @echo "--------------------------------------------------------------"
1158 @echo ">>> Installing kernel ${_kernel}"
1159 @echo "--------------------------------------------------------------"
1160 cd ${KRNLOBJDIR}/${_kernel}; \
1161 ${CROSSENV} PATH=${TMPPATH} \
1162 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1166 distributekernel distributekernel.debug:
1167 .if !defined(NO_INSTALLKERNEL)
1168 .if empty(INSTALLKERNEL)
1169 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1172 mkdir -p ${DESTDIR}/${DISTDIR}
1173 .if defined(NO_ROOT)
1174 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1176 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1177 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1178 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1179 DESTDIR=${INSTALL_DDIR}/kernel \
1180 ${.TARGET:S/distributekernel/install/}
1181 .if defined(NO_ROOT)
1182 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1183 ${DESTDIR}/${DISTDIR}/kernel.meta
1186 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1187 .for _kernel in ${BUILDKERNELS:[2..-1]}
1188 .if defined(NO_ROOT)
1189 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1191 cd ${KRNLOBJDIR}/${_kernel}; \
1192 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1193 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1194 KERNEL=${INSTKERNNAME}.${_kernel} \
1195 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1196 ${.TARGET:S/distributekernel/install/}
1197 .if defined(NO_ROOT)
1198 @sed -e "s|^./kernel.${_kernel}|.|" \
1199 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1200 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1206 .if defined(NO_ROOT)
1207 .if !defined(NO_INSTALLKERNEL)
1208 cd ${DESTDIR}/${DISTDIR}/kernel; \
1209 tar cvf - --exclude '*.debug' \
1210 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1211 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1213 cd ${DESTDIR}/${DISTDIR}/kernel; \
1214 tar cvf - --include '*/*/*.debug' \
1215 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1216 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1217 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1218 .for _kernel in ${BUILDKERNELS:[2..-1]}
1219 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1220 tar cvf - --exclude '*.debug' \
1221 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1222 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1223 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1224 tar cvf - --include '*/*/*.debug' \
1225 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1226 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1230 .if !defined(NO_INSTALLKERNEL)
1231 cd ${DESTDIR}/${DISTDIR}/kernel; \
1232 tar cvf - --exclude '*.debug' . | \
1233 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1235 cd ${DESTDIR}/${DISTDIR}/kernel; \
1236 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1237 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1238 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1239 .for _kernel in ${BUILDKERNELS:[2..-1]}
1240 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1241 tar cvf - --exclude '*.debug' . | \
1242 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1243 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1244 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1245 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1251 ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1253 PORTSDIR?= /usr/ports
1254 WSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/worldstage
1255 KSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/kernelstage
1256 REPODIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/repo
1257 PKGSIGNKEY?= # empty
1260 .if !exists(${LOCALBASE}/sbin/pkg)
1261 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1265 ${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1268 rm -rf /tmp/ports.${TARGET} || :
1269 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${REVISION} \
1270 PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} WSTAGEDIR=${WSTAGEDIR} \
1271 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1273 real-packages: stage-packages create-packages sign-packages
1276 @mkdir -p ${WSTAGEDIR} ${KSTAGEDIR}
1277 ${_+_}@cd ${.CURDIR}; \
1278 ${MAKE} DESTDIR=${DESTDIR:U${WSTAGEDIR}} -DNO_ROOT -B stageworld ; \
1279 ${MAKE} DESTDIR=${DESTDIR:U${KSTAGEDIR}} -DNO_ROOT -B stagekernel
1281 create-packages: _pkgbootstrap
1282 @mkdir -p ${REPODIR}
1283 ${_+_}@cd ${.CURDIR}; \
1284 ${MAKE} DESTDIR=${DESTDIR:U${WSTAGEDIR}} \
1285 PKG_VERSION=${PKG_VERSION} create-world-packages ; \
1286 ${MAKE} DESTDIR=${DESTDIR:U${KSTAGEDIR}} \
1287 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1288 create-kernel-packages
1290 create-world-packages: _pkgbootstrap
1291 @rm -f ${DESTDIR}/*.plist 2>/dev/null || :
1293 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1295 @for plist in ${DESTDIR}/*.plist; do \
1296 plist=$${plist##*/} ; \
1297 pkgname=$${plist%.plist} ; \
1298 sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \
1299 -s ${SRCDIR} -u ${DESTDIR}/$${pkgname}.ucl ; \
1301 @for plist in ${DESTDIR}/*.plist; do \
1302 plist=$${plist##*/} ; \
1303 pkgname=$${plist%.plist} ; \
1305 /^name/ { printf("===> Creating %s-", $$2); next } \
1306 /^version/ { print $$2; next } \
1307 ' ${DESTDIR}/$${pkgname}.ucl ; \
1308 pkg -o ABI_FILE=${DESTDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1309 create -M ${DESTDIR}/$${pkgname}.ucl \
1310 -p ${DESTDIR}/$${pkgname}.plist \
1312 -o ${REPODIR}/$$(pkg -o ABI_FILE=${DESTDIR}/bin/sh config ABI)/${PKG_VERSION} ; \
1315 create-kernel-packages: _pkgbootstrap
1316 .if exists(${DESTDIR}/kernel.meta)
1317 .for flavor in "" -debug
1318 @cd ${DESTDIR}/${DISTDIR} ; \
1319 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1320 -v kernel=yes -v _kernconf=${INSTALLKERNEL} \
1321 ${DESTDIR}/kernel.meta ; \
1322 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1323 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1324 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1325 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1326 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1327 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1328 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1329 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1330 ${SRCDIR}/release/packages/kernel.ucl \
1331 > ${DESTDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1333 /name/ { printf("===> Creating %s-", $$2); next } \
1334 /version/ {print $$2; next } ' \
1335 ${DESTDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1336 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1337 create -M ${DESTDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1338 -p ${DESTDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1339 -r ${DESTDIR}/${DISTDIR} \
1340 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1343 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1344 .for _kernel in ${BUILDKERNELS:[2..-1]}
1345 .if exists(${DESTDIR}/kernel.${_kernel}.meta)
1346 .for flavor in "" -debug
1347 @cd ${DESTDIR}/kernel.${_kernel} ; \
1348 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1349 -v kernel=yes -v _kernconf=${_kernel} \
1350 ${DESTDIR}/kernel.${_kernel}.meta ; \
1351 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1352 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1353 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1354 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1355 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1356 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1357 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1358 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1359 ${SRCDIR}/release/packages/kernel.ucl \
1360 > ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1362 /name/ { printf("===> Creating %s-", $$2); next } \
1363 /version/ {print $$2; next } ' \
1364 ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1365 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1366 create -M ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1367 -p ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1368 -r ${DESTDIR}/kernel.${_kernel} \
1369 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1375 sign-packages: _pkgbootstrap
1376 @[ -L "${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1377 unlink ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1378 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1379 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1380 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1382 ln -s ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1383 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest
1389 # Run test suite on installed world.
1392 @if [ ! -x ${LOCALBASE}/bin/kyua ]; then \
1393 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1396 ${_+_}${LOCALBASE}/bin/kyua test -k ${TESTSBASE}/Kyuafile
1402 # Build the API documentation with doxygen
1405 @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1406 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1409 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1414 # Update the source tree(s), by running svn/svnup to update to the
1418 .if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1419 @echo "--------------------------------------------------------------"
1420 @echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1421 @echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1422 @echo "--------------------------------------------------------------"
1425 .if defined(SVN_UPDATE)
1426 @echo "--------------------------------------------------------------"
1427 @echo ">>> Updating ${.CURDIR} using Subversion"
1428 @echo "--------------------------------------------------------------"
1429 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1433 # ------------------------------------------------------------------------
1435 # From here onwards are utility targets used by the 'make world' and
1436 # related targets. If your 'world' breaks, you may like to try to fix
1437 # the problem and manually run the following targets to attempt to
1438 # complete the build. Beware, this is *not* guaranteed to work, you
1439 # need to have a pretty good grip on the current state of the system
1440 # to attempt to manually finish it. If in doubt, 'make world' again.
1444 # legacy: Build compatibility shims for the next three targets. This is a
1445 # minimal set of tools and shims necessary to compensate for older systems
1446 # which don't have the APIs required by the targets built in bootstrap-tools,
1447 # build-tools or cross-tools.
1450 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1451 # r296685 fix cross-endian objcopy
1452 .if ${BOOTSTRAPPING} < 1100102
1453 _elftoolchain_libs= lib/libelf lib/libdwarf
1457 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1458 @echo "ERROR: Source upgrades from versions prior to 8.0 are not supported."; \
1461 .for _tool in tools/build ${_elftoolchain_libs}
1462 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1463 cd ${.CURDIR}/${_tool}; \
1464 ${MAKE} DIRPRFX=${_tool}/ obj; \
1465 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1466 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1467 ${MAKE} DIRPRFX=${_tool}/ all; \
1468 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1472 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1473 # are built to build other binaries in the system. However, the focus of these
1474 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1475 # libraries, augmented by -legacy.
1477 _bt= _bootstrap-tools
1479 .if ${MK_GAMES} != "no"
1480 _strfile= usr.bin/fortune/strfile
1483 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1484 _gperf= gnu/usr.bin/gperf
1487 .if ${MK_GROFF} != "no"
1488 _groff= gnu/usr.bin/groff \
1492 .if ${MK_VT} != "no"
1493 _vtfontcvt= usr.bin/vtfontcvt
1496 .if ${BOOTSTRAPPING} < 900002
1500 .if ${BOOTSTRAPPING} < 1000033
1501 _libopenbsd= lib/libopenbsd
1505 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1506 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1509 .if ${BOOTSTRAPPING} < 1000026
1510 _nmtree= lib/libnetbsd \
1513 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1516 .if ${BOOTSTRAPPING} < 1000027
1520 # r264059 support for status=
1521 .if ${BOOTSTRAPPING} < 1100017
1525 # r277259 crunchide: Correct 64-bit section header offset
1526 # r281674 crunchide: always include both 32- and 64-bit ELF support
1527 # r285986 crunchen: use STRIPBIN rather than STRIP
1528 .if ${BOOTSTRAPPING} < 1100078
1529 _crunch= usr.sbin/crunch
1532 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1539 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1541 .if ${MK_BSNMP} != "no"
1542 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1545 # We need to build tblgen when we're building clang either as
1546 # the bootstrap compiler, or as the part of the normal build.
1547 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1549 lib/clang/libllvmsupport \
1550 lib/clang/libllvmtablegen \
1551 usr.bin/clang/llvm-tblgen \
1552 usr.bin/clang/clang-tblgen
1554 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1555 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1558 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1561 .if ${MK_GPL_DTC} != "no"
1562 _dtc= gnu/usr.bin/dtc
1565 .if ${MK_KERBEROS} != "no"
1566 _kerberos5_bootstrap_tools= \
1567 kerberos5/tools/make-roken \
1568 kerberos5/lib/libroken \
1569 kerberos5/lib/libvers \
1570 kerberos5/tools/asn1_compile \
1571 kerberos5/tools/slc \
1574 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1577 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
1578 .if ${MK_MANDOCDB} != "no" && ${BOOTSTRAPPING} < 1100075
1579 _libopenbsd?= lib/libopenbsd
1580 _makewhatis= lib/libsqlite3 \
1582 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1585 bootstrap-tools: .PHONY
1587 # Please document (add comment) why something is in 'bootstrap-tools'.
1588 # Try to bound the building of the bootstrap-tool to just the
1589 # FreeBSD versions that need the tool built at this stage of the build.
1592 ${_kerberos5_bootstrap_tools} \
1615 ${_bt}-${_tool}: .PHONY .MAKE
1616 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1617 cd ${.CURDIR}/${_tool}; \
1618 ${MAKE} DIRPRFX=${_tool}/ obj; \
1619 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1620 ${MAKE} DIRPRFX=${_tool}/ all; \
1621 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1623 bootstrap-tools: ${_bt}-${_tool}
1627 # build-tools: Build special purpose build tools
1629 .if !defined(NO_SHARE)
1630 _share= share/syscons/scrnmaps
1633 .if ${MK_GCC} != "no"
1634 _gcc_tools= gnu/usr.bin/cc/cc_tools
1637 .if ${MK_RESCUE} != "no"
1638 # rescue includes programs that have build-tools targets
1639 _rescue=rescue/rescue
1645 ${LOCAL_TOOL_DIRS} \
1646 lib/ncurses/ncurses \
1647 lib/ncurses/ncursesw \
1652 usr.bin/mkesdb_static \
1653 usr.bin/mkcsmapper_static \
1655 build-tools_${_tool}: .PHONY
1656 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1657 cd ${.CURDIR}/${_tool}; \
1658 ${MAKE} DIRPRFX=${_tool}/ obj; \
1659 ${MAKE} DIRPRFX=${_tool}/ build-tools
1660 build-tools: build-tools_${_tool}
1664 build-tools_${_tool}: .PHONY
1665 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1666 cd ${.CURDIR}/${_tool}; \
1667 ${MAKE} DIRPRFX=${_tool}/ obj; \
1668 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1669 ${MAKE} DIRPRFX=${_tool}/ all
1670 build-tools: build-tools_${_tool}
1674 # kernel-tools: Build kernel-building tools
1677 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1678 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1679 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1682 # cross-tools: All the tools needed to build the rest of the system after
1683 # we get done with the earlier stages. It is the last set of tools needed
1684 # to begin building the target binaries.
1686 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1687 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1688 _btxld= usr.sbin/btxld
1692 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1693 # resulting from missing bug fixes or ELF Toolchain updates.
1694 .if ${MK_CDDL} != "no"
1695 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1696 cddl/usr.bin/ctfmerge
1699 # If we're given an XAS, don't build binutils.
1700 .if ${XAS:M/*} == ""
1701 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1702 _binutils= gnu/usr.bin/binutils
1704 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1705 _elftctools= lib/libelftc \
1711 # These are not required by the build, but can be useful for developers who
1712 # cross-build on a FreeBSD 10 host:
1713 _elftctools+= usr.bin/addr2line
1715 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1716 # If cross-building with an external binutils we still need to build strip for
1717 # the target (for at least crunchide).
1718 _elftctools= lib/libelftc \
1723 # If an full path to an external cross compiler is given, don't build
1725 .if ${XCC:N${CCACHE_BIN}:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1726 .if ${MK_CLANG_BOOTSTRAP} != "no"
1727 _clang= usr.bin/clang
1728 _clang_libs= lib/clang
1730 .if ${MK_GCC_BOOTSTRAP} != "no"
1734 .if ${MK_USB} != "no"
1735 _usb_tools= sys/boot/usb/tools
1738 cross-tools: .MAKE .PHONY
1749 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1750 cd ${.CURDIR}/${_tool}; \
1751 ${MAKE} DIRPRFX=${_tool}/ obj; \
1752 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1753 ${MAKE} DIRPRFX=${_tool}/ all; \
1754 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1757 NXBDESTDIR= ${OBJTREE}/nxb-bin
1758 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1759 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1760 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1761 NXBMAKE= ${NXBENV} ${MAKE} \
1762 LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \
1763 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1764 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1765 MK_GDB=no MK_TESTS=no \
1767 MK_HTML=no NO_LINT=yes MK_MAN=no \
1768 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1769 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1770 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1771 MK_LLDB=no MK_DEBUG_FILES=no
1773 # native-xtools is the current target for qemu-user cross builds of ports
1774 # via poudriere and the imgact_binmisc kernel module.
1775 # For non-clang enabled targets that are still using the in tree gcc
1776 # we must build a gperf binary for one instance of its Makefiles. On
1777 # clang-enabled systems, the gperf binary is obsolete.
1778 native-xtools: .PHONY
1779 .if ${MK_GCC_BOOTSTRAP} != "no"
1780 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1781 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,depend,all,install)"; \
1782 cd ${.CURDIR}/${_gperf}; \
1783 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1784 if [ -z "${NO_DEPEND}" ]; then ${NXBMAKE} DIRPRFX=${_gperf}/ depend; fi; \
1785 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1786 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1788 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1789 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1790 -p ${NXBDESTDIR}/usr >/dev/null
1791 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1792 -p ${NXBDESTDIR}/usr/include >/dev/null
1793 .if ${MK_DEBUG_FILES} != "no"
1794 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1795 -p ${NXBDESTDIR}/usr/lib >/dev/null
1856 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1857 cd ${.CURDIR}/${_tool}; \
1858 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1859 if [ -z "${NO_DEPEND}" ]; then ${NXBMAKE} DIRPRFX=${_tool}/ depend; fi; \
1860 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1861 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1865 # hierarchy - ensure that all the needed directories are present
1867 hierarchy hier: .MAKE .PHONY
1868 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1871 # libraries - build all libraries, and install them under ${DESTDIR}.
1873 # The list of libraries with dependents (${_prebuild_libs}) and their
1874 # interdependencies (__L) are built automatically by the
1875 # ${.CURDIR}/tools/make_libdeps.sh script.
1877 libraries: .MAKE .PHONY
1878 ${_+_}cd ${.CURDIR}; \
1879 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1880 ${MAKE} -f Makefile.inc1 _startup_libs; \
1881 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1882 ${MAKE} -f Makefile.inc1 _generic_libs
1885 # static libgcc.a prerequisite for shared libc
1887 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1889 # These dependencies are not automatically generated:
1891 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1892 # all shared libraries for ELF.
1894 _startup_libs= gnu/lib/csu
1895 _startup_libs+= lib/csu
1896 _startup_libs+= gnu/lib/libgcc
1897 _startup_libs+= lib/libcompiler_rt
1898 _startup_libs+= lib/libc
1899 _startup_libs+= lib/libc_nonshared
1900 .if ${MK_LIBCPLUSPLUS} != "no"
1901 _startup_libs+= lib/libcxxrt
1904 gnu/lib/libgcc__L: lib/libc__L
1905 gnu/lib/libgcc__L: lib/libc_nonshared__L
1906 .if ${MK_LIBCPLUSPLUS} != "no"
1907 lib/libcxxrt__L: gnu/lib/libgcc__L
1910 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1911 ${_kerberos5_lib_libhdb} \
1912 ${_kerberos5_lib_libheimbase} \
1913 ${_kerberos5_lib_libheimntlm} \
1915 ${_kerberos5_lib_libheimipcc} \
1916 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1917 ${_kerberos5_lib_libroken} \
1918 ${_kerberos5_lib_libwind} \
1919 lib/libbz2 ${_libcom_err} lib/libcrypt \
1920 lib/libelf lib/libexpat \
1923 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1925 lib/ncurses/ncurses lib/ncurses/ncursesw \
1926 lib/libopie lib/libpam ${_lib_libthr} \
1927 ${_lib_libradius} lib/libsbuf lib/libtacplus \
1929 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1930 ${_cddl_lib_libuutil} \
1931 ${_cddl_lib_libavl} \
1932 ${_cddl_lib_libzfs_core} \
1933 ${_cddl_lib_libctf} \
1934 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1935 ${_secure_lib_libcrypto} ${_lib_libldns} \
1936 ${_secure_lib_libssh} ${_secure_lib_libssl} \
1938 .if ${MK_GNUCXX} != "no"
1939 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1940 gnu/lib/libstdc++__L: lib/msun__L
1941 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1944 .if ${MK_LIBCPLUSPLUS} != "no"
1945 _prebuild_libs+= lib/libc++
1948 lib/libgeom__L: lib/libexpat__L
1949 lib/libkvm__L: lib/libelf__L
1951 .if ${MK_LIBTHR} != "no"
1952 _lib_libthr= lib/libthr
1955 .if ${MK_RADIUS_SUPPORT} != "no"
1956 _lib_libradius= lib/libradius
1959 .if ${MK_OFED} != "no"
1960 _ofed_lib= contrib/ofed/usr.lib
1961 _prebuild_libs+= contrib/ofed/usr.lib/libosmcomp
1962 _prebuild_libs+= contrib/ofed/usr.lib/libopensm
1963 _prebuild_libs+= contrib/ofed/usr.lib/libibcommon
1964 _prebuild_libs+= contrib/ofed/usr.lib/libibverbs
1965 _prebuild_libs+= contrib/ofed/usr.lib/libibumad
1967 contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
1968 contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
1969 contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
1972 .if ${MK_CASPER} != "no"
1973 _lib_casper= lib/libcasper
1976 lib/libpjdlog__L: lib/libutil__L
1977 lib/libcasper__L: lib/libnv__L
1978 lib/liblzma__L: lib/libthr__L
1980 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1981 .for _DIR in ${LOCAL_LIB_DIRS}
1982 .if exists(${.CURDIR}/${_DIR}/Makefile) && empty(_generic_libs:M${_DIR})
1983 _generic_libs+= ${_DIR}
1987 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1989 .if ${MK_CDDL} != "no"
1990 _cddl_lib_libumem= cddl/lib/libumem
1991 _cddl_lib_libnvpair= cddl/lib/libnvpair
1992 _cddl_lib_libavl= cddl/lib/libavl
1993 _cddl_lib_libuutil= cddl/lib/libuutil
1994 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1995 _cddl_lib_libctf= cddl/lib/libctf
1997 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1998 cddl/lib/libzfs__L: lib/libgeom__L
1999 cddl/lib/libctf__L: lib/libz__L
2001 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
2002 # on select architectures though (see cddl/lib/Makefile)
2003 .if ${MACHINE_CPUARCH} != "sparc64"
2004 _prebuild_libs+= lib/libproc lib/librtld_db
2007 .if ${MK_CRYPT} != "no"
2008 .if ${MK_OPENSSL} != "no"
2009 _secure_lib_libcrypto= secure/lib/libcrypto
2010 _secure_lib_libssl= secure/lib/libssl
2011 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2012 .if ${MK_LDNS} != "no"
2013 _lib_libldns= lib/libldns
2014 lib/libldns__L: secure/lib/libcrypto__L
2016 .if ${MK_OPENSSH} != "no"
2017 _secure_lib_libssh= secure/lib/libssh
2018 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2019 .if ${MK_LDNS} != "no"
2020 secure/lib/libssh__L: lib/libldns__L
2022 .if ${MK_KERBEROS_SUPPORT} != "no"
2023 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2024 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2025 lib/libmd__L kerberos5/lib/libroken__L
2029 _secure_lib= secure/lib
2032 .if ${MK_KERBEROS} != "no"
2033 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2034 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2035 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2036 kerberos5/lib/libwind__L lib/libsqlite3__L
2037 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2038 kerberos5/lib/libroken__L lib/libcom_err__L
2039 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2040 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2041 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2042 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2043 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2044 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2045 kerberos5/lib/libroken__L: lib/libcrypt__L
2046 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2047 kerberos5/lib/libheimbase__L: lib/libthr__L
2048 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2051 lib/libsqlite3__L: lib/libthr__L
2053 .if ${MK_GSSAPI} != "no"
2054 _lib_libgssapi= lib/libgssapi
2057 .if ${MK_KERBEROS} != "no"
2058 _kerberos5_lib= kerberos5/lib
2059 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2060 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2061 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2062 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2063 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2064 _kerberos5_lib_libroken= kerberos5/lib/libroken
2065 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2066 _libsqlite3= lib/libsqlite3
2067 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2068 _kerberos5_lib_libwind= kerberos5/lib/libwind
2069 _libcom_err= lib/libcom_err
2072 .if ${MK_NIS} != "no"
2073 _lib_libypclnt= lib/libypclnt
2076 .if ${MK_OPENSSL} == "no"
2077 lib/libradius__L: lib/libmd__L
2081 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2082 .if ${MK_CXX} != "no"
2083 .if ${MK_LIBCPLUSPLUS} != "no"
2084 lib/libproc__L: lib/libcxxrt__L
2085 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2086 lib/libproc__L: gnu/lib/libsupc++__L
2090 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2092 .for _lib in ${_prereq_libs}
2093 ${_lib}__PL: .PHONY .MAKE
2094 .if exists(${.CURDIR}/${_lib})
2095 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2096 cd ${.CURDIR}/${_lib}; \
2097 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2098 if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; fi; \
2099 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2100 DIRPRFX=${_lib}/ all; \
2101 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2102 DIRPRFX=${_lib}/ install
2106 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
2107 ${_lib}__L: .PHONY .MAKE
2108 .if exists(${.CURDIR}/${_lib})
2109 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2110 cd ${.CURDIR}/${_lib}; \
2111 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2112 if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; fi; \
2113 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2114 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2118 # libpam is special: we need to build static PAM modules before
2119 # static PAM library, and dynamic PAM library before dynamic PAM
2121 lib/libpam__L: .PHONY .MAKE
2122 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
2123 cd ${.CURDIR}/lib/libpam; \
2124 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj; \
2125 if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ depend; fi; \
2126 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2127 -D_NO_LIBPAM_SO_YET all; \
2128 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2129 -D_NO_LIBPAM_SO_YET install
2131 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2132 _startup_libs: ${_startup_libs:S/$/__L/}
2133 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2134 _generic_libs: ${_generic_libs:S/$/__L/}
2136 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2137 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2138 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2139 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2140 # parallel. This is safe for the world stage of buildworld though since it has
2141 # already built libraries in a proper order and installed includes into
2142 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2143 # avoid trashing a system if it crashes mid-install.
2144 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2148 .include <bsd.subdir.mk>
2150 .if make(check-old) || make(check-old-dirs) || \
2151 make(check-old-files) || make(check-old-libs) || \
2152 make(delete-old) || make(delete-old-dirs) || \
2153 make(delete-old-files) || make(delete-old-libs)
2156 # check for / delete old files section
2159 .include "ObsoleteFiles.inc"
2161 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2162 else you can not start such an application. Consult UPDATING for more \
2163 information regarding how to cope with the removal/revision bump of a \
2166 .if !defined(BATCH_DELETE_OLD_FILES)
2173 @echo ">>> Removing old files (only deletes safe to delete libs)"
2174 # Ask for every old file if the user really wants to remove it.
2175 # It's annoying, but better safe than sorry.
2176 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2177 # argument list will get too long. Using .for/.endfor make "loops" will make
2178 # the Makefile parser segfault.
2181 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2182 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2183 while read file; do \
2184 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2185 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2186 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2188 for ext in debug symbols; do \
2189 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2190 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2191 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2196 # Remove catpages without corresponding manpages.
2198 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2199 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2200 while read catpage; do \
2202 if [ ! -e "$${manpage}" ]; then \
2203 rm ${RM_I} $${catpage} <&3; \
2206 @echo ">>> Old files removed"
2209 @echo ">>> Checking for old files"
2211 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2212 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2213 while read file; do \
2214 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2215 echo "${DESTDIR}/$${file}"; \
2217 for ext in debug symbols; do \
2218 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2219 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2223 # Check for catpages without corresponding manpages.
2224 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2225 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2226 while read catpage; do \
2228 if [ ! -e "$${manpage}" ]; then \
2234 @echo ">>> Removing old libraries"
2235 @echo "${OLD_LIBS_MESSAGE}" | fmt
2238 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2239 -V OLD_LIBS | xargs -n1 | \
2240 while read file; do \
2241 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2242 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2243 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2245 for ext in debug symbols; do \
2246 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2247 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2248 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2253 @echo ">>> Old libraries removed"
2256 @echo ">>> Checking for old libraries"
2258 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2259 -V OLD_LIBS | xargs -n1 | \
2260 while read file; do \
2261 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2262 echo "${DESTDIR}/$${file}"; \
2264 for ext in debug symbols; do \
2265 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2266 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2272 @echo ">>> Removing old directories"
2274 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2275 -V OLD_DIRS | xargs -n1 | sort -r | \
2276 while read dir; do \
2277 if [ -d "${DESTDIR}/$${dir}" ]; then \
2278 rmdir -v "${DESTDIR}/$${dir}" || true; \
2279 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2280 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2283 @echo ">>> Old directories removed"
2286 @echo ">>> Checking for old directories"
2288 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2289 -V OLD_DIRS | xargs -n1 | \
2290 while read dir; do \
2291 if [ -d "${DESTDIR}/$${dir}" ]; then \
2292 echo "${DESTDIR}/$${dir}"; \
2293 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2294 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2298 delete-old: delete-old-files delete-old-dirs
2299 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2301 check-old: check-old-files check-old-libs check-old-dirs
2302 @echo "To remove old files and directories run '${MAKE} delete-old'."
2303 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2308 # showconfig - show build configuration.
2311 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2312 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2314 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2315 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2317 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2318 .if exists(${KERNCONFDIR}/${KERNCONF})
2319 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2320 '${KERNCONFDIR}/${KERNCONF}' ; echo
2326 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2327 DTBOUTPUTPATH= ${.CURDIR}
2331 # Build 'standalone' Device Tree Blob
2334 @PATH=${TMPPATH} MACHINE=${TARGET} \
2335 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2336 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2341 # In the following, the first 'rm' in a series will usually remove all
2342 # files and directories. If it does not, then there are probably some
2343 # files with file flags set, so this unsets them and tries the 'rm' a
2344 # second time. There are situations where this target will be cleaning
2345 # some directories via more than one method, but that duplication is
2346 # needed to correctly handle all the possible situations. Removing all
2347 # files without file flags set in the first 'rm' instance saves time,
2348 # because 'chflags' will need to operate on fewer files afterwards.
2350 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2351 # created by bsd.obj.mk, except that we don't want to .include that file
2354 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2356 .if exists(${BW_CANONICALOBJDIR}/)
2357 -rm -rf ${BW_CANONICALOBJDIR}/*
2358 -chflags -R 0 ${BW_CANONICALOBJDIR}
2359 rm -rf ${BW_CANONICALOBJDIR}/*
2361 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2362 # To be safe in this case, fall back to a 'make cleandir'
2363 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2366 .if defined(TARGET) && defined(TARGET_ARCH)
2368 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2369 XDEV_CPUTYPE?=${CPUTYPE}
2371 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2374 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2375 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2376 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2377 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2378 CPUTYPE=${XDEV_CPUTYPE}
2380 XDDIR=${TARGET_ARCH}-freebsd
2383 .error XDTP variable should be an absolute path
2386 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2387 INSTALL="sh ${.CURDIR}/tools/install.sh"
2389 TOOLS_PREFIX=${XDTP}
2390 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2391 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2392 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2393 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2394 CPP="${CPP} ${CD2CFLAGS}" \
2395 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2397 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2398 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2399 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2400 XDDESTDIR=${DESTDIR}/${XDTP}
2402 OSREL!= uname -r | sed -e 's/[-(].*//'
2405 .ORDER: xdev-build xdev-install xdev-links
2406 xdev: xdev-build xdev-install
2408 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2409 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2411 _xb-worldtmp: .PHONY
2412 mkdir -p ${CDTMP}/usr
2413 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2414 -p ${CDTMP}/usr >/dev/null
2416 _xb-bootstrap-tools: .PHONY
2420 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
2421 cd ${.CURDIR}/${_tool}; \
2422 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2423 if [ -z "${NO_DEPEND}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ depend; fi; \
2424 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2425 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2428 _xb-build-tools: .PHONY
2429 ${_+_}@cd ${.CURDIR}; \
2430 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2432 _xb-cross-tools: .PHONY
2440 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
2441 cd ${.CURDIR}/${_tool}; \
2442 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2443 if [ -z "${NO_DEPEND}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ depend; fi; \
2444 ${CDMAKE} DIRPRFX=${_tool}/ all
2448 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2449 mkdir -p ${XDDESTDIR}
2450 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2451 -p ${XDDESTDIR} >/dev/null
2452 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2453 -p ${XDDESTDIR}/usr >/dev/null
2454 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2455 -p ${XDDESTDIR}/usr/include >/dev/null
2456 .if defined(LIBCOMPAT)
2457 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2458 -p ${XDDESTDIR}/usr >/dev/null
2460 .if ${MK_TESTS} != "no"
2461 mkdir -p ${XDDESTDIR}${TESTSBASE}
2462 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2463 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2466 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2467 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2469 _xi-cross-tools: .PHONY
2470 @echo "_xi-cross-tools"
2478 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2479 cd ${.CURDIR}/${_tool}; \
2480 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2483 _xi-includes: .PHONY
2484 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2485 DESTDIR=${XDDESTDIR}
2487 _xi-libraries: .PHONY
2488 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2489 DESTDIR=${XDDESTDIR}
2492 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2493 mkdir -p ../../../../usr/bin; \
2495 ln -sf ../../${XDTP}/usr/bin/$$i \
2496 ../../../../usr/bin/${XDDIR}-$$i; \
2497 ln -sf ../../${XDTP}/usr/bin/$$i \
2498 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2501 xdev xdev-build xdev-install xdev-links:
2502 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"