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."
52 LOCALBASE?= /usr/local
54 # Cross toolchain changes must be in effect before bsd.compiler.mk
55 # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
56 .if defined(CROSS_TOOLCHAIN)
57 .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
58 CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
60 .if defined(CROSS_TOOLCHAIN_PREFIX)
61 CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
62 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
64 # If we do not have a bootstrap binutils (because the in-tree one does not
65 # support the target architecture), provide a default cross-binutils prefix.
66 # This allows aarch64 builds, for example, to automatically use the
67 # aarch64-binutils port or package.
69 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
70 !defined(CROSS_BINUTILS_PREFIX)
71 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
72 .if !exists(${CROSS_BINUTILS_PREFIX})
73 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
78 XCOMPILERS= CC CXX CPP
79 .for COMPILER in ${XCOMPILERS}
80 .if defined(CROSS_COMPILER_PREFIX)
81 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
83 X${COMPILER}?= ${${COMPILER}}
86 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
87 .for BINUTIL in ${XBINUTILS}
88 .if defined(CROSS_BINUTILS_PREFIX) && \
89 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
90 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
92 X${BINUTIL}?= ${${BINUTIL}}
95 # If a full path to an external cross compiler is given, don't build
97 .if ${XCC:N${CCACHE_BIN}:M/*}
101 # Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early.
102 .include <bsd.compiler.mk>
103 .include "share/mk/src.opts.mk"
105 # Check if there is a local compiler that can satisfy as an external compiler.
106 .if ${MK_SYSTEM_COMPILER} == "yes" && ${MK_CROSS_COMPILER} == "yes" && \
107 (${MK_CLANG_BOOTSTRAP} == "yes" || ${MK_GCC_BOOTSTRAP} == "yes") && \
109 # Which compiler is expected to be used?
110 .if ${MK_CLANG_BOOTSTRAP} == "yes"
111 _expected_compiler_type= clang
112 .elif ${MK_GCC_BOOTSTRAP} == "yes"
113 _expected_compiler_type= gcc
115 # If the expected vs CC is different then we can't skip.
116 # GCC cannot be used for cross-arch yet. For clang we pass -target later if
117 # TARGET_ARCH!=MACHINE_ARCH.
118 .if ${_expected_compiler_type} == ${COMPILER_TYPE} && \
119 (${COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH})
120 # It needs to be the same revision as we would build for the bootstrap.
121 .if !defined(CROSS_COMPILER_FREEBSD_VERSION)
122 .if ${_expected_compiler_type} == "clang"
123 CROSS_COMPILER_FREEBSD_VERSION!= \
124 awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
125 ${SRCDIR}/lib/clang/include/clang/Basic/Version.inc || echo unknown
126 CROSS_COMPILER_VERSION!= \
127 awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
128 ${SRCDIR}/lib/clang/include/clang/Basic/Version.inc || echo unknown
129 .elif ${_expected_compiler_type} == "gcc"
130 CROSS_COMPILER_FREEBSD_VERSION!= \
131 awk '$$2 == "FBSD_CC_VER" {printf("%d\n", $$3)}' \
132 ${SRCDIR}/gnu/usr.bin/cc/cc_tools/freebsd-native.h || echo unknown
133 CROSS_COMPILER_VERSION!= \
134 awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3}' \
135 ${SRCDIR}/contrib/gcc/BASE-VER || echo unknown
137 .export CROSS_COMPILER_FREEBSD_VERSION CROSS_COMPILER_VERSION
138 .endif # !defined(CROSS_COMPILER_FREEBSD_VERSION)
139 .if ${COMPILER_VERSION} == ${CROSS_COMPILER_VERSION} && \
140 ${COMPILER_FREEBSD_VERSION} == ${CROSS_COMPILER_FREEBSD_VERSION}
141 # Everything matches, disable the bootstrap compiler.
142 MK_CLANG_BOOTSTRAP= no
144 CROSSENV+= COMPILER_VERSION=${COMPILER_VERSION} \
145 COMPILER_TYPE=${COMPILER_TYPE} \
146 COMPILER_FREEBSD_VERSION=${COMPILER_FREEBSD_VERSION}
148 .info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler.
150 .endif # ${COMPILER_VERSION} == ${CROSS_COMPILER_VERSION}
151 .endif # ${_expected_compiler_type} == ${COMPILER_TYPE}
152 .endif # ${XCC:N${CCACHE_BIN}:M/*}
155 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
156 # keep the users system reasonably usable. For static->dynamic root upgrades,
157 # we don't want to install a dynamic binary without rtld and the needed
158 # libraries. More commonly, for dynamic root, we don't want to install a
159 # binary that requires a newer library version that hasn't been installed yet.
160 # This ordering is not a guarantee though. The only guarantee of a working
161 # system here would require fine-grained ordering of all components based
162 # on their dependencies.
163 .if !empty(SUBDIR_OVERRIDE)
164 SUBDIR= ${SUBDIR_OVERRIDE}
167 .if !defined(NO_ROOT) && (make(installworld) || make(install))
168 # Ensure libraries are installed before progressing.
172 .if ${MK_CDDL} != "no"
176 .if ${MK_KERBEROS} != "no"
179 .if ${MK_RESCUE} != "no"
183 .if ${MK_CRYPT} != "no"
186 .if !defined(NO_SHARE)
189 SUBDIR+=sys usr.bin usr.sbin
190 .if ${MK_TESTS} != "no"
193 .if ${MK_OFED} != "no"
197 # Local directories are last, since it is nice to at least get the base
198 # system rebuilt before you do them.
199 .for _DIR in ${LOCAL_DIRS}
200 .if exists(${.CURDIR}/${_DIR}/Makefile)
204 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
205 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
206 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
207 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
208 _REDUNDENT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
210 .for _DIR in ${LOCAL_LIB_DIRS}
211 .if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
214 .warning ${_DIR} not added to SUBDIR list. See UPDATING 20141121.
218 # We must do etc/ last as it hooks into building the man whatis file
219 # by calling 'makedb' in share/man. This is only relevant for
220 # install/distribute so they build the whatis file after every manpage is
222 .if make(installworld) || make(install)
227 .endif # !empty(SUBDIR_OVERRIDE)
230 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
233 .if defined(NO_CLEANDIR)
234 CLEANDIR= clean cleandepend
239 .if ${MK_META_MODE} == "yes"
240 # If filemon is used then we can rely on the build being incremental-safe.
241 # The .meta files will also track the build command and rebuild should
243 .if empty(.MAKE.MODE:Mnofilemon)
249 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
251 .if empty(SHELL:M*csh*)
252 BUILDENV_SHELL?=${SHELL}
254 BUILDENV_SHELL?=/bin/sh
257 .if !defined(SVN) || empty(SVN)
258 . for _P in /usr/bin /usr/local/bin
259 . for _S in svn svnlite
260 . if exists(${_P}/${_S})
268 MAKEOBJDIRPREFIX?= /usr/obj
269 .if !defined(OSRELDATE)
270 .if exists(/usr/include/osreldate.h)
271 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
272 /usr/include/osreldate.h
279 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
280 .if !defined(_REVISION)
281 _REVISION!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V REVISION
284 .if !defined(_BRANCH)
285 _BRANCH!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V BRANCH
288 .if !defined(SRCRELDATE)
289 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
290 ${SRCDIR}/sys/sys/param.h
293 .if !defined(VERSION)
294 VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
298 .if !defined(PKG_VERSION)
299 .if ${_BRANCH:MSTABLE*} || ${_BRANCH:MCURRENT*}
300 TIMENOW= %Y%m%d%H%M%S
301 EXTRA_REVISION= .s${TIMENOW:gmtime}
304 EXTRA_REVISION= _${_BRANCH:C/.*-p([0-9]+$)/\1/}
306 PKG_VERSION= ${_REVISION}${EXTRA_REVISION}
309 KNOWN_ARCHES?= aarch64/arm64 \
327 .if ${TARGET} == ${TARGET_ARCH}
330 _t= ${TARGET_ARCH}/${TARGET}
333 .if empty(KNOWN_ARCHES:M${_t})
334 .error Unknown target ${TARGET_ARCH}:${TARGET}.
338 .if ${TARGET} == ${MACHINE}
339 TARGET_CPUTYPE?=${CPUTYPE}
344 .if !empty(TARGET_CPUTYPE)
345 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
347 _TARGET_CPUTYPE=dummy
349 _CPUTYPE!= MK_AUTO_OBJ=no MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
350 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
351 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
352 .error CPUTYPE global should be set with ?=.
355 BUILD_ARCH!= uname -p
356 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
357 .error To cross-build, set TARGET_ARCH.
360 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
361 OBJTREE= ${MAKEOBJDIRPREFIX}
363 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
365 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
366 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
367 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
368 STRICTTMPPATH= ${BPATH}:${XPATH}
369 TMPPATH= ${STRICTTMPPATH}:${PATH}
372 # Avoid running mktemp(1) unless actually needed.
373 # It may not be functional, e.g., due to new ABI
374 # when in the middle of installing over this system.
376 .if make(distributeworld) || make(installworld) || make(stageworld)
377 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
380 .if make(stagekernel) || make(distributekernel)
386 # Building a world goes through the following stages
388 # 1. legacy stage [BMAKE]
389 # This stage is responsible for creating compatibility
390 # shims that are needed by the bootstrap-tools,
391 # build-tools and cross-tools stages. These are generally
392 # APIs that tools from one of those three stages need to
393 # build that aren't present on the host.
394 # 1. bootstrap-tools stage [BMAKE]
395 # This stage is responsible for creating programs that
396 # are needed for backward compatibility reasons. They
397 # are not built as cross-tools.
398 # 2. build-tools stage [TMAKE]
399 # This stage is responsible for creating the object
400 # tree and building any tools that are needed during
401 # the build process. Some programs are listed during
402 # this phase because they build binaries to generate
403 # files needed to build these programs. This stage also
404 # builds the 'build-tools' target rather than 'all'.
405 # 3. cross-tools stage [XMAKE]
406 # This stage is responsible for creating any tools that
407 # are needed for building the system. A cross-compiler is one
408 # of them. This differs from build tools in two ways:
409 # 1. the 'all' target is built rather than 'build-tools'
410 # 2. these tools are installed into TMPPATH for stage 4.
411 # 4. world stage [WMAKE]
412 # This stage actually builds the world.
413 # 5. install stage (optional) [IMAKE]
414 # This stage installs a previously built world.
419 # Common environment for world related stages
420 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
421 MACHINE_ARCH=${TARGET_ARCH} \
423 CPUTYPE=${TARGET_CPUTYPE}
424 .if ${MK_META_MODE} != "no"
425 # Don't rebuild build-tools targets during normal build.
426 CROSSENV+= BUILD_TOOLS_META=.NOMETA_CMP
428 .if ${MK_GROFF} != "no"
429 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
430 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
431 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
433 .if defined(TARGET_CFLAGS)
434 CROSSENV+= ${TARGET_CFLAGS}
437 # bootstrap-tools stage
438 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
439 TOOLS_PREFIX=${WORLDTMP} \
440 PATH=${BPATH}:${PATH} \
441 WORLDTMP=${WORLDTMP} \
442 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
443 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
445 BOOTSTRAPPING=${OSRELDATE} \
447 MK_HTML=no NO_LINT=yes MK_MAN=no \
448 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
449 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
450 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
451 MK_LLDB=no MK_TESTS=no \
454 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
455 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
459 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
460 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
461 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
463 BOOTSTRAPPING=${OSRELDATE} \
466 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
467 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
468 MK_LLDB=no MK_TESTS=no
471 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
472 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
473 MK_GDB=no MK_TESTS=no
476 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
477 PATH=${BPATH}:${PATH} \
479 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
480 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
482 BOOTSTRAPPING=${OSRELDATE} \
484 MK_HTML=no -DNO_LINT MK_MAN=no \
485 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
486 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
489 WMAKEENV= ${CROSSENV} \
490 INSTALL="sh ${.CURDIR}/tools/install.sh" \
494 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
496 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
499 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
500 CPP="${XCPP} ${XCFLAGS}" \
501 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
502 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
503 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
506 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
507 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
508 # directory, but the compiler will look in the right place for its
509 # tools so we don't need to tell it where to look.
510 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
513 # External compiler needs sysroot and target flags.
514 .if ${MK_CROSS_COMPILER} == "no" || \
515 (${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no")
516 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
517 BFLAGS+= -B${WORLDTMP}/usr/bin
519 .if ${TARGET} == "arm"
520 .if ${TARGET_ARCH:Marmv6*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
521 TARGET_ABI= gnueabihf
526 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
527 # GCC requires -isystem and -L when using a cross-compiler.
528 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
529 # Force using libc++ for external GCC.
530 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
531 -nostdinc++ -L${WORLDTMP}/../lib/libc++
534 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
535 XCFLAGS+= -target ${TARGET_TRIPLE}
537 XCFLAGS+= --sysroot=${WORLDTMP}
539 .endif # ${MK_CROSS_COMPILER} == "no"
545 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
546 ${TARGET_ARCH} == "powerpc64")
548 .include "Makefile.libcompat"
549 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH} == "armv6"
551 .include "Makefile.libcompat"
554 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
556 IMAKEENV= ${CROSSENV}
557 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
558 ${IMAKE_INSTALL} ${IMAKE_MTREE}
559 .if empty(.MAKEFLAGS:M-n)
560 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
561 LD_LIBRARY_PATH=${INSTALLTMP} \
562 PATH_LOCALE=${INSTALLTMP}/locale
563 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
565 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
567 .if defined(DB_FROM_SRC)
568 INSTALLFLAGS+= -N ${.CURDIR}/etc
569 MTREEFLAGS+= -N ${.CURDIR}/etc
571 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
572 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
574 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
575 IMAKE+= -DNO_ROOT METALOG=${METALOG}
576 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
579 .if defined(BUILD_PKGS)
580 INSTALLFLAGS+= -h sha256
582 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
583 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
584 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
588 KMAKEENV= ${WMAKEENV}
589 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
590 .if ${MK_META_MODE} == "yes"
591 # meta mode normally is disallowed when building from curdir==objdir, but we
592 # want to allow it for the kernel build.
593 KMAKEENV+= META_MODE="${.MAKE.MODE} curdirOk=yes"
599 # Attempt to rebuild the entire system, with reasonable chance of
600 # success, regardless of how old your existing system is.
603 .if ${.CURDIR:C/[^,]//g} != ""
604 # The m4 build of sendmail files doesn't like it if ',' is used
605 # anywhere in the path of it's files.
607 @echo "*** Error: path to source tree contains a comma ','"
612 @echo "--------------------------------------------------------------"
613 @echo ">>> Rebuilding the temporary build tree"
614 @echo "--------------------------------------------------------------"
615 .if !defined(NO_CLEAN)
617 .if defined(LIBCOMPAT)
618 rm -rf ${LIBCOMPATTMP}
621 rm -rf ${WORLDTMP}/legacy/usr/include
622 # XXX - These can depend on any header file.
623 rm -f ${OBJTREE}${.CURDIR}/lib/libsysdecode/ioctl.c
624 rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c
627 lib lib/casper usr legacy/bin legacy/usr
628 mkdir -p ${WORLDTMP}/${_dir}
630 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
631 -p ${WORLDTMP}/legacy/usr >/dev/null
632 .if ${MK_GROFF} != "no"
633 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
634 -p ${WORLDTMP}/legacy/usr >/dev/null
636 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
637 -p ${WORLDTMP}/usr >/dev/null
638 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
639 -p ${WORLDTMP}/usr/include >/dev/null
640 ln -sf ${.CURDIR}/sys ${WORLDTMP}
641 .if ${MK_DEBUG_FILES} != "no"
642 # We could instead disable debug files for these build stages
643 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
644 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
645 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
646 -p ${WORLDTMP}/usr/lib >/dev/null
648 .if defined(LIBCOMPAT)
649 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
650 -p ${WORLDTMP}/usr >/dev/null
651 .if ${MK_DEBUG_FILES} != "no"
652 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
653 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
654 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
655 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
658 .if ${MK_TESTS} != "no"
659 mkdir -p ${WORLDTMP}${TESTSBASE}
660 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
661 -p ${WORLDTMP}${TESTSBASE} >/dev/null
662 .if ${MK_DEBUG_FILES} != "no"
663 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
664 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
665 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
668 .for _mtree in ${LOCAL_MTREE}
669 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
673 @echo "--------------------------------------------------------------"
674 @echo ">>> stage 1.1: legacy release compatibility shims"
675 @echo "--------------------------------------------------------------"
676 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
679 @echo "--------------------------------------------------------------"
680 @echo ">>> stage 1.2: bootstrap tools"
681 @echo "--------------------------------------------------------------"
682 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
684 .if !defined(NO_CLEAN)
686 @echo "--------------------------------------------------------------"
687 @echo ">>> stage 2.1: cleaning up the object tree"
688 @echo "--------------------------------------------------------------"
689 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
690 .if defined(LIBCOMPAT)
691 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
696 @echo "--------------------------------------------------------------"
697 @echo ">>> stage 2.2: rebuilding the object tree"
698 @echo "--------------------------------------------------------------"
699 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
702 @echo "--------------------------------------------------------------"
703 @echo ">>> stage 2.3: build tools"
704 @echo "--------------------------------------------------------------"
705 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
708 @echo "--------------------------------------------------------------"
709 @echo ">>> stage 3: cross tools"
710 @echo "--------------------------------------------------------------"
711 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
712 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
715 @echo "--------------------------------------------------------------"
716 @echo ">>> stage 4.1: building includes"
717 @echo "--------------------------------------------------------------"
718 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
719 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
720 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
721 MK_INCLUDES=yes includes
722 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
723 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
727 @echo "--------------------------------------------------------------"
728 @echo ">>> stage 4.2: building libraries"
729 @echo "--------------------------------------------------------------"
730 ${_+_}cd ${.CURDIR}; \
731 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
732 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
735 @echo "--------------------------------------------------------------"
736 @echo ">>> stage 4.3: building everything"
737 @echo "--------------------------------------------------------------"
738 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
741 WMAKE_TGTS+= _worldtmp _legacy
742 .if empty(SUBDIR_OVERRIDE)
743 WMAKE_TGTS+= _bootstrap-tools
745 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
746 WMAKE_TGTS+= _includes _libraries
747 WMAKE_TGTS+= everything
748 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
749 WMAKE_TGTS+= build${libcompat}
752 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
753 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
755 buildworld_prologue: .PHONY
756 @echo "--------------------------------------------------------------"
757 @echo ">>> World build started on `LC_ALL=C date`"
758 @echo "--------------------------------------------------------------"
760 buildworld_epilogue: .PHONY
762 @echo "--------------------------------------------------------------"
763 @echo ">>> World build completed on `LC_ALL=C date`"
764 @echo "--------------------------------------------------------------"
767 # We need to have this as a target because the indirection between Makefile
768 # and Makefile.inc1 causes the correct PATH to be used, rather than a
769 # modification of the current environment's PATH. In addition, we need
770 # to quote multiword values.
773 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
775 .if ${.TARGETS:Mbuildenv}
776 .if ${.MAKEFLAGS:M-j}
777 .error The buildenv target is incompatible with -j
780 BUILDENV_DIR?= ${.CURDIR}
782 @echo Entering world for ${TARGET_ARCH}:${TARGET}
783 .if ${BUILDENV_SHELL:M*zsh*}
784 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
786 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
789 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
790 toolchain: ${TOOLCHAIN_TGTS} .PHONY
791 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries} .PHONY
796 # Checks to be sure system is ready for installworld/installkernel.
798 installcheck: _installcheck_world _installcheck_kernel .PHONY
799 _installcheck_world: .PHONY
800 _installcheck_kernel: .PHONY
803 # Require DESTDIR to be set if installing for a different architecture or
804 # using the user/group database in the source tree.
806 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
808 .if !make(distributeworld)
809 _installcheck_world: __installcheck_DESTDIR
810 _installcheck_kernel: __installcheck_DESTDIR
811 __installcheck_DESTDIR: .PHONY
812 .if !defined(DESTDIR) || empty(DESTDIR)
813 @echo "ERROR: Please set DESTDIR!"; \
819 .if !defined(DB_FROM_SRC)
821 # Check for missing UIDs/GIDs.
823 CHECK_UIDS= auditdistd
825 .if ${MK_SENDMAIL} != "no"
831 CHECK_GIDS+= proxy authpf
833 .if ${MK_UNBOUND} != "no"
837 _installcheck_world: __installcheck_UGID
838 __installcheck_UGID: .PHONY
839 .for uid in ${CHECK_UIDS}
840 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
841 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
845 .for gid in ${CHECK_GIDS}
846 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
847 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
854 # Required install tools to be saved in a scratch dir for safety.
856 .if ${MK_ZONEINFO} != "no"
857 _zoneinfo= zic tzsetup
860 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
861 date echo egrep find grep id install ${_install-info} \
862 ln make mkdir mtree mv pwd_mkdb \
863 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
866 # Needed for share/man
867 .if ${MK_MAN} != "no"
874 # Distributes everything compiled by a `buildworld'.
878 # Installs everything compiled by a 'buildworld'.
881 # Non-base distributions produced by the base system
882 EXTRA_DISTRIBUTIONS= doc
883 .if defined(LIBCOMPAT)
884 EXTRA_DISTRIBUTIONS+= lib${libcompat}
886 .if ${MK_TESTS} != "no"
887 EXTRA_DISTRIBUTIONS+= tests
891 .if ${MK_DEBUG_FILES} != "no"
892 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
895 MTREE_MAGIC?= mtree 2.0
897 distributeworld installworld stageworld: _installcheck_world .PHONY
898 mkdir -p ${INSTALLTMP}
899 progs=$$(for prog in ${ITOOLS}; do \
900 if progpath=`which $$prog`; then \
903 echo "Required tool $$prog not found in PATH." >&2; \
907 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
908 while read line; do \
910 if [ "$$2 $$3" != "not found" ]; then \
913 echo "Required library $$1 not found." >&2; \
917 cp $$libs $$progs ${INSTALLTMP}
918 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
920 -mkdir -p ${METALOG:H}
921 echo "#${MTREE_MAGIC}" > ${METALOG}
923 .if make(distributeworld)
924 .for dist in ${EXTRA_DISTRIBUTIONS}
925 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
926 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
927 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
928 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
929 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
930 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
931 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
932 .if ${MK_DEBUG_FILES} != "no"
933 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
934 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
936 .if defined(LIBCOMPAT)
937 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
938 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
939 .if ${MK_DEBUG_FILES} != "no"
940 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
941 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
944 .if ${MK_TESTS} != "no" && ${dist} == "tests"
945 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
946 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
947 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
948 .if ${MK_DEBUG_FILES} != "no"
949 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
950 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
954 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
955 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
956 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
957 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
958 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
959 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
960 .if defined(LIBCOMPAT)
961 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
962 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
966 -mkdir ${DESTDIR}/${DISTDIR}/base
967 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
968 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
969 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
970 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
972 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
973 ${IMAKEENV} rm -rf ${INSTALLTMP}
974 .if make(distributeworld)
975 .for dist in ${EXTRA_DISTRIBUTIONS}
976 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
979 .for dist in base ${EXTRA_DISTRIBUTIONS}
980 @# For each file that exists in this dist, print the corresponding
981 @# line from the METALOG. This relies on the fact that
982 @# a line containing only the filename will sort immediately before
983 @# the relevant mtree line.
984 cd ${DESTDIR}/${DISTDIR}; \
985 find ./${dist} | sort -u ${METALOG} - | \
986 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
987 ${DESTDIR}/${DISTDIR}/${dist}.meta
989 .for dist in ${DEBUG_DISTRIBUTIONS}
990 @# For each file that exists in this dist, print the corresponding
991 @# line from the METALOG. This relies on the fact that
992 @# a line containing only the filename will sort immediately before
993 @# the relevant mtree line.
994 cd ${DESTDIR}/${DISTDIR}; \
995 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
996 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
997 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1002 packageworld: .PHONY
1003 .for dist in base ${EXTRA_DISTRIBUTIONS}
1004 .if defined(NO_ROOT)
1005 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1006 tar cvf - --exclude usr/lib/debug \
1007 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1008 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1010 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1011 tar cvf - --exclude usr/lib/debug . | \
1012 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1016 .for dist in ${DEBUG_DISTRIBUTIONS}
1017 . if defined(NO_ROOT)
1018 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1019 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1020 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1022 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1023 tar cvLf - usr/lib/debug | \
1024 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1031 # If you have a build server, you can NFS mount the source and obj directories
1032 # and do a 'make reinstall' on the *client* to install new binaries from the
1033 # most recent server build.
1035 restage reinstall: .MAKE .PHONY
1036 @echo "--------------------------------------------------------------"
1037 @echo ">>> Making hierarchy"
1038 @echo "--------------------------------------------------------------"
1039 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1040 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1042 @echo "--------------------------------------------------------------"
1043 @echo ">>> Making distribution"
1044 @echo "--------------------------------------------------------------"
1045 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1046 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
1049 @echo "--------------------------------------------------------------"
1050 @echo ">>> Installing everything"
1051 @echo "--------------------------------------------------------------"
1052 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1053 .if defined(LIBCOMPAT)
1054 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1057 redistribute: .MAKE .PHONY
1058 @echo "--------------------------------------------------------------"
1059 @echo ">>> Distributing everything"
1060 @echo "--------------------------------------------------------------"
1061 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1062 .if defined(LIBCOMPAT)
1063 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1064 DISTRIBUTION=lib${libcompat}
1067 distrib-dirs distribution: .MAKE .PHONY
1068 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1069 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1070 .if make(distribution)
1071 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1072 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1073 METALOG=${METALOG} MK_TESTS=no installconfig
1077 # buildkernel and installkernel
1079 # Which kernels to build and/or install is specified by setting
1080 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1081 # Only the existing (depending TARGET) config files are used
1082 # for building kernels and only the first of these is designated
1083 # as the one being installed.
1085 # Note that we have to use TARGET instead of TARGET_ARCH when
1086 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1087 # be set to cross-build, we have to make sure TARGET is set
1090 .if defined(KERNFAST)
1094 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1095 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1096 KERNCONF=${KERNFAST}
1099 .if ${TARGET_ARCH} == "powerpc64"
1100 KERNCONF?= GENERIC64
1104 INSTKERNNAME?= kernel
1106 KERNSRCDIR?= ${.CURDIR}/sys
1107 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1108 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1109 KERNCONFDIR?= ${KRNLCONFDIR}
1113 .if defined(NO_INSTALLKERNEL)
1114 # All of the BUILDKERNELS loops start at index 1.
1115 BUILDKERNELS+= dummy
1117 .for _kernel in ${KERNCONF}
1118 .if exists(${KERNCONFDIR}/${_kernel})
1119 BUILDKERNELS+= ${_kernel}
1120 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1121 INSTALLKERNEL= ${_kernel}
1126 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1131 # Builds all kernels defined by BUILDKERNELS.
1133 buildkernel: .MAKE .PHONY
1134 .if empty(BUILDKERNELS:Ndummy)
1135 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1139 .for _kernel in ${BUILDKERNELS:Ndummy}
1140 @echo "--------------------------------------------------------------"
1141 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1142 @echo "--------------------------------------------------------------"
1143 @echo "===> ${_kernel}"
1144 mkdir -p ${KRNLOBJDIR}
1145 .if !defined(NO_KERNELCONFIG)
1147 @echo "--------------------------------------------------------------"
1148 @echo ">>> stage 1: configuring the kernel"
1149 @echo "--------------------------------------------------------------"
1150 cd ${KRNLCONFDIR}; \
1152 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1153 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1155 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1157 @echo "--------------------------------------------------------------"
1158 @echo ">>> stage 2.1: cleaning up the object tree"
1159 @echo "--------------------------------------------------------------"
1160 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1162 .if !defined(NO_KERNELOBJ)
1164 @echo "--------------------------------------------------------------"
1165 @echo ">>> stage 2.2: rebuilding the object tree"
1166 @echo "--------------------------------------------------------------"
1167 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1170 @echo "--------------------------------------------------------------"
1171 @echo ">>> stage 2.3: build tools"
1172 @echo "--------------------------------------------------------------"
1173 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1175 @echo "--------------------------------------------------------------"
1176 @echo ">>> stage 3.1: building everything"
1177 @echo "--------------------------------------------------------------"
1178 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1179 @echo "--------------------------------------------------------------"
1180 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1181 @echo "--------------------------------------------------------------"
1184 NO_INSTALLEXTRAKERNELS?= yes
1187 # installkernel, etc.
1189 # Install the kernel defined by INSTALLKERNEL
1191 installkernel installkernel.debug \
1192 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1193 .if !defined(NO_INSTALLKERNEL)
1194 .if empty(INSTALLKERNEL)
1195 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1198 @echo "--------------------------------------------------------------"
1199 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1200 @echo "--------------------------------------------------------------"
1201 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1202 ${CROSSENV} PATH=${TMPPATH} \
1203 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1205 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1206 .for _kernel in ${BUILDKERNELS:[2..-1]}
1207 @echo "--------------------------------------------------------------"
1208 @echo ">>> Installing kernel ${_kernel}"
1209 @echo "--------------------------------------------------------------"
1210 cd ${KRNLOBJDIR}/${_kernel}; \
1211 ${CROSSENV} PATH=${TMPPATH} \
1212 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1216 distributekernel distributekernel.debug: .PHONY
1217 .if !defined(NO_INSTALLKERNEL)
1218 .if empty(INSTALLKERNEL)
1219 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1222 mkdir -p ${DESTDIR}/${DISTDIR}
1223 .if defined(NO_ROOT)
1224 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1226 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1227 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1228 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1229 DESTDIR=${INSTALL_DDIR}/kernel \
1230 ${.TARGET:S/distributekernel/install/}
1231 .if defined(NO_ROOT)
1232 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1233 ${DESTDIR}/${DISTDIR}/kernel.meta
1236 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1237 .for _kernel in ${BUILDKERNELS:[2..-1]}
1238 .if defined(NO_ROOT)
1239 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1241 cd ${KRNLOBJDIR}/${_kernel}; \
1242 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1243 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1244 KERNEL=${INSTKERNNAME}.${_kernel} \
1245 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1246 ${.TARGET:S/distributekernel/install/}
1247 .if defined(NO_ROOT)
1248 @sed -e "s|^./kernel.${_kernel}|.|" \
1249 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1250 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1255 packagekernel: .PHONY
1256 .if defined(NO_ROOT)
1257 .if !defined(NO_INSTALLKERNEL)
1258 cd ${DESTDIR}/${DISTDIR}/kernel; \
1259 tar cvf - --exclude '*.debug' \
1260 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1261 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1263 cd ${DESTDIR}/${DISTDIR}/kernel; \
1264 tar cvf - --include '*/*/*.debug' \
1265 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1266 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1267 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1268 .for _kernel in ${BUILDKERNELS:[2..-1]}
1269 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1270 tar cvf - --exclude '*.debug' \
1271 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1272 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1273 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1274 tar cvf - --include '*/*/*.debug' \
1275 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1276 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1280 .if !defined(NO_INSTALLKERNEL)
1281 cd ${DESTDIR}/${DISTDIR}/kernel; \
1282 tar cvf - --exclude '*.debug' . | \
1283 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1285 cd ${DESTDIR}/${DISTDIR}/kernel; \
1286 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1287 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1288 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1289 .for _kernel in ${BUILDKERNELS:[2..-1]}
1290 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1291 tar cvf - --exclude '*.debug' . | \
1292 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1293 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1294 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1295 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1301 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1303 PORTSDIR?= /usr/ports
1304 WSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/worldstage
1305 KSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/kernelstage
1306 REPODIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/repo
1307 PKGSIGNKEY?= # empty
1309 .ORDER: stage-packages create-packages
1310 .ORDER: create-packages create-world-packages
1311 .ORDER: create-packages create-kernel-packages
1312 .ORDER: create-packages sign-packages
1314 _pkgbootstrap: .PHONY
1315 .if !exists(${LOCALBASE}/sbin/pkg)
1316 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1320 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1323 rm -rf /tmp/ports.${TARGET} || :
1324 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
1325 PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} WSTAGEDIR=${WSTAGEDIR} \
1326 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1328 real-packages: stage-packages create-packages sign-packages .PHONY
1330 stage-packages: .PHONY
1331 @mkdir -p ${REPODIR} ${WSTAGEDIR} ${KSTAGEDIR}
1332 ${_+_}@cd ${.CURDIR}; \
1333 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT -B stageworld ; \
1334 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT -B stagekernel
1336 create-packages: _pkgbootstrap .PHONY
1337 @mkdir -p ${REPODIR}
1338 ${_+_}@cd ${.CURDIR}; \
1339 ${MAKE} DESTDIR=${WSTAGEDIR} \
1340 PKG_VERSION=${PKG_VERSION} create-world-packages ; \
1341 ${MAKE} DESTDIR=${KSTAGEDIR} \
1342 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1343 create-kernel-packages
1345 create-world-packages: _pkgbootstrap .PHONY
1346 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1347 @cd ${WSTAGEDIR} ; \
1348 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1349 ${WSTAGEDIR}/METALOG
1350 @for plist in ${WSTAGEDIR}/*.plist; do \
1351 plist=$${plist##*/} ; \
1352 pkgname=$${plist%.plist} ; \
1353 sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \
1354 -s ${SRCDIR} -u ${WSTAGEDIR}/$${pkgname}.ucl ; \
1356 @for plist in ${WSTAGEDIR}/*.plist; do \
1357 plist=$${plist##*/} ; \
1358 pkgname=$${plist%.plist} ; \
1360 /^name/ { printf("===> Creating %s-", $$2); next } \
1361 /^version/ { print $$2; next } \
1362 ' ${WSTAGEDIR}/$${pkgname}.ucl ; \
1363 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1364 create -M ${WSTAGEDIR}/$${pkgname}.ucl \
1365 -p ${WSTAGEDIR}/$${pkgname}.plist \
1367 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} ; \
1370 create-kernel-packages: _pkgbootstrap .PHONY
1371 .if exists(${KSTAGEDIR}/kernel.meta)
1372 .for flavor in "" -debug
1373 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1374 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1375 -v kernel=yes -v _kernconf=${INSTALLKERNEL} \
1376 ${KSTAGEDIR}/kernel.meta ; \
1377 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1378 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1379 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1380 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1381 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1382 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1383 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1384 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1385 ${SRCDIR}/release/packages/kernel.ucl \
1386 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1388 /name/ { printf("===> Creating %s-", $$2); next } \
1389 /version/ {print $$2; next } ' \
1390 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1391 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1392 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1393 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1394 -r ${KSTAGEDIR}/${DISTDIR} \
1395 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1398 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1399 .for _kernel in ${BUILDKERNELS:[2..-1]}
1400 .if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1401 .for flavor in "" -debug
1402 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1403 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1404 -v kernel=yes -v _kernconf=${_kernel} \
1405 ${KSTAGEDIR}/kernel.${_kernel}.meta ; \
1406 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1407 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1408 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1409 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1410 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1411 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1412 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1413 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1414 ${SRCDIR}/release/packages/kernel.ucl \
1415 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1417 /name/ { printf("===> Creating %s-", $$2); next } \
1418 /version/ {print $$2; next } ' \
1419 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1420 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1421 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1422 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1423 -r ${KSTAGEDIR}/kernel.${_kernel} \
1424 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1430 sign-packages: _pkgbootstrap .PHONY
1431 @[ -L "${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1432 unlink ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1433 pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1434 -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1435 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1437 ln -s ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1438 ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest
1444 # Run test suite on installed world.
1447 @if [ ! -x ${LOCALBASE}/bin/kyua ]; then \
1448 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1451 ${_+_}${LOCALBASE}/bin/kyua test -k ${TESTSBASE}/Kyuafile
1457 # Build the API documentation with doxygen
1460 @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \
1461 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1464 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1469 # Update the source tree(s), by running svn/svnup to update to the
1473 .if defined(SVN_UPDATE)
1474 @echo "--------------------------------------------------------------"
1475 @echo ">>> Updating ${.CURDIR} using Subversion"
1476 @echo "--------------------------------------------------------------"
1477 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1481 # ------------------------------------------------------------------------
1483 # From here onwards are utility targets used by the 'make world' and
1484 # related targets. If your 'world' breaks, you may like to try to fix
1485 # the problem and manually run the following targets to attempt to
1486 # complete the build. Beware, this is *not* guaranteed to work, you
1487 # need to have a pretty good grip on the current state of the system
1488 # to attempt to manually finish it. If in doubt, 'make world' again.
1492 # legacy: Build compatibility shims for the next three targets. This is a
1493 # minimal set of tools and shims necessary to compensate for older systems
1494 # which don't have the APIs required by the targets built in bootstrap-tools,
1495 # build-tools or cross-tools.
1498 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1499 # r296685 fix cross-endian objcopy
1500 .if ${BOOTSTRAPPING} < 1100102
1501 _elftoolchain_libs= lib/libelf lib/libdwarf
1505 .if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
1506 @echo "ERROR: Source upgrades from versions prior to 8.0 are not supported."; \
1509 .for _tool in tools/build ${_elftoolchain_libs}
1510 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1511 cd ${.CURDIR}/${_tool}; \
1512 ${MAKE} DIRPRFX=${_tool}/ obj; \
1513 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1514 ${MAKE} DIRPRFX=${_tool}/ all; \
1515 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1519 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1520 # are built to build other binaries in the system. However, the focus of these
1521 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1522 # libraries, augmented by -legacy.
1524 _bt= _bootstrap-tools
1526 .if ${MK_GAMES} != "no"
1527 _strfile= usr.bin/fortune/strfile
1530 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1531 _gperf= gnu/usr.bin/gperf
1534 .if ${MK_GROFF} != "no"
1535 _groff= gnu/usr.bin/groff \
1539 .if ${MK_VT} != "no"
1540 _vtfontcvt= usr.bin/vtfontcvt
1543 .if ${BOOTSTRAPPING} < 900002
1547 .if ${BOOTSTRAPPING} < 1000033
1548 _libopenbsd= lib/libopenbsd
1552 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1553 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1556 .if ${BOOTSTRAPPING} < 1000026
1557 _nmtree= lib/libnetbsd \
1560 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1563 .if ${BOOTSTRAPPING} < 1000027
1567 # r264059 support for status=
1568 .if ${BOOTSTRAPPING} < 1100017
1572 # r277259 crunchide: Correct 64-bit section header offset
1573 # r281674 crunchide: always include both 32- and 64-bit ELF support
1574 # r285986 crunchen: use STRIPBIN rather than STRIP
1575 .if ${BOOTSTRAPPING} < 1100078
1576 _crunch= usr.sbin/crunch
1579 .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
1583 # r296926 -P keymap search path, MFC to stable/10 in r298297
1584 .if ${BOOTSTRAPPING} < 1003501 || \
1585 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
1586 _kbdcontrol= usr.sbin/kbdcontrol
1592 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1594 .if ${MK_BSNMP} != "no"
1595 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1598 # We need to build tblgen when we're building clang either as
1599 # the bootstrap compiler, or as the part of the normal build.
1600 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no"
1602 lib/clang/libllvmsupport \
1603 lib/clang/libllvmtablegen \
1604 usr.bin/clang/llvm-tblgen \
1605 usr.bin/clang/clang-tblgen
1607 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1608 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
1611 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1614 .if ${MK_GPL_DTC} != "no"
1615 _dtc= gnu/usr.bin/dtc
1618 .if ${MK_KERBEROS} != "no"
1619 _kerberos5_bootstrap_tools= \
1620 kerberos5/tools/make-roken \
1621 kerberos5/lib/libroken \
1622 kerberos5/lib/libvers \
1623 kerberos5/tools/asn1_compile \
1624 kerberos5/tools/slc \
1627 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1630 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
1631 .if ${MK_MANDOCDB} != "no" && ${BOOTSTRAPPING} < 1100075
1632 _libopenbsd?= lib/libopenbsd
1633 _makewhatis= lib/libsqlite3 \
1635 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
1638 bootstrap-tools: .PHONY
1640 # Please document (add comment) why something is in 'bootstrap-tools'.
1641 # Try to bound the building of the bootstrap-tool to just the
1642 # FreeBSD versions that need the tool built at this stage of the build.
1645 ${_kerberos5_bootstrap_tools} \
1669 ${_bt}-${_tool}: .PHONY .MAKE
1670 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1671 cd ${.CURDIR}/${_tool}; \
1672 ${MAKE} DIRPRFX=${_tool}/ obj; \
1673 ${MAKE} DIRPRFX=${_tool}/ all; \
1674 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1676 bootstrap-tools: ${_bt}-${_tool}
1680 # build-tools: Build special purpose build tools
1682 .if !defined(NO_SHARE)
1683 _share= share/syscons/scrnmaps
1686 .if ${MK_GCC} != "no"
1687 _gcc_tools= gnu/usr.bin/cc/cc_tools
1690 .if ${MK_RESCUE} != "no"
1691 # rescue includes programs that have build-tools targets
1692 _rescue=rescue/rescue
1698 ${LOCAL_TOOL_DIRS} \
1699 lib/ncurses/ncurses \
1700 lib/ncurses/ncursesw \
1705 usr.bin/mkesdb_static \
1706 usr.bin/mkcsmapper_static \
1708 build-tools_${_tool}: .PHONY
1709 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1710 cd ${.CURDIR}/${_tool}; \
1711 ${MAKE} DIRPRFX=${_tool}/ obj; \
1712 ${MAKE} DIRPRFX=${_tool}/ build-tools
1713 build-tools: build-tools_${_tool}
1717 build-tools_${_tool}: .PHONY
1718 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \
1719 cd ${.CURDIR}/${_tool}; \
1720 ${MAKE} DIRPRFX=${_tool}/ obj; \
1721 ${MAKE} DIRPRFX=${_tool}/ all
1722 build-tools: build-tools_${_tool}
1726 # kernel-tools: Build kernel-building tools
1728 kernel-tools: .PHONY
1729 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1730 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1731 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1734 # cross-tools: All the tools needed to build the rest of the system after
1735 # we get done with the earlier stages. It is the last set of tools needed
1736 # to begin building the target binaries.
1738 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1739 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1740 _btxld= usr.sbin/btxld
1744 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1745 # resulting from missing bug fixes or ELF Toolchain updates.
1746 .if ${MK_CDDL} != "no"
1747 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1748 cddl/usr.bin/ctfmerge
1751 # If we're given an XAS, don't build binutils.
1752 .if ${XAS:M/*} == ""
1753 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1754 _binutils= gnu/usr.bin/binutils
1756 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1757 _elftctools= lib/libelftc \
1763 # These are not required by the build, but can be useful for developers who
1764 # cross-build on a FreeBSD 10 host:
1765 _elftctools+= usr.bin/addr2line
1767 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1768 # If cross-building with an external binutils we still need to build strip for
1769 # the target (for at least crunchide).
1770 _elftctools= lib/libelftc \
1775 .if ${MK_CROSS_COMPILER} != "no"
1776 .if ${MK_CLANG_BOOTSTRAP} != "no"
1777 _clang= usr.bin/clang
1778 _clang_libs= lib/clang
1780 .if ${MK_GCC_BOOTSTRAP} != "no"
1784 .if ${MK_USB} != "no"
1785 _usb_tools= sys/boot/usb/tools
1788 cross-tools: .MAKE .PHONY
1799 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1800 cd ${.CURDIR}/${_tool}; \
1801 ${MAKE} DIRPRFX=${_tool}/ obj; \
1802 ${MAKE} DIRPRFX=${_tool}/ all; \
1803 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1806 NXBDESTDIR= ${OBJTREE}/nxb-bin
1807 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1808 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1809 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1810 NXBMAKE= ${NXBENV} ${MAKE} \
1811 LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \
1812 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1813 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1814 MK_GDB=no MK_TESTS=no \
1816 MK_HTML=no NO_LINT=yes MK_MAN=no \
1817 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1818 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1819 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1820 MK_LLDB=no MK_DEBUG_FILES=no
1822 # native-xtools is the current target for qemu-user cross builds of ports
1823 # via poudriere and the imgact_binmisc kernel module.
1824 # For non-clang enabled targets that are still using the in tree gcc
1825 # we must build a gperf binary for one instance of its Makefiles. On
1826 # clang-enabled systems, the gperf binary is obsolete.
1827 native-xtools: .PHONY
1828 .if ${MK_GCC_BOOTSTRAP} != "no"
1829 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1830 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \
1831 cd ${.CURDIR}/${_gperf}; \
1832 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1833 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1834 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1836 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1837 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1838 -p ${NXBDESTDIR}/usr >/dev/null
1839 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1840 -p ${NXBDESTDIR}/usr/include >/dev/null
1841 .if ${MK_DEBUG_FILES} != "no"
1842 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1843 -p ${NXBDESTDIR}/usr/lib >/dev/null
1904 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1905 cd ${.CURDIR}/${_tool}; \
1906 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
1907 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
1908 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
1912 # hierarchy - ensure that all the needed directories are present
1914 hierarchy hier: .MAKE .PHONY
1915 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
1918 # libraries - build all libraries, and install them under ${DESTDIR}.
1920 # The list of libraries with dependents (${_prebuild_libs}) and their
1921 # interdependencies (__L) are built automatically by the
1922 # ${.CURDIR}/tools/make_libdeps.sh script.
1924 libraries: .MAKE .PHONY
1925 ${_+_}cd ${.CURDIR}; \
1926 ${MAKE} -f Makefile.inc1 _prereq_libs; \
1927 ${MAKE} -f Makefile.inc1 _startup_libs; \
1928 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
1929 ${MAKE} -f Makefile.inc1 _generic_libs
1932 # static libgcc.a prerequisite for shared libc
1934 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
1936 # These dependencies are not automatically generated:
1938 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
1939 # all shared libraries for ELF.
1941 _startup_libs= gnu/lib/csu
1942 _startup_libs+= lib/csu
1943 _startup_libs+= gnu/lib/libgcc
1944 _startup_libs+= lib/libcompiler_rt
1945 _startup_libs+= lib/libc
1946 _startup_libs+= lib/libc_nonshared
1947 .if ${MK_LIBCPLUSPLUS} != "no"
1948 _startup_libs+= lib/libcxxrt
1951 gnu/lib/libgcc__L: lib/libc__L
1952 gnu/lib/libgcc__L: lib/libc_nonshared__L
1953 .if ${MK_LIBCPLUSPLUS} != "no"
1954 lib/libcxxrt__L: gnu/lib/libgcc__L
1957 _prebuild_libs= ${_kerberos5_lib_libasn1} \
1958 ${_kerberos5_lib_libhdb} \
1959 ${_kerberos5_lib_libheimbase} \
1960 ${_kerberos5_lib_libheimntlm} \
1962 ${_kerberos5_lib_libheimipcc} \
1963 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
1964 ${_kerberos5_lib_libroken} \
1965 ${_kerberos5_lib_libwind} \
1966 lib/libbz2 ${_libcom_err} lib/libcrypt \
1967 lib/libelf lib/libexpat \
1970 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
1972 lib/ncurses/ncurses lib/ncurses/ncursesw \
1973 lib/libopie lib/libpam/libpam ${_lib_libthr} \
1974 ${_lib_libradius} lib/libsbuf lib/libtacplus \
1976 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
1977 ${_cddl_lib_libuutil} \
1978 ${_cddl_lib_libavl} \
1979 ${_cddl_lib_libzfs_core} \
1980 ${_cddl_lib_libctf} \
1981 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
1982 ${_secure_lib_libcrypto} ${_lib_libldns} \
1983 ${_secure_lib_libssh} ${_secure_lib_libssl} \
1986 .if ${MK_GNUCXX} != "no"
1987 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
1988 gnu/lib/libstdc++__L: lib/msun__L
1989 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
1992 .if ${MK_LIBCPLUSPLUS} != "no"
1993 _prebuild_libs+= lib/libc++
1996 lib/libgeom__L: lib/libexpat__L
1997 lib/libkvm__L: lib/libelf__L
1999 .if ${MK_LIBTHR} != "no"
2000 _lib_libthr= lib/libthr
2003 .if ${MK_RADIUS_SUPPORT} != "no"
2004 _lib_libradius= lib/libradius
2007 .if ${MK_OFED} != "no"
2008 _ofed_lib= contrib/ofed/usr.lib
2009 _prebuild_libs+= contrib/ofed/usr.lib/libosmcomp
2010 _prebuild_libs+= contrib/ofed/usr.lib/libopensm
2011 _prebuild_libs+= contrib/ofed/usr.lib/libibcommon
2012 _prebuild_libs+= contrib/ofed/usr.lib/libibverbs
2013 _prebuild_libs+= contrib/ofed/usr.lib/libibumad
2015 contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
2016 contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
2017 contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
2020 .if ${MK_CASPER} != "no"
2021 _lib_casper= lib/libcasper
2024 lib/libpjdlog__L: lib/libutil__L
2025 lib/libcasper__L: lib/libnv__L
2026 lib/liblzma__L: lib/libthr__L
2028 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
2029 .for _DIR in ${LOCAL_LIB_DIRS}
2030 .if exists(${.CURDIR}/${_DIR}/Makefile) && empty(_generic_libs:M${_DIR})
2031 _generic_libs+= ${_DIR}
2035 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2037 .if ${MK_CDDL} != "no"
2038 _cddl_lib_libumem= cddl/lib/libumem
2039 _cddl_lib_libnvpair= cddl/lib/libnvpair
2040 _cddl_lib_libavl= cddl/lib/libavl
2041 _cddl_lib_libuutil= cddl/lib/libuutil
2042 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2043 _cddl_lib_libctf= cddl/lib/libctf
2045 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2046 cddl/lib/libzfs__L: lib/libgeom__L
2047 cddl/lib/libctf__L: lib/libz__L
2049 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
2050 # on select architectures though (see cddl/lib/Makefile)
2051 .if ${MACHINE_CPUARCH} != "sparc64"
2052 _prebuild_libs+= lib/libproc lib/librtld_db
2055 .if ${MK_CRYPT} != "no"
2056 .if ${MK_OPENSSL} != "no"
2057 _secure_lib_libcrypto= secure/lib/libcrypto
2058 _secure_lib_libssl= secure/lib/libssl
2059 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2060 .if ${MK_LDNS} != "no"
2061 _lib_libldns= lib/libldns
2062 lib/libldns__L: secure/lib/libcrypto__L
2064 .if ${MK_OPENSSH} != "no"
2065 _secure_lib_libssh= secure/lib/libssh
2066 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2067 .if ${MK_LDNS} != "no"
2068 secure/lib/libssh__L: lib/libldns__L
2070 .if ${MK_KERBEROS_SUPPORT} != "no"
2071 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2072 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2073 lib/libmd__L kerberos5/lib/libroken__L
2077 _secure_lib= secure/lib
2080 .if ${MK_KERBEROS} != "no"
2081 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2082 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2083 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2084 kerberos5/lib/libwind__L lib/libsqlite3__L
2085 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2086 kerberos5/lib/libroken__L lib/libcom_err__L
2087 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2088 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2089 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2090 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2091 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2092 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2093 kerberos5/lib/libroken__L: lib/libcrypt__L
2094 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2095 kerberos5/lib/libheimbase__L: lib/libthr__L
2096 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2099 lib/libsqlite3__L: lib/libthr__L
2101 .if ${MK_GSSAPI} != "no"
2102 _lib_libgssapi= lib/libgssapi
2105 .if ${MK_KERBEROS} != "no"
2106 _kerberos5_lib= kerberos5/lib
2107 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2108 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2109 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2110 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2111 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2112 _kerberos5_lib_libroken= kerberos5/lib/libroken
2113 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2114 _libsqlite3= lib/libsqlite3
2115 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2116 _kerberos5_lib_libwind= kerberos5/lib/libwind
2117 _libcom_err= lib/libcom_err
2120 .if ${MK_NIS} != "no"
2121 _lib_libypclnt= lib/libypclnt
2124 .if ${MK_OPENSSL} == "no"
2125 lib/libradius__L: lib/libmd__L
2129 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2130 .if ${MK_CXX} != "no"
2131 .if ${MK_LIBCPLUSPLUS} != "no"
2132 lib/libproc__L: lib/libcxxrt__L
2133 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2134 lib/libproc__L: gnu/lib/libsupc++__L
2138 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2140 .for _lib in ${_prereq_libs}
2141 ${_lib}__PL: .PHONY .MAKE
2142 .if exists(${.CURDIR}/${_lib})
2143 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2144 cd ${.CURDIR}/${_lib}; \
2145 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2146 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2147 DIRPRFX=${_lib}/ all; \
2148 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2149 DIRPRFX=${_lib}/ install
2153 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
2154 ${_lib}__L: .PHONY .MAKE
2155 .if exists(${.CURDIR}/${_lib})
2156 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2157 cd ${.CURDIR}/${_lib}; \
2158 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2159 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2160 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2164 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2165 _startup_libs: ${_startup_libs:S/$/__L/}
2166 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2167 _generic_libs: ${_generic_libs:S/$/__L/}
2169 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2170 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2171 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2172 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2173 # parallel. This is safe for the world stage of buildworld though since it has
2174 # already built libraries in a proper order and installed includes into
2175 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2176 # avoid trashing a system if it crashes mid-install.
2177 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2181 .include <bsd.subdir.mk>
2183 .if make(check-old) || make(check-old-dirs) || \
2184 make(check-old-files) || make(check-old-libs) || \
2185 make(delete-old) || make(delete-old-dirs) || \
2186 make(delete-old-files) || make(delete-old-libs)
2189 # check for / delete old files section
2192 .include "ObsoleteFiles.inc"
2194 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2195 else you can not start such an application. Consult UPDATING for more \
2196 information regarding how to cope with the removal/revision bump of a \
2199 .if !defined(BATCH_DELETE_OLD_FILES)
2205 delete-old-files: .PHONY
2206 @echo ">>> Removing old files (only deletes safe to delete libs)"
2207 # Ask for every old file if the user really wants to remove it.
2208 # It's annoying, but better safe than sorry.
2209 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2210 # argument list will get too long. Using .for/.endfor make "loops" will make
2211 # the Makefile parser segfault.
2214 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2215 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2216 while read file; do \
2217 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2218 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2219 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2221 for ext in debug symbols; do \
2222 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2223 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2224 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2229 # Remove catpages without corresponding manpages.
2231 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2232 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2233 while read catpage; do \
2235 if [ ! -e "$${manpage}" ]; then \
2236 rm ${RM_I} $${catpage} <&3; \
2239 @echo ">>> Old files removed"
2241 check-old-files: .PHONY
2242 @echo ">>> Checking for old files"
2244 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2245 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2246 while read file; do \
2247 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2248 echo "${DESTDIR}/$${file}"; \
2250 for ext in debug symbols; do \
2251 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2252 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2256 # Check for catpages without corresponding manpages.
2257 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2258 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2259 while read catpage; do \
2261 if [ ! -e "$${manpage}" ]; then \
2266 delete-old-libs: .PHONY
2267 @echo ">>> Removing old libraries"
2268 @echo "${OLD_LIBS_MESSAGE}" | fmt
2271 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2272 -V OLD_LIBS | xargs -n1 | \
2273 while read file; do \
2274 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2275 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2276 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2278 for ext in debug symbols; do \
2279 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2280 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2281 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2286 @echo ">>> Old libraries removed"
2288 check-old-libs: .PHONY
2289 @echo ">>> Checking for old libraries"
2291 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2292 -V OLD_LIBS | xargs -n1 | \
2293 while read file; do \
2294 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2295 echo "${DESTDIR}/$${file}"; \
2297 for ext in debug symbols; do \
2298 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2299 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2304 delete-old-dirs: .PHONY
2305 @echo ">>> Removing old directories"
2307 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2308 -V OLD_DIRS | xargs -n1 | sort -r | \
2309 while read dir; do \
2310 if [ -d "${DESTDIR}/$${dir}" ]; then \
2311 rmdir -v "${DESTDIR}/$${dir}" || true; \
2312 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2313 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2316 @echo ">>> Old directories removed"
2318 check-old-dirs: .PHONY
2319 @echo ">>> Checking for old directories"
2321 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2322 -V OLD_DIRS | xargs -n1 | \
2323 while read dir; do \
2324 if [ -d "${DESTDIR}/$${dir}" ]; then \
2325 echo "${DESTDIR}/$${dir}"; \
2326 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2327 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2331 delete-old: delete-old-files delete-old-dirs .PHONY
2332 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2334 check-old: check-old-files check-old-libs check-old-dirs .PHONY
2335 @echo "To remove old files and directories run '${MAKE} delete-old'."
2336 @echo "To remove old libraries run '${MAKE} delete-old-libs'."
2341 # showconfig - show build configuration.
2344 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2345 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2347 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2348 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2350 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2351 .if exists(${KERNCONFDIR}/${KERNCONF})
2352 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2353 '${KERNCONFDIR}/${KERNCONF}' ; echo
2359 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2360 DTBOUTPUTPATH= ${.CURDIR}
2364 # Build 'standalone' Device Tree Blob
2367 @PATH=${TMPPATH} MACHINE=${TARGET} \
2368 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2369 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2374 # In the following, the first 'rm' in a series will usually remove all
2375 # files and directories. If it does not, then there are probably some
2376 # files with file flags set, so this unsets them and tries the 'rm' a
2377 # second time. There are situations where this target will be cleaning
2378 # some directories via more than one method, but that duplication is
2379 # needed to correctly handle all the possible situations. Removing all
2380 # files without file flags set in the first 'rm' instance saves time,
2381 # because 'chflags' will need to operate on fewer files afterwards.
2383 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2384 # created by bsd.obj.mk, except that we don't want to .include that file
2387 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2389 .if exists(${BW_CANONICALOBJDIR}/)
2390 -rm -rf ${BW_CANONICALOBJDIR}/*
2391 -chflags -R 0 ${BW_CANONICALOBJDIR}
2392 rm -rf ${BW_CANONICALOBJDIR}/*
2394 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2395 # To be safe in this case, fall back to a 'make cleandir'
2396 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2399 .if defined(TARGET) && defined(TARGET_ARCH)
2401 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2402 XDEV_CPUTYPE?=${CPUTYPE}
2404 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2407 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2408 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2409 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2410 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2411 CPUTYPE=${XDEV_CPUTYPE}
2413 XDDIR=${TARGET_ARCH}-freebsd
2416 .error XDTP variable should be an absolute path
2419 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2420 INSTALL="sh ${.CURDIR}/tools/install.sh"
2422 TOOLS_PREFIX=${XDTP}
2423 CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \
2424 --sysroot=${XDDESTDIR}/ -B${XDDESTDIR}/usr/libexec \
2425 -B${XDDESTDIR}/usr/bin -B${XDDESTDIR}/usr/lib
2426 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CFLAGS}" \
2427 CPP="${CPP} ${CD2CFLAGS}" \
2428 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2430 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2431 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2432 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2433 XDDESTDIR=${DESTDIR}/${XDTP}
2435 OSREL!= uname -r | sed -e 's/[-(].*//'
2438 .ORDER: xdev-build xdev-install xdev-links
2439 xdev: xdev-build xdev-install .PHONY
2441 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2442 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
2444 _xb-worldtmp: .PHONY
2445 mkdir -p ${CDTMP}/usr
2446 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2447 -p ${CDTMP}/usr >/dev/null
2449 _xb-bootstrap-tools: .PHONY
2453 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2454 cd ${.CURDIR}/${_tool}; \
2455 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2456 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2457 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2460 _xb-build-tools: .PHONY
2461 ${_+_}@cd ${.CURDIR}; \
2462 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2464 _xb-cross-tools: .PHONY
2472 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2473 cd ${.CURDIR}/${_tool}; \
2474 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2475 ${CDMAKE} DIRPRFX=${_tool}/ all
2479 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2480 mkdir -p ${XDDESTDIR}
2481 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2482 -p ${XDDESTDIR} >/dev/null
2483 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2484 -p ${XDDESTDIR}/usr >/dev/null
2485 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2486 -p ${XDDESTDIR}/usr/include >/dev/null
2487 .if defined(LIBCOMPAT)
2488 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2489 -p ${XDDESTDIR}/usr >/dev/null
2491 .if ${MK_TESTS} != "no"
2492 mkdir -p ${XDDESTDIR}${TESTSBASE}
2493 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2494 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2497 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2498 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
2500 _xi-cross-tools: .PHONY
2501 @echo "_xi-cross-tools"
2509 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2510 cd ${.CURDIR}/${_tool}; \
2511 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2514 _xi-includes: .PHONY
2515 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2516 DESTDIR=${XDDESTDIR}
2518 _xi-libraries: .PHONY
2519 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2520 DESTDIR=${XDDESTDIR}
2523 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2524 mkdir -p ../../../../usr/bin; \
2526 ln -sf ../../${XDTP}/usr/bin/$$i \
2527 ../../../../usr/bin/${XDDIR}-$$i; \
2528 ln -sf ../../${XDTP}/usr/bin/$$i \
2529 ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \
2532 xdev xdev-build xdev-install xdev-links: .PHONY
2533 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"