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_META_MODE} != "no"
300 # Don't rebuild build-tools targets during normal build.
301 CROSSENV+= BUILD_TOOLS_META=.NOMETA_CMP
303 .if ${MK_GROFF} != "no"
304 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
305 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
306 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
308 .if defined(TARGET_CFLAGS)
309 CROSSENV+= ${TARGET_CFLAGS}
312 # bootstrap-tools stage
313 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
314 PATH=${BPATH}:${PATH} \
315 WORLDTMP=${WORLDTMP} \
316 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
317 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
319 BOOTSTRAPPING=${OSRELDATE} \
321 MK_HTML=no NO_LINT=yes MK_MAN=no \
322 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
323 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
324 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
325 MK_LLDB=no MK_TESTS=no \
328 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
329 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
333 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
334 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
335 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
337 BOOTSTRAPPING=${OSRELDATE} \
340 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
341 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
342 MK_LLDB=no MK_TESTS=no
345 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
346 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
347 MK_GDB=no MK_TESTS=no
350 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
351 PATH=${BPATH}:${PATH} \
353 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
354 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
356 BOOTSTRAPPING=${OSRELDATE} \
358 MK_HTML=no -DNO_LINT MK_MAN=no \
359 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
360 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
363 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 CPP="${XCPP} ${XCFLAGS}" \
411 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
412 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
413 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
416 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
417 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
418 # directory, but the compiler will look in the right place for its
419 # tools so we don't need to tell it where to look.
420 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
423 # External compiler needs sysroot and target flags.
424 .if ${XCC:N${CCACHE_BIN}:M/*} || ${MK_CROSS_COMPILER} == "no"
425 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${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 # GCC requires -isystem and -L when using a cross-compiler.
437 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
438 # Force using libc++ for external GCC.
439 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
440 -nostdinc++ -L${WORLDTMP}/../lib/libc++
443 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
444 XCFLAGS+= -target ${TARGET_TRIPLE}
446 XCFLAGS+= --sysroot=${WORLDTMP}
448 .endif # ${XCC:M/*} || ${MK_CROSS_COMPILER} == "no"
454 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
455 ${TARGET_ARCH} == "powerpc64")
457 .include "Makefile.libcompat"
458 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH} == "armv6"
460 .include "Makefile.libcompat"
463 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
465 IMAKEENV= ${CROSSENV}
466 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
467 ${IMAKE_INSTALL} ${IMAKE_MTREE}
468 .if empty(.MAKEFLAGS:M-n)
469 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
470 LD_LIBRARY_PATH=${INSTALLTMP} \
471 PATH_LOCALE=${INSTALLTMP}/locale
472 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
474 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
476 .if defined(DB_FROM_SRC)
477 INSTALLFLAGS+= -N ${.CURDIR}/etc
478 MTREEFLAGS+= -N ${.CURDIR}/etc
480 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
481 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
483 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
484 IMAKE+= -DNO_ROOT METALOG=${METALOG}
485 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
488 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
489 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
490 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
494 KMAKEENV= ${WMAKEENV}
495 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
500 # Attempt to rebuild the entire system, with reasonable chance of
501 # success, regardless of how old your existing system is.
504 .if ${.CURDIR:C/[^,]//g} != ""
505 # The m4 build of sendmail files doesn't like it if ',' is used
506 # anywhere in the path of it's files.
508 @echo "*** Error: path to source tree contains a comma ','"
513 @echo "--------------------------------------------------------------"
514 @echo ">>> Rebuilding the temporary build tree"
515 @echo "--------------------------------------------------------------"
516 .if !defined(NO_CLEAN)
518 .if defined(LIBCOMPAT)
519 rm -rf ${LIBCOMPATTMP}
522 rm -rf ${WORLDTMP}/legacy/usr/include
523 # XXX - These can depend on any header file.
524 rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c
525 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
528 lib lib/casper usr legacy/bin legacy/usr
529 mkdir -p ${WORLDTMP}/${_dir}
531 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
532 -p ${WORLDTMP}/legacy/usr >/dev/null
533 .if ${MK_GROFF} != "no"
534 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
535 -p ${WORLDTMP}/legacy/usr >/dev/null
537 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
538 -p ${WORLDTMP}/usr >/dev/null
539 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
540 -p ${WORLDTMP}/usr/include >/dev/null
541 ln -sf ${.CURDIR}/sys ${WORLDTMP}
542 .if ${MK_DEBUG_FILES} != "no"
543 # We could instead disable debug files for these build stages
544 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
545 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
546 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
547 -p ${WORLDTMP}/usr/lib >/dev/null
549 .if defined(LIBCOMPAT)
550 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
551 -p ${WORLDTMP}/usr >/dev/null
552 .if ${MK_DEBUG_FILES} != "no"
553 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
554 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
555 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
556 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
559 .if ${MK_TESTS} != "no"
560 mkdir -p ${WORLDTMP}${TESTSBASE}
561 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
562 -p ${WORLDTMP}${TESTSBASE} >/dev/null
563 .if ${MK_DEBUG_FILES} != "no"
564 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
565 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
566 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
569 .for _mtree in ${LOCAL_MTREE}
570 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
574 @echo "--------------------------------------------------------------"
575 @echo ">>> stage 1.1: legacy release compatibility shims"
576 @echo "--------------------------------------------------------------"
577 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
580 @echo "--------------------------------------------------------------"
581 @echo ">>> stage 1.2: bootstrap tools"
582 @echo "--------------------------------------------------------------"
583 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
585 .if !defined(NO_CLEAN)
587 @echo "--------------------------------------------------------------"
588 @echo ">>> stage 2.1: cleaning up the object tree"
589 @echo "--------------------------------------------------------------"
590 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
591 .if defined(LIBCOMPAT)
592 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
597 @echo "--------------------------------------------------------------"
598 @echo ">>> stage 2.2: rebuilding the object tree"
599 @echo "--------------------------------------------------------------"
600 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
603 @echo "--------------------------------------------------------------"
604 @echo ">>> stage 2.3: build tools"
605 @echo "--------------------------------------------------------------"
606 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
609 @echo "--------------------------------------------------------------"
610 @echo ">>> stage 3: cross tools"
611 @echo "--------------------------------------------------------------"
612 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
613 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
616 @echo "--------------------------------------------------------------"
617 @echo ">>> stage 4.1: building includes"
618 @echo "--------------------------------------------------------------"
619 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
620 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
621 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
622 MK_INCLUDES=yes includes
623 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
624 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
628 @echo "--------------------------------------------------------------"
629 @echo ">>> stage 4.2: building libraries"
630 @echo "--------------------------------------------------------------"
631 ${_+_}cd ${.CURDIR}; \
632 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
633 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
636 @echo "--------------------------------------------------------------"
637 @echo ">>> stage 4.3: building everything"
638 @echo "--------------------------------------------------------------"
639 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
642 WMAKE_TGTS+= _worldtmp _legacy
643 .if empty(SUBDIR_OVERRIDE)
644 WMAKE_TGTS+= _bootstrap-tools
646 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
647 WMAKE_TGTS+= _includes _libraries
648 WMAKE_TGTS+= everything
649 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
650 WMAKE_TGTS+= build${libcompat}
653 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
654 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
656 buildworld_prologue: .PHONY
657 @echo "--------------------------------------------------------------"
658 @echo ">>> World build started on `LC_ALL=C date`"
659 @echo "--------------------------------------------------------------"
661 buildworld_epilogue: .PHONY
663 @echo "--------------------------------------------------------------"
664 @echo ">>> World build completed on `LC_ALL=C date`"
665 @echo "--------------------------------------------------------------"
668 # We need to have this as a target because the indirection between Makefile
669 # and Makefile.inc1 causes the correct PATH to be used, rather than a
670 # modification of the current environment's PATH. In addition, we need
671 # to quote multiword values.
674 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
676 .if ${.TARGETS:Mbuildenv}
677 .if ${.MAKEFLAGS:M-j}
678 .error The buildenv target is incompatible with -j
681 BUILDENV_DIR?= ${.CURDIR}
683 @echo Entering world for ${TARGET_ARCH}:${TARGET}
684 .if ${BUILDENV_SHELL:M*zsh*}
685 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
687 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
690 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
691 toolchain: ${TOOLCHAIN_TGTS}
692 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
697 # Checks to be sure system is ready for installworld/installkernel.
699 installcheck: _installcheck_world _installcheck_kernel
701 _installcheck_kernel:
704 # Require DESTDIR to be set if installing for a different architecture or
705 # using the user/group database in the source tree.
707 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
709 .if !make(distributeworld)
710 _installcheck_world: __installcheck_DESTDIR
711 _installcheck_kernel: __installcheck_DESTDIR
712 __installcheck_DESTDIR:
713 .if !defined(DESTDIR) || empty(DESTDIR)
714 @echo "ERROR: Please set DESTDIR!"; \
720 .if !defined(DB_FROM_SRC)
722 # Check for missing UIDs/GIDs.
724 CHECK_UIDS= auditdistd
726 .if ${MK_SENDMAIL} != "no"
732 CHECK_GIDS+= proxy authpf
734 .if ${MK_UNBOUND} != "no"
738 _installcheck_world: __installcheck_UGID
740 .for uid in ${CHECK_UIDS}
741 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
742 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
746 .for gid in ${CHECK_GIDS}
747 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
748 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
755 # Required install tools to be saved in a scratch dir for safety.
757 .if ${MK_ZONEINFO} != "no"
758 _zoneinfo= zic tzsetup
761 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
762 date echo egrep find grep id install ${_install-info} \
763 ln make mkdir mtree mv pwd_mkdb \
764 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
767 # Needed for share/man
768 .if ${MK_MAN} != "no"
775 # Distributes everything compiled by a `buildworld'.
779 # Installs everything compiled by a 'buildworld'.
782 # Non-base distributions produced by the base system
783 EXTRA_DISTRIBUTIONS= doc
784 .if defined(LIBCOMPAT)
785 EXTRA_DISTRIBUTIONS+= lib${libcompat}
787 .if ${MK_TESTS} != "no"
788 EXTRA_DISTRIBUTIONS+= tests
792 .if ${MK_DEBUG_FILES} != "no"
793 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
796 MTREE_MAGIC?= mtree 2.0
798 distributeworld installworld: _installcheck_world
799 mkdir -p ${INSTALLTMP}
800 progs=$$(for prog in ${ITOOLS}; do \
801 if progpath=`which $$prog`; then \
804 echo "Required tool $$prog not found in PATH." >&2; \
808 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
809 while read line; do \
811 if [ "$$2 $$3" != "not found" ]; then \
814 echo "Required library $$1 not found." >&2; \
818 cp $$libs $$progs ${INSTALLTMP}
819 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
821 -mkdir -p ${METALOG:H}
822 echo "#${MTREE_MAGIC}" > ${METALOG}
824 .if make(distributeworld)
825 .for dist in ${EXTRA_DISTRIBUTIONS}
826 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
827 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
828 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
829 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
830 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
831 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
832 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
833 .if ${MK_DEBUG_FILES} != "no"
834 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
835 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
837 .if defined(LIBCOMPAT)
838 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
839 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
840 .if ${MK_DEBUG_FILES} != "no"
841 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
842 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
845 .if ${MK_TESTS} != "no" && ${dist} == "tests"
846 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
847 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
848 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
849 .if ${MK_DEBUG_FILES} != "no"
850 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
851 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
855 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
856 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
857 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
858 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
859 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
860 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
861 .if defined(LIBCOMPAT)
862 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
863 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
867 -mkdir ${DESTDIR}/${DISTDIR}/base
868 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
869 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
870 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
871 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
873 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
874 ${IMAKEENV} rm -rf ${INSTALLTMP}
875 .if make(distributeworld)
876 .for dist in ${EXTRA_DISTRIBUTIONS}
877 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
880 .for dist in base ${EXTRA_DISTRIBUTIONS}
881 @# For each file that exists in this dist, print the corresponding
882 @# line from the METALOG. This relies on the fact that
883 @# a line containing only the filename will sort immediatly before
884 @# the relevant mtree line.
885 cd ${DESTDIR}/${DISTDIR}; \
886 find ./${dist} | sort -u ${METALOG} - | \
887 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
888 ${DESTDIR}/${DISTDIR}/${dist}.meta
890 .for dist in ${DEBUG_DISTRIBUTIONS}
891 @# For each file that exists in this dist, print the corresponding
892 @# line from the METALOG. This relies on the fact that
893 @# a line containing only the filename will sort immediatly before
894 @# the relevant mtree line.
895 cd ${DESTDIR}/${DISTDIR}; \
896 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
897 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
898 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
904 .for dist in base ${EXTRA_DISTRIBUTIONS}
906 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
907 tar cvf - --exclude usr/lib/debug \
908 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
909 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
911 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
912 tar cvf - --exclude usr/lib/debug . | \
913 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
917 .for dist in ${DEBUG_DISTRIBUTIONS}
918 . if defined(NO_ROOT)
919 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
920 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
921 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
923 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
924 tar cvLf - usr/lib/debug | \
925 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
932 # If you have a build server, you can NFS mount the source and obj directories
933 # and do a 'make reinstall' on the *client* to install new binaries from the
934 # most recent server build.
936 reinstall: .MAKE .PHONY
937 @echo "--------------------------------------------------------------"
938 @echo ">>> Making hierarchy"
939 @echo "--------------------------------------------------------------"
940 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
941 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
943 @echo "--------------------------------------------------------------"
944 @echo ">>> Installing everything"
945 @echo "--------------------------------------------------------------"
946 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
947 .if defined(LIBCOMPAT)
948 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
951 redistribute: .MAKE .PHONY
952 @echo "--------------------------------------------------------------"
953 @echo ">>> Distributing everything"
954 @echo "--------------------------------------------------------------"
955 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
956 .if defined(LIBCOMPAT)
957 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
958 DISTRIBUTION=lib${libcompat}
961 distrib-dirs distribution: .MAKE .PHONY
962 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
963 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
964 .if make(distribution)
965 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
966 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
967 METALOG=${METALOG} MK_TESTS=no installconfig
971 # buildkernel and installkernel
973 # Which kernels to build and/or install is specified by setting
974 # KERNCONF. If not defined a GENERIC kernel is built/installed.
975 # Only the existing (depending TARGET) config files are used
976 # for building kernels and only the first of these is designated
977 # as the one being installed.
979 # Note that we have to use TARGET instead of TARGET_ARCH when
980 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
981 # be set to cross-build, we have to make sure TARGET is set
984 .if defined(KERNFAST)
988 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
989 .if !defined(KERNCONF) && ${KERNFAST} != "1"
993 .if ${TARGET_ARCH} == "powerpc64"
998 INSTKERNNAME?= kernel
1000 KERNSRCDIR?= ${.CURDIR}/sys
1001 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1002 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1003 KERNCONFDIR?= ${KRNLCONFDIR}
1007 .if defined(NO_INSTALLKERNEL)
1008 # All of the BUILDKERNELS loops start at index 1.
1009 BUILDKERNELS+= dummy
1011 .for _kernel in ${KERNCONF}
1012 .if exists(${KERNCONFDIR}/${_kernel})
1013 BUILDKERNELS+= ${_kernel}
1014 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1015 INSTALLKERNEL= ${_kernel}
1020 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1025 # Builds all kernels defined by BUILDKERNELS.
1027 buildkernel: .MAKE .PHONY
1028 .if empty(BUILDKERNELS:Ndummy)
1029 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1033 .for _kernel in ${BUILDKERNELS:Ndummy}
1034 @echo "--------------------------------------------------------------"
1035 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1036 @echo "--------------------------------------------------------------"
1037 @echo "===> ${_kernel}"
1038 mkdir -p ${KRNLOBJDIR}
1039 .if !defined(NO_KERNELCONFIG)
1041 @echo "--------------------------------------------------------------"
1042 @echo ">>> stage 1: configuring the kernel"
1043 @echo "--------------------------------------------------------------"
1044 cd ${KRNLCONFDIR}; \
1046 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1047 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1049 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1051 @echo "--------------------------------------------------------------"
1052 @echo ">>> stage 2.1: cleaning up the object tree"
1053 @echo "--------------------------------------------------------------"
1054 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1056 .if !defined(NO_KERNELOBJ)
1058 @echo "--------------------------------------------------------------"
1059 @echo ">>> stage 2.2: rebuilding the object tree"
1060 @echo "--------------------------------------------------------------"
1061 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1064 @echo "--------------------------------------------------------------"
1065 @echo ">>> stage 2.3: build tools"
1066 @echo "--------------------------------------------------------------"
1067 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1069 @echo "--------------------------------------------------------------"
1070 @echo ">>> stage 3.1: building everything"
1071 @echo "--------------------------------------------------------------"
1072 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1073 @echo "--------------------------------------------------------------"
1074 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1075 @echo "--------------------------------------------------------------"
1079 # installkernel, etc.
1081 # Install the kernel defined by INSTALLKERNEL
1083 installkernel installkernel.debug \
1084 reinstallkernel reinstallkernel.debug: _installcheck_kernel
1085 .if !defined(NO_INSTALLKERNEL)
1086 .if empty(INSTALLKERNEL)
1087 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1090 @echo "--------------------------------------------------------------"
1091 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1092 @echo "--------------------------------------------------------------"
1093 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1094 ${CROSSENV} PATH=${TMPPATH} \
1095 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1097 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1098 .for _kernel in ${BUILDKERNELS:[2..-1]}
1099 @echo "--------------------------------------------------------------"
1100 @echo ">>> Installing kernel ${_kernel}"
1101 @echo "--------------------------------------------------------------"
1102 cd ${KRNLOBJDIR}/${_kernel}; \
1103 ${CROSSENV} PATH=${TMPPATH} \
1104 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1108 distributekernel distributekernel.debug:
1109 .if !defined(NO_INSTALLKERNEL)
1110 .if empty(INSTALLKERNEL)
1111 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1114 mkdir -p ${DESTDIR}/${DISTDIR}
1115 .if defined(NO_ROOT)
1116 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1118 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1119 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1120 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1121 DESTDIR=${INSTALL_DDIR}/kernel \
1122 ${.TARGET:S/distributekernel/install/}
1123 .if defined(NO_ROOT)
1124 sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1125 ${DESTDIR}/${DISTDIR}/kernel.meta
1128 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1129 .for _kernel in ${BUILDKERNELS:[2..-1]}
1130 .if defined(NO_ROOT)
1131 echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1133 cd ${KRNLOBJDIR}/${_kernel}; \
1134 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1135 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1136 KERNEL=${INSTKERNNAME}.${_kernel} \
1137 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1138 ${.TARGET:S/distributekernel/install/}
1139 .if defined(NO_ROOT)
1140 sed -e 's|^./kernel|.|' \
1141 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1142 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1148 .if defined(NO_ROOT)
1149 .if !defined(NO_INSTALLKERNEL)
1150 cd ${DESTDIR}/${DISTDIR}/kernel; \
1151 tar cvf - --exclude '*.debug' \
1152 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1153 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1155 cd ${DESTDIR}/${DISTDIR}/kernel; \
1156 tar cvf - --include '*/*/*.debug' \
1157 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1158 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1159 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1160 .for _kernel in ${BUILDKERNELS:[2..-1]}
1161 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1162 tar cvf - --exclude '*.debug' \
1163 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1164 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1165 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1166 tar cvf - --include '*/*/*.debug' \
1167 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1168 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1172 .if !defined(NO_INSTALLKERNEL)
1173 cd ${DESTDIR}/${DISTDIR}/kernel; \
1174 tar cvf - --exclude '*.debug' . | \
1175 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1177 cd ${DESTDIR}/${DISTDIR}/kernel; \
1178 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1179 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1180 .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
1181 .for _kernel in ${BUILDKERNELS:[2..-1]}
1182 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1183 tar cvf - --exclude '*.debug' . | \
1184 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1185 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1186 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1187 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1196 # Run test suite on installed world.
1199 @if [ ! -x ${LOCALBASE}/bin/kyua ]; then \
1200 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1203 ${_+_}${LOCALBASE}/bin/kyua test -k ${TESTSBASE}/Kyuafile
1209 # Build the API documentation with doxygen
1212 @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1213 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1216 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1221 # Update the source tree(s), by running svn/svnup to update to the
1225 .if defined(SVN_UPDATE)
1226 @echo "--------------------------------------------------------------"
1227 @echo ">>> Updating ${.CURDIR} using Subversion"
1228 @echo "--------------------------------------------------------------"
1229 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1233 # ------------------------------------------------------------------------
1235 # From here onwards are utility targets used by the 'make world' and
1236 # related targets. If your 'world' breaks, you may like to try to fix
1237 # the problem and manually run the following targets to attempt to
1238 # complete the build. Beware, this is *not* guaranteed to work, you
1239 # need to have a pretty good grip on the current state of the system
1240 # to attempt to manually finish it. If in doubt, 'make world' again.
1244 # legacy: Build compatibility shims for the next three targets. This is a
1245 # minimal set of tools and shims necessary to compensate for older systems
1246 # which don't have the APIs required by the targets built in bootstrap-tools,
1247 # build-tools or cross-tools.
1250 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1251 # r296685 fix cross-endian objcopy
1252 .if ${BOOTSTRAPPING} < 1100102
1253 _elftoolchain_libs= lib/libelf lib/libdwarf
1257 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1258 @echo "ERROR: Source upgrades from versions prior to 8.0 are not supported."; \
1261 .for _tool in tools/build ${_elftoolchain_libs}
1262 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1263 cd ${.CURDIR}/${_tool}; \
1264 ${MAKE} DIRPRFX=${_tool}/ obj; \
1265 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1266 ${MAKE} DIRPRFX=${_tool}/ all; \
1267 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1271 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1272 # are built to build other binaries in the system. However, the focus of these
1273 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1274 # libraries, augmented by -legacy.
1276 _bt= _bootstrap-tools
1278 .if ${MK_GAMES} != "no"
1279 _strfile= usr.bin/fortune/strfile
1282 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1283 _gperf= gnu/usr.bin/gperf
1286 .if ${MK_GROFF} != "no"
1287 _groff= gnu/usr.bin/groff \
1291 .if ${MK_VT} != "no"
1292 _vtfontcvt= usr.bin/vtfontcvt
1295 .if ${BOOTSTRAPPING} < 900002
1299 .if ${BOOTSTRAPPING} < 1000033
1300 _libopenbsd= lib/libopenbsd
1304 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1305 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1308 .if ${BOOTSTRAPPING} < 1000026
1309 _nmtree= lib/libnetbsd \
1312 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1315 .if ${BOOTSTRAPPING} < 1000027
1319 # r264059 support for status=
1320 .if ${BOOTSTRAPPING} < 1100017
1324 # r277259 crunchide: Correct 64-bit section header offset
1325 # r281674 crunchide: always include both 32- and 64-bit ELF support
1326 # r285986 crunchen: use STRIPBIN rather than STRIP
1327 .if ${BOOTSTRAPPING} < 1100078
1328 _crunch= usr.sbin/crunch
1331 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1335 # r296926 -P keymap search path
1336 .if ${BOOTSTRAPPING} < 1100103
1337 _kbdcontrol= usr.sbin/kbdcontrol
1343 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1345 .if ${MK_BSNMP} != "no"
1346 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1349 # We need to build tblgen when we're building clang either as
1350 # the bootstrap compiler, or as the part of the normal build.
1351 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1353 lib/clang/libllvmsupport \
1354 lib/clang/libllvmtablegen \
1355 usr.bin/clang/llvm-tblgen \
1356 usr.bin/clang/clang-tblgen
1358 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1359 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1362 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1365 .if ${MK_GPL_DTC} != "no"
1366 _dtc= gnu/usr.bin/dtc
1369 .if ${MK_KERBEROS} != "no"
1370 _kerberos5_bootstrap_tools= \
1371 kerberos5/tools/make-roken \
1372 kerberos5/lib/libroken \
1373 kerberos5/lib/libvers \
1374 kerberos5/tools/asn1_compile \
1375 kerberos5/tools/slc \
1378 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1381 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
1382 .if ${MK_MANDOCDB} != "no" && ${BOOTSTRAPPING} < 1100075
1383 _libopenbsd?= lib/libopenbsd
1384 _makewhatis= lib/libsqlite3 \
1386 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1389 bootstrap-tools: .PHONY
1391 # Please document (add comment) why something is in 'bootstrap-tools'.
1392 # Try to bound the building of the bootstrap-tool to just the
1393 # FreeBSD versions that need the tool built at this stage of the build.
1396 ${_kerberos5_bootstrap_tools} \
1420 ${_bt}-${_tool}: .PHONY .MAKE
1421 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1422 cd ${.CURDIR}/${_tool}; \
1423 ${MAKE} DIRPRFX=${_tool}/ obj; \
1424 ${MAKE} DIRPRFX=${_tool}/ all; \
1425 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1427 bootstrap-tools: ${_bt}-${_tool}
1431 # build-tools: Build special purpose build tools
1433 .if !defined(NO_SHARE)
1434 _share= share/syscons/scrnmaps
1437 .if ${MK_GCC} != "no"
1438 _gcc_tools= gnu/usr.bin/cc/cc_tools
1441 .if ${MK_RESCUE} != "no"
1442 # rescue includes programs that have build-tools targets
1443 _rescue=rescue/rescue
1449 ${LOCAL_TOOL_DIRS} \
1450 lib/ncurses/ncurses \
1451 lib/ncurses/ncursesw \
1456 usr.bin/mkesdb_static \
1457 usr.bin/mkcsmapper_static \
1459 build-tools_${_tool}: .PHONY
1460 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1461 cd ${.CURDIR}/${_tool}; \
1462 ${MAKE} DIRPRFX=${_tool}/ obj; \
1463 ${MAKE} DIRPRFX=${_tool}/ build-tools
1464 build-tools: build-tools_${_tool}
1468 build-tools_${_tool}: .PHONY
1469 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \
1470 cd ${.CURDIR}/${_tool}; \
1471 ${MAKE} DIRPRFX=${_tool}/ obj; \
1472 ${MAKE} DIRPRFX=${_tool}/ all
1473 build-tools: build-tools_${_tool}
1477 # kernel-tools: Build kernel-building tools
1480 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1481 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1482 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1485 # cross-tools: All the tools needed to build the rest of the system after
1486 # we get done with the earlier stages. It is the last set of tools needed
1487 # to begin building the target binaries.
1489 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1490 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1491 _btxld= usr.sbin/btxld
1495 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1496 # resulting from missing bug fixes or ELF Toolchain updates.
1497 .if ${MK_CDDL} != "no"
1498 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1499 cddl/usr.bin/ctfmerge
1502 # If we're given an XAS, don't build binutils.
1503 .if ${XAS:M/*} == ""
1504 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1505 _binutils= gnu/usr.bin/binutils
1507 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1508 _elftctools= lib/libelftc \
1514 # These are not required by the build, but can be useful for developers who
1515 # cross-build on a FreeBSD 10 host:
1516 _elftctools+= usr.bin/addr2line
1518 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1519 # If cross-building with an external binutils we still need to build strip for
1520 # the target (for at least crunchide).
1521 _elftctools= lib/libelftc \
1526 # If an full path to an external cross compiler is given, don't build
1528 .if ${XCC:N${CCACHE_BIN}:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
1529 .if ${MK_CLANG_BOOTSTRAP} != "no"
1530 _clang= usr.bin/clang
1531 _clang_libs= lib/clang
1533 .if ${MK_GCC_BOOTSTRAP} != "no"
1537 .if ${MK_USB} != "no"
1538 _usb_tools= sys/boot/usb/tools
1541 cross-tools: .MAKE .PHONY
1552 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1553 cd ${.CURDIR}/${_tool}; \
1554 ${MAKE} DIRPRFX=${_tool}/ obj; \
1555 ${MAKE} DIRPRFX=${_tool}/ all; \
1556 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1559 NXBDESTDIR= ${OBJTREE}/nxb-bin
1560 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1561 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1562 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1563 NXBMAKE= ${NXBENV} ${MAKE} \
1564 LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \
1565 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1566 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1567 MK_GDB=no MK_TESTS=no \
1569 MK_HTML=no NO_LINT=yes MK_MAN=no \
1570 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1571 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1572 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1573 MK_LLDB=no MK_DEBUG_FILES=no
1575 # native-xtools is the current target for qemu-user cross builds of ports
1576 # via poudriere and the imgact_binmisc kernel module.
1577 # For non-clang enabled targets that are still using the in tree gcc
1578 # we must build a gperf binary for one instance of its Makefiles. On
1579 # clang-enabled systems, the gperf binary is obsolete.
1580 native-xtools: .PHONY
1581 .if ${MK_GCC_BOOTSTRAP} != "no"
1582 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1583 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \
1584 cd ${.CURDIR}/${_gperf}; \
1585 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1586 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1587 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1589 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1590 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1591 -p ${NXBDESTDIR}/usr >/dev/null
1592 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1593 -p ${NXBDESTDIR}/usr/include >/dev/null
1594 .if ${MK_DEBUG_FILES} != "no"
1595 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1596 -p ${NXBDESTDIR}/usr/lib >/dev/null
1657 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1658 cd ${.CURDIR}/${_tool}; \
1659 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1660 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1661 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1665 # hierarchy - ensure that all the needed directories are present
1667 hierarchy hier: .MAKE .PHONY
1668 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1671 # libraries - build all libraries, and install them under ${DESTDIR}.
1673 # The list of libraries with dependents (${_prebuild_libs}) and their
1674 # interdependencies (__L) are built automatically by the
1675 # ${.CURDIR}/tools/make_libdeps.sh script.
1677 libraries: .MAKE .PHONY
1678 ${_+_}cd ${.CURDIR}; \
1679 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1680 ${MAKE} -f Makefile.inc1 _startup_libs; \
1681 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1682 ${MAKE} -f Makefile.inc1 _generic_libs
1685 # static libgcc.a prerequisite for shared libc
1687 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1689 # These dependencies are not automatically generated:
1691 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1692 # all shared libraries for ELF.
1694 _startup_libs= gnu/lib/csu
1695 _startup_libs+= lib/csu
1696 _startup_libs+= gnu/lib/libgcc
1697 _startup_libs+= lib/libcompiler_rt
1698 _startup_libs+= lib/libc
1699 _startup_libs+= lib/libc_nonshared
1700 .if ${MK_LIBCPLUSPLUS} != "no"
1701 _startup_libs+= lib/libcxxrt
1704 gnu/lib/libgcc__L: lib/libc__L
1705 gnu/lib/libgcc__L: lib/libc_nonshared__L
1706 .if ${MK_LIBCPLUSPLUS} != "no"
1707 lib/libcxxrt__L: gnu/lib/libgcc__L
1710 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1711 ${_kerberos5_lib_libhdb} \
1712 ${_kerberos5_lib_libheimbase} \
1713 ${_kerberos5_lib_libheimntlm} \
1715 ${_kerberos5_lib_libheimipcc} \
1716 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1717 ${_kerberos5_lib_libroken} \
1718 ${_kerberos5_lib_libwind} \
1719 lib/libbz2 ${_libcom_err} lib/libcrypt \
1720 lib/libelf lib/libexpat \
1723 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1725 lib/ncurses/ncurses lib/ncurses/ncursesw \
1726 lib/libopie lib/libpam/libpam ${_lib_libthr} \
1727 ${_lib_libradius} lib/libsbuf lib/libtacplus \
1729 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1730 ${_cddl_lib_libuutil} \
1731 ${_cddl_lib_libavl} \
1732 ${_cddl_lib_libzfs_core} \
1733 ${_cddl_lib_libctf} \
1734 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1735 ${_secure_lib_libcrypto} ${_lib_libldns} \
1736 ${_secure_lib_libssh} ${_secure_lib_libssl} \
1739 .if ${MK_GNUCXX} != "no"
1740 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1741 gnu/lib/libstdc++__L: lib/msun__L
1742 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1745 .if ${MK_LIBCPLUSPLUS} != "no"
1746 _prebuild_libs+= lib/libc++
1749 lib/libgeom__L: lib/libexpat__L
1750 lib/libkvm__L: lib/libelf__L
1752 .if ${MK_LIBTHR} != "no"
1753 _lib_libthr= lib/libthr
1756 .if ${MK_RADIUS_SUPPORT} != "no"
1757 _lib_libradius= lib/libradius
1760 .if ${MK_OFED} != "no"
1761 _ofed_lib= contrib/ofed/usr.lib
1762 _prebuild_libs+= contrib/ofed/usr.lib/libosmcomp
1763 _prebuild_libs+= contrib/ofed/usr.lib/libopensm
1764 _prebuild_libs+= contrib/ofed/usr.lib/libibcommon
1765 _prebuild_libs+= contrib/ofed/usr.lib/libibverbs
1766 _prebuild_libs+= contrib/ofed/usr.lib/libibumad
1768 contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
1769 contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
1770 contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
1773 .if ${MK_CASPER} != "no"
1774 _lib_casper= lib/libcasper
1777 lib/libpjdlog__L: lib/libutil__L
1778 lib/libcasper__L: lib/libnv__L
1779 lib/liblzma__L: lib/libthr__L
1781 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
1782 .for _DIR in ${LOCAL_LIB_DIRS}
1783 .if exists(${.CURDIR}/${_DIR}/Makefile) && empty(_generic_libs:M${_DIR})
1784 _generic_libs+= ${_DIR}
1788 lib/libopie__L lib/libtacplus__L: lib/libmd__L
1790 .if ${MK_CDDL} != "no"
1791 _cddl_lib_libumem= cddl/lib/libumem
1792 _cddl_lib_libnvpair= cddl/lib/libnvpair
1793 _cddl_lib_libavl= cddl/lib/libavl
1794 _cddl_lib_libuutil= cddl/lib/libuutil
1795 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
1796 _cddl_lib_libctf= cddl/lib/libctf
1798 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
1799 cddl/lib/libzfs__L: lib/libgeom__L
1800 cddl/lib/libctf__L: lib/libz__L
1802 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
1803 # on select architectures though (see cddl/lib/Makefile)
1804 .if ${MACHINE_CPUARCH} != "sparc64"
1805 _prebuild_libs+= lib/libproc lib/librtld_db
1808 .if ${MK_CRYPT} != "no"
1809 .if ${MK_OPENSSL} != "no"
1810 _secure_lib_libcrypto= secure/lib/libcrypto
1811 _secure_lib_libssl= secure/lib/libssl
1812 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
1813 .if ${MK_LDNS} != "no"
1814 _lib_libldns= lib/libldns
1815 lib/libldns__L: secure/lib/libcrypto__L
1817 .if ${MK_OPENSSH} != "no"
1818 _secure_lib_libssh= secure/lib/libssh
1819 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
1820 .if ${MK_LDNS} != "no"
1821 secure/lib/libssh__L: lib/libldns__L
1823 .if ${MK_KERBEROS_SUPPORT} != "no"
1824 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
1825 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
1826 lib/libmd__L kerberos5/lib/libroken__L
1830 _secure_lib= secure/lib
1833 .if ${MK_KERBEROS} != "no"
1834 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
1835 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1836 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
1837 kerberos5/lib/libwind__L lib/libsqlite3__L
1838 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
1839 kerberos5/lib/libroken__L lib/libcom_err__L
1840 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1841 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
1842 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
1843 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
1844 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
1845 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
1846 kerberos5/lib/libroken__L: lib/libcrypt__L
1847 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
1848 kerberos5/lib/libheimbase__L: lib/libthr__L
1849 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
1852 lib/libsqlite3__L: lib/libthr__L
1854 .if ${MK_GSSAPI} != "no"
1855 _lib_libgssapi= lib/libgssapi
1858 .if ${MK_KERBEROS} != "no"
1859 _kerberos5_lib= kerberos5/lib
1860 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
1861 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
1862 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
1863 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
1864 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
1865 _kerberos5_lib_libroken= kerberos5/lib/libroken
1866 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
1867 _libsqlite3= lib/libsqlite3
1868 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
1869 _kerberos5_lib_libwind= kerberos5/lib/libwind
1870 _libcom_err= lib/libcom_err
1873 .if ${MK_NIS} != "no"
1874 _lib_libypclnt= lib/libypclnt
1877 .if ${MK_OPENSSL} == "no"
1878 lib/libradius__L: lib/libmd__L
1882 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
1883 .if ${MK_CXX} != "no"
1884 .if ${MK_LIBCPLUSPLUS} != "no"
1885 lib/libproc__L: lib/libcxxrt__L
1886 .else # This implies MK_GNUCXX != "no"; see lib/libproc
1887 lib/libproc__L: gnu/lib/libsupc++__L
1891 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
1893 .for _lib in ${_prereq_libs}
1894 ${_lib}__PL: .PHONY .MAKE
1895 .if exists(${.CURDIR}/${_lib})
1896 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
1897 cd ${.CURDIR}/${_lib}; \
1898 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
1899 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
1900 DIRPRFX=${_lib}/ all; \
1901 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
1902 DIRPRFX=${_lib}/ install
1906 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
1907 ${_lib}__L: .PHONY .MAKE
1908 .if exists(${.CURDIR}/${_lib})
1909 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
1910 cd ${.CURDIR}/${_lib}; \
1911 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
1912 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
1913 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
1917 _prereq_libs: ${_prereq_libs:S/$/__PL/}
1918 _startup_libs: ${_startup_libs:S/$/__L/}
1919 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
1920 _generic_libs: ${_generic_libs:S/$/__L/}
1922 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
1923 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
1924 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
1925 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
1926 # parallel. This is safe for the world stage of buildworld though since it has
1927 # already built libraries in a proper order and installed includes into
1928 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
1929 # avoid trashing a system if it crashes mid-install.
1930 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
1934 .include <bsd.subdir.mk>
1936 .if make(check-old) || make(check-old-dirs) || \
1937 make(check-old-files) || make(check-old-libs) || \
1938 make(delete-old) || make(delete-old-dirs) || \
1939 make(delete-old-files) || make(delete-old-libs)
1942 # check for / delete old files section
1945 .include "ObsoleteFiles.inc"
1947 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
1948 else you can not start such an application. Consult UPDATING for more \
1949 information regarding how to cope with the removal/revision bump of a \
1952 .if !defined(BATCH_DELETE_OLD_FILES)
1959 @echo ">>> Removing old files (only deletes safe to delete libs)"
1960 # Ask for every old file if the user really wants to remove it.
1961 # It's annoying, but better safe than sorry.
1962 # NB: We cannot pass the list of OLD_FILES as a parameter because the
1963 # argument list will get too long. Using .for/.endfor make "loops" will make
1964 # the Makefile parser segfault.
1967 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1968 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1969 while read file; do \
1970 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
1971 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
1972 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
1974 for ext in debug symbols; do \
1975 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
1976 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
1977 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
1982 # Remove catpages without corresponding manpages.
1984 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
1985 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
1986 while read catpage; do \
1988 if [ ! -e "$${manpage}" ]; then \
1989 rm ${RM_I} $${catpage} <&3; \
1992 @echo ">>> Old files removed"
1995 @echo ">>> Checking for old files"
1997 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
1998 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
1999 while read file; do \
2000 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2001 echo "${DESTDIR}/$${file}"; \
2003 for ext in debug symbols; do \
2004 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2005 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2009 # Check for catpages without corresponding manpages.
2010 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2011 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2012 while read catpage; do \
2014 if [ ! -e "$${manpage}" ]; then \
2020 @echo ">>> Removing old libraries"
2021 @echo "${OLD_LIBS_MESSAGE}" | fmt
2024 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2025 -V OLD_LIBS | xargs -n1 | \
2026 while read file; do \
2027 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2028 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2029 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2031 for ext in debug symbols; do \
2032 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2033 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2034 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2039 @echo ">>> Old libraries removed"
2042 @echo ">>> Checking for old libraries"
2044 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2045 -V OLD_LIBS | xargs -n1 | \
2046 while read file; do \
2047 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2048 echo "${DESTDIR}/$${file}"; \
2050 for ext in debug symbols; do \
2051 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2052 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2058 @echo ">>> Removing old directories"
2060 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2061 -V OLD_DIRS | xargs -n1 | sort -r | \
2062 while read dir; do \
2063 if [ -d "${DESTDIR}/$${dir}" ]; then \
2064 rmdir -v "${DESTDIR}/$${dir}" || true; \
2065 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2066 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2069 @echo ">>> Old directories removed"
2072 @echo ">>> Checking for old directories"
2074 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2075 -V OLD_DIRS | xargs -n1 | \
2076 while read dir; do \
2077 if [ -d "${DESTDIR}/$${dir}" ]; then \
2078 echo "${DESTDIR}/$${dir}"; \
2079 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2080 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2084 delete-old: delete-old-files delete-old-dirs
2085 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2087 check-old: check-old-files check-old-libs check-old-dirs
2088 @echo "To remove old files and directories run '${MAKE} delete-old'."
2089 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2094 # showconfig - show build configuration.
2097 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2098 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2100 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2101 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2103 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2104 .if exists(${KERNCONFDIR}/${KERNCONF})
2105 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2106 '${KERNCONFDIR}/${KERNCONF}' ; echo
2112 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2113 DTBOUTPUTPATH= ${.CURDIR}
2117 # Build 'standalone' Device Tree Blob
2120 @PATH=${TMPPATH} MACHINE=${TARGET} \
2121 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2122 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2127 # In the following, the first 'rm' in a series will usually remove all
2128 # files and directories. If it does not, then there are probably some
2129 # files with file flags set, so this unsets them and tries the 'rm' a
2130 # second time. There are situations where this target will be cleaning
2131 # some directories via more than one method, but that duplication is
2132 # needed to correctly handle all the possible situations. Removing all
2133 # files without file flags set in the first 'rm' instance saves time,
2134 # because 'chflags' will need to operate on fewer files afterwards.
2136 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2137 # created by bsd.obj.mk, except that we don't want to .include that file
2140 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2142 .if exists(${BW_CANONICALOBJDIR}/)
2143 -rm -rf ${BW_CANONICALOBJDIR}/*
2144 -chflags -R 0 ${BW_CANONICALOBJDIR}
2145 rm -rf ${BW_CANONICALOBJDIR}/*
2147 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2148 # To be safe in this case, fall back to a 'make cleandir'
2149 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2152 .if defined(TARGET) && defined(TARGET_ARCH)
2154 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2155 XDEV_CPUTYPE?=${CPUTYPE}
2157 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2160 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2161 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2162 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2163 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2164 CPUTYPE=${XDEV_CPUTYPE}
2166 XDDIR=${TARGET_ARCH}-freebsd
2169 .error XDTP variable should be an absolute path
2172 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2173 INSTALL="sh ${.CURDIR}/tools/install.sh"
2175 TOOLS_PREFIX=${XDTP}
2176 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2177 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2178 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2179 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2180 CPP="${CPP} ${CD2CFLAGS}" \
2181 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2183 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2184 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2185 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2186 XDDESTDIR=${DESTDIR}/${XDTP}
2188 OSREL!= uname -r | sed -e 's/[-(].*//'
2191 .ORDER: xdev-build xdev-install xdev-links
2192 xdev: xdev-build xdev-install
2194 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2195 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2197 _xb-worldtmp: .PHONY
2198 mkdir -p ${CDTMP}/usr
2199 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2200 -p ${CDTMP}/usr >/dev/null
2202 _xb-bootstrap-tools: .PHONY
2206 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2207 cd ${.CURDIR}/${_tool}; \
2208 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2209 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2210 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2213 _xb-build-tools: .PHONY
2214 ${_+_}@cd ${.CURDIR}; \
2215 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2217 _xb-cross-tools: .PHONY
2225 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2226 cd ${.CURDIR}/${_tool}; \
2227 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2228 ${CDMAKE} DIRPRFX=${_tool}/ all
2232 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2233 mkdir -p ${XDDESTDIR}
2234 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2235 -p ${XDDESTDIR} >/dev/null
2236 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2237 -p ${XDDESTDIR}/usr >/dev/null
2238 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2239 -p ${XDDESTDIR}/usr/include >/dev/null
2240 .if defined(LIBCOMPAT)
2241 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2242 -p ${XDDESTDIR}/usr >/dev/null
2244 .if ${MK_TESTS} != "no"
2245 mkdir -p ${XDDESTDIR}${TESTSBASE}
2246 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2247 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2250 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2251 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2253 _xi-cross-tools: .PHONY
2254 @echo "_xi-cross-tools"
2262 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2263 cd ${.CURDIR}/${_tool}; \
2264 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2267 _xi-includes: .PHONY
2268 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2269 DESTDIR=${XDDESTDIR}
2271 _xi-libraries: .PHONY
2272 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2273 DESTDIR=${XDDESTDIR}
2276 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2277 mkdir -p ../../../../usr/bin; \
2279 ln -sf ../../${XDTP}/usr/bin/$$i \
2280 ../../../../usr/bin/${XDDIR}-$$i; \
2281 ln -sf ../../${XDTP}/usr/bin/$$i \
2282 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2285 xdev xdev-build xdev-install xdev-links:
2286 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"