4 # Make command line options:
5 # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
6 # -DNO_CLEAN do not clean at all
7 # -DDB_FROM_SRC use the user/group databases in src/etc instead of
8 # the system database when installing.
9 # -DNO_SHARE do not go into share subdir
10 # -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,OBJ}
11 # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
12 # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
13 # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
14 # -DNO_PORTSUPDATE do not update ports in ${MAKE} update
15 # -DNO_ROOT install without using root privilege
16 # -DNO_DOCUPDATE do not update doc in ${MAKE} update
17 # -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects
18 # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
19 # LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list
20 # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
21 # LOCAL_MTREE="list of mtree files" to process to allow local directories
22 # to be created before files are installed
23 # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
25 # METALOG="path to metadata log" to write permission and ownership
26 # when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
27 # TARGET="machine" to crossbuild world for a different machine type
28 # TARGET_ARCH= may be required when a TARGET supports multiple endians
29 # BUILDENV_SHELL= shell to launch for the buildenv target (def:${SHELL})
30 # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
31 # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
32 # SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
33 # All libraries and includes, and some build tools will still build.
36 # The intended user-driven targets are:
37 # buildworld - rebuild *everything*, including glue to help do upgrades
38 # installworld- install everything built by "buildworld"
39 # checkworld - run test suite on installed world
40 # doxygen - build API documentation of the kernel
41 # update - convenient way to update your source tree (eg: svn/svnup)
43 # Standard targets (not defined here) are documented in the makefiles in
44 # /usr/share/mk. These include:
45 # obj depend all install clean cleandepend cleanobj
47 .if !defined(TARGET) || !defined(TARGET_ARCH)
48 .error "Both TARGET and TARGET_ARCH must be defined."
51 LOCALBASE?= /usr/local
53 # Cross toolchain changes must be in effect before bsd.compiler.mk
54 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
55 .if defined(CROSS_TOOLCHAIN)
56 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
57 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
59 .include <bsd.compiler.mk> # don't depend on src.opts.mk doing it
60 .include "share/mk/src.opts.mk"
62 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
63 # keep the users system reasonably usable. For static->dynamic root upgrades,
64 # we don't want to install a dynamic binary without rtld and the needed
65 # libraries. More commonly, for dynamic root, we don't want to install a
66 # binary that requires a newer library version that hasn't been installed yet.
67 # This ordering is not a guarantee though. The only guarantee of a working
68 # system here would require fine-grained ordering of all components based
69 # on their dependencies.
71 .if !empty(SUBDIR_OVERRIDE)
72 SUBDIR= ${SUBDIR_OVERRIDE}
75 .if !defined(NO_ROOT) && (make(installworld) || make(install))
76 # Ensure libraries are installed before progressing.
80 .if ${MK_CDDL} != "no"
84 .if ${MK_KERBEROS} != "no"
87 .if ${MK_RESCUE} != "no"
91 .if ${MK_CRYPT} != "no"
94 .if !defined(NO_SHARE)
97 SUBDIR+=sys usr.bin usr.sbin
98 .if ${MK_TESTS} != "no"
101 .if ${MK_OFED} != "no"
105 # Local directories are last, since it is nice to at least get the base
106 # system rebuilt before you do them.
107 .for _DIR in ${LOCAL_DIRS}
108 .if exists(${.CURDIR}/${_DIR}/Makefile)
112 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
113 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
114 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
115 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
116 _REDUNDENT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
118 .for _DIR in ${LOCAL_LIB_DIRS}
119 .if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
122 .warning ${_DIR} not added to SUBDIR list. See UPDATING 20141121.
126 # We must do etc/ last as it hooks into building the man whatis file
127 # by calling 'makedb' in share/man. This is only relevant for
128 # install/distribute so they build the whatis file after every manpage is
130 .if make(installworld) || make(install)
135 .endif # !empty(SUBDIR_OVERRIDE)
138 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
141 .if defined(NO_CLEANDIR)
142 CLEANDIR= clean cleandepend
148 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
150 .if empty(SHELL:M*csh*)
151 BUILDENV_SHELL?=${SHELL}
153 BUILDENV_SHELL?=/bin/sh
156 .if !defined(SVN) || empty(SVN)
157 . for _P in /usr/bin /usr/local/bin
158 . for _S in svn svnlite
159 . if exists(${_P}/${_S})
167 MAKEOBJDIRPREFIX?= /usr/obj
168 .if !defined(OSRELDATE)
169 .if exists(/usr/include/osreldate.h)
170 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
171 /usr/include/osreldate.h
178 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
179 .if !defined(VERSION)
180 REVISION!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V REVISION
181 BRANCH!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V BRANCH
182 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
183 ${SRCDIR}/sys/sys/param.h
184 VERSION= FreeBSD ${REVISION}-${BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
188 KNOWN_ARCHES?= aarch64/arm64 \
207 .if ${TARGET} == ${TARGET_ARCH}
210 _t= ${TARGET_ARCH}/${TARGET}
213 .if empty(KNOWN_ARCHES:M${_t})
214 .error Unknown target ${TARGET_ARCH}:${TARGET}.
218 .if ${TARGET} == ${MACHINE}
219 TARGET_CPUTYPE?=${CPUTYPE}
224 .if !empty(TARGET_CPUTYPE)
225 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
227 _TARGET_CPUTYPE=dummy
229 _CPUTYPE!= MK_AUTO_OBJ=no MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
230 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
231 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
232 .error CPUTYPE global should be set with ?=.
235 BUILD_ARCH!= uname -p
236 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
237 .error To cross-build, set TARGET_ARCH.
240 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
241 OBJTREE= ${MAKEOBJDIRPREFIX}
243 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
245 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
246 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
247 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
248 STRICTTMPPATH= ${BPATH}:${XPATH}
249 TMPPATH= ${STRICTTMPPATH}:${PATH}
252 # Avoid running mktemp(1) unless actually needed.
253 # It may not be functional, e.g., due to new ABI
254 # when in the middle of installing over this system.
256 .if make(distributeworld) || make(installworld)
257 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
261 # Building a world goes through the following stages
263 # 1. legacy stage [BMAKE]
264 # This stage is responsible for creating compatibility
265 # shims that are needed by the bootstrap-tools,
266 # build-tools and cross-tools stages. These are generally
267 # APIs that tools from one of those three stages need to
268 # build that aren't present on the host.
269 # 1. bootstrap-tools stage [BMAKE]
270 # This stage is responsible for creating programs that
271 # are needed for backward compatibility reasons. They
272 # are not built as cross-tools.
273 # 2. build-tools stage [TMAKE]
274 # This stage is responsible for creating the object
275 # tree and building any tools that are needed during
276 # the build process. Some programs are listed during
277 # this phase because they build binaries to generate
278 # files needed to build these programs. This stage also
279 # builds the 'build-tools' target rather than 'all'.
280 # 3. cross-tools stage [XMAKE]
281 # This stage is responsible for creating any tools that
282 # are needed for building the system. A cross-compiler is one
283 # of them. This differs from build tools in two ways:
284 # 1. the 'all' target is built rather than 'build-tools'
285 # 2. these tools are installed into TMPPATH for stage 4.
286 # 4. world stage [WMAKE]
287 # This stage actually builds the world.
288 # 5. install stage (optional) [IMAKE]
289 # This stage installs a previously built world.
294 # Common environment for world related stages
295 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
296 MACHINE_ARCH=${TARGET_ARCH} \
298 CPUTYPE=${TARGET_CPUTYPE}
299 .if ${MK_GROFF} != "no"
300 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
301 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
302 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
304 .if defined(TARGET_CFLAGS)
305 CROSSENV+= ${TARGET_CFLAGS}
308 # bootstrap-tools stage
309 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
310 PATH=${BPATH}:${PATH} \
311 WORLDTMP=${WORLDTMP} \
312 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
313 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
315 BOOTSTRAPPING=${OSRELDATE} \
317 MK_HTML=no NO_LINT=yes MK_MAN=no \
318 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
319 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
320 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
321 MK_LLDB=no MK_TESTS=no \
324 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
325 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
329 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
330 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
331 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
333 BOOTSTRAPPING=${OSRELDATE} \
336 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
337 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
338 MK_LLDB=no MK_TESTS=no
341 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
342 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
343 MK_GDB=no MK_TESTS=no
346 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
347 PATH=${BPATH}:${PATH} \
349 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
350 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
352 BOOTSTRAPPING=${OSRELDATE} \
354 MK_HTML=no -DNO_LINT MK_MAN=no \
355 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
356 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
359 WMAKEENV= ${CROSSENV} \
360 INSTALL="sh ${.CURDIR}/tools/install.sh" \
364 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
366 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
369 .if defined(CROSS_TOOLCHAIN_PREFIX)
370 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
371 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
374 # If we do not have a bootstrap binutils (because the in-tree one does not
375 # support the target architecture), provide a default cross-binutils prefix.
376 # This allows aarch64 builds, for example, to automatically use the
377 # aarch64-binutils port or package.
378 .if !make(showconfig)
379 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
380 !defined(CROSS_BINUTILS_PREFIX)
381 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
382 .if !exists(${CROSS_BINUTILS_PREFIX})
383 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
388 XCOMPILERS= CC CXX CPP
389 .for COMPILER in ${XCOMPILERS}
390 .if defined(CROSS_COMPILER_PREFIX)
391 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
393 X${COMPILER}?= ${${COMPILER}}
396 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
397 .for BINUTIL in ${XBINUTILS}
398 .if defined(CROSS_BINUTILS_PREFIX) && \
399 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
400 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
402 X${BINUTIL}?= ${${BINUTIL}}
405 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
406 CPP="${XCPP} ${XCFLAGS}" \
407 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
408 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
409 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
412 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
413 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
414 # directory, but the compiler will look in the right place for its
415 # tools so we don't need to tell it where to look.
416 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
419 # External compiler needs sysroot and target flags.
420 .if ${XCC:N${CCACHE_BIN}:M/*} || ${MK_CROSS_COMPILER} == "no"
421 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
422 BFLAGS+= -B${WORLDTMP}/usr/bin
424 .if ${TARGET} == "arm"
425 .if ${TARGET_ARCH:M*hf*} != ""
426 TARGET_ABI= gnueabihf
431 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
432 # GCC requires -isystem and -L when using a cross-compiler.
433 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
434 # Force using libc++ for external GCC.
435 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
436 -nostdinc++ -L${WORLDTMP}/../lib/libc++
439 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
440 XCFLAGS+= -target ${TARGET_TRIPLE}
442 XCFLAGS+= --sysroot=${WORLDTMP}
444 .endif # ${XCC:M/*} || ${MK_CROSS_COMPILER} == "no"
450 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
451 ${TARGET_ARCH} == "powerpc64")
453 .include "Makefile.libcompat"
454 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH} == "armv6"
456 .include "Makefile.libcompat"
459 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
461 IMAKEENV= ${CROSSENV}
462 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
463 ${IMAKE_INSTALL} ${IMAKE_MTREE}
464 .if empty(.MAKEFLAGS:M-n)
465 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
466 LD_LIBRARY_PATH=${INSTALLTMP} \
467 PATH_LOCALE=${INSTALLTMP}/locale
468 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
470 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
472 .if defined(DB_FROM_SRC)
473 INSTALLFLAGS+= -N ${.CURDIR}/etc
474 MTREEFLAGS+= -N ${.CURDIR}/etc
476 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
477 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
479 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
480 IMAKE+= -DNO_ROOT METALOG=${METALOG}
481 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
484 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
485 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
486 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
490 KMAKEENV= ${WMAKEENV}
491 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
496 # Attempt to rebuild the entire system, with reasonable chance of
497 # success, regardless of how old your existing system is.
500 .if ${.CURDIR:C/[^,]//g} != ""
501 # The m4 build of sendmail files doesn't like it if ',' is used
502 # anywhere in the path of it's files.
504 @echo "*** Error: path to source tree contains a comma ','"
509 @echo "--------------------------------------------------------------"
510 @echo ">>> Rebuilding the temporary build tree"
511 @echo "--------------------------------------------------------------"
512 .if !defined(NO_CLEAN)
514 .if defined(LIBCOMPAT)
515 rm -rf ${LIBCOMPATTMP}
518 rm -rf ${WORLDTMP}/legacy/usr/include
519 # XXX - These can depend on any header file.
520 rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c
521 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
524 lib lib/casper usr legacy/bin legacy/usr
525 mkdir -p ${WORLDTMP}/${_dir}
527 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
528 -p ${WORLDTMP}/legacy/usr >/dev/null
529 .if ${MK_GROFF} != "no"
530 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
531 -p ${WORLDTMP}/legacy/usr >/dev/null
533 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
534 -p ${WORLDTMP}/usr >/dev/null
535 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
536 -p ${WORLDTMP}/usr/include >/dev/null
537 ln -sf ${.CURDIR}/sys ${WORLDTMP}
538 .if ${MK_DEBUG_FILES} != "no"
539 # We could instead disable debug files for these build stages
540 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
541 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
542 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
543 -p ${WORLDTMP}/usr/lib >/dev/null
545 .if defined(LIBCOMPAT)
546 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
547 -p ${WORLDTMP}/usr >/dev/null
548 .if ${MK_DEBUG_FILES} != "no"
549 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
550 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
551 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
552 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
555 .if ${MK_TESTS} != "no"
556 mkdir -p ${WORLDTMP}${TESTSBASE}
557 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
558 -p ${WORLDTMP}${TESTSBASE} >/dev/null
559 .if ${MK_DEBUG_FILES} != "no"
560 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
561 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
562 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
565 .for _mtree in ${LOCAL_MTREE}
566 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
570 @echo "--------------------------------------------------------------"
571 @echo ">>> stage 1.1: legacy release compatibility shims"
572 @echo "--------------------------------------------------------------"
573 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
576 @echo "--------------------------------------------------------------"
577 @echo ">>> stage 1.2: bootstrap tools"
578 @echo "--------------------------------------------------------------"
579 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
581 .if !defined(NO_CLEAN)
583 @echo "--------------------------------------------------------------"
584 @echo ">>> stage 2.1: cleaning up the object tree"
585 @echo "--------------------------------------------------------------"
586 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
587 .if defined(LIBCOMPAT)
588 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
593 @echo "--------------------------------------------------------------"
594 @echo ">>> stage 2.2: rebuilding the object tree"
595 @echo "--------------------------------------------------------------"
596 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
599 @echo "--------------------------------------------------------------"
600 @echo ">>> stage 2.3: build tools"
601 @echo "--------------------------------------------------------------"
602 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
605 @echo "--------------------------------------------------------------"
606 @echo ">>> stage 3: cross tools"
607 @echo "--------------------------------------------------------------"
608 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
609 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
612 @echo "--------------------------------------------------------------"
613 @echo ">>> stage 4.1: building includes"
614 @echo "--------------------------------------------------------------"
615 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
616 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
617 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
618 MK_INCLUDES=yes includes
619 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
620 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
624 @echo "--------------------------------------------------------------"
625 @echo ">>> stage 4.2: building libraries"
626 @echo "--------------------------------------------------------------"
627 ${_+_}cd ${.CURDIR}; \
628 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
629 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
632 @echo "--------------------------------------------------------------"
633 @echo ">>> stage 4.3: building everything"
634 @echo "--------------------------------------------------------------"
635 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
638 WMAKE_TGTS+= _worldtmp _legacy
639 .if empty(SUBDIR_OVERRIDE)
640 WMAKE_TGTS+= _bootstrap-tools
642 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
643 WMAKE_TGTS+= _includes _libraries
644 WMAKE_TGTS+= everything
645 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
646 WMAKE_TGTS+= build${libcompat}
649 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
650 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
652 buildworld_prologue: .PHONY
653 @echo "--------------------------------------------------------------"
654 @echo ">>> World build started on `LC_ALL=C date`"
655 @echo "--------------------------------------------------------------"
657 buildworld_epilogue: .PHONY
659 @echo "--------------------------------------------------------------"
660 @echo ">>> World build completed on `LC_ALL=C date`"
661 @echo "--------------------------------------------------------------"
664 # We need to have this as a target because the indirection between Makefile
665 # and Makefile.inc1 causes the correct PATH to be used, rather than a
666 # modification of the current environment's PATH. In addition, we need
667 # to quote multiword values.
670 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
672 .if ${.TARGETS:Mbuildenv}
673 .if ${.MAKEFLAGS:M-j}
674 .error The buildenv target is incompatible with -j
677 BUILDENV_DIR?= ${.CURDIR}
679 @echo Entering world for ${TARGET_ARCH}:${TARGET}
680 .if ${BUILDENV_SHELL:M*zsh*}
681 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
683 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
686 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
687 toolchain: ${TOOLCHAIN_TGTS}
688 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
693 # Checks to be sure system is ready for installworld/installkernel.
695 installcheck: _installcheck_world _installcheck_kernel
697 _installcheck_kernel:
700 # Require DESTDIR to be set if installing for a different architecture or
701 # using the user/group database in the source tree.
703 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
705 .if !make(distributeworld)
706 _installcheck_world: __installcheck_DESTDIR
707 _installcheck_kernel: __installcheck_DESTDIR
708 __installcheck_DESTDIR:
709 .if !defined(DESTDIR) || empty(DESTDIR)
710 @echo "ERROR: Please set DESTDIR!"; \
716 .if !defined(DB_FROM_SRC)
718 # Check for missing UIDs/GIDs.
720 CHECK_UIDS= auditdistd
722 .if ${MK_SENDMAIL} != "no"
728 CHECK_GIDS+= proxy authpf
730 .if ${MK_UNBOUND} != "no"
734 _installcheck_world: __installcheck_UGID
736 .for uid in ${CHECK_UIDS}
737 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
738 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
742 .for gid in ${CHECK_GIDS}
743 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
744 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
751 # Required install tools to be saved in a scratch dir for safety.
753 .if ${MK_ZONEINFO} != "no"
754 _zoneinfo= zic tzsetup
757 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
758 date echo egrep find grep id install ${_install-info} \
759 ln make mkdir mtree mv pwd_mkdb \
760 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
763 # Needed for share/man
764 .if ${MK_MAN} != "no"
771 # Distributes everything compiled by a `buildworld'.
775 # Installs everything compiled by a 'buildworld'.
778 # Non-base distributions produced by the base system
779 EXTRA_DISTRIBUTIONS= doc
780 .if defined(LIBCOMPAT)
781 EXTRA_DISTRIBUTIONS+= lib${libcompat}
783 .if ${MK_TESTS} != "no"
784 EXTRA_DISTRIBUTIONS+= tests
788 .if ${MK_DEBUG_FILES} != "no"
789 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
792 MTREE_MAGIC?= mtree 2.0
794 distributeworld installworld: _installcheck_world
795 mkdir -p ${INSTALLTMP}
796 progs=$$(for prog in ${ITOOLS}; do \
797 if progpath=`which $$prog`; then \
800 echo "Required tool $$prog not found in PATH." >&2; \
804 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
805 while read line; do \
807 if [ "$$2 $$3" != "not found" ]; then \
810 echo "Required library $$1 not found." >&2; \
814 cp $$libs $$progs ${INSTALLTMP}
815 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
817 -mkdir -p ${METALOG:H}
818 echo "#${MTREE_MAGIC}" > ${METALOG}
820 .if make(distributeworld)
821 .for dist in ${EXTRA_DISTRIBUTIONS}
822 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
823 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
824 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
825 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
826 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
827 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
828 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
829 .if ${MK_DEBUG_FILES} != "no"
830 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
831 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
833 .if defined(LIBCOMPAT)
834 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
835 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
836 .if ${MK_DEBUG_FILES} != "no"
837 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
838 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
841 .if ${MK_TESTS} != "no" && ${dist} == "tests"
842 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
843 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
844 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
845 .if ${MK_DEBUG_FILES} != "no"
846 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
847 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
851 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
852 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
853 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
854 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
855 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
856 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
857 .if defined(LIBCOMPAT)
858 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
859 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
863 -mkdir ${DESTDIR}/${DISTDIR}/base
864 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
865 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
866 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
867 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
869 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
870 ${IMAKEENV} rm -rf ${INSTALLTMP}
871 .if make(distributeworld)
872 .for dist in ${EXTRA_DISTRIBUTIONS}
873 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
876 .for dist in base ${EXTRA_DISTRIBUTIONS}
877 @# For each file that exists in this dist, print the corresponding
878 @# line from the METALOG. This relies on the fact that
879 @# a line containing only the filename will sort immediatly before
880 @# the relevant mtree line.
881 cd ${DESTDIR}/${DISTDIR}; \
882 find ./${dist} | sort -u ${METALOG} - | \
883 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
884 ${DESTDIR}/${DISTDIR}/${dist}.meta
886 .for dist in ${DEBUG_DISTRIBUTIONS}
887 @# For each file that exists in this dist, print the corresponding
888 @# line from the METALOG. This relies on the fact that
889 @# a line containing only the filename will sort immediatly before
890 @# the relevant mtree line.
891 cd ${DESTDIR}/${DISTDIR}; \
892 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
893 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
894 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
900 .for dist in base ${EXTRA_DISTRIBUTIONS}
902 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
903 tar cvf - --exclude usr/lib/debug \
904 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
905 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
907 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
908 tar cvf - --exclude usr/lib/debug . | \
909 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
913 .for dist in ${DEBUG_DISTRIBUTIONS}
914 . if defined(NO_ROOT)
915 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
916 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
917 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
919 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
920 tar cvLf - usr/lib/debug | \
921 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
928 # If you have a build server, you can NFS mount the source and obj directories
929 # and do a 'make reinstall' on the *client* to install new binaries from the
930 # most recent server build.
932 reinstall: .MAKE .PHONY
933 @echo "--------------------------------------------------------------"
934 @echo ">>> Making hierarchy"
935 @echo "--------------------------------------------------------------"
936 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
937 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
939 @echo "--------------------------------------------------------------"
940 @echo ">>> Installing everything"
941 @echo "--------------------------------------------------------------"
942 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
943 .if defined(LIBCOMPAT)
944 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
947 redistribute: .MAKE .PHONY
948 @echo "--------------------------------------------------------------"
949 @echo ">>> Distributing everything"
950 @echo "--------------------------------------------------------------"
951 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
952 .if defined(LIBCOMPAT)
953 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
954 DISTRIBUTION=lib${libcompat}
957 distrib-dirs distribution: .MAKE .PHONY
958 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
959 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
960 .if make(distribution)
961 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
962 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
963 METALOG=${METALOG} MK_TESTS=no installconfig
967 # buildkernel and installkernel
969 # Which kernels to build and/or install is specified by setting
970 # KERNCONF. If not defined a GENERIC kernel is built/installed.
971 # Only the existing (depending TARGET) config files are used
972 # for building kernels and only the first of these is designated
973 # as the one being installed.
975 # Note that we have to use TARGET instead of TARGET_ARCH when
976 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
977 # be set to cross-build, we have to make sure TARGET is set
980 .if defined(KERNFAST)
984 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
985 .if !defined(KERNCONF) && ${KERNFAST} != "1"
989 .if ${TARGET_ARCH} == "powerpc64"
994 INSTKERNNAME?= kernel
996 KERNSRCDIR?= ${.CURDIR}/sys
997 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
998 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
999 KERNCONFDIR?= ${KRNLCONFDIR}
1003 .if defined(NO_INSTALLKERNEL)
1004 # All of the BUILDKERNELS loops start at index 1.
1005 BUILDKERNELS+= dummy
1007 .for _kernel in ${KERNCONF}
1008 .if exists(${KERNCONFDIR}/${_kernel})
1009 BUILDKERNELS+= ${_kernel}
1010 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1011 INSTALLKERNEL= ${_kernel}
1016 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1021 # Builds all kernels defined by BUILDKERNELS.
1023 buildkernel: .MAKE .PHONY
1024 .if empty(BUILDKERNELS:Ndummy)
1025 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1029 .for _kernel in ${BUILDKERNELS:Ndummy}
1030 @echo "--------------------------------------------------------------"
1031 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1032 @echo "--------------------------------------------------------------"
1033 @echo "===> ${_kernel}"
1034 mkdir -p ${KRNLOBJDIR}
1035 .if !defined(NO_KERNELCONFIG)
1037 @echo "--------------------------------------------------------------"
1038 @echo ">>> stage 1: configuring the kernel"
1039 @echo "--------------------------------------------------------------"
1040 cd ${KRNLCONFDIR}; \
1042 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1043 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1045 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1047 @echo "--------------------------------------------------------------"
1048 @echo ">>> stage 2.1: cleaning up the object tree"
1049 @echo "--------------------------------------------------------------"
1050 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1052 .if !defined(NO_KERNELOBJ)
1054 @echo "--------------------------------------------------------------"
1055 @echo ">>> stage 2.2: rebuilding the object tree"
1056 @echo "--------------------------------------------------------------"
1057 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1060 @echo "--------------------------------------------------------------"
1061 @echo ">>> stage 2.3: build tools"
1062 @echo "--------------------------------------------------------------"
1063 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1065 @echo "--------------------------------------------------------------"
1066 @echo ">>> stage 3.1: building everything"
1067 @echo "--------------------------------------------------------------"
1068 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1069 @echo "--------------------------------------------------------------"
1070 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1071 @echo "--------------------------------------------------------------"
1075 # installkernel, etc.
1077 # Install the kernel defined by INSTALLKERNEL
1079 installkernel installkernel.debug \
1080 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1081 .if !defined(NO_INSTALLKERNEL)
1082 .if empty(INSTALLKERNEL)
1083 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1086 @echo "--------------------------------------------------------------"
1087 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1088 @echo "--------------------------------------------------------------"
1089 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1090 ${CROSSENV} PATH=${TMPPATH} \
1091 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1093 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1094 .for _kernel in ${BUILDKERNELS:[2..-1]}
1095 @echo "--------------------------------------------------------------"
1096 @echo ">>> Installing kernel ${_kernel}"
1097 @echo "--------------------------------------------------------------"
1098 cd ${KRNLOBJDIR}/${_kernel}; \
1099 ${CROSSENV} PATH=${TMPPATH} \
1100 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1104 distributekernel distributekernel.debug:
1105 .if !defined(NO_INSTALLKERNEL)
1106 .if empty(INSTALLKERNEL)
1107 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1110 mkdir -p ${DESTDIR}/${DISTDIR}
1111 .if defined(NO_ROOT)
1112 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1114 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1115 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1116 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1117 DESTDIR=${INSTALL_DDIR}/kernel \
1118 ${.TARGET:S/distributekernel/install/}
1119 .if defined(NO_ROOT)
1120 sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1121 ${DESTDIR}/${DISTDIR}/kernel.meta
1124 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1125 .for _kernel in ${BUILDKERNELS:[2..-1]}
1126 .if defined(NO_ROOT)
1127 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1129 cd ${KRNLOBJDIR}/${_kernel}; \
1130 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1131 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1132 KERNEL=${INSTKERNNAME}.${_kernel} \
1133 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1134 ${.TARGET:S/distributekernel/install/}
1135 .if defined(NO_ROOT)
1136 sed -e 's|^./kernel|.|' \
1137 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1138 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1144 .if defined(NO_ROOT)
1145 .if !defined(NO_INSTALLKERNEL)
1146 cd ${DESTDIR}/${DISTDIR}/kernel; \
1147 tar cvf - --exclude '*.debug' \
1148 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1149 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1151 cd ${DESTDIR}/${DISTDIR}/kernel; \
1152 tar cvf - --include '*/*/*.debug' \
1153 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1154 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1155 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1156 .for _kernel in ${BUILDKERNELS:[2..-1]}
1157 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1158 tar cvf - --exclude '*.debug' \
1159 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1160 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1161 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1162 tar cvf - --include '*/*/*.debug' \
1163 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1164 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1168 .if !defined(NO_INSTALLKERNEL)
1169 cd ${DESTDIR}/${DISTDIR}/kernel; \
1170 tar cvf - --exclude '*.debug' . | \
1171 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1173 cd ${DESTDIR}/${DISTDIR}/kernel; \
1174 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1175 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1176 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1177 .for _kernel in ${BUILDKERNELS:[2..-1]}
1178 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1179 tar cvf - --exclude '*.debug' . | \
1180 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1181 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1182 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1183 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1192 # Run test suite on installed world.
1195 @if [ ! -x ${LOCALBASE}/bin/kyua ]; then \
1196 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1199 ${_+_}${LOCALBASE}/bin/kyua test -k ${TESTSBASE}/Kyuafile
1205 # Build the API documentation with doxygen
1208 @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1209 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1212 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1217 # Update the source tree(s), by running svn/svnup to update to the
1221 .if defined(SVN_UPDATE)
1222 @echo "--------------------------------------------------------------"
1223 @echo ">>> Updating ${.CURDIR} using Subversion"
1224 @echo "--------------------------------------------------------------"
1225 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1229 # ------------------------------------------------------------------------
1231 # From here onwards are utility targets used by the 'make world' and
1232 # related targets. If your 'world' breaks, you may like to try to fix
1233 # the problem and manually run the following targets to attempt to
1234 # complete the build. Beware, this is *not* guaranteed to work, you
1235 # need to have a pretty good grip on the current state of the system
1236 # to attempt to manually finish it. If in doubt, 'make world' again.
1240 # legacy: Build compatibility shims for the next three targets. This is a
1241 # minimal set of tools and shims necessary to compensate for older systems
1242 # which don't have the APIs required by the targets built in bootstrap-tools,
1243 # build-tools or cross-tools.
1246 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1247 # r296685 fix cross-endian objcopy
1248 .if ${BOOTSTRAPPING} < 1100102
1249 _elftoolchain_libs= lib/libelf lib/libdwarf
1253 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1254 @echo "ERROR: Source upgrades from versions prior to 8.0 are not supported."; \
1257 .for _tool in tools/build ${_elftoolchain_libs}
1258 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1259 cd ${.CURDIR}/${_tool}; \
1260 ${MAKE} DIRPRFX=${_tool}/ obj; \
1261 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1262 ${MAKE} DIRPRFX=${_tool}/ all; \
1263 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1267 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1268 # are built to build other binaries in the system. However, the focus of these
1269 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1270 # libraries, augmented by -legacy.
1272 _bt= _bootstrap-tools
1274 .if ${MK_GAMES} != "no"
1275 _strfile= usr.bin/fortune/strfile
1278 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1279 _gperf= gnu/usr.bin/gperf
1282 .if ${MK_GROFF} != "no"
1283 _groff= gnu/usr.bin/groff \
1287 .if ${MK_VT} != "no"
1288 _vtfontcvt= usr.bin/vtfontcvt
1291 .if ${BOOTSTRAPPING} < 900002
1295 .if ${BOOTSTRAPPING} < 1000033
1296 _libopenbsd= lib/libopenbsd
1300 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1301 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1304 .if ${BOOTSTRAPPING} < 1000026
1305 _nmtree= lib/libnetbsd \
1308 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1311 .if ${BOOTSTRAPPING} < 1000027
1315 # r264059 support for status=
1316 .if ${BOOTSTRAPPING} < 1100017
1320 # r277259 crunchide: Correct 64-bit section header offset
1321 # r281674 crunchide: always include both 32- and 64-bit ELF support
1322 # r285986 crunchen: use STRIPBIN rather than STRIP
1323 .if ${BOOTSTRAPPING} < 1100078
1324 _crunch= usr.sbin/crunch
1327 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1331 # r296926 -P keymap search path
1332 .if ${BOOTSTRAPPING} < 1100103
1333 _kbdcontrol= usr.sbin/kbdcontrol
1339 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1341 .if ${MK_BSNMP} != "no"
1342 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1345 # We need to build tblgen when we're building clang either as
1346 # the bootstrap compiler, or as the part of the normal build.
1347 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1349 lib/clang/libllvmsupport \
1350 lib/clang/libllvmtablegen \
1351 usr.bin/clang/llvm-tblgen \
1352 usr.bin/clang/clang-tblgen
1354 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1355 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1358 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1361 .if ${MK_GPL_DTC} != "no"
1362 _dtc= gnu/usr.bin/dtc
1365 .if ${MK_KERBEROS} != "no"
1366 _kerberos5_bootstrap_tools= \
1367 kerberos5/tools/make-roken \
1368 kerberos5/lib/libroken \
1369 kerberos5/lib/libvers \
1370 kerberos5/tools/asn1_compile \
1371 kerberos5/tools/slc \
1374 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1377 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
1378 .if ${MK_MANDOCDB} != "no" && ${BOOTSTRAPPING} < 1100075
1379 _libopenbsd?= lib/libopenbsd
1380 _makewhatis= lib/libsqlite3 \
1382 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1385 bootstrap-tools: .PHONY
1387 # Please document (add comment) why something is in 'bootstrap-tools'.
1388 # Try to bound the building of the bootstrap-tool to just the
1389 # FreeBSD versions that need the tool built at this stage of the build.
1392 ${_kerberos5_bootstrap_tools} \
1416 ${_bt}-${_tool}: .PHONY .MAKE
1417 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1418 cd ${.CURDIR}/${_tool}; \
1419 ${MAKE} DIRPRFX=${_tool}/ obj; \
1420 ${MAKE} DIRPRFX=${_tool}/ all; \
1421 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1423 bootstrap-tools: ${_bt}-${_tool}
1427 # build-tools: Build special purpose build tools
1429 .if !defined(NO_SHARE)
1430 _share= share/syscons/scrnmaps
1433 .if ${MK_GCC} != "no"
1434 _gcc_tools= gnu/usr.bin/cc/cc_tools
1437 .if ${MK_RESCUE} != "no"
1438 # rescue includes programs that have build-tools targets
1439 _rescue=rescue/rescue
1445 ${LOCAL_TOOL_DIRS} \
1446 lib/ncurses/ncurses \
1447 lib/ncurses/ncursesw \
1452 usr.bin/mkesdb_static \
1453 usr.bin/mkcsmapper_static \
1455 build-tools_${_tool}: .PHONY
1456 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1457 cd ${.CURDIR}/${_tool}; \
1458 ${MAKE} DIRPRFX=${_tool}/ obj; \
1459 ${MAKE} DIRPRFX=${_tool}/ build-tools
1460 build-tools: build-tools_${_tool}
1464 build-tools_${_tool}: .PHONY
1465 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \
1466 cd ${.CURDIR}/${_tool}; \
1467 ${MAKE} DIRPRFX=${_tool}/ obj; \
1468 ${MAKE} DIRPRFX=${_tool}/ all
1469 build-tools: build-tools_${_tool}
1473 # kernel-tools: Build kernel-building tools
1476 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1477 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1478 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1481 # cross-tools: All the tools needed to build the rest of the system after
1482 # we get done with the earlier stages. It is the last set of tools needed
1483 # to begin building the target binaries.
1485 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1486 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1487 _btxld= usr.sbin/btxld
1491 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1492 # resulting from missing bug fixes or ELF Toolchain updates.
1493 .if ${MK_CDDL} != "no"
1494 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1495 cddl/usr.bin/ctfmerge
1498 # If we're given an XAS, don't build binutils.
1499 .if ${XAS:M/*} == ""
1500 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1501 _binutils= gnu/usr.bin/binutils
1503 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1504 _elftctools= lib/libelftc \
1510 # These are not required by the build, but can be useful for developers who
1511 # cross-build on a FreeBSD 10 host:
1512 _elftctools+= usr.bin/addr2line
1514 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1515 # If cross-building with an external binutils we still need to build strip for
1516 # the target (for at least crunchide).
1517 _elftctools= lib/libelftc \
1522 # If an full path to an external cross compiler is given, don't build
1524 .if ${XCC:N${CCACHE_BIN}:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1525 .if ${MK_CLANG_BOOTSTRAP} != "no"
1526 _clang= usr.bin/clang
1527 _clang_libs= lib/clang
1529 .if ${MK_GCC_BOOTSTRAP} != "no"
1533 .if ${MK_USB} != "no"
1534 _usb_tools= sys/boot/usb/tools
1537 cross-tools: .MAKE .PHONY
1548 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1549 cd ${.CURDIR}/${_tool}; \
1550 ${MAKE} DIRPRFX=${_tool}/ obj; \
1551 ${MAKE} DIRPRFX=${_tool}/ all; \
1552 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1555 NXBDESTDIR= ${OBJTREE}/nxb-bin
1556 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1557 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1558 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1559 NXBMAKE= ${NXBENV} ${MAKE} \
1560 LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \
1561 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1562 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1563 MK_GDB=no MK_TESTS=no \
1565 MK_HTML=no NO_LINT=yes MK_MAN=no \
1566 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1567 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1568 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1569 MK_LLDB=no MK_DEBUG_FILES=no
1571 # native-xtools is the current target for qemu-user cross builds of ports
1572 # via poudriere and the imgact_binmisc kernel module.
1573 # For non-clang enabled targets that are still using the in tree gcc
1574 # we must build a gperf binary for one instance of its Makefiles. On
1575 # clang-enabled systems, the gperf binary is obsolete.
1576 native-xtools: .PHONY
1577 .if ${MK_GCC_BOOTSTRAP} != "no"
1578 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1579 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \
1580 cd ${.CURDIR}/${_gperf}; \
1581 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1582 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1583 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1585 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1586 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1587 -p ${NXBDESTDIR}/usr >/dev/null
1588 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1589 -p ${NXBDESTDIR}/usr/include >/dev/null
1590 .if ${MK_DEBUG_FILES} != "no"
1591 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1592 -p ${NXBDESTDIR}/usr/lib >/dev/null
1653 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1654 cd ${.CURDIR}/${_tool}; \
1655 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1656 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1657 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1661 # hierarchy - ensure that all the needed directories are present
1663 hierarchy hier: .MAKE .PHONY
1664 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1667 # libraries - build all libraries, and install them under ${DESTDIR}.
1669 # The list of libraries with dependents (${_prebuild_libs}) and their
1670 # interdependencies (__L) are built automatically by the
1671 # ${.CURDIR}/tools/make_libdeps.sh script.
1673 libraries: .MAKE .PHONY
1674 ${_+_}cd ${.CURDIR}; \
1675 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1676 ${MAKE} -f Makefile.inc1 _startup_libs; \
1677 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1678 ${MAKE} -f Makefile.inc1 _generic_libs
1681 # static libgcc.a prerequisite for shared libc
1683 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1685 # These dependencies are not automatically generated:
1687 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1688 # all shared libraries for ELF.
1690 _startup_libs= gnu/lib/csu
1691 _startup_libs+= lib/csu
1692 _startup_libs+= gnu/lib/libgcc
1693 _startup_libs+= lib/libcompiler_rt
1694 _startup_libs+= lib/libc
1695 _startup_libs+= lib/libc_nonshared
1696 .if ${MK_LIBCPLUSPLUS} != "no"
1697 _startup_libs+= lib/libcxxrt
1700 gnu/lib/libgcc__L: lib/libc__L
1701 gnu/lib/libgcc__L: lib/libc_nonshared__L
1702 .if ${MK_LIBCPLUSPLUS} != "no"
1703 lib/libcxxrt__L: gnu/lib/libgcc__L
1706 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1707 ${_kerberos5_lib_libhdb} \
1708 ${_kerberos5_lib_libheimbase} \
1709 ${_kerberos5_lib_libheimntlm} \
1711 ${_kerberos5_lib_libheimipcc} \
1712 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1713 ${_kerberos5_lib_libroken} \
1714 ${_kerberos5_lib_libwind} \
1715 lib/libbz2 ${_libcom_err} lib/libcrypt \
1716 lib/libelf lib/libexpat \
1719 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1721 lib/ncurses/ncurses lib/ncurses/ncursesw \
1722 lib/libopie lib/libpam/libpam ${_lib_libthr} \
1723 ${_lib_libradius} lib/libsbuf lib/libtacplus \
1725 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1726 ${_cddl_lib_libuutil} \
1727 ${_cddl_lib_libavl} \
1728 ${_cddl_lib_libzfs_core} \
1729 ${_cddl_lib_libctf} \
1730 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1731 ${_secure_lib_libcrypto} ${_lib_libldns} \
1732 ${_secure_lib_libssh} ${_secure_lib_libssl} \
1735 .if ${MK_GNUCXX} != "no"
1736 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1737 gnu/lib/libstdc++__L: lib/msun__L
1738 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1741 .if ${MK_LIBCPLUSPLUS} != "no"
1742 _prebuild_libs+= lib/libc++
1745 lib/libgeom__L: lib/libexpat__L
1746 lib/libkvm__L: lib/libelf__L
1748 .if ${MK_LIBTHR} != "no"
1749 _lib_libthr= lib/libthr
1752 .if ${MK_RADIUS_SUPPORT} != "no"
1753 _lib_libradius= lib/libradius
1756 .if ${MK_OFED} != "no"
1757 _ofed_lib= contrib/ofed/usr.lib
1758 _prebuild_libs+= contrib/ofed/usr.lib/libosmcomp
1759 _prebuild_libs+= contrib/ofed/usr.lib/libopensm
1760 _prebuild_libs+= contrib/ofed/usr.lib/libibcommon
1761 _prebuild_libs+= contrib/ofed/usr.lib/libibverbs
1762 _prebuild_libs+= contrib/ofed/usr.lib/libibumad
1764 contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
1765 contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
1766 contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
1769 .if ${MK_CASPER} != "no"
1770 _lib_casper= lib/libcasper
1773 lib/libpjdlog__L: lib/libutil__L
1774 lib/libcasper__L: lib/libnv__L
1775 lib/liblzma__L: lib/libthr__L
1777 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1778 .for _DIR in ${LOCAL_LIB_DIRS}
1779 .if exists(${.CURDIR}/${_DIR}/Makefile) && empty(_generic_libs:M${_DIR})
1780 _generic_libs+= ${_DIR}
1784 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1786 .if ${MK_CDDL} != "no"
1787 _cddl_lib_libumem= cddl/lib/libumem
1788 _cddl_lib_libnvpair= cddl/lib/libnvpair
1789 _cddl_lib_libavl= cddl/lib/libavl
1790 _cddl_lib_libuutil= cddl/lib/libuutil
1791 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1792 _cddl_lib_libctf= cddl/lib/libctf
1794 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1795 cddl/lib/libzfs__L: lib/libgeom__L
1796 cddl/lib/libctf__L: lib/libz__L
1798 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
1799 # on select architectures though (see cddl/lib/Makefile)
1800 .if ${MACHINE_CPUARCH} != "sparc64"
1801 _prebuild_libs+= lib/libproc lib/librtld_db
1804 .if ${MK_CRYPT} != "no"
1805 .if ${MK_OPENSSL} != "no"
1806 _secure_lib_libcrypto= secure/lib/libcrypto
1807 _secure_lib_libssl= secure/lib/libssl
1808 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1809 .if ${MK_LDNS} != "no"
1810 _lib_libldns= lib/libldns
1811 lib/libldns__L: secure/lib/libcrypto__L
1813 .if ${MK_OPENSSH} != "no"
1814 _secure_lib_libssh= secure/lib/libssh
1815 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1816 .if ${MK_LDNS} != "no"
1817 secure/lib/libssh__L: lib/libldns__L
1819 .if ${MK_KERBEROS_SUPPORT} != "no"
1820 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1821 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1822 lib/libmd__L kerberos5/lib/libroken__L
1826 _secure_lib= secure/lib
1829 .if ${MK_KERBEROS} != "no"
1830 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1831 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1832 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1833 kerberos5/lib/libwind__L lib/libsqlite3__L
1834 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1835 kerberos5/lib/libroken__L lib/libcom_err__L
1836 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1837 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1838 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1839 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1840 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1841 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
1842 kerberos5/lib/libroken__L: lib/libcrypt__L
1843 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
1844 kerberos5/lib/libheimbase__L: lib/libthr__L
1845 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
1848 lib/libsqlite3__L: lib/libthr__L
1850 .if ${MK_GSSAPI} != "no"
1851 _lib_libgssapi= lib/libgssapi
1854 .if ${MK_KERBEROS} != "no"
1855 _kerberos5_lib= kerberos5/lib
1856 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1857 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
1858 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
1859 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1860 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1861 _kerberos5_lib_libroken= kerberos5/lib/libroken
1862 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1863 _libsqlite3= lib/libsqlite3
1864 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
1865 _kerberos5_lib_libwind= kerberos5/lib/libwind
1866 _libcom_err= lib/libcom_err
1869 .if ${MK_NIS} != "no"
1870 _lib_libypclnt= lib/libypclnt
1873 .if ${MK_OPENSSL} == "no"
1874 lib/libradius__L: lib/libmd__L
1878 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
1879 .if ${MK_CXX} != "no"
1880 .if ${MK_LIBCPLUSPLUS} != "no"
1881 lib/libproc__L: lib/libcxxrt__L
1882 .else # This implies MK_GNUCXX != "no"; see lib/libproc
1883 lib/libproc__L: gnu/lib/libsupc++__L
1887 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
1889 .for _lib in ${_prereq_libs}
1890 ${_lib}__PL: .PHONY .MAKE
1891 .if exists(${.CURDIR}/${_lib})
1892 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
1893 cd ${.CURDIR}/${_lib}; \
1894 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
1895 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
1896 DIRPRFX=${_lib}/ all; \
1897 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
1898 DIRPRFX=${_lib}/ install
1902 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
1903 ${_lib}__L: .PHONY .MAKE
1904 .if exists(${.CURDIR}/${_lib})
1905 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
1906 cd ${.CURDIR}/${_lib}; \
1907 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
1908 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
1909 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
1913 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1914 _startup_libs: ${_startup_libs:S/$/__L/}
1915 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1916 _generic_libs: ${_generic_libs:S/$/__L/}
1918 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
1919 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
1920 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
1921 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
1922 # parallel. This is safe for the world stage of buildworld though since it has
1923 # already built libraries in a proper order and installed includes into
1924 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
1925 # avoid trashing a system if it crashes mid-install.
1926 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
1930 .include <bsd.subdir.mk>
1932 .if make(check-old) || make(check-old-dirs) || \
1933 make(check-old-files) || make(check-old-libs) || \
1934 make(delete-old) || make(delete-old-dirs) || \
1935 make(delete-old-files) || make(delete-old-libs)
1938 # check for / delete old files section
1941 .include "ObsoleteFiles.inc"
1943 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1944 else you can not start such an application. Consult UPDATING for more \
1945 information regarding how to cope with the removal/revision bump of a \
1948 .if !defined(BATCH_DELETE_OLD_FILES)
1955 @echo ">>> Removing old files (only deletes safe to delete libs)"
1956 # Ask for every old file if the user really wants to remove it.
1957 # It's annoying, but better safe than sorry.
1958 # NB: We cannot pass the list of OLD_FILES as a parameter because the
1959 # argument list will get too long. Using .for/.endfor make "loops" will make
1960 # the Makefile parser segfault.
1963 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1964 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1965 while read file; do \
1966 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1967 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1968 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1970 for ext in debug symbols; do \
1971 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
1972 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1973 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
1978 # Remove catpages without corresponding manpages.
1980 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1981 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1982 while read catpage; do \
1984 if [ ! -e "$${manpage}" ]; then \
1985 rm ${RM_I} $${catpage} <&3; \
1988 @echo ">>> Old files removed"
1991 @echo ">>> Checking for old files"
1993 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1994 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1995 while read file; do \
1996 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1997 echo "${DESTDIR}/$${file}"; \
1999 for ext in debug symbols; do \
2000 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2001 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2005 # Check for catpages without corresponding manpages.
2006 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2007 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2008 while read catpage; do \
2010 if [ ! -e "$${manpage}" ]; then \
2016 @echo ">>> Removing old libraries"
2017 @echo "${OLD_LIBS_MESSAGE}" | fmt
2020 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2021 -V OLD_LIBS | xargs -n1 | \
2022 while read file; do \
2023 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2024 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2025 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2027 for ext in debug symbols; do \
2028 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2029 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2030 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2035 @echo ">>> Old libraries removed"
2038 @echo ">>> Checking for old libraries"
2040 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2041 -V OLD_LIBS | xargs -n1 | \
2042 while read file; do \
2043 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2044 echo "${DESTDIR}/$${file}"; \
2046 for ext in debug symbols; do \
2047 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2048 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2054 @echo ">>> Removing old directories"
2056 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2057 -V OLD_DIRS | xargs -n1 | sort -r | \
2058 while read dir; do \
2059 if [ -d "${DESTDIR}/$${dir}" ]; then \
2060 rmdir -v "${DESTDIR}/$${dir}" || true; \
2061 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2062 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2065 @echo ">>> Old directories removed"
2068 @echo ">>> Checking for old directories"
2070 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2071 -V OLD_DIRS | xargs -n1 | \
2072 while read dir; do \
2073 if [ -d "${DESTDIR}/$${dir}" ]; then \
2074 echo "${DESTDIR}/$${dir}"; \
2075 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2076 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2080 delete-old: delete-old-files delete-old-dirs
2081 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2083 check-old: check-old-files check-old-libs check-old-dirs
2084 @echo "To remove old files and directories run '${MAKE} delete-old'."
2085 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2090 # showconfig - show build configuration.
2093 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2094 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2096 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2097 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2099 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2100 .if exists(${KERNCONFDIR}/${KERNCONF})
2101 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2102 '${KERNCONFDIR}/${KERNCONF}' ; echo
2108 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2109 DTBOUTPUTPATH= ${.CURDIR}
2113 # Build 'standalone' Device Tree Blob
2116 @PATH=${TMPPATH} MACHINE=${TARGET} \
2117 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2118 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2123 # In the following, the first 'rm' in a series will usually remove all
2124 # files and directories. If it does not, then there are probably some
2125 # files with file flags set, so this unsets them and tries the 'rm' a
2126 # second time. There are situations where this target will be cleaning
2127 # some directories via more than one method, but that duplication is
2128 # needed to correctly handle all the possible situations. Removing all
2129 # files without file flags set in the first 'rm' instance saves time,
2130 # because 'chflags' will need to operate on fewer files afterwards.
2132 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2133 # created by bsd.obj.mk, except that we don't want to .include that file
2136 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2138 .if exists(${BW_CANONICALOBJDIR}/)
2139 -rm -rf ${BW_CANONICALOBJDIR}/*
2140 -chflags -R 0 ${BW_CANONICALOBJDIR}
2141 rm -rf ${BW_CANONICALOBJDIR}/*
2143 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2144 # To be safe in this case, fall back to a 'make cleandir'
2145 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2148 .if defined(TARGET) && defined(TARGET_ARCH)
2150 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2151 XDEV_CPUTYPE?=${CPUTYPE}
2153 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2156 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2157 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2158 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2159 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2160 CPUTYPE=${XDEV_CPUTYPE}
2162 XDDIR=${TARGET_ARCH}-freebsd
2165 .error XDTP variable should be an absolute path
2168 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2169 INSTALL="sh ${.CURDIR}/tools/install.sh"
2171 TOOLS_PREFIX=${XDTP}
2172 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2173 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2174 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2175 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2176 CPP="${CPP} ${CD2CFLAGS}" \
2177 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2179 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2180 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2181 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2182 XDDESTDIR=${DESTDIR}/${XDTP}
2184 OSREL!= uname -r | sed -e 's/[-(].*//'
2187 .ORDER: xdev-build xdev-install xdev-links
2188 xdev: xdev-build xdev-install
2190 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2191 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2193 _xb-worldtmp: .PHONY
2194 mkdir -p ${CDTMP}/usr
2195 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2196 -p ${CDTMP}/usr >/dev/null
2198 _xb-bootstrap-tools: .PHONY
2202 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2203 cd ${.CURDIR}/${_tool}; \
2204 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2205 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2206 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2209 _xb-build-tools: .PHONY
2210 ${_+_}@cd ${.CURDIR}; \
2211 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2213 _xb-cross-tools: .PHONY
2221 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2222 cd ${.CURDIR}/${_tool}; \
2223 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2224 ${CDMAKE} DIRPRFX=${_tool}/ all
2228 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2229 mkdir -p ${XDDESTDIR}
2230 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2231 -p ${XDDESTDIR} >/dev/null
2232 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2233 -p ${XDDESTDIR}/usr >/dev/null
2234 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2235 -p ${XDDESTDIR}/usr/include >/dev/null
2236 .if defined(LIBCOMPAT)
2237 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2238 -p ${XDDESTDIR}/usr >/dev/null
2240 .if ${MK_TESTS} != "no"
2241 mkdir -p ${XDDESTDIR}${TESTSBASE}
2242 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2243 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2246 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2247 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2249 _xi-cross-tools: .PHONY
2250 @echo "_xi-cross-tools"
2258 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2259 cd ${.CURDIR}/${_tool}; \
2260 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2263 _xi-includes: .PHONY
2264 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2265 DESTDIR=${XDDESTDIR}
2267 _xi-libraries: .PHONY
2268 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2269 DESTDIR=${XDDESTDIR}
2272 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2273 mkdir -p ../../../../usr/bin; \
2275 ln -sf ../../${XDTP}/usr/bin/$$i \
2276 ../../../../usr/bin/${XDDIR}-$$i; \
2277 ln -sf ../../${XDTP}/usr/bin/$$i \
2278 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2281 xdev xdev-build xdev-install xdev-links:
2282 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"