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) || make(distributeworld) || \
90 .-include "${OBJTREE}${.CURDIR}/compiler-metadata.mk"
91 .if !defined(_LOADED_COMPILER_METADATA)
92 .error A build is required first. You may have the wrong MAKEOBJDIRPREFIX set.
96 # Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early.
97 .include <bsd.compiler.mk>
98 .include "share/mk/src.opts.mk"
100 # Check if there is a local compiler that can satisfy as an external compiler.
101 # Which compiler is expected to be used?
102 .if ${MK_CLANG_BOOTSTRAP} == "yes"
103 WANT_COMPILER_TYPE= clang
104 .elif ${MK_GCC_BOOTSTRAP} == "yes"
105 WANT_COMPILER_TYPE= gcc
109 .if !defined(WANT_COMPILER_FREEBSD_VERSION)
110 .if ${WANT_COMPILER_TYPE} == "clang"
111 WANT_COMPILER_FREEBSD_VERSION_FILE= lib/clang/freebsd_cc_version.h
112 WANT_COMPILER_FREEBSD_VERSION!= \
113 awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
114 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
115 WANT_COMPILER_VERSION_FILE= lib/clang/include/clang/Basic/Version.inc
116 WANT_COMPILER_VERSION!= \
117 awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
118 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
119 .elif ${WANT_COMPILER_TYPE} == "gcc"
120 WANT_COMPILER_FREEBSD_VERSION_FILE= gnu/usr.bin/cc/cc_tools/freebsd-native.h
121 WANT_COMPILER_FREEBSD_VERSION!= \
122 awk '$$2 == "FBSD_CC_VER" {printf("%d\n", $$3)}' \
123 ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
124 WANT_COMPILER_VERSION_FILE= contrib/gcc/BASE-VER
125 WANT_COMPILER_VERSION!= \
126 awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3}' \
127 ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
129 .export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION
130 .endif # !defined(WANT_COMPILER_FREEBSD_VERSION)
131 # It needs to be the same revision as we would build for the bootstrap.
132 # If the expected vs CC is different then we can't skip.
133 # GCC cannot be used for cross-arch yet. For clang we pass -target later if
134 # TARGET_ARCH!=MACHINE_ARCH.
135 .if ${MK_SYSTEM_COMPILER} == "yes" && \
136 (${MK_CLANG_BOOTSTRAP} == "yes" || ${MK_GCC_BOOTSTRAP} == "yes") && \
137 !make(showconfig) && !make(native-xtools) && !make(xdev*) && \
138 ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE} && \
139 (${COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \
140 ${COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \
141 ${COMPILER_FREEBSD_VERSION} == ${WANT_COMPILER_FREEBSD_VERSION}
142 # Everything matches, disable the bootstrap compiler.
143 MK_CLANG_BOOTSTRAP= no
145 USING_SYSTEM_COMPILER= yes
146 .endif # ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE}
147 USING_SYSTEM_COMPILER?= no
148 TEST_SYSTEM_COMPILER_VARS= \
149 USING_SYSTEM_COMPILER MK_SYSTEM_COMPILER \
150 MK_CROSS_COMPILER MK_CLANG_BOOTSTRAP MK_GCC_BOOTSTRAP \
151 WANT_COMPILER_TYPE WANT_COMPILER_VERSION WANT_COMPILER_VERSION_FILE \
152 WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \
153 CC COMPILER_TYPE COMPILER_FEATURES COMPILER_VERSION \
154 COMPILER_FREEBSD_VERSION \
155 LINKER_TYPE LINKER_FEATURES LINKER_VERSION
156 test-system-compiler: .PHONY
157 .for v in ${TEST_SYSTEM_COMPILER_VARS}
158 ${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}"
160 .if ${USING_SYSTEM_COMPILER} == "yes" && \
161 (make(buildworld) || make(buildkernel) || make(kernel-toolchain) || \
162 make(toolchain) || make(_cross-tools))
163 .info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler.
166 # For installworld need to ensure that the looked-up compiler metadata is
167 # passed along rather than trying to run cc from the restricted
169 .if ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
170 .if !defined(X_COMPILER_TYPE)
171 CROSSENV+= COMPILER_VERSION=${COMPILER_VERSION} \
172 COMPILER_TYPE=${COMPILER_TYPE} \
173 COMPILER_FEATURES="${COMPILER_FEATURES}" \
174 COMPILER_FREEBSD_VERSION=${COMPILER_FREEBSD_VERSION}
176 CROSSENV+= COMPILER_VERSION=${X_COMPILER_VERSION} \
177 COMPILER_FEATURES="${X_COMPILER_FEATURES}" \
178 COMPILER_TYPE=${X_COMPILER_TYPE} \
179 COMPILER_FREEBSD_VERSION=${X_COMPILER_FREEBSD_VERSION}
182 # Store some compiler metadata for use in installworld where we don't
183 # want to invoke CC at all.
184 _COMPILER_METADATA_VARS= COMPILER_VERSION \
187 COMPILER_FREEBSD_VERSION \
191 compiler-metadata.mk: .PHONY .META
193 @echo ".info Using cached compiler metadata from build at $$(hostname) on $$(date)" \
195 @echo "_LOADED_COMPILER_METADATA=t" >> ${.TARGET}
196 .for v in ${_COMPILER_METADATA_VARS}
197 @echo "${v}=${${v}}" >> ${.TARGET}
199 @echo ".export ${_COMPILER_METADATA_VARS}" >> ${.TARGET}
201 # Handle external binutils.
202 .if defined(CROSS_TOOLCHAIN_PREFIX)
203 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
205 # If we do not have a bootstrap binutils (because the in-tree one does not
206 # support the target architecture), provide a default cross-binutils prefix.
207 # This allows riscv64 builds, for example, to automatically use the
208 # riscv64-binutils port or package.
209 .if !make(showconfig)
210 .if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
211 ${MK_LLD_BOOTSTRAP} == "no" && \
212 !defined(CROSS_BINUTILS_PREFIX)
213 CROSS_BINUTILS_PREFIX=/usr/local/${TARGET_ARCH}-freebsd/bin/
214 .if !exists(${CROSS_BINUTILS_PREFIX})
215 .error In-tree binutils does not support the ${TARGET_ARCH} architecture. Install the ${TARGET_ARCH}-binutils port or package or set CROSS_BINUTILS_PREFIX.
219 XBINUTILS= AS AR LD NM OBJCOPY OBJDUMP RANLIB SIZE STRINGS
220 .for BINUTIL in ${XBINUTILS}
221 .if defined(CROSS_BINUTILS_PREFIX) && \
222 exists(${CROSS_BINUTILS_PREFIX}${${BINUTIL}})
223 X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
225 X${BINUTIL}?= ${${BINUTIL}}
230 # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
231 # keep the users system reasonably usable. For static->dynamic root upgrades,
232 # we don't want to install a dynamic binary without rtld and the needed
233 # libraries. More commonly, for dynamic root, we don't want to install a
234 # binary that requires a newer library version that hasn't been installed yet.
235 # This ordering is not a guarantee though. The only guarantee of a working
236 # system here would require fine-grained ordering of all components based
237 # on their dependencies.
238 .if !empty(SUBDIR_OVERRIDE)
239 SUBDIR= ${SUBDIR_OVERRIDE}
242 # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
243 # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
244 # LOCAL_LIB_DIRS=foo/lib to behave as expected.
245 .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
246 _REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
248 .for _DIR in ${LOCAL_LIB_DIRS}
249 .if ${_DIR} == ".WAIT" || (empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
253 .if !defined(NO_ROOT) && (make(installworld) || make(install))
254 # Ensure libraries are installed before progressing.
258 .if ${MK_CDDL} != "no"
262 .if ${MK_KERBEROS} != "no"
265 .if ${MK_RESCUE} != "no"
269 .if ${MK_CRYPT} != "no"
272 .if !defined(NO_SHARE)
275 .if ${MK_BOOT} != "no"
278 SUBDIR+=sys usr.bin usr.sbin
279 .if ${MK_TESTS} != "no"
283 # Local directories are built in parallel with the base system directories.
284 # Users may insert a .WAIT directive at the beginning or elsewhere within
285 # the LOCAL_DIRS and LOCAL_LIB_DIRS lists as needed.
286 .for _DIR in ${LOCAL_DIRS}
287 .if ${_DIR} == ".WAIT" || exists(${.CURDIR}/${_DIR}/Makefile)
292 # We must do etc/ last as it hooks into building the man whatis file
293 # by calling 'makedb' in share/man. This is only relevant for
294 # install/distribute so they build the whatis file after every manpage is
296 .if make(installworld) || make(install)
301 .endif # !empty(SUBDIR_OVERRIDE)
304 .warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
307 .if defined(NO_CLEANDIR)
308 CLEANDIR= clean cleandepend
313 .if ${MK_META_MODE} == "yes"
314 # If filemon is used then we can rely on the build being incremental-safe.
315 # The .meta files will also track the build command and rebuild should
317 .if empty(.MAKE.MODE:Mnofilemon)
323 PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
325 .if empty(SHELL:M*csh*)
326 BUILDENV_SHELL?=${SHELL}
328 BUILDENV_SHELL?=/bin/sh
331 .if !defined(SVN) || empty(SVN)
332 . for _P in /usr/bin /usr/local/bin
333 . for _S in svn svnlite
334 . if exists(${_P}/${_S})
342 .if !defined(OSRELDATE)
343 .if exists(/usr/include/osreldate.h)
344 OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
345 /usr/include/osreldate.h
352 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
353 .if !defined(_REVISION)
354 _REVISION!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V REVISION
357 .if !defined(_BRANCH)
358 _BRANCH!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V BRANCH
361 .if !defined(SRCRELDATE)
362 SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
363 ${SRCDIR}/sys/sys/param.h
366 .if !defined(VERSION)
367 VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
371 .if !defined(PKG_VERSION)
372 .if ${_BRANCH:MSTABLE*} || ${_BRANCH:MCURRENT*} || ${_BRANCH:MALPHA*}
373 TIMENOW= %Y%m%d%H%M%S
374 EXTRA_REVISION= .s${TIMENOW:gmtime}
377 EXTRA_REVISION= _${_BRANCH:C/.*-p([0-9]+$)/\1/}
379 PKG_VERSION= ${_REVISION}${EXTRA_REVISION}
382 KNOWN_ARCHES?= aarch64/arm64 \
400 .if ${TARGET} == ${TARGET_ARCH}
403 _t= ${TARGET_ARCH}/${TARGET}
406 .if empty(KNOWN_ARCHES:M${_t})
407 .error Unknown target ${TARGET_ARCH}:${TARGET}.
411 .if ${TARGET} == ${MACHINE}
412 TARGET_CPUTYPE?=${CPUTYPE}
417 .if !empty(TARGET_CPUTYPE)
418 _TARGET_CPUTYPE=${TARGET_CPUTYPE}
420 _TARGET_CPUTYPE=dummy
422 _CPUTYPE!= MK_AUTO_OBJ=no MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
423 -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE
424 .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
425 .error CPUTYPE global should be set with ?=.
428 BUILD_ARCH!= uname -p
429 .if ${MACHINE_ARCH} != ${BUILD_ARCH}
430 .error To cross-build, set TARGET_ARCH.
433 WORLDTMP= ${OBJTREE}${.CURDIR}/tmp
434 BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin
435 XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
436 STRICTTMPPATH= ${BPATH}:${XPATH}
437 TMPPATH= ${STRICTTMPPATH}:${PATH}
440 # Avoid running mktemp(1) unless actually needed.
441 # It may not be functional, e.g., due to new ABI
442 # when in the middle of installing over this system.
444 .if make(distributeworld) || make(installworld) || make(stageworld)
445 INSTALLTMP!= /usr/bin/mktemp -d -u -t install
448 .if make(stagekernel) || make(distributekernel)
454 # Building a world goes through the following stages
456 # 1. legacy stage [BMAKE]
457 # This stage is responsible for creating compatibility
458 # shims that are needed by the bootstrap-tools,
459 # build-tools and cross-tools stages. These are generally
460 # APIs that tools from one of those three stages need to
461 # build that aren't present on the host.
462 # 1. bootstrap-tools stage [BMAKE]
463 # This stage is responsible for creating programs that
464 # are needed for backward compatibility reasons. They
465 # are not built as cross-tools.
466 # 2. build-tools stage [TMAKE]
467 # This stage is responsible for creating the object
468 # tree and building any tools that are needed during
469 # the build process. Some programs are listed during
470 # this phase because they build binaries to generate
471 # files needed to build these programs. This stage also
472 # builds the 'build-tools' target rather than 'all'.
473 # 3. cross-tools stage [XMAKE]
474 # This stage is responsible for creating any tools that
475 # are needed for building the system. A cross-compiler is one
476 # of them. This differs from build tools in two ways:
477 # 1. the 'all' target is built rather than 'build-tools'
478 # 2. these tools are installed into TMPPATH for stage 4.
479 # 4. world stage [WMAKE]
480 # This stage actually builds the world.
481 # 5. install stage (optional) [IMAKE]
482 # This stage installs a previously built world.
487 MINIMUM_SUPPORTED_OSREL?= 900044
488 MINIMUM_SUPPORTED_REL?= 9.1
490 # Common environment for world related stages
491 CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
492 MACHINE_ARCH=${TARGET_ARCH} \
494 CPUTYPE=${TARGET_CPUTYPE}
495 .if ${MK_META_MODE} != "no"
496 # Don't rebuild build-tools targets during normal build.
497 CROSSENV+= BUILD_TOOLS_META=.NOMETA
499 .if ${MK_GROFF} != "no"
500 CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
501 GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
502 GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac
504 .if defined(TARGET_CFLAGS)
505 CROSSENV+= ${TARGET_CFLAGS}
508 # bootstrap-tools stage
509 BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
510 TOOLS_PREFIX=${WORLDTMP} \
511 PATH=${BPATH}:${PATH} \
512 WORLDTMP=${WORLDTMP} \
513 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
514 # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
516 BOOTSTRAPPING=${OSRELDATE} \
518 MK_HTML=no NO_LINT=yes MK_MAN=no \
519 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
520 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
521 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
522 MK_LLDB=no MK_TESTS=no \
525 BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
526 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
530 TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
531 ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
532 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
534 BOOTSTRAPPING=${OSRELDATE} \
537 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
538 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
539 MK_LLDB=no MK_TESTS=no
542 XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
543 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
544 MK_GDB=no MK_TESTS=no
547 KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
548 PATH=${BPATH}:${PATH} \
550 KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \
551 ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
553 BOOTSTRAPPING=${OSRELDATE} \
555 MK_HTML=no -DNO_LINT MK_MAN=no \
556 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
557 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no
560 WMAKEENV= ${CROSSENV} \
561 INSTALL="sh ${.CURDIR}/tools/install.sh" \
565 HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
567 HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
570 CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
571 CPP="${XCPP} ${XCFLAGS}" \
572 AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
573 OBJDUMP=${XOBJDUMP} OBJCOPY="${XOBJCOPY}" \
574 RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
577 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
578 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
579 # directory, but the compiler will look in the right place for its
580 # tools so we don't need to tell it where to look.
581 BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
584 # External compiler needs sysroot and target flags.
585 .if ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
586 .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
587 BFLAGS+= -B${WORLDTMP}/usr/bin
589 .if ${TARGET} == "arm"
590 .if ${TARGET_ARCH:Marmv6*} != "" && ${TARGET_CPUTYPE:M*soft*} == ""
591 TARGET_ABI= gnueabihf
596 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
597 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
598 # won't set header path and -L is used to ensure the base library path
599 # is added before the port PREFIX library path.
600 XCFLAGS+= -isystem ${WORLDTMP}/usr/include -L${WORLDTMP}/usr/lib
601 # Force using libc++ for external GCC.
602 .if ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
603 XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \
604 -nostdinc++ -L${WORLDTMP}/../lib/libc++
608 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.2
609 XCFLAGS+= -target ${TARGET_TRIPLE}
611 XCFLAGS+= --sysroot=${WORLDTMP}
612 .endif # ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
618 .if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
619 ${TARGET_ARCH} == "powerpc64")
621 .include "Makefile.libcompat"
622 .elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH} == "armv6"
624 .include "Makefile.libcompat"
627 WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
629 IMAKEENV= ${CROSSENV}
630 IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
631 ${IMAKE_INSTALL} ${IMAKE_MTREE}
632 .if empty(.MAKEFLAGS:M-n)
633 IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
634 LD_LIBRARY_PATH=${INSTALLTMP} \
635 PATH_LOCALE=${INSTALLTMP}/locale
636 IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
638 IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
640 .if defined(DB_FROM_SRC)
641 INSTALLFLAGS+= -N ${.CURDIR}/etc
642 MTREEFLAGS+= -N ${.CURDIR}/etc
644 _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
645 INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
647 METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
648 METALOG:= ${METALOG:C,//+,/,g}
649 IMAKE+= -DNO_ROOT METALOG=${METALOG}
650 INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
653 .if defined(BUILD_PKGS)
654 INSTALLFLAGS+= -h sha256
656 .if defined(DB_FROM_SRC) || defined(NO_ROOT)
657 IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}"
658 IMAKE_MTREE= MTREE_CMD="mtree ${MTREEFLAGS}"
662 KMAKEENV= ${WMAKEENV}
663 KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
668 # Attempt to rebuild the entire system, with reasonable chance of
669 # success, regardless of how old your existing system is.
672 .if ${.CURDIR:C/[^,]//g} != ""
673 # The m4 build of sendmail files doesn't like it if ',' is used
674 # anywhere in the path of it's files.
676 @echo "*** Error: path to source tree contains a comma ','"
681 @echo "--------------------------------------------------------------"
682 @echo ">>> Rebuilding the temporary build tree"
683 @echo "--------------------------------------------------------------"
684 .if !defined(NO_CLEAN)
686 .if defined(LIBCOMPAT)
687 rm -rf ${LIBCOMPATTMP}
690 rm -rf ${WORLDTMP}/legacy/usr/include
691 .if ${USING_SYSTEM_COMPILER} == "yes"
693 if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \
694 inum=$$(stat -f %i ${WORLDTMP}/usr/bin/${cc}); \
695 find ${WORLDTMP}/usr/bin -inum $${inum} -delete; \
698 .endif # ${USING_SYSTEM_COMPILER} == "yes"
699 .endif # !defined(NO_CLEAN)
701 lib lib/casper usr legacy/bin legacy/usr
702 mkdir -p ${WORLDTMP}/${_dir}
704 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
705 -p ${WORLDTMP}/legacy/usr >/dev/null
706 .if ${MK_GROFF} != "no"
707 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \
708 -p ${WORLDTMP}/legacy/usr >/dev/null
710 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
711 -p ${WORLDTMP}/legacy/usr/include >/dev/null
712 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
713 -p ${WORLDTMP}/usr >/dev/null
714 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
715 -p ${WORLDTMP}/usr/include >/dev/null
716 ln -sf ${.CURDIR}/sys ${WORLDTMP}
717 .if ${MK_DEBUG_FILES} != "no"
718 # We could instead disable debug files for these build stages
719 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
720 -p ${WORLDTMP}/legacy/usr/lib >/dev/null
721 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
722 -p ${WORLDTMP}/usr/lib >/dev/null
724 .if defined(LIBCOMPAT)
725 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
726 -p ${WORLDTMP}/usr >/dev/null
727 .if ${MK_DEBUG_FILES} != "no"
728 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
729 -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null
730 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
731 -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
734 .if ${MK_TESTS} != "no"
735 mkdir -p ${WORLDTMP}${TESTSBASE}
736 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
737 -p ${WORLDTMP}${TESTSBASE} >/dev/null
738 .if ${MK_DEBUG_FILES} != "no"
739 mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE}
740 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
741 -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null
744 .for _mtree in ${LOCAL_MTREE}
745 mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
749 @echo "--------------------------------------------------------------"
750 @echo ">>> stage 1.1: legacy release compatibility shims"
751 @echo "--------------------------------------------------------------"
752 ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
755 @echo "--------------------------------------------------------------"
756 @echo ">>> stage 1.2: bootstrap tools"
757 @echo "--------------------------------------------------------------"
758 ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
760 .if !defined(NO_CLEAN)
762 @echo "--------------------------------------------------------------"
763 @echo ">>> stage 2.1: cleaning up the object tree"
764 @echo "--------------------------------------------------------------"
765 ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
766 .if defined(LIBCOMPAT)
767 ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
772 @echo "--------------------------------------------------------------"
773 @echo ">>> stage 2.2: rebuilding the object tree"
774 @echo "--------------------------------------------------------------"
775 ${_+_}cd ${.CURDIR}; ${WMAKE} obj
778 @echo "--------------------------------------------------------------"
779 @echo ">>> stage 2.3: build tools"
780 @echo "--------------------------------------------------------------"
781 ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
784 @echo "--------------------------------------------------------------"
785 @echo ">>> stage 3: cross tools"
786 @echo "--------------------------------------------------------------"
787 @rm -f ${OBJTREE}${.CURDIR}/compiler-metadata.mk
788 ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
789 ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
792 @echo "--------------------------------------------------------------"
793 @echo ">>> stage 3.1: recording compiler metadata"
794 @echo "--------------------------------------------------------------"
795 ${_+_}cd ${.CURDIR}; ${WMAKE} compiler-metadata.mk
798 @echo "--------------------------------------------------------------"
799 @echo ">>> stage 4.1: building includes"
800 @echo "--------------------------------------------------------------"
801 # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
802 # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
803 ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
804 MK_INCLUDES=yes includes
805 .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
806 ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
810 @echo "--------------------------------------------------------------"
811 @echo ">>> stage 4.2: building libraries"
812 @echo "--------------------------------------------------------------"
813 ${_+_}cd ${.CURDIR}; \
814 ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
815 MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS} libraries
818 @echo "--------------------------------------------------------------"
819 @echo ">>> stage 4.3: building everything"
820 @echo "--------------------------------------------------------------"
821 ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
824 WMAKE_TGTS+= _worldtmp _legacy
825 .if empty(SUBDIR_OVERRIDE)
826 WMAKE_TGTS+= _bootstrap-tools
828 WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
829 WMAKE_TGTS+= _compiler-metadata
830 WMAKE_TGTS+= _includes _libraries
831 WMAKE_TGTS+= everything
832 .if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
833 WMAKE_TGTS+= build${libcompat}
836 buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
837 .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
839 buildworld_prologue: .PHONY
840 @echo "--------------------------------------------------------------"
841 @echo ">>> World build started on `LC_ALL=C date`"
842 @echo "--------------------------------------------------------------"
844 buildworld_epilogue: .PHONY
846 @echo "--------------------------------------------------------------"
847 @echo ">>> World build completed on `LC_ALL=C date`"
848 @echo "--------------------------------------------------------------"
851 # We need to have this as a target because the indirection between Makefile
852 # and Makefile.inc1 causes the correct PATH to be used, rather than a
853 # modification of the current environment's PATH. In addition, we need
854 # to quote multiword values.
857 @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
859 .if ${.TARGETS:Mbuildenv}
860 .if ${.MAKEFLAGS:M-j}
861 .error The buildenv target is incompatible with -j
864 BUILDENV_DIR?= ${.CURDIR}
866 # Note: make will report any errors the shell reports. This can
867 # be odd if the last command in an interactive shell generates an
868 # error or is terminated by SIGINT. These reported errors look bad,
869 # but are harmless. Allowing them also allows BUIDLENV_SHELL to
870 # be a complex command whose status will be returned to the caller.
871 # Some scripts in tools rely on this behavior to report build errors.
874 @echo Entering world for ${TARGET_ARCH}:${TARGET}
875 .if ${BUILDENV_SHELL:M*zsh*}
876 @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
878 @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL}
880 TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}}
881 toolchain: ${TOOLCHAIN_TGTS} .PHONY
882 kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries} .PHONY
887 # Checks to be sure system is ready for installworld/installkernel.
889 installcheck: _installcheck_world _installcheck_kernel .PHONY
890 _installcheck_world: .PHONY
891 _installcheck_kernel: .PHONY
894 # Require DESTDIR to be set if installing for a different architecture or
895 # using the user/group database in the source tree.
897 .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
899 .if !make(distributeworld)
900 _installcheck_world: __installcheck_DESTDIR
901 _installcheck_kernel: __installcheck_DESTDIR
902 __installcheck_DESTDIR: .PHONY
903 .if !defined(DESTDIR) || empty(DESTDIR)
904 @echo "ERROR: Please set DESTDIR!"; \
910 .if !defined(DB_FROM_SRC)
912 # Check for missing UIDs/GIDs.
914 CHECK_UIDS= auditdistd
916 .if ${MK_SENDMAIL} != "no"
922 CHECK_GIDS+= proxy authpf
924 .if ${MK_UNBOUND} != "no"
928 _installcheck_world: __installcheck_UGID
929 __installcheck_UGID: .PHONY
930 .for uid in ${CHECK_UIDS}
931 @if ! `id -u ${uid} >/dev/null 2>&1`; then \
932 echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
936 .for gid in ${CHECK_GIDS}
937 @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
938 echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
944 # If installing over the running system (DESTDIR is / or unset) and the install
945 # includes rescue, try running rescue from the objdir as a sanity check. If
946 # rescue is not functional (e.g., because it depends on a system call not
947 # supported by the currently running kernel), abort the installation.
949 .if !make(distributeworld) && ${MK_RESCUE} != "no" && \
950 (empty(DESTDIR) || ${DESTDIR} == "/") && empty(BYPASS_INSTALLCHECK_SH)
951 _installcheck_world: __installcheck_sh_check
952 __installcheck_sh_check: .PHONY
953 @if [ "`${OBJTREE}${.CURDIR}/rescue/rescue/rescue sh -c 'echo OK'`" != \
955 echo "rescue/sh check failed, installation aborted" >&2; \
961 # Required install tools to be saved in a scratch dir for safety.
963 .if ${MK_ZONEINFO} != "no"
964 _zoneinfo= zic tzsetup
967 ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
968 date echo egrep find grep id install ${_install-info} \
969 ln make mkdir mtree mv pwd_mkdb \
970 rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
973 # Needed for share/man
974 .if ${MK_MAN_UTILS} != "no"
981 # Distributes everything compiled by a `buildworld'.
985 # Installs everything compiled by a 'buildworld'.
988 # Non-base distributions produced by the base system
989 EXTRA_DISTRIBUTIONS= doc
990 .if defined(LIBCOMPAT)
991 EXTRA_DISTRIBUTIONS+= lib${libcompat}
993 .if ${MK_TESTS} != "no"
994 EXTRA_DISTRIBUTIONS+= tests
998 .if ${MK_DEBUG_FILES} != "no"
999 DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,doc,,:S,tests,,}
1002 MTREE_MAGIC?= mtree 2.0
1004 distributeworld installworld stageworld: _installcheck_world .PHONY
1005 mkdir -p ${INSTALLTMP}
1006 progs=$$(for prog in ${ITOOLS}; do \
1007 if progpath=`which $$prog`; then \
1010 echo "Required tool $$prog not found in PATH." >&2; \
1014 libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
1015 while read line; do \
1017 if [ "$$2 $$3" != "not found" ]; then \
1020 echo "Required library $$1 not found." >&2; \
1024 cp $$libs $$progs ${INSTALLTMP}
1025 cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
1026 .if defined(NO_ROOT)
1027 -mkdir -p ${METALOG:H}
1028 echo "#${MTREE_MAGIC}" > ${METALOG}
1030 .if make(distributeworld)
1031 .for dist in ${EXTRA_DISTRIBUTIONS}
1032 -mkdir ${DESTDIR}/${DISTDIR}/${dist}
1033 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
1034 -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
1035 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1036 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1037 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1038 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
1039 .if ${MK_DEBUG_FILES} != "no"
1040 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1041 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
1043 .if defined(LIBCOMPAT)
1044 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1045 -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
1046 .if ${MK_DEBUG_FILES} != "no"
1047 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
1048 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
1051 .if ${MK_TESTS} != "no" && ${dist} == "tests"
1052 -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
1053 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1054 -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
1055 .if ${MK_DEBUG_FILES} != "no"
1056 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
1057 -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
1060 .if defined(NO_ROOT)
1061 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
1062 sed -e 's#^\./#./${dist}/#' >> ${METALOG}
1063 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
1064 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1065 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
1066 sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
1067 .if defined(LIBCOMPAT)
1068 ${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
1069 sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
1073 -mkdir ${DESTDIR}/${DISTDIR}/base
1074 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1075 METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
1076 DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
1077 LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
1079 ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
1080 ${IMAKEENV} rm -rf ${INSTALLTMP}
1081 .if make(distributeworld)
1082 .for dist in ${EXTRA_DISTRIBUTIONS}
1083 find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete
1085 .if defined(NO_ROOT)
1086 .for dist in base ${EXTRA_DISTRIBUTIONS}
1087 @# For each file that exists in this dist, print the corresponding
1088 @# line from the METALOG. This relies on the fact that
1089 @# a line containing only the filename will sort immediately before
1090 @# the relevant mtree line.
1091 cd ${DESTDIR}/${DISTDIR}; \
1092 find ./${dist} | sort -u ${METALOG} - | \
1093 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1094 ${DESTDIR}/${DISTDIR}/${dist}.meta
1096 .for dist in ${DEBUG_DISTRIBUTIONS}
1097 @# For each file that exists in this dist, print the corresponding
1098 @# line from the METALOG. This relies on the fact that
1099 @# a line containing only the filename will sort immediately before
1100 @# the relevant mtree line.
1101 cd ${DESTDIR}/${DISTDIR}; \
1102 find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
1103 awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
1104 ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
1109 packageworld: .PHONY
1110 .for dist in base ${EXTRA_DISTRIBUTIONS}
1111 .if defined(NO_ROOT)
1112 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1113 tar cvf - --exclude usr/lib/debug \
1114 @${DESTDIR}/${DISTDIR}/${dist}.meta | \
1115 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1117 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1118 tar cvf - --exclude usr/lib/debug . | \
1119 ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
1123 .for dist in ${DEBUG_DISTRIBUTIONS}
1124 . if defined(NO_ROOT)
1125 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1126 tar cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
1127 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1129 ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
1130 tar cvLf - usr/lib/debug | \
1131 ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
1138 # If you have a build server, you can NFS mount the source and obj directories
1139 # and do a 'make reinstall' on the *client* to install new binaries from the
1140 # most recent server build.
1142 restage reinstall: .MAKE .PHONY
1143 @echo "--------------------------------------------------------------"
1144 @echo ">>> Making hierarchy"
1145 @echo "--------------------------------------------------------------"
1146 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1147 LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
1149 @echo "--------------------------------------------------------------"
1150 @echo ">>> Making distribution"
1151 @echo "--------------------------------------------------------------"
1152 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
1153 LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
1156 @echo "--------------------------------------------------------------"
1157 @echo ">>> Installing everything"
1158 @echo "--------------------------------------------------------------"
1159 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
1160 .if defined(LIBCOMPAT)
1161 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
1164 redistribute: .MAKE .PHONY
1165 @echo "--------------------------------------------------------------"
1166 @echo ">>> Distributing everything"
1167 @echo "--------------------------------------------------------------"
1168 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
1169 .if defined(LIBCOMPAT)
1170 ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
1171 DISTRIBUTION=lib${libcompat}
1174 distrib-dirs distribution: .MAKE .PHONY
1175 ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
1176 ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
1177 .if make(distribution)
1178 ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
1179 ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
1180 METALOG=${METALOG} MK_TESTS=no installconfig
1184 # buildkernel and installkernel
1186 # Which kernels to build and/or install is specified by setting
1187 # KERNCONF. If not defined a GENERIC kernel is built/installed.
1188 # Only the existing (depending TARGET) config files are used
1189 # for building kernels and only the first of these is designated
1190 # as the one being installed.
1192 # Note that we have to use TARGET instead of TARGET_ARCH when
1193 # we're in kernel-land. Since only TARGET_ARCH is (expected) to
1194 # be set to cross-build, we have to make sure TARGET is set
1197 .if defined(KERNFAST)
1201 # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
1202 .if !defined(KERNCONF) && ${KERNFAST} != "1"
1203 KERNCONF=${KERNFAST}
1206 .if ${TARGET_ARCH} == "powerpc64"
1207 KERNCONF?= GENERIC64
1211 INSTKERNNAME?= kernel
1213 KERNSRCDIR?= ${.CURDIR}/sys
1214 KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
1215 KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR}
1216 KERNCONFDIR?= ${KRNLCONFDIR}
1220 .if defined(NO_INSTALLKERNEL)
1221 # All of the BUILDKERNELS loops start at index 1.
1222 BUILDKERNELS+= dummy
1224 .for _kernel in ${KERNCONF}
1225 .if exists(${KERNCONFDIR}/${_kernel})
1226 BUILDKERNELS+= ${_kernel}
1227 .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
1228 INSTALLKERNEL= ${_kernel}
1231 .if make(buildkernel)
1232 .error Missing KERNCONF ${KERNCONFDIR}/${_kernel}
1237 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY
1242 # Builds all kernels defined by BUILDKERNELS.
1244 buildkernel: .MAKE .PHONY
1245 .if empty(BUILDKERNELS:Ndummy)
1246 @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
1250 .for _kernel in ${BUILDKERNELS:Ndummy}
1251 @echo "--------------------------------------------------------------"
1252 @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
1253 @echo "--------------------------------------------------------------"
1254 @echo "===> ${_kernel}"
1255 mkdir -p ${KRNLOBJDIR}
1256 .if !defined(NO_KERNELCONFIG)
1258 @echo "--------------------------------------------------------------"
1259 @echo ">>> stage 1: configuring the kernel"
1260 @echo "--------------------------------------------------------------"
1261 cd ${KRNLCONFDIR}; \
1263 config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
1264 -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}'
1266 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
1268 @echo "--------------------------------------------------------------"
1269 @echo ">>> stage 2.1: cleaning up the object tree"
1270 @echo "--------------------------------------------------------------"
1271 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
1273 .if !defined(NO_KERNELOBJ)
1275 @echo "--------------------------------------------------------------"
1276 @echo ">>> stage 2.2: rebuilding the object tree"
1277 @echo "--------------------------------------------------------------"
1278 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
1281 @echo "--------------------------------------------------------------"
1282 @echo ">>> stage 2.3: build tools"
1283 @echo "--------------------------------------------------------------"
1284 ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
1286 @echo "--------------------------------------------------------------"
1287 @echo ">>> stage 3.1: building everything"
1288 @echo "--------------------------------------------------------------"
1289 ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
1290 @echo "--------------------------------------------------------------"
1291 @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
1292 @echo "--------------------------------------------------------------"
1295 NO_INSTALLEXTRAKERNELS?= yes
1298 # installkernel, etc.
1300 # Install the kernel defined by INSTALLKERNEL
1302 installkernel installkernel.debug \
1303 reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
1304 .if !defined(NO_INSTALLKERNEL)
1305 .if empty(INSTALLKERNEL)
1306 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1309 @echo "--------------------------------------------------------------"
1310 @echo ">>> Installing kernel ${INSTALLKERNEL}"
1311 @echo "--------------------------------------------------------------"
1312 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1313 ${CROSSENV} PATH=${TMPPATH} \
1314 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
1316 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1317 .for _kernel in ${BUILDKERNELS:[2..-1]}
1318 @echo "--------------------------------------------------------------"
1319 @echo ">>> Installing kernel ${_kernel}"
1320 @echo "--------------------------------------------------------------"
1321 cd ${KRNLOBJDIR}/${_kernel}; \
1322 ${CROSSENV} PATH=${TMPPATH} \
1323 ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
1327 distributekernel distributekernel.debug: .PHONY
1328 .if !defined(NO_INSTALLKERNEL)
1329 .if empty(INSTALLKERNEL)
1330 @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
1333 mkdir -p ${DESTDIR}/${DISTDIR}
1334 .if defined(NO_ROOT)
1335 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
1337 cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
1338 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
1339 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
1340 DESTDIR=${INSTALL_DDIR}/kernel \
1341 ${.TARGET:S/distributekernel/install/}
1342 .if defined(NO_ROOT)
1343 @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
1344 ${DESTDIR}/${DISTDIR}/kernel.meta
1347 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1348 .for _kernel in ${BUILDKERNELS:[2..-1]}
1349 .if defined(NO_ROOT)
1350 @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
1352 cd ${KRNLOBJDIR}/${_kernel}; \
1353 ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
1354 ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
1355 KERNEL=${INSTKERNNAME}.${_kernel} \
1356 DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
1357 ${.TARGET:S/distributekernel/install/}
1358 .if defined(NO_ROOT)
1359 @sed -e "s|^./kernel.${_kernel}|.|" \
1360 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
1361 ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
1366 packagekernel: .PHONY
1367 .if defined(NO_ROOT)
1368 .if !defined(NO_INSTALLKERNEL)
1369 cd ${DESTDIR}/${DISTDIR}/kernel; \
1370 tar cvf - --exclude '*.debug' \
1371 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1372 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1374 cd ${DESTDIR}/${DISTDIR}/kernel; \
1375 tar cvf - --include '*/*/*.debug' \
1376 @${DESTDIR}/${DISTDIR}/kernel.meta | \
1377 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
1378 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1379 .for _kernel in ${BUILDKERNELS:[2..-1]}
1380 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1381 tar cvf - --exclude '*.debug' \
1382 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1383 ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
1384 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1385 tar cvf - --include '*/*/*.debug' \
1386 @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
1387 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1391 .if !defined(NO_INSTALLKERNEL)
1392 cd ${DESTDIR}/${DISTDIR}/kernel; \
1393 tar cvf - --exclude '*.debug' . | \
1394 ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
1396 cd ${DESTDIR}/${DISTDIR}/kernel; \
1397 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1398 ${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 cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
1405 tar cvf - --include '*/*/*.debug' $$(eval find .) | \
1406 ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
1412 ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
1414 PORTSDIR?= /usr/ports
1415 WSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/worldstage
1416 KSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/kernelstage
1417 REPODIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/repo
1418 PKGSIGNKEY?= # empty
1420 .ORDER: stage-packages create-packages
1421 .ORDER: create-packages create-world-packages
1422 .ORDER: create-packages create-kernel-packages
1423 .ORDER: create-packages sign-packages
1425 _pkgbootstrap: .PHONY
1426 .if !exists(${LOCALBASE}/sbin/pkg)
1427 @env ASSUME_ALWAYS_YES=YES pkg bootstrap
1431 ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} real-packages
1434 rm -rf /tmp/ports.${TARGET} || :
1435 env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
1436 PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \
1437 WSTAGEDIR=${WSTAGEDIR} \
1438 sh ${.CURDIR}/release/scripts/make-pkg-package.sh
1440 real-packages: stage-packages create-packages sign-packages .PHONY
1442 stage-packages: .PHONY
1443 @mkdir -p ${REPODIR} ${WSTAGEDIR} ${KSTAGEDIR}
1444 ${_+_}@cd ${.CURDIR}; \
1445 ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT -B stageworld ; \
1446 ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT -B stagekernel
1448 create-packages: _pkgbootstrap .PHONY
1449 @mkdir -p ${REPODIR}
1450 ${_+_}@cd ${.CURDIR}; \
1451 ${MAKE} DESTDIR=${WSTAGEDIR} \
1452 PKG_VERSION=${PKG_VERSION} create-world-packages ; \
1453 ${MAKE} DESTDIR=${KSTAGEDIR} \
1454 PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
1455 create-kernel-packages
1457 create-world-packages: _pkgbootstrap .PHONY
1458 @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
1459 @cd ${WSTAGEDIR} ; \
1460 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1461 ${WSTAGEDIR}/METALOG
1462 @for plist in ${WSTAGEDIR}/*.plist; do \
1463 plist=$${plist##*/} ; \
1464 pkgname=$${plist%.plist} ; \
1465 sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \
1466 -s ${SRCDIR} -u ${WSTAGEDIR}/$${pkgname}.ucl ; \
1468 @for plist in ${WSTAGEDIR}/*.plist; do \
1469 plist=$${plist##*/} ; \
1470 pkgname=$${plist%.plist} ; \
1472 /^name/ { printf("===> Creating %s-", $$2); next } \
1473 /^version/ { print $$2; next } \
1474 ' ${WSTAGEDIR}/$${pkgname}.ucl ; \
1475 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1476 create -M ${WSTAGEDIR}/$${pkgname}.ucl \
1477 -p ${WSTAGEDIR}/$${pkgname}.plist \
1479 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} ; \
1482 create-kernel-packages: _pkgbootstrap .PHONY
1483 .if exists(${KSTAGEDIR}/kernel.meta)
1484 .for flavor in "" -debug
1485 @cd ${KSTAGEDIR}/${DISTDIR} ; \
1486 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1487 -v kernel=yes -v _kernconf=${INSTALLKERNEL} \
1488 ${KSTAGEDIR}/kernel.meta ; \
1489 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1490 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1491 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1492 -e "s/%PKGNAME%/kernel-${INSTALLKERNEL:tl}${flavor}/" \
1493 -e "s/%KERNELDIR%/kernel/" \
1494 -e "s/%COMMENT%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1495 -e "s/%DESC%/FreeBSD ${INSTALLKERNEL} kernel ${flavor}/" \
1496 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1497 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1498 ${SRCDIR}/release/packages/kernel.ucl \
1499 > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1501 /name/ { printf("===> Creating %s-", $$2); next } \
1502 /version/ {print $$2; next } ' \
1503 ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
1504 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1505 create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
1506 -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
1507 -r ${KSTAGEDIR}/${DISTDIR} \
1508 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1511 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
1512 .for _kernel in ${BUILDKERNELS:[2..-1]}
1513 .if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
1514 .for flavor in "" -debug
1515 @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
1516 awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
1517 -v kernel=yes -v _kernconf=${_kernel} \
1518 ${KSTAGEDIR}/kernel.${_kernel}.meta ; \
1519 cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
1520 pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
1521 sed -e "s/%VERSION%/${PKG_VERSION}/" \
1522 -e "s/%PKGNAME%/kernel-${_kernel:tl}${flavor}/" \
1523 -e "s/%KERNELDIR%/kernel.${_kernel}/" \
1524 -e "s/%COMMENT%/FreeBSD ${_kernel} kernel ${flavor}/" \
1525 -e "s/%DESC%/FreeBSD ${_kernel} kernel ${flavor}/" \
1526 -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
1527 -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
1528 ${SRCDIR}/release/packages/kernel.ucl \
1529 > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1531 /name/ { printf("===> Creating %s-", $$2); next } \
1532 /version/ {print $$2; next } ' \
1533 ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
1534 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
1535 create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
1536 -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
1537 -r ${KSTAGEDIR}/kernel.${_kernel} \
1538 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
1544 sign-packages: _pkgbootstrap .PHONY
1545 @[ -L "${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest" ] && \
1546 unlink ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/latest ; \
1547 ${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh repo \
1548 -o ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1549 ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} \
1551 cd ${REPODIR}/$$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI); \
1552 ln -s ${PKG_VERSION} latest
1558 # Run test suite on installed world.
1561 @if [ ! -x "${LOCALBASE}/bin/kyua" ]; then \
1562 echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
1565 ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile
1571 # Build the API documentation with doxygen
1574 @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \
1575 echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
1578 ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
1583 # Update the source tree(s), by running svn/svnup to update to the
1587 .if defined(SVN_UPDATE)
1588 @echo "--------------------------------------------------------------"
1589 @echo ">>> Updating ${.CURDIR} using Subversion"
1590 @echo "--------------------------------------------------------------"
1591 @(cd ${.CURDIR}; ${SVN} update ${SVNFLAGS})
1595 # ------------------------------------------------------------------------
1597 # From here onwards are utility targets used by the 'make world' and
1598 # related targets. If your 'world' breaks, you may like to try to fix
1599 # the problem and manually run the following targets to attempt to
1600 # complete the build. Beware, this is *not* guaranteed to work, you
1601 # need to have a pretty good grip on the current state of the system
1602 # to attempt to manually finish it. If in doubt, 'make world' again.
1606 # legacy: Build compatibility shims for the next three targets. This is a
1607 # minimal set of tools and shims necessary to compensate for older systems
1608 # which don't have the APIs required by the targets built in bootstrap-tools,
1609 # build-tools or cross-tools.
1612 # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
1613 # r296685 fix cross-endian objcopy
1614 .if ${BOOTSTRAPPING} < 1100102
1615 _elftoolchain_libs= lib/libelf lib/libdwarf
1619 .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
1620 @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
1623 .for _tool in tools/build ${_elftoolchain_libs} lib/libnv
1624 ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
1625 cd ${.CURDIR}/${_tool}; \
1626 ${MAKE} DIRPRFX=${_tool}/ obj; \
1627 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
1628 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
1629 ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
1630 DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1634 # bootstrap-tools: Build tools needed for compatibility. These are binaries that
1635 # are built to build other binaries in the system. However, the focus of these
1636 # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
1637 # libraries, augmented by -legacy.
1639 _bt= _bootstrap-tools
1641 .if ${MK_GAMES} != "no"
1642 _strfile= usr.bin/fortune/strfile
1645 .if ${MK_GCC} != "no" && ${MK_CXX} != "no"
1646 _gperf= gnu/usr.bin/gperf
1649 .if ${MK_SHAREDOCS} != "no" && ${MK_GROFF} != "no"
1650 _groff= gnu/usr.bin/groff \
1654 .if ${MK_VT} != "no"
1655 _vtfontcvt= usr.bin/vtfontcvt
1658 .if ${BOOTSTRAPPING} < 1000033
1659 _libopenbsd= lib/libopenbsd
1663 ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
1664 ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
1667 # r245440 mtree -N support added
1668 # r313404 requires sha384.h for libnetbsd, added to libmd in r292782
1669 .if ${BOOTSTRAPPING} < 1100093
1670 _nmtree= lib/libmd \
1674 ${_bt}-lib/libnetbsd: ${_bt}-lib/libmd
1675 ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
1678 .if ${BOOTSTRAPPING} < 1000027
1682 # r277259 crunchide: Correct 64-bit section header offset
1683 # r281674 crunchide: always include both 32- and 64-bit ELF support
1684 .if ${BOOTSTRAPPING} < 1100078
1685 _crunchide= usr.sbin/crunch/crunchide
1688 # r285986 crunchen: use STRIPBIN rather than STRIP
1689 # 1100113: Support MK_AUTO_OBJ
1690 # 1100509: META_MODE fixes
1691 .if ${BOOTSTRAPPING} < 1100078 || \
1692 (${MK_AUTO_OBJ} == "yes" && ${BOOTSTRAPPING} < 1100114) || \
1693 (${MK_META_MODE} == "yes" && ${BOOTSTRAPPING} < 1200006)
1694 _crunchgen= usr.sbin/crunch/crunchgen
1697 # r296926 -P keymap search path, MFC to stable/10 in r298297
1698 .if ${BOOTSTRAPPING} < 1003501 || \
1699 (${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
1700 _kbdcontrol= usr.sbin/kbdcontrol
1706 ${_bt}-usr.bin/yacc: ${_bt}-lib/liby
1708 .if ${MK_BSNMP} != "no"
1709 _gensnmptree= usr.sbin/bsnmpd/gensnmptree
1712 # We need to build tblgen when we're building clang or lld, either as
1713 # bootstrap tools, or as the part of the normal build.
1714 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
1715 ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no"
1717 lib/clang/libllvmminimal \
1718 usr.bin/clang/llvm-tblgen \
1719 usr.bin/clang/clang-tblgen
1721 ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal
1722 ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal
1725 # Default to building the GPL DTC, but build the BSDL one if users explicitly
1728 .if ${MK_GPL_DTC} != "no"
1729 _dtc= gnu/usr.bin/dtc
1732 .if ${MK_KERBEROS} != "no"
1733 _kerberos5_bootstrap_tools= \
1734 kerberos5/tools/make-roken \
1735 kerberos5/lib/libroken \
1736 kerberos5/lib/libvers \
1737 kerberos5/tools/asn1_compile \
1738 kerberos5/tools/slc \
1741 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
1744 # r283777 makewhatis(1) replaced with mandoc version which builds a database.
1745 .if ${MK_MANDOCDB} != "no"
1746 _libopenbsd?= lib/libopenbsd
1747 _makewhatis= usr.bin/mandoc
1748 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
1751 bootstrap-tools: .PHONY
1753 # Please document (add comment) why something is in 'bootstrap-tools'.
1754 # Try to bound the building of the bootstrap-tool to just the
1755 # FreeBSD versions that need the tool built at this stage of the build.
1758 ${_kerberos5_bootstrap_tools} \
1780 ${_bt}-${_tool}: .PHONY .MAKE
1781 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1782 cd ${.CURDIR}/${_tool}; \
1783 ${MAKE} DIRPRFX=${_tool}/ obj; \
1784 ${MAKE} DIRPRFX=${_tool}/ all; \
1785 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
1787 bootstrap-tools: ${_bt}-${_tool}
1791 # build-tools: Build special purpose build tools
1793 .if !defined(NO_SHARE)
1794 _share= share/syscons/scrnmaps
1797 .if ${MK_GCC} != "no"
1798 _gcc_tools= gnu/usr.bin/cc/cc_tools
1801 .if ${MK_RESCUE} != "no"
1802 # rescue includes programs that have build-tools targets
1803 _rescue=rescue/rescue
1806 .if ${MK_TCSH} != "no"
1813 ${LOCAL_TOOL_DIRS} \
1814 lib/ncurses/ncurses \
1815 lib/ncurses/ncursesw \
1820 usr.bin/mkesdb_static \
1821 usr.bin/mkcsmapper_static \
1823 build-tools_${_tool}: .PHONY
1824 ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
1825 cd ${.CURDIR}/${_tool}; \
1826 ${MAKE} DIRPRFX=${_tool}/ obj; \
1827 ${MAKE} DIRPRFX=${_tool}/ build-tools
1828 build-tools: build-tools_${_tool}
1832 build-tools_${_tool}: .PHONY
1833 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \
1834 cd ${.CURDIR}/${_tool}; \
1835 ${MAKE} DIRPRFX=${_tool}/ obj; \
1836 ${MAKE} DIRPRFX=${_tool}/ all
1837 build-tools: build-tools_${_tool}
1841 # kernel-tools: Build kernel-building tools
1843 kernel-tools: .PHONY
1844 mkdir -p ${MAKEOBJDIRPREFIX}/usr
1845 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1846 -p ${MAKEOBJDIRPREFIX}/usr >/dev/null
1849 # cross-tools: All the tools needed to build the rest of the system after
1850 # we get done with the earlier stages. It is the last set of tools needed
1851 # to begin building the target binaries.
1853 .if ${TARGET_ARCH} != ${MACHINE_ARCH}
1854 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
1855 _btxld= usr.sbin/btxld
1859 # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
1860 # resulting from missing bug fixes or ELF Toolchain updates.
1861 .if ${MK_CDDL} != "no"
1862 _dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
1863 cddl/usr.bin/ctfmerge
1866 # If we're given an XAS, don't build binutils.
1867 .if ${XAS:M/*} == ""
1868 .if ${MK_BINUTILS_BOOTSTRAP} != "no"
1869 _binutils= gnu/usr.bin/binutils
1871 .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1872 _elftctools= lib/libelftc \
1878 # These are not required by the build, but can be useful for developers who
1879 # cross-build on a FreeBSD 10 host:
1880 _elftctools+= usr.bin/addr2line
1882 .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
1883 # If cross-building with an external binutils we still need to build strip for
1884 # the target (for at least crunchide).
1885 _elftctools= lib/libelftc \
1890 .if ${MK_CLANG_BOOTSTRAP} != "no"
1891 _clang= usr.bin/clang
1893 .if ${MK_LLD_BOOTSTRAP} != "no"
1894 _lld= usr.bin/clang/lld
1896 .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no"
1897 _clang_libs= lib/clang
1899 .if ${MK_GCC_BOOTSTRAP} != "no"
1900 _gcc= gnu/usr.bin/cc
1902 .if ${MK_USB} != "no"
1903 _usb_tools= stand/usb/tools
1906 cross-tools: .MAKE .PHONY
1917 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
1918 cd ${.CURDIR}/${_tool}; \
1919 ${MAKE} DIRPRFX=${_tool}/ obj; \
1920 ${MAKE} DIRPRFX=${_tool}/ all; \
1921 ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
1924 NXBDESTDIR= ${OBJTREE}/nxb-bin
1925 NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
1927 INSTALL="sh ${.CURDIR}/tools/install.sh" \
1928 PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
1929 NXBMAKE= ${NXBENV} ${MAKE} \
1930 LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \
1931 CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \
1932 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \
1933 MK_GDB=no MK_TESTS=no \
1935 MK_HTML=no NO_LINT=yes MK_MAN=no \
1936 -DNO_PIC MK_PROFILE=no -DNO_SHARED \
1937 -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
1938 MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
1939 MK_LLDB=no MK_DEBUG_FILES=no
1941 # native-xtools is the current target for qemu-user cross builds of ports
1942 # via poudriere and the imgact_binmisc kernel module.
1943 # For non-clang enabled targets that are still using the in tree gcc
1944 # we must build a gperf binary for one instance of its Makefiles. On
1945 # clang-enabled systems, the gperf binary is obsolete.
1946 native-xtools: .PHONY
1947 .if ${MK_GCC_BOOTSTRAP} != "no"
1948 mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
1949 ${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \
1950 cd ${.CURDIR}/${_gperf}; \
1951 ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
1952 ${NXBMAKE} DIRPRFX=${_gperf}/ all; \
1953 ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
1955 mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
1956 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
1957 -p ${NXBDESTDIR}/usr >/dev/null
1958 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
1959 -p ${NXBDESTDIR}/usr/include >/dev/null
1960 .if ${MK_DEBUG_FILES} != "no"
1961 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
1962 -p ${NXBDESTDIR}/usr/lib >/dev/null
2024 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2025 cd ${.CURDIR}/${_tool}; \
2026 ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
2027 ${NXBMAKE} DIRPRFX=${_tool}/ all; \
2028 ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
2032 # hierarchy - ensure that all the needed directories are present
2034 hierarchy hier: .MAKE .PHONY
2035 ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
2038 # libraries - build all libraries, and install them under ${DESTDIR}.
2040 # The list of libraries with dependents (${_prebuild_libs}) and their
2041 # interdependencies (__L) are built automatically by the
2042 # ${.CURDIR}/tools/make_libdeps.sh script.
2044 libraries: .MAKE .PHONY
2045 ${_+_}cd ${.CURDIR}; \
2046 ${MAKE} -f Makefile.inc1 _prereq_libs; \
2047 ${MAKE} -f Makefile.inc1 _startup_libs; \
2048 ${MAKE} -f Makefile.inc1 _prebuild_libs; \
2049 ${MAKE} -f Makefile.inc1 _generic_libs
2052 # static libgcc.a prerequisite for shared libc
2054 _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
2056 # These dependencies are not automatically generated:
2058 # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before
2059 # all shared libraries for ELF.
2061 _startup_libs= gnu/lib/csu
2062 _startup_libs+= lib/csu
2063 _startup_libs+= gnu/lib/libgcc
2064 _startup_libs+= lib/libcompiler_rt
2065 _startup_libs+= lib/libc
2066 _startup_libs+= lib/libc_nonshared
2067 .if ${MK_LIBCPLUSPLUS} != "no"
2068 _startup_libs+= lib/libcxxrt
2071 gnu/lib/libgcc__L: lib/libc__L
2072 gnu/lib/libgcc__L: lib/libc_nonshared__L
2073 .if ${MK_LIBCPLUSPLUS} != "no"
2074 lib/libcxxrt__L: gnu/lib/libgcc__L
2077 _prebuild_libs= ${_kerberos5_lib_libasn1} \
2078 ${_kerberos5_lib_libhdb} \
2079 ${_kerberos5_lib_libheimbase} \
2080 ${_kerberos5_lib_libheimntlm} \
2082 ${_kerberos5_lib_libheimipcc} \
2083 ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
2084 ${_kerberos5_lib_libroken} \
2085 ${_kerberos5_lib_libwind} \
2086 lib/libbz2 ${_libcom_err} lib/libcrypt \
2087 lib/libelf lib/libexpat \
2090 lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
2092 lib/ncurses/ncurses lib/ncurses/ncursesw \
2093 lib/libopie lib/libpam/libpam ${_lib_libthr} \
2094 ${_lib_libradius} lib/libsbuf lib/libtacplus \
2096 ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
2097 ${_cddl_lib_libuutil} \
2098 ${_cddl_lib_libavl} \
2099 ${_cddl_lib_libzfs_core} \
2100 ${_cddl_lib_libctf} \
2101 lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
2102 ${_secure_lib_libcrypto} ${_lib_libldns} \
2103 ${_secure_lib_libssh} ${_secure_lib_libssl}
2105 .if ${MK_GNUCXX} != "no"
2106 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
2107 gnu/lib/libstdc++__L: lib/msun__L
2108 gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
2111 .if ${MK_DIALOG} != "no"
2112 _prebuild_libs+= gnu/lib/libdialog
2113 gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
2116 .if ${MK_LIBCPLUSPLUS} != "no"
2117 _prebuild_libs+= lib/libc++
2120 lib/libgeom__L: lib/libexpat__L
2121 lib/libkvm__L: lib/libelf__L
2123 .if ${MK_LIBTHR} != "no"
2124 _lib_libthr= lib/libthr
2127 .if ${MK_RADIUS_SUPPORT} != "no"
2128 _lib_libradius= lib/libradius
2131 .if ${MK_OFED} != "no"
2133 lib/ofed/libibverbs \
2135 lib/ofed/libibumad \
2139 lib/ofed/libibmad__L: lib/ofed/libibumad__L
2140 lib/ofed/complib__L: lib/libthr__L
2141 lib/ofed/libmlx5__L: lib/ofed/libibverbs__L lib/libthr__L
2144 .if ${MK_CASPER} != "no"
2145 _lib_casper= lib/libcasper
2148 lib/libpjdlog__L: lib/libutil__L
2149 lib/libcasper__L: lib/libnv__L
2150 lib/liblzma__L: lib/libthr__L
2152 _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib
2153 .for _DIR in ${LOCAL_LIB_DIRS}
2154 .if ${_DIR} == ".WAIT" || (empty(_generic_libs:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
2155 _generic_libs+= ${_DIR}
2159 lib/libopie__L lib/libtacplus__L: lib/libmd__L
2161 .if ${MK_CDDL} != "no"
2162 _cddl_lib_libumem= cddl/lib/libumem
2163 _cddl_lib_libnvpair= cddl/lib/libnvpair
2164 _cddl_lib_libavl= cddl/lib/libavl
2165 _cddl_lib_libuutil= cddl/lib/libuutil
2166 .if ${MK_ZFS} != "no"
2167 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
2168 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
2170 _cddl_lib_libctf= cddl/lib/libctf
2172 cddl/lib/libctf__L: lib/libz__L
2174 # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
2175 # on select architectures though (see cddl/lib/Makefile)
2176 .if ${MACHINE_CPUARCH} != "sparc64"
2177 _prebuild_libs+= lib/libproc lib/librtld_db
2180 .if ${MK_CRYPT} != "no"
2181 .if ${MK_OPENSSL} != "no"
2182 _secure_lib_libcrypto= secure/lib/libcrypto
2183 _secure_lib_libssl= secure/lib/libssl
2184 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
2185 .if ${MK_LDNS} != "no"
2186 _lib_libldns= lib/libldns
2187 lib/libldns__L: secure/lib/libcrypto__L
2189 .if ${MK_OPENSSH} != "no"
2190 _secure_lib_libssh= secure/lib/libssh
2191 secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
2192 .if ${MK_LDNS} != "no"
2193 secure/lib/libssh__L: lib/libldns__L
2195 .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no"
2196 secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
2197 kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
2198 lib/libmd__L kerberos5/lib/libroken__L
2202 _secure_lib= secure/lib
2205 .if ${MK_KERBEROS} != "no"
2206 kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
2207 kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2208 kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
2209 kerberos5/lib/libwind__L lib/libsqlite3__L
2210 kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
2211 kerberos5/lib/libroken__L lib/libcom_err__L
2212 kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2213 secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
2214 kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
2215 lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
2216 kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
2217 kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
2218 kerberos5/lib/libroken__L: lib/libcrypt__L
2219 kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
2220 kerberos5/lib/libheimbase__L: lib/libthr__L
2221 kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
2224 lib/libsqlite3__L: lib/libthr__L
2226 .if ${MK_GSSAPI} != "no"
2227 _lib_libgssapi= lib/libgssapi
2230 .if ${MK_KERBEROS} != "no"
2231 _kerberos5_lib= kerberos5/lib
2232 _kerberos5_lib_libasn1= kerberos5/lib/libasn1
2233 _kerberos5_lib_libhdb= kerberos5/lib/libhdb
2234 _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
2235 _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
2236 _kerberos5_lib_libhx509= kerberos5/lib/libhx509
2237 _kerberos5_lib_libroken= kerberos5/lib/libroken
2238 _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
2239 _libsqlite3= lib/libsqlite3
2240 _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
2241 _kerberos5_lib_libwind= kerberos5/lib/libwind
2242 _libcom_err= lib/libcom_err
2245 .if ${MK_NIS} != "no"
2246 _lib_libypclnt= lib/libypclnt
2249 .if ${MK_OPENSSL} == "no"
2250 lib/libradius__L: lib/libmd__L
2254 ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
2255 .if ${MK_CXX} != "no"
2256 .if ${MK_LIBCPLUSPLUS} != "no"
2257 lib/libproc__L: lib/libcxxrt__L
2258 .else # This implies MK_GNUCXX != "no"; see lib/libproc
2259 lib/libproc__L: gnu/lib/libsupc++__L
2263 .for _lib in ${_prereq_libs}
2264 ${_lib}__PL: .PHONY .MAKE
2265 .if exists(${.CURDIR}/${_lib})
2266 ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
2267 cd ${.CURDIR}/${_lib}; \
2268 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
2269 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2270 DIRPRFX=${_lib}/ all; \
2271 ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
2272 DIRPRFX=${_lib}/ install
2276 .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
2277 ${_lib}__L: .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 DIRPRFX=${_lib}/ all; \
2283 ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
2287 _prereq_libs: ${_prereq_libs:S/$/__PL/}
2288 _startup_libs: ${_startup_libs:S/$/__L/}
2289 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
2290 _generic_libs: ${_generic_libs:S/$/__L/}
2292 # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
2293 # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
2294 # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
2295 # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
2296 # parallel. This is safe for the world stage of buildworld though since it has
2297 # already built libraries in a proper order and installed includes into
2298 # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
2299 # avoid trashing a system if it crashes mid-install.
2300 .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
2304 .include <bsd.subdir.mk>
2306 .if make(check-old) || make(check-old-dirs) || \
2307 make(check-old-files) || make(check-old-libs) || \
2308 make(delete-old) || make(delete-old-dirs) || \
2309 make(delete-old-files) || make(delete-old-libs)
2312 # check for / delete old files section
2315 .include "ObsoleteFiles.inc"
2317 OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
2318 else you can not start such an application. Consult UPDATING for more \
2319 information regarding how to cope with the removal/revision bump of a \
2322 .if !defined(BATCH_DELETE_OLD_FILES)
2328 delete-old-files: .PHONY
2329 @echo ">>> Removing old files (only deletes safe to delete libs)"
2330 # Ask for every old file if the user really wants to remove it.
2331 # It's annoying, but better safe than sorry.
2332 # NB: We cannot pass the list of OLD_FILES as a parameter because the
2333 # argument list will get too long. Using .for/.endfor make "loops" will make
2334 # the Makefile parser segfault.
2337 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2338 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2339 while read file; do \
2340 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2341 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2342 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2344 for ext in debug symbols; do \
2345 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2346 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2347 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2352 # Remove catpages without corresponding manpages.
2354 find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2355 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2356 while read catpage; do \
2358 if [ ! -e "$${manpage}" ]; then \
2359 rm ${RM_I} $${catpage} <&3; \
2362 @echo ">>> Old files removed"
2364 check-old-files: .PHONY
2365 @echo ">>> Checking for old files"
2367 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2368 -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \
2369 while read file; do \
2370 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2371 echo "${DESTDIR}/$${file}"; \
2373 for ext in debug symbols; do \
2374 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2375 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2379 # Check for catpages without corresponding manpages.
2380 @find ${DESTDIR}/usr/share/man/cat* ! -type d | \
2381 sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
2382 while read catpage; do \
2384 if [ ! -e "$${manpage}" ]; then \
2389 delete-old-libs: .PHONY
2390 @echo ">>> Removing old libraries"
2391 @echo "${OLD_LIBS_MESSAGE}" | fmt
2394 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2395 -V OLD_LIBS | xargs -n1 | \
2396 while read file; do \
2397 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2398 chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
2399 rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
2401 for ext in debug symbols; do \
2402 if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
2403 "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2404 rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
2409 @echo ">>> Old libraries removed"
2411 check-old-libs: .PHONY
2412 @echo ">>> Checking for old libraries"
2414 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2415 -V OLD_LIBS | xargs -n1 | \
2416 while read file; do \
2417 if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
2418 echo "${DESTDIR}/$${file}"; \
2420 for ext in debug symbols; do \
2421 if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
2422 echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
2427 delete-old-dirs: .PHONY
2428 @echo ">>> Removing old directories"
2430 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2431 -V OLD_DIRS | xargs -n1 | sort -r | \
2432 while read dir; do \
2433 if [ -d "${DESTDIR}/$${dir}" ]; then \
2434 rmdir -v "${DESTDIR}/$${dir}" || true; \
2435 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2436 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2438 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2439 rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \
2440 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2441 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2444 @echo ">>> Old directories removed"
2446 check-old-dirs: .PHONY
2447 @echo ">>> Checking for old directories"
2449 ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
2450 -V OLD_DIRS | xargs -n1 | \
2451 while read dir; do \
2452 if [ -d "${DESTDIR}/$${dir}" ]; then \
2453 echo "${DESTDIR}/$${dir}"; \
2454 elif [ -L "${DESTDIR}/$${dir}" ]; then \
2455 echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
2457 if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2458 echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \
2459 elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
2460 echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
2464 delete-old: delete-old-files delete-old-dirs .PHONY
2465 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2467 check-old: check-old-files check-old-libs check-old-dirs .PHONY
2468 @echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
2469 @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
2474 # showconfig - show build configuration.
2477 @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1; \
2478 ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1) 2>&1 | grep ^MK_ | sort -u
2480 .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
2481 DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
2483 .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
2484 .if exists(${KERNCONFDIR}/${KERNCONF})
2485 FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
2486 '${KERNCONFDIR}/${KERNCONF}' ; echo
2492 .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
2493 DTBOUTPUTPATH= ${.CURDIR}
2497 # Build 'standalone' Device Tree Blob
2500 @PATH=${TMPPATH} MACHINE=${TARGET} \
2501 ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
2502 "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
2507 # In the following, the first 'rm' in a series will usually remove all
2508 # files and directories. If it does not, then there are probably some
2509 # files with file flags set, so this unsets them and tries the 'rm' a
2510 # second time. There are situations where this target will be cleaning
2511 # some directories via more than one method, but that duplication is
2512 # needed to correctly handle all the possible situations. Removing all
2513 # files without file flags set in the first 'rm' instance saves time,
2514 # because 'chflags' will need to operate on fewer files afterwards.
2516 # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
2517 # created by bsd.obj.mk, except that we don't want to .include that file
2520 BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR}
2522 .if exists(${BW_CANONICALOBJDIR}/)
2523 -rm -rf ${BW_CANONICALOBJDIR}/*
2524 -chflags -R 0 ${BW_CANONICALOBJDIR}
2525 rm -rf ${BW_CANONICALOBJDIR}/*
2527 .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2528 # To be safe in this case, fall back to a 'make cleandir'
2529 ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
2532 .if defined(TARGET) && defined(TARGET_ARCH)
2534 .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
2535 XDEV_CPUTYPE?=${CPUTYPE}
2537 XDEV_CPUTYPE?=${TARGET_CPUTYPE}
2540 NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
2541 MK_MAN=no MK_NLS=no MK_PROFILE=no \
2542 MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WARNS=no \
2543 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
2544 CPUTYPE=${XDEV_CPUTYPE}
2546 XDDIR=${TARGET_ARCH}-freebsd
2549 .error XDTP variable should be an absolute path
2552 CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \
2553 INSTALL="sh ${.CURDIR}/tools/install.sh"
2555 TOOLS_PREFIX=${XDTP}
2557 .if ${WANT_COMPILER_TYPE} == gcc || \
2558 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
2559 # GCC requires -isystem and -L when using a cross-compiler. --sysroot
2560 # won't set header path and -L is used to ensure the base library path
2561 # is added before the port PREFIX library path.
2562 CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib
2563 # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
2564 # combined with --sysroot.
2565 CD2CFLAGS+= -B${XDDESTDIR}/usr/lib
2566 # Force using libc++ for external GCC.
2567 .if ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
2568 CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \
2572 CD2CFLAGS+= --sysroot=${XDDESTDIR}/
2573 CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \
2574 CPP="${CPP} ${CD2CFLAGS}" \
2575 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
2577 CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp
2578 CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2579 CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN}
2580 .if ${MK_META_MODE} != "no"
2581 # Don't rebuild build-tools targets during normal build.
2582 CD2MAKE+= BUILD_TOOLS_META=.NOMETA
2584 XDDESTDIR=${DESTDIR}/${XDTP}
2586 .ORDER: xdev-build xdev-install xdev-links
2587 xdev: xdev-build xdev-install .PHONY
2589 .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
2590 xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
2592 _xb-worldtmp: .PHONY
2593 mkdir -p ${CDTMP}/usr
2594 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2595 -p ${CDTMP}/usr >/dev/null
2597 _xb-bootstrap-tools: .PHONY
2602 ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
2603 cd ${.CURDIR}/${_tool}; \
2604 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2605 ${CDMAKE} DIRPRFX=${_tool}/ all; \
2606 ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
2609 _xb-build-tools: .PHONY
2610 ${_+_}@cd ${.CURDIR}; \
2611 ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools
2613 _xb-cross-tools: .PHONY
2621 ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
2622 cd ${.CURDIR}/${_tool}; \
2623 ${CDMAKE} DIRPRFX=${_tool}/ obj; \
2624 ${CDMAKE} DIRPRFX=${_tool}/ all
2628 ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
2629 mkdir -p ${XDDESTDIR}
2630 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \
2631 -p ${XDDESTDIR} >/dev/null
2632 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
2633 -p ${XDDESTDIR}/usr >/dev/null
2634 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
2635 -p ${XDDESTDIR}/usr/include >/dev/null
2636 .if defined(LIBCOMPAT)
2637 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
2638 -p ${XDDESTDIR}/usr >/dev/null
2640 .if ${MK_TESTS} != "no"
2641 mkdir -p ${XDDESTDIR}${TESTSBASE}
2642 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
2643 -p ${XDDESTDIR}${TESTSBASE} >/dev/null
2646 .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
2647 xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
2649 _xi-cross-tools: .PHONY
2650 @echo "_xi-cross-tools"
2658 ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
2659 cd ${.CURDIR}/${_tool}; \
2660 ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
2663 _xi-includes: .PHONY
2664 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
2665 DESTDIR=${XDDESTDIR}
2667 _xi-libraries: .PHONY
2668 ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
2669 DESTDIR=${XDDESTDIR}
2672 ${_+_}cd ${XDDESTDIR}/usr/bin; \
2673 mkdir -p ../../../../usr/bin; \
2675 ln -sf ../../${XDTP}/usr/bin/$$i \
2676 ../../../../usr/bin/${XDDIR}-$$i; \
2677 ln -sf ../../${XDTP}/usr/bin/$$i \
2678 ../../../../usr/bin/${XDDIR}${_REVISION}-$$i; \
2681 xdev xdev-build xdev-install xdev-links: .PHONY
2682 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target"