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}
64 XCOMPILERS= CC CXX CPP
65 .for COMPILER in ${XCOMPILERS}
66 .if defined(CROSS_COMPILER_PREFIX)
67 X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
69 X${COMPILER}?= ${${COMPILER}}
72 # If a full path to an external cross compiler is given, don't build
74 .if ${XCC:N${CCACHE_BIN}:M/*}
75 MK_CLANG_BOOTSTRAP= no
79 MAKEOBJDIRPREFIX?= /usr/obj
80 .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING)
81 OBJTREE= ${MAKEOBJDIRPREFIX}
83 OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH}
86 # Pull in compiler metadata from buildworld/toolchain if possible to avoid
87 # running CC from bsd.compiler.mk.
88 .if make(installworld) || make(install)
89 .-include "${OBJTREE}${.CURDIR}/compiler-metadata.mk"
92 # Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early.
93 .include <bsd.compiler.mk>
94 .include "share/mk/src.opts.mk"
96 # Check if there is a local compiler that can satisfy as an external compiler.
97 # Which compiler is expected to be used?
98 .if ${MK_CLANG_BOOTSTRAP} == "yes"
99 WANT_COMPILER_TYPE= clang
100 .elif ${MK_GCC_BOOTSTRAP} == "yes"
101 WANT_COMPILER_TYPE= gcc
105 .if !defined(WANT_COMPILER_FREEBSD_VERSION)
106 .if ${WANT_COMPILER_TYPE} == "clang"
107 WANT_COMPILER_FREEBSD_VERSION_FILE= lib/clang/freebsd_cc_version.h
108 WANT_COMPILER_FREEBSD_VERSION!= \
109 awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
110 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
111 WANT_COMPILER_VERSION_FILE= lib/clang/include/clang/Basic/Version.inc
112 WANT_COMPILER_VERSION!= \
113 awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
114 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
115 .elif ${WANT_COMPILER_TYPE} == "gcc"
116 WANT_COMPILER_FREEBSD_VERSION_FILE= gnu/usr.bin/cc/cc_tools/freebsd-native.h
117 WANT_COMPILER_FREEBSD_VERSION!= \
118 awk '$$2 == "FBSD_CC_VER" {printf("%d\n", $$3)}' \
119 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
120 WANT_COMPILER_VERSION_FILE= contrib/gcc/BASE-VER
121 WANT_COMPILER_VERSION!= \
122 awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3}' \
123 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
125 .export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION
126 .endif # !defined(WANT_COMPILER_FREEBSD_VERSION)
127 # It needs to be the same revision as we would build for the bootstrap.
128 # If the expected vs CC is different then we can't skip.
129 # GCC cannot be used for cross-arch yet. For clang we pass -target later if
130 # TARGET_ARCH!=MACHINE_ARCH.
131 .if ${MK_SYSTEM_COMPILER} == "yes" && \
132 (${MK_CLANG_BOOTSTRAP} == "yes" || ${MK_GCC_BOOTSTRAP} == "yes") && \
133 !make(showconfig) && !make(native-xtools) && !make(xdev*) && \
134 ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE} && \
135 (${COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \
136 ${COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \
137 ${COMPILER_FREEBSD_VERSION} == ${WANT_COMPILER_FREEBSD_VERSION}
138 # Everything matches, disable the bootstrap compiler.
139 MK_CLANG_BOOTSTRAP= no
141 USING_SYSTEM_COMPILER= yes
142 .endif # ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE}
143 USING_SYSTEM_COMPILER?= no
144 TEST_SYSTEM_COMPILER_VARS= \
145 USING_SYSTEM_COMPILER MK_SYSTEM_COMPILER \
146 MK_CROSS_COMPILER MK_CLANG_BOOTSTRAP MK_GCC_BOOTSTRAP \
147 WANT_COMPILER_TYPE WANT_COMPILER_VERSION WANT_COMPILER_VERSION_FILE \
148 WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \
149 CC COMPILER_TYPE COMPILER_FEATURES COMPILER_VERSION \
150 COMPILER_FREEBSD_VERSION
151 test-system-compiler: .PHONY
152 .for v in ${TEST_SYSTEM_COMPILER_VARS}
153 ${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}"
155 .if ${USING_SYSTEM_COMPILER} == "yes" && \
156 (make(buildworld) || make(buildkernel) || make(kernel-toolchain) || \
157 make(toolchain) || make(_cross-tools))
158 .info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler.
161 # For installworld need to ensure that the looked-up compiler metadata is
162 # passed along rather than trying to run cc from the restricted
164 .if ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
165 .if !defined(X_COMPILER_TYPE)
166 CROSSENV+= COMPILER_VERSION=${COMPILER_VERSION} \
167 COMPILER_TYPE=${COMPILER_TYPE} \
168 COMPILER_FEATURES=${COMPILER_FEATURES} \
169 COMPILER_FREEBSD_VERSION=${COMPILER_FREEBSD_VERSION}
171 CROSSENV+= COMPILER_VERSION=${X_COMPILER_VERSION} \
172 COMPILER_FEATURES=${X_COMPILER_FEATURES} \
173 COMPILER_TYPE=${X_COMPILER_TYPE} \
174 COMPILER_FREEBSD_VERSION=${X_COMPILER_FREEBSD_VERSION}
177 # Store some compiler metadata for use in installworld where we don't
178 # want to invoke CC at all.
179 _COMPILER_METADATA_VARS= COMPILER_VERSION \
182 COMPILER_FREEBSD_VERSION
183 compiler-metadata.mk: .PHONY .META
185 @echo ".info Using cached compiler metadata from build at $$(hostname) on $$(date)" \
187 .for v in ${_COMPILER_METADATA_VARS}
188 @echo "${v}=${${v}}" >> ${.TARGET}
190 @echo ".export ${_COMPILER_METADATA_VARS}" >> ${.TARGET}
192 # Handle external binutils.
193 .if defined(CROSS_TOOLCHAIN_PREFIX)
194 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
196 # If we do not have a bootstrap binutils (because the in-tree one does not
197 # support the target architecture), provide a default cross-binutils prefix.
198 # This allows riscv64 builds, for example, to automatically use the
199 # riscv64-binutils port or package.
200 .if !make(showconfig)
201 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
202 ${MK_LLD_BOOTSTRAP} == "no" && \
203 !defined(CROSS_BINUTILS_PREFIX)
204 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
205 .if !exists(${CROSS_BINUTILS_PREFIX})
206 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
210 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
211 .for BINUTIL in ${XBINUTILS}
212 .if defined(CROSS_BINUTILS_PREFIX) && \
213 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
214 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
216 X${BINUTIL}?= ${${BINUTIL}}
221 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
222 # keep the users system reasonably usable. For static->dynamic root upgrades,
223 # we don't want to install a dynamic binary without rtld and the needed
224 # libraries. More commonly, for dynamic root, we don't want to install a
225 # binary that requires a newer library version that hasn't been installed yet.
226 # This ordering is not a guarantee though. The only guarantee of a working
227 # system here would require fine-grained ordering of all components based
228 # on their dependencies.
229 .if !empty(SUBDIR_OVERRIDE)
230 SUBDIR= ${SUBDIR_OVERRIDE}
233 .if !defined(NO_ROOT) && (make(installworld) || make(install))
234 # Ensure libraries are installed before progressing.
238 .if ${MK_CDDL} != "no"
242 .if ${MK_KERBEROS} != "no"
245 .if ${MK_RESCUE} != "no"
249 .if ${MK_CRYPT} != "no"
252 .if !defined(NO_SHARE)
255 SUBDIR+=sys usr.bin usr.sbin
256 .if ${MK_TESTS} != "no"
259 .if ${MK_OFED} != "no"
263 # Local directories are built in parallel with the base system directories.
264 # Users may insert a .WAIT directive at the beginning or elsewhere within
265 # the LOCAL_DIRS and LOCAL_LIB_DIRS lists as needed.
266 .for _DIR in ${LOCAL_DIRS}
267 .if ${_DIR} == ".WAIT" || exists(${.CURDIR}/${_DIR}/Makefile)
271 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
272 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
273 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
274 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
275 _REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
277 .for _DIR in ${LOCAL_LIB_DIRS}
278 .if ${_DIR} == ".WAIT" || (empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
283 # We must do etc/ last as it hooks into building the man whatis file
284 # by calling 'makedb' in share/man. This is only relevant for
285 # install/distribute so they build the whatis file after every manpage is
287 .if make(installworld) || make(install)
292 .endif # !empty(SUBDIR_OVERRIDE)
295 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
298 .if defined(NO_CLEANDIR)
299 CLEANDIR= clean cleandepend
304 .if ${MK_META_MODE} == "yes"
305 # If filemon is used then we can rely on the build being incremental-safe.
306 # The .meta files will also track the build command and rebuild should
308 .if empty(.MAKE.MODE:Mnofilemon)
314 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
316 .if empty(SHELL:M*csh*)
317 BUILDENV_SHELL?=${SHELL}
319 BUILDENV_SHELL?=/bin/sh
322 .if !defined(SVN) || empty(SVN)
323 . for _P in /usr/bin /usr/local/bin
324 . for _S in svn svnlite
325 . if exists(${_P}/${_S})
333 .if !defined(OSRELDATE)
334 .if exists(/usr/include/osreldate.h)
335 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
336 /usr/include/osreldate.h
343 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
344 .if !defined(_REVISION)
345 _REVISION!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V REVISION
348 .if !defined(_BRANCH)
349 _BRANCH!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V BRANCH
352 .if !defined(SRCRELDATE)
353 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
354 ${SRCDIR}/sys/sys/param.h
357 .if !defined(VERSION)
358 VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
362 .if !defined(PKG_VERSION)
363 .if ${_BRANCH:MSTABLE*} || ${_BRANCH:MCURRENT*} || ${_BRANCH:MALPHA*}
364 TIMENOW= %Y%m%d%H%M%S
365 EXTRA_REVISION= .s${TIMENOW:gmtime}
368 EXTRA_REVISION= _${_BRANCH:C/.*-p([0-9]+$)/\1/}
370 PKG_VERSION= ${_REVISION}${EXTRA_REVISION}
373 KNOWN_ARCHES?= aarch64/arm64 \
391 .if ${TARGET} == ${TARGET_ARCH}
394 _t= ${TARGET_ARCH}/${TARGET}
397 .if empty(KNOWN_ARCHES:M${_t})
398 .error Unknown target ${TARGET_ARCH}:${TARGET}.
402 .if ${TARGET} == ${MACHINE}
403 TARGET_CPUTYPE?=${CPUTYPE}
408 .if !empty(TARGET_CPUTYPE)
409 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
411 _TARGET_CPUTYPE=dummy
413 _CPUTYPE!= MK_AUTO_OBJ=no MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
414 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
415 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
416 .error CPUTYPE global should be set with ?=.
419 BUILD_ARCH!= uname -p
420 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
421 .error To cross-build, set TARGET_ARCH.
424 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
425 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
426 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
427 STRICTTMPPATH= ${BPATH}:${XPATH}
428 TMPPATH= ${STRICTTMPPATH}:${PATH}
431 # Avoid running mktemp(1) unless actually needed.
432 # It may not be functional, e.g., due to new ABI
433 # when in the middle of installing over this system.
435 .if make(distributeworld) || make(installworld) || make(stageworld)
436 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
439 .if make(stagekernel) || make(distributekernel)
445 # Building a world goes through the following stages
447 # 1. legacy stage [BMAKE]
448 # This stage is responsible for creating compatibility
449 # shims that are needed by the bootstrap-tools,
450 # build-tools and cross-tools stages. These are generally
451 # APIs that tools from one of those three stages need to
452 # build that aren't present on the host.
453 # 1. bootstrap-tools stage [BMAKE]
454 # This stage is responsible for creating programs that
455 # are needed for backward compatibility reasons. They
456 # are not built as cross-tools.
457 # 2. build-tools stage [TMAKE]
458 # This stage is responsible for creating the object
459 # tree and building any tools that are needed during
460 # the build process. Some programs are listed during
461 # this phase because they build binaries to generate
462 # files needed to build these programs. This stage also
463 # builds the 'build-tools' target rather than 'all'.
464 # 3. cross-tools stage [XMAKE]
465 # This stage is responsible for creating any tools that
466 # are needed for building the system. A cross-compiler is one
467 # of them. This differs from build tools in two ways:
468 # 1. the 'all' target is built rather than 'build-tools'
469 # 2. these tools are installed into TMPPATH for stage 4.
470 # 4. world stage [WMAKE]
471 # This stage actually builds the world.
472 # 5. install stage (optional) [IMAKE]
473 # This stage installs a previously built world.
478 MINIMUM_SUPPORTED_OSREL?= 900044
479 MINIMUM_SUPPORTED_REL?= 9.1
481 # Common environment for world related stages
482 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
483 MACHINE_ARCH=${TARGET_ARCH} \
485 CPUTYPE=${TARGET_CPUTYPE}
486 .if ${MK_META_MODE} != "no"
487 # Don't rebuild build-tools targets during normal build.
488 CROSSENV+= BUILD_TOOLS_META=.NOMETA
490 .if ${MK_GROFF} != "no"
491 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
492 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
493 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
495 .if defined(TARGET_CFLAGS)
496 CROSSENV+= ${TARGET_CFLAGS}
499 # bootstrap-tools stage
500 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
501 TOOLS_PREFIX=${WORLDTMP} \
502 PATH=${BPATH}:${PATH} \
503 WORLDTMP=${WORLDTMP} \
504 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
505 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
507 BOOTSTRAPPING=${OSRELDATE} \
509 MK_HTML=no NO_LINT=yes MK_MAN=no \
510 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
511 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
512 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
513 MK_LLDB=no MK_TESTS=no \
516 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
517 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
521 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
522 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
523 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
525 BOOTSTRAPPING=${OSRELDATE} \
528 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
529 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
530 MK_LLDB=no MK_TESTS=no
533 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
534 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
535 MK_GDB=no MK_TESTS=no
538 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
539 PATH=${BPATH}:${PATH} \
541 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
542 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
544 BOOTSTRAPPING=${OSRELDATE} \
546 MK_HTML=no -DNO_LINT MK_MAN=no \
547 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
548 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
551 WMAKEENV= ${CROSSENV} \
552 INSTALL="sh ${.CURDIR}/tools/install.sh" \
556 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
558 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
561 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
562 CPP="${XCPP} ${XCFLAGS}" \
563 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
564 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
565 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
568 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
569 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
570 # directory, but the compiler will look in the right place for its
571 # tools so we don't need to tell it where to look.
572 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
575 # External compiler needs sysroot and target flags.
576 .if ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
577 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
578 BFLAGS+= -B${WORLDTMP}/usr/bin
580 .if ${TARGET} == "arm"
581 .if ${TARGET_ARCH:Marmv6*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
582 TARGET_ABI= gnueabihf
587 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
588 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
589 # won't set header path and -L is used to ensure the base library path
590 # is added before the port PREFIX library path.
591 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
592 # Force using libc++ for external GCC.
593 .if ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
594 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
595 -nostdinc++ -L${WORLDTMP}/../lib/libc++
599 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.1
600 XCFLAGS+= -target ${TARGET_TRIPLE}
602 XCFLAGS+= --sysroot=${WORLDTMP}
603 .endif # ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
609 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
610 ${TARGET_ARCH} == "powerpc64")
612 .include "Makefile.libcompat"
613 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH} == "armv6"
615 .include "Makefile.libcompat"
618 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
620 IMAKEENV= ${CROSSENV}
621 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
622 ${IMAKE_INSTALL} ${IMAKE_MTREE}
623 .if empty(.MAKEFLAGS:M-n)
624 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
625 LD_LIBRARY_PATH=${INSTALLTMP} \
626 PATH_LOCALE=${INSTALLTMP}/locale
627 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
629 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
631 .if defined(DB_FROM_SRC)
632 INSTALLFLAGS+= -N ${.CURDIR}/etc
633 MTREEFLAGS+= -N ${.CURDIR}/etc
635 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
636 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
638 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
639 METALOG:= ${METALOG:C,//+,/,g}
640 IMAKE+= -DNO_ROOT METALOG=${METALOG}
641 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
644 .if defined(BUILD_PKGS)
645 INSTALLFLAGS+= -h sha256
647 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
648 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
649 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
653 KMAKEENV= ${WMAKEENV}
654 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
659 # Attempt to rebuild the entire system, with reasonable chance of
660 # success, regardless of how old your existing system is.
663 .if ${.CURDIR:C/[^,]//g} != ""
664 # The m4 build of sendmail files doesn't like it if ',' is used
665 # anywhere in the path of it's files.
667 @echo "*** Error: path to source tree contains a comma ','"
672 @echo "--------------------------------------------------------------"
673 @echo ">>> Rebuilding the temporary build tree"
674 @echo "--------------------------------------------------------------"
675 .if !defined(NO_CLEAN)
677 .if defined(LIBCOMPAT)
678 rm -rf ${LIBCOMPATTMP}
681 rm -rf ${WORLDTMP}/legacy/usr/include
682 .if ${USING_SYSTEM_COMPILER} == "yes"
684 if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \
685 inum=$$(stat -f %i ${WORLDTMP}/usr/bin/${cc}); \
686 find ${WORLDTMP}/usr/bin -inum $${inum} -delete; \
689 .endif # ${USING_SYSTEM_COMPILER} == "yes"
690 .endif # !defined(NO_CLEAN)
692 lib lib/casper usr legacy/bin legacy/usr
693 mkdir -p ${WORLDTMP}/${_dir}
695 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
696 -p ${WORLDTMP}/legacy/usr >/dev/null
697 .if ${MK_GROFF} != "no"
698 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
699 -p ${WORLDTMP}/legacy/usr >/dev/null
701 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
702 -p ${WORLDTMP}/legacy/usr/include >/dev/null
703 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
704 -p ${WORLDTMP}/usr >/dev/null
705 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
706 -p ${WORLDTMP}/usr/include >/dev/null
707 ln -sf ${.CURDIR}/sys ${WORLDTMP}
708 .if ${MK_DEBUG_FILES} != "no"
709 # We could instead disable debug files for these build stages
710 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
711 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
712 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
713 -p ${WORLDTMP}/usr/lib >/dev/null
715 .if defined(LIBCOMPAT)
716 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
717 -p ${WORLDTMP}/usr >/dev/null
718 .if ${MK_DEBUG_FILES} != "no"
719 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
720 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
721 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
722 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
725 .if ${MK_TESTS} != "no"
726 mkdir -p ${WORLDTMP}${TESTSBASE}
727 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
728 -p ${WORLDTMP}${TESTSBASE} >/dev/null
729 .if ${MK_DEBUG_FILES} != "no"
730 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
731 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
732 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
735 .for _mtree in ${LOCAL_MTREE}
736 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
740 @echo "--------------------------------------------------------------"
741 @echo ">>> stage 1.1: legacy release compatibility shims"
742 @echo "--------------------------------------------------------------"
743 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
746 @echo "--------------------------------------------------------------"
747 @echo ">>> stage 1.2: bootstrap tools"
748 @echo "--------------------------------------------------------------"
749 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
751 .if !defined(NO_CLEAN)
753 @echo "--------------------------------------------------------------"
754 @echo ">>> stage 2.1: cleaning up the object tree"
755 @echo "--------------------------------------------------------------"
756 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
757 .if defined(LIBCOMPAT)
758 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
763 @echo "--------------------------------------------------------------"
764 @echo ">>> stage 2.2: rebuilding the object tree"
765 @echo "--------------------------------------------------------------"
766 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
769 @echo "--------------------------------------------------------------"
770 @echo ">>> stage 2.3: build tools"
771 @echo "--------------------------------------------------------------"
772 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
775 @echo "--------------------------------------------------------------"
776 @echo ">>> stage 3: cross tools"
777 @echo "--------------------------------------------------------------"
778 @rm -f ${.OBJDIR}/compiler-metadata.mk
779 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
780 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
783 @echo "--------------------------------------------------------------"
784 @echo ">>> stage 3.1: recording compiler metadata"
785 @echo "--------------------------------------------------------------"
786 ${_+_}cd ${.CURDIR}; ${WMAKE} compiler-metadata.mk
789 @echo "--------------------------------------------------------------"
790 @echo ">>> stage 4.1: building includes"
791 @echo "--------------------------------------------------------------"
792 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
793 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
794 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
795 MK_INCLUDES=yes includes
796 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
797 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
801 @echo "--------------------------------------------------------------"
802 @echo ">>> stage 4.2: building libraries"
803 @echo "--------------------------------------------------------------"
804 ${_+_}cd ${.CURDIR}; \
805 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
806 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
809 @echo "--------------------------------------------------------------"
810 @echo ">>> stage 4.3: building everything"
811 @echo "--------------------------------------------------------------"
812 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
815 WMAKE_TGTS+= _worldtmp _legacy
816 .if empty(SUBDIR_OVERRIDE)
817 WMAKE_TGTS+= _bootstrap-tools
819 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
820 WMAKE_TGTS+= _compiler-metadata
821 WMAKE_TGTS+= _includes _libraries
822 WMAKE_TGTS+= everything
823 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
824 WMAKE_TGTS+= build${libcompat}
827 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
828 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
830 buildworld_prologue: .PHONY
831 @echo "--------------------------------------------------------------"
832 @echo ">>> World build started on `LC_ALL=C date`"
833 @echo "--------------------------------------------------------------"
835 buildworld_epilogue: .PHONY
837 @echo "--------------------------------------------------------------"
838 @echo ">>> World build completed on `LC_ALL=C date`"
839 @echo "--------------------------------------------------------------"
842 # We need to have this as a target because the indirection between Makefile
843 # and Makefile.inc1 causes the correct PATH to be used, rather than a
844 # modification of the current environment's PATH. In addition, we need
845 # to quote multiword values.
848 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
850 .if ${.TARGETS:Mbuildenv}
851 .if ${.MAKEFLAGS:M-j}
852 .error The buildenv target is incompatible with -j
855 BUILDENV_DIR?= ${.CURDIR}
857 @echo Entering world for ${TARGET_ARCH}:${TARGET}
858 .if ${BUILDENV_SHELL:M*zsh*}
859 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
861 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
864 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
865 toolchain: ${TOOLCHAIN_TGTS} .PHONY
866 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries} .PHONY
871 # Checks to be sure system is ready for installworld/installkernel.
873 installcheck: _installcheck_world _installcheck_kernel .PHONY
874 _installcheck_world: .PHONY
875 _installcheck_kernel: .PHONY
878 # Require DESTDIR to be set if installing for a different architecture or
879 # using the user/group database in the source tree.
881 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
883 .if !make(distributeworld)
884 _installcheck_world: __installcheck_DESTDIR
885 _installcheck_kernel: __installcheck_DESTDIR
886 __installcheck_DESTDIR: .PHONY
887 .if !defined(DESTDIR) || empty(DESTDIR)
888 @echo "ERROR: Please set DESTDIR!"; \
894 .if !defined(DB_FROM_SRC)
896 # Check for missing UIDs/GIDs.
898 CHECK_UIDS= auditdistd
900 .if ${MK_SENDMAIL} != "no"
906 CHECK_GIDS+= proxy authpf
908 .if ${MK_UNBOUND} != "no"
912 _installcheck_world: __installcheck_UGID
913 __installcheck_UGID: .PHONY
914 .for uid in ${CHECK_UIDS}
915 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
916 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
920 .for gid in ${CHECK_GIDS}
921 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
922 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
928 # If installing over the running system (DESTDIR is / or unset) and the install
929 # includes rescue, try running rescue from the objdir as a sanity check. If
930 # rescue is not functional (e.g., because it depends on a system call not
931 # supported by the currently running kernel), abort the installation.
933 .if !make(distributeworld) && ${MK_RESCUE} != "no" && \
934 (empty(DESTDIR) || ${DESTDIR} == "/") && empty(BYPASS_INSTALLCHECK_SH)
935 _installcheck_world: __installcheck_sh_check
936 __installcheck_sh_check: .PHONY
937 @if [ "`${OBJTREE}${.CURDIR}/rescue/rescue/rescue sh -c 'echo OK'`" != \
939 echo "rescue/sh check failed, installation aborted" >&2; \
945 # Required install tools to be saved in a scratch dir for safety.
947 .if ${MK_ZONEINFO} != "no"
948 _zoneinfo= zic tzsetup
951 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
952 date echo egrep find grep id install ${_install-info} \
953 ln make mkdir mtree mv pwd_mkdb \
954 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
957 # Needed for share/man
958 .if ${MK_MAN_UTILS} != "no"
965 # Distributes everything compiled by a `buildworld'.
969 # Installs everything compiled by a 'buildworld'.
972 # Non-base distributions produced by the base system
973 EXTRA_DISTRIBUTIONS= doc
974 .if defined(LIBCOMPAT)
975 EXTRA_DISTRIBUTIONS+= lib${libcompat}
977 .if ${MK_TESTS} != "no"
978 EXTRA_DISTRIBUTIONS+= tests
982 .if ${MK_DEBUG_FILES} != "no"
983 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
986 MTREE_MAGIC?= mtree 2.0
988 distributeworld installworld stageworld: _installcheck_world .PHONY
989 mkdir -p ${INSTALLTMP}
990 progs=$$(for prog in ${ITOOLS}; do \
991 if progpath=`which $$prog`; then \
994 echo "Required tool $$prog not found in PATH." >&2; \
998 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
999 while read line; do \
1001 if [ "$$2 $$3" != "not found" ]; then \
1004 echo "Required library $$1 not found." >&2; \
1008 cp $$libs $$progs ${INSTALLTMP}
1009 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
1010 .if defined(NO_ROOT)
1011 -mkdir -p ${METALOG:H}
1012 echo "#${MTREE_MAGIC}" > ${METALOG}
1014 .if make(distributeworld)
1015 .for dist in ${EXTRA_DISTRIBUTIONS}
1016 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
1017 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1018 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
1019 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1020 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1021 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1022 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
1023 .if ${MK_DEBUG_FILES} != "no"
1024 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1025 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
1027 .if defined(LIBCOMPAT)
1028 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1029 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1030 .if ${MK_DEBUG_FILES} != "no"
1031 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1032 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
1035 .if ${MK_TESTS} != "no" && ${dist} == "tests"
1036 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
1037 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1038 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
1039 .if ${MK_DEBUG_FILES} != "no"
1040 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1041 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
1044 .if defined(NO_ROOT)
1045 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1046 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1047 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1048 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1049 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1050 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1051 .if defined(LIBCOMPAT)
1052 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
1053 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1057 -mkdir ${DESTDIR}/${DISTDIR}/base
1058 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1059 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1060 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1061 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1063 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1064 ${IMAKEENV} rm -rf ${INSTALLTMP}
1065 .if make(distributeworld)
1066 .for dist in ${EXTRA_DISTRIBUTIONS}
1067 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete
1069 .if defined(NO_ROOT)
1070 .for dist in base ${EXTRA_DISTRIBUTIONS}
1071 @# For each file that exists in this dist, print the corresponding
1072 @# line from the METALOG. This relies on the fact that
1073 @# a line containing only the filename will sort immediately before
1074 @# the relevant mtree line.
1075 cd ${DESTDIR}/${DISTDIR}; \
1076 find ./${dist} | sort -u ${METALOG} - | \
1077 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1078 ${DESTDIR}/${DISTDIR}/${dist}.meta
1080 .for dist in ${DEBUG_DISTRIBUTIONS}
1081 @# For each file that exists in this dist, print the corresponding
1082 @# line from the METALOG. This relies on the fact that
1083 @# a line containing only the filename will sort immediately before
1084 @# the relevant mtree line.
1085 cd ${DESTDIR}/${DISTDIR}; \
1086 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1087 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1088 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1093 packageworld: .PHONY
1094 .for dist in base ${EXTRA_DISTRIBUTIONS}
1095 .if defined(NO_ROOT)
1096 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1097 tar cvf - --exclude usr/lib/debug \
1098 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1099 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1101 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1102 tar cvf - --exclude usr/lib/debug . | \
1103 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1107 .for dist in ${DEBUG_DISTRIBUTIONS}
1108 . if defined(NO_ROOT)
1109 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1110 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1111 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1113 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1114 tar cvLf - usr/lib/debug | \
1115 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1122 # If you have a build server, you can NFS mount the source and obj directories
1123 # and do a 'make reinstall' on the *client* to install new binaries from the
1124 # most recent server build.
1126 restage reinstall: .MAKE .PHONY
1127 @echo "--------------------------------------------------------------"
1128 @echo ">>> Making hierarchy"
1129 @echo "--------------------------------------------------------------"
1130 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1131 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1133 @echo "--------------------------------------------------------------"
1134 @echo ">>> Making distribution"
1135 @echo "--------------------------------------------------------------"
1136 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1137 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
1140 @echo "--------------------------------------------------------------"
1141 @echo ">>> Installing everything"
1142 @echo "--------------------------------------------------------------"
1143 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1144 .if defined(LIBCOMPAT)
1145 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1148 redistribute: .MAKE .PHONY
1149 @echo "--------------------------------------------------------------"
1150 @echo ">>> Distributing everything"
1151 @echo "--------------------------------------------------------------"
1152 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1153 .if defined(LIBCOMPAT)
1154 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1155 DISTRIBUTION=lib${libcompat}
1158 distrib-dirs distribution: .MAKE .PHONY
1159 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1160 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1161 .if make(distribution)
1162 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1163 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1164 METALOG=${METALOG} MK_TESTS=no installconfig
1168 # buildkernel and installkernel
1170 # Which kernels to build and/or install is specified by setting
1171 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1172 # Only the existing (depending TARGET) config files are used
1173 # for building kernels and only the first of these is designated
1174 # as the one being installed.
1176 # Note that we have to use TARGET instead of TARGET_ARCH when
1177 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1178 # be set to cross-build, we have to make sure TARGET is set
1181 .if defined(KERNFAST)
1185 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1186 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1187 KERNCONF=${KERNFAST}
1190 .if ${TARGET_ARCH} == "powerpc64"
1191 KERNCONF?= GENERIC64
1195 INSTKERNNAME?= kernel
1197 KERNSRCDIR?= ${.CURDIR}/sys
1198 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1199 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1200 KERNCONFDIR?= ${KRNLCONFDIR}
1204 .if defined(NO_INSTALLKERNEL)
1205 # All of the BUILDKERNELS loops start at index 1.
1206 BUILDKERNELS+= dummy
1208 .for _kernel in ${KERNCONF}
1209 .if exists(${KERNCONFDIR}/${_kernel})
1210 BUILDKERNELS+= ${_kernel}
1211 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1212 INSTALLKERNEL= ${_kernel}
1215 .if make(buildkernel)
1216 .error Missing KERNCONF ${KERNCONFDIR}/${_kernel}
1221 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1226 # Builds all kernels defined by BUILDKERNELS.
1228 buildkernel: .MAKE .PHONY
1229 .if empty(BUILDKERNELS:Ndummy)
1230 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1234 .for _kernel in ${BUILDKERNELS:Ndummy}
1235 @echo "--------------------------------------------------------------"
1236 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1237 @echo "--------------------------------------------------------------"
1238 @echo "===> ${_kernel}"
1239 mkdir -p ${KRNLOBJDIR}
1240 .if !defined(NO_KERNELCONFIG)
1242 @echo "--------------------------------------------------------------"
1243 @echo ">>> stage 1: configuring the kernel"
1244 @echo "--------------------------------------------------------------"
1245 cd ${KRNLCONFDIR}; \
1247 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1248 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1250 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1252 @echo "--------------------------------------------------------------"
1253 @echo ">>> stage 2.1: cleaning up the object tree"
1254 @echo "--------------------------------------------------------------"
1255 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1257 .if !defined(NO_KERNELOBJ)
1259 @echo "--------------------------------------------------------------"
1260 @echo ">>> stage 2.2: rebuilding the object tree"
1261 @echo "--------------------------------------------------------------"
1262 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1265 @echo "--------------------------------------------------------------"
1266 @echo ">>> stage 2.3: build tools"
1267 @echo "--------------------------------------------------------------"
1268 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1270 @echo "--------------------------------------------------------------"
1271 @echo ">>> stage 3.1: building everything"
1272 @echo "--------------------------------------------------------------"
1273 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1274 @echo "--------------------------------------------------------------"
1275 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1276 @echo "--------------------------------------------------------------"
1279 NO_INSTALLEXTRAKERNELS?= yes
1282 # installkernel, etc.
1284 # Install the kernel defined by INSTALLKERNEL
1286 installkernel installkernel.debug \
1287 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1288 .if !defined(NO_INSTALLKERNEL)
1289 .if empty(INSTALLKERNEL)
1290 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1293 @echo "--------------------------------------------------------------"
1294 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1295 @echo "--------------------------------------------------------------"
1296 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1297 ${CROSSENV} PATH=${TMPPATH} \
1298 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1300 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1301 .for _kernel in ${BUILDKERNELS:[2..-1]}
1302 @echo "--------------------------------------------------------------"
1303 @echo ">>> Installing kernel ${_kernel}"
1304 @echo "--------------------------------------------------------------"
1305 cd ${KRNLOBJDIR}/${_kernel}; \
1306 ${CROSSENV} PATH=${TMPPATH} \
1307 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1311 distributekernel distributekernel.debug: .PHONY
1312 .if !defined(NO_INSTALLKERNEL)
1313 .if empty(INSTALLKERNEL)
1314 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1317 mkdir -p ${DESTDIR}/${DISTDIR}
1318 .if defined(NO_ROOT)
1319 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1321 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1322 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1323 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1324 DESTDIR=${INSTALL_DDIR}/kernel \
1325 ${.TARGET:S/distributekernel/install/}
1326 .if defined(NO_ROOT)
1327 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1328 ${DESTDIR}/${DISTDIR}/kernel.meta
1331 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1332 .for _kernel in ${BUILDKERNELS:[2..-1]}
1333 .if defined(NO_ROOT)
1334 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1336 cd ${KRNLOBJDIR}/${_kernel}; \
1337 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1338 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1339 KERNEL=${INSTKERNNAME}.${_kernel} \
1340 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1341 ${.TARGET:S/distributekernel/install/}
1342 .if defined(NO_ROOT)
1343 @sed -e "s|^./kernel.${_kernel}|.|" \
1344 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1345 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1350 packagekernel: .PHONY
1351 .if defined(NO_ROOT)
1352 .if !defined(NO_INSTALLKERNEL)
1353 cd ${DESTDIR}/${DISTDIR}/kernel; \
1354 tar cvf - --exclude '*.debug' \
1355 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1356 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1358 .if ${MK_DEBUG_FILES} != "no"
1359 cd ${DESTDIR}/${DISTDIR}/kernel; \
1360 tar cvf - --include '*/*/*.debug' \
1361 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1362 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1364 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1365 .for _kernel in ${BUILDKERNELS:[2..-1]}
1366 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1367 tar cvf - --exclude '*.debug' \
1368 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1369 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1370 .if ${MK_DEBUG_FILES} != "no"
1371 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1372 tar cvf - --include '*/*/*.debug' \
1373 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1374 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1379 .if !defined(NO_INSTALLKERNEL)
1380 cd ${DESTDIR}/${DISTDIR}/kernel; \
1381 tar cvf - --exclude '*.debug' . | \
1382 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1384 .if ${MK_DEBUG_FILES} != "no"
1385 cd ${DESTDIR}/${DISTDIR}/kernel; \
1386 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1387 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1389 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1390 .for _kernel in ${BUILDKERNELS:[2..-1]}
1391 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1392 tar cvf - --exclude '*.debug' . | \
1393 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1394 .if ${MK_DEBUG_FILES} != "no"
1395 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1396 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1397 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1404 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1406 PORTSDIR?= /usr/ports
1407 WSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/worldstage
1408 KSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/kernelstage
1409 REPODIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/repo
1410 PKGSIGNKEY?= # empty
1412 .ORDER: stage-packages create-packages
1413 .ORDER: create-packages create-world-packages
1414 .ORDER: create-packages create-kernel-packages
1415 .ORDER: create-packages sign-packages
1417 _pkgbootstrap: .PHONY
1418 .if !exists(${LOCALBASE}/sbin/pkg)
1419 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1423 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1426 rm -rf /tmp/ports.${TARGET} || :
1427 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
1428 PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \
1429 WSTAGEDIR=${WSTAGEDIR} \
1430 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1432 real-packages: stage-packages create-packages sign-packages .PHONY
1434 stage-packages: .PHONY
1435 @mkdir -p ${REPODIR} ${WSTAGEDIR} ${KSTAGEDIR}
1436 ${_+_}@cd ${.CURDIR}; \
1437 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT -B stageworld ; \
1438 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT -B stagekernel
1440 create-packages: _pkgbootstrap .PHONY
1441 @mkdir -p ${REPODIR}
1442 ${_+_}@cd ${.CURDIR}; \
1443 ${MAKE} DESTDIR=${WSTAGEDIR} \
1444 PKG_VERSION=${PKG_VERSION} create-world-packages ; \
1445 ${MAKE} DESTDIR=${KSTAGEDIR} \
1446 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1447 create-kernel-packages
1449 create-world-packages: _pkgbootstrap .PHONY
1450 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1451 @cd ${WSTAGEDIR} ; \
1452 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1453 ${WSTAGEDIR}/METALOG
1454 @for plist in ${WSTAGEDIR}/*.plist; do \
1455 plist=$${plist##*/} ; \
1456 pkgname=$${plist%.plist} ; \
1457 sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \
1458 -s ${SRCDIR} -u ${WSTAGEDIR}/$${pkgname}.ucl ; \
1460 @for plist in ${WSTAGEDIR}/*.plist; do \
1461 plist=$${plist##*/} ; \
1462 pkgname=$${plist%.plist} ; \
1464 /^name/ { printf("===> Creating %s-", $$2); next } \
1465 /^version/ { print $$2; next } \
1466 ' ${WSTAGEDIR}/$${pkgname}.ucl ; \
1467 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1468 create -M ${WSTAGEDIR}/$${pkgname}.ucl \
1469 -p ${WSTAGEDIR}/$${pkgname}.plist \
1471 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} ; \
1474 create-kernel-packages: _pkgbootstrap .PHONY
1475 .if exists(${KSTAGEDIR}/kernel.meta)
1476 .if ${MK_DEBUG_FILES} != "no"
1479 .for flavor in "" ${_debug}
1480 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1481 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1482 -v kernel=yes -v _kernconf=${INSTALLKERNEL} \
1483 ${KSTAGEDIR}/kernel.meta ; \
1484 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1485 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1486 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1487 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1488 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1489 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1490 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1491 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1492 ${SRCDIR}/release/packages/kernel.ucl \
1493 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1495 /name/ { printf("===> Creating %s-", $$2); next } \
1496 /version/ {print $$2; next } ' \
1497 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1498 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1499 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1500 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1501 -r ${KSTAGEDIR}/${DISTDIR} \
1502 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1505 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1506 .for _kernel in ${BUILDKERNELS:[2..-1]}
1507 .if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1508 .if ${MK_DEBUG_FILES} != "no"
1511 .for flavor in "" ${_debug}
1512 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1513 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1514 -v kernel=yes -v _kernconf=${_kernel} \
1515 ${KSTAGEDIR}/kernel.${_kernel}.meta ; \
1516 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1517 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1518 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1519 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1520 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1521 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1522 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1523 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1524 ${SRCDIR}/release/packages/kernel.ucl \
1525 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1527 /name/ { printf("===> Creating %s-", $$2); next } \
1528 /version/ {print $$2; next } ' \
1529 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1530 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1531 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1532 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1533 -r ${KSTAGEDIR}/kernel.${_kernel} \
1534 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1540 sign-packages: _pkgbootstrap .PHONY
1541 @[ -L "${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1542 unlink ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1543 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1544 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1545 ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1547 cd ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI); \
1548 ln -s ${PKG_VERSION} latest
1554 # Run test suite on installed world.
1557 @if [ ! -x "${LOCALBASE}/bin/kyua" ]; then \
1558 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1561 ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile
1567 # Build the API documentation with doxygen
1570 @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \
1571 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1574 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1579 # Update the source tree(s), by running svn/svnup to update to the
1583 .if defined(SVN_UPDATE)
1584 @echo "--------------------------------------------------------------"
1585 @echo ">>> Updating ${.CURDIR} using Subversion"
1586 @echo "--------------------------------------------------------------"
1587 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1591 # ------------------------------------------------------------------------
1593 # From here onwards are utility targets used by the 'make world' and
1594 # related targets. If your 'world' breaks, you may like to try to fix
1595 # the problem and manually run the following targets to attempt to
1596 # complete the build. Beware, this is *not* guaranteed to work, you
1597 # need to have a pretty good grip on the current state of the system
1598 # to attempt to manually finish it. If in doubt, 'make world' again.
1602 # legacy: Build compatibility shims for the next three targets. This is a
1603 # minimal set of tools and shims necessary to compensate for older systems
1604 # which don't have the APIs required by the targets built in bootstrap-tools,
1605 # build-tools or cross-tools.
1608 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1609 # r296685 fix cross-endian objcopy
1610 .if ${BOOTSTRAPPING} < 1100102
1611 _elftoolchain_libs= lib/libelf lib/libdwarf
1615 .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
1616 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
1619 .for _tool in tools/build ${_elftoolchain_libs}
1620 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1621 cd ${.CURDIR}/${_tool}; \
1622 ${MAKE} DIRPRFX=${_tool}/ obj; \
1623 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1624 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
1625 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
1626 DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1630 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1631 # are built to build other binaries in the system. However, the focus of these
1632 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1633 # libraries, augmented by -legacy.
1635 _bt= _bootstrap-tools
1637 .if ${MK_GAMES} != "no"
1638 _strfile= usr.bin/fortune/strfile
1641 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1642 _gperf= gnu/usr.bin/gperf
1645 .if ${MK_SHAREDOCS} != "no" && ${MK_GROFF} != "no"
1646 _groff= gnu/usr.bin/groff \
1650 .if ${MK_VT} != "no"
1651 _vtfontcvt= usr.bin/vtfontcvt
1654 .if ${BOOTSTRAPPING} < 1000033
1655 _libopenbsd= lib/libopenbsd
1659 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1660 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1663 # r245440 mtree -N support added
1664 # r313404 requires sha384.h for libnetbsd, added to libmd in r292782
1665 .if ${BOOTSTRAPPING} < 1100093
1666 _nmtree= lib/libmd \
1670 ${_bt}-lib/libnetbsd: ${_bt}-lib/libmd
1671 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1674 .if ${BOOTSTRAPPING} < 1000027
1678 # r277259 crunchide: Correct 64-bit section header offset
1679 # r281674 crunchide: always include both 32- and 64-bit ELF support
1680 .if ${BOOTSTRAPPING} < 1100078
1681 _crunchide= usr.sbin/crunch/crunchide
1684 # r285986 crunchen: use STRIPBIN rather than STRIP
1685 # 1100113: Support MK_AUTO_OBJ
1686 # 1100509: META_MODE fixes
1687 .if ${BOOTSTRAPPING} < 1100078 || \
1688 (${MK_AUTO_OBJ} == "yes" && ${BOOTSTRAPPING} < 1100114) || \
1689 (${MK_META_MODE} == "yes" && ${BOOTSTRAPPING} < 1200006)
1690 _crunchgen= usr.sbin/crunch/crunchgen
1693 # r296926 -P keymap search path, MFC to stable/10 in r298297
1694 .if ${BOOTSTRAPPING} < 1003501 || \
1695 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
1696 _kbdcontrol= usr.sbin/kbdcontrol
1702 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1704 .if ${MK_BSNMP} != "no"
1705 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1708 # We need to build tblgen when we're building clang or lld, either as
1709 # bootstrap tools, or as the part of the normal build.
1710 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
1711 ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no"
1713 lib/clang/libllvmminimal \
1714 usr.bin/clang/llvm-tblgen \
1715 usr.bin/clang/clang-tblgen
1717 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal
1718 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal
1721 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1724 .if ${MK_GPL_DTC} != "no"
1725 _dtc= gnu/usr.bin/dtc
1728 .if ${MK_KERBEROS} != "no"
1729 _kerberos5_bootstrap_tools= \
1730 kerberos5/tools/make-roken \
1731 kerberos5/lib/libroken \
1732 kerberos5/lib/libvers \
1733 kerberos5/tools/asn1_compile \
1734 kerberos5/tools/slc \
1737 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1740 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
1741 .if ${MK_MANDOCDB} != "no"
1742 _libopenbsd?= lib/libopenbsd
1743 _makewhatis= usr.bin/mandoc
1744 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
1747 bootstrap-tools: .PHONY
1749 # Please document (add comment) why something is in 'bootstrap-tools'.
1750 # Try to bound the building of the bootstrap-tool to just the
1751 # FreeBSD versions that need the tool built at this stage of the build.
1754 ${_kerberos5_bootstrap_tools} \
1776 ${_bt}-${_tool}: .PHONY .MAKE
1777 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1778 cd ${.CURDIR}/${_tool}; \
1779 ${MAKE} DIRPRFX=${_tool}/ obj; \
1780 ${MAKE} DIRPRFX=${_tool}/ all; \
1781 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1783 bootstrap-tools: ${_bt}-${_tool}
1787 # build-tools: Build special purpose build tools
1789 .if !defined(NO_SHARE)
1790 _share= share/syscons/scrnmaps
1793 .if ${MK_GCC} != "no"
1794 _gcc_tools= gnu/usr.bin/cc/cc_tools
1797 .if ${MK_RESCUE} != "no"
1798 # rescue includes programs that have build-tools targets
1799 _rescue=rescue/rescue
1802 .if ${MK_TCSH} != "no"
1809 ${LOCAL_TOOL_DIRS} \
1810 lib/ncurses/ncurses \
1811 lib/ncurses/ncursesw \
1816 usr.bin/mkesdb_static \
1817 usr.bin/mkcsmapper_static \
1819 build-tools_${_tool}: .PHONY
1820 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1821 cd ${.CURDIR}/${_tool}; \
1822 ${MAKE} DIRPRFX=${_tool}/ obj; \
1823 ${MAKE} DIRPRFX=${_tool}/ build-tools
1824 build-tools: build-tools_${_tool}
1828 build-tools_${_tool}: .PHONY
1829 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \
1830 cd ${.CURDIR}/${_tool}; \
1831 ${MAKE} DIRPRFX=${_tool}/ obj; \
1832 ${MAKE} DIRPRFX=${_tool}/ all
1833 build-tools: build-tools_${_tool}
1837 # kernel-tools: Build kernel-building tools
1839 kernel-tools: .PHONY
1840 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1841 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1842 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1845 # cross-tools: All the tools needed to build the rest of the system after
1846 # we get done with the earlier stages. It is the last set of tools needed
1847 # to begin building the target binaries.
1849 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1850 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1851 _btxld= usr.sbin/btxld
1855 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1856 # resulting from missing bug fixes or ELF Toolchain updates.
1857 .if ${MK_CDDL} != "no"
1858 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1859 cddl/usr.bin/ctfmerge
1862 # If we're given an XAS, don't build binutils.
1863 .if ${XAS:M/*} == ""
1864 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1865 _binutils= gnu/usr.bin/binutils
1867 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1868 _elftctools= lib/libelftc \
1874 # These are not required by the build, but can be useful for developers who
1875 # cross-build on a FreeBSD 10 host:
1876 _elftctools+= usr.bin/addr2line
1878 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1879 # If cross-building with an external binutils we still need to build strip for
1880 # the target (for at least crunchide).
1881 _elftctools= lib/libelftc \
1886 .if ${MK_CLANG_BOOTSTRAP} != "no"
1887 _clang= usr.bin/clang
1889 .if ${MK_LLD_BOOTSTRAP} != "no"
1890 _lld= usr.bin/clang/lld
1892 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no"
1893 _clang_libs= lib/clang
1895 .if ${MK_GCC_BOOTSTRAP} != "no"
1896 _gcc= gnu/usr.bin/cc
1898 .if ${MK_USB} != "no"
1899 _usb_tools= sys/boot/usb/tools
1902 cross-tools: .MAKE .PHONY
1913 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1914 cd ${.CURDIR}/${_tool}; \
1915 ${MAKE} DIRPRFX=${_tool}/ obj; \
1916 ${MAKE} DIRPRFX=${_tool}/ all; \
1917 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1920 NXBDESTDIR= ${OBJTREE}/nxb-bin
1921 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1923 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1924 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1925 NXBMAKE= ${NXBENV} ${MAKE} \
1926 LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \
1927 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1928 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1929 MK_GDB=no MK_TESTS=no \
1931 MK_HTML=no NO_LINT=yes MK_MAN=no \
1932 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1933 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1934 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1935 MK_LLDB=no MK_DEBUG_FILES=no
1937 # native-xtools is the current target for qemu-user cross builds of ports
1938 # via poudriere and the imgact_binmisc kernel module.
1939 # For non-clang enabled targets that are still using the in tree gcc
1940 # we must build a gperf binary for one instance of its Makefiles. On
1941 # clang-enabled systems, the gperf binary is obsolete.
1942 native-xtools: .PHONY
1943 .if ${MK_GCC_BOOTSTRAP} != "no"
1944 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1945 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \
1946 cd ${.CURDIR}/${_gperf}; \
1947 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1948 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1949 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1951 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1952 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1953 -p ${NXBDESTDIR}/usr >/dev/null
1954 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1955 -p ${NXBDESTDIR}/usr/include >/dev/null
1956 .if ${MK_DEBUG_FILES} != "no"
1957 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1958 -p ${NXBDESTDIR}/usr/lib >/dev/null
2020 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2021 cd ${.CURDIR}/${_tool}; \
2022 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
2023 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
2024 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
2028 # hierarchy - ensure that all the needed directories are present
2030 hierarchy hier: .MAKE .PHONY
2031 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
2034 # libraries - build all libraries, and install them under ${DESTDIR}.
2036 # The list of libraries with dependents (${_prebuild_libs}) and their
2037 # interdependencies (__L) are built automatically by the
2038 # ${.CURDIR}/tools/make_libdeps.sh script.
2040 libraries: .MAKE .PHONY
2041 ${_+_}cd ${.CURDIR}; \
2042 ${MAKE} -f Makefile.inc1 _prereq_libs; \
2043 ${MAKE} -f Makefile.inc1 _startup_libs; \
2044 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
2045 ${MAKE} -f Makefile.inc1 _generic_libs
2048 # static libgcc.a prerequisite for shared libc
2050 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
2052 # These dependencies are not automatically generated:
2054 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
2055 # all shared libraries for ELF.
2057 _startup_libs= gnu/lib/csu
2058 _startup_libs+= lib/csu
2059 _startup_libs+= gnu/lib/libgcc
2060 _startup_libs+= lib/libcompiler_rt
2061 _startup_libs+= lib/libc
2062 _startup_libs+= lib/libc_nonshared
2063 .if ${MK_LIBCPLUSPLUS} != "no"
2064 _startup_libs+= lib/libcxxrt
2067 gnu/lib/libgcc__L: lib/libc__L
2068 gnu/lib/libgcc__L: lib/libc_nonshared__L
2069 .if ${MK_LIBCPLUSPLUS} != "no"
2070 lib/libcxxrt__L: gnu/lib/libgcc__L
2073 _prebuild_libs= ${_kerberos5_lib_libasn1} \
2074 ${_kerberos5_lib_libhdb} \
2075 ${_kerberos5_lib_libheimbase} \
2076 ${_kerberos5_lib_libheimntlm} \
2078 ${_kerberos5_lib_libheimipcc} \
2079 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
2080 ${_kerberos5_lib_libroken} \
2081 ${_kerberos5_lib_libwind} \
2082 lib/libbz2 ${_libcom_err} lib/libcrypt \
2083 lib/libelf lib/libexpat \
2086 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
2088 lib/ncurses/ncurses lib/ncurses/ncursesw \
2089 lib/libopie lib/libpam/libpam ${_lib_libthr} \
2090 ${_lib_libradius} lib/libsbuf lib/libtacplus \
2092 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
2093 ${_cddl_lib_libuutil} \
2094 ${_cddl_lib_libavl} \
2095 ${_cddl_lib_libzfs_core} \
2096 ${_cddl_lib_libctf} \
2097 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
2098 ${_secure_lib_libcrypto} ${_lib_libldns} \
2099 ${_secure_lib_libssh} ${_secure_lib_libssl}
2101 .if ${MK_GNUCXX} != "no"
2102 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
2103 gnu/lib/libstdc++__L: lib/msun__L
2104 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
2107 .if ${MK_DIALOG} != "no"
2108 _prebuild_libs+= gnu/lib/libdialog
2109 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2112 .if ${MK_LIBCPLUSPLUS} != "no"
2113 _prebuild_libs+= lib/libc++
2116 lib/libgeom__L: lib/libexpat__L
2117 lib/libkvm__L: lib/libelf__L
2119 .if ${MK_LIBTHR} != "no"
2120 _lib_libthr= lib/libthr
2123 .if ${MK_RADIUS_SUPPORT} != "no"
2124 _lib_libradius= lib/libradius
2127 .if ${MK_OFED} != "no"
2128 _ofed_lib= contrib/ofed/usr.lib
2129 _prebuild_libs+= contrib/ofed/usr.lib/libosmcomp
2130 _prebuild_libs+= contrib/ofed/usr.lib/libopensm
2131 _prebuild_libs+= contrib/ofed/usr.lib/libibcommon
2132 _prebuild_libs+= contrib/ofed/usr.lib/libibverbs
2133 _prebuild_libs+= contrib/ofed/usr.lib/libibumad
2135 contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
2136 contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
2137 contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
2140 .if ${MK_CASPER} != "no"
2141 _lib_casper= lib/libcasper
2144 lib/libpjdlog__L: lib/libutil__L
2145 lib/libcasper__L: lib/libnv__L
2146 lib/liblzma__L: lib/libthr__L
2148 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
2149 .for _DIR in ${LOCAL_LIB_DIRS}
2150 .if ${_DIR} == ".WAIT" || (empty(_generic_libs:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
2151 _generic_libs+= ${_DIR}
2155 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2157 .if ${MK_CDDL} != "no"
2158 _cddl_lib_libumem= cddl/lib/libumem
2159 _cddl_lib_libnvpair= cddl/lib/libnvpair
2160 _cddl_lib_libavl= cddl/lib/libavl
2161 _cddl_lib_libuutil= cddl/lib/libuutil
2162 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2163 _cddl_lib_libctf= cddl/lib/libctf
2165 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2166 cddl/lib/libzfs__L: lib/libgeom__L
2167 cddl/lib/libctf__L: lib/libz__L
2169 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
2170 # on select architectures though (see cddl/lib/Makefile)
2171 .if ${MACHINE_CPUARCH} != "sparc64"
2172 _prebuild_libs+= lib/libproc lib/librtld_db
2175 .if ${MK_CRYPT} != "no"
2176 .if ${MK_OPENSSL} != "no"
2177 _secure_lib_libcrypto= secure/lib/libcrypto
2178 _secure_lib_libssl= secure/lib/libssl
2179 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2180 .if ${MK_LDNS} != "no"
2181 _lib_libldns= lib/libldns
2182 lib/libldns__L: secure/lib/libcrypto__L
2184 .if ${MK_OPENSSH} != "no"
2185 _secure_lib_libssh= secure/lib/libssh
2186 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2187 .if ${MK_LDNS} != "no"
2188 secure/lib/libssh__L: lib/libldns__L
2190 .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no"
2191 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2192 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2193 lib/libmd__L kerberos5/lib/libroken__L
2197 _secure_lib= secure/lib
2200 .if ${MK_KERBEROS} != "no"
2201 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2202 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2203 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2204 kerberos5/lib/libwind__L lib/libsqlite3__L
2205 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2206 kerberos5/lib/libroken__L lib/libcom_err__L
2207 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2208 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2209 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2210 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2211 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2212 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2213 kerberos5/lib/libroken__L: lib/libcrypt__L
2214 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2215 kerberos5/lib/libheimbase__L: lib/libthr__L
2216 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2219 lib/libsqlite3__L: lib/libthr__L
2221 .if ${MK_GSSAPI} != "no"
2222 _lib_libgssapi= lib/libgssapi
2225 .if ${MK_KERBEROS} != "no"
2226 _kerberos5_lib= kerberos5/lib
2227 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2228 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2229 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2230 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2231 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2232 _kerberos5_lib_libroken= kerberos5/lib/libroken
2233 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2234 _libsqlite3= lib/libsqlite3
2235 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2236 _kerberos5_lib_libwind= kerberos5/lib/libwind
2237 _libcom_err= lib/libcom_err
2240 .if ${MK_NIS} != "no"
2241 _lib_libypclnt= lib/libypclnt
2244 .if ${MK_OPENSSL} == "no"
2245 lib/libradius__L: lib/libmd__L
2249 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2250 .if ${MK_CXX} != "no"
2251 .if ${MK_LIBCPLUSPLUS} != "no"
2252 lib/libproc__L: lib/libcxxrt__L
2253 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2254 lib/libproc__L: gnu/lib/libsupc++__L
2258 .for _lib in ${_prereq_libs}
2259 ${_lib}__PL: .PHONY .MAKE
2260 .if exists(${.CURDIR}/${_lib})
2261 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2262 cd ${.CURDIR}/${_lib}; \
2263 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2264 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2265 DIRPRFX=${_lib}/ all; \
2266 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2267 DIRPRFX=${_lib}/ install
2271 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
2272 ${_lib}__L: .PHONY .MAKE
2273 .if exists(${.CURDIR}/${_lib})
2274 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2275 cd ${.CURDIR}/${_lib}; \
2276 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2277 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2278 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2282 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2283 _startup_libs: ${_startup_libs:S/$/__L/}
2284 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2285 _generic_libs: ${_generic_libs:S/$/__L/}
2287 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2288 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2289 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2290 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2291 # parallel. This is safe for the world stage of buildworld though since it has
2292 # already built libraries in a proper order and installed includes into
2293 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2294 # avoid trashing a system if it crashes mid-install.
2295 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2299 .include <bsd.subdir.mk>
2301 .if make(check-old) || make(check-old-dirs) || \
2302 make(check-old-files) || make(check-old-libs) || \
2303 make(delete-old) || make(delete-old-dirs) || \
2304 make(delete-old-files) || make(delete-old-libs)
2307 # check for / delete old files section
2310 .include "ObsoleteFiles.inc"
2312 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2313 else you can not start such an application. Consult UPDATING for more \
2314 information regarding how to cope with the removal/revision bump of a \
2317 .if !defined(BATCH_DELETE_OLD_FILES)
2323 delete-old-files: .PHONY
2324 @echo ">>> Removing old files (only deletes safe to delete libs)"
2325 # Ask for every old file if the user really wants to remove it.
2326 # It's annoying, but better safe than sorry.
2327 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2328 # argument list will get too long. Using .for/.endfor make "loops" will make
2329 # the Makefile parser segfault.
2332 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2333 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2334 while read file; do \
2335 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2336 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2337 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2339 for ext in debug symbols; do \
2340 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2341 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2342 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2347 # Remove catpages without corresponding manpages.
2349 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2350 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2351 while read catpage; do \
2353 if [ ! -e "$${manpage}" ]; then \
2354 rm ${RM_I} $${catpage} <&3; \
2357 @echo ">>> Old files removed"
2359 check-old-files: .PHONY
2360 @echo ">>> Checking for old files"
2362 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2363 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2364 while read file; do \
2365 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2366 echo "${DESTDIR}/$${file}"; \
2368 for ext in debug symbols; do \
2369 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2370 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2374 # Check for catpages without corresponding manpages.
2375 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2376 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2377 while read catpage; do \
2379 if [ ! -e "$${manpage}" ]; then \
2384 delete-old-libs: .PHONY
2385 @echo ">>> Removing old libraries"
2386 @echo "${OLD_LIBS_MESSAGE}" | fmt
2389 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2390 -V OLD_LIBS | xargs -n1 | \
2391 while read file; do \
2392 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2393 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2394 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2396 for ext in debug symbols; do \
2397 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2398 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2399 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2404 @echo ">>> Old libraries removed"
2406 check-old-libs: .PHONY
2407 @echo ">>> Checking for old libraries"
2409 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2410 -V OLD_LIBS | xargs -n1 | \
2411 while read file; do \
2412 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2413 echo "${DESTDIR}/$${file}"; \
2415 for ext in debug symbols; do \
2416 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2417 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2422 delete-old-dirs: .PHONY
2423 @echo ">>> Removing old directories"
2425 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2426 -V OLD_DIRS | xargs -n1 | sort -r | \
2427 while read dir; do \
2428 if [ -d "${DESTDIR}/$${dir}" ]; then \
2429 rmdir -v "${DESTDIR}/$${dir}" || true; \
2430 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2431 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2433 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2434 rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \
2435 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2436 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2439 @echo ">>> Old directories removed"
2441 check-old-dirs: .PHONY
2442 @echo ">>> Checking for old directories"
2444 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2445 -V OLD_DIRS | xargs -n1 | \
2446 while read dir; do \
2447 if [ -d "${DESTDIR}/$${dir}" ]; then \
2448 echo "${DESTDIR}/$${dir}"; \
2449 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2450 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2452 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2453 echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \
2454 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2455 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2459 delete-old: delete-old-files delete-old-dirs .PHONY
2460 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2462 check-old: check-old-files check-old-libs check-old-dirs .PHONY
2463 @echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
2464 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2469 # showconfig - show build configuration.
2472 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2473 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2475 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2476 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2478 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2479 .if exists(${KERNCONFDIR}/${KERNCONF})
2480 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2481 '${KERNCONFDIR}/${KERNCONF}' ; echo
2487 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2488 DTBOUTPUTPATH= ${.CURDIR}
2492 # Build 'standalone' Device Tree Blob
2495 @PATH=${TMPPATH} MACHINE=${TARGET} \
2496 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2497 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2502 # In the following, the first 'rm' in a series will usually remove all
2503 # files and directories. If it does not, then there are probably some
2504 # files with file flags set, so this unsets them and tries the 'rm' a
2505 # second time. There are situations where this target will be cleaning
2506 # some directories via more than one method, but that duplication is
2507 # needed to correctly handle all the possible situations. Removing all
2508 # files without file flags set in the first 'rm' instance saves time,
2509 # because 'chflags' will need to operate on fewer files afterwards.
2511 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2512 # created by bsd.obj.mk, except that we don't want to .include that file
2515 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2517 .if exists(${BW_CANONICALOBJDIR}/)
2518 -rm -rf ${BW_CANONICALOBJDIR}/*
2519 -chflags -R 0 ${BW_CANONICALOBJDIR}
2520 rm -rf ${BW_CANONICALOBJDIR}/*
2522 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2523 # To be safe in this case, fall back to a 'make cleandir'
2524 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2527 .if defined(TARGET) && defined(TARGET_ARCH)
2529 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2530 XDEV_CPUTYPE?=${CPUTYPE}
2532 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2535 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2536 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2537 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2538 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2539 CPUTYPE=${XDEV_CPUTYPE}
2541 XDDIR=${TARGET_ARCH}-freebsd
2544 .error XDTP variable should be an absolute path
2547 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2548 INSTALL="sh ${.CURDIR}/tools/install.sh"
2550 TOOLS_PREFIX=${XDTP}
2552 .if ${WANT_COMPILER_TYPE} == gcc || \
2553 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
2554 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
2555 # won't set header path and -L is used to ensure the base library path
2556 # is added before the port PREFIX library path.
2557 CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib
2558 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
2559 # combined with --sysroot.
2560 CD2CFLAGS+= -B${XDDESTDIR}/usr/lib
2561 # Force using libc++ for external GCC.
2562 .if ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
2563 CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \
2567 CD2CFLAGS+= --sysroot=${XDDESTDIR}/
2568 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \
2569 CPP="${CPP} ${CD2CFLAGS}" \
2570 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2572 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2573 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2574 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2575 .if ${MK_META_MODE} != "no"
2576 # Don't rebuild build-tools targets during normal build.
2577 CD2MAKE+= BUILD_TOOLS_META=.NOMETA
2579 XDDESTDIR=${DESTDIR}/${XDTP}
2581 .ORDER: xdev-build xdev-install xdev-links
2582 xdev: xdev-build xdev-install .PHONY
2584 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2585 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
2587 _xb-worldtmp: .PHONY
2588 mkdir -p ${CDTMP}/usr
2589 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2590 -p ${CDTMP}/usr >/dev/null
2592 _xb-bootstrap-tools: .PHONY
2597 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2598 cd ${.CURDIR}/${_tool}; \
2599 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2600 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2601 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2604 _xb-build-tools: .PHONY
2605 ${_+_}@cd ${.CURDIR}; \
2606 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2608 _xb-cross-tools: .PHONY
2616 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2617 cd ${.CURDIR}/${_tool}; \
2618 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2619 ${CDMAKE} DIRPRFX=${_tool}/ all
2623 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2624 mkdir -p ${XDDESTDIR}
2625 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2626 -p ${XDDESTDIR} >/dev/null
2627 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2628 -p ${XDDESTDIR}/usr >/dev/null
2629 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2630 -p ${XDDESTDIR}/usr/include >/dev/null
2631 .if defined(LIBCOMPAT)
2632 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2633 -p ${XDDESTDIR}/usr >/dev/null
2635 .if ${MK_TESTS} != "no"
2636 mkdir -p ${XDDESTDIR}${TESTSBASE}
2637 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2638 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2641 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2642 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
2644 _xi-cross-tools: .PHONY
2645 @echo "_xi-cross-tools"
2653 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2654 cd ${.CURDIR}/${_tool}; \
2655 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2658 _xi-includes: .PHONY
2659 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2660 DESTDIR=${XDDESTDIR}
2662 _xi-libraries: .PHONY
2663 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2664 DESTDIR=${XDDESTDIR}
2667 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2668 mkdir -p ../../../../usr/bin; \
2670 ln -sf ../../${XDTP}/usr/bin/$$i \
2671 ../../../../usr/bin/${XDDIR}-$$i; \
2672 ln -sf ../../${XDTP}/usr/bin/$$i \
2673 ../../../../usr/bin/${XDDIR}${_REVISION}-$$i; \
2676 xdev xdev-build xdev-install xdev-links: .PHONY
2677 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"