4 # Make command line options:
5 # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6 # -DNO_CLEAN do not clean at all
7 # -DDB_FROM_SRC use the user/group databases in src/etc instead of
8 # the system database when installing.
9 # -DNO_SHARE do not go into share subdir
10 # -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,DEPEND,OBJ}
11 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
12 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
13 # -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
14 # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
15 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
16 # -DNO_ROOT install without using root privilege
17 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
18 # -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects
19 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
20 # LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list
21 # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
22 # LOCAL_MTREE="list of mtree files" to process to allow local directories
23 # to be created before files are installed
24 # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
26 # METALOG="path to metadata log" to write permission and ownership
27 # when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
28 # TARGET="machine" to crossbuild world for a different machine type
29 # TARGET_ARCH= may be required when a TARGET supports multiple endians
30 # BUILDENV_SHELL= shell to launch for the buildenv target (def:${SHELL})
31 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
32 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
33 # SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
34 # All libraries and includes, and some build tools will still build.
37 # The intended user-driven targets are:
38 # buildworld - rebuild *everything*, including glue to help do upgrades
39 # installworld- install everything built by "buildworld"
40 # checkworld - run test suite on installed world
41 # doxygen - build API documentation of the kernel
42 # update - convenient way to update your source tree (eg: svn/svnup)
44 # Standard targets (not defined here) are documented in the makefiles in
45 # /usr/share/mk. These include:
46 # obj depend all install clean cleandepend cleanobj
48 .if !defined(TARGET) || !defined(TARGET_ARCH)
49 .error "Both TARGET and TARGET_ARCH must be defined."
52 LOCALBASE?= /usr/local
54 # Cross toolchain changes must be in effect before bsd.compiler.mk
55 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
56 .if defined(CROSS_TOOLCHAIN)
57 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
58 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
60 .include <bsd.compiler.mk> # don't depend on src.opts.mk doing it
61 .include "share/mk/src.opts.mk"
63 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
64 # keep the users system reasonably usable. For static->dynamic root upgrades,
65 # we don't want to install a dynamic binary without rtld and the needed
66 # libraries. More commonly, for dynamic root, we don't want to install a
67 # binary that requires a newer library version that hasn't been installed yet.
68 # This ordering is not a guarantee though. The only guarantee of a working
69 # system here would require fine-grained ordering of all components based
70 # on their dependencies.
72 .if !empty(SUBDIR_OVERRIDE)
73 SUBDIR= ${SUBDIR_OVERRIDE}
76 .if !defined(NO_ROOT) && (make(installworld) || make(install))
77 # Ensure libraries are installed before progressing.
81 .if ${MK_CDDL} != "no"
85 .if ${MK_KERBEROS} != "no"
88 .if ${MK_RESCUE} != "no"
92 .if ${MK_CRYPT} != "no"
95 .if !defined(NO_SHARE)
98 SUBDIR+=sys usr.bin usr.sbin
99 .if ${MK_TESTS} != "no"
102 .if ${MK_OFED} != "no"
106 # Local directories are last, since it is nice to at least get the base
107 # system rebuilt before you do them.
108 .for _DIR in ${LOCAL_DIRS}
109 .if exists(${.CURDIR}/${_DIR}/Makefile)
113 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
114 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
115 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
116 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
117 _REDUNDENT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
119 .for _DIR in ${LOCAL_LIB_DIRS}
120 .if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
123 .warning ${_DIR} not added to SUBDIR list. See UPDATING 20141121.
127 # We must do etc/ last as it hooks into building the man whatis file
128 # by calling 'makedb' in share/man. This is only relevant for
129 # install/distribute so they build the whatis file after every manpage is
131 .if make(installworld) || make(install)
136 .endif # !empty(SUBDIR_OVERRIDE)
139 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
142 .if defined(NO_CLEANDIR)
143 CLEANDIR= clean cleandepend
148 # FAST_DEPEND can skip depend tree-walks.
149 .if ${MK_FAST_DEPEND} == "yes"
153 # Ensure shell checks later have a value.
154 .if defined(NO_DEPEND)
159 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
161 .if empty(SHELL:M*csh*)
162 BUILDENV_SHELL?=${SHELL}
164 BUILDENV_SHELL?=/bin/sh
167 SVN?= /usr/local/bin/svn
170 MAKEOBJDIRPREFIX?= /usr/obj
171 .if !defined(OSRELDATE)
172 .if exists(/usr/include/osreldate.h)
173 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
174 /usr/include/osreldate.h
181 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
182 .if !defined(VERSION)
183 REVISION!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V REVISION
184 BRANCH!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V BRANCH
185 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
186 ${SRCDIR}/sys/sys/param.h
187 VERSION= FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
191 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 _CPUTYPE!= MK_AUTO_OBJ=no MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
233 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
234 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
235 .error CPUTYPE global should be set with ?=.
238 BUILD_ARCH!= uname -p
239 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
240 .error To cross-build, set TARGET_ARCH.
243 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
244 OBJTREE= ${MAKEOBJDIRPREFIX}
246 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
248 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
249 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
250 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
251 STRICTTMPPATH= ${BPATH}:${XPATH}
252 TMPPATH= ${STRICTTMPPATH}:${PATH}
255 # Avoid running mktemp(1) unless actually needed.
256 # It may not be functional, e.g., due to new ABI
257 # when in the middle of installing over this system.
259 .if make(distributeworld) || make(installworld)
260 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
264 # Building a world goes through the following stages
266 # 1. legacy stage [BMAKE]
267 # This stage is responsible for creating compatibility
268 # shims that are needed by the bootstrap-tools,
269 # build-tools and cross-tools stages. These are generally
270 # APIs that tools from one of those three stages need to
271 # build that aren't present on the host.
272 # 1. bootstrap-tools stage [BMAKE]
273 # This stage is responsible for creating programs that
274 # are needed for backward compatibility reasons. They
275 # are not built as cross-tools.
276 # 2. build-tools stage [TMAKE]
277 # This stage is responsible for creating the object
278 # tree and building any tools that are needed during
279 # the build process. Some programs are listed during
280 # this phase because they build binaries to generate
281 # files needed to build these programs. This stage also
282 # builds the 'build-tools' target rather than 'all'.
283 # 3. cross-tools stage [XMAKE]
284 # This stage is responsible for creating any tools that
285 # are needed for building the system. A cross-compiler is one
286 # of them. This differs from build tools in two ways:
287 # 1. the 'all' target is built rather than 'build-tools'
288 # 2. these tools are installed into TMPPATH for stage 4.
289 # 4. world stage [WMAKE]
290 # This stage actually builds the world.
291 # 5. install stage (optional) [IMAKE]
292 # This stage installs a previously built world.
297 # Common environment for world related stages
298 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
299 MACHINE_ARCH=${TARGET_ARCH} \
301 CPUTYPE=${TARGET_CPUTYPE}
302 .if ${MK_GROFF} != "no"
303 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
304 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
305 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
307 .if defined(TARGET_CFLAGS)
308 CROSSENV+= ${TARGET_CFLAGS}
311 # bootstrap-tools stage
312 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
313 PATH=${BPATH}:${PATH} \
314 WORLDTMP=${WORLDTMP} \
315 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
316 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
318 BOOTSTRAPPING=${OSRELDATE} \
320 MK_HTML=no NO_LINT=yes MK_MAN=no \
321 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
322 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
323 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
324 MK_LLDB=no MK_TESTS=no \
327 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
328 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
332 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
333 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
334 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
336 BOOTSTRAPPING=${OSRELDATE} \
339 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
340 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
341 MK_LLDB=no MK_TESTS=no
344 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
345 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
346 MK_GDB=no MK_TESTS=no
349 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
350 PATH=${BPATH}:${PATH} \
352 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
353 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
355 BOOTSTRAPPING=${OSRELDATE} \
357 MK_HTML=no -DNO_LINT MK_MAN=no \
358 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
359 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
362 WMAKEENV= ${CROSSENV} \
364 INSTALL="sh ${.CURDIR}/tools/install.sh" \
368 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
370 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
373 .if defined(CROSS_TOOLCHAIN_PREFIX)
374 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
375 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
378 # If we do not have a bootstrap binutils (because the in-tree one does not
379 # support the target architecture), provide a default cross-binutils prefix.
380 # This allows aarch64 builds, for example, to automatically use the
381 # aarch64-binutils port or package.
382 .if !make(showconfig)
383 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
384 !defined(CROSS_BINUTILS_PREFIX)
385 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
386 .if !exists(${CROSS_BINUTILS_PREFIX})
387 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
392 XCOMPILERS= CC CXX CPP
393 .for COMPILER in ${XCOMPILERS}
394 .if defined(CROSS_COMPILER_PREFIX)
395 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
397 X${COMPILER}?= ${${COMPILER}}
400 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
401 .for BINUTIL in ${XBINUTILS}
402 .if defined(CROSS_BINUTILS_PREFIX) && \
403 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
404 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
406 X${BINUTIL}?= ${${BINUTIL}}
409 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
410 DEPFLAGS="${DEPFLAGS}" \
411 CPP="${XCPP} ${XCFLAGS}" \
412 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
413 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
414 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
417 .if ${XCC:N${CCACHE_BIN}:M/*}
418 .if defined(CROSS_BINUTILS_PREFIX)
419 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
420 # directory, but the compiler will look in the right place for it's
421 # tools so we don't need to tell it where to look.
422 .if exists(${CROSS_BINUTILS_PREFIX})
423 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
426 BFLAGS+= -B${WORLDTMP}/usr/bin
428 .if ${TARGET} == "arm"
429 .if ${TARGET_ARCH:M*hf*} != ""
430 TARGET_ABI= gnueabihf
435 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
436 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
437 XCXXFLAGS+= -I${WORLDTMP}/usr/include/c++/v1 -std=gnu++11 -L${WORLDTMP}/../lib/libc++
438 # XXX: DEPFLAGS is a workaround for not properly passing CXXFLAGS to sub-makes
439 # due to CXX="${XCXX} ${XCXXFLAGS}". bsd.dep.mk does use CXXFLAGS when
440 # building C++ files so this can come out if passing CXXFLAGS down is fixed.
441 DEPFLAGS+= -I${WORLDTMP}/usr/include/c++/v1
444 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
445 XCFLAGS+= -target ${TARGET_TRIPLE}
447 XCFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
448 XCXXFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
450 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
451 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
453 XCXXFLAGS+= ${BFLAGS}
457 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
459 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
461 LIB32_OBJTREE= ${OBJTREE}${.CURDIR}/world32
462 LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
464 .if ${TARGET_ARCH} == "amd64"
465 .if empty(TARGET_CPUTYPE)
466 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
468 LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
470 LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
471 MACHINE_CPU="i686 mmx sse sse2"
474 LD="${XLD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
475 OBJCOPY="${XOBJCOPY}"
477 .elif ${TARGET_ARCH} == "powerpc64"
478 .if empty(TARGET_CPUTYPE)
479 LIB32CPUFLAGS= -mcpu=powerpc
481 LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
483 LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
485 LD="${XLD} -m elf32ppc_fbsd" \
486 OBJCOPY="${XOBJCOPY}"
490 LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
491 -isystem ${LIB32TMP}/usr/include/ \
492 -L${LIB32TMP}/usr/lib32 \
493 -B${LIB32TMP}/usr/lib32
494 .if ${XCC:N${CCACHE_BIN}:M/*}
495 LIB32FLAGS+= --sysroot=${WORLDTMP}
498 # Yes, the flags are redundant.
499 LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${LIB32_OBJTREE} \
500 _LDSCRIPTROOT=${LIB32TMP} \
501 INSTALL="sh ${.CURDIR}/tools/install.sh" \
504 SHLIBDIR=/usr/lib32 \
505 DTRACE="${DTRACE} -32"
506 LIB32WMAKEFLAGS+= CC="${XCC} ${LIB32FLAGS}" \
507 CXX="${XCXX} ${LIB32FLAGS}" \
508 DESTDIR=${LIB32TMP} \
516 LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
518 LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \
519 MK_TOOLCHAIN=no ${IMAKE_INSTALL}
522 IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*}
523 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
524 ${IMAKE_INSTALL} ${IMAKE_MTREE}
525 .if empty(.MAKEFLAGS:M-n)
526 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
527 LD_LIBRARY_PATH=${INSTALLTMP} \
528 PATH_LOCALE=${INSTALLTMP}/locale
529 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
531 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
533 .if defined(DB_FROM_SRC)
534 INSTALLFLAGS+= -N ${.CURDIR}/etc
535 MTREEFLAGS+= -N ${.CURDIR}/etc
537 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
538 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
540 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
541 IMAKE+= -DNO_ROOT METALOG=${METALOG}
542 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
545 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
546 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
547 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
551 KMAKEENV= ${WMAKEENV}
552 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
557 # Attempt to rebuild the entire system, with reasonable chance of
558 # success, regardless of how old your existing system is.
561 .if ${.CURDIR:C/[^,]//g} != ""
562 # The m4 build of sendmail files doesn't like it if ',' is used
563 # anywhere in the path of it's files.
565 @echo "*** Error: path to source tree contains a comma ','"
570 @echo "--------------------------------------------------------------"
571 @echo ">>> Rebuilding the temporary build tree"
572 @echo "--------------------------------------------------------------"
573 .if !defined(NO_CLEAN)
575 .if defined(LIB32TMP)
579 rm -rf ${WORLDTMP}/legacy/usr/include
580 # XXX - These can depend on any header file.
581 rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c
582 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
585 lib lib/casper usr legacy/bin legacy/usr
586 mkdir -p ${WORLDTMP}/${_dir}
588 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
589 -p ${WORLDTMP}/legacy/usr >/dev/null
590 .if ${MK_GROFF} != "no"
591 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
592 -p ${WORLDTMP}/legacy/usr >/dev/null
594 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
595 -p ${WORLDTMP}/usr >/dev/null
596 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
597 -p ${WORLDTMP}/usr/include >/dev/null
598 ln -sf ${.CURDIR}/sys ${WORLDTMP}
599 .if ${MK_DEBUG_FILES} != "no"
600 # We could instead disable debug files for these build stages
601 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
602 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
603 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
604 -p ${WORLDTMP}/usr/lib >/dev/null
606 .if ${MK_LIB32} != "no"
607 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
608 -p ${WORLDTMP}/usr >/dev/null
609 .if ${MK_DEBUG_FILES} != "no"
610 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
611 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
612 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
613 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
616 .if ${MK_TESTS} != "no"
617 mkdir -p ${WORLDTMP}${TESTSBASE}
618 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
619 -p ${WORLDTMP}${TESTSBASE} >/dev/null
620 .if ${MK_DEBUG_FILES} != "no"
621 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
622 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
623 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
626 .for _mtree in ${LOCAL_MTREE}
627 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
631 @echo "--------------------------------------------------------------"
632 @echo ">>> stage 1.1: legacy release compatibility shims"
633 @echo "--------------------------------------------------------------"
634 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
637 @echo "--------------------------------------------------------------"
638 @echo ">>> stage 1.2: bootstrap tools"
639 @echo "--------------------------------------------------------------"
640 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
642 .if !defined(NO_CLEAN)
644 @echo "--------------------------------------------------------------"
645 @echo ">>> stage 2.1: cleaning up the object tree"
646 @echo "--------------------------------------------------------------"
647 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
648 .if defined(LIB32TMP)
649 ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR}
654 @echo "--------------------------------------------------------------"
655 @echo ">>> stage 2.2: rebuilding the object tree"
656 @echo "--------------------------------------------------------------"
657 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
660 @echo "--------------------------------------------------------------"
661 @echo ">>> stage 2.3: build tools"
662 @echo "--------------------------------------------------------------"
663 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
666 @echo "--------------------------------------------------------------"
667 @echo ">>> stage 3: cross tools"
668 @echo "--------------------------------------------------------------"
669 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
670 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
673 @echo "--------------------------------------------------------------"
674 @echo ">>> stage 4.1: building includes"
675 @echo "--------------------------------------------------------------"
676 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
677 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
678 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
680 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
681 ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks includes
685 @echo "--------------------------------------------------------------"
686 @echo ">>> stage 4.2: building libraries"
687 @echo "--------------------------------------------------------------"
688 ${_+_}cd ${.CURDIR}; \
689 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
690 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
693 @echo "--------------------------------------------------------------"
694 @echo ">>> stage 4.3: make dependencies"
695 @echo "--------------------------------------------------------------"
696 ${_+_}cd ${.CURDIR}; ${WMAKE} depend
699 @echo "--------------------------------------------------------------"
700 @echo ">>> stage 4.4: building everything"
701 @echo "--------------------------------------------------------------"
702 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
703 .if defined(LIB32TMP)
706 @echo "--------------------------------------------------------------"
707 @echo ">>> stage 5.1: building 32 bit shim libraries"
708 @echo "--------------------------------------------------------------"
709 mkdir -p ${LIB32TMP}/usr/include
710 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
711 -p ${LIB32TMP}/usr >/dev/null
712 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
713 -p ${LIB32TMP}/usr/include >/dev/null
714 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
715 -p ${LIB32TMP}/usr >/dev/null
716 .if ${MK_DEBUG_FILES} != "no"
717 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
718 -p ${LIB32TMP}/usr/lib >/dev/null
719 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
720 -p ${LIB32TMP}/usr/lib/debug/usr >/dev/null
723 ln -sf ${.CURDIR}/sys ${WORLDTMP}
724 .for _t in obj includes
725 ${_+_}cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
726 ${_+_}cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
727 .if ${MK_CDDL} != "no"
728 ${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
730 ${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
731 .if ${MK_CRYPT} != "no"
732 ${_+_}cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
734 .if ${MK_KERBEROS} != "no"
735 ${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
738 .for _dir in usr.bin/lex/lib
739 ${_+_}cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
741 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
742 ${_+_}cd ${.CURDIR}/${_dir}; \
743 WORLDTMP=${WORLDTMP} \
744 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
745 MAKEOBJDIRPREFIX=${LIB32_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \
746 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
749 ${_+_}cd ${.CURDIR}; \
750 ${LIB32WMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
751 .for _t in obj depend all
752 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
753 -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t}
754 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
755 DIRPRFX=usr.bin/ldd ${_t}
758 distribute32 install32: .MAKE .PHONY
759 ${_+_}cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
760 .if ${MK_CDDL} != "no"
761 ${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
763 ${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
764 .if ${MK_CRYPT} != "no"
765 ${_+_}cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
767 .if ${MK_KERBEROS} != "no"
768 ${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
770 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \
771 PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
772 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} \
777 WMAKE_TGTS+= _worldtmp _legacy
778 .if empty(SUBDIR_OVERRIDE)
779 WMAKE_TGTS+= _bootstrap-tools
781 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
782 WMAKE_TGTS+= _includes _libraries
783 .if !defined(NO_DEPEND)
786 WMAKE_TGTS+= everything
787 .if defined(LIB32TMP) && ${MK_LIB32} != "no" && empty(SUBDIR_OVERRIDE)
791 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
792 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
795 @echo "--------------------------------------------------------------"
796 @echo ">>> World build started on `LC_ALL=C date`"
797 @echo "--------------------------------------------------------------"
801 @echo "--------------------------------------------------------------"
802 @echo ">>> World build completed on `LC_ALL=C date`"
803 @echo "--------------------------------------------------------------"
806 # We need to have this as a target because the indirection between Makefile
807 # and Makefile.inc1 causes the correct PATH to be used, rather than a
808 # modification of the current environment's PATH. In addition, we need
809 # to quote multiword values.
812 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
814 .if ${.TARGETS:Mbuildenv}
815 .if ${.MAKEFLAGS:M-j}
816 .error The buildenv target is incompatible with -j
819 BUILDENV_DIR?= ${.CURDIR}
821 @echo Entering world for ${TARGET_ARCH}:${TARGET}
822 .if ${BUILDENV_SHELL:M*zsh*}
823 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
825 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
828 TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
829 toolchain: ${TOOLCHAIN_TGTS}
830 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
835 # Checks to be sure system is ready for installworld/installkernel.
837 installcheck: _installcheck_world _installcheck_kernel
839 _installcheck_kernel:
842 # Require DESTDIR to be set if installing for a different architecture or
843 # using the user/group database in the source tree.
845 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
847 .if !make(distributeworld)
848 _installcheck_world: __installcheck_DESTDIR
849 _installcheck_kernel: __installcheck_DESTDIR
850 __installcheck_DESTDIR:
851 .if !defined(DESTDIR) || empty(DESTDIR)
852 @echo "ERROR: Please set DESTDIR!"; \
858 .if !defined(DB_FROM_SRC)
860 # Check for missing UIDs/GIDs.
862 CHECK_UIDS= auditdistd
864 .if ${MK_SENDMAIL} != "no"
870 CHECK_GIDS+= proxy authpf
872 .if ${MK_UNBOUND} != "no"
876 _installcheck_world: __installcheck_UGID
878 .for uid in ${CHECK_UIDS}
879 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
880 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
884 .for gid in ${CHECK_GIDS}
885 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
886 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
893 # Required install tools to be saved in a scratch dir for safety.
895 .if ${MK_ZONEINFO} != "no"
896 _zoneinfo= zic tzsetup
899 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
900 date echo egrep find grep id install ${_install-info} \
901 ln make mkdir mtree mv pwd_mkdb \
902 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
905 # Needed for share/man
906 .if ${MK_MAN} != "no"
913 # Distributes everything compiled by a `buildworld'.
917 # Installs everything compiled by a 'buildworld'.
920 # Non-base distributions produced by the base system
921 EXTRA_DISTRIBUTIONS= doc
922 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
923 EXTRA_DISTRIBUTIONS+= lib32
925 .if ${MK_TESTS} != "no"
926 EXTRA_DISTRIBUTIONS+= tests
930 .if ${MK_DEBUG_FILES} != "no"
931 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
934 MTREE_MAGIC?= mtree 2.0
936 distributeworld installworld: _installcheck_world
937 mkdir -p ${INSTALLTMP}
938 progs=$$(for prog in ${ITOOLS}; do \
939 if progpath=`which $$prog`; then \
942 echo "Required tool $$prog not found in PATH." >&2; \
946 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
947 while read line; do \
949 if [ "$$2 $$3" != "not found" ]; then \
952 echo "Required library $$1 not found." >&2; \
956 cp $$libs $$progs ${INSTALLTMP}
957 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
959 -mkdir -p ${METALOG:H}
960 echo "#${MTREE_MAGIC}" > ${METALOG}
962 .if make(distributeworld)
963 .for dist in ${EXTRA_DISTRIBUTIONS}
964 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
965 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
966 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
967 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
968 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
969 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
970 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
971 .if ${MK_DEBUG_FILES} != "no"
972 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
973 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
975 .if ${MK_LIB32} != "no"
976 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
977 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
978 .if ${MK_DEBUG_FILES} != "no"
979 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
980 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
983 .if ${MK_TESTS} != "no" && ${dist} == "tests"
984 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
985 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
986 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
987 .if ${MK_DEBUG_FILES} != "no"
988 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
989 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
993 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
994 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
995 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
996 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
997 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
998 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
999 .if ${MK_LIB32} != "no"
1000 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib32.dist | \
1001 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1005 -mkdir ${DESTDIR}/${DISTDIR}/base
1006 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1007 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1008 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1009 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1011 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1012 ${IMAKEENV} rm -rf ${INSTALLTMP}
1013 .if make(distributeworld)
1014 .for dist in ${EXTRA_DISTRIBUTIONS}
1015 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
1017 .if defined(NO_ROOT)
1018 .for dist in base ${EXTRA_DISTRIBUTIONS}
1019 @# For each file that exists in this dist, print the corresponding
1020 @# line from the METALOG. This relies on the fact that
1021 @# a line containing only the filename will sort immediatly before
1022 @# the relevant mtree line.
1023 cd ${DESTDIR}/${DISTDIR}; \
1024 find ./${dist} | sort -u ${METALOG} - | \
1025 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1026 ${DESTDIR}/${DISTDIR}/${dist}.meta
1028 .for dist in ${DEBUG_DISTRIBUTIONS}
1029 @# For each file that exists in this dist, print the corresponding
1030 @# line from the METALOG. This relies on the fact that
1031 @# a line containing only the filename will sort immediatly before
1032 @# the relevant mtree line.
1033 cd ${DESTDIR}/${DISTDIR}; \
1034 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1035 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1036 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1042 .for dist in base ${EXTRA_DISTRIBUTIONS}
1043 .if defined(NO_ROOT)
1044 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1045 tar cvf - --exclude usr/lib/debug \
1046 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1047 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1049 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1050 tar cvf - --exclude usr/lib/debug . | \
1051 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1055 .for dist in ${DEBUG_DISTRIBUTIONS}
1056 . if defined(NO_ROOT)
1057 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1058 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1059 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1061 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1062 tar cvLf - usr/lib/debug | \
1063 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1070 # If you have a build server, you can NFS mount the source and obj directories
1071 # and do a 'make reinstall' on the *client* to install new binaries from the
1072 # most recent server build.
1074 reinstall: .MAKE .PHONY
1075 @echo "--------------------------------------------------------------"
1076 @echo ">>> Making hierarchy"
1077 @echo "--------------------------------------------------------------"
1078 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1079 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1081 @echo "--------------------------------------------------------------"
1082 @echo ">>> Installing everything"
1083 @echo "--------------------------------------------------------------"
1084 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1085 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
1086 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
1089 redistribute: .MAKE .PHONY
1090 @echo "--------------------------------------------------------------"
1091 @echo ">>> Distributing everything"
1092 @echo "--------------------------------------------------------------"
1093 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1094 .if defined(LIB32TMP) && ${MK_LIB32} != "no"
1095 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \
1099 distrib-dirs distribution: .MAKE .PHONY
1100 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1101 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1102 .if make(distribution)
1103 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1104 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1105 METALOG=${METALOG} MK_TESTS=no installconfig
1109 # buildkernel and installkernel
1111 # Which kernels to build and/or install is specified by setting
1112 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1113 # Only the existing (depending TARGET) config files are used
1114 # for building kernels and only the first of these is designated
1115 # as the one being installed.
1117 # Note that we have to use TARGET instead of TARGET_ARCH when
1118 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1119 # be set to cross-build, we have to make sure TARGET is set
1122 .if defined(KERNFAST)
1127 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1128 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1129 KERNCONF=${KERNFAST}
1132 .if ${TARGET_ARCH} == "powerpc64"
1133 KERNCONF?= GENERIC64
1137 INSTKERNNAME?= kernel
1139 KERNSRCDIR?= ${.CURDIR}/sys
1140 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1141 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1142 KERNCONFDIR?= ${KRNLCONFDIR}
1146 .if defined(NO_INSTALLKERNEL)
1147 # All of the BUILDKERNELS loops start at index 1.
1148 BUILDKERNELS+= dummy
1150 .for _kernel in ${KERNCONF}
1151 .if exists(${KERNCONFDIR}/${_kernel})
1152 BUILDKERNELS+= ${_kernel}
1153 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1154 INSTALLKERNEL= ${_kernel}
1159 ${WMAKE_TGTS:N_worldtmp:Nbuild32} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1164 # Builds all kernels defined by BUILDKERNELS.
1166 buildkernel: .MAKE .PHONY
1167 .if empty(BUILDKERNELS:Ndummy)
1168 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1172 .for _kernel in ${BUILDKERNELS:Ndummy}
1173 @echo "--------------------------------------------------------------"
1174 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1175 @echo "--------------------------------------------------------------"
1176 @echo "===> ${_kernel}"
1177 mkdir -p ${KRNLOBJDIR}
1178 .if !defined(NO_KERNELCONFIG)
1180 @echo "--------------------------------------------------------------"
1181 @echo ">>> stage 1: configuring the kernel"
1182 @echo "--------------------------------------------------------------"
1183 cd ${KRNLCONFDIR}; \
1185 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1186 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1188 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1190 @echo "--------------------------------------------------------------"
1191 @echo ">>> stage 2.1: cleaning up the object tree"
1192 @echo "--------------------------------------------------------------"
1193 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1195 .if !defined(NO_KERNELOBJ)
1197 @echo "--------------------------------------------------------------"
1198 @echo ">>> stage 2.2: rebuilding the object tree"
1199 @echo "--------------------------------------------------------------"
1200 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1203 @echo "--------------------------------------------------------------"
1204 @echo ">>> stage 2.3: build tools"
1205 @echo "--------------------------------------------------------------"
1206 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1207 .if !defined(NO_KERNELDEPEND)
1209 @echo "--------------------------------------------------------------"
1210 @echo ">>> stage 3.1: making dependencies"
1211 @echo "--------------------------------------------------------------"
1212 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ
1215 @echo "--------------------------------------------------------------"
1216 @echo ">>> stage 3.2: building everything"
1217 @echo "--------------------------------------------------------------"
1218 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1219 @echo "--------------------------------------------------------------"
1220 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1221 @echo "--------------------------------------------------------------"
1225 # installkernel, etc.
1227 # Install the kernel defined by INSTALLKERNEL
1229 installkernel installkernel.debug \
1230 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1231 .if !defined(NO_INSTALLKERNEL)
1232 .if empty(INSTALLKERNEL)
1233 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1236 @echo "--------------------------------------------------------------"
1237 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1238 @echo "--------------------------------------------------------------"
1239 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1240 ${CROSSENV} PATH=${TMPPATH} \
1241 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1243 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1244 .for _kernel in ${BUILDKERNELS:[2..-1]}
1245 @echo "--------------------------------------------------------------"
1246 @echo ">>> Installing kernel ${_kernel}"
1247 @echo "--------------------------------------------------------------"
1248 cd ${KRNLOBJDIR}/${_kernel}; \
1249 ${CROSSENV} PATH=${TMPPATH} \
1250 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1254 distributekernel distributekernel.debug:
1255 .if !defined(NO_INSTALLKERNEL)
1256 .if empty(INSTALLKERNEL)
1257 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1260 mkdir -p ${DESTDIR}/${DISTDIR}
1261 .if defined(NO_ROOT)
1262 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1264 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1265 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1266 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1267 DESTDIR=${INSTALL_DDIR}/kernel \
1268 ${.TARGET:S/distributekernel/install/}
1269 .if defined(NO_ROOT)
1270 sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1271 ${DESTDIR}/${DISTDIR}/kernel.meta
1274 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1275 .for _kernel in ${BUILDKERNELS:[2..-1]}
1276 .if defined(NO_ROOT)
1277 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1279 cd ${KRNLOBJDIR}/${_kernel}; \
1280 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1281 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1282 KERNEL=${INSTKERNNAME}.${_kernel} \
1283 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1284 ${.TARGET:S/distributekernel/install/}
1285 .if defined(NO_ROOT)
1286 sed -e 's|^./kernel|.|' \
1287 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1288 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1294 .if defined(NO_ROOT)
1295 .if !defined(NO_INSTALLKERNEL)
1296 cd ${DESTDIR}/${DISTDIR}/kernel; \
1297 tar cvf - --exclude '*.debug' \
1298 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1299 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1301 cd ${DESTDIR}/${DISTDIR}/kernel; \
1302 tar cvf - --include '*/*/*.debug' \
1303 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1304 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1305 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1306 .for _kernel in ${BUILDKERNELS:[2..-1]}
1307 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1308 tar cvf - --exclude '*.debug' \
1309 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1310 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1311 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1312 tar cvf - --include '*/*/*.debug' \
1313 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1314 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1318 .if !defined(NO_INSTALLKERNEL)
1319 cd ${DESTDIR}/${DISTDIR}/kernel; \
1320 tar cvf - --exclude '*.debug' . | \
1321 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1323 cd ${DESTDIR}/${DISTDIR}/kernel; \
1324 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1325 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1326 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1327 .for _kernel in ${BUILDKERNELS:[2..-1]}
1328 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1329 tar cvf - --exclude '*.debug' . | \
1330 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1331 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1332 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1333 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1342 # Run test suite on installed world.
1345 @if [ ! -x ${LOCALBASE}/bin/kyua ]; then \
1346 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1349 ${_+_}${LOCALBASE}/bin/kyua test -k ${TESTSBASE}/Kyuafile
1355 # Build the API documentation with doxygen
1358 @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1359 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1362 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1367 # Update the source tree(s), by running svn/svnup to update to the
1371 .if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
1372 @echo "--------------------------------------------------------------"
1373 @echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
1374 @echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
1375 @echo "--------------------------------------------------------------"
1378 .if defined(SVN_UPDATE)
1379 @echo "--------------------------------------------------------------"
1380 @echo ">>> Updating ${.CURDIR} using Subversion"
1381 @echo "--------------------------------------------------------------"
1382 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1386 # ------------------------------------------------------------------------
1388 # From here onwards are utility targets used by the 'make world' and
1389 # related targets. If your 'world' breaks, you may like to try to fix
1390 # the problem and manually run the following targets to attempt to
1391 # complete the build. Beware, this is *not* guaranteed to work, you
1392 # need to have a pretty good grip on the current state of the system
1393 # to attempt to manually finish it. If in doubt, 'make world' again.
1397 # legacy: Build compatibility shims for the next three targets. This is a
1398 # minimal set of tools and shims necessary to compensate for older systems
1399 # which don't have the APIs required by the targets built in bootstrap-tools,
1400 # build-tools or cross-tools.
1403 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1404 .if ${BOOTSTRAPPING} < 1100006
1405 _elftoolchain_libs= lib/libelf lib/libdwarf
1409 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1410 @echo "ERROR: Source upgrades from versions prior to 8.0 are not supported."; \
1413 .for _tool in tools/build ${_elftoolchain_libs}
1414 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
1415 cd ${.CURDIR}/${_tool}; \
1416 ${MAKE} DIRPRFX=${_tool}/ obj; \
1417 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1418 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1419 ${MAKE} DIRPRFX=${_tool}/ all; \
1420 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1424 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1425 # are built to build other binaries in the system. However, the focus of these
1426 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1427 # libraries, augmented by -legacy.
1429 _bt= _bootstrap-tools
1431 .if ${MK_GAMES} != "no"
1432 _strfile= usr.bin/fortune/strfile
1435 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1436 _gperf= gnu/usr.bin/gperf
1439 .if ${MK_GROFF} != "no"
1440 _groff= gnu/usr.bin/groff \
1444 .if ${MK_VT} != "no"
1445 _vtfontcvt= usr.bin/vtfontcvt
1448 .if ${BOOTSTRAPPING} < 900002
1452 .if ${BOOTSTRAPPING} < 1000033
1453 _libopenbsd= lib/libopenbsd
1457 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1458 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1461 .if ${BOOTSTRAPPING} < 1000026
1462 _nmtree= lib/libnetbsd \
1465 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1468 .if ${BOOTSTRAPPING} < 1000027
1472 # r264059 support for status=
1473 .if ${BOOTSTRAPPING} < 1100017
1477 # r277259 crunchide: Correct 64-bit section header offset
1478 # r281674 crunchide: always include both 32- and 64-bit ELF support
1479 # r285986 crunchen: use STRIPBIN rather than STRIP
1480 .if ${BOOTSTRAPPING} < 1100078
1481 _crunch= usr.sbin/crunch
1484 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1491 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1493 .if ${MK_BSNMP} != "no"
1494 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1497 # We need to build tblgen when we're building clang either as
1498 # the bootstrap compiler, or as the part of the normal build.
1499 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1501 lib/clang/libllvmsupport \
1502 lib/clang/libllvmtablegen \
1503 usr.bin/clang/llvm-tblgen \
1504 usr.bin/clang/clang-tblgen
1506 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1507 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1510 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1513 .if ${MK_GPL_DTC} != "no"
1514 _dtc= gnu/usr.bin/dtc
1517 .if ${MK_KERBEROS} != "no"
1518 _kerberos5_bootstrap_tools= \
1519 kerberos5/tools/make-roken \
1520 kerberos5/lib/libroken \
1521 kerberos5/lib/libvers \
1522 kerberos5/tools/asn1_compile \
1523 kerberos5/tools/slc \
1526 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1529 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
1530 .if ${MK_MANDOCDB} != "no" && ${BOOTSTRAPPING} < 1100075
1531 _libopenbsd?= lib/libopenbsd
1532 _makewhatis= lib/libsqlite3 \
1534 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1537 bootstrap-tools: .PHONY
1539 # Please document (add comment) why something is in 'bootstrap-tools'.
1540 # Try to bound the building of the bootstrap-tool to just the
1541 # FreeBSD versions that need the tool built at this stage of the build.
1544 ${_kerberos5_bootstrap_tools} \
1567 ${_bt}-${_tool}: .PHONY .MAKE
1568 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1569 cd ${.CURDIR}/${_tool}; \
1570 ${MAKE} DIRPRFX=${_tool}/ obj; \
1571 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1572 ${MAKE} DIRPRFX=${_tool}/ all; \
1573 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1575 bootstrap-tools: ${_bt}-${_tool}
1579 # build-tools: Build special purpose build tools
1581 .if !defined(NO_SHARE)
1582 _share= share/syscons/scrnmaps
1585 .if ${MK_GCC} != "no"
1586 _gcc_tools= gnu/usr.bin/cc/cc_tools
1589 .if ${MK_RESCUE} != "no"
1590 # rescue includes programs that have build-tools targets
1591 _rescue=rescue/rescue
1597 ${LOCAL_TOOL_DIRS} \
1598 lib/ncurses/ncurses \
1599 lib/ncurses/ncursesw \
1604 usr.bin/mkesdb_static \
1605 usr.bin/mkcsmapper_static \
1607 build-tools_${_tool}: .PHONY
1608 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1609 cd ${.CURDIR}/${_tool}; \
1610 ${MAKE} DIRPRFX=${_tool}/ obj; \
1611 ${MAKE} DIRPRFX=${_tool}/ build-tools
1612 build-tools: build-tools_${_tool}
1616 build-tools_${_tool}: .PHONY
1617 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
1618 cd ${.CURDIR}/${_tool}; \
1619 ${MAKE} DIRPRFX=${_tool}/ obj; \
1620 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1621 ${MAKE} DIRPRFX=${_tool}/ all
1622 build-tools: build-tools_${_tool}
1626 # kernel-tools: Build kernel-building tools
1629 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1630 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1631 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1634 # cross-tools: All the tools needed to build the rest of the system after
1635 # we get done with the earlier stages. It is the last set of tools needed
1636 # to begin building the target binaries.
1638 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1639 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1640 _btxld= usr.sbin/btxld
1644 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1645 # resulting from missing bug fixes or ELF Toolchain updates.
1646 .if ${MK_CDDL} != "no"
1647 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1648 cddl/usr.bin/ctfmerge
1651 # If we're given an XAS, don't build binutils.
1652 .if ${XAS:M/*} == ""
1653 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1654 _binutils= gnu/usr.bin/binutils
1656 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1657 _elftctools= lib/libelftc \
1663 # These are not required by the build, but can be useful for developers who
1664 # cross-build on a FreeBSD 10 host:
1665 _elftctools+= usr.bin/addr2line
1667 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1668 # If cross-building with an external binutils we still need to build strip for
1669 # the target (for at least crunchide).
1670 _elftctools= lib/libelftc \
1675 # If an full path to an external cross compiler is given, don't build
1677 .if ${XCC:N${CCACHE_BIN}:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1678 .if ${MK_CLANG_BOOTSTRAP} != "no"
1679 _clang= usr.bin/clang
1680 _clang_libs= lib/clang
1682 .if ${MK_GCC_BOOTSTRAP} != "no"
1686 .if ${MK_USB} != "no"
1687 _usb_tools= sys/boot/usb/tools
1690 cross-tools: .MAKE .PHONY
1701 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1702 cd ${.CURDIR}/${_tool}; \
1703 ${MAKE} DIRPRFX=${_tool}/ obj; \
1704 if [ -z "${NO_DEPEND}" ]; then ${MAKE} DIRPRFX=${_tool}/ depend; fi; \
1705 ${MAKE} DIRPRFX=${_tool}/ all; \
1706 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1709 NXBDESTDIR= ${OBJTREE}/nxb-bin
1710 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1711 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1712 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1713 NXBMAKE= ${NXBENV} ${MAKE} \
1714 LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \
1715 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1716 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1717 MK_GDB=no MK_TESTS=no \
1719 MK_HTML=no NO_LINT=yes MK_MAN=no \
1720 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1721 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1722 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1723 MK_LLDB=no MK_DEBUG_FILES=no
1725 # native-xtools is the current target for qemu-user cross builds of ports
1726 # via poudriere and the imgact_binmisc kernel module.
1727 # For non-clang enabled targets that are still using the in tree gcc
1728 # we must build a gperf binary for one instance of its Makefiles. On
1729 # clang-enabled systems, the gperf binary is obsolete.
1730 native-xtools: .PHONY
1731 .if ${MK_GCC_BOOTSTRAP} != "no"
1732 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1733 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,depend,all,install)"; \
1734 cd ${.CURDIR}/${_gperf}; \
1735 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1736 if [ -z "${NO_DEPEND}" ]; then ${NXBMAKE} DIRPRFX=${_gperf}/ depend; fi; \
1737 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1738 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1740 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1741 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1742 -p ${NXBDESTDIR}/usr >/dev/null
1743 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1744 -p ${NXBDESTDIR}/usr/include >/dev/null
1745 .if ${MK_DEBUG_FILES} != "no"
1746 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1747 -p ${NXBDESTDIR}/usr/lib >/dev/null
1808 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
1809 cd ${.CURDIR}/${_tool}; \
1810 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1811 if [ -z "${NO_DEPEND}" ]; then ${NXBMAKE} DIRPRFX=${_tool}/ depend; fi; \
1812 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1813 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1817 # hierarchy - ensure that all the needed directories are present
1819 hierarchy hier: .MAKE .PHONY
1820 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1823 # libraries - build all libraries, and install them under ${DESTDIR}.
1825 # The list of libraries with dependents (${_prebuild_libs}) and their
1826 # interdependencies (__L) are built automatically by the
1827 # ${.CURDIR}/tools/make_libdeps.sh script.
1829 libraries: .MAKE .PHONY
1830 ${_+_}cd ${.CURDIR}; \
1831 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1832 ${MAKE} -f Makefile.inc1 _startup_libs; \
1833 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1834 ${MAKE} -f Makefile.inc1 _generic_libs
1837 # static libgcc.a prerequisite for shared libc
1839 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1841 # These dependencies are not automatically generated:
1843 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1844 # all shared libraries for ELF.
1846 _startup_libs= gnu/lib/csu
1847 _startup_libs+= lib/csu
1848 _startup_libs+= gnu/lib/libgcc
1849 _startup_libs+= lib/libcompiler_rt
1850 _startup_libs+= lib/libc
1851 _startup_libs+= lib/libc_nonshared
1852 .if ${MK_LIBCPLUSPLUS} != "no"
1853 _startup_libs+= lib/libcxxrt
1856 gnu/lib/libgcc__L: lib/libc__L
1857 gnu/lib/libgcc__L: lib/libc_nonshared__L
1858 .if ${MK_LIBCPLUSPLUS} != "no"
1859 lib/libcxxrt__L: gnu/lib/libgcc__L
1862 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1863 ${_kerberos5_lib_libhdb} \
1864 ${_kerberos5_lib_libheimbase} \
1865 ${_kerberos5_lib_libheimntlm} \
1867 ${_kerberos5_lib_libheimipcc} \
1868 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1869 ${_kerberos5_lib_libroken} \
1870 ${_kerberos5_lib_libwind} \
1871 lib/libbz2 ${_libcom_err} lib/libcrypt \
1872 lib/libelf lib/libexpat \
1875 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1877 lib/ncurses/ncurses lib/ncurses/ncursesw \
1878 lib/libopie lib/libpam ${_lib_libthr} \
1879 ${_lib_libradius} lib/libsbuf lib/libtacplus \
1881 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1882 ${_cddl_lib_libuutil} \
1883 ${_cddl_lib_libavl} \
1884 ${_cddl_lib_libzfs_core} \
1885 ${_cddl_lib_libctf} \
1886 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1887 ${_secure_lib_libcrypto} ${_lib_libldns} \
1888 ${_secure_lib_libssh} ${_secure_lib_libssl} \
1890 .if ${MK_GNUCXX} != "no"
1891 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1892 gnu/lib/libstdc++__L: lib/msun__L
1893 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1896 .if ${MK_LIBCPLUSPLUS} != "no"
1897 _prebuild_libs+= lib/libc++
1900 lib/libgeom__L: lib/libexpat__L
1901 lib/libkvm__L: lib/libelf__L
1903 .if ${MK_LIBTHR} != "no"
1904 _lib_libthr= lib/libthr
1907 .if ${MK_RADIUS_SUPPORT} != "no"
1908 _lib_libradius= lib/libradius
1911 .if ${MK_OFED} != "no"
1912 _ofed_lib= contrib/ofed/usr.lib
1913 _prebuild_libs+= contrib/ofed/usr.lib/libosmcomp
1914 _prebuild_libs+= contrib/ofed/usr.lib/libopensm
1915 _prebuild_libs+= contrib/ofed/usr.lib/libibcommon
1916 _prebuild_libs+= contrib/ofed/usr.lib/libibverbs
1917 _prebuild_libs+= contrib/ofed/usr.lib/libibumad
1919 contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
1920 contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
1921 contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
1924 .if ${MK_CASPER} != "no"
1925 _lib_casper= lib/libcasper
1928 lib/libpjdlog__L: lib/libutil__L
1929 lib/libcasper__L: lib/libnv__L
1930 lib/liblzma__L: lib/libthr__L
1932 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1933 .for _DIR in ${LOCAL_LIB_DIRS}
1934 .if exists(${.CURDIR}/${_DIR}/Makefile) && empty(_generic_libs:M${_DIR})
1935 _generic_libs+= ${_DIR}
1939 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1941 .if ${MK_CDDL} != "no"
1942 _cddl_lib_libumem= cddl/lib/libumem
1943 _cddl_lib_libnvpair= cddl/lib/libnvpair
1944 _cddl_lib_libavl= cddl/lib/libavl
1945 _cddl_lib_libuutil= cddl/lib/libuutil
1946 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1947 _cddl_lib_libctf= cddl/lib/libctf
1949 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1950 cddl/lib/libzfs__L: lib/libgeom__L
1951 cddl/lib/libctf__L: lib/libz__L
1953 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
1954 # on select architectures though (see cddl/lib/Makefile)
1955 .if ${MACHINE_CPUARCH} != "sparc64"
1956 _prebuild_libs+= lib/libproc lib/librtld_db
1959 .if ${MK_CRYPT} != "no"
1960 .if ${MK_OPENSSL} != "no"
1961 _secure_lib_libcrypto= secure/lib/libcrypto
1962 _secure_lib_libssl= secure/lib/libssl
1963 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1964 .if ${MK_LDNS} != "no"
1965 _lib_libldns= lib/libldns
1966 lib/libldns__L: secure/lib/libcrypto__L
1968 .if ${MK_OPENSSH} != "no"
1969 _secure_lib_libssh= secure/lib/libssh
1970 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1971 .if ${MK_LDNS} != "no"
1972 secure/lib/libssh__L: lib/libldns__L
1974 .if ${MK_KERBEROS_SUPPORT} != "no"
1975 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1976 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1977 lib/libmd__L kerberos5/lib/libroken__L
1981 _secure_lib= secure/lib
1984 .if ${MK_KERBEROS} != "no"
1985 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1986 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1987 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1988 kerberos5/lib/libwind__L lib/libsqlite3__L
1989 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1990 kerberos5/lib/libroken__L lib/libcom_err__L
1991 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1992 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1993 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1994 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1995 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1996 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
1997 kerberos5/lib/libroken__L: lib/libcrypt__L
1998 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
1999 kerberos5/lib/libheimbase__L: lib/libthr__L
2000 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2003 lib/libsqlite3__L: lib/libthr__L
2005 .if ${MK_GSSAPI} != "no"
2006 _lib_libgssapi= lib/libgssapi
2009 .if ${MK_KERBEROS} != "no"
2010 _kerberos5_lib= kerberos5/lib
2011 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2012 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2013 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2014 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2015 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2016 _kerberos5_lib_libroken= kerberos5/lib/libroken
2017 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2018 _libsqlite3= lib/libsqlite3
2019 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2020 _kerberos5_lib_libwind= kerberos5/lib/libwind
2021 _libcom_err= lib/libcom_err
2024 .if ${MK_NIS} != "no"
2025 _lib_libypclnt= lib/libypclnt
2028 .if ${MK_OPENSSL} == "no"
2029 lib/libradius__L: lib/libmd__L
2033 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2034 .if ${MK_CXX} != "no"
2035 .if ${MK_LIBCPLUSPLUS} != "no"
2036 lib/libproc__L: lib/libcxxrt__L
2037 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2038 lib/libproc__L: gnu/lib/libsupc++__L
2042 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2044 .for _lib in ${_prereq_libs}
2045 ${_lib}__PL: .PHONY .MAKE
2046 .if exists(${.CURDIR}/${_lib})
2047 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2048 cd ${.CURDIR}/${_lib}; \
2049 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2050 if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; fi; \
2051 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2052 DIRPRFX=${_lib}/ all; \
2053 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2054 DIRPRFX=${_lib}/ install
2058 .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
2059 ${_lib}__L: .PHONY .MAKE
2060 .if exists(${.CURDIR}/${_lib})
2061 ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
2062 cd ${.CURDIR}/${_lib}; \
2063 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2064 if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ depend; fi; \
2065 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2066 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2070 # libpam is special: we need to build static PAM modules before
2071 # static PAM library, and dynamic PAM library before dynamic PAM
2073 lib/libpam__L: .PHONY .MAKE
2074 ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
2075 cd ${.CURDIR}/lib/libpam; \
2076 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj; \
2077 if [ -z "${NO_DEPEND}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ depend; fi; \
2078 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2079 -D_NO_LIBPAM_SO_YET all; \
2080 ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
2081 -D_NO_LIBPAM_SO_YET install
2083 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2084 _startup_libs: ${_startup_libs:S/$/__L/}
2085 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2086 _generic_libs: ${_generic_libs:S/$/__L/}
2088 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2089 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2090 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2091 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2092 # parallel. This is safe for the world stage of buildworld though since it has
2093 # already built libraries in a proper order and installed includes into
2094 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2095 # avoid trashing a system if it crashes mid-install.
2096 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2100 .include <bsd.subdir.mk>
2102 .if make(check-old) || make(check-old-dirs) || \
2103 make(check-old-files) || make(check-old-libs) || \
2104 make(delete-old) || make(delete-old-dirs) || \
2105 make(delete-old-files) || make(delete-old-libs)
2108 # check for / delete old files section
2111 .include "ObsoleteFiles.inc"
2113 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2114 else you can not start such an application. Consult UPDATING for more \
2115 information regarding how to cope with the removal/revision bump of a \
2118 .if !defined(BATCH_DELETE_OLD_FILES)
2125 @echo ">>> Removing old files (only deletes safe to delete libs)"
2126 # Ask for every old file if the user really wants to remove it.
2127 # It's annoying, but better safe than sorry.
2128 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2129 # argument list will get too long. Using .for/.endfor make "loops" will make
2130 # the Makefile parser segfault.
2133 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2134 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2135 while read file; do \
2136 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2137 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2138 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2140 for ext in debug symbols; do \
2141 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2142 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2143 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2148 # Remove catpages without corresponding manpages.
2150 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2151 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2152 while read catpage; do \
2154 if [ ! -e "$${manpage}" ]; then \
2155 rm ${RM_I} $${catpage} <&3; \
2158 @echo ">>> Old files removed"
2161 @echo ">>> Checking for old files"
2163 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2164 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2165 while read file; do \
2166 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2167 echo "${DESTDIR}/$${file}"; \
2169 for ext in debug symbols; do \
2170 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2171 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2175 # Check for catpages without corresponding manpages.
2176 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2177 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2178 while read catpage; do \
2180 if [ ! -e "$${manpage}" ]; then \
2186 @echo ">>> Removing old libraries"
2187 @echo "${OLD_LIBS_MESSAGE}" | fmt
2190 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2191 -V OLD_LIBS | xargs -n1 | \
2192 while read file; do \
2193 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2194 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2195 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2197 for ext in debug symbols; do \
2198 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2199 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2200 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2205 @echo ">>> Old libraries removed"
2208 @echo ">>> Checking for old libraries"
2210 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2211 -V OLD_LIBS | xargs -n1 | \
2212 while read file; do \
2213 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2214 echo "${DESTDIR}/$${file}"; \
2216 for ext in debug symbols; do \
2217 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2218 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2224 @echo ">>> Removing old directories"
2226 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2227 -V OLD_DIRS | xargs -n1 | sort -r | \
2228 while read dir; do \
2229 if [ -d "${DESTDIR}/$${dir}" ]; then \
2230 rmdir -v "${DESTDIR}/$${dir}" || true; \
2231 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2232 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2235 @echo ">>> Old directories removed"
2238 @echo ">>> Checking for old directories"
2240 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2241 -V OLD_DIRS | xargs -n1 | \
2242 while read dir; do \
2243 if [ -d "${DESTDIR}/$${dir}" ]; then \
2244 echo "${DESTDIR}/$${dir}"; \
2245 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2246 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2250 delete-old: delete-old-files delete-old-dirs
2251 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2253 check-old: check-old-files check-old-libs check-old-dirs
2254 @echo "To remove old files and directories run '${MAKE} delete-old'."
2255 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2260 # showconfig - show build configuration.
2263 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2264 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2266 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2267 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2269 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2270 .if exists(${KERNCONFDIR}/${KERNCONF})
2271 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2272 '${KERNCONFDIR}/${KERNCONF}' ; echo
2278 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2279 DTBOUTPUTPATH= ${.CURDIR}
2283 # Build 'standalone' Device Tree Blob
2286 @PATH=${TMPPATH} MACHINE=${TARGET} \
2287 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2288 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2293 # In the following, the first 'rm' in a series will usually remove all
2294 # files and directories. If it does not, then there are probably some
2295 # files with file flags set, so this unsets them and tries the 'rm' a
2296 # second time. There are situations where this target will be cleaning
2297 # some directories via more than one method, but that duplication is
2298 # needed to correctly handle all the possible situations. Removing all
2299 # files without file flags set in the first 'rm' instance saves time,
2300 # because 'chflags' will need to operate on fewer files afterwards.
2302 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2303 # created by bsd.obj.mk, except that we don't want to .include that file
2306 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2308 .if exists(${BW_CANONICALOBJDIR}/)
2309 -rm -rf ${BW_CANONICALOBJDIR}/*
2310 -chflags -R 0 ${BW_CANONICALOBJDIR}
2311 rm -rf ${BW_CANONICALOBJDIR}/*
2313 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2314 # To be safe in this case, fall back to a 'make cleandir'
2315 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2318 .if defined(TARGET) && defined(TARGET_ARCH)
2320 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2321 XDEV_CPUTYPE?=${CPUTYPE}
2323 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2326 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2327 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2328 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2329 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2330 CPUTYPE=${XDEV_CPUTYPE}
2332 XDDIR=${TARGET_ARCH}-freebsd
2335 .error XDTP variable should be an absolute path
2338 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2339 INSTALL="sh ${.CURDIR}/tools/install.sh"
2341 TOOLS_PREFIX=${XDTP}
2342 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2343 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2344 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2345 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2346 CPP="${CPP} ${CD2CFLAGS}" \
2347 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2349 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2350 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2351 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2352 XDDESTDIR=${DESTDIR}/${XDTP}
2354 OSREL!= uname -r | sed -e 's/[-(].*//'
2357 .ORDER: xdev-build xdev-install xdev-links
2358 xdev: xdev-build xdev-install
2360 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2361 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2363 _xb-worldtmp: .PHONY
2364 mkdir -p ${CDTMP}/usr
2365 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2366 -p ${CDTMP}/usr >/dev/null
2368 _xb-bootstrap-tools: .PHONY
2372 ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
2373 cd ${.CURDIR}/${_tool}; \
2374 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2375 if [ -z "${NO_DEPEND}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ depend; fi; \
2376 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2377 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2380 _xb-build-tools: .PHONY
2381 ${_+_}@cd ${.CURDIR}; \
2382 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2384 _xb-cross-tools: .PHONY
2392 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
2393 cd ${.CURDIR}/${_tool}; \
2394 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2395 if [ -z "${NO_DEPEND}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ depend; fi; \
2396 ${CDMAKE} DIRPRFX=${_tool}/ all
2400 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2401 mkdir -p ${XDDESTDIR}
2402 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2403 -p ${XDDESTDIR} >/dev/null
2404 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2405 -p ${XDDESTDIR}/usr >/dev/null
2406 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2407 -p ${XDDESTDIR}/usr/include >/dev/null
2408 .if ${MK_LIB32} != "no"
2409 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
2410 -p ${XDDESTDIR}/usr >/dev/null
2412 .if ${MK_TESTS} != "no"
2413 mkdir -p ${XDDESTDIR}${TESTSBASE}
2414 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2415 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2418 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2419 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2421 _xi-cross-tools: .PHONY
2422 @echo "_xi-cross-tools"
2430 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2431 cd ${.CURDIR}/${_tool}; \
2432 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2435 _xi-includes: .PHONY
2436 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2437 DESTDIR=${XDDESTDIR}
2439 _xi-libraries: .PHONY
2440 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2441 DESTDIR=${XDDESTDIR}
2444 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2445 mkdir -p ../../../../usr/bin; \
2447 ln -sf ../../${XDTP}/usr/bin/$$i \
2448 ../../../../usr/bin/${XDDIR}-$$i; \
2449 ln -sf ../../${XDTP}/usr/bin/$$i \
2450 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2453 xdev xdev-build xdev-install xdev-links:
2454 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"