4 # Make command line options:
5 # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6 # -DNO_CLEAN do not clean at all
7 # -DDB_FROM_SRC use the user/group databases in src/etc instead of
8 # the system database when installing.
9 # -DNO_SHARE do not go into share subdir
10 # -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,DEPEND,OBJ}
11 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
12 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
13 # -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
14 # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
15 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
16 # -DNO_ROOT install without using root privilege
17 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
18 # -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects
19 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
20 # LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list
21 # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
22 # LOCAL_MTREE="list of mtree files" to process to allow local directories
23 # to be created before files are installed
24 # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
26 # METALOG="path to metadata log" to write permission and ownership
27 # when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
28 # TARGET="machine" to crossbuild world for a different machine type
29 # TARGET_ARCH= may be required when a TARGET supports multiple endians
30 # BUILDENV_SHELL= shell to launch for the buildenv target (def:${SHELL})
31 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
32 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
33 # SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
34 # All libraries and includes, and some build tools will still build.
37 # The intended user-driven targets are:
38 # buildworld - rebuild *everything*, including glue to help do upgrades
39 # installworld- install everything built by "buildworld"
40 # checkworld - run test suite on installed world
41 # doxygen - build API documentation of the kernel
42 # update - convenient way to update your source tree (eg: svn/svnup)
44 # Standard targets (not defined here) are documented in the makefiles in
45 # /usr/share/mk. These include:
46 # obj depend all install clean cleandepend cleanobj
48 .if !defined(TARGET) || !defined(TARGET_ARCH)
49 .error "Both TARGET and TARGET_ARCH must be defined."
52 LOCALBASE?= /usr/local
54 # Cross toolchain changes must be in effect before bsd.compiler.mk
55 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
56 .if defined(CROSS_TOOLCHAIN)
57 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
58 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
60 .include <bsd.compiler.mk> # don't depend on src.opts.mk doing it
61 .include "share/mk/src.opts.mk"
63 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
64 # keep the users system reasonably usable. For static->dynamic root upgrades,
65 # we don't want to install a dynamic binary without rtld and the needed
66 # libraries. More commonly, for dynamic root, we don't want to install a
67 # binary that requires a newer library version that hasn't been installed yet.
68 # This ordering is not a guarantee though. The only guarantee of a working
69 # system here would require fine-grained ordering of all components based
70 # on their dependencies.
72 .if !empty(SUBDIR_OVERRIDE)
73 SUBDIR= ${SUBDIR_OVERRIDE}
76 .if !defined(NO_ROOT) && (make(installworld) || make(install))
77 # Ensure libraries are installed before progressing.
81 .if ${MK_CDDL} != "no"
85 .if ${MK_KERBEROS} != "no"
88 .if ${MK_RESCUE} != "no"
92 .if ${MK_CRYPT} != "no"
95 .if !defined(NO_SHARE)
98 SUBDIR+=sys usr.bin usr.sbin
99 .if ${MK_TESTS} != "no"
102 .if ${MK_OFED} != "no"
106 # Local directories are last, since it is nice to at least get the base
107 # system rebuilt before you do them.
108 .for _DIR in ${LOCAL_DIRS}
109 .if exists(${.CURDIR}/${_DIR}/Makefile)
113 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
114 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
115 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
116 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
117 _REDUNDENT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
119 .for _DIR in ${LOCAL_LIB_DIRS}
120 .if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
123 .warning ${_DIR} not added to SUBDIR list. See UPDATING 20141121.
127 # We must do etc/ last as it hooks into building the man whatis file
128 # by calling 'makedb' in share/man. This is only relevant for
129 # install/distribute so they build the whatis file after every manpage is
131 .if make(installworld) || make(install)
136 .endif # !empty(SUBDIR_OVERRIDE)
139 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
142 .if defined(NO_CLEANDIR)
143 CLEANDIR= clean cleandepend
148 # FAST_DEPEND can skip depend tree-walks.
149 .if ${MK_FAST_DEPEND} == "yes"
153 # Ensure shell checks later have a value.
154 .if defined(NO_DEPEND)
159 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
161 .if empty(SHELL:M*csh*)
162 BUILDENV_SHELL?=${SHELL}
164 BUILDENV_SHELL?=/bin/sh
167 SVN?= /usr/local/bin/svn
170 MAKEOBJDIRPREFIX?= /usr/obj
171 .if !defined(OSRELDATE)
172 .if exists(/usr/include/osreldate.h)
173 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
174 /usr/include/osreldate.h
181 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
182 .if !defined(VERSION) && !make(showconfig)
183 REVISION!= ${MAKE} -C ${SRCDIR}/release -V REVISION
184 BRANCH!= ${MAKE} -C ${SRCDIR}/release -V BRANCH
185 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
186 ${SRCDIR}/sys/sys/param.h
187 VERSION= FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
191 KNOWN_ARCHES?= aarch64/arm64 \
210 .if ${TARGET} == ${TARGET_ARCH}
213 _t= ${TARGET_ARCH}/${TARGET}
216 .if empty(KNOWN_ARCHES:M${_t})
217 .error Unknown target ${TARGET_ARCH}:${TARGET}.
221 .if ${TARGET} == ${MACHINE}
222 TARGET_CPUTYPE?=${CPUTYPE}
227 .if !empty(TARGET_CPUTYPE)
228 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
230 _TARGET_CPUTYPE=dummy
232 # Skip for showconfig as it is just wasted time and may invoke auto.obj.mk.
233 .if !make(showconfig)
234 _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
235 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
236 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
237 .error CPUTYPE global should be set with ?=.
241 BUILD_ARCH!= uname -p
242 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
243 .error To cross-build, set TARGET_ARCH.
246 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
247 OBJTREE= ${MAKEOBJDIRPREFIX}
249 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
251 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
252 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
253 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
254 STRICTTMPPATH= ${BPATH}:${XPATH}
255 TMPPATH= ${STRICTTMPPATH}:${PATH}
258 # Avoid running mktemp(1) unless actually needed.
259 # It may not be functional, e.g., due to new ABI
260 # when in the middle of installing over this system.
262 .if make(distributeworld) || make(installworld)
263 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
267 # Building a world goes through the following stages
269 # 1. legacy stage [BMAKE]
270 # This stage is responsible for creating compatibility
271 # shims that are needed by the bootstrap-tools,
272 # build-tools and cross-tools stages. These are generally
273 # APIs that tools from one of those three stages need to
274 # build that aren't present on the host.
275 # 1. bootstrap-tools stage [BMAKE]
276 # This stage is responsible for creating programs that
277 # are needed for backward compatibility reasons. They
278 # are not built as cross-tools.
279 # 2. build-tools stage [TMAKE]
280 # This stage is responsible for creating the object
281 # tree and building any tools that are needed during
282 # the build process. Some programs are listed during
283 # this phase because they build binaries to generate
284 # files needed to build these programs. This stage also
285 # builds the 'build-tools' target rather than 'all'.
286 # 3. cross-tools stage [XMAKE]
287 # This stage is responsible for creating any tools that
288 # are needed for building the system. A cross-compiler is one
289 # of them. This differs from build tools in two ways:
290 # 1. the 'all' target is built rather than 'build-tools'
291 # 2. these tools are installed into TMPPATH for stage 4.
292 # 4. world stage [WMAKE]
293 # This stage actually builds the world.
294 # 5. install stage (optional) [IMAKE]
295 # This stage installs a previously built world.
300 # Common environment for world related stages
301 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
302 MACHINE_ARCH=${TARGET_ARCH} \
304 CPUTYPE=${TARGET_CPUTYPE}
305 .if ${MK_GROFF} != "no"
306 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
307 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
308 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
310 .if defined(TARGET_CFLAGS)
311 CROSSENV+= ${TARGET_CFLAGS}
314 # bootstrap-tools stage
315 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
316 PATH=${BPATH}:${PATH} \
317 WORLDTMP=${WORLDTMP} \
318 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
319 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
321 BOOTSTRAPPING=${OSRELDATE} \
323 MK_HTML=no NO_LINT=yes MK_MAN=no \
324 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
325 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
326 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
327 MK_LLDB=no MK_TESTS=no \
330 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
331 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
335 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
336 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
337 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
339 BOOTSTRAPPING=${OSRELDATE} \
342 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
343 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
344 MK_LLDB=no MK_TESTS=no
347 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
348 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
349 MK_GDB=no MK_TESTS=no
352 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
353 PATH=${BPATH}:${PATH} \
355 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
356 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
358 BOOTSTRAPPING=${OSRELDATE} \
360 MK_HTML=no -DNO_LINT MK_MAN=no \
361 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
362 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
365 WMAKEENV= ${CROSSENV} \
367 INSTALL="sh ${.CURDIR}/tools/install.sh" \
371 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
373 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
376 .if defined(CROSS_TOOLCHAIN_PREFIX)
377 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
378 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
381 # If we do not have a bootstrap binutils (because the in-tree one does not
382 # support the target architecture), provide a default cross-binutils prefix.
383 # This allows aarch64 builds, for example, to automatically use the
384 # aarch64-binutils port or package.
385 .if !make(showconfig)
386 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
387 !defined(CROSS_BINUTILS_PREFIX)
388 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
389 .if !exists(${CROSS_BINUTILS_PREFIX})
390 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
395 XCOMPILERS= CC CXX CPP
396 .for COMPILER in ${XCOMPILERS}
397 .if defined(CROSS_COMPILER_PREFIX)
398 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
400 X${COMPILER}?= ${${COMPILER}}
403 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
404 .for BINUTIL in ${XBINUTILS}
405 .if defined(CROSS_BINUTILS_PREFIX) && \
406 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
407 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
409 X${BINUTIL}?= ${${BINUTIL}}
412 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
413 DEPFLAGS="${DEPFLAGS}" \
414 CPP="${XCPP} ${XCFLAGS}" \
415 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
416 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
417 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
420 .if ${XCC:N${CCACHE_BIN}:M/*}
421 .if defined(CROSS_BINUTILS_PREFIX)
422 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
423 # directory, but the compiler will look in the right place for it's
424 # tools so we don't need to tell it where to look.
425 .if exists(${CROSS_BINUTILS_PREFIX})
426 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
429 BFLAGS+= -B${WORLDTMP}/usr/bin
431 .if ${TARGET} == "arm"
432 .if ${TARGET_ARCH:M*hf*} != ""
433 TARGET_ABI= gnueabihf
438 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
439 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
440 XCXXFLAGS+= -I${WORLDTMP}/usr/include/c++/v1 -std=gnu++11 -L${WORLDTMP}/../lib/libc++
441 # XXX: DEPFLAGS is a workaround for not properly passing CXXFLAGS to sub-makes
442 # due to CXX="${XCXX} ${XCXXFLAGS}". bsd.dep.mk does use CXXFLAGS when
443 # building C++ files so this can come out if passing CXXFLAGS down is fixed.
444 DEPFLAGS+= -I${WORLDTMP}/usr/include/c++/v1
447 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
448 XCFLAGS+= -target ${TARGET_TRIPLE}
450 XCFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
451 XCXXFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
453 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
454 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
456 XCXXFLAGS+= ${BFLAGS}
460 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
462 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
464 LIB32_OBJTREE= ${OBJTREE}${.CURDIR}/world32
465 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
467 .if ${TARGET_ARCH} == "amd64"
468 .if empty(TARGET_CPUTYPE)
469 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
471 LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
473 LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
474 MACHINE_CPU="i686 mmx sse sse2"
477 LD="${XLD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
478 OBJCOPY="${XOBJCOPY}"
480 .elif ${TARGET_ARCH} == "powerpc64"
481 .if empty(TARGET_CPUTYPE)
482 LIB32CPUFLAGS= -mcpu=powerpc
484 LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
486 LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
488 LD="${XLD} -m elf32ppc_fbsd" \
489 OBJCOPY="${XOBJCOPY}"
493 LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
494 -isystem ${LIB32TMP}/usr/include/ \
495 -L${LIB32TMP}/usr/lib32 \
496 -B${LIB32TMP}/usr/lib32
497 .if ${XCC:N${CCACHE_BIN}:M/*}
498 LIB32FLAGS+= --sysroot=${WORLDTMP}
501 # Yes, the flags are redundant.
502 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${LIB32_OBJTREE} \
503 _LDSCRIPTROOT=${LIB32TMP} \
504 INSTALL="sh ${.CURDIR}/tools/install.sh" \
507 SHLIBDIR=/usr/lib32 \
508 DTRACE="${DTRACE} -32"
509 LIB32WMAKEFLAGS+= CC="${XCC} ${LIB32FLAGS}" \
510 CXX="${XCXX} ${LIB32FLAGS}" \
511 DESTDIR=${LIB32TMP} \
519 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
521 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \
522 MK_TOOLCHAIN=no ${IMAKE_INSTALL}
525 IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*}
526 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
527 ${IMAKE_INSTALL} ${IMAKE_MTREE}
528 .if empty(.MAKEFLAGS:M-n)
529 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
530 LD_LIBRARY_PATH=${INSTALLTMP} \
531 PATH_LOCALE=${INSTALLTMP}/locale
532 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
534 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
536 .if defined(DB_FROM_SRC)
537 INSTALLFLAGS+= -N ${.CURDIR}/etc
538 MTREEFLAGS+= -N ${.CURDIR}/etc
540 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
541 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
543 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
544 IMAKE+= -DNO_ROOT METALOG=${METALOG}
545 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
548 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
549 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
550 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
554 KMAKEENV= ${WMAKEENV}
555 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
560 # Attempt to rebuild the entire system, with reasonable chance of
561 # success, regardless of how old your existing system is.
564 .if ${.CURDIR:C/[^,]//g} != ""
565 # The m4 build of sendmail files doesn't like it if ',' is used
566 # anywhere in the path of it's files.
568 @echo "*** Error: path to source tree contains a comma ','"
573 @echo "--------------------------------------------------------------"
574 @echo ">>> Rebuilding the temporary build tree"
575 @echo "--------------------------------------------------------------"
576 .if !defined(NO_CLEAN)
578 .if defined(LIB32TMP)
582 rm -rf ${WORLDTMP}/legacy/usr/include
583 # XXX - These can depend on any header file.
584 rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c
585 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
588 lib lib/casper usr legacy/bin legacy/usr
589 mkdir -p ${WORLDTMP}/${_dir}
591 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
592 -p ${WORLDTMP}/legacy/usr >/dev/null
593 .if ${MK_GROFF} != "no"
594 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
595 -p ${WORLDTMP}/legacy/usr >/dev/null
597 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
598 -p ${WORLDTMP}/usr >/dev/null
599 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
600 -p ${WORLDTMP}/usr/include >/dev/null
601 ln -sf ${.CURDIR}/sys ${WORLDTMP}
602 .if ${MK_DEBUG_FILES} != "no"
603 # We could instead disable debug files for these build stages
604 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
605 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
606 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
607 -p ${WORLDTMP}/usr/lib >/dev/null
609 .if ${MK_LIB32} != "no"
610 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
611 -p ${WORLDTMP}/usr >/dev/null
612 .if ${MK_DEBUG_FILES} != "no"
613 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
614 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
615 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
616 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
619 .if ${MK_TESTS} != "no"
620 mkdir -p ${WORLDTMP}${TESTSBASE}
621 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
622 -p ${WORLDTMP}${TESTSBASE} >/dev/null
623 .if ${MK_DEBUG_FILES} != "no"
624 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
625 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
626 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
629 .for _mtree in ${LOCAL_MTREE}
630 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
634 @echo "--------------------------------------------------------------"
635 @echo ">>> stage 1.1: legacy release compatibility shims"
636 @echo "--------------------------------------------------------------"
637 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
640 @echo "--------------------------------------------------------------"
641 @echo ">>> stage 1.2: bootstrap tools"
642 @echo "--------------------------------------------------------------"
643 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
645 .if !defined(NO_CLEAN)
647 @echo "--------------------------------------------------------------"
648 @echo ">>> stage 2.1: cleaning up the object tree"
649 @echo "--------------------------------------------------------------"
650 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
651 .if defined(LIB32TMP)
652 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR}
657 @echo "--------------------------------------------------------------"
658 @echo ">>> stage 2.2: rebuilding the object tree"
659 @echo "--------------------------------------------------------------"
660 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
663 @echo "--------------------------------------------------------------"
664 @echo ">>> stage 2.3: build tools"
665 @echo "--------------------------------------------------------------"
666 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
669 @echo "--------------------------------------------------------------"
670 @echo ">>> stage 3: cross tools"
671 @echo "--------------------------------------------------------------"
672 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
673 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
676 @echo "--------------------------------------------------------------"
677 @echo ">>> stage 4.1: building includes"
678 @echo "--------------------------------------------------------------"
679 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
680 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
681 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
683 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
684 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks includes
688 @echo "--------------------------------------------------------------"
689 @echo ">>> stage 4.2: building libraries"
690 @echo "--------------------------------------------------------------"
691 ${_+_}cd ${.CURDIR}; \
692 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
693 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
696 @echo "--------------------------------------------------------------"
697 @echo ">>> stage 4.3: make dependencies"
698 @echo "--------------------------------------------------------------"
699 ${_+_}cd ${.CURDIR}; ${WMAKE} depend
702 @echo "--------------------------------------------------------------"
703 @echo ">>> stage 4.4: building everything"
704 @echo "--------------------------------------------------------------"
705 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
706 .if defined(LIB32TMP)
709 @echo "--------------------------------------------------------------"
710 @echo ">>> stage 5.1: building 32 bit shim libraries"
711 @echo "--------------------------------------------------------------"
712 mkdir -p ${LIB32TMP}/usr/include
713 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
714 -p ${LIB32TMP}/usr >/dev/null
715 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
716 -p ${LIB32TMP}/usr/include >/dev/null
717 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
718 -p ${LIB32TMP}/usr >/dev/null
719 .if ${MK_DEBUG_FILES} != "no"
720 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
721 -p ${LIB32TMP}/usr/lib >/dev/null
722 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
723 -p ${LIB32TMP}/usr/lib/debug/usr >/dev/null
726 ln -sf ${.CURDIR}/sys ${WORLDTMP}
727 .for _t in obj includes
728 ${_+_}cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
729 ${_+_}cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
730 .if ${MK_CDDL} != "no"
731 ${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
733 ${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
734 .if ${MK_CRYPT} != "no"
735 ${_+_}cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
737 .if ${MK_KERBEROS} != "no"
738 ${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
741 .for _dir in usr.bin/lex/lib
742 ${_+_}cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
744 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
745 ${_+_}cd ${.CURDIR}/${_dir}; \
746 WORLDTMP=${WORLDTMP} \
747 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
748 MAKEOBJDIRPREFIX=${LIB32_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \
749 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
752 ${_+_}cd ${.CURDIR}; \
753 ${LIB32WMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
754 .for _t in obj depend all
755 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
756 -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t}
757 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
758 DIRPRFX=usr.bin/ldd ${_t}
761 distribute32 install32: .MAKE .PHONY
762 ${_+_}cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
763 .if ${MK_CDDL} != "no"
764 ${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
766 ${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
767 .if ${MK_CRYPT} != "no"
768 ${_+_}cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
770 .if ${MK_KERBEROS} != "no"
771 ${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
773 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \
774 PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
775 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} \
780 WMAKE_TGTS+= _worldtmp _legacy
781 .if empty(SUBDIR_OVERRIDE)
782 WMAKE_TGTS+= _bootstrap-tools
784 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
785 WMAKE_TGTS+= _includes _libraries
786 .if !defined(NO_DEPEND)
789 WMAKE_TGTS+= everything
790 .if defined(LIB32TMP) && ${MK_LIB32} != "no" && empty(SUBDIR_OVERRIDE)
794 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
795 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
798 @echo "--------------------------------------------------------------"
799 @echo ">>> World build started on `LC_ALL=C date`"
800 @echo "--------------------------------------------------------------"
804 @echo "--------------------------------------------------------------"
805 @echo ">>> World build completed on `LC_ALL=C date`"
806 @echo "--------------------------------------------------------------"
809 # We need to have this as a target because the indirection between Makefile
810 # and Makefile.inc1 causes the correct PATH to be used, rather than a
811 # modification of the current environment's PATH. In addition, we need
812 # to quote multiword values.
815 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
817 .if ${.TARGETS:Mbuildenv}
818 .if ${.MAKEFLAGS:M-j}
819 .error The buildenv target is incompatible with -j
822 BUILDENV_DIR?= ${.CURDIR}
824 @echo Entering world for ${TARGET_ARCH}:${TARGET}
825 .if ${BUILDENV_SHELL:M*zsh*}
826 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
828 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
831 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
832 toolchain: ${TOOLCHAIN_TGTS}
833 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
838 # Checks to be sure system is ready for installworld/installkernel.
840 installcheck: _installcheck_world _installcheck_kernel
842 _installcheck_kernel:
845 # Require DESTDIR to be set if installing for a different architecture or
846 # using the user/group database in the source tree.
848 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
850 .if !make(distributeworld)
851 _installcheck_world: __installcheck_DESTDIR
852 _installcheck_kernel: __installcheck_DESTDIR
853 __installcheck_DESTDIR:
854 .if !defined(DESTDIR) || empty(DESTDIR)
855 @echo "ERROR: Please set DESTDIR!"; \
861 .if !defined(DB_FROM_SRC)
863 # Check for missing UIDs/GIDs.
865 CHECK_UIDS= auditdistd
867 .if ${MK_SENDMAIL} != "no"
873 CHECK_GIDS+= proxy authpf
875 .if ${MK_UNBOUND} != "no"
879 _installcheck_world: __installcheck_UGID
881 .for uid in ${CHECK_UIDS}
882 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
883 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
887 .for gid in ${CHECK_GIDS}
888 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
889 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
896 # Required install tools to be saved in a scratch dir for safety.
898 .if ${MK_ZONEINFO} != "no"
899 _zoneinfo= zic tzsetup
902 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
903 date echo egrep find grep id install ${_install-info} \
904 ln make mkdir mtree mv pwd_mkdb \
905 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
908 # Needed for share/man
909 .if ${MK_MAN} != "no"
916 # Distributes everything compiled by a `buildworld'.
920 # Installs everything compiled by a 'buildworld'.
923 # Non-base distributions produced by the base system
924 EXTRA_DISTRIBUTIONS= doc
925 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
926 EXTRA_DISTRIBUTIONS+= lib32
928 .if ${MK_TESTS} != "no"
929 EXTRA_DISTRIBUTIONS+= tests
933 .if ${MK_DEBUG_FILES} != "no"
934 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
937 MTREE_MAGIC?= mtree 2.0
939 distributeworld installworld: _installcheck_world
940 mkdir -p ${INSTALLTMP}
941 progs=$$(for prog in ${ITOOLS}; do \
942 if progpath=`which $$prog`; then \
945 echo "Required tool $$prog not found in PATH." >&2; \
949 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
950 while read line; do \
952 if [ "$$2 $$3" != "not found" ]; then \
955 echo "Required library $$1 not found." >&2; \
959 cp $$libs $$progs ${INSTALLTMP}
960 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
962 echo "#${MTREE_MAGIC}" > ${METALOG}
964 .if make(distributeworld)
965 .for dist in ${EXTRA_DISTRIBUTIONS}
966 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
967 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
968 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
969 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
970 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
971 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
972 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
973 .if ${MK_DEBUG_FILES} != "no"
974 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
975 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
977 .if ${MK_LIB32} != "no"
978 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
979 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
980 .if ${MK_DEBUG_FILES} != "no"
981 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
982 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
985 .if ${MK_TESTS} != "no" && ${dist} == "tests"
986 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
987 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
988 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
989 .if ${MK_DEBUG_FILES} != "no"
990 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
991 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
995 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
996 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
997 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
998 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
999 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1000 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1001 .if ${MK_LIB32} != "no"
1002 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib32.dist | \
1003 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1007 -mkdir ${DESTDIR}/${DISTDIR}/base
1008 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1009 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1010 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1011 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1013 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1014 ${IMAKEENV} rm -rf ${INSTALLTMP}
1015 .if make(distributeworld)
1016 .for dist in ${EXTRA_DISTRIBUTIONS}
1017 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
1019 .if defined(NO_ROOT)
1020 .for dist in base ${EXTRA_DISTRIBUTIONS}
1021 @# For each file that exists in this dist, print the corresponding
1022 @# line from the METALOG. This relies on the fact that
1023 @# a line containing only the filename will sort immediatly before
1024 @# the relevant mtree line.
1025 cd ${DESTDIR}/${DISTDIR}; \
1026 find ./${dist} | sort -u ${METALOG} - | \
1027 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1028 ${DESTDIR}/${DISTDIR}/${dist}.meta
1030 .for dist in ${DEBUG_DISTRIBUTIONS}
1031 @# For each file that exists in this dist, print the corresponding
1032 @# line from the METALOG. This relies on the fact that
1033 @# a line containing only the filename will sort immediatly before
1034 @# the relevant mtree line.
1035 cd ${DESTDIR}/${DISTDIR}; \
1036 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1037 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1038 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1044 .for dist in base ${EXTRA_DISTRIBUTIONS}
1045 .if defined(NO_ROOT)
1046 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1047 tar cvf - --exclude usr/lib/debug \
1048 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1049 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1051 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1052 tar cvf - --exclude usr/lib/debug . | \
1053 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1057 .for dist in ${DEBUG_DISTRIBUTIONS}
1058 . if defined(NO_ROOT)
1059 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1060 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1061 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1063 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1064 tar cvLf - usr/lib/debug | \
1065 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1072 # If you have a build server, you can NFS mount the source and obj directories
1073 # and do a 'make reinstall' on the *client* to install new binaries from the
1074 # most recent server build.
1076 reinstall: .MAKE .PHONY
1077 @echo "--------------------------------------------------------------"
1078 @echo ">>> Making hierarchy"
1079 @echo "--------------------------------------------------------------"
1080 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1081 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1083 @echo "--------------------------------------------------------------"
1084 @echo ">>> Installing everything"
1085 @echo "--------------------------------------------------------------"
1086 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1087 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
1088 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
1091 redistribute: .MAKE .PHONY
1092 @echo "--------------------------------------------------------------"
1093 @echo ">>> Distributing everything"
1094 @echo "--------------------------------------------------------------"
1095 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1096 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
1097 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
1101 distrib-dirs distribution: .MAKE .PHONY
1102 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1103 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1104 .if make(distribution)
1105 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1106 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1107 METALOG=${METALOG} MK_TESTS=no installconfig
1111 # buildkernel and installkernel
1113 # Which kernels to build and/or install is specified by setting
1114 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1115 # Only the existing (depending TARGET) config files are used
1116 # for building kernels and only the first of these is designated
1117 # as the one being installed.
1119 # Note that we have to use TARGET instead of TARGET_ARCH when
1120 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1121 # be set to cross-build, we have to make sure TARGET is set
1124 .if defined(KERNFAST)
1129 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1130 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1131 KERNCONF=${KERNFAST}
1134 .if ${TARGET_ARCH} == "powerpc64"
1135 KERNCONF?= GENERIC64
1139 INSTKERNNAME?= kernel
1141 KERNSRCDIR?= ${.CURDIR}/sys
1142 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1143 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1144 KERNCONFDIR?= ${KRNLCONFDIR}
1148 .if defined(NO_INSTALLKERNEL)
1149 # All of the BUILDKERNELS loops start at index 1.
1150 BUILDKERNELS+= dummy
1152 .for _kernel in ${KERNCONF}
1153 .if exists(${KERNCONFDIR}/${_kernel})
1154 BUILDKERNELS+= ${_kernel}
1155 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1156 INSTALLKERNEL= ${_kernel}
1161 ${WMAKE_TGTS:N_worldtmp:Nbuild32} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1166 # Builds all kernels defined by BUILDKERNELS.
1168 buildkernel: .MAKE .PHONY
1169 .if empty(BUILDKERNELS:Ndummy)
1170 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1174 .for _kernel in ${BUILDKERNELS:Ndummy}
1175 @echo "--------------------------------------------------------------"
1176 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1177 @echo "--------------------------------------------------------------"
1178 @echo "===> ${_kernel}"
1179 mkdir -p ${KRNLOBJDIR}
1180 .if !defined(NO_KERNELCONFIG)
1182 @echo "--------------------------------------------------------------"
1183 @echo ">>> stage 1: configuring the kernel"
1184 @echo "--------------------------------------------------------------"
1185 cd ${KRNLCONFDIR}; \
1187 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1188 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1190 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1192 @echo "--------------------------------------------------------------"
1193 @echo ">>> stage 2.1: cleaning up the object tree"
1194 @echo "--------------------------------------------------------------"
1195 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1197 .if !defined(NO_KERNELOBJ)
1199 @echo "--------------------------------------------------------------"
1200 @echo ">>> stage 2.2: rebuilding the object tree"
1201 @echo "--------------------------------------------------------------"
1202 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1205 @echo "--------------------------------------------------------------"
1206 @echo ">>> stage 2.3: build tools"
1207 @echo "--------------------------------------------------------------"
1208 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1209 .if !defined(NO_KERNELDEPEND)
1211 @echo "--------------------------------------------------------------"
1212 @echo ">>> stage 3.1: making dependencies"
1213 @echo "--------------------------------------------------------------"
1214 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
1217 @echo "--------------------------------------------------------------"
1218 @echo ">>> stage 3.2: building everything"
1219 @echo "--------------------------------------------------------------"
1220 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1221 @echo "--------------------------------------------------------------"
1222 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1223 @echo "--------------------------------------------------------------"
1227 # installkernel, etc.
1229 # Install the kernel defined by INSTALLKERNEL
1231 installkernel installkernel.debug \
1232 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1233 .if !defined(NO_INSTALLKERNEL)
1234 .if empty(INSTALLKERNEL)
1235 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1238 @echo "--------------------------------------------------------------"
1239 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1240 @echo "--------------------------------------------------------------"
1241 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1242 ${CROSSENV} PATH=${TMPPATH} \
1243 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1245 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1246 .for _kernel in ${BUILDKERNELS:[2..-1]}
1247 @echo "--------------------------------------------------------------"
1248 @echo ">>> Installing kernel ${_kernel}"
1249 @echo "--------------------------------------------------------------"
1250 cd ${KRNLOBJDIR}/${_kernel}; \
1251 ${CROSSENV} PATH=${TMPPATH} \
1252 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1256 distributekernel distributekernel.debug:
1257 .if !defined(NO_INSTALLKERNEL)
1258 .if empty(INSTALLKERNEL)
1259 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1262 mkdir -p ${DESTDIR}/${DISTDIR}
1263 .if defined(NO_ROOT)
1264 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1266 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1267 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1268 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1269 DESTDIR=${INSTALL_DDIR}/kernel \
1270 ${.TARGET:S/distributekernel/install/}
1271 .if defined(NO_ROOT)
1272 sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1273 ${DESTDIR}/${DISTDIR}/kernel.meta
1276 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1277 .for _kernel in ${BUILDKERNELS:[2..-1]}
1278 .if defined(NO_ROOT)
1279 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1281 cd ${KRNLOBJDIR}/${_kernel}; \
1282 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1283 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1284 KERNEL=${INSTKERNNAME}.${_kernel} \
1285 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1286 ${.TARGET:S/distributekernel/install/}
1287 .if defined(NO_ROOT)
1288 sed -e 's|^./kernel|.|' \
1289 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1290 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1296 .if defined(NO_ROOT)
1297 .if !defined(NO_INSTALLKERNEL)
1298 cd ${DESTDIR}/${DISTDIR}/kernel; \
1299 tar cvf - --exclude '*.debug' \
1300 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1301 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1303 cd ${DESTDIR}/${DISTDIR}/kernel; \
1304 tar cvf - --include '*/*/*.debug' \
1305 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1306 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1307 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1308 .for _kernel in ${BUILDKERNELS:[2..-1]}
1309 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1310 tar cvf - --exclude '*.debug' \
1311 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1312 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1313 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1314 tar cvf - --include '*/*/*.debug' \
1315 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1316 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1320 .if !defined(NO_INSTALLKERNEL)
1321 cd ${DESTDIR}/${DISTDIR}/kernel; \
1322 tar cvf - --exclude '*.debug' . | \
1323 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1325 cd ${DESTDIR}/${DISTDIR}/kernel; \
1326 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1327 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1328 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1329 .for _kernel in ${BUILDKERNELS:[2..-1]}
1330 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1331 tar cvf - --exclude '*.debug' . | \
1332 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1333 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1334 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1335 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1344 # Run test suite on installed world.
1347 @if [ ! -x ${LOCALBASE}/bin/kyua ]; then \
1348 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1351 ${_+_}${LOCALBASE}/bin/kyua test -k ${TESTSBASE}/Kyuafile
1357 # Build the API documentation with doxygen
1360 @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1361 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1364 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1369 # Update the source tree(s), by running svn/svnup to update to the
1373 .if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1374 @echo "--------------------------------------------------------------"
1375 @echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1376 @echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1377 @echo "--------------------------------------------------------------"
1380 .if defined(SVN_UPDATE)
1381 @echo "--------------------------------------------------------------"
1382 @echo ">>> Updating ${.CURDIR} using Subversion"
1383 @echo "--------------------------------------------------------------"
1384 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1388 # ------------------------------------------------------------------------
1390 # From here onwards are utility targets used by the 'make world' and
1391 # related targets. If your 'world' breaks, you may like to try to fix
1392 # the problem and manually run the following targets to attempt to
1393 # complete the build. Beware, this is *not* guaranteed to work, you
1394 # need to have a pretty good grip on the current state of the system
1395 # to attempt to manually finish it. If in doubt, 'make world' again.
1399 # legacy: Build compatibility shims for the next three targets. This is a
1400 # minimal set of tools and shims necessary to compensate for older systems
1401 # which don't have the APIs required by the targets built in bootstrap-tools,
1402 # build-tools or cross-tools.
1405 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1406 .if ${BOOTSTRAPPING} < 1100006
1407 _elftoolchain_libs= lib/libelf lib/libdwarf
1411 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1412 @echo "ERROR: Source upgrades from versions prior to 8.0 are not supported."; \
1415 .for _tool in tools/build ${_elftoolchain_libs}
1416 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1417 cd ${.CURDIR}/${_tool}; \
1418 ${MAKE} DIRPRFX=${_tool}/ obj; \
1419 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1420 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1421 ${MAKE} DIRPRFX=${_tool}/ all; \
1422 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1426 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1427 # are built to build other binaries in the system. However, the focus of these
1428 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1429 # libraries, augmented by -legacy.
1431 _bt= _bootstrap-tools
1433 .if ${MK_GAMES} != "no"
1434 _strfile= usr.bin/fortune/strfile
1437 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1438 _gperf= gnu/usr.bin/gperf
1441 .if ${MK_GROFF} != "no"
1442 _groff= gnu/usr.bin/groff \
1446 .if ${MK_VT} != "no"
1447 _vtfontcvt= usr.bin/vtfontcvt
1450 .if ${BOOTSTRAPPING} < 900002
1454 .if ${BOOTSTRAPPING} < 1000033
1455 _libopenbsd= lib/libopenbsd
1459 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1460 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1463 .if ${BOOTSTRAPPING} < 1000026
1464 _nmtree= lib/libnetbsd \
1467 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1470 .if ${BOOTSTRAPPING} < 1000027
1474 # r264059 support for status=
1475 .if ${BOOTSTRAPPING} < 1100017
1479 # r277259 crunchide: Correct 64-bit section header offset
1480 # r281674 crunchide: always include both 32- and 64-bit ELF support
1481 # r285986 crunchen: use STRIPBIN rather than STRIP
1482 .if ${BOOTSTRAPPING} < 1100078
1483 _crunch= usr.sbin/crunch
1486 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1493 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1495 .if ${MK_BSNMP} != "no"
1496 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1499 # We need to build tblgen when we're building clang either as
1500 # the bootstrap compiler, or as the part of the normal build.
1501 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1503 lib/clang/libllvmsupport \
1504 lib/clang/libllvmtablegen \
1505 usr.bin/clang/tblgen \
1506 usr.bin/clang/clang-tblgen
1508 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1509 ${_bt}-usr.bin/clang/tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1512 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1515 .if ${MK_GPL_DTC} != "no"
1516 _dtc= gnu/usr.bin/dtc
1519 .if ${MK_KERBEROS} != "no"
1520 _kerberos5_bootstrap_tools= \
1521 kerberos5/tools/make-roken \
1522 kerberos5/lib/libroken \
1523 kerberos5/lib/libvers \
1524 kerberos5/tools/asn1_compile \
1525 kerberos5/tools/slc \
1528 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1531 .if ${MK_MANDOCDB} != "no"
1532 _libopenbsd?= lib/libopenbsd
1533 _makewhatis= lib/libsqlite3 \
1535 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1537 _makewhatis=usr.bin/makewhatis
1540 bootstrap-tools: .PHONY
1542 # Please document (add comment) why something is in 'bootstrap-tools'.
1543 # Try to bound the building of the bootstrap-tool to just the
1544 # FreeBSD versions that need the tool built at this stage of the build.
1547 ${_kerberos5_bootstrap_tools} \
1570 ${_bt}-${_tool}: .PHONY .MAKE
1571 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1572 cd ${.CURDIR}/${_tool}; \
1573 ${MAKE} DIRPRFX=${_tool}/ obj; \
1574 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1575 ${MAKE} DIRPRFX=${_tool}/ all; \
1576 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1578 bootstrap-tools: ${_bt}-${_tool}
1582 # build-tools: Build special purpose build tools
1584 .if !defined(NO_SHARE)
1585 _share= share/syscons/scrnmaps
1588 .if ${MK_GCC} != "no"
1589 _gcc_tools= gnu/usr.bin/cc/cc_tools
1592 .if ${MK_RESCUE} != "no"
1593 # rescue includes programs that have build-tools targets
1594 _rescue=rescue/rescue
1600 ${LOCAL_TOOL_DIRS} \
1601 lib/ncurses/ncurses \
1602 lib/ncurses/ncursesw \
1607 usr.bin/mkesdb_static \
1608 usr.bin/mkcsmapper_static \
1610 build-tools_${_tool}: .PHONY
1611 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1612 cd ${.CURDIR}/${_tool}; \
1613 ${MAKE} DIRPRFX=${_tool}/ obj; \
1614 ${MAKE} DIRPRFX=${_tool}/ build-tools
1615 build-tools: build-tools_${_tool}
1619 build-tools_${_tool}: .PHONY
1620 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1621 cd ${.CURDIR}/${_tool}; \
1622 ${MAKE} DIRPRFX=${_tool}/ obj; \
1623 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1624 ${MAKE} DIRPRFX=${_tool}/ all
1625 build-tools: build-tools_${_tool}
1629 # kernel-tools: Build kernel-building tools
1632 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1633 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1634 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1637 # cross-tools: All the tools needed to build the rest of the system after
1638 # we get done with the earlier stages. It is the last set of tools needed
1639 # to begin building the target binaries.
1641 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1642 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1643 _btxld= usr.sbin/btxld
1647 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1648 # resulting from missing bug fixes or ELF Toolchain updates.
1649 .if ${MK_CDDL} != "no"
1650 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1651 cddl/usr.bin/ctfmerge
1654 # If we're given an XAS, don't build binutils.
1655 .if ${XAS:M/*} == ""
1656 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1657 _binutils= gnu/usr.bin/binutils
1659 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1660 _elftctools= lib/libelftc \
1666 # These are not required by the build, but can be useful for developers who
1667 # cross-build on a FreeBSD 10 host:
1668 _elftctools+= usr.bin/addr2line
1670 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1671 # If cross-building with an external binutils we still need to build strip for
1672 # the target (for at least crunchide).
1673 _elftctools= lib/libelftc \
1678 # If an full path to an external cross compiler is given, don't build
1680 .if ${XCC:N${CCACHE_BIN}:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1681 .if ${MK_CLANG_BOOTSTRAP} != "no"
1682 _clang= usr.bin/clang
1683 _clang_libs= lib/clang
1685 .if ${MK_GCC_BOOTSTRAP} != "no"
1689 .if ${MK_USB} != "no"
1690 _usb_tools= sys/boot/usb/tools
1693 cross-tools: .MAKE .PHONY
1704 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1705 cd ${.CURDIR}/${_tool}; \
1706 ${MAKE} DIRPRFX=${_tool}/ obj; \
1707 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1708 ${MAKE} DIRPRFX=${_tool}/ all; \
1709 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1712 NXBDESTDIR= ${OBJTREE}/nxb-bin
1713 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1714 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1715 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1716 NXBMAKE= ${NXBENV} ${MAKE} \
1717 TBLGEN=${NXBDESTDIR}/usr/bin/tblgen \
1718 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1719 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1720 MK_GDB=no MK_TESTS=no \
1722 MK_HTML=no NO_LINT=yes MK_MAN=no \
1723 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1724 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1725 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1726 MK_LLDB=no MK_DEBUG_FILES=no
1728 # native-xtools is the current target for qemu-user cross builds of ports
1729 # via poudriere and the imgact_binmisc kernel module.
1730 # For non-clang enabled targets that are still using the in tree gcc
1731 # we must build a gperf binary for one instance of its Makefiles. On
1732 # clang-enabled systems, the gperf binary is obsolete.
1733 native-xtools: .PHONY
1734 .if ${MK_GCC_BOOTSTRAP} != "no"
1735 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1736 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,depend,all,install)"; \
1737 cd ${.CURDIR}/${_gperf}; \
1738 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1739 if [ -z "${NO_DEPEND}" ]; then ${NXBMAKE} DIRPRFX=${_gperf}/ depend; fi; \
1740 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1741 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1743 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1744 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1745 -p ${NXBDESTDIR}/usr >/dev/null
1746 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1747 -p ${NXBDESTDIR}/usr/include >/dev/null
1748 .if ${MK_DEBUG_FILES} != "no"
1749 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1750 -p ${NXBDESTDIR}/usr/lib >/dev/null
1811 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1812 cd ${.CURDIR}/${_tool}; \
1813 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1814 if [ -z "${NO_DEPEND}" ]; then ${NXBMAKE} DIRPRFX=${_tool}/ depend; fi; \
1815 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1816 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1820 # hierarchy - ensure that all the needed directories are present
1822 hierarchy hier: .MAKE .PHONY
1823 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1826 # libraries - build all libraries, and install them under ${DESTDIR}.
1828 # The list of libraries with dependents (${_prebuild_libs}) and their
1829 # interdependencies (__L) are built automatically by the
1830 # ${.CURDIR}/tools/make_libdeps.sh script.
1832 libraries: .MAKE .PHONY
1833 ${_+_}cd ${.CURDIR}; \
1834 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1835 ${MAKE} -f Makefile.inc1 _startup_libs; \
1836 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1837 ${MAKE} -f Makefile.inc1 _generic_libs
1840 # static libgcc.a prerequisite for shared libc
1842 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1844 # These dependencies are not automatically generated:
1846 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1847 # all shared libraries for ELF.
1849 _startup_libs= gnu/lib/csu
1850 _startup_libs+= lib/csu
1851 _startup_libs+= gnu/lib/libgcc
1852 _startup_libs+= lib/libcompiler_rt
1853 _startup_libs+= lib/libc
1854 _startup_libs+= lib/libc_nonshared
1855 .if ${MK_LIBCPLUSPLUS} != "no"
1856 _startup_libs+= lib/libcxxrt
1859 gnu/lib/libgcc__L: lib/libc__L
1860 gnu/lib/libgcc__L: lib/libc_nonshared__L
1861 .if ${MK_LIBCPLUSPLUS} != "no"
1862 lib/libcxxrt__L: gnu/lib/libgcc__L
1865 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1866 ${_kerberos5_lib_libhdb} \
1867 ${_kerberos5_lib_libheimbase} \
1868 ${_kerberos5_lib_libheimntlm} \
1870 ${_kerberos5_lib_libheimipcc} \
1871 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1872 ${_kerberos5_lib_libroken} \
1873 ${_kerberos5_lib_libwind} \
1874 lib/libbz2 ${_libcom_err} lib/libcrypt \
1875 lib/libelf lib/libexpat \
1878 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1880 lib/ncurses/ncurses lib/ncurses/ncursesw \
1881 lib/libopie lib/libpam ${_lib_libthr} \
1882 ${_lib_libradius} lib/libsbuf lib/libtacplus \
1884 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1885 ${_cddl_lib_libuutil} \
1886 ${_cddl_lib_libavl} \
1887 ${_cddl_lib_libzfs_core} \
1888 ${_cddl_lib_libctf} \
1889 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1890 ${_secure_lib_libcrypto} ${_lib_libldns} \
1891 ${_secure_lib_libssh} ${_secure_lib_libssl} \
1893 .if ${MK_GNUCXX} != "no"
1894 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1895 gnu/lib/libstdc++__L: lib/msun__L
1896 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1899 .if ${MK_LIBCPLUSPLUS} != "no"
1900 _prebuild_libs+= lib/libc++
1903 lib/libgeom__L: lib/libexpat__L
1904 lib/libkvm__L: lib/libelf__L
1906 .if ${MK_LIBTHR} != "no"
1907 _lib_libthr= lib/libthr
1910 .if ${MK_RADIUS_SUPPORT} != "no"
1911 _lib_libradius= lib/libradius
1914 .if ${MK_OFED} != "no"
1915 _ofed_lib= contrib/ofed/usr.lib/
1918 .if ${MK_CASPER} != "no"
1919 _lib_casper= lib/libcasper
1922 lib/libpjdlog__L: lib/libutil__L
1923 lib/libcasper__L: lib/libnv__L
1924 lib/liblzma__L: lib/libthr__L
1926 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1927 .for _DIR in ${LOCAL_LIB_DIRS}
1928 .if exists(${.CURDIR}/${_DIR}/Makefile)
1929 _generic_libs+= ${_DIR}
1933 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1935 .if ${MK_CDDL} != "no"
1936 _cddl_lib_libumem= cddl/lib/libumem
1937 _cddl_lib_libnvpair= cddl/lib/libnvpair
1938 _cddl_lib_libavl= cddl/lib/libavl
1939 _cddl_lib_libuutil= cddl/lib/libuutil
1940 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1941 _cddl_lib_libctf= cddl/lib/libctf
1943 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1944 cddl/lib/libzfs__L: lib/libgeom__L
1945 cddl/lib/libctf__L: lib/libz__L
1947 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
1948 # on select architectures though (see cddl/lib/Makefile)
1949 .if ${MACHINE_CPUARCH} != "sparc64"
1950 _prebuild_libs+= lib/libproc lib/librtld_db
1953 .if ${MK_CRYPT} != "no"
1954 .if ${MK_OPENSSL} != "no"
1955 _secure_lib_libcrypto= secure/lib/libcrypto
1956 _secure_lib_libssl= secure/lib/libssl
1957 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1958 .if ${MK_LDNS} != "no"
1959 _lib_libldns= lib/libldns
1960 lib/libldns__L: secure/lib/libcrypto__L
1962 .if ${MK_OPENSSH} != "no"
1963 _secure_lib_libssh= secure/lib/libssh
1964 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1965 .if ${MK_LDNS} != "no"
1966 secure/lib/libssh__L: lib/libldns__L
1968 .if ${MK_KERBEROS_SUPPORT} != "no"
1969 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1970 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1971 lib/libmd__L kerberos5/lib/libroken__L
1975 _secure_lib= secure/lib
1978 .if ${MK_KERBEROS} != "no"
1979 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1980 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1981 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1982 kerberos5/lib/libwind__L lib/libsqlite3__L
1983 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1984 kerberos5/lib/libroken__L lib/libcom_err__L
1985 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1986 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1987 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1988 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1989 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1990 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
1991 kerberos5/lib/libroken__L: lib/libcrypt__L
1992 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
1993 kerberos5/lib/libheimbase__L: lib/libthr__L
1994 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
1997 lib/libsqlite3__L: lib/libthr__L
1999 .if ${MK_GSSAPI} != "no"
2000 _lib_libgssapi= lib/libgssapi
2003 .if ${MK_KERBEROS} != "no"
2004 _kerberos5_lib= kerberos5/lib
2005 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2006 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2007 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2008 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2009 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2010 _kerberos5_lib_libroken= kerberos5/lib/libroken
2011 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2012 _libsqlite3= lib/libsqlite3
2013 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2014 _kerberos5_lib_libwind= kerberos5/lib/libwind
2015 _libcom_err= lib/libcom_err
2018 .if ${MK_NIS} != "no"
2019 _lib_libypclnt= lib/libypclnt
2022 .if ${MK_OPENSSL} == "no"
2023 lib/libradius__L: lib/libmd__L
2027 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2028 .if ${MK_CXX} != "no"
2029 .if ${MK_LIBCPLUSPLUS} != "no"
2030 lib/libproc__L: lib/libcxxrt__L
2031 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2032 lib/libproc__L: gnu/lib/libsupc++__L
2036 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2038 .for _lib in ${_prereq_libs}
2039 ${_lib}__PL: .PHONY .MAKE
2040 .if exists(${.CURDIR}/${_lib})
2041 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2042 cd ${.CURDIR}/${_lib}; \
2043 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2044 if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; fi; \
2045 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2046 DIRPRFX=${_lib}/ all; \
2047 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2048 DIRPRFX=${_lib}/ install
2052 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
2053 ${_lib}__L: .PHONY .MAKE
2054 .if exists(${.CURDIR}/${_lib})
2055 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2056 cd ${.CURDIR}/${_lib}; \
2057 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2058 if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; fi; \
2059 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2060 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2064 # libpam is special: we need to build static PAM modules before
2065 # static PAM library, and dynamic PAM library before dynamic PAM
2067 lib/libpam__L: .PHONY .MAKE
2068 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
2069 cd ${.CURDIR}/lib/libpam; \
2070 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj; \
2071 if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ depend; fi; \
2072 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2073 -D_NO_LIBPAM_SO_YET all; \
2074 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2075 -D_NO_LIBPAM_SO_YET install
2077 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2078 _startup_libs: ${_startup_libs:S/$/__L/}
2079 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2080 _generic_libs: ${_generic_libs:S/$/__L/}
2082 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2083 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2084 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2085 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2086 # parallel. This is safe for the world stage of buildworld though since it has
2087 # already built libraries in a proper order and installed includes into
2088 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2089 # avoid trashing a system if it crashes mid-install.
2090 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2094 .include <bsd.subdir.mk>
2096 .if make(check-old) || make(check-old-dirs) || \
2097 make(check-old-files) || make(check-old-libs) || \
2098 make(delete-old) || make(delete-old-dirs) || \
2099 make(delete-old-files) || make(delete-old-libs)
2102 # check for / delete old files section
2105 .include "ObsoleteFiles.inc"
2107 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2108 else you can not start such an application. Consult UPDATING for more \
2109 information regarding how to cope with the removal/revision bump of a \
2112 .if !defined(BATCH_DELETE_OLD_FILES)
2119 @echo ">>> Removing old files (only deletes safe to delete libs)"
2120 # Ask for every old file if the user really wants to remove it.
2121 # It's annoying, but better safe than sorry.
2122 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2123 # argument list will get too long. Using .for/.endfor make "loops" will make
2124 # the Makefile parser segfault.
2127 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2128 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2129 while read file; do \
2130 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2131 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2132 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2134 for ext in debug symbols; do \
2135 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2136 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2137 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2142 # Remove catpages without corresponding manpages.
2144 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2145 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2146 while read catpage; do \
2148 if [ ! -e "$${manpage}" ]; then \
2149 rm ${RM_I} $${catpage} <&3; \
2152 @echo ">>> Old files removed"
2155 @echo ">>> Checking for old files"
2157 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2158 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2159 while read file; do \
2160 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2161 echo "${DESTDIR}/$${file}"; \
2163 for ext in debug symbols; do \
2164 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2165 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2169 # Check for catpages without corresponding manpages.
2170 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2171 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2172 while read catpage; do \
2174 if [ ! -e "$${manpage}" ]; then \
2180 @echo ">>> Removing old libraries"
2181 @echo "${OLD_LIBS_MESSAGE}" | fmt
2184 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2185 -V OLD_LIBS | xargs -n1 | \
2186 while read file; do \
2187 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2188 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2189 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2191 for ext in debug symbols; do \
2192 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2193 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2194 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2199 @echo ">>> Old libraries removed"
2202 @echo ">>> Checking for old libraries"
2204 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2205 -V OLD_LIBS | xargs -n1 | \
2206 while read file; do \
2207 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2208 echo "${DESTDIR}/$${file}"; \
2210 for ext in debug symbols; do \
2211 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2212 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2218 @echo ">>> Removing old directories"
2220 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2221 -V OLD_DIRS | xargs -n1 | sort -r | \
2222 while read dir; do \
2223 if [ -d "${DESTDIR}/$${dir}" ]; then \
2224 rmdir -v "${DESTDIR}/$${dir}" || true; \
2225 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2226 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2229 @echo ">>> Old directories removed"
2232 @echo ">>> Checking for old directories"
2234 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2235 -V OLD_DIRS | xargs -n1 | \
2236 while read dir; do \
2237 if [ -d "${DESTDIR}/$${dir}" ]; then \
2238 echo "${DESTDIR}/$${dir}"; \
2239 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2240 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2244 delete-old: delete-old-files delete-old-dirs
2245 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2247 check-old: check-old-files check-old-libs check-old-dirs
2248 @echo "To remove old files and directories run '${MAKE} delete-old'."
2249 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2254 # showconfig - show build configuration.
2257 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2258 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2260 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2261 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2263 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2264 .if exists(${KERNCONFDIR}/${KERNCONF})
2265 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2266 '${KERNCONFDIR}/${KERNCONF}' ; echo
2272 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2273 DTBOUTPUTPATH= ${.CURDIR}
2277 # Build 'standalone' Device Tree Blob
2280 @PATH=${TMPPATH} MACHINE=${TARGET} \
2281 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2282 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2287 # In the following, the first 'rm' in a series will usually remove all
2288 # files and directories. If it does not, then there are probably some
2289 # files with file flags set, so this unsets them and tries the 'rm' a
2290 # second time. There are situations where this target will be cleaning
2291 # some directories via more than one method, but that duplication is
2292 # needed to correctly handle all the possible situations. Removing all
2293 # files without file flags set in the first 'rm' instance saves time,
2294 # because 'chflags' will need to operate on fewer files afterwards.
2296 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2297 # created by bsd.obj.mk, except that we don't want to .include that file
2300 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2302 .if exists(${BW_CANONICALOBJDIR}/)
2303 -rm -rf ${BW_CANONICALOBJDIR}/*
2304 -chflags -R 0 ${BW_CANONICALOBJDIR}
2305 rm -rf ${BW_CANONICALOBJDIR}/*
2307 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2308 # To be safe in this case, fall back to a 'make cleandir'
2309 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2312 .if defined(TARGET) && defined(TARGET_ARCH)
2314 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2315 XDEV_CPUTYPE?=${CPUTYPE}
2317 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2320 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2321 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2322 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2323 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2324 CPUTYPE=${XDEV_CPUTYPE}
2326 XDDIR=${TARGET_ARCH}-freebsd
2329 .error XDTP variable should be an absolute path
2332 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2333 INSTALL="sh ${.CURDIR}/tools/install.sh"
2335 TOOLS_PREFIX=${XDTP}
2336 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2337 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2338 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2339 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2340 CPP="${CPP} ${CD2CFLAGS}" \
2341 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2343 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2344 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2345 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2346 XDDESTDIR=${DESTDIR}/${XDTP}
2348 OSREL!= uname -r | sed -e 's/[-(].*//'
2351 .ORDER: xdev-build xdev-install xdev-links
2352 xdev: xdev-build xdev-install
2354 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2355 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2357 _xb-worldtmp: .PHONY
2358 mkdir -p ${CDTMP}/usr
2359 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2360 -p ${CDTMP}/usr >/dev/null
2362 _xb-bootstrap-tools: .PHONY
2366 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
2367 cd ${.CURDIR}/${_tool}; \
2368 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2369 if [ -z "${NO_DEPEND}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ depend; fi; \
2370 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2371 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2374 _xb-build-tools: .PHONY
2375 ${_+_}@cd ${.CURDIR}; \
2376 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2378 _xb-cross-tools: .PHONY
2386 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
2387 cd ${.CURDIR}/${_tool}; \
2388 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2389 if [ -z "${NO_DEPEND}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ depend; fi; \
2390 ${CDMAKE} DIRPRFX=${_tool}/ all
2394 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2395 mkdir -p ${XDDESTDIR}
2396 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2397 -p ${XDDESTDIR} >/dev/null
2398 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2399 -p ${XDDESTDIR}/usr >/dev/null
2400 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2401 -p ${XDDESTDIR}/usr/include >/dev/null
2402 .if ${MK_LIB32} != "no"
2403 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
2404 -p ${XDDESTDIR}/usr >/dev/null
2406 .if ${MK_TESTS} != "no"
2407 mkdir -p ${XDDESTDIR}${TESTSBASE}
2408 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2409 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2412 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2413 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2415 _xi-cross-tools: .PHONY
2416 @echo "_xi-cross-tools"
2424 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2425 cd ${.CURDIR}/${_tool}; \
2426 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2429 _xi-includes: .PHONY
2430 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2431 DESTDIR=${XDDESTDIR}
2433 _xi-libraries: .PHONY
2434 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2435 DESTDIR=${XDDESTDIR}
2438 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2439 mkdir -p ../../../../usr/bin; \
2441 ln -sf ../../${XDTP}/usr/bin/$$i \
2442 ../../../../usr/bin/${XDDIR}-$$i; \
2443 ln -sf ../../${XDTP}/usr/bin/$$i \
2444 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2447 xdev xdev-build xdev-install xdev-links:
2448 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"