4 # Make command line options:
5 # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6 # -DNO_CLEAN do not clean at all
7 # -DDB_FROM_SRC use the user/group databases in src/etc instead of
8 # the system database when installing.
9 # -DNO_SHARE do not go into share subdir
10 # -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,OBJ}
11 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
12 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
13 # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
14 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
15 # -DNO_ROOT install without using root privilege
16 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
17 # -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects
18 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
19 # LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list
20 # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
21 # LOCAL_MTREE="list of mtree files" to process to allow local directories
22 # to be created before files are installed
23 # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
25 # METALOG="path to metadata log" to write permission and ownership
26 # when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
27 # TARGET="machine" to crossbuild world for a different machine type
28 # TARGET_ARCH= may be required when a TARGET supports multiple endians
29 # BUILDENV_SHELL= shell to launch for the buildenv target (def:${SHELL})
30 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
31 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
32 # SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
33 # All libraries and includes, and some build tools will still build.
36 # The intended user-driven targets are:
37 # buildworld - rebuild *everything*, including glue to help do upgrades
38 # installworld- install everything built by "buildworld"
39 # checkworld - run test suite on installed world
40 # doxygen - build API documentation of the kernel
41 # update - convenient way to update your source tree (eg: svn/svnup)
43 # Standard targets (not defined here) are documented in the makefiles in
44 # /usr/share/mk. These include:
45 # obj depend all install clean cleandepend cleanobj
47 .if !defined(TARGET) || !defined(TARGET_ARCH)
48 .error "Both TARGET and TARGET_ARCH must be defined."
51 LOCALBASE?= /usr/local
53 # Cross toolchain changes must be in effect before bsd.compiler.mk
54 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
55 .if defined(CROSS_TOOLCHAIN)
56 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
57 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
59 .include <bsd.compiler.mk> # don't depend on src.opts.mk doing it
60 .include "share/mk/src.opts.mk"
62 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
63 # keep the users system reasonably usable. For static->dynamic root upgrades,
64 # we don't want to install a dynamic binary without rtld and the needed
65 # libraries. More commonly, for dynamic root, we don't want to install a
66 # binary that requires a newer library version that hasn't been installed yet.
67 # This ordering is not a guarantee though. The only guarantee of a working
68 # system here would require fine-grained ordering of all components based
69 # on their dependencies.
71 .if !empty(SUBDIR_OVERRIDE)
72 SUBDIR= ${SUBDIR_OVERRIDE}
75 .if !defined(NO_ROOT) && (make(installworld) || make(install))
76 # Ensure libraries are installed before progressing.
80 .if ${MK_CDDL} != "no"
84 .if ${MK_KERBEROS} != "no"
87 .if ${MK_RESCUE} != "no"
91 .if ${MK_CRYPT} != "no"
94 .if !defined(NO_SHARE)
97 SUBDIR+=sys usr.bin usr.sbin
98 .if ${MK_TESTS} != "no"
101 .if ${MK_OFED} != "no"
105 # Local directories are last, since it is nice to at least get the base
106 # system rebuilt before you do them.
107 .for _DIR in ${LOCAL_DIRS}
108 .if exists(${.CURDIR}/${_DIR}/Makefile)
112 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
113 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
114 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
115 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
116 _REDUNDENT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
118 .for _DIR in ${LOCAL_LIB_DIRS}
119 .if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
122 .warning ${_DIR} not added to SUBDIR list. See UPDATING 20141121.
126 # We must do etc/ last as it hooks into building the man whatis file
127 # by calling 'makedb' in share/man. This is only relevant for
128 # install/distribute so they build the whatis file after every manpage is
130 .if make(installworld) || make(install)
135 .endif # !empty(SUBDIR_OVERRIDE)
138 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
141 .if defined(NO_CLEANDIR)
142 CLEANDIR= clean cleandepend
148 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
150 .if empty(SHELL:M*csh*)
151 BUILDENV_SHELL?=${SHELL}
153 BUILDENV_SHELL?=/bin/sh
156 .if !defined(SVN) || empty(SVN)
157 . for _P in /usr/bin /usr/local/bin
158 . for _S in svn svnlite
159 . if exists(${_P}/${_S})
167 MAKEOBJDIRPREFIX?= /usr/obj
168 .if !defined(OSRELDATE)
169 .if exists(/usr/include/osreldate.h)
170 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
171 /usr/include/osreldate.h
178 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
179 .if !defined(VERSION)
180 REVISION!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V REVISION
181 BRANCH!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V BRANCH
182 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
183 ${SRCDIR}/sys/sys/param.h
184 VERSION= FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
188 .if !defined(PKG_VERSION)
189 REVISION!= ${MAKE} -C ${SRCDIR}/release -V REVISION
190 BRANCH!= ${MAKE} -C ${SRCDIR}/release -V BRANCH
191 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
192 ${SRCDIR}/sys/sys/param.h
193 .if ${BRANCH:MSTABLE*} || ${BRANCH:MCURRENT*}
194 TIMENOW= %Y%m%d%H%M%S
195 EXTRA_REVISION= .s${TIMENOW:gmtime}
198 EXTRA_REVISION= _${BRANCH:C/.*-p([0-9]+$)/\1/}
200 PKG_VERSION= ${REVISION}${EXTRA_REVISION}
203 KNOWN_ARCHES?= aarch64/arm64 \
222 .if ${TARGET} == ${TARGET_ARCH}
225 _t= ${TARGET_ARCH}/${TARGET}
228 .if empty(KNOWN_ARCHES:M${_t})
229 .error Unknown target ${TARGET_ARCH}:${TARGET}.
233 .if ${TARGET} == ${MACHINE}
234 TARGET_CPUTYPE?=${CPUTYPE}
239 .if !empty(TARGET_CPUTYPE)
240 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
242 _TARGET_CPUTYPE=dummy
244 _CPUTYPE!= MK_AUTO_OBJ=no MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
245 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
246 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
247 .error CPUTYPE global should be set with ?=.
250 BUILD_ARCH!= uname -p
251 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
252 .error To cross-build, set TARGET_ARCH.
255 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
256 OBJTREE= ${MAKEOBJDIRPREFIX}
258 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
260 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
261 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
262 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
263 STRICTTMPPATH= ${BPATH}:${XPATH}
264 TMPPATH= ${STRICTTMPPATH}:${PATH}
267 # Avoid running mktemp(1) unless actually needed.
268 # It may not be functional, e.g., due to new ABI
269 # when in the middle of installing over this system.
271 .if make(distributeworld) || make(installworld) || make(stageworld)
272 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
275 .if make(stagekernel) || make(distributekernel)
281 # Building a world goes through the following stages
283 # 1. legacy stage [BMAKE]
284 # This stage is responsible for creating compatibility
285 # shims that are needed by the bootstrap-tools,
286 # build-tools and cross-tools stages. These are generally
287 # APIs that tools from one of those three stages need to
288 # build that aren't present on the host.
289 # 1. bootstrap-tools stage [BMAKE]
290 # This stage is responsible for creating programs that
291 # are needed for backward compatibility reasons. They
292 # are not built as cross-tools.
293 # 2. build-tools stage [TMAKE]
294 # This stage is responsible for creating the object
295 # tree and building any tools that are needed during
296 # the build process. Some programs are listed during
297 # this phase because they build binaries to generate
298 # files needed to build these programs. This stage also
299 # builds the 'build-tools' target rather than 'all'.
300 # 3. cross-tools stage [XMAKE]
301 # This stage is responsible for creating any tools that
302 # are needed for building the system. A cross-compiler is one
303 # of them. This differs from build tools in two ways:
304 # 1. the 'all' target is built rather than 'build-tools'
305 # 2. these tools are installed into TMPPATH for stage 4.
306 # 4. world stage [WMAKE]
307 # This stage actually builds the world.
308 # 5. install stage (optional) [IMAKE]
309 # This stage installs a previously built world.
314 # Common environment for world related stages
315 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
316 MACHINE_ARCH=${TARGET_ARCH} \
318 CPUTYPE=${TARGET_CPUTYPE}
319 .if ${MK_GROFF} != "no"
320 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
321 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
322 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
324 .if defined(TARGET_CFLAGS)
325 CROSSENV+= ${TARGET_CFLAGS}
328 # bootstrap-tools stage
329 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
330 PATH=${BPATH}:${PATH} \
331 WORLDTMP=${WORLDTMP} \
332 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
333 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
335 BOOTSTRAPPING=${OSRELDATE} \
337 MK_HTML=no NO_LINT=yes MK_MAN=no \
338 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
339 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
340 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
341 MK_LLDB=no MK_TESTS=no \
344 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
345 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
349 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
350 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
351 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
353 BOOTSTRAPPING=${OSRELDATE} \
356 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
357 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
358 MK_LLDB=no MK_TESTS=no
361 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
362 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
363 MK_GDB=no MK_TESTS=no
366 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
367 PATH=${BPATH}:${PATH} \
369 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
370 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
372 BOOTSTRAPPING=${OSRELDATE} \
374 MK_HTML=no -DNO_LINT MK_MAN=no \
375 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
376 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
379 WMAKEENV= ${CROSSENV} \
380 INSTALL="sh ${.CURDIR}/tools/install.sh" \
384 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
386 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
389 .if defined(CROSS_TOOLCHAIN_PREFIX)
390 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
391 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
394 # If we do not have a bootstrap binutils (because the in-tree one does not
395 # support the target architecture), provide a default cross-binutils prefix.
396 # This allows aarch64 builds, for example, to automatically use the
397 # aarch64-binutils port or package.
398 .if !make(showconfig)
399 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
400 !defined(CROSS_BINUTILS_PREFIX)
401 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
402 .if !exists(${CROSS_BINUTILS_PREFIX})
403 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
408 XCOMPILERS= CC CXX CPP
409 .for COMPILER in ${XCOMPILERS}
410 .if defined(CROSS_COMPILER_PREFIX)
411 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
413 X${COMPILER}?= ${${COMPILER}}
416 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
417 .for BINUTIL in ${XBINUTILS}
418 .if defined(CROSS_BINUTILS_PREFIX) && \
419 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
420 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
422 X${BINUTIL}?= ${${BINUTIL}}
425 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
426 CPP="${XCPP} ${XCFLAGS}" \
427 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
428 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
429 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
432 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
433 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
434 # directory, but the compiler will look in the right place for its
435 # tools so we don't need to tell it where to look.
436 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
439 # External compiler needs sysroot and target flags.
440 .if ${XCC:N${CCACHE_BIN}:M/*} || ${MK_CROSS_COMPILER} == "no"
441 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
442 BFLAGS+= -B${WORLDTMP}/usr/bin
444 .if ${TARGET} == "arm"
445 .if ${TARGET_ARCH:M*hf*} != ""
446 TARGET_ABI= gnueabihf
451 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
452 # GCC requires -isystem and -L when using a cross-compiler.
453 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
454 # Force using libc++ for external GCC.
455 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
456 -nostdinc++ -L${WORLDTMP}/../lib/libc++
459 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
460 XCFLAGS+= -target ${TARGET_TRIPLE}
462 XCFLAGS+= --sysroot=${WORLDTMP}
464 .endif # ${XCC:M/*} || ${MK_CROSS_COMPILER} == "no"
470 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
471 ${TARGET_ARCH} == "powerpc64")
473 .include "Makefile.libcompat"
474 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH} == "armv6"
476 .include "Makefile.libcompat"
479 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
481 IMAKEENV= ${CROSSENV}
482 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
483 ${IMAKE_INSTALL} ${IMAKE_MTREE}
484 .if empty(.MAKEFLAGS:M-n)
485 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
486 LD_LIBRARY_PATH=${INSTALLTMP} \
487 PATH_LOCALE=${INSTALLTMP}/locale
488 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
490 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
492 .if defined(DB_FROM_SRC)
493 INSTALLFLAGS+= -N ${.CURDIR}/etc
494 MTREEFLAGS+= -N ${.CURDIR}/etc
496 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
497 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
499 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
500 IMAKE+= -DNO_ROOT METALOG=${METALOG}
501 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
504 .if defined(BUILD_PKGS)
505 INSTALLFLAGS+= -h sha256
507 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
508 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
509 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
513 KMAKEENV= ${WMAKEENV}
514 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
519 # Attempt to rebuild the entire system, with reasonable chance of
520 # success, regardless of how old your existing system is.
523 .if ${.CURDIR:C/[^,]//g} != ""
524 # The m4 build of sendmail files doesn't like it if ',' is used
525 # anywhere in the path of it's files.
527 @echo "*** Error: path to source tree contains a comma ','"
532 @echo "--------------------------------------------------------------"
533 @echo ">>> Rebuilding the temporary build tree"
534 @echo "--------------------------------------------------------------"
535 .if !defined(NO_CLEAN)
537 .if defined(LIBCOMPAT)
538 rm -rf ${LIBCOMPATTMP}
541 rm -rf ${WORLDTMP}/legacy/usr/include
542 # XXX - These can depend on any header file.
543 rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c
544 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
547 lib lib/casper usr legacy/bin legacy/usr
548 mkdir -p ${WORLDTMP}/${_dir}
550 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
551 -p ${WORLDTMP}/legacy/usr >/dev/null
552 .if ${MK_GROFF} != "no"
553 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
554 -p ${WORLDTMP}/legacy/usr >/dev/null
556 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
557 -p ${WORLDTMP}/usr >/dev/null
558 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
559 -p ${WORLDTMP}/usr/include >/dev/null
560 ln -sf ${.CURDIR}/sys ${WORLDTMP}
561 .if ${MK_DEBUG_FILES} != "no"
562 # We could instead disable debug files for these build stages
563 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
564 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
565 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
566 -p ${WORLDTMP}/usr/lib >/dev/null
568 .if defined(LIBCOMPAT)
569 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
570 -p ${WORLDTMP}/usr >/dev/null
571 .if ${MK_DEBUG_FILES} != "no"
572 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
573 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
574 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
575 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
578 .if ${MK_TESTS} != "no"
579 mkdir -p ${WORLDTMP}${TESTSBASE}
580 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
581 -p ${WORLDTMP}${TESTSBASE} >/dev/null
582 .if ${MK_DEBUG_FILES} != "no"
583 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
584 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
585 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
588 .for _mtree in ${LOCAL_MTREE}
589 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
593 @echo "--------------------------------------------------------------"
594 @echo ">>> stage 1.1: legacy release compatibility shims"
595 @echo "--------------------------------------------------------------"
596 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
599 @echo "--------------------------------------------------------------"
600 @echo ">>> stage 1.2: bootstrap tools"
601 @echo "--------------------------------------------------------------"
602 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
604 .if !defined(NO_CLEAN)
606 @echo "--------------------------------------------------------------"
607 @echo ">>> stage 2.1: cleaning up the object tree"
608 @echo "--------------------------------------------------------------"
609 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
610 .if defined(LIBCOMPAT)
611 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
616 @echo "--------------------------------------------------------------"
617 @echo ">>> stage 2.2: rebuilding the object tree"
618 @echo "--------------------------------------------------------------"
619 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
622 @echo "--------------------------------------------------------------"
623 @echo ">>> stage 2.3: build tools"
624 @echo "--------------------------------------------------------------"
625 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
628 @echo "--------------------------------------------------------------"
629 @echo ">>> stage 3: cross tools"
630 @echo "--------------------------------------------------------------"
631 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
632 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
635 @echo "--------------------------------------------------------------"
636 @echo ">>> stage 4.1: building includes"
637 @echo "--------------------------------------------------------------"
638 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
639 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
640 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
641 MK_INCLUDES=yes includes
642 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
643 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
647 @echo "--------------------------------------------------------------"
648 @echo ">>> stage 4.2: building libraries"
649 @echo "--------------------------------------------------------------"
650 ${_+_}cd ${.CURDIR}; \
651 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
652 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
655 @echo "--------------------------------------------------------------"
656 @echo ">>> stage 4.3: building everything"
657 @echo "--------------------------------------------------------------"
658 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
661 WMAKE_TGTS+= _worldtmp _legacy
662 .if empty(SUBDIR_OVERRIDE)
663 WMAKE_TGTS+= _bootstrap-tools
665 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
666 WMAKE_TGTS+= _includes _libraries
667 WMAKE_TGTS+= everything
668 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
669 WMAKE_TGTS+= build${libcompat}
672 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
673 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
676 @echo "--------------------------------------------------------------"
677 @echo ">>> World build started on `LC_ALL=C date`"
678 @echo "--------------------------------------------------------------"
682 @echo "--------------------------------------------------------------"
683 @echo ">>> World build completed on `LC_ALL=C date`"
684 @echo "--------------------------------------------------------------"
687 # We need to have this as a target because the indirection between Makefile
688 # and Makefile.inc1 causes the correct PATH to be used, rather than a
689 # modification of the current environment's PATH. In addition, we need
690 # to quote multiword values.
693 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
695 .if ${.TARGETS:Mbuildenv}
696 .if ${.MAKEFLAGS:M-j}
697 .error The buildenv target is incompatible with -j
700 BUILDENV_DIR?= ${.CURDIR}
702 @echo Entering world for ${TARGET_ARCH}:${TARGET}
703 .if ${BUILDENV_SHELL:M*zsh*}
704 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
706 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
709 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
710 toolchain: ${TOOLCHAIN_TGTS}
711 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
716 # Checks to be sure system is ready for installworld/installkernel.
718 installcheck: _installcheck_world _installcheck_kernel
720 _installcheck_kernel:
723 # Require DESTDIR to be set if installing for a different architecture or
724 # using the user/group database in the source tree.
726 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
728 .if !make(distributeworld)
729 _installcheck_world: __installcheck_DESTDIR
730 _installcheck_kernel: __installcheck_DESTDIR
731 __installcheck_DESTDIR:
732 .if !defined(DESTDIR) || empty(DESTDIR)
733 @echo "ERROR: Please set DESTDIR!"; \
739 .if !defined(DB_FROM_SRC)
741 # Check for missing UIDs/GIDs.
743 CHECK_UIDS= auditdistd
745 .if ${MK_SENDMAIL} != "no"
751 CHECK_GIDS+= proxy authpf
753 .if ${MK_UNBOUND} != "no"
757 _installcheck_world: __installcheck_UGID
759 .for uid in ${CHECK_UIDS}
760 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
761 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
765 .for gid in ${CHECK_GIDS}
766 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
767 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
774 # Required install tools to be saved in a scratch dir for safety.
776 .if ${MK_ZONEINFO} != "no"
777 _zoneinfo= zic tzsetup
780 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
781 date echo egrep find grep id install ${_install-info} \
782 ln make mkdir mtree mv pwd_mkdb \
783 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
786 # Needed for share/man
787 .if ${MK_MAN} != "no"
794 # Distributes everything compiled by a `buildworld'.
798 # Installs everything compiled by a 'buildworld'.
801 # Non-base distributions produced by the base system
802 EXTRA_DISTRIBUTIONS= doc
803 .if defined(LIBCOMPAT)
804 EXTRA_DISTRIBUTIONS+= lib${libcompat}
806 .if ${MK_TESTS} != "no"
807 EXTRA_DISTRIBUTIONS+= tests
811 .if ${MK_DEBUG_FILES} != "no"
812 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
815 MTREE_MAGIC?= mtree 2.0
817 distributeworld installworld stageworld: _installcheck_world
818 mkdir -p ${INSTALLTMP}
819 progs=$$(for prog in ${ITOOLS}; do \
820 if progpath=`which $$prog`; then \
823 echo "Required tool $$prog not found in PATH." >&2; \
827 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
828 while read line; do \
830 if [ "$$2 $$3" != "not found" ]; then \
833 echo "Required library $$1 not found." >&2; \
837 cp $$libs $$progs ${INSTALLTMP}
838 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
840 -mkdir -p ${METALOG:H}
841 echo "#${MTREE_MAGIC}" > ${METALOG}
843 .if make(distributeworld)
844 .for dist in ${EXTRA_DISTRIBUTIONS}
845 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
846 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
847 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
848 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
849 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
850 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
851 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
852 .if ${MK_DEBUG_FILES} != "no"
853 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
854 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
856 .if defined(LIBCOMPAT)
857 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
858 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
859 .if ${MK_DEBUG_FILES} != "no"
860 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
861 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
864 .if ${MK_TESTS} != "no" && ${dist} == "tests"
865 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
866 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
867 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
868 .if ${MK_DEBUG_FILES} != "no"
869 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
870 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
874 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
875 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
876 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
877 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
878 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
879 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
880 .if defined(LIBCOMPAT)
881 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
882 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
886 -mkdir ${DESTDIR}/${DISTDIR}/base
887 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
888 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
889 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
890 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
892 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
893 ${IMAKEENV} rm -rf ${INSTALLTMP}
894 .if make(distributeworld)
895 .for dist in ${EXTRA_DISTRIBUTIONS}
896 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
899 .for dist in base ${EXTRA_DISTRIBUTIONS}
900 @# For each file that exists in this dist, print the corresponding
901 @# line from the METALOG. This relies on the fact that
902 @# a line containing only the filename will sort immediatly before
903 @# the relevant mtree line.
904 cd ${DESTDIR}/${DISTDIR}; \
905 find ./${dist} | sort -u ${METALOG} - | \
906 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
907 ${DESTDIR}/${DISTDIR}/${dist}.meta
909 .for dist in ${DEBUG_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}/usr/lib/debug | sort -u ${METALOG} - | \
916 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
917 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
923 .for dist in base ${EXTRA_DISTRIBUTIONS}
925 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
926 tar cvf - --exclude usr/lib/debug \
927 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
928 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
930 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
931 tar cvf - --exclude usr/lib/debug . | \
932 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
936 .for dist in ${DEBUG_DISTRIBUTIONS}
937 . if defined(NO_ROOT)
938 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
939 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
940 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
942 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
943 tar cvLf - usr/lib/debug | \
944 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
951 # If you have a build server, you can NFS mount the source and obj directories
952 # and do a 'make reinstall' on the *client* to install new binaries from the
953 # most recent server build.
955 reinstall: .MAKE .PHONY
956 @echo "--------------------------------------------------------------"
957 @echo ">>> Making hierarchy"
958 @echo "--------------------------------------------------------------"
959 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
960 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
962 @echo "--------------------------------------------------------------"
963 @echo ">>> Installing everything"
964 @echo "--------------------------------------------------------------"
965 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
966 .if defined(LIBCOMPAT)
967 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
970 restage: .MAKE .PHONY
971 @echo "--------------------------------------------------------------"
972 @echo ">>> Making hierarchy"
973 @echo "--------------------------------------------------------------"
974 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
975 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy distribution
977 @echo "--------------------------------------------------------------"
978 @echo ">>> Installing everything"
979 @echo "--------------------------------------------------------------"
980 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
981 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
982 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
985 redistribute: .MAKE .PHONY
986 @echo "--------------------------------------------------------------"
987 @echo ">>> Distributing everything"
988 @echo "--------------------------------------------------------------"
989 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
990 .if defined(LIBCOMPAT)
991 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
992 DISTRIBUTION=lib${libcompat}
995 distrib-dirs distribution: .MAKE .PHONY
996 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
997 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
998 .if make(distribution)
999 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1000 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1001 METALOG=${METALOG} MK_TESTS=no installconfig
1005 # buildkernel and installkernel
1007 # Which kernels to build and/or install is specified by setting
1008 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1009 # Only the existing (depending TARGET) config files are used
1010 # for building kernels and only the first of these is designated
1011 # as the one being installed.
1013 # Note that we have to use TARGET instead of TARGET_ARCH when
1014 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1015 # be set to cross-build, we have to make sure TARGET is set
1018 .if defined(KERNFAST)
1022 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1023 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1024 KERNCONF=${KERNFAST}
1027 .if ${TARGET_ARCH} == "powerpc64"
1028 KERNCONF?= GENERIC64
1032 INSTKERNNAME?= kernel
1034 KERNSRCDIR?= ${.CURDIR}/sys
1035 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1036 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1037 KERNCONFDIR?= ${KRNLCONFDIR}
1041 .if defined(NO_INSTALLKERNEL)
1042 # All of the BUILDKERNELS loops start at index 1.
1043 BUILDKERNELS+= dummy
1045 .for _kernel in ${KERNCONF}
1046 .if exists(${KERNCONFDIR}/${_kernel})
1047 BUILDKERNELS+= ${_kernel}
1048 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1049 INSTALLKERNEL= ${_kernel}
1054 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1059 # Builds all kernels defined by BUILDKERNELS.
1061 buildkernel: .MAKE .PHONY
1062 .if empty(BUILDKERNELS:Ndummy)
1063 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1067 .for _kernel in ${BUILDKERNELS:Ndummy}
1068 @echo "--------------------------------------------------------------"
1069 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1070 @echo "--------------------------------------------------------------"
1071 @echo "===> ${_kernel}"
1072 mkdir -p ${KRNLOBJDIR}
1073 .if !defined(NO_KERNELCONFIG)
1075 @echo "--------------------------------------------------------------"
1076 @echo ">>> stage 1: configuring the kernel"
1077 @echo "--------------------------------------------------------------"
1078 cd ${KRNLCONFDIR}; \
1080 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1081 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1083 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1085 @echo "--------------------------------------------------------------"
1086 @echo ">>> stage 2.1: cleaning up the object tree"
1087 @echo "--------------------------------------------------------------"
1088 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1090 .if !defined(NO_KERNELOBJ)
1092 @echo "--------------------------------------------------------------"
1093 @echo ">>> stage 2.2: rebuilding the object tree"
1094 @echo "--------------------------------------------------------------"
1095 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1098 @echo "--------------------------------------------------------------"
1099 @echo ">>> stage 2.3: build tools"
1100 @echo "--------------------------------------------------------------"
1101 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1103 @echo "--------------------------------------------------------------"
1104 @echo ">>> stage 3.1: building everything"
1105 @echo "--------------------------------------------------------------"
1106 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1107 @echo "--------------------------------------------------------------"
1108 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1109 @echo "--------------------------------------------------------------"
1113 # installkernel, etc.
1115 # Install the kernel defined by INSTALLKERNEL
1117 installkernel installkernel.debug \
1118 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1119 .if !defined(NO_INSTALLKERNEL)
1120 .if empty(INSTALLKERNEL)
1121 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1124 @echo "--------------------------------------------------------------"
1125 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1126 @echo "--------------------------------------------------------------"
1127 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1128 ${CROSSENV} PATH=${TMPPATH} \
1129 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1131 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1132 .for _kernel in ${BUILDKERNELS:[2..-1]}
1133 @echo "--------------------------------------------------------------"
1134 @echo ">>> Installing kernel ${_kernel}"
1135 @echo "--------------------------------------------------------------"
1136 cd ${KRNLOBJDIR}/${_kernel}; \
1137 ${CROSSENV} PATH=${TMPPATH} \
1138 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1142 distributekernel distributekernel.debug:
1143 .if !defined(NO_INSTALLKERNEL)
1144 .if empty(INSTALLKERNEL)
1145 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1148 mkdir -p ${DESTDIR}/${DISTDIR}
1149 .if defined(NO_ROOT)
1150 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1152 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1153 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1154 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1155 DESTDIR=${INSTALL_DDIR}/kernel \
1156 ${.TARGET:S/distributekernel/install/}
1157 .if defined(NO_ROOT)
1158 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1159 ${DESTDIR}/${DISTDIR}/kernel.meta
1162 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1163 .for _kernel in ${BUILDKERNELS:[2..-1]}
1164 .if defined(NO_ROOT)
1165 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1167 cd ${KRNLOBJDIR}/${_kernel}; \
1168 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1169 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1170 KERNEL=${INSTKERNNAME}.${_kernel} \
1171 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1172 ${.TARGET:S/distributekernel/install/}
1173 .if defined(NO_ROOT)
1174 @sed -e "s|^./kernel.${_kernel}|.|" \
1175 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1176 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1182 .if defined(NO_ROOT)
1183 .if !defined(NO_INSTALLKERNEL)
1184 cd ${DESTDIR}/${DISTDIR}/kernel; \
1185 tar cvf - --exclude '*.debug' \
1186 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1187 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1189 cd ${DESTDIR}/${DISTDIR}/kernel; \
1190 tar cvf - --include '*/*/*.debug' \
1191 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1192 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1193 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1194 .for _kernel in ${BUILDKERNELS:[2..-1]}
1195 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1196 tar cvf - --exclude '*.debug' \
1197 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1198 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1199 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1200 tar cvf - --include '*/*/*.debug' \
1201 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1202 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1206 .if !defined(NO_INSTALLKERNEL)
1207 cd ${DESTDIR}/${DISTDIR}/kernel; \
1208 tar cvf - --exclude '*.debug' . | \
1209 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1211 cd ${DESTDIR}/${DISTDIR}/kernel; \
1212 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1213 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1214 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1215 .for _kernel in ${BUILDKERNELS:[2..-1]}
1216 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1217 tar cvf - --exclude '*.debug' . | \
1218 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1219 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1220 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1221 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1227 ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1229 PORTSDIR?= /usr/ports
1230 WSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/worldstage
1231 KSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/kernelstage
1232 REPODIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/repo
1233 PKGSIGNKEY?= # empty
1235 .ORDER: stage-packages create-packages
1236 .ORDER: create-packages create-world-packages
1237 .ORDER: create-packages create-kernel-packages
1238 .ORDER: create-packages sign-packages
1241 .if !exists(${LOCALBASE}/sbin/pkg)
1242 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1246 ${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1249 rm -rf /tmp/ports.${TARGET} || :
1250 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${REVISION} \
1251 PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} WSTAGEDIR=${WSTAGEDIR} \
1252 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1254 real-packages: stage-packages create-packages sign-packages
1257 @mkdir -p ${REPODIR} ${WSTAGEDIR} ${KSTAGEDIR}
1258 ${_+_}@cd ${.CURDIR}; \
1259 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT -B stageworld ; \
1260 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT -B stagekernel
1262 create-packages: _pkgbootstrap
1263 @mkdir -p ${REPODIR}
1264 ${_+_}@cd ${.CURDIR}; \
1265 ${MAKE} DESTDIR=${WSTAGEDIR} \
1266 PKG_VERSION=${PKG_VERSION} create-world-packages ; \
1267 ${MAKE} DESTDIR=${KSTAGEDIR} \
1268 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1269 create-kernel-packages
1271 create-world-packages: _pkgbootstrap
1272 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1273 @cd ${WSTAGEDIR} ; \
1274 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1275 ${WSTAGEDIR}/METALOG
1276 @for plist in ${WSTAGEDIR}/*.plist; do \
1277 plist=$${plist##*/} ; \
1278 pkgname=$${plist%.plist} ; \
1279 sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \
1280 -s ${SRCDIR} -u ${WSTAGEDIR}/$${pkgname}.ucl ; \
1282 @for plist in ${WSTAGEDIR}/*.plist; do \
1283 plist=$${plist##*/} ; \
1284 pkgname=$${plist%.plist} ; \
1286 /^name/ { printf("===> Creating %s-", $$2); next } \
1287 /^version/ { print $$2; next } \
1288 ' ${WSTAGEDIR}/$${pkgname}.ucl ; \
1289 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1290 create -M ${WSTAGEDIR}/$${pkgname}.ucl \
1291 -p ${WSTAGEDIR}/$${pkgname}.plist \
1293 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} ; \
1296 create-kernel-packages: _pkgbootstrap
1297 .if exists(${KSTAGEDIR}/kernel.meta)
1298 .for flavor in "" -debug
1299 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1300 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1301 -v kernel=yes -v _kernconf=${INSTALLKERNEL} \
1302 ${KSTAGEDIR}/kernel.meta ; \
1303 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1304 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1305 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1306 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1307 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1308 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1309 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1310 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1311 ${SRCDIR}/release/packages/kernel.ucl \
1312 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1314 /name/ { printf("===> Creating %s-", $$2); next } \
1315 /version/ {print $$2; next } ' \
1316 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1317 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1318 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1319 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1320 -r ${KSTAGEDIR}/${DISTDIR} \
1321 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1324 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1325 .for _kernel in ${BUILDKERNELS:[2..-1]}
1326 .if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1327 .for flavor in "" -debug
1328 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1329 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1330 -v kernel=yes -v _kernconf=${_kernel} \
1331 ${KSTAGEDIR}/kernel.${_kernel}.meta ; \
1332 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1333 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1334 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1335 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1336 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1337 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1338 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1339 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1340 ${SRCDIR}/release/packages/kernel.ucl \
1341 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1343 /name/ { printf("===> Creating %s-", $$2); next } \
1344 /version/ {print $$2; next } ' \
1345 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1346 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1347 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1348 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1349 -r ${KSTAGEDIR}/kernel.${_kernel} \
1350 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1356 sign-packages: _pkgbootstrap
1357 @[ -L "${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1358 unlink ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1359 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1360 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1361 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1363 ln -s ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1364 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest
1370 # Run test suite on installed world.
1373 @if [ ! -x ${LOCALBASE}/bin/kyua ]; then \
1374 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1377 ${_+_}${LOCALBASE}/bin/kyua test -k ${TESTSBASE}/Kyuafile
1383 # Build the API documentation with doxygen
1386 @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1387 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1390 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1395 # Update the source tree(s), by running svn/svnup to update to the
1399 .if defined(SVN_UPDATE)
1400 @echo "--------------------------------------------------------------"
1401 @echo ">>> Updating ${.CURDIR} using Subversion"
1402 @echo "--------------------------------------------------------------"
1403 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1407 # ------------------------------------------------------------------------
1409 # From here onwards are utility targets used by the 'make world' and
1410 # related targets. If your 'world' breaks, you may like to try to fix
1411 # the problem and manually run the following targets to attempt to
1412 # complete the build. Beware, this is *not* guaranteed to work, you
1413 # need to have a pretty good grip on the current state of the system
1414 # to attempt to manually finish it. If in doubt, 'make world' again.
1418 # legacy: Build compatibility shims for the next three targets. This is a
1419 # minimal set of tools and shims necessary to compensate for older systems
1420 # which don't have the APIs required by the targets built in bootstrap-tools,
1421 # build-tools or cross-tools.
1424 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1425 # r296685 fix cross-endian objcopy
1426 .if ${BOOTSTRAPPING} < 1100102
1427 _elftoolchain_libs= lib/libelf lib/libdwarf
1431 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1432 @echo "ERROR: Source upgrades from versions prior to 8.0 are not supported."; \
1435 .for _tool in tools/build ${_elftoolchain_libs}
1436 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1437 cd ${.CURDIR}/${_tool}; \
1438 ${MAKE} DIRPRFX=${_tool}/ obj; \
1439 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1440 ${MAKE} DIRPRFX=${_tool}/ all; \
1441 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1445 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1446 # are built to build other binaries in the system. However, the focus of these
1447 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1448 # libraries, augmented by -legacy.
1450 _bt= _bootstrap-tools
1452 .if ${MK_GAMES} != "no"
1453 _strfile= usr.bin/fortune/strfile
1456 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1457 _gperf= gnu/usr.bin/gperf
1460 .if ${MK_GROFF} != "no"
1461 _groff= gnu/usr.bin/groff \
1465 .if ${MK_VT} != "no"
1466 _vtfontcvt= usr.bin/vtfontcvt
1469 .if ${BOOTSTRAPPING} < 900002
1473 .if ${BOOTSTRAPPING} < 1000033
1474 _libopenbsd= lib/libopenbsd
1478 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1479 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1482 .if ${BOOTSTRAPPING} < 1000026
1483 _nmtree= lib/libnetbsd \
1486 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1489 .if ${BOOTSTRAPPING} < 1000027
1493 # r264059 support for status=
1494 .if ${BOOTSTRAPPING} < 1100017
1498 # r277259 crunchide: Correct 64-bit section header offset
1499 # r281674 crunchide: always include both 32- and 64-bit ELF support
1500 # r285986 crunchen: use STRIPBIN rather than STRIP
1501 .if ${BOOTSTRAPPING} < 1100078
1502 _crunch= usr.sbin/crunch
1505 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1509 # r296926 -P keymap search path
1510 .if ${BOOTSTRAPPING} < 1100103
1511 _kbdcontrol= usr.sbin/kbdcontrol
1517 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1519 .if ${MK_BSNMP} != "no"
1520 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1523 # We need to build tblgen when we're building clang either as
1524 # the bootstrap compiler, or as the part of the normal build.
1525 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1527 lib/clang/libllvmsupport \
1528 lib/clang/libllvmtablegen \
1529 usr.bin/clang/llvm-tblgen \
1530 usr.bin/clang/clang-tblgen
1532 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1533 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1536 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1539 .if ${MK_GPL_DTC} != "no"
1540 _dtc= gnu/usr.bin/dtc
1543 .if ${MK_KERBEROS} != "no"
1544 _kerberos5_bootstrap_tools= \
1545 kerberos5/tools/make-roken \
1546 kerberos5/lib/libroken \
1547 kerberos5/lib/libvers \
1548 kerberos5/tools/asn1_compile \
1549 kerberos5/tools/slc \
1552 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1555 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
1556 .if ${MK_MANDOCDB} != "no" && ${BOOTSTRAPPING} < 1100075
1557 _libopenbsd?= lib/libopenbsd
1558 _makewhatis= lib/libsqlite3 \
1560 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1563 bootstrap-tools: .PHONY
1565 # Please document (add comment) why something is in 'bootstrap-tools'.
1566 # Try to bound the building of the bootstrap-tool to just the
1567 # FreeBSD versions that need the tool built at this stage of the build.
1570 ${_kerberos5_bootstrap_tools} \
1594 ${_bt}-${_tool}: .PHONY .MAKE
1595 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1596 cd ${.CURDIR}/${_tool}; \
1597 ${MAKE} DIRPRFX=${_tool}/ obj; \
1598 ${MAKE} DIRPRFX=${_tool}/ all; \
1599 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1601 bootstrap-tools: ${_bt}-${_tool}
1605 # build-tools: Build special purpose build tools
1607 .if !defined(NO_SHARE)
1608 _share= share/syscons/scrnmaps
1611 .if ${MK_GCC} != "no"
1612 _gcc_tools= gnu/usr.bin/cc/cc_tools
1615 .if ${MK_RESCUE} != "no"
1616 # rescue includes programs that have build-tools targets
1617 _rescue=rescue/rescue
1623 ${LOCAL_TOOL_DIRS} \
1624 lib/ncurses/ncurses \
1625 lib/ncurses/ncursesw \
1630 usr.bin/mkesdb_static \
1631 usr.bin/mkcsmapper_static \
1633 build-tools_${_tool}: .PHONY
1634 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1635 cd ${.CURDIR}/${_tool}; \
1636 ${MAKE} DIRPRFX=${_tool}/ obj; \
1637 ${MAKE} DIRPRFX=${_tool}/ build-tools
1638 build-tools: build-tools_${_tool}
1642 build-tools_${_tool}: .PHONY
1643 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \
1644 cd ${.CURDIR}/${_tool}; \
1645 ${MAKE} DIRPRFX=${_tool}/ obj; \
1646 ${MAKE} DIRPRFX=${_tool}/ all
1647 build-tools: build-tools_${_tool}
1651 # kernel-tools: Build kernel-building tools
1654 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1655 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1656 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1659 # cross-tools: All the tools needed to build the rest of the system after
1660 # we get done with the earlier stages. It is the last set of tools needed
1661 # to begin building the target binaries.
1663 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1664 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1665 _btxld= usr.sbin/btxld
1669 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1670 # resulting from missing bug fixes or ELF Toolchain updates.
1671 .if ${MK_CDDL} != "no"
1672 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1673 cddl/usr.bin/ctfmerge
1676 # If we're given an XAS, don't build binutils.
1677 .if ${XAS:M/*} == ""
1678 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1679 _binutils= gnu/usr.bin/binutils
1681 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1682 _elftctools= lib/libelftc \
1688 # These are not required by the build, but can be useful for developers who
1689 # cross-build on a FreeBSD 10 host:
1690 _elftctools+= usr.bin/addr2line
1692 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1693 # If cross-building with an external binutils we still need to build strip for
1694 # the target (for at least crunchide).
1695 _elftctools= lib/libelftc \
1700 # If an full path to an external cross compiler is given, don't build
1702 .if ${XCC:N${CCACHE_BIN}:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1703 .if ${MK_CLANG_BOOTSTRAP} != "no"
1704 _clang= usr.bin/clang
1705 _clang_libs= lib/clang
1707 .if ${MK_GCC_BOOTSTRAP} != "no"
1711 .if ${MK_USB} != "no"
1712 _usb_tools= sys/boot/usb/tools
1715 cross-tools: .MAKE .PHONY
1726 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1727 cd ${.CURDIR}/${_tool}; \
1728 ${MAKE} DIRPRFX=${_tool}/ obj; \
1729 ${MAKE} DIRPRFX=${_tool}/ all; \
1730 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1733 NXBDESTDIR= ${OBJTREE}/nxb-bin
1734 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1735 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1736 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1737 NXBMAKE= ${NXBENV} ${MAKE} \
1738 LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \
1739 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1740 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1741 MK_GDB=no MK_TESTS=no \
1743 MK_HTML=no NO_LINT=yes MK_MAN=no \
1744 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1745 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1746 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1747 MK_LLDB=no MK_DEBUG_FILES=no
1749 # native-xtools is the current target for qemu-user cross builds of ports
1750 # via poudriere and the imgact_binmisc kernel module.
1751 # For non-clang enabled targets that are still using the in tree gcc
1752 # we must build a gperf binary for one instance of its Makefiles. On
1753 # clang-enabled systems, the gperf binary is obsolete.
1754 native-xtools: .PHONY
1755 .if ${MK_GCC_BOOTSTRAP} != "no"
1756 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1757 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \
1758 cd ${.CURDIR}/${_gperf}; \
1759 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1760 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1761 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1763 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1764 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1765 -p ${NXBDESTDIR}/usr >/dev/null
1766 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1767 -p ${NXBDESTDIR}/usr/include >/dev/null
1768 .if ${MK_DEBUG_FILES} != "no"
1769 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1770 -p ${NXBDESTDIR}/usr/lib >/dev/null
1831 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1832 cd ${.CURDIR}/${_tool}; \
1833 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1834 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1835 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1839 # hierarchy - ensure that all the needed directories are present
1841 hierarchy hier: .MAKE .PHONY
1842 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1845 # libraries - build all libraries, and install them under ${DESTDIR}.
1847 # The list of libraries with dependents (${_prebuild_libs}) and their
1848 # interdependencies (__L) are built automatically by the
1849 # ${.CURDIR}/tools/make_libdeps.sh script.
1851 libraries: .MAKE .PHONY
1852 ${_+_}cd ${.CURDIR}; \
1853 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1854 ${MAKE} -f Makefile.inc1 _startup_libs; \
1855 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1856 ${MAKE} -f Makefile.inc1 _generic_libs
1859 # static libgcc.a prerequisite for shared libc
1861 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1863 # These dependencies are not automatically generated:
1865 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1866 # all shared libraries for ELF.
1868 _startup_libs= gnu/lib/csu
1869 _startup_libs+= lib/csu
1870 _startup_libs+= gnu/lib/libgcc
1871 _startup_libs+= lib/libcompiler_rt
1872 _startup_libs+= lib/libc
1873 _startup_libs+= lib/libc_nonshared
1874 .if ${MK_LIBCPLUSPLUS} != "no"
1875 _startup_libs+= lib/libcxxrt
1878 gnu/lib/libgcc__L: lib/libc__L
1879 gnu/lib/libgcc__L: lib/libc_nonshared__L
1880 .if ${MK_LIBCPLUSPLUS} != "no"
1881 lib/libcxxrt__L: gnu/lib/libgcc__L
1884 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1885 ${_kerberos5_lib_libhdb} \
1886 ${_kerberos5_lib_libheimbase} \
1887 ${_kerberos5_lib_libheimntlm} \
1889 ${_kerberos5_lib_libheimipcc} \
1890 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1891 ${_kerberos5_lib_libroken} \
1892 ${_kerberos5_lib_libwind} \
1893 lib/libbz2 ${_libcom_err} lib/libcrypt \
1894 lib/libelf lib/libexpat \
1897 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1899 lib/ncurses/ncurses lib/ncurses/ncursesw \
1900 lib/libopie lib/libpam ${_lib_libthr} \
1901 ${_lib_libradius} lib/libsbuf lib/libtacplus \
1903 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1904 ${_cddl_lib_libuutil} \
1905 ${_cddl_lib_libavl} \
1906 ${_cddl_lib_libzfs_core} \
1907 ${_cddl_lib_libctf} \
1908 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1909 ${_secure_lib_libcrypto} ${_lib_libldns} \
1910 ${_secure_lib_libssh} ${_secure_lib_libssl} \
1912 .if ${MK_GNUCXX} != "no"
1913 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1914 gnu/lib/libstdc++__L: lib/msun__L
1915 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1918 .if ${MK_LIBCPLUSPLUS} != "no"
1919 _prebuild_libs+= lib/libc++
1922 lib/libgeom__L: lib/libexpat__L
1923 lib/libkvm__L: lib/libelf__L
1925 .if ${MK_LIBTHR} != "no"
1926 _lib_libthr= lib/libthr
1929 .if ${MK_RADIUS_SUPPORT} != "no"
1930 _lib_libradius= lib/libradius
1933 .if ${MK_OFED} != "no"
1934 _ofed_lib= contrib/ofed/usr.lib
1935 _prebuild_libs+= contrib/ofed/usr.lib/libosmcomp
1936 _prebuild_libs+= contrib/ofed/usr.lib/libopensm
1937 _prebuild_libs+= contrib/ofed/usr.lib/libibcommon
1938 _prebuild_libs+= contrib/ofed/usr.lib/libibverbs
1939 _prebuild_libs+= contrib/ofed/usr.lib/libibumad
1941 contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
1942 contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
1943 contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
1946 .if ${MK_CASPER} != "no"
1947 _lib_casper= lib/libcasper
1950 lib/libpjdlog__L: lib/libutil__L
1951 lib/libcasper__L: lib/libnv__L
1952 lib/liblzma__L: lib/libthr__L
1954 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1955 .for _DIR in ${LOCAL_LIB_DIRS}
1956 .if exists(${.CURDIR}/${_DIR}/Makefile) && empty(_generic_libs:M${_DIR})
1957 _generic_libs+= ${_DIR}
1961 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1963 .if ${MK_CDDL} != "no"
1964 _cddl_lib_libumem= cddl/lib/libumem
1965 _cddl_lib_libnvpair= cddl/lib/libnvpair
1966 _cddl_lib_libavl= cddl/lib/libavl
1967 _cddl_lib_libuutil= cddl/lib/libuutil
1968 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1969 _cddl_lib_libctf= cddl/lib/libctf
1971 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1972 cddl/lib/libzfs__L: lib/libgeom__L
1973 cddl/lib/libctf__L: lib/libz__L
1975 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
1976 # on select architectures though (see cddl/lib/Makefile)
1977 .if ${MACHINE_CPUARCH} != "sparc64"
1978 _prebuild_libs+= lib/libproc lib/librtld_db
1981 .if ${MK_CRYPT} != "no"
1982 .if ${MK_OPENSSL} != "no"
1983 _secure_lib_libcrypto= secure/lib/libcrypto
1984 _secure_lib_libssl= secure/lib/libssl
1985 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1986 .if ${MK_LDNS} != "no"
1987 _lib_libldns= lib/libldns
1988 lib/libldns__L: secure/lib/libcrypto__L
1990 .if ${MK_OPENSSH} != "no"
1991 _secure_lib_libssh= secure/lib/libssh
1992 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1993 .if ${MK_LDNS} != "no"
1994 secure/lib/libssh__L: lib/libldns__L
1996 .if ${MK_KERBEROS_SUPPORT} != "no"
1997 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1998 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1999 lib/libmd__L kerberos5/lib/libroken__L
2003 _secure_lib= secure/lib
2006 .if ${MK_KERBEROS} != "no"
2007 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2008 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2009 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2010 kerberos5/lib/libwind__L lib/libsqlite3__L
2011 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2012 kerberos5/lib/libroken__L lib/libcom_err__L
2013 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2014 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2015 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2016 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2017 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2018 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2019 kerberos5/lib/libroken__L: lib/libcrypt__L
2020 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2021 kerberos5/lib/libheimbase__L: lib/libthr__L
2022 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2025 lib/libsqlite3__L: lib/libthr__L
2027 .if ${MK_GSSAPI} != "no"
2028 _lib_libgssapi= lib/libgssapi
2031 .if ${MK_KERBEROS} != "no"
2032 _kerberos5_lib= kerberos5/lib
2033 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2034 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2035 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2036 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2037 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2038 _kerberos5_lib_libroken= kerberos5/lib/libroken
2039 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2040 _libsqlite3= lib/libsqlite3
2041 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2042 _kerberos5_lib_libwind= kerberos5/lib/libwind
2043 _libcom_err= lib/libcom_err
2046 .if ${MK_NIS} != "no"
2047 _lib_libypclnt= lib/libypclnt
2050 .if ${MK_OPENSSL} == "no"
2051 lib/libradius__L: lib/libmd__L
2055 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2056 .if ${MK_CXX} != "no"
2057 .if ${MK_LIBCPLUSPLUS} != "no"
2058 lib/libproc__L: lib/libcxxrt__L
2059 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2060 lib/libproc__L: gnu/lib/libsupc++__L
2064 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2066 .for _lib in ${_prereq_libs}
2067 ${_lib}__PL: .PHONY .MAKE
2068 .if exists(${.CURDIR}/${_lib})
2069 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2070 cd ${.CURDIR}/${_lib}; \
2071 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2072 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2073 DIRPRFX=${_lib}/ all; \
2074 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2075 DIRPRFX=${_lib}/ install
2079 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
2080 ${_lib}__L: .PHONY .MAKE
2081 .if exists(${.CURDIR}/${_lib})
2082 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2083 cd ${.CURDIR}/${_lib}; \
2084 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2085 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2086 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2090 # libpam is special: we need to build static PAM modules before
2091 # static PAM library, and dynamic PAM library before dynamic PAM
2093 lib/libpam__L: .PHONY .MAKE
2094 ${_+_}@${ECHODIR} "===> lib/libpam (obj,all,install)"; \
2095 cd ${.CURDIR}/lib/libpam; \
2096 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj; \
2097 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2098 -D_NO_LIBPAM_SO_YET all; \
2099 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2100 -D_NO_LIBPAM_SO_YET 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)
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"
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 \
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"
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}"; \
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"
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
2270 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2272 check-old: check-old-files check-old-libs check-old-dirs
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
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
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
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:
2471 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"