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 # 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}
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
135 .endif # !empty(SUBDIR_OVERRIDE)
138 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
141 .if defined(NO_CLEANDIR)
142 CLEANDIR= clean cleandepend
148 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
150 .if empty(SHELL:M*csh*)
151 BUILDENV_SHELL?=${SHELL}
153 BUILDENV_SHELL?=/bin/sh
156 SVN?= /usr/local/bin/svn
159 MAKEOBJDIRPREFIX?= /usr/obj
160 .if !defined(OSRELDATE)
161 .if exists(/usr/include/osreldate.h)
162 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
163 /usr/include/osreldate.h
170 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
171 .if !defined(VERSION) && !make(showconfig)
172 REVISION!= ${MAKE} -C ${SRCDIR}/release -V REVISION
173 BRANCH!= ${MAKE} -C ${SRCDIR}/release -V BRANCH
174 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
175 ${SRCDIR}/sys/sys/param.h
176 VERSION= FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
180 .if !defined(PKG_VERSION)
181 REVISION!= ${MAKE} -C ${SRCDIR}/release -V REVISION
182 BRANCH!= ${MAKE} -C ${SRCDIR}/release -V BRANCH
183 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
184 ${SRCDIR}/sys/sys/param.h
185 .if ${BRANCH:MSTABLE*} || ${BRANCH:MCURRENT*}
186 TIMENOW= %Y%m%d%H%M%S
187 EXTRA_REVISION= .s${TIMENOW:gmtime}
190 EXTRA_REVISION= _${BRANCH:C/.*-p([0-9]+$)/\1/}
192 PKG_VERSION= ${REVISION}${EXTRA_REVISION}
195 KNOWN_ARCHES?= aarch64/arm64 \
214 .if ${TARGET} == ${TARGET_ARCH}
217 _t= ${TARGET_ARCH}/${TARGET}
220 .if empty(KNOWN_ARCHES:M${_t})
221 .error Unknown target ${TARGET_ARCH}:${TARGET}.
225 .if ${TARGET} == ${MACHINE}
226 TARGET_CPUTYPE?=${CPUTYPE}
231 .if !empty(TARGET_CPUTYPE)
232 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
234 _TARGET_CPUTYPE=dummy
236 # Skip for showconfig as it is just wasted time and may invoke auto.obj.mk.
237 .if !make(showconfig)
238 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
239 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
240 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
241 .error CPUTYPE global should be set with ?=.
245 BUILD_ARCH!= uname -p
246 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
247 .error To cross-build, set TARGET_ARCH.
250 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
251 OBJTREE= ${MAKEOBJDIRPREFIX}
253 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
255 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
256 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
257 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
258 STRICTTMPPATH= ${BPATH}:${XPATH}
259 TMPPATH= ${STRICTTMPPATH}:${PATH}
262 # Avoid running mktemp(1) unless actually needed.
263 # It may not be functional, e.g., due to new ABI
264 # when in the middle of installing over this system.
266 .if make(distributeworld) || make(installworld) || make(stageworld)
267 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
271 # Building a world goes through the following stages
273 # 1. legacy stage [BMAKE]
274 # This stage is responsible for creating compatibility
275 # shims that are needed by the bootstrap-tools,
276 # build-tools and cross-tools stages. These are generally
277 # APIs that tools from one of those three stages need to
278 # build that aren't present on the host.
279 # 1. bootstrap-tools stage [BMAKE]
280 # This stage is responsible for creating programs that
281 # are needed for backward compatibility reasons. They
282 # are not built as cross-tools.
283 # 2. build-tools stage [TMAKE]
284 # This stage is responsible for creating the object
285 # tree and building any tools that are needed during
286 # the build process. Some programs are listed during
287 # this phase because they build binaries to generate
288 # files needed to build these programs. This stage also
289 # builds the 'build-tools' target rather than 'all'.
290 # 3. cross-tools stage [XMAKE]
291 # This stage is responsible for creating any tools that
292 # are needed for building the system. A cross-compiler is one
293 # of them. This differs from build tools in two ways:
294 # 1. the 'all' target is built rather than 'build-tools'
295 # 2. these tools are installed into TMPPATH for stage 4.
296 # 4. world stage [WMAKE]
297 # This stage actually builds the world.
298 # 5. install stage (optional) [IMAKE]
299 # This stage installs a previously built world.
304 # Common environment for world related stages
305 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
306 MACHINE_ARCH=${TARGET_ARCH} \
308 CPUTYPE=${TARGET_CPUTYPE}
309 .if ${MK_GROFF} != "no"
310 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
311 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
312 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
314 .if defined(TARGET_CFLAGS)
315 CROSSENV+= ${TARGET_CFLAGS}
318 # bootstrap-tools stage
319 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
320 PATH=${BPATH}:${PATH} \
321 WORLDTMP=${WORLDTMP} \
322 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
323 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
325 BOOTSTRAPPING=${OSRELDATE} \
327 MK_HTML=no NO_LINT=yes MK_MAN=no \
328 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
329 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
330 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
331 MK_LLDB=no MK_TESTS=no \
334 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
335 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
339 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
340 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
341 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
343 BOOTSTRAPPING=${OSRELDATE} \
346 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
347 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
348 MK_LLDB=no MK_TESTS=no
351 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
352 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
353 MK_GDB=no MK_TESTS=no
356 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
357 PATH=${BPATH}:${PATH} \
359 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
360 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
362 BOOTSTRAPPING=${OSRELDATE} \
364 MK_HTML=no -DNO_LINT MK_MAN=no \
365 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
366 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
369 WMAKEENV= ${CROSSENV} \
371 INSTALL="sh ${.CURDIR}/tools/install.sh" \
375 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
377 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
380 .if defined(CROSS_TOOLCHAIN_PREFIX)
381 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
382 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
385 # If we do not have a bootstrap binutils (because the in-tree one does not
386 # support the target architecture), provide a default cross-binutils prefix.
387 # This allows aarch64 builds, for example, to automatically use the
388 # aarch64-binutils port or package.
389 .if !make(showconfig)
390 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
391 !defined(CROSS_BINUTILS_PREFIX)
392 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
393 .if !exists(${CROSS_BINUTILS_PREFIX})
394 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
399 XCOMPILERS= CC CXX CPP
400 .for COMPILER in ${XCOMPILERS}
401 .if defined(CROSS_COMPILER_PREFIX)
402 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
404 X${COMPILER}?= ${${COMPILER}}
407 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
408 .for BINUTIL in ${XBINUTILS}
409 .if defined(CROSS_BINUTILS_PREFIX) && \
410 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
411 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
413 X${BINUTIL}?= ${${BINUTIL}}
416 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
417 DEPFLAGS="${DEPFLAGS}" \
418 CPP="${XCPP} ${XCFLAGS}" \
419 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
420 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
421 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
424 .if ${XCC:N${CCACHE_BIN}:M/*}
425 .if defined(CROSS_BINUTILS_PREFIX)
426 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
427 # directory, but the compiler will look in the right place for it's
428 # tools so we don't need to tell it where to look.
429 .if exists(${CROSS_BINUTILS_PREFIX})
430 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
433 BFLAGS+= -B${WORLDTMP}/usr/bin
435 .if ${TARGET} == "arm"
436 .if ${TARGET_ARCH:M*hf*} != ""
437 TARGET_ABI= gnueabihf
442 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
443 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
444 XCXXFLAGS+= -I${WORLDTMP}/usr/include/c++/v1 -std=gnu++11 -L${WORLDTMP}/../lib/libc++
445 # XXX: DEPFLAGS is a workaround for not properly passing CXXFLAGS to sub-makes
446 # due to CXX="${XCXX} ${XCXXFLAGS}". bsd.dep.mk does use CXXFLAGS when
447 # building C++ files so this can come out if passing CXXFLAGS down is fixed.
448 DEPFLAGS+= -I${WORLDTMP}/usr/include/c++/v1
451 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
452 XCFLAGS+= -target ${TARGET_TRIPLE}
454 XCFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
455 XCXXFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
457 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
458 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
460 XCXXFLAGS+= ${BFLAGS}
464 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
466 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
468 LIB32_OBJTREE= ${OBJTREE}${.CURDIR}/world32
469 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
471 .if ${TARGET_ARCH} == "amd64"
472 .if empty(TARGET_CPUTYPE)
473 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
475 LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
477 LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
478 MACHINE_CPU="i686 mmx sse sse2"
481 LD="${XLD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
482 OBJCOPY="${XOBJCOPY}"
484 .elif ${TARGET_ARCH} == "powerpc64"
485 .if empty(TARGET_CPUTYPE)
486 LIB32CPUFLAGS= -mcpu=powerpc
488 LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
490 LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
492 LD="${XLD} -m elf32ppc_fbsd" \
493 OBJCOPY="${XOBJCOPY}"
497 LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
498 -isystem ${LIB32TMP}/usr/include/ \
499 -L${LIB32TMP}/usr/lib32 \
500 -B${LIB32TMP}/usr/lib32
501 .if ${XCC:N${CCACHE_BIN}:M/*}
502 LIB32FLAGS+= --sysroot=${WORLDTMP}
505 # Yes, the flags are redundant.
506 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${LIB32_OBJTREE} \
507 _LDSCRIPTROOT=${LIB32TMP} \
508 INSTALL="sh ${.CURDIR}/tools/install.sh" \
511 SHLIBDIR=/usr/lib32 \
512 DTRACE="${DTRACE} -32"
513 LIB32WMAKEFLAGS+= CC="${XCC} ${LIB32FLAGS}" \
514 CXX="${XCXX} ${LIB32FLAGS}" \
515 DESTDIR=${LIB32TMP} \
523 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
525 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \
526 MK_TOOLCHAIN=no ${IMAKE_INSTALL}
529 IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*}
530 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
531 ${IMAKE_INSTALL} ${IMAKE_MTREE}
532 .if empty(.MAKEFLAGS:M-n)
533 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
534 LD_LIBRARY_PATH=${INSTALLTMP} \
535 PATH_LOCALE=${INSTALLTMP}/locale
536 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
538 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
540 .if defined(DB_FROM_SRC)
541 INSTALLFLAGS+= -N ${.CURDIR}/etc
542 MTREEFLAGS+= -N ${.CURDIR}/etc
544 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
545 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
547 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
548 IMAKE+= -DNO_ROOT METALOG=${METALOG}
549 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
552 .if defined(BUILD_PKGS)
553 INSTALLFLAGS+= -h sha256
555 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
556 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
557 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
561 KMAKEENV= ${WMAKEENV}
562 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
567 # Attempt to rebuild the entire system, with reasonable chance of
568 # success, regardless of how old your existing system is.
571 .if ${.CURDIR:C/[^,]//g} != ""
572 # The m4 build of sendmail files doesn't like it if ',' is used
573 # anywhere in the path of it's files.
575 @echo "*** Error: path to source tree contains a comma ','"
580 @echo "--------------------------------------------------------------"
581 @echo ">>> Rebuilding the temporary build tree"
582 @echo "--------------------------------------------------------------"
583 .if !defined(NO_CLEAN)
585 .if defined(LIB32TMP)
589 rm -rf ${WORLDTMP}/legacy/usr/include
590 # XXX - These three can depend on any header file.
591 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
592 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
593 rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
596 lib usr legacy/bin legacy/usr
597 mkdir -p ${WORLDTMP}/${_dir}
599 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
600 -p ${WORLDTMP}/legacy/usr >/dev/null
601 .if ${MK_GROFF} != "no"
602 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
603 -p ${WORLDTMP}/legacy/usr >/dev/null
605 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
606 -p ${WORLDTMP}/usr >/dev/null
607 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
608 -p ${WORLDTMP}/usr/include >/dev/null
609 ln -sf ${.CURDIR}/sys ${WORLDTMP}
610 .if ${MK_DEBUG_FILES} != "no"
611 # We could instead disable debug files for these build stages
612 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
613 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
614 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
615 -p ${WORLDTMP}/usr/lib >/dev/null
617 .if ${MK_LIB32} != "no"
618 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
619 -p ${WORLDTMP}/usr >/dev/null
620 .if ${MK_DEBUG_FILES} != "no"
621 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
622 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
623 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
624 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
627 .if ${MK_TESTS} != "no"
628 mkdir -p ${WORLDTMP}${TESTSBASE}
629 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
630 -p ${WORLDTMP}${TESTSBASE} >/dev/null
631 .if ${MK_DEBUG_FILES} != "no"
632 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
633 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
634 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
637 .for _mtree in ${LOCAL_MTREE}
638 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
642 @echo "--------------------------------------------------------------"
643 @echo ">>> stage 1.1: legacy release compatibility shims"
644 @echo "--------------------------------------------------------------"
645 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
648 @echo "--------------------------------------------------------------"
649 @echo ">>> stage 1.2: bootstrap tools"
650 @echo "--------------------------------------------------------------"
651 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
653 .if !defined(NO_CLEAN)
655 @echo "--------------------------------------------------------------"
656 @echo ">>> stage 2.1: cleaning up the object tree"
657 @echo "--------------------------------------------------------------"
658 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
659 .if defined(LIB32TMP)
660 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR}
665 @echo "--------------------------------------------------------------"
666 @echo ">>> stage 2.2: rebuilding the object tree"
667 @echo "--------------------------------------------------------------"
668 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
671 @echo "--------------------------------------------------------------"
672 @echo ">>> stage 2.3: build tools"
673 @echo "--------------------------------------------------------------"
674 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
677 @echo "--------------------------------------------------------------"
678 @echo ">>> stage 3: cross tools"
679 @echo "--------------------------------------------------------------"
680 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
681 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
684 @echo "--------------------------------------------------------------"
685 @echo ">>> stage 4.1: building includes"
686 @echo "--------------------------------------------------------------"
687 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
688 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
689 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
691 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
692 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks includes
696 @echo "--------------------------------------------------------------"
697 @echo ">>> stage 4.2: building libraries"
698 @echo "--------------------------------------------------------------"
699 ${_+_}cd ${.CURDIR}; \
700 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
701 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
704 @echo "--------------------------------------------------------------"
705 @echo ">>> stage 4.3: make dependencies"
706 @echo "--------------------------------------------------------------"
707 ${_+_}cd ${.CURDIR}; ${WMAKE} depend
710 @echo "--------------------------------------------------------------"
711 @echo ">>> stage 4.4: building everything"
712 @echo "--------------------------------------------------------------"
713 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
714 .if defined(LIB32TMP)
717 @echo "--------------------------------------------------------------"
718 @echo ">>> stage 5.1: building 32 bit shim libraries"
719 @echo "--------------------------------------------------------------"
720 mkdir -p ${LIB32TMP}/usr/include
721 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
722 -p ${LIB32TMP}/usr >/dev/null
723 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
724 -p ${LIB32TMP}/usr/include >/dev/null
725 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
726 -p ${LIB32TMP}/usr >/dev/null
727 .if ${MK_DEBUG_FILES} != "no"
728 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
729 -p ${LIB32TMP}/usr/lib >/dev/null
730 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
731 -p ${LIB32TMP}/usr/lib/debug/usr >/dev/null
734 ln -sf ${.CURDIR}/sys ${WORLDTMP}
735 .for _t in obj includes
736 ${_+_}cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
737 ${_+_}cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
738 .if ${MK_CDDL} != "no"
739 ${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
741 ${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
742 .if ${MK_CRYPT} != "no"
743 ${_+_}cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
745 .if ${MK_KERBEROS} != "no"
746 ${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
749 .for _dir in usr.bin/lex/lib
750 ${_+_}cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
752 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
753 ${_+_}cd ${.CURDIR}/${_dir}; \
754 WORLDTMP=${WORLDTMP} \
755 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
756 MAKEOBJDIRPREFIX=${LIB32_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \
757 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
760 ${_+_}cd ${.CURDIR}; \
761 ${LIB32WMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
762 .for _t in obj depend all
763 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
764 -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t}
765 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
766 DIRPRFX=usr.bin/ldd ${_t}
769 distribute32 install32: .MAKE .PHONY
770 ${_+_}cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
771 .if ${MK_CDDL} != "no"
772 ${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
774 ${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
775 .if ${MK_CRYPT} != "no"
776 ${_+_}cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
778 .if ${MK_KERBEROS} != "no"
779 ${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
781 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \
782 PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
783 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} \
788 WMAKE_TGTS+= _worldtmp _legacy
789 .if empty(SUBDIR_OVERRIDE)
790 WMAKE_TGTS+= _bootstrap-tools
792 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
793 WMAKE_TGTS+= _includes _libraries _depend everything
794 .if defined(LIB32TMP) && ${MK_LIB32} != "no" && empty(SUBDIR_OVERRIDE)
798 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
799 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
802 @echo "--------------------------------------------------------------"
803 @echo ">>> World build started on `LC_ALL=C date`"
804 @echo "--------------------------------------------------------------"
808 @echo "--------------------------------------------------------------"
809 @echo ">>> World build completed on `LC_ALL=C date`"
810 @echo "--------------------------------------------------------------"
813 # We need to have this as a target because the indirection between Makefile
814 # and Makefile.inc1 causes the correct PATH to be used, rather than a
815 # modification of the current environment's PATH. In addition, we need
816 # to quote multiword values.
819 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
821 .if ${.TARGETS:Mbuildenv}
822 .if ${.MAKEFLAGS:M-j}
823 .error The buildenv target is incompatible with -j
826 BUILDENV_DIR?= ${.CURDIR}
828 @echo Entering world for ${TARGET_ARCH}:${TARGET}
829 .if ${BUILDENV_SHELL:M*zsh*}
830 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
832 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
835 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
836 toolchain: ${TOOLCHAIN_TGTS}
837 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
842 # Checks to be sure system is ready for installworld/installkernel.
844 installcheck: _installcheck_world _installcheck_kernel
846 _installcheck_kernel:
849 # Require DESTDIR to be set if installing for a different architecture or
850 # using the user/group database in the source tree.
852 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
854 .if !make(distributeworld)
855 _installcheck_world: __installcheck_DESTDIR
856 _installcheck_kernel: __installcheck_DESTDIR
857 __installcheck_DESTDIR:
858 .if !defined(DESTDIR) || empty(DESTDIR)
859 @echo "ERROR: Please set DESTDIR!"; \
865 .if !defined(DB_FROM_SRC)
867 # Check for missing UIDs/GIDs.
869 CHECK_UIDS= auditdistd
871 .if ${MK_SENDMAIL} != "no"
877 CHECK_GIDS+= proxy authpf
879 .if ${MK_UNBOUND} != "no"
883 _installcheck_world: __installcheck_UGID
885 .for uid in ${CHECK_UIDS}
886 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
887 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
891 .for gid in ${CHECK_GIDS}
892 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
893 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
900 # Required install tools to be saved in a scratch dir for safety.
902 .if ${MK_ZONEINFO} != "no"
903 _zoneinfo= zic tzsetup
906 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
907 date echo egrep find grep id install ${_install-info} \
908 ln make mkdir mtree mv pwd_mkdb \
909 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
912 # Needed for share/man
913 .if ${MK_MAN} != "no"
920 # Distributes everything compiled by a `buildworld'.
924 # Installs everything compiled by a 'buildworld'.
927 # Non-base distributions produced by the base system
928 EXTRA_DISTRIBUTIONS= doc
929 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
930 EXTRA_DISTRIBUTIONS+= lib32
932 .if ${MK_TESTS} != "no"
933 EXTRA_DISTRIBUTIONS+= tests
937 .if ${MK_DEBUG_FILES} != "no"
938 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
941 MTREE_MAGIC?= mtree 2.0
943 distributeworld installworld stageworld: _installcheck_world
944 mkdir -p ${INSTALLTMP}
945 progs=$$(for prog in ${ITOOLS}; do \
946 if progpath=`which $$prog`; then \
949 echo "Required tool $$prog not found in PATH." >&2; \
953 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
954 while read line; do \
956 if [ "$$2 $$3" != "not found" ]; then \
959 echo "Required library $$1 not found." >&2; \
963 cp $$libs $$progs ${INSTALLTMP}
964 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
966 echo "#${MTREE_MAGIC}" > ${METALOG}
968 .if make(distributeworld)
969 .for dist in ${EXTRA_DISTRIBUTIONS}
970 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
971 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
972 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
973 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
974 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
975 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
976 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
977 .if ${MK_DEBUG_FILES} != "no"
978 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
979 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
981 .if ${MK_LIB32} != "no"
982 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
983 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
984 .if ${MK_DEBUG_FILES} != "no"
985 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
986 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
989 .if ${MK_TESTS} != "no" && ${dist} == "tests"
990 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
991 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
992 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
993 .if ${MK_DEBUG_FILES} != "no"
994 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
995 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
999 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1000 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1001 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1002 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1003 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1004 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1005 .if ${MK_LIB32} != "no"
1006 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib32.dist | \
1007 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1011 -mkdir ${DESTDIR}/${DISTDIR}/base
1012 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1013 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1014 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1015 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1017 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1018 ${IMAKEENV} rm -rf ${INSTALLTMP}
1019 .if make(distributeworld)
1020 .for dist in ${EXTRA_DISTRIBUTIONS}
1021 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
1023 .if defined(NO_ROOT)
1024 .for dist in base ${EXTRA_DISTRIBUTIONS}
1025 @# For each file that exists in this dist, print the corresponding
1026 @# line from the METALOG. This relies on the fact that
1027 @# a line containing only the filename will sort immediatly before
1028 @# the relevant mtree line.
1029 cd ${DESTDIR}/${DISTDIR}; \
1030 find ./${dist} | sort -u ${METALOG} - | \
1031 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1032 ${DESTDIR}/${DISTDIR}/${dist}.meta
1034 .for dist in ${DEBUG_DISTRIBUTIONS}
1035 @# For each file that exists in this dist, print the corresponding
1036 @# line from the METALOG. This relies on the fact that
1037 @# a line containing only the filename will sort immediatly before
1038 @# the relevant mtree line.
1039 cd ${DESTDIR}/${DISTDIR}; \
1040 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1041 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1042 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1048 .for dist in base ${EXTRA_DISTRIBUTIONS}
1049 .if defined(NO_ROOT)
1050 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1051 tar cvf - --exclude usr/lib/debug \
1052 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1053 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1055 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1056 tar cvf - --exclude usr/lib/debug . | \
1057 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1061 .for dist in ${DEBUG_DISTRIBUTIONS}
1062 . if defined(NO_ROOT)
1063 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1064 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1065 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1067 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1068 tar cvLf - usr/lib/debug | \
1069 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1076 # If you have a build server, you can NFS mount the source and obj directories
1077 # and do a 'make reinstall' on the *client* to install new binaries from the
1078 # most recent server build.
1080 reinstall: .MAKE .PHONY
1081 @echo "--------------------------------------------------------------"
1082 @echo ">>> Making hierarchy"
1083 @echo "--------------------------------------------------------------"
1084 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1085 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1087 @echo "--------------------------------------------------------------"
1088 @echo ">>> Installing everything"
1089 @echo "--------------------------------------------------------------"
1090 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1091 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
1092 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
1095 restage: .MAKE .PHONY
1096 @echo "--------------------------------------------------------------"
1097 @echo ">>> Making hierarchy"
1098 @echo "--------------------------------------------------------------"
1099 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1100 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy distribution
1102 @echo "--------------------------------------------------------------"
1103 @echo ">>> Installing everything"
1104 @echo "--------------------------------------------------------------"
1105 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1106 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
1107 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
1110 redistribute: .MAKE .PHONY
1111 @echo "--------------------------------------------------------------"
1112 @echo ">>> Distributing everything"
1113 @echo "--------------------------------------------------------------"
1114 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1115 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
1116 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
1120 distrib-dirs: .MAKE .PHONY
1121 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1122 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1124 distribution: .MAKE .PHONY
1125 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1126 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1127 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1128 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1129 METALOG=${METALOG} installconfig
1132 # buildkernel and installkernel
1134 # Which kernels to build and/or install is specified by setting
1135 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1136 # Only the existing (depending TARGET) config files are used
1137 # for building kernels and only the first of these is designated
1138 # as the one being installed.
1140 # Note that we have to use TARGET instead of TARGET_ARCH when
1141 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1142 # be set to cross-build, we have to make sure TARGET is set
1145 .if defined(KERNFAST)
1150 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1151 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1152 KERNCONF=${KERNFAST}
1155 .if ${TARGET_ARCH} == "powerpc64"
1156 KERNCONF?= GENERIC64
1160 INSTKERNNAME?= kernel
1162 KERNSRCDIR?= ${.CURDIR}/sys
1163 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1164 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1165 KERNCONFDIR?= ${KRNLCONFDIR}
1169 .if defined(NO_INSTALLKERNEL)
1170 # All of the BUILDKERNELS loops start at index 1.
1171 BUILDKERNELS+= dummy
1173 .for _kernel in ${KERNCONF}
1174 .if exists(${KERNCONFDIR}/${_kernel})
1175 BUILDKERNELS+= ${_kernel}
1176 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1177 INSTALLKERNEL= ${_kernel}
1182 ${WMAKE_TGTS:N_worldtmp:Nbuild32} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1187 # Builds all kernels defined by BUILDKERNELS.
1189 buildkernel: .MAKE .PHONY
1190 .if empty(BUILDKERNELS:Ndummy)
1191 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1195 .for _kernel in ${BUILDKERNELS:Ndummy}
1196 @echo "--------------------------------------------------------------"
1197 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1198 @echo "--------------------------------------------------------------"
1199 @echo "===> ${_kernel}"
1200 mkdir -p ${KRNLOBJDIR}
1201 .if !defined(NO_KERNELCONFIG)
1203 @echo "--------------------------------------------------------------"
1204 @echo ">>> stage 1: configuring the kernel"
1205 @echo "--------------------------------------------------------------"
1206 cd ${KRNLCONFDIR}; \
1208 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1209 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1211 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1213 @echo "--------------------------------------------------------------"
1214 @echo ">>> stage 2.1: cleaning up the object tree"
1215 @echo "--------------------------------------------------------------"
1216 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1218 .if !defined(NO_KERNELOBJ)
1220 @echo "--------------------------------------------------------------"
1221 @echo ">>> stage 2.2: rebuilding the object tree"
1222 @echo "--------------------------------------------------------------"
1223 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1226 @echo "--------------------------------------------------------------"
1227 @echo ">>> stage 2.3: build tools"
1228 @echo "--------------------------------------------------------------"
1229 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1230 .if !defined(NO_KERNELDEPEND)
1232 @echo "--------------------------------------------------------------"
1233 @echo ">>> stage 3.1: making dependencies"
1234 @echo "--------------------------------------------------------------"
1235 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
1238 @echo "--------------------------------------------------------------"
1239 @echo ">>> stage 3.2: building everything"
1240 @echo "--------------------------------------------------------------"
1241 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1242 @echo "--------------------------------------------------------------"
1243 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1244 @echo "--------------------------------------------------------------"
1248 # installkernel, etc.
1250 # Install the kernel defined by INSTALLKERNEL
1252 installkernel installkernel.debug \
1253 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1254 .if !defined(NO_INSTALLKERNEL)
1255 .if empty(INSTALLKERNEL)
1256 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1259 @echo "--------------------------------------------------------------"
1260 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1261 @echo "--------------------------------------------------------------"
1262 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1263 ${CROSSENV} PATH=${TMPPATH} \
1264 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1266 .if ${BUILDKERNELS:[#]} > 1
1267 .for _kernel in ${BUILDKERNELS:[2..-1]}
1268 @echo "--------------------------------------------------------------"
1269 @echo ">>> Installing kernel ${_kernel}"
1270 @echo "--------------------------------------------------------------"
1271 cd ${KRNLOBJDIR}/${_kernel}; \
1272 ${CROSSENV} PATH=${TMPPATH} \
1273 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1277 distributekernel distributekernel.debug:
1278 .if !defined(NO_INSTALLKERNEL)
1279 .if empty(INSTALLKERNEL)
1280 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1283 mkdir -p ${DESTDIR}/${DISTDIR}
1284 .if defined(NO_ROOT)
1285 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1287 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1288 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1289 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1290 DESTDIR=${INSTALL_DDIR}/kernel \
1291 ${.TARGET:S/distributekernel/install/}
1292 .if defined(NO_ROOT)
1293 sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1294 ${DESTDIR}/${DISTDIR}/kernel.meta
1297 .if ${BUILDKERNELS:[#]} > 1
1298 .for _kernel in ${BUILDKERNELS:[2..-1]}
1299 .if defined(NO_ROOT)
1300 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1302 cd ${KRNLOBJDIR}/${_kernel}; \
1303 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1304 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1305 KERNEL=${INSTKERNNAME}.${_kernel} \
1306 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1307 ${.TARGET:S/distributekernel/install/}
1308 .if defined(NO_ROOT)
1309 sed -e 's|^./kernel|.|' \
1310 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1311 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1317 .if defined(NO_ROOT)
1318 .if !defined(NO_INSTALLKERNEL)
1319 cd ${DESTDIR}/${DISTDIR}/kernel; \
1320 tar cvf - @${DESTDIR}/${DISTDIR}/kernel.meta | \
1321 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1323 .if ${BUILDKERNELS:[#]} > 1
1324 .for _kernel in ${BUILDKERNELS:[2..-1]}
1325 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1326 tar cvf - @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1327 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1331 .if !defined(NO_INSTALLKERNEL)
1332 cd ${DESTDIR}/${DISTDIR}/kernel; \
1334 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1336 .if ${BUILDKERNELS:[#]} > 1
1337 .for _kernel in ${BUILDKERNELS:[2..-1]}
1338 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1340 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1345 create-world-packages:
1346 @rm -f ${DESTDIR}/*.plist 2>/dev/null || :
1348 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1350 @for plist in ${DESTDIR}/*.plist; do \
1351 plist=$${plist##*/} ; \
1352 test -f ${SRCDIR}/release/packages/$${plist%.plist}.ucl || \
1353 ( echo "Unkown package FreeBSD-$${plist%.plist}" ; false ) ; \
1355 @cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1356 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1357 for plist in ${DESTDIR}/*.plist; do \
1358 plist=$${plist##*/} ; \
1359 pkgname=$${plist%.plist} ; \
1360 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1361 -e "s/%PKGNAME%/$${pkgname}/" \
1362 -e "s/%COMMENT%/Generic comment for $${pkgname}/" \
1363 -e "s/%DESC%/Generic description for $${pkgname}/" \
1364 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1365 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1366 ${SRCDIR}/release/packages/$${pkgname}.ucl \
1367 > ${DESTDIR}/$${pkgname}.ucl ; \
1369 /^name/ { printf("===> Creating %s-", $$2); next } \
1370 /^version/ { print $$2; next } \
1371 ' ${DESTDIR}/$${pkgname}.ucl ; \
1372 pkg -o ABI_FILE=${DESTDIR}/bin/sh \
1373 create -M ${DESTDIR}/$${pkgname}.ucl \
1374 -p ${DESTDIR}/$${pkgname}.plist \
1375 -r ${DESTDIR} -o ${DESTDIR} ; \
1378 STAGEDIR= ${MAKEOBJDIRPREFIX}${.CURDIR}/stage
1381 @mkdir -p ${MAKEOBJDIRPREFIX}${.CURDIR}/stage
1382 ${_+_}@cd ${.CURDIR}; \
1383 ${MAKE} ${.MAKEFLAGS} buildworld ; \
1384 ${MAKE} DESTDIR=${DESTDIR:U${STAGEDIR}} -DNO_ROOT -B stageworld ; \
1385 ${MAKE} DESTDIR=${DESTDIR:U${STAGEDIR}} create-world-packages
1387 create-kernel-packages:
1388 .if !defined(NO_ROOT)
1389 @echo "ERROR: create-kernel-packages can only be done with -DNO_ROOT"; \
1392 @cd ${DESTDIR}/${DISTDIR} ; \
1393 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1394 ${DESTDIR}/${DISTDIR}/kernel.meta
1395 .for flavor in release debug
1396 .if exists(${DESTDIR}/${DISTDIR}/${flavor}.plist)
1397 @rm -rf ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir
1398 @cp -r ${SRCDIR}/release/packages/kernel \
1399 ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir
1400 @cd ${DESTDIR}/${DISTDIR} ; \
1401 sed -i '' -e "s/%VERSION%/${PKG_VERSION}/" \
1402 -e "s/%PKGNAME%/kernel-${flavor}/" \
1403 -e "s/%COMMENT%/FreeBSD ${KERNCONF} kernel ${flavor}/" \
1404 -e "s/%DESC%/FreeBSD ${KERNCONF} kernel ${flavor}/" \
1405 ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir/+MANIFEST
1406 @awk -F\" '/name/ { printf("===> Creating %s-", $$2) } /version/ {print $$2 }' \
1407 ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir/+MANIFEST
1408 @pkg create -m ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir \
1409 -p ${DESTDIR}/${DISTDIR}/${flavor}.plist \
1410 -r ${DESTDIR}/${DISTDIR}/kernel \
1414 .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
1415 @cd ${DESTDIR}/${DISTDIR} ; \
1416 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1417 ${DESTDIR}/${DISTDIR}/kernel${_kernel}.meta
1418 .for flavor in release debug
1419 .if exists(${DESTDIR}/${DISTDIR}/${flavor}.plist)
1420 @rm -rf ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir
1421 @cp -r ${SRCDIR}/release/packages/kernel \
1422 ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir
1423 @cd ${DESTDIR}/${DISTDIR} ; \
1424 sed -i '' -e "s/%VERSION%/${PKG_VERSION}/" \
1425 -e "s/%PKGNAME%/kernel-${flavor}/" \
1426 -e "s/%COMMENT%/FreeBSD ${KERNCONF} kernel ${flavor}/" \
1427 -e "s/%DESC%/FreeBSD ${KERNCONF} kernel ${flavor}/" \
1428 ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir/+MANIFEST
1429 @awk -F\" '/name/ { printf("===> Creating %s-", $$2) } /version/ {print $$2 }' \
1430 ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir/+MANIFEST
1431 @pkg create -m ${DESTDIR}/${DISTDIR}/${flavor}-manifestdir \
1432 -p ${DESTDIR}/${DISTDIR}/${flavor}.plist \
1433 -r ${DESTDIR}/${DISTDIR}/kernel.${_kernel} \
1442 # Build the API documentation with doxygen
1445 @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1446 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1449 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1454 # Update the source tree(s), by running svn/svnup to update to the
1458 .if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1459 @echo "--------------------------------------------------------------"
1460 @echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1461 @echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1462 @echo "--------------------------------------------------------------"
1465 .if defined(SVN_UPDATE)
1466 @echo "--------------------------------------------------------------"
1467 @echo ">>> Updating ${.CURDIR} using Subversion"
1468 @echo "--------------------------------------------------------------"
1469 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1473 # ------------------------------------------------------------------------
1475 # From here onwards are utility targets used by the 'make world' and
1476 # related targets. If your 'world' breaks, you may like to try to fix
1477 # the problem and manually run the following targets to attempt to
1478 # complete the build. Beware, this is *not* guaranteed to work, you
1479 # need to have a pretty good grip on the current state of the system
1480 # to attempt to manually finish it. If in doubt, 'make world' again.
1484 # legacy: Build compatibility shims for the next three targets. This is a
1485 # minimal set of tools and shims necessary to compensate for older systems
1486 # which don't have the APIs required by the targets built in bootstrap-tools,
1487 # build-tools or cross-tools.
1490 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1491 .if ${BOOTSTRAPPING} < 1100006
1492 _elftoolchain_libs= lib/libelf lib/libdwarf
1496 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1497 @echo "ERROR: Source upgrades from versions prior to 8.0 are not supported."; \
1500 .for _tool in tools/build ${_elftoolchain_libs}
1501 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1502 cd ${.CURDIR}/${_tool}; \
1503 ${MAKE} DIRPRFX=${_tool}/ obj; \
1504 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1505 ${MAKE} DIRPRFX=${_tool}/ depend; \
1506 ${MAKE} DIRPRFX=${_tool}/ all; \
1507 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1511 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1512 # are built to build other binaries in the system. However, the focus of these
1513 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1514 # libraries, augmented by -legacy.
1516 _bt= _bootstrap-tools
1518 .if ${MK_GAMES} != "no"
1519 _strfile= usr.bin/fortune/strfile
1522 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1523 _gperf= gnu/usr.bin/gperf
1526 .if ${MK_GROFF} != "no"
1527 _groff= gnu/usr.bin/groff \
1531 .if ${MK_VT} != "no"
1532 _vtfontcvt= usr.bin/vtfontcvt
1535 .if ${BOOTSTRAPPING} < 900002
1539 .if ${BOOTSTRAPPING} < 1000002
1540 _libopenbsd= lib/libopenbsd
1543 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1546 .if ${BOOTSTRAPPING} < 1000026
1547 _nmtree= lib/libnetbsd \
1550 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1553 .if ${BOOTSTRAPPING} < 1000027
1557 .if ${BOOTSTRAPPING} < 1000033
1560 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1563 # r277259 crunchide: Correct 64-bit section header offset
1564 # r281674 crunchide: always include both 32- and 64-bit ELF support
1565 # r285986 crunchen: use STRIPBIN rather than STRIP
1566 .if ${BOOTSTRAPPING} < 1100078
1567 _crunch= usr.sbin/crunch
1570 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1577 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1579 .if ${MK_BSNMP} != "no"
1580 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1583 # We need to build tblgen when we're building clang either as
1584 # the bootstrap compiler, or as the part of the normal build.
1585 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1587 lib/clang/libllvmsupport \
1588 lib/clang/libllvmtablegen \
1589 usr.bin/clang/tblgen \
1590 usr.bin/clang/clang-tblgen
1592 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1593 ${_bt}-usr.bin/clang/tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1596 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1599 .if ${MK_GPL_DTC} != "no"
1600 _dtc= gnu/usr.bin/dtc
1603 .if ${MK_KERBEROS} != "no"
1604 _kerberos5_bootstrap_tools= \
1605 kerberos5/tools/make-roken \
1606 kerberos5/lib/libroken \
1607 kerberos5/lib/libvers \
1608 kerberos5/tools/asn1_compile \
1609 kerberos5/tools/slc \
1612 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1615 .if ${MK_MANDOCDB} != "no"
1616 _libopenbsd?= lib/libopenbsd
1617 _makewhatis= lib/libsqlite3 \
1619 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1621 _makewhatis=usr.bin/makewhatis
1624 bootstrap-tools: .PHONY
1626 # Please document (add comment) why something is in 'bootstrap-tools'.
1627 # Try to bound the building of the bootstrap-tool to just the
1628 # FreeBSD versions that need the tool built at this stage of the build.
1631 ${_kerberos5_bootstrap_tools} \
1653 ${_bt}-${_tool}: .PHONY .MAKE
1654 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1655 cd ${.CURDIR}/${_tool}; \
1656 ${MAKE} DIRPRFX=${_tool}/ obj; \
1657 ${MAKE} DIRPRFX=${_tool}/ depend; \
1658 ${MAKE} DIRPRFX=${_tool}/ all; \
1659 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1661 bootstrap-tools: ${_bt}-${_tool}
1665 # build-tools: Build special purpose build tools
1667 .if !defined(NO_SHARE)
1668 _share= share/syscons/scrnmaps
1671 .if ${MK_GCC} != "no"
1672 _gcc_tools= gnu/usr.bin/cc/cc_tools
1675 .if ${MK_RESCUE} != "no"
1676 # rescue includes programs that have build-tools targets
1677 _rescue=rescue/rescue
1683 ${LOCAL_TOOL_DIRS} \
1684 lib/ncurses/ncurses \
1685 lib/ncurses/ncursesw \
1690 usr.bin/mkesdb_static \
1691 usr.bin/mkcsmapper_static \
1693 build-tools_${_tool}: .PHONY
1694 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1695 cd ${.CURDIR}/${_tool}; \
1696 ${MAKE} DIRPRFX=${_tool}/ obj; \
1697 ${MAKE} DIRPRFX=${_tool}/ build-tools
1698 build-tools: build-tools_${_tool}
1702 build-tools_${_tool}: .PHONY
1703 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1704 cd ${.CURDIR}/${_tool}; \
1705 ${MAKE} DIRPRFX=${_tool}/ obj; \
1706 ${MAKE} DIRPRFX=${_tool}/ depend; \
1707 ${MAKE} DIRPRFX=${_tool}/ all
1708 build-tools: build-tools_${_tool}
1712 # kernel-tools: Build kernel-building tools
1715 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1716 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1717 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1720 # cross-tools: All the tools needed to build the rest of the system after
1721 # we get done with the earlier stages. It is the last set of tools needed
1722 # to begin building the target binaries.
1724 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1725 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1726 _btxld= usr.sbin/btxld
1730 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1731 # resulting from missing bug fixes or ELF Toolchain updates.
1732 .if ${MK_CDDL} != "no"
1733 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1734 cddl/usr.bin/ctfmerge
1737 # If we're given an XAS, don't build binutils.
1738 .if ${XAS:M/*} == ""
1739 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1740 _binutils= gnu/usr.bin/binutils
1742 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1743 _elftctools= lib/libelftc \
1748 # These are not required by the build, but can be useful for developers who
1749 # cross-build on a FreeBSD 10 host:
1750 _elftctools+= usr.bin/addr2line
1752 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1753 # If cross-building with an external binutils we still need to build strip for
1754 # the target (for at least crunchide).
1755 _elftctools= lib/libelftc \
1759 # If an full path to an external cross compiler is given, don't build
1761 .if ${XCC:N${CCACHE_BIN}:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1762 .if ${MK_CLANG_BOOTSTRAP} != "no"
1763 _clang= usr.bin/clang
1764 _clang_libs= lib/clang
1766 .if ${MK_GCC_BOOTSTRAP} != "no"
1770 .if ${MK_USB} != "no"
1771 _usb_tools= sys/boot/usb/tools
1774 cross-tools: .MAKE .PHONY
1785 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1786 cd ${.CURDIR}/${_tool}; \
1787 ${MAKE} DIRPRFX=${_tool}/ obj; \
1788 ${MAKE} DIRPRFX=${_tool}/ depend; \
1789 ${MAKE} DIRPRFX=${_tool}/ all; \
1790 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1793 NXBDESTDIR= ${OBJTREE}/nxb-bin
1794 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1795 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1796 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1797 NXBMAKE= ${NXBENV} ${MAKE} \
1798 TBLGEN=${NXBDESTDIR}/usr/bin/tblgen \
1799 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1800 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1801 MK_GDB=no MK_TESTS=no \
1803 MK_HTML=no NO_LINT=yes MK_MAN=no \
1804 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1805 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1806 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1807 MK_LLDB=no MK_DEBUG_FILES=no
1809 # native-xtools is the current target for qemu-user cross builds of ports
1810 # via poudriere and the imgact_binmisc kernel module.
1811 # For non-clang enabled targets that are still using the in tree gcc
1812 # we must build a gperf binary for one instance of its Makefiles. On
1813 # clang-enabled systems, the gperf binary is obsolete.
1814 native-xtools: .PHONY
1815 .if ${MK_GCC_BOOTSTRAP} != "no"
1816 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1817 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,depend,all,install)"; \
1818 cd ${.CURDIR}/${_gperf}; \
1819 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1820 ${NXBMAKE} DIRPRFX=${_gperf}/ depend; \
1821 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1822 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1824 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1825 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1826 -p ${NXBDESTDIR}/usr >/dev/null
1827 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1828 -p ${NXBDESTDIR}/usr/include >/dev/null
1829 .if ${MK_DEBUG_FILES} != "no"
1830 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1831 -p ${NXBDESTDIR}/usr/lib >/dev/null
1892 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1893 cd ${.CURDIR}/${_tool}; \
1894 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1895 ${NXBMAKE} DIRPRFX=${_tool}/ depend; \
1896 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1897 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1901 # hierarchy - ensure that all the needed directories are present
1903 hierarchy hier: .MAKE .PHONY
1904 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1907 # libraries - build all libraries, and install them under ${DESTDIR}.
1909 # The list of libraries with dependents (${_prebuild_libs}) and their
1910 # interdependencies (__L) are built automatically by the
1911 # ${.CURDIR}/tools/make_libdeps.sh script.
1913 libraries: .MAKE .PHONY
1914 ${_+_}cd ${.CURDIR}; \
1915 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1916 ${MAKE} -f Makefile.inc1 _startup_libs; \
1917 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1918 ${MAKE} -f Makefile.inc1 _generic_libs
1921 # static libgcc.a prerequisite for shared libc
1923 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1925 # These dependencies are not automatically generated:
1927 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1928 # all shared libraries for ELF.
1930 _startup_libs= gnu/lib/csu
1931 _startup_libs+= lib/csu
1932 _startup_libs+= gnu/lib/libgcc
1933 _startup_libs+= lib/libcompiler_rt
1934 _startup_libs+= lib/libc
1935 _startup_libs+= lib/libc_nonshared
1936 .if ${MK_LIBCPLUSPLUS} != "no"
1937 _startup_libs+= lib/libcxxrt
1940 gnu/lib/libgcc__L: lib/libc__L
1941 gnu/lib/libgcc__L: lib/libc_nonshared__L
1942 .if ${MK_LIBCPLUSPLUS} != "no"
1943 lib/libcxxrt__L: gnu/lib/libgcc__L
1946 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1947 ${_kerberos5_lib_libhdb} \
1948 ${_kerberos5_lib_libheimbase} \
1949 ${_kerberos5_lib_libheimntlm} \
1951 ${_kerberos5_lib_libheimipcc} \
1952 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1953 ${_kerberos5_lib_libroken} \
1954 ${_kerberos5_lib_libwind} \
1955 lib/libbz2 ${_libcom_err} lib/libcrypt \
1956 lib/libelf lib/libexpat \
1959 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1960 ${_lib_libcapsicum} \
1961 lib/ncurses/ncurses lib/ncurses/ncursesw \
1962 lib/libopie lib/libpam ${_lib_libthr} \
1963 ${_lib_libradius} lib/libsbuf lib/libtacplus \
1965 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1966 ${_cddl_lib_libuutil} \
1967 ${_cddl_lib_libavl} \
1968 ${_cddl_lib_libzfs_core} \
1969 ${_cddl_lib_libctf} \
1970 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1971 ${_secure_lib_libcrypto} ${_lib_libldns} \
1972 ${_secure_lib_libssh} ${_secure_lib_libssl} \
1974 .if ${MK_GNUCXX} != "no"
1975 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1976 gnu/lib/libstdc++__L: lib/msun__L
1977 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1980 .if ${MK_LIBCPLUSPLUS} != "no"
1981 _prebuild_libs+= lib/libc++
1984 lib/libgeom__L: lib/libexpat__L
1985 lib/libkvm__L: lib/libelf__L
1987 .if ${MK_LIBTHR} != "no"
1988 _lib_libthr= lib/libthr
1991 .if ${MK_RADIUS_SUPPORT} != "no"
1992 _lib_libradius= lib/libradius
1995 .if ${MK_OFED} != "no"
1996 _ofed_lib= contrib/ofed/usr.lib/
1999 .if ${MK_CASPER} != "no"
2000 _lib_libcapsicum=lib/libcapsicum
2003 lib/libcapsicum__L: lib/libnv__L
2004 lib/libpjdlog__L: lib/libutil__L
2005 lib/liblzma__L: lib/libthr__L
2007 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
2008 .for _DIR in ${LOCAL_LIB_DIRS}
2009 .if exists(${.CURDIR}/${_DIR}/Makefile)
2010 _generic_libs+= ${_DIR}
2014 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2016 .if ${MK_CDDL} != "no"
2017 _cddl_lib_libumem= cddl/lib/libumem
2018 _cddl_lib_libnvpair= cddl/lib/libnvpair
2019 _cddl_lib_libavl= cddl/lib/libavl
2020 _cddl_lib_libuutil= cddl/lib/libuutil
2021 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2022 _cddl_lib_libctf= cddl/lib/libctf
2024 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2025 cddl/lib/libzfs__L: lib/libgeom__L
2026 cddl/lib/libctf__L: lib/libz__L
2028 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
2029 # on select architectures though (see cddl/lib/Makefile)
2030 .if ${MACHINE_CPUARCH} != "sparc64"
2031 _prebuild_libs+= lib/libproc lib/librtld_db
2034 .if ${MK_CRYPT} != "no"
2035 .if ${MK_OPENSSL} != "no"
2036 _secure_lib_libcrypto= secure/lib/libcrypto
2037 _secure_lib_libssl= secure/lib/libssl
2038 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2039 .if ${MK_LDNS} != "no"
2040 _lib_libldns= lib/libldns
2041 lib/libldns__L: secure/lib/libcrypto__L
2043 .if ${MK_OPENSSH} != "no"
2044 _secure_lib_libssh= secure/lib/libssh
2045 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2046 .if ${MK_LDNS} != "no"
2047 secure/lib/libssh__L: lib/libldns__L
2049 .if ${MK_KERBEROS_SUPPORT} != "no"
2050 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2051 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2052 lib/libmd__L kerberos5/lib/libroken__L
2056 _secure_lib= secure/lib
2059 .if ${MK_KERBEROS} != "no"
2060 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2061 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2062 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2063 kerberos5/lib/libwind__L lib/libsqlite3__L
2064 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2065 kerberos5/lib/libroken__L lib/libcom_err__L
2066 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2067 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2068 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2069 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2070 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2071 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2072 kerberos5/lib/libroken__L: lib/libcrypt__L
2073 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2074 kerberos5/lib/libheimbase__L: lib/libthr__L
2075 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2078 lib/libsqlite3__L: lib/libthr__L
2080 .if ${MK_GSSAPI} != "no"
2081 _lib_libgssapi= lib/libgssapi
2084 .if ${MK_KERBEROS} != "no"
2085 _kerberos5_lib= kerberos5/lib
2086 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2087 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2088 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2089 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2090 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2091 _kerberos5_lib_libroken= kerberos5/lib/libroken
2092 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2093 _libsqlite3= lib/libsqlite3
2094 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2095 _kerberos5_lib_libwind= kerberos5/lib/libwind
2096 _libcom_err= lib/libcom_err
2099 .if ${MK_NIS} != "no"
2100 _lib_libypclnt= lib/libypclnt
2103 .if ${MK_OPENSSL} == "no"
2104 lib/libradius__L: lib/libmd__L
2108 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2109 .if ${MK_CXX} != "no"
2110 .if ${MK_LIBCPLUSPLUS} != "no"
2111 lib/libproc__L: lib/libcxxrt__L
2112 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2113 lib/libproc__L: gnu/lib/libsupc++__L
2117 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2119 .for _lib in ${_prereq_libs}
2120 ${_lib}__PL: .PHONY .MAKE
2121 .if exists(${.CURDIR}/${_lib})
2122 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2123 cd ${.CURDIR}/${_lib}; \
2124 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2125 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; \
2126 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2127 DIRPRFX=${_lib}/ all; \
2128 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2129 DIRPRFX=${_lib}/ install
2133 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
2134 ${_lib}__L: .PHONY .MAKE
2135 .if exists(${.CURDIR}/${_lib})
2136 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2137 cd ${.CURDIR}/${_lib}; \
2138 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2139 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; \
2140 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2141 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2145 # libpam is special: we need to build static PAM modules before
2146 # static PAM library, and dynamic PAM library before dynamic PAM
2148 lib/libpam__L: .PHONY .MAKE
2149 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
2150 cd ${.CURDIR}/lib/libpam; \
2151 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj; \
2152 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ depend; \
2153 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2154 -D_NO_LIBPAM_SO_YET all; \
2155 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2156 -D_NO_LIBPAM_SO_YET install
2158 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2159 _startup_libs: ${_startup_libs:S/$/__L/}
2160 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2161 _generic_libs: ${_generic_libs:S/$/__L/}
2163 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2164 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2165 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2166 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2167 # parallel. This is safe for the world stage of buildworld though since it has
2168 # already built libraries in a proper order and installed includes into
2169 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2170 # avoid trashing a system if it crashes mid-install.
2171 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2175 .include <bsd.subdir.mk>
2177 .if make(check-old) || make(check-old-dirs) || \
2178 make(check-old-files) || make(check-old-libs) || \
2179 make(delete-old) || make(delete-old-dirs) || \
2180 make(delete-old-files) || make(delete-old-libs)
2183 # check for / delete old files section
2186 .include "ObsoleteFiles.inc"
2188 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2189 else you can not start such an application. Consult UPDATING for more \
2190 information regarding how to cope with the removal/revision bump of a \
2193 .if !defined(BATCH_DELETE_OLD_FILES)
2200 @echo ">>> Removing old files (only deletes safe to delete libs)"
2201 # Ask for every old file if the user really wants to remove it.
2202 # It's annoying, but better safe than sorry.
2203 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2204 # argument list will get too long. Using .for/.endfor make "loops" will make
2205 # the Makefile parser segfault.
2208 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2209 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2210 while read file; do \
2211 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2212 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2213 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2215 for ext in debug symbols; do \
2216 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2217 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2218 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2223 # Remove catpages without corresponding manpages.
2225 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2226 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2227 while read catpage; do \
2229 if [ ! -e "$${manpage}" ]; then \
2230 rm ${RM_I} $${catpage} <&3; \
2233 @echo ">>> Old files removed"
2236 @echo ">>> Checking for old files"
2238 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2239 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2240 while read file; do \
2241 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2242 echo "${DESTDIR}/$${file}"; \
2244 for ext in debug symbols; do \
2245 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2246 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2250 # Check for catpages without corresponding manpages.
2251 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2252 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2253 while read catpage; do \
2255 if [ ! -e "$${manpage}" ]; then \
2261 @echo ">>> Removing old libraries"
2262 @echo "${OLD_LIBS_MESSAGE}" | fmt
2265 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2266 -V OLD_LIBS | xargs -n1 | \
2267 while read file; do \
2268 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2269 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2270 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2272 for ext in debug symbols; do \
2273 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2274 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2275 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2280 @echo ">>> Old libraries removed"
2283 @echo ">>> Checking for old libraries"
2285 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2286 -V OLD_LIBS | xargs -n1 | \
2287 while read file; do \
2288 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2289 echo "${DESTDIR}/$${file}"; \
2291 for ext in debug symbols; do \
2292 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2293 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2299 @echo ">>> Removing old directories"
2301 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2302 -V OLD_DIRS | xargs -n1 | sort -r | \
2303 while read dir; do \
2304 if [ -d "${DESTDIR}/$${dir}" ]; then \
2305 rmdir -v "${DESTDIR}/$${dir}" || true; \
2306 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2307 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2310 @echo ">>> Old directories removed"
2313 @echo ">>> Checking for old directories"
2315 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2316 -V OLD_DIRS | xargs -n1 | \
2317 while read dir; do \
2318 if [ -d "${DESTDIR}/$${dir}" ]; then \
2319 echo "${DESTDIR}/$${dir}"; \
2320 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2321 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2325 delete-old: delete-old-files delete-old-dirs
2326 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2328 check-old: check-old-files check-old-libs check-old-dirs
2329 @echo "To remove old files and directories run '${MAKE} delete-old'."
2330 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2335 # showconfig - show build configuration.
2338 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2339 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2341 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2342 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2344 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2345 .if exists(${KERNCONFDIR}/${KERNCONF})
2346 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2347 '${KERNCONFDIR}/${KERNCONF}' ; echo
2353 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2354 DTBOUTPUTPATH= ${.CURDIR}
2358 # Build 'standalone' Device Tree Blob
2361 @PATH=${TMPPATH} MACHINE=${TARGET} \
2362 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2363 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2368 # In the following, the first 'rm' in a series will usually remove all
2369 # files and directories. If it does not, then there are probably some
2370 # files with file flags set, so this unsets them and tries the 'rm' a
2371 # second time. There are situations where this target will be cleaning
2372 # some directories via more than one method, but that duplication is
2373 # needed to correctly handle all the possible situations. Removing all
2374 # files without file flags set in the first 'rm' instance saves time,
2375 # because 'chflags' will need to operate on fewer files afterwards.
2377 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2378 # created by bsd.obj.mk, except that we don't want to .include that file
2381 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2383 .if exists(${BW_CANONICALOBJDIR}/)
2384 -rm -rf ${BW_CANONICALOBJDIR}/*
2385 -chflags -R 0 ${BW_CANONICALOBJDIR}
2386 rm -rf ${BW_CANONICALOBJDIR}/*
2388 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2389 # To be safe in this case, fall back to a 'make cleandir'
2390 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2393 .if defined(TARGET) && defined(TARGET_ARCH)
2395 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2396 XDEV_CPUTYPE?=${CPUTYPE}
2398 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2401 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2402 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2403 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2404 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2405 CPUTYPE=${XDEV_CPUTYPE}
2407 XDDIR=${TARGET_ARCH}-freebsd
2410 .error XDTP variable should be an absolute path
2413 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2414 INSTALL="sh ${.CURDIR}/tools/install.sh"
2416 TOOLS_PREFIX=${XDTP}
2417 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2418 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2419 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2420 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2421 CPP="${CPP} ${CD2CFLAGS}" \
2422 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2424 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2425 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2426 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2427 XDDESTDIR=${DESTDIR}/${XDTP}
2429 OSREL!= uname -r | sed -e 's/[-(].*//'
2432 .ORDER: xdev-build xdev-install xdev-links
2433 xdev: xdev-build xdev-install
2435 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2436 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2438 _xb-worldtmp: .PHONY
2439 mkdir -p ${CDTMP}/usr
2440 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2441 -p ${CDTMP}/usr >/dev/null
2443 _xb-bootstrap-tools: .PHONY
2447 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
2448 cd ${.CURDIR}/${_tool}; \
2449 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2450 ${CDMAKE} DIRPRFX=${_tool}/ depend; \
2451 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2452 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2455 _xb-build-tools: .PHONY
2456 ${_+_}@cd ${.CURDIR}; \
2457 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2459 _xb-cross-tools: .PHONY
2467 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
2468 cd ${.CURDIR}/${_tool}; \
2469 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2470 ${CDMAKE} DIRPRFX=${_tool}/ depend; \
2471 ${CDMAKE} DIRPRFX=${_tool}/ all
2475 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2476 mkdir -p ${XDDESTDIR}
2477 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2478 -p ${XDDESTDIR} >/dev/null
2479 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2480 -p ${XDDESTDIR}/usr >/dev/null
2481 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2482 -p ${XDDESTDIR}/usr/include >/dev/null
2483 .if ${MK_LIB32} != "no"
2484 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
2485 -p ${XDDESTDIR}/usr >/dev/null
2487 .if ${MK_TESTS} != "no"
2488 mkdir -p ${XDDESTDIR}${TESTSBASE}
2489 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2490 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2493 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2494 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2496 _xi-cross-tools: .PHONY
2497 @echo "_xi-cross-tools"
2505 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2506 cd ${.CURDIR}/${_tool}; \
2507 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2510 _xi-includes: .PHONY
2511 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2512 DESTDIR=${XDDESTDIR}
2514 _xi-libraries: .PHONY
2515 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2516 DESTDIR=${XDDESTDIR}
2519 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2520 mkdir -p ../../../../usr/bin; \
2522 ln -sf ../../${XDTP}/usr/bin/$$i \
2523 ../../../../usr/bin/${XDDIR}-$$i; \
2524 ln -sf ../../${XDTP}/usr/bin/$$i \
2525 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2528 xdev xdev-build xdev-install xdev-links:
2529 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"