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"
90 .if !defined(_LOADED_COMPILER_METADATA)
91 .error A build is required first. You may have the wrong MAKEOBJDIRPREFIX set.
95 # Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early.
96 .include <bsd.compiler.mk>
97 .include "share/mk/src.opts.mk"
99 # Check if there is a local compiler that can satisfy as an external compiler.
100 # Which compiler is expected to be used?
101 .if ${MK_CLANG_BOOTSTRAP} == "yes"
102 WANT_COMPILER_TYPE= clang
103 .elif ${MK_GCC_BOOTSTRAP} == "yes"
104 WANT_COMPILER_TYPE= gcc
108 .if !defined(WANT_COMPILER_FREEBSD_VERSION)
109 .if ${WANT_COMPILER_TYPE} == "clang"
110 WANT_COMPILER_FREEBSD_VERSION_FILE= lib/clang/freebsd_cc_version.h
111 WANT_COMPILER_FREEBSD_VERSION!= \
112 awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
113 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
114 WANT_COMPILER_VERSION_FILE= lib/clang/include/clang/Basic/Version.inc
115 WANT_COMPILER_VERSION!= \
116 awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
117 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
118 .elif ${WANT_COMPILER_TYPE} == "gcc"
119 WANT_COMPILER_FREEBSD_VERSION_FILE= gnu/usr.bin/cc/cc_tools/freebsd-native.h
120 WANT_COMPILER_FREEBSD_VERSION!= \
121 awk '$$2 == "FBSD_CC_VER" {printf("%d\n", $$3)}' \
122 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
123 WANT_COMPILER_VERSION_FILE= contrib/gcc/BASE-VER
124 WANT_COMPILER_VERSION!= \
125 awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3}' \
126 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
128 .export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION
129 .endif # !defined(WANT_COMPILER_FREEBSD_VERSION)
130 # It needs to be the same revision as we would build for the bootstrap.
131 # If the expected vs CC is different then we can't skip.
132 # GCC cannot be used for cross-arch yet. For clang we pass -target later if
133 # TARGET_ARCH!=MACHINE_ARCH.
134 .if ${MK_SYSTEM_COMPILER} == "yes" && \
135 (${MK_CLANG_BOOTSTRAP} == "yes" || ${MK_GCC_BOOTSTRAP} == "yes") && \
136 !make(showconfig) && !make(native-xtools) && !make(xdev*) && \
137 ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE} && \
138 (${COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \
139 ${COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \
140 ${COMPILER_FREEBSD_VERSION} == ${WANT_COMPILER_FREEBSD_VERSION}
141 # Everything matches, disable the bootstrap compiler.
142 MK_CLANG_BOOTSTRAP= no
144 USING_SYSTEM_COMPILER= yes
145 .endif # ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE}
146 USING_SYSTEM_COMPILER?= no
147 TEST_SYSTEM_COMPILER_VARS= \
148 USING_SYSTEM_COMPILER MK_SYSTEM_COMPILER \
149 MK_CROSS_COMPILER MK_CLANG_BOOTSTRAP MK_GCC_BOOTSTRAP \
150 WANT_COMPILER_TYPE WANT_COMPILER_VERSION WANT_COMPILER_VERSION_FILE \
151 WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \
152 CC COMPILER_TYPE COMPILER_FEATURES COMPILER_VERSION \
153 COMPILER_FREEBSD_VERSION \
154 LINKER_TYPE LINKER_FEATURES LINKER_VERSION
155 test-system-compiler: .PHONY
156 .for v in ${TEST_SYSTEM_COMPILER_VARS}
157 ${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}"
159 .if ${USING_SYSTEM_COMPILER} == "yes" && \
160 (make(buildworld) || make(buildkernel) || make(kernel-toolchain) || \
161 make(toolchain) || make(_cross-tools))
162 .info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler.
165 # For installworld need to ensure that the looked-up compiler metadata is
166 # passed along rather than trying to run cc from the restricted
168 .if ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
169 .if !defined(X_COMPILER_TYPE)
170 CROSSENV+= COMPILER_VERSION=${COMPILER_VERSION} \
171 COMPILER_TYPE=${COMPILER_TYPE} \
172 COMPILER_FEATURES="${COMPILER_FEATURES}" \
173 COMPILER_FREEBSD_VERSION=${COMPILER_FREEBSD_VERSION}
175 CROSSENV+= COMPILER_VERSION=${X_COMPILER_VERSION} \
176 COMPILER_FEATURES="${X_COMPILER_FEATURES}" \
177 COMPILER_TYPE=${X_COMPILER_TYPE} \
178 COMPILER_FREEBSD_VERSION=${X_COMPILER_FREEBSD_VERSION}
181 # Store some compiler metadata for use in installworld where we don't
182 # want to invoke CC at all.
183 _COMPILER_METADATA_VARS= COMPILER_VERSION \
186 COMPILER_FREEBSD_VERSION \
190 compiler-metadata.mk: .PHONY .META
192 @echo ".info Using cached compiler metadata from build at $$(hostname) on $$(date)" \
194 @echo "_LOADED_COMPILER_METADATA=t" >> ${.TARGET}
195 .for v in ${_COMPILER_METADATA_VARS}
196 @echo "${v}=${${v}}" >> ${.TARGET}
198 @echo ".export ${_COMPILER_METADATA_VARS}" >> ${.TARGET}
200 # Handle external binutils.
201 .if defined(CROSS_TOOLCHAIN_PREFIX)
202 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
204 # If we do not have a bootstrap binutils (because the in-tree one does not
205 # support the target architecture), provide a default cross-binutils prefix.
206 # This allows riscv64 builds, for example, to automatically use the
207 # riscv64-binutils port or package.
208 .if !make(showconfig)
209 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
210 ${MK_LLD_BOOTSTRAP} == "no" && \
211 !defined(CROSS_BINUTILS_PREFIX)
212 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
213 .if !exists(${CROSS_BINUTILS_PREFIX})
214 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
218 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
219 .for BINUTIL in ${XBINUTILS}
220 .if defined(CROSS_BINUTILS_PREFIX) && \
221 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
222 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
224 X${BINUTIL}?= ${${BINUTIL}}
229 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
230 # keep the users system reasonably usable. For static->dynamic root upgrades,
231 # we don't want to install a dynamic binary without rtld and the needed
232 # libraries. More commonly, for dynamic root, we don't want to install a
233 # binary that requires a newer library version that hasn't been installed yet.
234 # This ordering is not a guarantee though. The only guarantee of a working
235 # system here would require fine-grained ordering of all components based
236 # on their dependencies.
237 .if !empty(SUBDIR_OVERRIDE)
238 SUBDIR= ${SUBDIR_OVERRIDE}
241 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
242 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
243 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
244 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
245 _REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
247 .for _DIR in ${LOCAL_LIB_DIRS}
248 .if ${_DIR} == ".WAIT" || (empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
252 .if !defined(NO_ROOT) && (make(installworld) || make(install))
253 # Ensure libraries are installed before progressing.
257 .if ${MK_CDDL} != "no"
261 .if ${MK_KERBEROS} != "no"
264 .if ${MK_RESCUE} != "no"
268 .if ${MK_CRYPT} != "no"
271 .if !defined(NO_SHARE)
274 .if ${MK_BOOT} != "no"
277 SUBDIR+=sys usr.bin usr.sbin
278 .if ${MK_TESTS} != "no"
282 # Local directories are built in parallel with the base system directories.
283 # Users may insert a .WAIT directive at the beginning or elsewhere within
284 # the LOCAL_DIRS and LOCAL_LIB_DIRS lists as needed.
285 .for _DIR in ${LOCAL_DIRS}
286 .if ${_DIR} == ".WAIT" || exists(${.CURDIR}/${_DIR}/Makefile)
291 # We must do etc/ last as it hooks into building the man whatis file
292 # by calling 'makedb' in share/man. This is only relevant for
293 # install/distribute so they build the whatis file after every manpage is
295 .if make(installworld) || make(install)
300 .endif # !empty(SUBDIR_OVERRIDE)
303 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
306 .if defined(NO_CLEANDIR)
307 CLEANDIR= clean cleandepend
312 .if ${MK_META_MODE} == "yes"
313 # If filemon is used then we can rely on the build being incremental-safe.
314 # The .meta files will also track the build command and rebuild should
316 .if empty(.MAKE.MODE:Mnofilemon)
322 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
324 .if empty(SHELL:M*csh*)
325 BUILDENV_SHELL?=${SHELL}
327 BUILDENV_SHELL?=/bin/sh
330 .if !defined(SVN) || empty(SVN)
331 . for _P in /usr/bin /usr/local/bin
332 . for _S in svn svnlite
333 . if exists(${_P}/${_S})
341 .if !defined(OSRELDATE)
342 .if exists(/usr/include/osreldate.h)
343 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
344 /usr/include/osreldate.h
351 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
352 .if !defined(_REVISION)
353 _REVISION!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V REVISION
356 .if !defined(_BRANCH)
357 _BRANCH!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V BRANCH
360 .if !defined(SRCRELDATE)
361 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
362 ${SRCDIR}/sys/sys/param.h
365 .if !defined(VERSION)
366 VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
370 .if !defined(PKG_VERSION)
371 .if ${_BRANCH:MSTABLE*} || ${_BRANCH:MCURRENT*} || ${_BRANCH:MALPHA*}
372 TIMENOW= %Y%m%d%H%M%S
373 EXTRA_REVISION= .s${TIMENOW:gmtime}
376 EXTRA_REVISION= _${_BRANCH:C/.*-p([0-9]+$)/\1/}
378 PKG_VERSION= ${_REVISION}${EXTRA_REVISION}
381 KNOWN_ARCHES?= aarch64/arm64 \
399 .if ${TARGET} == ${TARGET_ARCH}
402 _t= ${TARGET_ARCH}/${TARGET}
405 .if empty(KNOWN_ARCHES:M${_t})
406 .error Unknown target ${TARGET_ARCH}:${TARGET}.
410 .if ${TARGET} == ${MACHINE}
411 TARGET_CPUTYPE?=${CPUTYPE}
416 .if !empty(TARGET_CPUTYPE)
417 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
419 _TARGET_CPUTYPE=dummy
421 _CPUTYPE!= MK_AUTO_OBJ=no MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
422 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
423 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
424 .error CPUTYPE global should be set with ?=.
427 BUILD_ARCH!= uname -p
428 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
429 .error To cross-build, set TARGET_ARCH.
432 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
433 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
434 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
435 STRICTTMPPATH= ${BPATH}:${XPATH}
436 TMPPATH= ${STRICTTMPPATH}:${PATH}
439 # Avoid running mktemp(1) unless actually needed.
440 # It may not be functional, e.g., due to new ABI
441 # when in the middle of installing over this system.
443 .if make(distributeworld) || make(installworld) || make(stageworld)
444 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
447 .if make(stagekernel) || make(distributekernel)
453 # Building a world goes through the following stages
455 # 1. legacy stage [BMAKE]
456 # This stage is responsible for creating compatibility
457 # shims that are needed by the bootstrap-tools,
458 # build-tools and cross-tools stages. These are generally
459 # APIs that tools from one of those three stages need to
460 # build that aren't present on the host.
461 # 1. bootstrap-tools stage [BMAKE]
462 # This stage is responsible for creating programs that
463 # are needed for backward compatibility reasons. They
464 # are not built as cross-tools.
465 # 2. build-tools stage [TMAKE]
466 # This stage is responsible for creating the object
467 # tree and building any tools that are needed during
468 # the build process. Some programs are listed during
469 # this phase because they build binaries to generate
470 # files needed to build these programs. This stage also
471 # builds the 'build-tools' target rather than 'all'.
472 # 3. cross-tools stage [XMAKE]
473 # This stage is responsible for creating any tools that
474 # are needed for building the system. A cross-compiler is one
475 # of them. This differs from build tools in two ways:
476 # 1. the 'all' target is built rather than 'build-tools'
477 # 2. these tools are installed into TMPPATH for stage 4.
478 # 4. world stage [WMAKE]
479 # This stage actually builds the world.
480 # 5. install stage (optional) [IMAKE]
481 # This stage installs a previously built world.
486 MINIMUM_SUPPORTED_OSREL?= 900044
487 MINIMUM_SUPPORTED_REL?= 9.1
489 # Common environment for world related stages
490 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
491 MACHINE_ARCH=${TARGET_ARCH} \
493 CPUTYPE=${TARGET_CPUTYPE}
494 .if ${MK_META_MODE} != "no"
495 # Don't rebuild build-tools targets during normal build.
496 CROSSENV+= BUILD_TOOLS_META=.NOMETA
498 .if ${MK_GROFF} != "no"
499 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
500 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
501 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
503 .if defined(TARGET_CFLAGS)
504 CROSSENV+= ${TARGET_CFLAGS}
507 # bootstrap-tools stage
508 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
509 TOOLS_PREFIX=${WORLDTMP} \
510 PATH=${BPATH}:${PATH} \
511 WORLDTMP=${WORLDTMP} \
512 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
513 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
515 BOOTSTRAPPING=${OSRELDATE} \
517 MK_HTML=no NO_LINT=yes MK_MAN=no \
518 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
519 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
520 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
521 MK_LLDB=no MK_TESTS=no \
524 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
525 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
529 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
530 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
531 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
533 BOOTSTRAPPING=${OSRELDATE} \
536 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
537 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
538 MK_LLDB=no MK_TESTS=no
541 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
542 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
543 MK_GDB=no MK_TESTS=no
546 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
547 PATH=${BPATH}:${PATH} \
549 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
550 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
552 BOOTSTRAPPING=${OSRELDATE} \
554 MK_HTML=no -DNO_LINT MK_MAN=no \
555 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
556 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
559 WMAKEENV= ${CROSSENV} \
560 INSTALL="sh ${.CURDIR}/tools/install.sh" \
564 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
566 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
569 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
570 CPP="${XCPP} ${XCFLAGS}" \
571 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
572 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
573 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
576 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
577 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
578 # directory, but the compiler will look in the right place for its
579 # tools so we don't need to tell it where to look.
580 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
583 # External compiler needs sysroot and target flags.
584 .if ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
585 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
586 BFLAGS+= -B${WORLDTMP}/usr/bin
588 .if ${TARGET} == "arm"
589 .if ${TARGET_ARCH:Marmv6*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
590 TARGET_ABI= gnueabihf
595 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
596 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
597 # won't set header path and -L is used to ensure the base library path
598 # is added before the port PREFIX library path.
599 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
600 # Force using libc++ for external GCC.
601 .if ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
602 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
603 -nostdinc++ -L${WORLDTMP}/../lib/libc++
607 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.2
608 XCFLAGS+= -target ${TARGET_TRIPLE}
610 XCFLAGS+= --sysroot=${WORLDTMP}
611 .endif # ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
617 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
618 ${TARGET_ARCH} == "powerpc64")
620 .include "Makefile.libcompat"
621 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH} == "armv6"
623 .include "Makefile.libcompat"
626 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
628 IMAKEENV= ${CROSSENV}
629 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
630 ${IMAKE_INSTALL} ${IMAKE_MTREE}
631 .if empty(.MAKEFLAGS:M-n)
632 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
633 LD_LIBRARY_PATH=${INSTALLTMP} \
634 PATH_LOCALE=${INSTALLTMP}/locale
635 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
637 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
639 .if defined(DB_FROM_SRC)
640 INSTALLFLAGS+= -N ${.CURDIR}/etc
641 MTREEFLAGS+= -N ${.CURDIR}/etc
643 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
644 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
646 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
647 METALOG:= ${METALOG:C,//+,/,g}
648 IMAKE+= -DNO_ROOT METALOG=${METALOG}
649 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
652 .if defined(BUILD_PKGS)
653 INSTALLFLAGS+= -h sha256
655 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
656 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
657 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
661 KMAKEENV= ${WMAKEENV}
662 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
667 # Attempt to rebuild the entire system, with reasonable chance of
668 # success, regardless of how old your existing system is.
671 .if ${.CURDIR:C/[^,]//g} != ""
672 # The m4 build of sendmail files doesn't like it if ',' is used
673 # anywhere in the path of it's files.
675 @echo "*** Error: path to source tree contains a comma ','"
680 @echo "--------------------------------------------------------------"
681 @echo ">>> Rebuilding the temporary build tree"
682 @echo "--------------------------------------------------------------"
683 .if !defined(NO_CLEAN)
685 .if defined(LIBCOMPAT)
686 rm -rf ${LIBCOMPATTMP}
689 rm -rf ${WORLDTMP}/legacy/usr/include
690 .if ${USING_SYSTEM_COMPILER} == "yes"
692 if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \
693 inum=$$(stat -f %i ${WORLDTMP}/usr/bin/${cc}); \
694 find ${WORLDTMP}/usr/bin -inum $${inum} -delete; \
697 .endif # ${USING_SYSTEM_COMPILER} == "yes"
698 .endif # !defined(NO_CLEAN)
700 lib lib/casper usr legacy/bin legacy/usr
701 mkdir -p ${WORLDTMP}/${_dir}
703 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
704 -p ${WORLDTMP}/legacy/usr >/dev/null
705 .if ${MK_GROFF} != "no"
706 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
707 -p ${WORLDTMP}/legacy/usr >/dev/null
709 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
710 -p ${WORLDTMP}/legacy/usr/include >/dev/null
711 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
712 -p ${WORLDTMP}/usr >/dev/null
713 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
714 -p ${WORLDTMP}/usr/include >/dev/null
715 ln -sf ${.CURDIR}/sys ${WORLDTMP}
716 .if ${MK_DEBUG_FILES} != "no"
717 # We could instead disable debug files for these build stages
718 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
719 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
720 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
721 -p ${WORLDTMP}/usr/lib >/dev/null
723 .if defined(LIBCOMPAT)
724 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
725 -p ${WORLDTMP}/usr >/dev/null
726 .if ${MK_DEBUG_FILES} != "no"
727 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
728 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
729 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
730 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
733 .if ${MK_TESTS} != "no"
734 mkdir -p ${WORLDTMP}${TESTSBASE}
735 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
736 -p ${WORLDTMP}${TESTSBASE} >/dev/null
737 .if ${MK_DEBUG_FILES} != "no"
738 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
739 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
740 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
743 .for _mtree in ${LOCAL_MTREE}
744 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
748 @echo "--------------------------------------------------------------"
749 @echo ">>> stage 1.1: legacy release compatibility shims"
750 @echo "--------------------------------------------------------------"
751 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
754 @echo "--------------------------------------------------------------"
755 @echo ">>> stage 1.2: bootstrap tools"
756 @echo "--------------------------------------------------------------"
757 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
759 .if !defined(NO_CLEAN)
761 @echo "--------------------------------------------------------------"
762 @echo ">>> stage 2.1: cleaning up the object tree"
763 @echo "--------------------------------------------------------------"
764 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
765 .if defined(LIBCOMPAT)
766 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
771 @echo "--------------------------------------------------------------"
772 @echo ">>> stage 2.2: rebuilding the object tree"
773 @echo "--------------------------------------------------------------"
774 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
777 @echo "--------------------------------------------------------------"
778 @echo ">>> stage 2.3: build tools"
779 @echo "--------------------------------------------------------------"
780 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
783 @echo "--------------------------------------------------------------"
784 @echo ">>> stage 3: cross tools"
785 @echo "--------------------------------------------------------------"
786 @rm -f ${.OBJDIR}/compiler-metadata.mk
787 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
788 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
791 @echo "--------------------------------------------------------------"
792 @echo ">>> stage 3.1: recording compiler metadata"
793 @echo "--------------------------------------------------------------"
794 ${_+_}cd ${.CURDIR}; ${WMAKE} compiler-metadata.mk
797 @echo "--------------------------------------------------------------"
798 @echo ">>> stage 4.1: building includes"
799 @echo "--------------------------------------------------------------"
800 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
801 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
802 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
803 MK_INCLUDES=yes includes
804 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
805 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
809 @echo "--------------------------------------------------------------"
810 @echo ">>> stage 4.2: building libraries"
811 @echo "--------------------------------------------------------------"
812 ${_+_}cd ${.CURDIR}; \
813 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
814 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
817 @echo "--------------------------------------------------------------"
818 @echo ">>> stage 4.3: building everything"
819 @echo "--------------------------------------------------------------"
820 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
823 WMAKE_TGTS+= _worldtmp _legacy
824 .if empty(SUBDIR_OVERRIDE)
825 WMAKE_TGTS+= _bootstrap-tools
827 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
828 WMAKE_TGTS+= _compiler-metadata
829 WMAKE_TGTS+= _includes _libraries
830 WMAKE_TGTS+= everything
831 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
832 WMAKE_TGTS+= build${libcompat}
835 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
836 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
838 buildworld_prologue: .PHONY
839 @echo "--------------------------------------------------------------"
840 @echo ">>> World build started on `LC_ALL=C date`"
841 @echo "--------------------------------------------------------------"
843 buildworld_epilogue: .PHONY
845 @echo "--------------------------------------------------------------"
846 @echo ">>> World build completed on `LC_ALL=C date`"
847 @echo "--------------------------------------------------------------"
850 # We need to have this as a target because the indirection between Makefile
851 # and Makefile.inc1 causes the correct PATH to be used, rather than a
852 # modification of the current environment's PATH. In addition, we need
853 # to quote multiword values.
856 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
858 .if ${.TARGETS:Mbuildenv}
859 .if ${.MAKEFLAGS:M-j}
860 .error The buildenv target is incompatible with -j
863 BUILDENV_DIR?= ${.CURDIR}
865 # Note: make will report any errors the shell reports. This can
866 # be odd if the last command in an interactive shell generates an
867 # error or is terminated by SIGINT. These reported errors look bad,
868 # but are harmless. Allowing them also allows BUIDLENV_SHELL to
869 # be a complex command whose status will be returned to the caller.
870 # Some scripts in tools rely on this behavior to report build errors.
873 @echo Entering world for ${TARGET_ARCH}:${TARGET}
874 .if ${BUILDENV_SHELL:M*zsh*}
875 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
877 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL}
879 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
880 toolchain: ${TOOLCHAIN_TGTS} .PHONY
881 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries} .PHONY
886 # Checks to be sure system is ready for installworld/installkernel.
888 installcheck: _installcheck_world _installcheck_kernel .PHONY
889 _installcheck_world: .PHONY
890 _installcheck_kernel: .PHONY
893 # Require DESTDIR to be set if installing for a different architecture or
894 # using the user/group database in the source tree.
896 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
898 .if !make(distributeworld)
899 _installcheck_world: __installcheck_DESTDIR
900 _installcheck_kernel: __installcheck_DESTDIR
901 __installcheck_DESTDIR: .PHONY
902 .if !defined(DESTDIR) || empty(DESTDIR)
903 @echo "ERROR: Please set DESTDIR!"; \
909 .if !defined(DB_FROM_SRC)
911 # Check for missing UIDs/GIDs.
913 CHECK_UIDS= auditdistd
915 .if ${MK_SENDMAIL} != "no"
921 CHECK_GIDS+= proxy authpf
923 .if ${MK_UNBOUND} != "no"
927 _installcheck_world: __installcheck_UGID
928 __installcheck_UGID: .PHONY
929 .for uid in ${CHECK_UIDS}
930 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
931 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
935 .for gid in ${CHECK_GIDS}
936 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
937 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
943 # If installing over the running system (DESTDIR is / or unset) and the install
944 # includes rescue, try running rescue from the objdir as a sanity check. If
945 # rescue is not functional (e.g., because it depends on a system call not
946 # supported by the currently running kernel), abort the installation.
948 .if !make(distributeworld) && ${MK_RESCUE} != "no" && \
949 (empty(DESTDIR) || ${DESTDIR} == "/") && empty(BYPASS_INSTALLCHECK_SH)
950 _installcheck_world: __installcheck_sh_check
951 __installcheck_sh_check: .PHONY
952 @if [ "`${OBJTREE}${.CURDIR}/rescue/rescue/rescue sh -c 'echo OK'`" != \
954 echo "rescue/sh check failed, installation aborted" >&2; \
960 # Required install tools to be saved in a scratch dir for safety.
962 .if ${MK_ZONEINFO} != "no"
963 _zoneinfo= zic tzsetup
966 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
967 date echo egrep find grep id install ${_install-info} \
968 ln make mkdir mtree mv pwd_mkdb \
969 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
972 # Needed for share/man
973 .if ${MK_MAN_UTILS} != "no"
980 # Distributes everything compiled by a `buildworld'.
984 # Installs everything compiled by a 'buildworld'.
987 # Non-base distributions produced by the base system
988 EXTRA_DISTRIBUTIONS= doc
989 .if defined(LIBCOMPAT)
990 EXTRA_DISTRIBUTIONS+= lib${libcompat}
992 .if ${MK_TESTS} != "no"
993 EXTRA_DISTRIBUTIONS+= tests
997 .if ${MK_DEBUG_FILES} != "no"
998 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
1001 MTREE_MAGIC?= mtree 2.0
1003 distributeworld installworld stageworld: _installcheck_world .PHONY
1004 mkdir -p ${INSTALLTMP}
1005 progs=$$(for prog in ${ITOOLS}; do \
1006 if progpath=`which $$prog`; then \
1009 echo "Required tool $$prog not found in PATH." >&2; \
1013 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
1014 while read line; do \
1016 if [ "$$2 $$3" != "not found" ]; then \
1019 echo "Required library $$1 not found." >&2; \
1023 cp $$libs $$progs ${INSTALLTMP}
1024 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
1025 .if defined(NO_ROOT)
1026 -mkdir -p ${METALOG:H}
1027 echo "#${MTREE_MAGIC}" > ${METALOG}
1029 .if make(distributeworld)
1030 .for dist in ${EXTRA_DISTRIBUTIONS}
1031 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
1032 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1033 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
1034 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1035 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1036 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1037 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
1038 .if ${MK_DEBUG_FILES} != "no"
1039 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1040 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
1042 .if defined(LIBCOMPAT)
1043 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1044 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1045 .if ${MK_DEBUG_FILES} != "no"
1046 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1047 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
1050 .if ${MK_TESTS} != "no" && ${dist} == "tests"
1051 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
1052 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1053 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
1054 .if ${MK_DEBUG_FILES} != "no"
1055 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1056 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
1059 .if defined(NO_ROOT)
1060 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1061 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1062 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1063 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1064 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1065 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1066 .if defined(LIBCOMPAT)
1067 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
1068 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1072 -mkdir ${DESTDIR}/${DISTDIR}/base
1073 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1074 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1075 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1076 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1078 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1079 ${IMAKEENV} rm -rf ${INSTALLTMP}
1080 .if make(distributeworld)
1081 .for dist in ${EXTRA_DISTRIBUTIONS}
1082 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete
1084 .if defined(NO_ROOT)
1085 .for dist in base ${EXTRA_DISTRIBUTIONS}
1086 @# For each file that exists in this dist, print the corresponding
1087 @# line from the METALOG. This relies on the fact that
1088 @# a line containing only the filename will sort immediately before
1089 @# the relevant mtree line.
1090 cd ${DESTDIR}/${DISTDIR}; \
1091 find ./${dist} | sort -u ${METALOG} - | \
1092 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1093 ${DESTDIR}/${DISTDIR}/${dist}.meta
1095 .for dist in ${DEBUG_DISTRIBUTIONS}
1096 @# For each file that exists in this dist, print the corresponding
1097 @# line from the METALOG. This relies on the fact that
1098 @# a line containing only the filename will sort immediately before
1099 @# the relevant mtree line.
1100 cd ${DESTDIR}/${DISTDIR}; \
1101 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1102 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1103 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1108 packageworld: .PHONY
1109 .for dist in base ${EXTRA_DISTRIBUTIONS}
1110 .if defined(NO_ROOT)
1111 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1112 tar cvf - --exclude usr/lib/debug \
1113 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1114 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1116 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1117 tar cvf - --exclude usr/lib/debug . | \
1118 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1122 .for dist in ${DEBUG_DISTRIBUTIONS}
1123 . if defined(NO_ROOT)
1124 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1125 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1126 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1128 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1129 tar cvLf - usr/lib/debug | \
1130 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1137 # If you have a build server, you can NFS mount the source and obj directories
1138 # and do a 'make reinstall' on the *client* to install new binaries from the
1139 # most recent server build.
1141 restage reinstall: .MAKE .PHONY
1142 @echo "--------------------------------------------------------------"
1143 @echo ">>> Making hierarchy"
1144 @echo "--------------------------------------------------------------"
1145 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1146 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1148 @echo "--------------------------------------------------------------"
1149 @echo ">>> Making distribution"
1150 @echo "--------------------------------------------------------------"
1151 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1152 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
1155 @echo "--------------------------------------------------------------"
1156 @echo ">>> Installing everything"
1157 @echo "--------------------------------------------------------------"
1158 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1159 .if defined(LIBCOMPAT)
1160 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1163 redistribute: .MAKE .PHONY
1164 @echo "--------------------------------------------------------------"
1165 @echo ">>> Distributing everything"
1166 @echo "--------------------------------------------------------------"
1167 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1168 .if defined(LIBCOMPAT)
1169 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1170 DISTRIBUTION=lib${libcompat}
1173 distrib-dirs distribution: .MAKE .PHONY
1174 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1175 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1176 .if make(distribution)
1177 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1178 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1179 METALOG=${METALOG} MK_TESTS=no installconfig
1183 # buildkernel and installkernel
1185 # Which kernels to build and/or install is specified by setting
1186 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1187 # Only the existing (depending TARGET) config files are used
1188 # for building kernels and only the first of these is designated
1189 # as the one being installed.
1191 # Note that we have to use TARGET instead of TARGET_ARCH when
1192 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1193 # be set to cross-build, we have to make sure TARGET is set
1196 .if defined(KERNFAST)
1200 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1201 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1202 KERNCONF=${KERNFAST}
1205 .if ${TARGET_ARCH} == "powerpc64"
1206 KERNCONF?= GENERIC64
1210 INSTKERNNAME?= kernel
1212 KERNSRCDIR?= ${.CURDIR}/sys
1213 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1214 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1215 KERNCONFDIR?= ${KRNLCONFDIR}
1219 .if defined(NO_INSTALLKERNEL)
1220 # All of the BUILDKERNELS loops start at index 1.
1221 BUILDKERNELS+= dummy
1223 .for _kernel in ${KERNCONF}
1224 .if exists(${KERNCONFDIR}/${_kernel})
1225 BUILDKERNELS+= ${_kernel}
1226 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1227 INSTALLKERNEL= ${_kernel}
1230 .if make(buildkernel)
1231 .error Missing KERNCONF ${KERNCONFDIR}/${_kernel}
1236 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1241 # Builds all kernels defined by BUILDKERNELS.
1243 buildkernel: .MAKE .PHONY
1244 .if empty(BUILDKERNELS:Ndummy)
1245 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1249 .for _kernel in ${BUILDKERNELS:Ndummy}
1250 @echo "--------------------------------------------------------------"
1251 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1252 @echo "--------------------------------------------------------------"
1253 @echo "===> ${_kernel}"
1254 mkdir -p ${KRNLOBJDIR}
1255 .if !defined(NO_KERNELCONFIG)
1257 @echo "--------------------------------------------------------------"
1258 @echo ">>> stage 1: configuring the kernel"
1259 @echo "--------------------------------------------------------------"
1260 cd ${KRNLCONFDIR}; \
1262 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1263 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1265 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1267 @echo "--------------------------------------------------------------"
1268 @echo ">>> stage 2.1: cleaning up the object tree"
1269 @echo "--------------------------------------------------------------"
1270 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1272 .if !defined(NO_KERNELOBJ)
1274 @echo "--------------------------------------------------------------"
1275 @echo ">>> stage 2.2: rebuilding the object tree"
1276 @echo "--------------------------------------------------------------"
1277 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1280 @echo "--------------------------------------------------------------"
1281 @echo ">>> stage 2.3: build tools"
1282 @echo "--------------------------------------------------------------"
1283 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1285 @echo "--------------------------------------------------------------"
1286 @echo ">>> stage 3.1: building everything"
1287 @echo "--------------------------------------------------------------"
1288 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1289 @echo "--------------------------------------------------------------"
1290 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1291 @echo "--------------------------------------------------------------"
1294 NO_INSTALLEXTRAKERNELS?= yes
1297 # installkernel, etc.
1299 # Install the kernel defined by INSTALLKERNEL
1301 installkernel installkernel.debug \
1302 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1303 .if !defined(NO_INSTALLKERNEL)
1304 .if empty(INSTALLKERNEL)
1305 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1308 @echo "--------------------------------------------------------------"
1309 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1310 @echo "--------------------------------------------------------------"
1311 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1312 ${CROSSENV} PATH=${TMPPATH} \
1313 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1315 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1316 .for _kernel in ${BUILDKERNELS:[2..-1]}
1317 @echo "--------------------------------------------------------------"
1318 @echo ">>> Installing kernel ${_kernel}"
1319 @echo "--------------------------------------------------------------"
1320 cd ${KRNLOBJDIR}/${_kernel}; \
1321 ${CROSSENV} PATH=${TMPPATH} \
1322 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1326 distributekernel distributekernel.debug: .PHONY
1327 .if !defined(NO_INSTALLKERNEL)
1328 .if empty(INSTALLKERNEL)
1329 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1332 mkdir -p ${DESTDIR}/${DISTDIR}
1333 .if defined(NO_ROOT)
1334 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1336 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1337 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1338 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1339 DESTDIR=${INSTALL_DDIR}/kernel \
1340 ${.TARGET:S/distributekernel/install/}
1341 .if defined(NO_ROOT)
1342 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1343 ${DESTDIR}/${DISTDIR}/kernel.meta
1346 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1347 .for _kernel in ${BUILDKERNELS:[2..-1]}
1348 .if defined(NO_ROOT)
1349 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1351 cd ${KRNLOBJDIR}/${_kernel}; \
1352 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1353 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1354 KERNEL=${INSTKERNNAME}.${_kernel} \
1355 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1356 ${.TARGET:S/distributekernel/install/}
1357 .if defined(NO_ROOT)
1358 @sed -e "s|^./kernel.${_kernel}|.|" \
1359 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1360 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1365 packagekernel: .PHONY
1366 .if defined(NO_ROOT)
1367 .if !defined(NO_INSTALLKERNEL)
1368 cd ${DESTDIR}/${DISTDIR}/kernel; \
1369 tar cvf - --exclude '*.debug' \
1370 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1371 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1373 .if ${MK_DEBUG_FILES} != "no"
1374 cd ${DESTDIR}/${DISTDIR}/kernel; \
1375 tar cvf - --include '*/*/*.debug' \
1376 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1377 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1379 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1380 .for _kernel in ${BUILDKERNELS:[2..-1]}
1381 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1382 tar cvf - --exclude '*.debug' \
1383 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1384 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1385 .if ${MK_DEBUG_FILES} != "no"
1386 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1387 tar cvf - --include '*/*/*.debug' \
1388 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1389 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1394 .if !defined(NO_INSTALLKERNEL)
1395 cd ${DESTDIR}/${DISTDIR}/kernel; \
1396 tar cvf - --exclude '*.debug' . | \
1397 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1399 .if ${MK_DEBUG_FILES} != "no"
1400 cd ${DESTDIR}/${DISTDIR}/kernel; \
1401 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1402 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1404 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1405 .for _kernel in ${BUILDKERNELS:[2..-1]}
1406 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1407 tar cvf - --exclude '*.debug' . | \
1408 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1409 .if ${MK_DEBUG_FILES} != "no"
1410 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1411 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1412 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1419 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1421 PORTSDIR?= /usr/ports
1422 WSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/worldstage
1423 KSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/kernelstage
1424 REPODIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/repo
1425 PKGSIGNKEY?= # empty
1427 .ORDER: stage-packages create-packages
1428 .ORDER: create-packages create-world-packages
1429 .ORDER: create-packages create-kernel-packages
1430 .ORDER: create-packages sign-packages
1432 _pkgbootstrap: .PHONY
1433 .if !exists(${LOCALBASE}/sbin/pkg)
1434 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1438 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1441 rm -rf /tmp/ports.${TARGET} || :
1442 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
1443 PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \
1444 WSTAGEDIR=${WSTAGEDIR} \
1445 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1447 real-packages: stage-packages create-packages sign-packages .PHONY
1449 stage-packages: .PHONY
1450 @mkdir -p ${REPODIR} ${WSTAGEDIR} ${KSTAGEDIR}
1451 ${_+_}@cd ${.CURDIR}; \
1452 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT -B stageworld ; \
1453 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT -B stagekernel
1455 create-packages: _pkgbootstrap .PHONY
1456 @mkdir -p ${REPODIR}
1457 ${_+_}@cd ${.CURDIR}; \
1458 ${MAKE} DESTDIR=${WSTAGEDIR} \
1459 PKG_VERSION=${PKG_VERSION} create-world-packages ; \
1460 ${MAKE} DESTDIR=${KSTAGEDIR} \
1461 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1462 create-kernel-packages
1464 create-world-packages: _pkgbootstrap .PHONY
1465 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1466 @cd ${WSTAGEDIR} ; \
1467 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1468 ${WSTAGEDIR}/METALOG
1469 @for plist in ${WSTAGEDIR}/*.plist; do \
1470 plist=$${plist##*/} ; \
1471 pkgname=$${plist%.plist} ; \
1472 sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \
1473 -s ${SRCDIR} -u ${WSTAGEDIR}/$${pkgname}.ucl ; \
1475 @for plist in ${WSTAGEDIR}/*.plist; do \
1476 plist=$${plist##*/} ; \
1477 pkgname=$${plist%.plist} ; \
1479 /^name/ { printf("===> Creating %s-", $$2); next } \
1480 /^version/ { print $$2; next } \
1481 ' ${WSTAGEDIR}/$${pkgname}.ucl ; \
1482 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1483 create -M ${WSTAGEDIR}/$${pkgname}.ucl \
1484 -p ${WSTAGEDIR}/$${pkgname}.plist \
1486 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} ; \
1489 create-kernel-packages: _pkgbootstrap .PHONY
1490 .if exists(${KSTAGEDIR}/kernel.meta)
1491 .if ${MK_DEBUG_FILES} != "no"
1494 .for flavor in "" ${_debug}
1495 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1496 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1497 -v kernel=yes -v _kernconf=${INSTALLKERNEL} \
1498 ${KSTAGEDIR}/kernel.meta ; \
1499 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1500 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1501 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1502 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1503 -e "s/%KERNELDIR%/kernel/" \
1504 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1505 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1506 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1507 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1508 ${SRCDIR}/release/packages/kernel.ucl \
1509 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1511 /name/ { printf("===> Creating %s-", $$2); next } \
1512 /version/ {print $$2; next } ' \
1513 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1514 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1515 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1516 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1517 -r ${KSTAGEDIR}/${DISTDIR} \
1518 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1521 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1522 .for _kernel in ${BUILDKERNELS:[2..-1]}
1523 .if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1524 .if ${MK_DEBUG_FILES} != "no"
1527 .for flavor in "" ${_debug}
1528 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1529 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1530 -v kernel=yes -v _kernconf=${_kernel} \
1531 ${KSTAGEDIR}/kernel.${_kernel}.meta ; \
1532 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1533 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1534 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1535 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1536 -e "s/%KERNELDIR%/kernel.${_kernel}/" \
1537 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1538 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1539 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1540 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1541 ${SRCDIR}/release/packages/kernel.ucl \
1542 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1544 /name/ { printf("===> Creating %s-", $$2); next } \
1545 /version/ {print $$2; next } ' \
1546 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1547 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1548 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1549 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1550 -r ${KSTAGEDIR}/kernel.${_kernel} \
1551 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1557 sign-packages: _pkgbootstrap .PHONY
1558 @[ -L "${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1559 unlink ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1560 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1561 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1562 ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1564 cd ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI); \
1565 ln -s ${PKG_VERSION} latest
1571 # Run test suite on installed world.
1574 @if [ ! -x "${LOCALBASE}/bin/kyua" ]; then \
1575 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1578 ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile
1584 # Build the API documentation with doxygen
1587 @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \
1588 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1591 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1596 # Update the source tree(s), by running svn/svnup to update to the
1600 .if defined(SVN_UPDATE)
1601 @echo "--------------------------------------------------------------"
1602 @echo ">>> Updating ${.CURDIR} using Subversion"
1603 @echo "--------------------------------------------------------------"
1604 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1608 # ------------------------------------------------------------------------
1610 # From here onwards are utility targets used by the 'make world' and
1611 # related targets. If your 'world' breaks, you may like to try to fix
1612 # the problem and manually run the following targets to attempt to
1613 # complete the build. Beware, this is *not* guaranteed to work, you
1614 # need to have a pretty good grip on the current state of the system
1615 # to attempt to manually finish it. If in doubt, 'make world' again.
1619 # legacy: Build compatibility shims for the next three targets. This is a
1620 # minimal set of tools and shims necessary to compensate for older systems
1621 # which don't have the APIs required by the targets built in bootstrap-tools,
1622 # build-tools or cross-tools.
1625 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1626 # r296685 fix cross-endian objcopy
1627 .if ${BOOTSTRAPPING} < 1100102
1628 _elftoolchain_libs= lib/libelf lib/libdwarf
1632 .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
1633 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
1636 .for _tool in tools/build ${_elftoolchain_libs} lib/libnv
1637 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1638 cd ${.CURDIR}/${_tool}; \
1639 ${MAKE} DIRPRFX=${_tool}/ obj; \
1640 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1641 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
1642 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
1643 DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1647 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1648 # are built to build other binaries in the system. However, the focus of these
1649 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1650 # libraries, augmented by -legacy.
1652 _bt= _bootstrap-tools
1654 .if ${MK_GAMES} != "no"
1655 _strfile= usr.bin/fortune/strfile
1658 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1659 _gperf= gnu/usr.bin/gperf
1662 .if ${MK_SHAREDOCS} != "no" && ${MK_GROFF} != "no"
1663 _groff= gnu/usr.bin/groff \
1667 .if ${MK_VT} != "no"
1668 _vtfontcvt= usr.bin/vtfontcvt
1671 .if ${BOOTSTRAPPING} < 1000033
1672 _libopenbsd= lib/libopenbsd
1676 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1677 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1680 # r245440 mtree -N support added
1681 # r313404 requires sha384.h for libnetbsd, added to libmd in r292782
1682 .if ${BOOTSTRAPPING} < 1100093
1683 _nmtree= lib/libmd \
1687 ${_bt}-lib/libnetbsd: ${_bt}-lib/libmd
1688 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1691 .if ${BOOTSTRAPPING} < 1000027
1695 # r277259 crunchide: Correct 64-bit section header offset
1696 # r281674 crunchide: always include both 32- and 64-bit ELF support
1697 .if ${BOOTSTRAPPING} < 1100078
1698 _crunchide= usr.sbin/crunch/crunchide
1701 # r285986 crunchen: use STRIPBIN rather than STRIP
1702 # 1100113: Support MK_AUTO_OBJ
1703 # 1100509: META_MODE fixes
1704 .if ${BOOTSTRAPPING} < 1100078 || \
1705 (${MK_AUTO_OBJ} == "yes" && ${BOOTSTRAPPING} < 1100114) || \
1706 (${MK_META_MODE} == "yes" && ${BOOTSTRAPPING} < 1200006)
1707 _crunchgen= usr.sbin/crunch/crunchgen
1710 # r296926 -P keymap search path, MFC to stable/10 in r298297
1711 .if ${BOOTSTRAPPING} < 1003501 || \
1712 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
1713 _kbdcontrol= usr.sbin/kbdcontrol
1719 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1721 .if ${MK_BSNMP} != "no"
1722 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1725 # We need to build tblgen when we're building clang or lld, either as
1726 # bootstrap tools, or as the part of the normal build.
1727 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
1728 ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no"
1730 lib/clang/libllvmminimal \
1731 usr.bin/clang/llvm-tblgen \
1732 usr.bin/clang/clang-tblgen
1734 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal
1735 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal
1738 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1741 .if ${MK_GPL_DTC} != "no"
1742 _dtc= gnu/usr.bin/dtc
1745 .if ${MK_KERBEROS} != "no"
1746 _kerberos5_bootstrap_tools= \
1747 kerberos5/tools/make-roken \
1748 kerberos5/lib/libroken \
1749 kerberos5/lib/libvers \
1750 kerberos5/tools/asn1_compile \
1751 kerberos5/tools/slc \
1754 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1757 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
1758 .if ${MK_MANDOCDB} != "no"
1759 _libopenbsd?= lib/libopenbsd
1760 _makewhatis= usr.bin/mandoc
1761 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
1764 bootstrap-tools: .PHONY
1766 # Please document (add comment) why something is in 'bootstrap-tools'.
1767 # Try to bound the building of the bootstrap-tool to just the
1768 # FreeBSD versions that need the tool built at this stage of the build.
1771 ${_kerberos5_bootstrap_tools} \
1793 ${_bt}-${_tool}: .PHONY .MAKE
1794 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1795 cd ${.CURDIR}/${_tool}; \
1796 ${MAKE} DIRPRFX=${_tool}/ obj; \
1797 ${MAKE} DIRPRFX=${_tool}/ all; \
1798 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1800 bootstrap-tools: ${_bt}-${_tool}
1804 # build-tools: Build special purpose build tools
1806 .if !defined(NO_SHARE)
1807 _share= share/syscons/scrnmaps
1810 .if ${MK_GCC} != "no"
1811 _gcc_tools= gnu/usr.bin/cc/cc_tools
1814 .if ${MK_RESCUE} != "no"
1815 # rescue includes programs that have build-tools targets
1816 _rescue=rescue/rescue
1819 .if ${MK_TCSH} != "no"
1826 ${LOCAL_TOOL_DIRS} \
1827 lib/ncurses/ncurses \
1828 lib/ncurses/ncursesw \
1833 usr.bin/mkesdb_static \
1834 usr.bin/mkcsmapper_static \
1836 build-tools_${_tool}: .PHONY
1837 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1838 cd ${.CURDIR}/${_tool}; \
1839 ${MAKE} DIRPRFX=${_tool}/ obj; \
1840 ${MAKE} DIRPRFX=${_tool}/ build-tools
1841 build-tools: build-tools_${_tool}
1845 build-tools_${_tool}: .PHONY
1846 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \
1847 cd ${.CURDIR}/${_tool}; \
1848 ${MAKE} DIRPRFX=${_tool}/ obj; \
1849 ${MAKE} DIRPRFX=${_tool}/ all
1850 build-tools: build-tools_${_tool}
1854 # kernel-tools: Build kernel-building tools
1856 kernel-tools: .PHONY
1857 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1858 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1859 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1862 # cross-tools: All the tools needed to build the rest of the system after
1863 # we get done with the earlier stages. It is the last set of tools needed
1864 # to begin building the target binaries.
1866 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1867 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1868 _btxld= usr.sbin/btxld
1872 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1873 # resulting from missing bug fixes or ELF Toolchain updates.
1874 .if ${MK_CDDL} != "no"
1875 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1876 cddl/usr.bin/ctfmerge
1879 # If we're given an XAS, don't build binutils.
1880 .if ${XAS:M/*} == ""
1881 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1882 _binutils= gnu/usr.bin/binutils
1884 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1885 _elftctools= lib/libelftc \
1891 # These are not required by the build, but can be useful for developers who
1892 # cross-build on a FreeBSD 10 host:
1893 _elftctools+= usr.bin/addr2line
1895 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1896 # If cross-building with an external binutils we still need to build strip for
1897 # the target (for at least crunchide).
1898 _elftctools= lib/libelftc \
1903 .if ${MK_CLANG_BOOTSTRAP} != "no"
1904 _clang= usr.bin/clang
1906 .if ${MK_LLD_BOOTSTRAP} != "no"
1907 _lld= usr.bin/clang/lld
1909 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no"
1910 _clang_libs= lib/clang
1912 .if ${MK_GCC_BOOTSTRAP} != "no"
1913 _gcc= gnu/usr.bin/cc
1915 .if ${MK_USB} != "no"
1916 _usb_tools= stand/usb/tools
1919 cross-tools: .MAKE .PHONY
1930 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1931 cd ${.CURDIR}/${_tool}; \
1932 ${MAKE} DIRPRFX=${_tool}/ obj; \
1933 ${MAKE} DIRPRFX=${_tool}/ all; \
1934 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1937 NXBDESTDIR= ${OBJTREE}/nxb-bin
1938 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1940 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1941 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1942 NXBMAKE= ${NXBENV} ${MAKE} \
1943 LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \
1944 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1945 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1946 MK_GDB=no MK_TESTS=no \
1948 MK_HTML=no NO_LINT=yes MK_MAN=no \
1949 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1950 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1951 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1952 MK_LLDB=no MK_DEBUG_FILES=no
1954 # native-xtools is the current target for qemu-user cross builds of ports
1955 # via poudriere and the imgact_binmisc kernel module.
1956 # For non-clang enabled targets that are still using the in tree gcc
1957 # we must build a gperf binary for one instance of its Makefiles. On
1958 # clang-enabled systems, the gperf binary is obsolete.
1959 native-xtools: .PHONY
1960 .if ${MK_GCC_BOOTSTRAP} != "no"
1961 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1962 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \
1963 cd ${.CURDIR}/${_gperf}; \
1964 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1965 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1966 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1968 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1969 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1970 -p ${NXBDESTDIR}/usr >/dev/null
1971 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1972 -p ${NXBDESTDIR}/usr/include >/dev/null
1973 .if ${MK_DEBUG_FILES} != "no"
1974 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1975 -p ${NXBDESTDIR}/usr/lib >/dev/null
2037 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2038 cd ${.CURDIR}/${_tool}; \
2039 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
2040 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
2041 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
2045 # hierarchy - ensure that all the needed directories are present
2047 hierarchy hier: .MAKE .PHONY
2048 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
2051 # libraries - build all libraries, and install them under ${DESTDIR}.
2053 # The list of libraries with dependents (${_prebuild_libs}) and their
2054 # interdependencies (__L) are built automatically by the
2055 # ${.CURDIR}/tools/make_libdeps.sh script.
2057 libraries: .MAKE .PHONY
2058 ${_+_}cd ${.CURDIR}; \
2059 ${MAKE} -f Makefile.inc1 _prereq_libs; \
2060 ${MAKE} -f Makefile.inc1 _startup_libs; \
2061 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
2062 ${MAKE} -f Makefile.inc1 _generic_libs
2065 # static libgcc.a prerequisite for shared libc
2067 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
2069 # These dependencies are not automatically generated:
2071 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
2072 # all shared libraries for ELF.
2074 _startup_libs= gnu/lib/csu
2075 _startup_libs+= lib/csu
2076 _startup_libs+= gnu/lib/libgcc
2077 _startup_libs+= lib/libcompiler_rt
2078 _startup_libs+= lib/libc
2079 _startup_libs+= lib/libc_nonshared
2080 .if ${MK_LIBCPLUSPLUS} != "no"
2081 _startup_libs+= lib/libcxxrt
2084 gnu/lib/libgcc__L: lib/libc__L
2085 gnu/lib/libgcc__L: lib/libc_nonshared__L
2086 .if ${MK_LIBCPLUSPLUS} != "no"
2087 lib/libcxxrt__L: gnu/lib/libgcc__L
2090 _prebuild_libs= ${_kerberos5_lib_libasn1} \
2091 ${_kerberos5_lib_libhdb} \
2092 ${_kerberos5_lib_libheimbase} \
2093 ${_kerberos5_lib_libheimntlm} \
2095 ${_kerberos5_lib_libheimipcc} \
2096 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
2097 ${_kerberos5_lib_libroken} \
2098 ${_kerberos5_lib_libwind} \
2099 lib/libbz2 ${_libcom_err} lib/libcrypt \
2100 lib/libelf lib/libexpat \
2103 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
2105 lib/ncurses/ncurses lib/ncurses/ncursesw \
2106 lib/libopie lib/libpam/libpam ${_lib_libthr} \
2107 ${_lib_libradius} lib/libsbuf lib/libtacplus \
2109 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
2110 ${_cddl_lib_libuutil} \
2111 ${_cddl_lib_libavl} \
2112 ${_cddl_lib_libzfs_core} \
2113 ${_cddl_lib_libctf} \
2114 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
2115 ${_secure_lib_libcrypto} ${_lib_libldns} \
2116 ${_secure_lib_libssh} ${_secure_lib_libssl}
2118 .if ${MK_GNUCXX} != "no"
2119 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
2120 gnu/lib/libstdc++__L: lib/msun__L
2121 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
2124 .if ${MK_DIALOG} != "no"
2125 _prebuild_libs+= gnu/lib/libdialog
2126 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2129 .if ${MK_LIBCPLUSPLUS} != "no"
2130 _prebuild_libs+= lib/libc++
2133 lib/libgeom__L: lib/libexpat__L
2134 lib/libkvm__L: lib/libelf__L
2136 .if ${MK_LIBTHR} != "no"
2137 _lib_libthr= lib/libthr
2140 .if ${MK_RADIUS_SUPPORT} != "no"
2141 _lib_libradius= lib/libradius
2144 .if ${MK_OFED} != "no"
2146 lib/ofed/libibverbs \
2148 lib/ofed/libibumad \
2152 lib/ofed/libibmad__L: lib/ofed/libibumad__L
2153 lib/ofed/complib__L: lib/libthr__L
2154 lib/ofed/libmlx5__L: lib/ofed/libibverbs__L lib/libthr__L
2157 .if ${MK_CASPER} != "no"
2158 _lib_casper= lib/libcasper
2161 lib/libpjdlog__L: lib/libutil__L
2162 lib/libcasper__L: lib/libnv__L
2163 lib/liblzma__L: lib/libthr__L
2165 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
2166 .for _DIR in ${LOCAL_LIB_DIRS}
2167 .if ${_DIR} == ".WAIT" || (empty(_generic_libs:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
2168 _generic_libs+= ${_DIR}
2172 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2174 .if ${MK_CDDL} != "no"
2175 _cddl_lib_libumem= cddl/lib/libumem
2176 _cddl_lib_libnvpair= cddl/lib/libnvpair
2177 _cddl_lib_libavl= cddl/lib/libavl
2178 _cddl_lib_libuutil= cddl/lib/libuutil
2179 .if ${MK_ZFS} != "no"
2180 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2181 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2183 _cddl_lib_libctf= cddl/lib/libctf
2185 cddl/lib/libctf__L: lib/libz__L
2187 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
2188 # on select architectures though (see cddl/lib/Makefile)
2189 .if ${MACHINE_CPUARCH} != "sparc64"
2190 _prebuild_libs+= lib/libproc lib/librtld_db
2193 .if ${MK_CRYPT} != "no"
2194 .if ${MK_OPENSSL} != "no"
2195 _secure_lib_libcrypto= secure/lib/libcrypto
2196 _secure_lib_libssl= secure/lib/libssl
2197 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2198 .if ${MK_LDNS} != "no"
2199 _lib_libldns= lib/libldns
2200 lib/libldns__L: secure/lib/libcrypto__L
2202 .if ${MK_OPENSSH} != "no"
2203 _secure_lib_libssh= secure/lib/libssh
2204 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2205 .if ${MK_LDNS} != "no"
2206 secure/lib/libssh__L: lib/libldns__L
2208 .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no"
2209 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2210 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2211 lib/libmd__L kerberos5/lib/libroken__L
2215 _secure_lib= secure/lib
2218 .if ${MK_KERBEROS} != "no"
2219 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2220 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2221 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2222 kerberos5/lib/libwind__L lib/libsqlite3__L
2223 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2224 kerberos5/lib/libroken__L lib/libcom_err__L
2225 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2226 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2227 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2228 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2229 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2230 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2231 kerberos5/lib/libroken__L: lib/libcrypt__L
2232 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2233 kerberos5/lib/libheimbase__L: lib/libthr__L
2234 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2237 lib/libsqlite3__L: lib/libthr__L
2239 .if ${MK_GSSAPI} != "no"
2240 _lib_libgssapi= lib/libgssapi
2243 .if ${MK_KERBEROS} != "no"
2244 _kerberos5_lib= kerberos5/lib
2245 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2246 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2247 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2248 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2249 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2250 _kerberos5_lib_libroken= kerberos5/lib/libroken
2251 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2252 _libsqlite3= lib/libsqlite3
2253 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2254 _kerberos5_lib_libwind= kerberos5/lib/libwind
2255 _libcom_err= lib/libcom_err
2258 .if ${MK_NIS} != "no"
2259 _lib_libypclnt= lib/libypclnt
2262 .if ${MK_OPENSSL} == "no"
2263 lib/libradius__L: lib/libmd__L
2267 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2268 .if ${MK_CXX} != "no"
2269 .if ${MK_LIBCPLUSPLUS} != "no"
2270 lib/libproc__L: lib/libcxxrt__L
2271 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2272 lib/libproc__L: gnu/lib/libsupc++__L
2276 .for _lib in ${_prereq_libs}
2277 ${_lib}__PL: .PHONY .MAKE
2278 .if exists(${.CURDIR}/${_lib})
2279 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2280 cd ${.CURDIR}/${_lib}; \
2281 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2282 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2283 DIRPRFX=${_lib}/ all; \
2284 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2285 DIRPRFX=${_lib}/ install
2289 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
2290 ${_lib}__L: .PHONY .MAKE
2291 .if exists(${.CURDIR}/${_lib})
2292 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2293 cd ${.CURDIR}/${_lib}; \
2294 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2295 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2296 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2300 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2301 _startup_libs: ${_startup_libs:S/$/__L/}
2302 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2303 _generic_libs: ${_generic_libs:S/$/__L/}
2305 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2306 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2307 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2308 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2309 # parallel. This is safe for the world stage of buildworld though since it has
2310 # already built libraries in a proper order and installed includes into
2311 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2312 # avoid trashing a system if it crashes mid-install.
2313 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2317 .include <bsd.subdir.mk>
2319 .if make(check-old) || make(check-old-dirs) || \
2320 make(check-old-files) || make(check-old-libs) || \
2321 make(delete-old) || make(delete-old-dirs) || \
2322 make(delete-old-files) || make(delete-old-libs)
2325 # check for / delete old files section
2328 .include "ObsoleteFiles.inc"
2330 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2331 else you can not start such an application. Consult UPDATING for more \
2332 information regarding how to cope with the removal/revision bump of a \
2335 .if !defined(BATCH_DELETE_OLD_FILES)
2341 delete-old-files: .PHONY
2342 @echo ">>> Removing old files (only deletes safe to delete libs)"
2343 # Ask for every old file if the user really wants to remove it.
2344 # It's annoying, but better safe than sorry.
2345 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2346 # argument list will get too long. Using .for/.endfor make "loops" will make
2347 # the Makefile parser segfault.
2350 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2351 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2352 while read file; do \
2353 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2354 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2355 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2357 for ext in debug symbols; do \
2358 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2359 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2360 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2365 # Remove catpages without corresponding manpages.
2367 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2368 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2369 while read catpage; do \
2371 if [ ! -e "$${manpage}" ]; then \
2372 rm ${RM_I} $${catpage} <&3; \
2375 @echo ">>> Old files removed"
2377 check-old-files: .PHONY
2378 @echo ">>> Checking for old files"
2380 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2381 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2382 while read file; do \
2383 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2384 echo "${DESTDIR}/$${file}"; \
2386 for ext in debug symbols; do \
2387 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2388 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2392 # Check for catpages without corresponding manpages.
2393 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2394 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2395 while read catpage; do \
2397 if [ ! -e "$${manpage}" ]; then \
2402 delete-old-libs: .PHONY
2403 @echo ">>> Removing old libraries"
2404 @echo "${OLD_LIBS_MESSAGE}" | fmt
2407 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2408 -V OLD_LIBS | xargs -n1 | \
2409 while read file; do \
2410 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2411 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2412 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2414 for ext in debug symbols; do \
2415 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2416 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2417 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2422 @echo ">>> Old libraries removed"
2424 check-old-libs: .PHONY
2425 @echo ">>> Checking for old libraries"
2427 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2428 -V OLD_LIBS | xargs -n1 | \
2429 while read file; do \
2430 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2431 echo "${DESTDIR}/$${file}"; \
2433 for ext in debug symbols; do \
2434 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2435 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2440 delete-old-dirs: .PHONY
2441 @echo ">>> Removing old directories"
2443 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2444 -V OLD_DIRS | xargs -n1 | sort -r | \
2445 while read dir; do \
2446 if [ -d "${DESTDIR}/$${dir}" ]; then \
2447 rmdir -v "${DESTDIR}/$${dir}" || true; \
2448 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2449 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2451 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2452 rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \
2453 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2454 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2457 @echo ">>> Old directories removed"
2459 check-old-dirs: .PHONY
2460 @echo ">>> Checking for old directories"
2462 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2463 -V OLD_DIRS | xargs -n1 | \
2464 while read dir; do \
2465 if [ -d "${DESTDIR}/$${dir}" ]; then \
2466 echo "${DESTDIR}/$${dir}"; \
2467 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2468 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2470 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2471 echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \
2472 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2473 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2477 delete-old: delete-old-files delete-old-dirs .PHONY
2478 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2480 check-old: check-old-files check-old-libs check-old-dirs .PHONY
2481 @echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
2482 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2487 # showconfig - show build configuration.
2490 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2491 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2493 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2494 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2496 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2497 .if exists(${KERNCONFDIR}/${KERNCONF})
2498 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2499 '${KERNCONFDIR}/${KERNCONF}' ; echo
2505 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2506 DTBOUTPUTPATH= ${.CURDIR}
2510 # Build 'standalone' Device Tree Blob
2513 @PATH=${TMPPATH} MACHINE=${TARGET} \
2514 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2515 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2520 # In the following, the first 'rm' in a series will usually remove all
2521 # files and directories. If it does not, then there are probably some
2522 # files with file flags set, so this unsets them and tries the 'rm' a
2523 # second time. There are situations where this target will be cleaning
2524 # some directories via more than one method, but that duplication is
2525 # needed to correctly handle all the possible situations. Removing all
2526 # files without file flags set in the first 'rm' instance saves time,
2527 # because 'chflags' will need to operate on fewer files afterwards.
2529 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2530 # created by bsd.obj.mk, except that we don't want to .include that file
2533 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2535 .if exists(${BW_CANONICALOBJDIR}/)
2536 -rm -rf ${BW_CANONICALOBJDIR}/*
2537 -chflags -R 0 ${BW_CANONICALOBJDIR}
2538 rm -rf ${BW_CANONICALOBJDIR}/*
2540 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2541 # To be safe in this case, fall back to a 'make cleandir'
2542 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2545 .if defined(TARGET) && defined(TARGET_ARCH)
2547 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2548 XDEV_CPUTYPE?=${CPUTYPE}
2550 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2553 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2554 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2555 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2556 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2557 CPUTYPE=${XDEV_CPUTYPE}
2559 XDDIR=${TARGET_ARCH}-freebsd
2562 .error XDTP variable should be an absolute path
2565 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2566 INSTALL="sh ${.CURDIR}/tools/install.sh"
2568 TOOLS_PREFIX=${XDTP}
2570 .if ${WANT_COMPILER_TYPE} == gcc || \
2571 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
2572 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
2573 # won't set header path and -L is used to ensure the base library path
2574 # is added before the port PREFIX library path.
2575 CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib
2576 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
2577 # combined with --sysroot.
2578 CD2CFLAGS+= -B${XDDESTDIR}/usr/lib
2579 # Force using libc++ for external GCC.
2580 .if ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
2581 CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \
2585 CD2CFLAGS+= --sysroot=${XDDESTDIR}/
2586 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \
2587 CPP="${CPP} ${CD2CFLAGS}" \
2588 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2590 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2591 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2592 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2593 .if ${MK_META_MODE} != "no"
2594 # Don't rebuild build-tools targets during normal build.
2595 CD2MAKE+= BUILD_TOOLS_META=.NOMETA
2597 XDDESTDIR=${DESTDIR}/${XDTP}
2599 .ORDER: xdev-build xdev-install xdev-links
2600 xdev: xdev-build xdev-install .PHONY
2602 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2603 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
2605 _xb-worldtmp: .PHONY
2606 mkdir -p ${CDTMP}/usr
2607 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2608 -p ${CDTMP}/usr >/dev/null
2610 _xb-bootstrap-tools: .PHONY
2615 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2616 cd ${.CURDIR}/${_tool}; \
2617 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2618 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2619 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2622 _xb-build-tools: .PHONY
2623 ${_+_}@cd ${.CURDIR}; \
2624 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2626 _xb-cross-tools: .PHONY
2634 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2635 cd ${.CURDIR}/${_tool}; \
2636 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2637 ${CDMAKE} DIRPRFX=${_tool}/ all
2641 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2642 mkdir -p ${XDDESTDIR}
2643 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2644 -p ${XDDESTDIR} >/dev/null
2645 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2646 -p ${XDDESTDIR}/usr >/dev/null
2647 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2648 -p ${XDDESTDIR}/usr/include >/dev/null
2649 .if defined(LIBCOMPAT)
2650 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2651 -p ${XDDESTDIR}/usr >/dev/null
2653 .if ${MK_TESTS} != "no"
2654 mkdir -p ${XDDESTDIR}${TESTSBASE}
2655 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2656 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2659 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2660 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
2662 _xi-cross-tools: .PHONY
2663 @echo "_xi-cross-tools"
2671 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2672 cd ${.CURDIR}/${_tool}; \
2673 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2676 _xi-includes: .PHONY
2677 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2678 DESTDIR=${XDDESTDIR}
2680 _xi-libraries: .PHONY
2681 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2682 DESTDIR=${XDDESTDIR}
2685 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2686 mkdir -p ../../../../usr/bin; \
2688 ln -sf ../../${XDTP}/usr/bin/$$i \
2689 ../../../../usr/bin/${XDDIR}-$$i; \
2690 ln -sf ../../${XDTP}/usr/bin/$$i \
2691 ../../../../usr/bin/${XDDIR}${_REVISION}-$$i; \
2694 xdev xdev-build xdev-install xdev-links: .PHONY
2695 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"