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 .if ${MK_BOOT} != "no"
258 SUBDIR+=sys usr.bin usr.sbin
259 .if ${MK_TESTS} != "no"
262 .if ${MK_OFED} != "no"
266 # Local directories are built in parallel with the base system directories.
267 # Users may insert a .WAIT directive at the beginning or elsewhere within
268 # the LOCAL_DIRS and LOCAL_LIB_DIRS lists as needed.
269 .for _DIR in ${LOCAL_DIRS}
270 .if ${_DIR} == ".WAIT" || exists(${.CURDIR}/${_DIR}/Makefile)
274 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
275 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
276 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
277 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
278 _REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
280 .for _DIR in ${LOCAL_LIB_DIRS}
281 .if ${_DIR} == ".WAIT" || (empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
286 # We must do etc/ last as it hooks into building the man whatis file
287 # by calling 'makedb' in share/man. This is only relevant for
288 # install/distribute so they build the whatis file after every manpage is
290 .if make(installworld) || make(install)
295 .endif # !empty(SUBDIR_OVERRIDE)
298 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
301 .if defined(NO_CLEANDIR)
302 CLEANDIR= clean cleandepend
307 .if ${MK_META_MODE} == "yes"
308 # If filemon is used then we can rely on the build being incremental-safe.
309 # The .meta files will also track the build command and rebuild should
311 .if empty(.MAKE.MODE:Mnofilemon)
317 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
319 .if empty(SHELL:M*csh*)
320 BUILDENV_SHELL?=${SHELL}
322 BUILDENV_SHELL?=/bin/sh
325 .if !defined(SVN) || empty(SVN)
326 . for _P in /usr/bin /usr/local/bin
327 . for _S in svn svnlite
328 . if exists(${_P}/${_S})
336 .if !defined(OSRELDATE)
337 .if exists(/usr/include/osreldate.h)
338 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
339 /usr/include/osreldate.h
346 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
347 .if !defined(_REVISION)
348 _REVISION!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V REVISION
351 .if !defined(_BRANCH)
352 _BRANCH!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V BRANCH
355 .if !defined(SRCRELDATE)
356 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
357 ${SRCDIR}/sys/sys/param.h
360 .if !defined(VERSION)
361 VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
365 .if !defined(PKG_VERSION)
366 .if ${_BRANCH:MSTABLE*} || ${_BRANCH:MCURRENT*} || ${_BRANCH:MALPHA*}
367 TIMENOW= %Y%m%d%H%M%S
368 EXTRA_REVISION= .s${TIMENOW:gmtime}
371 EXTRA_REVISION= _${_BRANCH:C/.*-p([0-9]+$)/\1/}
373 PKG_VERSION= ${_REVISION}${EXTRA_REVISION}
376 KNOWN_ARCHES?= aarch64/arm64 \
394 .if ${TARGET} == ${TARGET_ARCH}
397 _t= ${TARGET_ARCH}/${TARGET}
400 .if empty(KNOWN_ARCHES:M${_t})
401 .error Unknown target ${TARGET_ARCH}:${TARGET}.
405 .if ${TARGET} == ${MACHINE}
406 TARGET_CPUTYPE?=${CPUTYPE}
411 .if !empty(TARGET_CPUTYPE)
412 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
414 _TARGET_CPUTYPE=dummy
416 _CPUTYPE!= MK_AUTO_OBJ=no MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
417 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
418 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
419 .error CPUTYPE global should be set with ?=.
422 BUILD_ARCH!= uname -p
423 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
424 .error To cross-build, set TARGET_ARCH.
427 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
428 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
429 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
430 STRICTTMPPATH= ${BPATH}:${XPATH}
431 TMPPATH= ${STRICTTMPPATH}:${PATH}
434 # Avoid running mktemp(1) unless actually needed.
435 # It may not be functional, e.g., due to new ABI
436 # when in the middle of installing over this system.
438 .if make(distributeworld) || make(installworld) || make(stageworld)
439 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
442 .if make(stagekernel) || make(distributekernel)
448 # Building a world goes through the following stages
450 # 1. legacy stage [BMAKE]
451 # This stage is responsible for creating compatibility
452 # shims that are needed by the bootstrap-tools,
453 # build-tools and cross-tools stages. These are generally
454 # APIs that tools from one of those three stages need to
455 # build that aren't present on the host.
456 # 1. bootstrap-tools stage [BMAKE]
457 # This stage is responsible for creating programs that
458 # are needed for backward compatibility reasons. They
459 # are not built as cross-tools.
460 # 2. build-tools stage [TMAKE]
461 # This stage is responsible for creating the object
462 # tree and building any tools that are needed during
463 # the build process. Some programs are listed during
464 # this phase because they build binaries to generate
465 # files needed to build these programs. This stage also
466 # builds the 'build-tools' target rather than 'all'.
467 # 3. cross-tools stage [XMAKE]
468 # This stage is responsible for creating any tools that
469 # are needed for building the system. A cross-compiler is one
470 # of them. This differs from build tools in two ways:
471 # 1. the 'all' target is built rather than 'build-tools'
472 # 2. these tools are installed into TMPPATH for stage 4.
473 # 4. world stage [WMAKE]
474 # This stage actually builds the world.
475 # 5. install stage (optional) [IMAKE]
476 # This stage installs a previously built world.
481 MINIMUM_SUPPORTED_OSREL?= 900044
482 MINIMUM_SUPPORTED_REL?= 9.1
484 # Common environment for world related stages
485 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
486 MACHINE_ARCH=${TARGET_ARCH} \
488 CPUTYPE=${TARGET_CPUTYPE}
489 .if ${MK_META_MODE} != "no"
490 # Don't rebuild build-tools targets during normal build.
491 CROSSENV+= BUILD_TOOLS_META=.NOMETA
493 .if ${MK_GROFF} != "no"
494 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
495 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
496 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
498 .if defined(TARGET_CFLAGS)
499 CROSSENV+= ${TARGET_CFLAGS}
502 # bootstrap-tools stage
503 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
504 TOOLS_PREFIX=${WORLDTMP} \
505 PATH=${BPATH}:${PATH} \
506 WORLDTMP=${WORLDTMP} \
507 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
508 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
510 BOOTSTRAPPING=${OSRELDATE} \
512 MK_HTML=no NO_LINT=yes MK_MAN=no \
513 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
514 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
515 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
516 MK_LLDB=no MK_TESTS=no \
519 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
520 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
524 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
525 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
526 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
528 BOOTSTRAPPING=${OSRELDATE} \
531 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
532 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
533 MK_LLDB=no MK_TESTS=no
536 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
537 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
538 MK_GDB=no MK_TESTS=no
541 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
542 PATH=${BPATH}:${PATH} \
544 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
545 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
547 BOOTSTRAPPING=${OSRELDATE} \
549 MK_HTML=no -DNO_LINT MK_MAN=no \
550 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
551 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
554 WMAKEENV= ${CROSSENV} \
555 INSTALL="sh ${.CURDIR}/tools/install.sh" \
559 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
561 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
564 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
565 CPP="${XCPP} ${XCFLAGS}" \
566 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
567 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
568 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
571 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
572 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
573 # directory, but the compiler will look in the right place for its
574 # tools so we don't need to tell it where to look.
575 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
578 # External compiler needs sysroot and target flags.
579 .if ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
580 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
581 BFLAGS+= -B${WORLDTMP}/usr/bin
583 .if ${TARGET} == "arm"
584 .if ${TARGET_ARCH:Marmv6*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
585 TARGET_ABI= gnueabihf
590 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
591 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
592 # won't set header path and -L is used to ensure the base library path
593 # is added before the port PREFIX library path.
594 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
595 # Force using libc++ for external GCC.
596 .if ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
597 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
598 -nostdinc++ -L${WORLDTMP}/../lib/libc++
602 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.1
603 XCFLAGS+= -target ${TARGET_TRIPLE}
605 XCFLAGS+= --sysroot=${WORLDTMP}
606 .endif # ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
612 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
613 ${TARGET_ARCH} == "powerpc64")
615 .include "Makefile.libcompat"
616 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH} == "armv6"
618 .include "Makefile.libcompat"
621 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
623 IMAKEENV= ${CROSSENV}
624 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
625 ${IMAKE_INSTALL} ${IMAKE_MTREE}
626 .if empty(.MAKEFLAGS:M-n)
627 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
628 LD_LIBRARY_PATH=${INSTALLTMP} \
629 PATH_LOCALE=${INSTALLTMP}/locale
630 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
632 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
634 .if defined(DB_FROM_SRC)
635 INSTALLFLAGS+= -N ${.CURDIR}/etc
636 MTREEFLAGS+= -N ${.CURDIR}/etc
638 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
639 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
641 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
642 METALOG:= ${METALOG:C,//+,/,g}
643 IMAKE+= -DNO_ROOT METALOG=${METALOG}
644 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
647 .if defined(BUILD_PKGS)
648 INSTALLFLAGS+= -h sha256
650 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
651 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
652 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
656 KMAKEENV= ${WMAKEENV}
657 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
662 # Attempt to rebuild the entire system, with reasonable chance of
663 # success, regardless of how old your existing system is.
666 .if ${.CURDIR:C/[^,]//g} != ""
667 # The m4 build of sendmail files doesn't like it if ',' is used
668 # anywhere in the path of it's files.
670 @echo "*** Error: path to source tree contains a comma ','"
675 @echo "--------------------------------------------------------------"
676 @echo ">>> Rebuilding the temporary build tree"
677 @echo "--------------------------------------------------------------"
678 .if !defined(NO_CLEAN)
680 .if defined(LIBCOMPAT)
681 rm -rf ${LIBCOMPATTMP}
684 rm -rf ${WORLDTMP}/legacy/usr/include
685 .if ${USING_SYSTEM_COMPILER} == "yes"
687 if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \
688 inum=$$(stat -f %i ${WORLDTMP}/usr/bin/${cc}); \
689 find ${WORLDTMP}/usr/bin -inum $${inum} -delete; \
692 .endif # ${USING_SYSTEM_COMPILER} == "yes"
693 .endif # !defined(NO_CLEAN)
695 lib lib/casper usr legacy/bin legacy/usr
696 mkdir -p ${WORLDTMP}/${_dir}
698 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
699 -p ${WORLDTMP}/legacy/usr >/dev/null
700 .if ${MK_GROFF} != "no"
701 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
702 -p ${WORLDTMP}/legacy/usr >/dev/null
704 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
705 -p ${WORLDTMP}/legacy/usr/include >/dev/null
706 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
707 -p ${WORLDTMP}/usr >/dev/null
708 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
709 -p ${WORLDTMP}/usr/include >/dev/null
710 ln -sf ${.CURDIR}/sys ${WORLDTMP}
711 .if ${MK_DEBUG_FILES} != "no"
712 # We could instead disable debug files for these build stages
713 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
714 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
715 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
716 -p ${WORLDTMP}/usr/lib >/dev/null
718 .if defined(LIBCOMPAT)
719 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
720 -p ${WORLDTMP}/usr >/dev/null
721 .if ${MK_DEBUG_FILES} != "no"
722 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
723 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
724 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
725 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
728 .if ${MK_TESTS} != "no"
729 mkdir -p ${WORLDTMP}${TESTSBASE}
730 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
731 -p ${WORLDTMP}${TESTSBASE} >/dev/null
732 .if ${MK_DEBUG_FILES} != "no"
733 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
734 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
735 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
738 .for _mtree in ${LOCAL_MTREE}
739 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
743 @echo "--------------------------------------------------------------"
744 @echo ">>> stage 1.1: legacy release compatibility shims"
745 @echo "--------------------------------------------------------------"
746 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
749 @echo "--------------------------------------------------------------"
750 @echo ">>> stage 1.2: bootstrap tools"
751 @echo "--------------------------------------------------------------"
752 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
754 .if !defined(NO_CLEAN)
756 @echo "--------------------------------------------------------------"
757 @echo ">>> stage 2.1: cleaning up the object tree"
758 @echo "--------------------------------------------------------------"
759 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
760 .if defined(LIBCOMPAT)
761 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
766 @echo "--------------------------------------------------------------"
767 @echo ">>> stage 2.2: rebuilding the object tree"
768 @echo "--------------------------------------------------------------"
769 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
772 @echo "--------------------------------------------------------------"
773 @echo ">>> stage 2.3: build tools"
774 @echo "--------------------------------------------------------------"
775 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
778 @echo "--------------------------------------------------------------"
779 @echo ">>> stage 3: cross tools"
780 @echo "--------------------------------------------------------------"
781 @rm -f ${.OBJDIR}/compiler-metadata.mk
782 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
783 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
786 @echo "--------------------------------------------------------------"
787 @echo ">>> stage 3.1: recording compiler metadata"
788 @echo "--------------------------------------------------------------"
789 ${_+_}cd ${.CURDIR}; ${WMAKE} compiler-metadata.mk
792 @echo "--------------------------------------------------------------"
793 @echo ">>> stage 4.1: building includes"
794 @echo "--------------------------------------------------------------"
795 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
796 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
797 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
798 MK_INCLUDES=yes includes
799 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
800 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
804 @echo "--------------------------------------------------------------"
805 @echo ">>> stage 4.2: building libraries"
806 @echo "--------------------------------------------------------------"
807 ${_+_}cd ${.CURDIR}; \
808 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
809 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
812 @echo "--------------------------------------------------------------"
813 @echo ">>> stage 4.3: building everything"
814 @echo "--------------------------------------------------------------"
815 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
818 WMAKE_TGTS+= _worldtmp _legacy
819 .if empty(SUBDIR_OVERRIDE)
820 WMAKE_TGTS+= _bootstrap-tools
822 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
823 WMAKE_TGTS+= _compiler-metadata
824 WMAKE_TGTS+= _includes _libraries
825 WMAKE_TGTS+= everything
826 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
827 WMAKE_TGTS+= build${libcompat}
830 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
831 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
833 buildworld_prologue: .PHONY
834 @echo "--------------------------------------------------------------"
835 @echo ">>> World build started on `LC_ALL=C date`"
836 @echo "--------------------------------------------------------------"
838 buildworld_epilogue: .PHONY
840 @echo "--------------------------------------------------------------"
841 @echo ">>> World build completed on `LC_ALL=C date`"
842 @echo "--------------------------------------------------------------"
845 # We need to have this as a target because the indirection between Makefile
846 # and Makefile.inc1 causes the correct PATH to be used, rather than a
847 # modification of the current environment's PATH. In addition, we need
848 # to quote multiword values.
851 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
853 .if ${.TARGETS:Mbuildenv}
854 .if ${.MAKEFLAGS:M-j}
855 .error The buildenv target is incompatible with -j
858 BUILDENV_DIR?= ${.CURDIR}
860 # Note: make will report any errors the shell reports. This can
861 # be odd if the last command in an interactive shell generates an
862 # error or is terminated by SIGINT. These reported errors look bad,
863 # but are harmless. Allowing them also allows BUIDLENV_SHELL to
864 # be a complex command whose status will be returned to the caller.
865 # Some scripts in tools rely on this behavior to report build errors.
868 @echo Entering world for ${TARGET_ARCH}:${TARGET}
869 .if ${BUILDENV_SHELL:M*zsh*}
870 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
872 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL}
874 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
875 toolchain: ${TOOLCHAIN_TGTS} .PHONY
876 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries} .PHONY
881 # Checks to be sure system is ready for installworld/installkernel.
883 installcheck: _installcheck_world _installcheck_kernel .PHONY
884 _installcheck_world: .PHONY
885 _installcheck_kernel: .PHONY
888 # Require DESTDIR to be set if installing for a different architecture or
889 # using the user/group database in the source tree.
891 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
893 .if !make(distributeworld)
894 _installcheck_world: __installcheck_DESTDIR
895 _installcheck_kernel: __installcheck_DESTDIR
896 __installcheck_DESTDIR: .PHONY
897 .if !defined(DESTDIR) || empty(DESTDIR)
898 @echo "ERROR: Please set DESTDIR!"; \
904 .if !defined(DB_FROM_SRC)
906 # Check for missing UIDs/GIDs.
908 CHECK_UIDS= auditdistd
910 .if ${MK_SENDMAIL} != "no"
916 CHECK_GIDS+= proxy authpf
918 .if ${MK_UNBOUND} != "no"
922 _installcheck_world: __installcheck_UGID
923 __installcheck_UGID: .PHONY
924 .for uid in ${CHECK_UIDS}
925 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
926 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
930 .for gid in ${CHECK_GIDS}
931 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
932 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
938 # If installing over the running system (DESTDIR is / or unset) and the install
939 # includes rescue, try running rescue from the objdir as a sanity check. If
940 # rescue is not functional (e.g., because it depends on a system call not
941 # supported by the currently running kernel), abort the installation.
943 .if !make(distributeworld) && ${MK_RESCUE} != "no" && \
944 (empty(DESTDIR) || ${DESTDIR} == "/") && empty(BYPASS_INSTALLCHECK_SH)
945 _installcheck_world: __installcheck_sh_check
946 __installcheck_sh_check: .PHONY
947 @if [ "`${OBJTREE}${.CURDIR}/rescue/rescue/rescue sh -c 'echo OK'`" != \
949 echo "rescue/sh check failed, installation aborted" >&2; \
955 # Required install tools to be saved in a scratch dir for safety.
957 .if ${MK_ZONEINFO} != "no"
958 _zoneinfo= zic tzsetup
961 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
962 date echo egrep find grep id install ${_install-info} \
963 ln make mkdir mtree mv pwd_mkdb \
964 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
967 # Needed for share/man
968 .if ${MK_MAN_UTILS} != "no"
975 # Distributes everything compiled by a `buildworld'.
979 # Installs everything compiled by a 'buildworld'.
982 # Non-base distributions produced by the base system
983 EXTRA_DISTRIBUTIONS= doc
984 .if defined(LIBCOMPAT)
985 EXTRA_DISTRIBUTIONS+= lib${libcompat}
987 .if ${MK_TESTS} != "no"
988 EXTRA_DISTRIBUTIONS+= tests
992 .if ${MK_DEBUG_FILES} != "no"
993 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
996 MTREE_MAGIC?= mtree 2.0
998 distributeworld installworld stageworld: _installcheck_world .PHONY
999 mkdir -p ${INSTALLTMP}
1000 progs=$$(for prog in ${ITOOLS}; do \
1001 if progpath=`which $$prog`; then \
1004 echo "Required tool $$prog not found in PATH." >&2; \
1008 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
1009 while read line; do \
1011 if [ "$$2 $$3" != "not found" ]; then \
1014 echo "Required library $$1 not found." >&2; \
1018 cp $$libs $$progs ${INSTALLTMP}
1019 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
1020 .if defined(NO_ROOT)
1021 -mkdir -p ${METALOG:H}
1022 echo "#${MTREE_MAGIC}" > ${METALOG}
1024 .if make(distributeworld)
1025 .for dist in ${EXTRA_DISTRIBUTIONS}
1026 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
1027 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1028 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
1029 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1030 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1031 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1032 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
1033 .if ${MK_DEBUG_FILES} != "no"
1034 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1035 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
1037 .if defined(LIBCOMPAT)
1038 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1039 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1040 .if ${MK_DEBUG_FILES} != "no"
1041 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1042 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
1045 .if ${MK_TESTS} != "no" && ${dist} == "tests"
1046 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
1047 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1048 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
1049 .if ${MK_DEBUG_FILES} != "no"
1050 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1051 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
1054 .if defined(NO_ROOT)
1055 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1056 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1057 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1058 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1059 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1060 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1061 .if defined(LIBCOMPAT)
1062 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
1063 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1067 -mkdir ${DESTDIR}/${DISTDIR}/base
1068 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1069 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1070 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1071 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1073 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1074 ${IMAKEENV} rm -rf ${INSTALLTMP}
1075 .if make(distributeworld)
1076 .for dist in ${EXTRA_DISTRIBUTIONS}
1077 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete
1079 .if defined(NO_ROOT)
1080 .for dist in base ${EXTRA_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} | sort -u ${METALOG} - | \
1087 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1088 ${DESTDIR}/${DISTDIR}/${dist}.meta
1090 .for dist in ${DEBUG_DISTRIBUTIONS}
1091 @# For each file that exists in this dist, print the corresponding
1092 @# line from the METALOG. This relies on the fact that
1093 @# a line containing only the filename will sort immediately before
1094 @# the relevant mtree line.
1095 cd ${DESTDIR}/${DISTDIR}; \
1096 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1097 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1098 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1103 packageworld: .PHONY
1104 .for dist in base ${EXTRA_DISTRIBUTIONS}
1105 .if defined(NO_ROOT)
1106 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1107 tar cvf - --exclude usr/lib/debug \
1108 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1109 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1111 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1112 tar cvf - --exclude usr/lib/debug . | \
1113 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1117 .for dist in ${DEBUG_DISTRIBUTIONS}
1118 . if defined(NO_ROOT)
1119 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1120 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1121 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1123 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1124 tar cvLf - usr/lib/debug | \
1125 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1132 # If you have a build server, you can NFS mount the source and obj directories
1133 # and do a 'make reinstall' on the *client* to install new binaries from the
1134 # most recent server build.
1136 restage reinstall: .MAKE .PHONY
1137 @echo "--------------------------------------------------------------"
1138 @echo ">>> Making hierarchy"
1139 @echo "--------------------------------------------------------------"
1140 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1141 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1143 @echo "--------------------------------------------------------------"
1144 @echo ">>> Making distribution"
1145 @echo "--------------------------------------------------------------"
1146 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1147 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
1150 @echo "--------------------------------------------------------------"
1151 @echo ">>> Installing everything"
1152 @echo "--------------------------------------------------------------"
1153 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1154 .if defined(LIBCOMPAT)
1155 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1158 redistribute: .MAKE .PHONY
1159 @echo "--------------------------------------------------------------"
1160 @echo ">>> Distributing everything"
1161 @echo "--------------------------------------------------------------"
1162 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1163 .if defined(LIBCOMPAT)
1164 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1165 DISTRIBUTION=lib${libcompat}
1168 distrib-dirs distribution: .MAKE .PHONY
1169 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1170 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1171 .if make(distribution)
1172 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1173 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1174 METALOG=${METALOG} MK_TESTS=no installconfig
1178 # buildkernel and installkernel
1180 # Which kernels to build and/or install is specified by setting
1181 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1182 # Only the existing (depending TARGET) config files are used
1183 # for building kernels and only the first of these is designated
1184 # as the one being installed.
1186 # Note that we have to use TARGET instead of TARGET_ARCH when
1187 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1188 # be set to cross-build, we have to make sure TARGET is set
1191 .if defined(KERNFAST)
1195 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1196 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1197 KERNCONF=${KERNFAST}
1200 .if ${TARGET_ARCH} == "powerpc64"
1201 KERNCONF?= GENERIC64
1205 INSTKERNNAME?= kernel
1207 KERNSRCDIR?= ${.CURDIR}/sys
1208 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1209 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1210 KERNCONFDIR?= ${KRNLCONFDIR}
1214 .if defined(NO_INSTALLKERNEL)
1215 # All of the BUILDKERNELS loops start at index 1.
1216 BUILDKERNELS+= dummy
1218 .for _kernel in ${KERNCONF}
1219 .if exists(${KERNCONFDIR}/${_kernel})
1220 BUILDKERNELS+= ${_kernel}
1221 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1222 INSTALLKERNEL= ${_kernel}
1225 .if make(buildkernel)
1226 .error Missing KERNCONF ${KERNCONFDIR}/${_kernel}
1231 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1236 # Builds all kernels defined by BUILDKERNELS.
1238 buildkernel: .MAKE .PHONY
1239 .if empty(BUILDKERNELS:Ndummy)
1240 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1244 .for _kernel in ${BUILDKERNELS:Ndummy}
1245 @echo "--------------------------------------------------------------"
1246 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1247 @echo "--------------------------------------------------------------"
1248 @echo "===> ${_kernel}"
1249 mkdir -p ${KRNLOBJDIR}
1250 .if !defined(NO_KERNELCONFIG)
1252 @echo "--------------------------------------------------------------"
1253 @echo ">>> stage 1: configuring the kernel"
1254 @echo "--------------------------------------------------------------"
1255 cd ${KRNLCONFDIR}; \
1257 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1258 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1260 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1262 @echo "--------------------------------------------------------------"
1263 @echo ">>> stage 2.1: cleaning up the object tree"
1264 @echo "--------------------------------------------------------------"
1265 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1267 .if !defined(NO_KERNELOBJ)
1269 @echo "--------------------------------------------------------------"
1270 @echo ">>> stage 2.2: rebuilding the object tree"
1271 @echo "--------------------------------------------------------------"
1272 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1275 @echo "--------------------------------------------------------------"
1276 @echo ">>> stage 2.3: build tools"
1277 @echo "--------------------------------------------------------------"
1278 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1280 @echo "--------------------------------------------------------------"
1281 @echo ">>> stage 3.1: building everything"
1282 @echo "--------------------------------------------------------------"
1283 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1284 @echo "--------------------------------------------------------------"
1285 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1286 @echo "--------------------------------------------------------------"
1289 NO_INSTALLEXTRAKERNELS?= yes
1292 # installkernel, etc.
1294 # Install the kernel defined by INSTALLKERNEL
1296 installkernel installkernel.debug \
1297 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1298 .if !defined(NO_INSTALLKERNEL)
1299 .if empty(INSTALLKERNEL)
1300 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1303 @echo "--------------------------------------------------------------"
1304 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1305 @echo "--------------------------------------------------------------"
1306 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1307 ${CROSSENV} PATH=${TMPPATH} \
1308 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1310 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1311 .for _kernel in ${BUILDKERNELS:[2..-1]}
1312 @echo "--------------------------------------------------------------"
1313 @echo ">>> Installing kernel ${_kernel}"
1314 @echo "--------------------------------------------------------------"
1315 cd ${KRNLOBJDIR}/${_kernel}; \
1316 ${CROSSENV} PATH=${TMPPATH} \
1317 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1321 distributekernel distributekernel.debug: .PHONY
1322 .if !defined(NO_INSTALLKERNEL)
1323 .if empty(INSTALLKERNEL)
1324 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1327 mkdir -p ${DESTDIR}/${DISTDIR}
1328 .if defined(NO_ROOT)
1329 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1331 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1332 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1333 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1334 DESTDIR=${INSTALL_DDIR}/kernel \
1335 ${.TARGET:S/distributekernel/install/}
1336 .if defined(NO_ROOT)
1337 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1338 ${DESTDIR}/${DISTDIR}/kernel.meta
1341 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1342 .for _kernel in ${BUILDKERNELS:[2..-1]}
1343 .if defined(NO_ROOT)
1344 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1346 cd ${KRNLOBJDIR}/${_kernel}; \
1347 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1348 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1349 KERNEL=${INSTKERNNAME}.${_kernel} \
1350 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1351 ${.TARGET:S/distributekernel/install/}
1352 .if defined(NO_ROOT)
1353 @sed -e "s|^./kernel.${_kernel}|.|" \
1354 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1355 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1360 packagekernel: .PHONY
1361 .if defined(NO_ROOT)
1362 .if !defined(NO_INSTALLKERNEL)
1363 cd ${DESTDIR}/${DISTDIR}/kernel; \
1364 tar cvf - --exclude '*.debug' \
1365 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1366 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1368 .if ${MK_DEBUG_FILES} != "no"
1369 cd ${DESTDIR}/${DISTDIR}/kernel; \
1370 tar cvf - --include '*/*/*.debug' \
1371 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1372 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1374 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1375 .for _kernel in ${BUILDKERNELS:[2..-1]}
1376 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1377 tar cvf - --exclude '*.debug' \
1378 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1379 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1380 .if ${MK_DEBUG_FILES} != "no"
1381 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1382 tar cvf - --include '*/*/*.debug' \
1383 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1384 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1389 .if !defined(NO_INSTALLKERNEL)
1390 cd ${DESTDIR}/${DISTDIR}/kernel; \
1391 tar cvf - --exclude '*.debug' . | \
1392 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1394 .if ${MK_DEBUG_FILES} != "no"
1395 cd ${DESTDIR}/${DISTDIR}/kernel; \
1396 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1397 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1399 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1400 .for _kernel in ${BUILDKERNELS:[2..-1]}
1401 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1402 tar cvf - --exclude '*.debug' . | \
1403 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1404 .if ${MK_DEBUG_FILES} != "no"
1405 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1406 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1407 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1414 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1416 PORTSDIR?= /usr/ports
1417 WSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/worldstage
1418 KSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/kernelstage
1419 REPODIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/repo
1420 PKGSIGNKEY?= # empty
1422 .ORDER: stage-packages create-packages
1423 .ORDER: create-packages create-world-packages
1424 .ORDER: create-packages create-kernel-packages
1425 .ORDER: create-packages sign-packages
1427 _pkgbootstrap: .PHONY
1428 .if !exists(${LOCALBASE}/sbin/pkg)
1429 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1433 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1436 rm -rf /tmp/ports.${TARGET} || :
1437 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
1438 PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \
1439 WSTAGEDIR=${WSTAGEDIR} \
1440 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1442 real-packages: stage-packages create-packages sign-packages .PHONY
1444 stage-packages: .PHONY
1445 @mkdir -p ${REPODIR} ${WSTAGEDIR} ${KSTAGEDIR}
1446 ${_+_}@cd ${.CURDIR}; \
1447 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT -B stageworld ; \
1448 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT -B stagekernel
1450 create-packages: _pkgbootstrap .PHONY
1451 @mkdir -p ${REPODIR}
1452 ${_+_}@cd ${.CURDIR}; \
1453 ${MAKE} DESTDIR=${WSTAGEDIR} \
1454 PKG_VERSION=${PKG_VERSION} create-world-packages ; \
1455 ${MAKE} DESTDIR=${KSTAGEDIR} \
1456 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1457 create-kernel-packages
1459 create-world-packages: _pkgbootstrap .PHONY
1460 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1461 @cd ${WSTAGEDIR} ; \
1462 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1463 ${WSTAGEDIR}/METALOG
1464 @for plist in ${WSTAGEDIR}/*.plist; do \
1465 plist=$${plist##*/} ; \
1466 pkgname=$${plist%.plist} ; \
1467 sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \
1468 -s ${SRCDIR} -u ${WSTAGEDIR}/$${pkgname}.ucl ; \
1470 @for plist in ${WSTAGEDIR}/*.plist; do \
1471 plist=$${plist##*/} ; \
1472 pkgname=$${plist%.plist} ; \
1474 /^name/ { printf("===> Creating %s-", $$2); next } \
1475 /^version/ { print $$2; next } \
1476 ' ${WSTAGEDIR}/$${pkgname}.ucl ; \
1477 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1478 create -M ${WSTAGEDIR}/$${pkgname}.ucl \
1479 -p ${WSTAGEDIR}/$${pkgname}.plist \
1481 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} ; \
1484 create-kernel-packages: _pkgbootstrap .PHONY
1485 .if exists(${KSTAGEDIR}/kernel.meta)
1486 .if ${MK_DEBUG_FILES} != "no"
1489 .for flavor in "" ${_debug}
1490 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1491 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1492 -v kernel=yes -v _kernconf=${INSTALLKERNEL} \
1493 ${KSTAGEDIR}/kernel.meta ; \
1494 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1495 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1496 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1497 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1498 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1499 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1500 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1501 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1502 ${SRCDIR}/release/packages/kernel.ucl \
1503 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1505 /name/ { printf("===> Creating %s-", $$2); next } \
1506 /version/ {print $$2; next } ' \
1507 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1508 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1509 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1510 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1511 -r ${KSTAGEDIR}/${DISTDIR} \
1512 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1515 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1516 .for _kernel in ${BUILDKERNELS:[2..-1]}
1517 .if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1518 .if ${MK_DEBUG_FILES} != "no"
1521 .for flavor in "" ${_debug}
1522 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1523 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1524 -v kernel=yes -v _kernconf=${_kernel} \
1525 ${KSTAGEDIR}/kernel.${_kernel}.meta ; \
1526 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1527 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1528 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1529 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1530 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1531 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1532 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1533 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1534 ${SRCDIR}/release/packages/kernel.ucl \
1535 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1537 /name/ { printf("===> Creating %s-", $$2); next } \
1538 /version/ {print $$2; next } ' \
1539 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1540 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1541 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1542 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1543 -r ${KSTAGEDIR}/kernel.${_kernel} \
1544 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1550 sign-packages: _pkgbootstrap .PHONY
1551 @[ -L "${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1552 unlink ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1553 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1554 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1555 ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1557 cd ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI); \
1558 ln -s ${PKG_VERSION} latest
1564 # Run test suite on installed world.
1567 @if [ ! -x "${LOCALBASE}/bin/kyua" ]; then \
1568 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1571 ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile
1577 # Build the API documentation with doxygen
1580 @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \
1581 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1584 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1589 # Update the source tree(s), by running svn/svnup to update to the
1593 .if defined(SVN_UPDATE)
1594 @echo "--------------------------------------------------------------"
1595 @echo ">>> Updating ${.CURDIR} using Subversion"
1596 @echo "--------------------------------------------------------------"
1597 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1601 # ------------------------------------------------------------------------
1603 # From here onwards are utility targets used by the 'make world' and
1604 # related targets. If your 'world' breaks, you may like to try to fix
1605 # the problem and manually run the following targets to attempt to
1606 # complete the build. Beware, this is *not* guaranteed to work, you
1607 # need to have a pretty good grip on the current state of the system
1608 # to attempt to manually finish it. If in doubt, 'make world' again.
1612 # legacy: Build compatibility shims for the next three targets. This is a
1613 # minimal set of tools and shims necessary to compensate for older systems
1614 # which don't have the APIs required by the targets built in bootstrap-tools,
1615 # build-tools or cross-tools.
1618 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1619 # r296685 fix cross-endian objcopy
1620 .if ${BOOTSTRAPPING} < 1100102
1621 _elftoolchain_libs= lib/libelf lib/libdwarf
1625 .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
1626 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
1629 .for _tool in tools/build ${_elftoolchain_libs}
1630 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1631 cd ${.CURDIR}/${_tool}; \
1632 ${MAKE} DIRPRFX=${_tool}/ obj; \
1633 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1634 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
1635 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
1636 DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1640 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1641 # are built to build other binaries in the system. However, the focus of these
1642 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1643 # libraries, augmented by -legacy.
1645 _bt= _bootstrap-tools
1647 .if ${MK_GAMES} != "no"
1648 _strfile= usr.bin/fortune/strfile
1651 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1652 _gperf= gnu/usr.bin/gperf
1655 .if ${MK_SHAREDOCS} != "no" && ${MK_GROFF} != "no"
1656 _groff= gnu/usr.bin/groff \
1660 .if ${MK_VT} != "no"
1661 _vtfontcvt= usr.bin/vtfontcvt
1664 .if ${BOOTSTRAPPING} < 1000033
1665 _libopenbsd= lib/libopenbsd
1669 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1670 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1673 # r245440 mtree -N support added
1674 # r313404 requires sha384.h for libnetbsd, added to libmd in r292782
1675 .if ${BOOTSTRAPPING} < 1100093
1676 _nmtree= lib/libmd \
1680 ${_bt}-lib/libnetbsd: ${_bt}-lib/libmd
1681 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1684 .if ${BOOTSTRAPPING} < 1000027
1688 # r277259 crunchide: Correct 64-bit section header offset
1689 # r281674 crunchide: always include both 32- and 64-bit ELF support
1690 .if ${BOOTSTRAPPING} < 1100078
1691 _crunchide= usr.sbin/crunch/crunchide
1694 # r285986 crunchen: use STRIPBIN rather than STRIP
1695 # 1100113: Support MK_AUTO_OBJ
1696 # 1100509: META_MODE fixes
1697 .if ${BOOTSTRAPPING} < 1100078 || \
1698 (${MK_AUTO_OBJ} == "yes" && ${BOOTSTRAPPING} < 1100114) || \
1699 (${MK_META_MODE} == "yes" && ${BOOTSTRAPPING} < 1200006)
1700 _crunchgen= usr.sbin/crunch/crunchgen
1703 # r296926 -P keymap search path, MFC to stable/10 in r298297
1704 .if ${BOOTSTRAPPING} < 1003501 || \
1705 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
1706 _kbdcontrol= usr.sbin/kbdcontrol
1712 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1714 .if ${MK_BSNMP} != "no"
1715 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1718 # We need to build tblgen when we're building clang or lld, either as
1719 # bootstrap tools, or as the part of the normal build.
1720 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
1721 ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no"
1723 lib/clang/libllvmminimal \
1724 usr.bin/clang/llvm-tblgen \
1725 usr.bin/clang/clang-tblgen
1727 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal
1728 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal
1731 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1734 .if ${MK_GPL_DTC} != "no"
1735 _dtc= gnu/usr.bin/dtc
1738 .if ${MK_KERBEROS} != "no"
1739 _kerberos5_bootstrap_tools= \
1740 kerberos5/tools/make-roken \
1741 kerberos5/lib/libroken \
1742 kerberos5/lib/libvers \
1743 kerberos5/tools/asn1_compile \
1744 kerberos5/tools/slc \
1747 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1750 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
1751 .if ${MK_MANDOCDB} != "no"
1752 _libopenbsd?= lib/libopenbsd
1753 _makewhatis= usr.bin/mandoc
1754 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
1757 bootstrap-tools: .PHONY
1759 # Please document (add comment) why something is in 'bootstrap-tools'.
1760 # Try to bound the building of the bootstrap-tool to just the
1761 # FreeBSD versions that need the tool built at this stage of the build.
1764 ${_kerberos5_bootstrap_tools} \
1786 ${_bt}-${_tool}: .PHONY .MAKE
1787 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1788 cd ${.CURDIR}/${_tool}; \
1789 ${MAKE} DIRPRFX=${_tool}/ obj; \
1790 ${MAKE} DIRPRFX=${_tool}/ all; \
1791 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1793 bootstrap-tools: ${_bt}-${_tool}
1797 # build-tools: Build special purpose build tools
1799 .if !defined(NO_SHARE)
1800 _share= share/syscons/scrnmaps
1803 .if ${MK_GCC} != "no"
1804 _gcc_tools= gnu/usr.bin/cc/cc_tools
1807 .if ${MK_RESCUE} != "no"
1808 # rescue includes programs that have build-tools targets
1809 _rescue=rescue/rescue
1812 .if ${MK_TCSH} != "no"
1819 ${LOCAL_TOOL_DIRS} \
1820 lib/ncurses/ncurses \
1821 lib/ncurses/ncursesw \
1826 usr.bin/mkesdb_static \
1827 usr.bin/mkcsmapper_static \
1829 build-tools_${_tool}: .PHONY
1830 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1831 cd ${.CURDIR}/${_tool}; \
1832 ${MAKE} DIRPRFX=${_tool}/ obj; \
1833 ${MAKE} DIRPRFX=${_tool}/ build-tools
1834 build-tools: build-tools_${_tool}
1838 build-tools_${_tool}: .PHONY
1839 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \
1840 cd ${.CURDIR}/${_tool}; \
1841 ${MAKE} DIRPRFX=${_tool}/ obj; \
1842 ${MAKE} DIRPRFX=${_tool}/ all
1843 build-tools: build-tools_${_tool}
1847 # kernel-tools: Build kernel-building tools
1849 kernel-tools: .PHONY
1850 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1851 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1852 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1855 # cross-tools: All the tools needed to build the rest of the system after
1856 # we get done with the earlier stages. It is the last set of tools needed
1857 # to begin building the target binaries.
1859 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1860 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1861 _btxld= usr.sbin/btxld
1865 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1866 # resulting from missing bug fixes or ELF Toolchain updates.
1867 .if ${MK_CDDL} != "no"
1868 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1869 cddl/usr.bin/ctfmerge
1872 # If we're given an XAS, don't build binutils.
1873 .if ${XAS:M/*} == ""
1874 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1875 _binutils= gnu/usr.bin/binutils
1877 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1878 _elftctools= lib/libelftc \
1884 # These are not required by the build, but can be useful for developers who
1885 # cross-build on a FreeBSD 10 host:
1886 _elftctools+= usr.bin/addr2line
1888 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1889 # If cross-building with an external binutils we still need to build strip for
1890 # the target (for at least crunchide).
1891 _elftctools= lib/libelftc \
1896 .if ${MK_CLANG_BOOTSTRAP} != "no"
1897 _clang= usr.bin/clang
1899 .if ${MK_LLD_BOOTSTRAP} != "no"
1900 _lld= usr.bin/clang/lld
1902 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no"
1903 _clang_libs= lib/clang
1905 .if ${MK_GCC_BOOTSTRAP} != "no"
1906 _gcc= gnu/usr.bin/cc
1908 .if ${MK_USB} != "no"
1909 _usb_tools= stand/usb/tools
1912 cross-tools: .MAKE .PHONY
1923 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1924 cd ${.CURDIR}/${_tool}; \
1925 ${MAKE} DIRPRFX=${_tool}/ obj; \
1926 ${MAKE} DIRPRFX=${_tool}/ all; \
1927 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1930 NXBDESTDIR= ${OBJTREE}/nxb-bin
1931 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1933 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1934 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1935 NXBMAKE= ${NXBENV} ${MAKE} \
1936 LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \
1937 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1938 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1939 MK_GDB=no MK_TESTS=no \
1941 MK_HTML=no NO_LINT=yes MK_MAN=no \
1942 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1943 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1944 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1945 MK_LLDB=no MK_DEBUG_FILES=no
1947 # native-xtools is the current target for qemu-user cross builds of ports
1948 # via poudriere and the imgact_binmisc kernel module.
1949 # For non-clang enabled targets that are still using the in tree gcc
1950 # we must build a gperf binary for one instance of its Makefiles. On
1951 # clang-enabled systems, the gperf binary is obsolete.
1952 native-xtools: .PHONY
1953 .if ${MK_GCC_BOOTSTRAP} != "no"
1954 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1955 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \
1956 cd ${.CURDIR}/${_gperf}; \
1957 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1958 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1959 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1961 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1962 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1963 -p ${NXBDESTDIR}/usr >/dev/null
1964 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1965 -p ${NXBDESTDIR}/usr/include >/dev/null
1966 .if ${MK_DEBUG_FILES} != "no"
1967 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1968 -p ${NXBDESTDIR}/usr/lib >/dev/null
2030 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2031 cd ${.CURDIR}/${_tool}; \
2032 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
2033 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
2034 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
2038 # hierarchy - ensure that all the needed directories are present
2040 hierarchy hier: .MAKE .PHONY
2041 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
2044 # libraries - build all libraries, and install them under ${DESTDIR}.
2046 # The list of libraries with dependents (${_prebuild_libs}) and their
2047 # interdependencies (__L) are built automatically by the
2048 # ${.CURDIR}/tools/make_libdeps.sh script.
2050 libraries: .MAKE .PHONY
2051 ${_+_}cd ${.CURDIR}; \
2052 ${MAKE} -f Makefile.inc1 _prereq_libs; \
2053 ${MAKE} -f Makefile.inc1 _startup_libs; \
2054 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
2055 ${MAKE} -f Makefile.inc1 _generic_libs
2058 # static libgcc.a prerequisite for shared libc
2060 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
2062 # These dependencies are not automatically generated:
2064 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
2065 # all shared libraries for ELF.
2067 _startup_libs= gnu/lib/csu
2068 _startup_libs+= lib/csu
2069 _startup_libs+= gnu/lib/libgcc
2070 _startup_libs+= lib/libcompiler_rt
2071 _startup_libs+= lib/libc
2072 _startup_libs+= lib/libc_nonshared
2073 .if ${MK_LIBCPLUSPLUS} != "no"
2074 _startup_libs+= lib/libcxxrt
2077 gnu/lib/libgcc__L: lib/libc__L
2078 gnu/lib/libgcc__L: lib/libc_nonshared__L
2079 .if ${MK_LIBCPLUSPLUS} != "no"
2080 lib/libcxxrt__L: gnu/lib/libgcc__L
2083 _prebuild_libs= ${_kerberos5_lib_libasn1} \
2084 ${_kerberos5_lib_libhdb} \
2085 ${_kerberos5_lib_libheimbase} \
2086 ${_kerberos5_lib_libheimntlm} \
2088 ${_kerberos5_lib_libheimipcc} \
2089 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
2090 ${_kerberos5_lib_libroken} \
2091 ${_kerberos5_lib_libwind} \
2092 lib/libbz2 ${_libcom_err} lib/libcrypt \
2093 lib/libelf lib/libexpat \
2096 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
2098 lib/ncurses/ncurses lib/ncurses/ncursesw \
2099 lib/libopie lib/libpam/libpam ${_lib_libthr} \
2100 ${_lib_libradius} lib/libsbuf lib/libtacplus \
2102 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
2103 ${_cddl_lib_libuutil} \
2104 ${_cddl_lib_libavl} \
2105 ${_cddl_lib_libzfs_core} \
2106 ${_cddl_lib_libctf} \
2107 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
2108 ${_secure_lib_libcrypto} ${_lib_libldns} \
2109 ${_secure_lib_libssh} ${_secure_lib_libssl}
2111 .if ${MK_GNUCXX} != "no"
2112 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
2113 gnu/lib/libstdc++__L: lib/msun__L
2114 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
2117 .if ${MK_DIALOG} != "no"
2118 _prebuild_libs+= gnu/lib/libdialog
2119 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2122 .if ${MK_LIBCPLUSPLUS} != "no"
2123 _prebuild_libs+= lib/libc++
2126 lib/libgeom__L: lib/libexpat__L
2127 lib/libkvm__L: lib/libelf__L
2129 .if ${MK_LIBTHR} != "no"
2130 _lib_libthr= lib/libthr
2133 .if ${MK_RADIUS_SUPPORT} != "no"
2134 _lib_libradius= lib/libradius
2137 .if ${MK_OFED} != "no"
2138 _ofed_lib= contrib/ofed/usr.lib
2139 _prebuild_libs+= contrib/ofed/usr.lib/libosmcomp
2140 _prebuild_libs+= contrib/ofed/usr.lib/libopensm
2141 _prebuild_libs+= contrib/ofed/usr.lib/libibcommon
2142 _prebuild_libs+= contrib/ofed/usr.lib/libibverbs
2143 _prebuild_libs+= contrib/ofed/usr.lib/libibumad
2145 contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
2146 contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
2147 contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
2150 .if ${MK_CASPER} != "no"
2151 _lib_casper= lib/libcasper
2154 lib/libpjdlog__L: lib/libutil__L
2155 lib/libcasper__L: lib/libnv__L
2156 lib/liblzma__L: lib/libthr__L
2158 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib}
2159 .for _DIR in ${LOCAL_LIB_DIRS}
2160 .if ${_DIR} == ".WAIT" || (empty(_generic_libs:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
2161 _generic_libs+= ${_DIR}
2165 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2167 .if ${MK_CDDL} != "no"
2168 _cddl_lib_libumem= cddl/lib/libumem
2169 _cddl_lib_libnvpair= cddl/lib/libnvpair
2170 _cddl_lib_libavl= cddl/lib/libavl
2171 _cddl_lib_libuutil= cddl/lib/libuutil
2172 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2173 _cddl_lib_libctf= cddl/lib/libctf
2175 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2176 cddl/lib/libzfs__L: lib/libgeom__L
2177 cddl/lib/libctf__L: lib/libz__L
2179 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
2180 # on select architectures though (see cddl/lib/Makefile)
2181 .if ${MACHINE_CPUARCH} != "sparc64"
2182 _prebuild_libs+= lib/libproc lib/librtld_db
2185 .if ${MK_CRYPT} != "no"
2186 .if ${MK_OPENSSL} != "no"
2187 _secure_lib_libcrypto= secure/lib/libcrypto
2188 _secure_lib_libssl= secure/lib/libssl
2189 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2190 .if ${MK_LDNS} != "no"
2191 _lib_libldns= lib/libldns
2192 lib/libldns__L: secure/lib/libcrypto__L
2194 .if ${MK_OPENSSH} != "no"
2195 _secure_lib_libssh= secure/lib/libssh
2196 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2197 .if ${MK_LDNS} != "no"
2198 secure/lib/libssh__L: lib/libldns__L
2200 .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no"
2201 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2202 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2203 lib/libmd__L kerberos5/lib/libroken__L
2207 _secure_lib= secure/lib
2210 .if ${MK_KERBEROS} != "no"
2211 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2212 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2213 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2214 kerberos5/lib/libwind__L lib/libsqlite3__L
2215 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2216 kerberos5/lib/libroken__L lib/libcom_err__L
2217 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2218 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2219 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2220 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2221 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2222 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2223 kerberos5/lib/libroken__L: lib/libcrypt__L
2224 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2225 kerberos5/lib/libheimbase__L: lib/libthr__L
2226 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2229 lib/libsqlite3__L: lib/libthr__L
2231 .if ${MK_GSSAPI} != "no"
2232 _lib_libgssapi= lib/libgssapi
2235 .if ${MK_KERBEROS} != "no"
2236 _kerberos5_lib= kerberos5/lib
2237 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2238 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2239 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2240 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2241 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2242 _kerberos5_lib_libroken= kerberos5/lib/libroken
2243 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2244 _libsqlite3= lib/libsqlite3
2245 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2246 _kerberos5_lib_libwind= kerberos5/lib/libwind
2247 _libcom_err= lib/libcom_err
2250 .if ${MK_NIS} != "no"
2251 _lib_libypclnt= lib/libypclnt
2254 .if ${MK_OPENSSL} == "no"
2255 lib/libradius__L: lib/libmd__L
2259 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2260 .if ${MK_CXX} != "no"
2261 .if ${MK_LIBCPLUSPLUS} != "no"
2262 lib/libproc__L: lib/libcxxrt__L
2263 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2264 lib/libproc__L: gnu/lib/libsupc++__L
2268 .for _lib in ${_prereq_libs}
2269 ${_lib}__PL: .PHONY .MAKE
2270 .if exists(${.CURDIR}/${_lib})
2271 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2272 cd ${.CURDIR}/${_lib}; \
2273 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2274 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2275 DIRPRFX=${_lib}/ all; \
2276 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2277 DIRPRFX=${_lib}/ install
2281 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
2282 ${_lib}__L: .PHONY .MAKE
2283 .if exists(${.CURDIR}/${_lib})
2284 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2285 cd ${.CURDIR}/${_lib}; \
2286 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2287 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
2288 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2292 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2293 _startup_libs: ${_startup_libs:S/$/__L/}
2294 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2295 _generic_libs: ${_generic_libs:S/$/__L/}
2297 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2298 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2299 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2300 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2301 # parallel. This is safe for the world stage of buildworld though since it has
2302 # already built libraries in a proper order and installed includes into
2303 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2304 # avoid trashing a system if it crashes mid-install.
2305 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2309 .include <bsd.subdir.mk>
2311 .if make(check-old) || make(check-old-dirs) || \
2312 make(check-old-files) || make(check-old-libs) || \
2313 make(delete-old) || make(delete-old-dirs) || \
2314 make(delete-old-files) || make(delete-old-libs)
2317 # check for / delete old files section
2320 .include "ObsoleteFiles.inc"
2322 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2323 else you can not start such an application. Consult UPDATING for more \
2324 information regarding how to cope with the removal/revision bump of a \
2327 .if !defined(BATCH_DELETE_OLD_FILES)
2333 delete-old-files: .PHONY
2334 @echo ">>> Removing old files (only deletes safe to delete libs)"
2335 # Ask for every old file if the user really wants to remove it.
2336 # It's annoying, but better safe than sorry.
2337 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2338 # argument list will get too long. Using .for/.endfor make "loops" will make
2339 # the Makefile parser segfault.
2342 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2343 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2344 while read file; do \
2345 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2346 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2347 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2349 for ext in debug symbols; do \
2350 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2351 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2352 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2357 # Remove catpages without corresponding manpages.
2359 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2360 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2361 while read catpage; do \
2363 if [ ! -e "$${manpage}" ]; then \
2364 rm ${RM_I} $${catpage} <&3; \
2367 @echo ">>> Old files removed"
2369 check-old-files: .PHONY
2370 @echo ">>> Checking for old files"
2372 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2373 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2374 while read file; do \
2375 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2376 echo "${DESTDIR}/$${file}"; \
2378 for ext in debug symbols; do \
2379 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2380 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2384 # Check for catpages without corresponding manpages.
2385 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2386 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2387 while read catpage; do \
2389 if [ ! -e "$${manpage}" ]; then \
2394 delete-old-libs: .PHONY
2395 @echo ">>> Removing old libraries"
2396 @echo "${OLD_LIBS_MESSAGE}" | fmt
2399 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2400 -V OLD_LIBS | xargs -n1 | \
2401 while read file; do \
2402 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2403 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2404 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2406 for ext in debug symbols; do \
2407 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2408 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2409 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2414 @echo ">>> Old libraries removed"
2416 check-old-libs: .PHONY
2417 @echo ">>> Checking for old libraries"
2419 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2420 -V OLD_LIBS | xargs -n1 | \
2421 while read file; do \
2422 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2423 echo "${DESTDIR}/$${file}"; \
2425 for ext in debug symbols; do \
2426 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2427 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2432 delete-old-dirs: .PHONY
2433 @echo ">>> Removing old directories"
2435 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2436 -V OLD_DIRS | xargs -n1 | sort -r | \
2437 while read dir; do \
2438 if [ -d "${DESTDIR}/$${dir}" ]; then \
2439 rmdir -v "${DESTDIR}/$${dir}" || true; \
2440 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2441 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2443 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2444 rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \
2445 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2446 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2449 @echo ">>> Old directories removed"
2451 check-old-dirs: .PHONY
2452 @echo ">>> Checking for old directories"
2454 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2455 -V OLD_DIRS | xargs -n1 | \
2456 while read dir; do \
2457 if [ -d "${DESTDIR}/$${dir}" ]; then \
2458 echo "${DESTDIR}/$${dir}"; \
2459 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2460 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2462 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2463 echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \
2464 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2465 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2469 delete-old: delete-old-files delete-old-dirs .PHONY
2470 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2472 check-old: check-old-files check-old-libs check-old-dirs .PHONY
2473 @echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
2474 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2479 # showconfig - show build configuration.
2482 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2483 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2485 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2486 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2488 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2489 .if exists(${KERNCONFDIR}/${KERNCONF})
2490 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2491 '${KERNCONFDIR}/${KERNCONF}' ; echo
2497 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2498 DTBOUTPUTPATH= ${.CURDIR}
2502 # Build 'standalone' Device Tree Blob
2505 @PATH=${TMPPATH} MACHINE=${TARGET} \
2506 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2507 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2512 # In the following, the first 'rm' in a series will usually remove all
2513 # files and directories. If it does not, then there are probably some
2514 # files with file flags set, so this unsets them and tries the 'rm' a
2515 # second time. There are situations where this target will be cleaning
2516 # some directories via more than one method, but that duplication is
2517 # needed to correctly handle all the possible situations. Removing all
2518 # files without file flags set in the first 'rm' instance saves time,
2519 # because 'chflags' will need to operate on fewer files afterwards.
2521 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2522 # created by bsd.obj.mk, except that we don't want to .include that file
2525 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2527 .if exists(${BW_CANONICALOBJDIR}/)
2528 -rm -rf ${BW_CANONICALOBJDIR}/*
2529 -chflags -R 0 ${BW_CANONICALOBJDIR}
2530 rm -rf ${BW_CANONICALOBJDIR}/*
2532 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2533 # To be safe in this case, fall back to a 'make cleandir'
2534 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2537 .if defined(TARGET) && defined(TARGET_ARCH)
2539 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2540 XDEV_CPUTYPE?=${CPUTYPE}
2542 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2545 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2546 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2547 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2548 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2549 CPUTYPE=${XDEV_CPUTYPE}
2551 XDDIR=${TARGET_ARCH}-freebsd
2554 .error XDTP variable should be an absolute path
2557 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2558 INSTALL="sh ${.CURDIR}/tools/install.sh"
2560 TOOLS_PREFIX=${XDTP}
2562 .if ${WANT_COMPILER_TYPE} == gcc || \
2563 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
2564 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
2565 # won't set header path and -L is used to ensure the base library path
2566 # is added before the port PREFIX library path.
2567 CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib
2568 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
2569 # combined with --sysroot.
2570 CD2CFLAGS+= -B${XDDESTDIR}/usr/lib
2571 # Force using libc++ for external GCC.
2572 .if ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
2573 CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \
2577 CD2CFLAGS+= --sysroot=${XDDESTDIR}/
2578 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \
2579 CPP="${CPP} ${CD2CFLAGS}" \
2580 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2582 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2583 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2584 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2585 .if ${MK_META_MODE} != "no"
2586 # Don't rebuild build-tools targets during normal build.
2587 CD2MAKE+= BUILD_TOOLS_META=.NOMETA
2589 XDDESTDIR=${DESTDIR}/${XDTP}
2591 .ORDER: xdev-build xdev-install xdev-links
2592 xdev: xdev-build xdev-install .PHONY
2594 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2595 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
2597 _xb-worldtmp: .PHONY
2598 mkdir -p ${CDTMP}/usr
2599 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2600 -p ${CDTMP}/usr >/dev/null
2602 _xb-bootstrap-tools: .PHONY
2607 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2608 cd ${.CURDIR}/${_tool}; \
2609 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2610 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2611 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2614 _xb-build-tools: .PHONY
2615 ${_+_}@cd ${.CURDIR}; \
2616 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2618 _xb-cross-tools: .PHONY
2626 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2627 cd ${.CURDIR}/${_tool}; \
2628 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2629 ${CDMAKE} DIRPRFX=${_tool}/ all
2633 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2634 mkdir -p ${XDDESTDIR}
2635 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2636 -p ${XDDESTDIR} >/dev/null
2637 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2638 -p ${XDDESTDIR}/usr >/dev/null
2639 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2640 -p ${XDDESTDIR}/usr/include >/dev/null
2641 .if defined(LIBCOMPAT)
2642 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2643 -p ${XDDESTDIR}/usr >/dev/null
2645 .if ${MK_TESTS} != "no"
2646 mkdir -p ${XDDESTDIR}${TESTSBASE}
2647 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2648 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2651 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2652 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
2654 _xi-cross-tools: .PHONY
2655 @echo "_xi-cross-tools"
2663 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2664 cd ${.CURDIR}/${_tool}; \
2665 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2668 _xi-includes: .PHONY
2669 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2670 DESTDIR=${XDDESTDIR}
2672 _xi-libraries: .PHONY
2673 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2674 DESTDIR=${XDDESTDIR}
2677 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2678 mkdir -p ../../../../usr/bin; \
2680 ln -sf ../../${XDTP}/usr/bin/$$i \
2681 ../../../../usr/bin/${XDDIR}-$$i; \
2682 ln -sf ../../${XDTP}/usr/bin/$$i \
2683 ../../../../usr/bin/${XDDIR}${_REVISION}-$$i; \
2686 xdev xdev-build xdev-install xdev-links: .PHONY
2687 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"