4 # The user-driven targets are:
6 # universe - *Really* build *everything* (buildworld and
7 # all kernels on all architectures). Define
8 # MAKE_JUST_KERNELS or WITHOUT_WORLDS to only build kernels,
9 # MAKE_JUST_WORLDS or WITHOUT_KERNELS to only build userland.
10 # tinderbox - Same as universe, but presents a list of failed build
11 # targets and exits with an error if there were any.
12 # worlds - Same as universe, except just makes the worlds.
13 # kernels - Same as universe, except just makes the kernels.
14 # buildworld - Rebuild *everything*, including glue to help do
16 # installworld - Install everything built by "buildworld".
17 # world - buildworld + installworld, no kernel.
18 # buildkernel - Rebuild the kernel and the kernel-modules.
19 # installkernel - Install the kernel and the kernel-modules.
21 # reinstallkernel - Reinstall the kernel and the kernel-modules.
22 # reinstallkernel.debug
23 # kernel - buildkernel + installkernel.
24 # kernel-toolchain - Builds the subset of world necessary to build a kernel
25 # kernel-toolchains - Build kernel-toolchain for all universe targets.
26 # doxygen - Build API documentation of the kernel, needs doxygen.
27 # checkworld - Run test suite on installed world.
28 # check-old - List obsolete directories/files/libraries.
29 # check-old-dirs - List obsolete directories.
30 # check-old-files - List obsolete files.
31 # check-old-libs - List obsolete libraries.
32 # delete-old - Delete obsolete directories/files.
33 # delete-old-dirs - Delete obsolete directories.
34 # delete-old-files - Delete obsolete files.
35 # delete-old-libs - Delete obsolete libraries.
36 # targets - Print a list of supported TARGET/TARGET_ARCH pairs
37 # for world and kernel targets.
38 # toolchains - Build a toolchain for all world and kernel targets.
39 # makeman - Regenerate src.conf(5)
40 # sysent - (Re)build syscall entries from syscalls.master.
41 # xdev - xdev-build + xdev-install for the architecture
42 # specified with TARGET and TARGET_ARCH.
43 # xdev-build - Build cross-development tools.
44 # xdev-install - Install cross-development tools.
45 # xdev-links - Create traditional links in /usr/bin for cc, etc
46 # native-xtools - Create host binaries that produce target objects
47 # for use in qemu user-mode jails. TARGET and
48 # TARGET_ARCH should be defined.
49 # native-xtools-install
50 # - Install the files to the given DESTDIR/NXTP where
51 # NXTP defaults to /nxb-bin.
53 # This makefile is simple by design. The FreeBSD make automatically reads
54 # the /usr/share/mk/sys.mk unless the -m argument is specified on the
55 # command line. By keeping this makefile simple, it doesn't matter too
56 # much how different the installed mk files are from those in the source
57 # tree. This makefile executes a child make process, forcing it to use
58 # the mk files from the source tree which are supposed to DTRT.
60 # Most of the user-driven targets (as listed above) are implemented in
61 # Makefile.inc1. The exceptions are universe, tinderbox and targets.
63 # If you want to build your system from source, be sure that /usr/obj has
64 # at least 6 GB of disk space available. A complete 'universe' build of
65 # r340283 (2018-11) required 167 GB of space. ZFS lz4 compression
66 # achieved a 2.18x ratio, reducing actual space to 81 GB.
68 # For individuals wanting to build from the sources currently on their
69 # system, the simple instructions are:
71 # 1. `cd /usr/src' (or to the directory containing your source tree).
72 # 2. Define `HISTORICAL_MAKE_WORLD' variable (see README).
75 # For individuals wanting to upgrade their sources (even if only a
76 # delta of a few days):
78 # 1. `cd /usr/src' (or to the directory containing your source tree).
79 # 2. `make buildworld'
80 # 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
81 # 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
82 # [steps 3. & 4. can be combined by using the "kernel" target]
83 # 5. `reboot' (in single user mode: boot -s from the loader prompt).
85 # 7. `make installworld'
86 # 8. `mergemaster' (you may wish to use -i, along with -U or -F).
87 # 9. `make delete-old'
89 # 11. `make delete-old-libs' (in case no 3rd party program uses them anymore)
91 # For individuals wanting to build from source with GCC from ports, first
92 # install the appropriate GCC cross toolchain package:
93 # `pkg install ${TARGET_ARCH}-gccN`
95 # Once you have installed the necessary cross toolchain, simply pass
96 # CROSS_TOOLCHAIN=${TARGET_ARCH}-gccN while building with the above steps,
97 # e.g., `make buildworld CROSS_TOOLCHAIN=amd64-gcc6`.
99 # The ${TARGET_ARCH}-gccN packages are provided as flavors of the
100 # devel/freebsd-gccN ports.
102 # See src/UPDATING `COMMON ITEMS' for more complete information.
104 # If TARGET=machine (e.g. powerpc, arm64, ...) is specified you can
105 # cross build world for other machine types using the buildworld target,
106 # and once the world is built you can cross build a kernel using the
107 # buildkernel target.
109 # Define the user-driven targets. These are listed here in alphabetical
110 # order, but that's not important.
112 # Targets that begin with underscore are internal targets intended for
113 # developer convenience only. They are intentionally not documented and
114 # completely subject to change without notice.
116 # For more information, see the build(7) manual page.
119 .if defined(UNIVERSE_TARGET) || defined(MAKE_JUST_WORLDS) || defined(WITHOUT_KERNELS)
122 .if defined(MAKE_JUST_KERNELS) || defined(WITHOUT_WORLDS)
128 # This is included so CC is set to ccache for -V, and COMPILER_TYPE/VERSION
129 # can be cached for sub-makes. We can't do this while still running on the
130 # old fmake from FreeBSD 9.x or older, so avoid including it then to avoid
131 # heartburn upgrading from older systems. The need for CC is done with new
132 # make later in the build, and caching COMPILER_TYPE/VERSION is only an
133 # optimization. Also sinclude it to be friendlier to foreign OS hosted builds.
134 .if ${MAKE_VERSION} >= 20140620 && defined(.PARSEDIR)
135 .sinclude <bsd.compiler.mk>
138 # Note: we use this awkward construct to be compatible with FreeBSD's
139 # old make used in 10.0 and 9.2 and earlier.
140 .if defined(MK_DIRDEPS_BUILD) && ${MK_DIRDEPS_BUILD} == "yes" && \
141 !make(showconfig) && !make(print-dir)
142 # targets/Makefile plays the role of top-level
143 .include "targets/Makefile"
146 TGTS= all all-man buildenv buildenvvars buildkernel buildworld \
147 check check-old check-old-dirs check-old-files check-old-libs \
148 checkdpadd checkworld clean cleandepend cleandir cleanworld \
150 delete-old delete-old-dirs delete-old-files delete-old-libs \
151 depend distribute distributekernel distributekernel.debug \
152 distributeworld distrib-dirs distribution doxygen \
153 everything hier hierarchy install installcheck installkernel \
154 installkernel.debug packagekernel packageworld \
155 reinstallkernel reinstallkernel.debug \
156 installworld kernel-toolchain libraries maninstall \
157 obj objlink showconfig tags toolchain \
159 _worldtmp _legacy _bootstrap-tools _cleanobj _obj \
160 _build-tools _build-metadata _cross-tools _includes _libraries \
161 build32 distribute32 install32 buildsoft distributesoft installsoft \
162 builddtb xdev xdev-build xdev-install \
163 xdev-links native-xtools native-xtools-install stageworld stagekernel \
164 stage-packages stage-packages-kernel stage-packages-world \
165 create-packages-world create-packages-kernel create-packages \
166 update-packages packages installconfig real-packages real-update-packages \
167 sign-packages package-pkg print-dir test-system-compiler test-system-linker
169 # These targets require a TARGET and TARGET_ARCH be defined.
170 XTGTS= native-xtools native-xtools-install xdev xdev-build xdev-install \
173 # XXX: r156740: This can't work since bsd.subdir.mk is not included ever.
174 # It will only work for SUBDIR_TARGETS in make.conf.
175 TGTS+= ${SUBDIR_TARGETS}
177 BITGTS= files includes
178 BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
181 # Only some targets are allowed to use meta mode. Others get it
182 # disabled. In some cases, such as 'install', meta mode can be dangerous
183 # as a cookie may be used to prevent redundant installations (such as
184 # for WORLDTMP staging). For DESTDIR=/ we always want to install though.
185 # For other cases, such as delete-old-libs, meta mode may break
186 # the interactive tty prompt. The safest route is to just whitelist
187 # the ones that benefit from it.
188 META_TGT_WHITELIST+= \
189 _* build32 buildfiles buildincludes buildkernel buildsoft \
190 buildworld everything kernel-toolchain kernel-toolchains kernel \
191 kernels libraries native-xtools showconfig test-system-compiler \
192 test-system-linker tinderbox toolchain \
193 toolchains universe universe-toolchain world worlds xdev xdev-build
195 .ORDER: buildworld installworld
196 .ORDER: buildworld distrib-dirs
197 .ORDER: buildworld distribution
198 .ORDER: buildworld distribute
199 .ORDER: buildworld distributeworld
200 .ORDER: buildworld buildkernel
201 .ORDER: distrib-dirs distribute
202 .ORDER: distrib-dirs distributeworld
203 .ORDER: distrib-dirs installworld
204 .ORDER: distribution distribute
205 .ORDER: distributeworld distribute
206 .ORDER: distributeworld distribution
207 .ORDER: installworld distribute
208 .ORDER: installworld distribution
209 .ORDER: installworld installkernel
210 .ORDER: buildkernel installkernel
211 .ORDER: buildkernel installkernel.debug
212 .ORDER: buildkernel reinstallkernel
213 .ORDER: buildkernel reinstallkernel.debug
215 PATH= /sbin:/bin:/usr/sbin:/usr/bin
216 MAKEOBJDIRPREFIX?= /usr/obj
217 _MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} MK_AUTO_OBJ=no \
218 ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
219 SRCCONF=${SRCCONF} SRC_ENV_CONF= \
220 -f /dev/null -V MAKEOBJDIRPREFIX dummy
221 .if !empty(_MAKEOBJDIRPREFIX)
222 .error MAKEOBJDIRPREFIX can only be set in environment or src-env.conf(5),\
223 not as a global (in make.conf(5) or src.conf(5)) or command-line variable.
226 # We often need to use the tree's version of make to build it.
227 # Choices add to complexity though.
228 # We cannot blindly use a make which may not be the one we want
229 # so be explicit - until all choice is removed.
231 .if !empty(.MAKE.MODE:Mmeta)
232 # 20160604 - support missing-meta,missing-filemon and performance improvements
233 WANT_MAKE_VERSION= 20160604
235 # 20160220 - support .dinclude for FAST_DEPEND.
236 WANT_MAKE_VERSION= 20160220
238 MYMAKE= ${OBJROOT}make.${MACHINE}/${WANT_MAKE}
239 .if defined(.PARSEDIR)
244 .if defined(ALWAYS_BOOTSTRAP_MAKE) || \
245 ${HAVE_MAKE} != ${WANT_MAKE} || \
246 (defined(WANT_MAKE_VERSION) && ${MAKE_VERSION} < ${WANT_MAKE_VERSION})
249 .if exists(${MYMAKE})
250 SUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
251 .elif defined(NEED_MAKE_UPGRADE)
252 # It may not exist yet but we may cause it to.
253 # In the case of fmake, upgrade_checks may cause a newer version to be built.
254 SUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
255 -m ${.CURDIR}/share/mk
257 SUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
260 _MAKE= PATH=${PATH} MAKE_CMD="${MAKE}" ${SUB_MAKE} -f Makefile.inc1 \
261 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH} ${_MAKEARGS}
263 .if defined(MK_META_MODE) && ${MK_META_MODE} == "yes"
264 # Only allow meta mode for the whitelisted targets. See META_TGT_WHITELIST
265 # above. If overridden as a make argument then don't bother trying to
267 .if empty(.MAKEOVERRIDES:MMK_META_MODE)
268 .for _tgt in ${META_TGT_WHITELIST}
270 _CAN_USE_META_MODE?= yes
273 .if !defined(_CAN_USE_META_MODE)
274 _MAKE+= MK_META_MODE=no
276 .if defined(.PARSEDIR)
279 .endif # !defined(_CAN_USE_META_MODE)
280 .endif # empty(.MAKEOVERRIDES:MMK_META_MODE)
282 .if ${MK_META_MODE} == "yes"
283 .if !exists(/dev/filemon) && !defined(NO_FILEMON) && !make(showconfig)
284 # Require filemon be loaded to provide a working incremental build
285 .error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded. \
286 ${.newline}ERROR: WITH_META_MODE is enabled but requires filemon for an incremental build. \
287 ${.newline}ERROR: 'kldload filemon' or pass -DNO_FILEMON to suppress this error.
288 .endif # !exists(/dev/filemon) && !defined(NO_FILEMON)
289 .endif # ${MK_META_MODE} == yes
290 .endif # defined(MK_META_MODE) && ${MK_META_MODE} == yes
292 # Guess target architecture from target type, and vice versa, based on
293 # historic FreeBSD practice of tending to have TARGET == TARGET_ARCH
294 # expanding to TARGET == TARGET_CPUARCH in recent times, with known
296 .if !defined(TARGET_ARCH) && defined(TARGET)
297 # T->TA mapping is usually TARGET with arm64 the odd man out
298 _TARGET_ARCH= ${TARGET:S/arm64/aarch64/:S/riscv/riscv64/:S/arm/armv7/}
299 .elif !defined(TARGET) && defined(TARGET_ARCH) && \
300 ${TARGET_ARCH} != ${MACHINE_ARCH}
301 # TA->T mapping is accidentally CPUARCH with aarch64 the odd man out
302 _TARGET= ${TARGET_ARCH:${__TO_CPUARCH}:C/aarch64/arm64/}
304 .if defined(TARGET) && !defined(_TARGET)
307 .if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
308 _TARGET_ARCH=${TARGET_ARCH}
310 # for historical compatibility for xdev targets
314 .if defined(XDEV_ARCH)
315 _TARGET_ARCH= ${XDEV_ARCH}
317 # Some targets require a set TARGET/TARGET_ARCH, check before the default
318 # MACHINE and after the compatibility handling.
319 .if !defined(_TARGET) || !defined(_TARGET_ARCH)
320 ${XTGTS}: _assert_target
322 # Otherwise, default to current machine type and architecture.
324 _TARGET_ARCH?= ${MACHINE_ARCH}
326 .if make(native-xtools*)
327 NXB_TARGET:= ${_TARGET}
328 NXB_TARGET_ARCH:= ${_TARGET_ARCH}
330 _TARGET_ARCH= ${MACHINE_ARCH}
331 _MAKE+= NXB_TARGET=${NXB_TARGET} \
332 NXB_TARGET_ARCH=${NXB_TARGET_ARCH}
339 _assert_target: .PHONY .MAKE
340 .for _tgt in ${XTGTS}
342 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${_tgt}\" target"
348 # Make sure we have an up-to-date make(1). Only world and buildworld
349 # should do this as those are the initial targets used for upgrades.
350 # The user can define ALWAYS_CHECK_MAKE to have this check performed
353 .if defined(ALWAYS_CHECK_MAKE) || !defined(.PARSEDIR)
354 ${TGTS}: upgrade_checks
356 buildworld: upgrade_checks
360 # Handle the user-driven targets, using the source relative mk files.
363 tinderbox toolchains kernel-toolchains: .MAKE
364 ${TGTS}: .PHONY .MAKE
365 ${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
367 # The historic default "all" target creates files which may cause stale
368 # or (in the cross build case) unlinkable results. Fail with an error
369 # when no target is given. The users can explicitly specify "all"
370 # if they want the historic behavior.
375 @echo "Explicit target required. Likely \"${SUBDIR_OVERRIDE:Dall:Ubuildworld}\" is wanted. See build(7)."
379 STARTTIME!= LC_ALL=C date
380 CHECK_TIME!= cmp=`mktemp`; find ${.CURDIR}/sys/sys/param.h -newer "$$cmp" && rm "$$cmp"; echo
381 .if !empty(CHECK_TIME)
382 .error check your date/time: ${STARTTIME}
385 .if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
389 # Attempt to rebuild and reinstall everything. This target is not to be
390 # used for upgrading an existing FreeBSD system, because the kernel is
391 # not included. One can argue that this target doesn't build everything
394 world: upgrade_checks .PHONY
395 @echo "--------------------------------------------------------------"
396 @echo ">>> make world started on ${STARTTIME}"
397 @echo "--------------------------------------------------------------"
398 .if target(pre-world)
400 @echo "--------------------------------------------------------------"
401 @echo ">>> Making 'pre-world' target"
402 @echo "--------------------------------------------------------------"
403 ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
405 ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
406 ${_+_}@cd ${.CURDIR}; ${_MAKE} installworld MK_META_MODE=no
407 .if target(post-world)
409 @echo "--------------------------------------------------------------"
410 @echo ">>> Making 'post-world' target"
411 @echo "--------------------------------------------------------------"
412 ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
415 @echo "--------------------------------------------------------------"
416 @echo ">>> make world completed on `LC_ALL=C date`"
417 @echo " (started ${STARTTIME})"
418 @echo "--------------------------------------------------------------"
421 @echo "WARNING: make world will overwrite your existing FreeBSD"
422 @echo "installation without also building and installing a new"
423 @echo "kernel. This can be dangerous. Please read the handbook,"
424 @echo "'Rebuilding world', for how to upgrade your system."
425 @echo "Define DESTDIR to where you want to install FreeBSD,"
426 @echo "including /, to override this warning and proceed as usual."
428 @echo "Bailing out now..."
435 # Short hand for `make buildkernel installkernel'
437 kernel: buildkernel installkernel .PHONY
440 # Perform a few tests to determine if the installed tools are adequate
441 # for building the world.
443 upgrade_checks: .PHONY
444 .if defined(NEED_MAKE_UPGRADE)
445 @${_+_}(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
449 # Upgrade make(1) to the current version using the installed
450 # headers, libraries and tools. Also, allow the location of
451 # the system bsdmake-like utility to be overridden.
455 INSTALL="sh ${.CURDIR}/tools/install.sh"
456 MMAKE= ${MMAKEENV} ${MAKE} \
457 OBJTOP=${MYMAKE:H}/obj \
458 OBJROOT='$${OBJTOP}/' \
460 MK_MAN=no -DNO_SHARED \
461 -DNO_CPU_CFLAGS MK_WERROR=no \
463 DESTDIR= PROGNAME=${MYMAKE:T}
467 @echo "--------------------------------------------------------------"
468 @echo ">>> Building an up-to-date ${.TARGET}(1)"
469 @echo "--------------------------------------------------------------"
470 ${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
474 ${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR=
477 @echo "'make regress' has been renamed 'make check'" | /usr/bin/fmt
480 tinderbox toolchains kernel-toolchains kernels worlds: upgrade_checks
483 @cd ${.CURDIR}; ${SUB_MAKE} DOING_TINDERBOX=YES universe
486 @cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
488 kernel-toolchains: .PHONY
489 @cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
492 @cd ${.CURDIR}; ${SUB_MAKE} universe -DWITHOUT_WORLDS
495 @cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=buildworld universe
500 # Attempt to rebuild *everything* for all supported architectures,
501 # with a reasonable chance of success, regardless of how old your
502 # existing system is.
504 .if make(universe) || make(universe_kernels) || make(tinderbox) || \
505 make(targets) || make(universe-toolchain)
507 # Don't build rarely used, semi-supported architectures unless requested.
509 .if defined(EXTRA_TARGETS)
510 EXTRA_ARCHES_mips= mipsel mipshf mipselhf mips64el mips64hf mips64elhf
511 EXTRA_ARCHES_mips+= mipsn32
512 # powerpcspe excluded from main list until clang fixed
513 EXTRA_ARCHES_powerpc= powerpcspe powerpc64le
515 TARGETS?=amd64 arm arm64 i386 mips powerpc riscv
516 _UNIVERSE_TARGETS= ${TARGETS}
517 TARGET_ARCHES_arm?= armv6 armv7
518 TARGET_ARCHES_arm64?= aarch64
519 TARGET_ARCHES_mips?= mips mips64 ${EXTRA_ARCHES_mips}
520 TARGET_ARCHES_powerpc?= powerpc powerpc64 ${EXTRA_ARCHES_powerpc}
521 TARGET_ARCHES_riscv?= riscv64 riscv64sf
522 .for target in ${TARGETS}
523 TARGET_ARCHES_${target}?= ${target}
526 .if defined(USE_GCC_TOOLCHAINS)
527 TOOLCHAINS_amd64= amd64-gcc6
528 TOOLCHAINS_arm64= aarch64-gcc6
529 TOOLCHAINS_i386= i386-gcc6
530 TOOLCHAINS_mips= mips-gcc6
531 TOOLCHAINS_powerpc= powerpc-gcc6 powerpc64-gcc6
532 TOOLCHAIN_powerpc64= powerpc64-gcc6
535 # If a target is using an external toolchain, set MAKE_PARAMS to enable use
536 # of the toolchain. If the external toolchain is missing, exclude the target
538 .for target in ${_UNIVERSE_TARGETS}
539 .if !empty(TOOLCHAINS_${target})
540 .for toolchain in ${TOOLCHAINS_${target}}
541 .if !exists(/usr/local/share/toolchains/${toolchain}.mk)
542 _UNIVERSE_TARGETS:= ${_UNIVERSE_TARGETS:N${target}}
543 universe: universe_${toolchain}_skip .PHONY
544 universe_epilogue: universe_${toolchain}_skip .PHONY
545 universe_${toolchain}_skip: universe_prologue .PHONY
546 @echo ">> ${target} skipped - install ${toolchain} port or package to build"
549 .for arch in ${TARGET_ARCHES_${target}}
550 TOOLCHAIN_${arch}?= ${TOOLCHAINS_${target}:[1]}
551 MAKE_PARAMS_${arch}?= CROSS_TOOLCHAIN=${TOOLCHAIN_${arch}}
556 UNIVERSE_TARGET?= buildworld
557 KERNSRCDIR?= ${.CURDIR}/sys
560 @echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
561 .for target in ${TARGETS}
562 .for target_arch in ${TARGET_ARCHES_${target}}
563 @echo " ${target}/${target_arch}"
567 .if defined(DOING_TINDERBOX)
568 FAILFILE=${.CURDIR}/_.tinderbox.failed
569 MAKEFAIL=tee -a ${FAILFILE}
574 universe_prologue: upgrade_checks
575 universe: universe_prologue
576 universe_prologue: .PHONY
577 @echo "--------------------------------------------------------------"
578 @echo ">>> make universe started on ${STARTTIME}"
579 @echo "--------------------------------------------------------------"
580 .if defined(DOING_TINDERBOX)
584 universe-toolchain: .PHONY universe_prologue
585 @echo "--------------------------------------------------------------"
586 @echo "> Toolchain bootstrap started on `LC_ALL=C date`"
587 @echo "--------------------------------------------------------------"
588 ${_+_}@cd ${.CURDIR}; \
589 env PATH=${PATH} ${SUB_MAKE} ${JFLAG} kernel-toolchain \
590 TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH} \
591 OBJTOP="${HOST_OBJTOP}" \
592 WITHOUT_SYSTEM_COMPILER=yes \
593 WITHOUT_SYSTEM_LINKER=yes \
594 TOOLS_PREFIX_UNDEF= \
596 MK_LLVM_TARGET_ALL=yes \
597 > _.${.TARGET} 2>&1 || \
598 (echo "${.TARGET} failed," \
599 "check _.${.TARGET} for details" | \
601 @if [ ! -e "${HOST_OBJTOP}/tmp/usr/bin/cc" ]; then \
602 echo "Missing host compiler at ${HOST_OBJTOP}/tmp/usr/bin/cc?" >&2; \
605 @if [ ! -e "${HOST_OBJTOP}/tmp/usr/bin/ld" ]; then \
606 echo "Missing host linker at ${HOST_OBJTOP}/tmp/usr/bin/ld?" >&2; \
609 @echo "--------------------------------------------------------------"
610 @echo "> Toolchain bootstrap completed on `LC_ALL=C date`"
611 @echo "--------------------------------------------------------------"
613 .for target in ${_UNIVERSE_TARGETS}
614 universe: universe_${target}
615 universe_epilogue: universe_${target}
616 universe_${target}: universe_${target}_prologue .PHONY
617 universe_${target}_prologue: universe_prologue .PHONY
618 @echo ">> ${target} started on `LC_ALL=C date`"
619 universe_${target}_worlds: .PHONY
621 .if !make(targets) && !make(universe-toolchain)
622 .for target_arch in ${TARGET_ARCHES_${target}}
623 .if !defined(_need_clang_${target}_${target_arch})
624 _need_clang_${target}_${target_arch} != \
625 env TARGET=${target} TARGET_ARCH=${target_arch} \
626 ${SUB_MAKE} -C ${.CURDIR} -f Makefile.inc1 test-system-compiler \
627 ${MAKE_PARAMS_${target_arch}} -V MK_CLANG_BOOTSTRAP 2>/dev/null || \
629 .export _need_clang_${target}_${target_arch}
631 .if !defined(_need_lld_${target}_${target_arch})
632 _need_lld_${target}_${target_arch} != \
633 env TARGET=${target} TARGET_ARCH=${target_arch} \
634 ${SUB_MAKE} -C ${.CURDIR} -f Makefile.inc1 test-system-linker \
635 ${MAKE_PARAMS_${target_arch}} -V MK_LLD_BOOTSTRAP 2>/dev/null || \
637 .export _need_lld_${target}_${target_arch}
639 # Setup env for each arch to use the one clang.
640 .if defined(_need_clang_${target}_${target_arch}) && \
641 ${_need_clang_${target}_${target_arch}} == "yes"
642 # No check on existing XCC or CROSS_BINUTILS_PREFIX, etc, is needed since
643 # we use the test-system-compiler logic to determine if clang needs to be
644 # built. It will be no from that logic if already using an external
645 # toolchain or /usr/bin/cc.
646 # XXX: Passing HOST_OBJTOP into the PATH would allow skipping legacy,
647 # bootstrap-tools, and cross-tools. Need to ensure each tool actually
648 # supports all TARGETS though.
649 # For now we only pass UNIVERSE_TOOLCHAIN_PATH which will be added at the end
650 # of STRICTTMPPATH to ensure that the target-specific binaries come first.
651 MAKE_PARAMS_${target_arch}+= \
652 XCC="${HOST_OBJTOP}/tmp/usr/bin/cc" \
653 XCXX="${HOST_OBJTOP}/tmp/usr/bin/c++" \
654 XCPP="${HOST_OBJTOP}/tmp/usr/bin/cpp" \
655 UNIVERSE_TOOLCHAIN_PATH=${HOST_OBJTOP}/tmp/usr/bin
657 .if defined(_need_lld_${target}_${target_arch}) && \
658 ${_need_lld_${target}_${target_arch}} == "yes"
659 MAKE_PARAMS_${target_arch}+= \
660 XLD="${HOST_OBJTOP}/tmp/usr/bin/ld"
663 .endif # !make(targets)
665 .if ${__DO_WORLDS} == "yes"
666 universe_${target}_done: universe_${target}_worlds .PHONY
667 .for target_arch in ${TARGET_ARCHES_${target}}
668 universe_${target}_worlds: universe_${target}_${target_arch} .PHONY
669 .if (defined(_need_clang_${target}_${target_arch}) && \
670 ${_need_clang_${target}_${target_arch}} == "yes") || \
671 (defined(_need_lld_${target}_${target_arch}) && \
672 ${_need_lld_${target}_${target_arch}} == "yes")
673 universe_${target}_${target_arch}: universe-toolchain
674 universe_${target}_prologue: universe-toolchain
676 universe_${target}_${target_arch}: universe_${target}_prologue .MAKE .PHONY
677 @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
678 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
679 ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
681 TARGET_ARCH=${target_arch} \
682 ${MAKE_PARAMS_${target_arch}} \
683 > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
684 (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
685 "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
687 @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
689 .endif # ${__DO_WORLDS} == "yes"
691 .if ${__DO_KERNELS} == "yes"
692 universe_${target}_done: universe_${target}_kernels .PHONY
693 universe_${target}_kernels: universe_${target}_worlds .PHONY
694 universe_${target}_kernels: universe_${target}_prologue .MAKE .PHONY
695 @cd ${.CURDIR}; ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
697 .endif # ${__DO_KERNELS} == "yes"
699 # Tell the user the worlds and kernels have completed
700 universe_${target}: universe_${target}_done
701 universe_${target}_done:
702 @echo ">> ${target} completed on `LC_ALL=C date`"
704 .if make(universe_kernconfs) || make(universe_kernels)
708 universe_kernels_prologue: .PHONY
709 @echo ">> ${TARGET} kernels started on `LC_ALL=C date`"
710 universe_kernels: universe_kernconfs .PHONY
711 @echo ">> ${TARGET} kernels completed on `LC_ALL=C date`"
712 .if defined(MAKE_ALL_KERNELS)
714 .elif defined(MAKE_LINT_KERNELS)
715 _THINNER=grep 'LINT' || true
717 _THINNER=xargs grep -L "^.NO_UNIVERSE" || true
719 KERNCONFS!= cd ${KERNSRCDIR}/${TARGET}/conf && \
720 find [[:upper:][:digit:]]*[[:upper:][:digit:]] \
721 -type f -maxdepth 0 \
722 ! -name DEFAULTS ! -name NOTES | \
724 universe_kernconfs: universe_kernels_prologue .PHONY
725 .for kernel in ${KERNCONFS}
726 TARGET_ARCH_${kernel}!= cd ${KERNSRCDIR}/${TARGET}/conf && \
727 env PATH=${HOST_OBJTOP}/tmp/legacy/bin:${PATH:Q} \
728 config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
729 grep -v WARNING: | cut -f 2
730 .if empty(TARGET_ARCH_${kernel})
731 .error "Target architecture for ${TARGET}/conf/${kernel} unknown. config(8) likely too old."
733 universe_kernconfs_${TARGET_ARCH_${kernel}}: universe_kernconf_${TARGET}_${kernel}
734 universe_kernconf_${TARGET}_${kernel}: .MAKE
735 @echo ">> ${TARGET}.${TARGET_ARCH_${kernel}} ${kernel} kernel started on `LC_ALL=C date`"
736 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
737 ${SUB_MAKE} ${JFLAG} buildkernel \
739 TARGET_ARCH=${TARGET_ARCH_${kernel}} \
740 ${MAKE_PARAMS_${TARGET_ARCH_${kernel}}} \
742 > _.${TARGET}.${kernel} 2>&1 || \
743 (echo "${TARGET} ${kernel} kernel failed," \
744 "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
745 @echo ">> ${TARGET}.${TARGET_ARCH_${kernel}} ${kernel} kernel completed on `LC_ALL=C date`"
747 .for target_arch in ${TARGET_ARCHES_${TARGET}}
748 universe_kernconfs: universe_kernconfs_${target_arch} .PHONY
749 universe_kernconfs_${target_arch}:
751 .endif # make(universe_kernels)
752 universe: universe_epilogue
753 universe_epilogue: .PHONY
754 @echo "--------------------------------------------------------------"
755 @echo ">>> make universe completed on `LC_ALL=C date`"
756 @echo " (started ${STARTTIME})"
757 @echo "--------------------------------------------------------------"
758 .if defined(DOING_TINDERBOX)
759 @if [ -e ${FAILFILE} ] ; then \
760 echo "Tinderbox failed:" ;\
767 .if defined(.PARSEDIR)
768 # This makefile does not run in meta mode
770 # Normally the things we run from here don't either.
771 # Using -DWITH_META_MODE
772 # we can buildworld with meta files created which are useful
773 # for debugging, but without any of the rest of a meta mode build.
776 # tell meta.autodep.mk to not even think about updating anything.
777 UPDATE_DEPENDFILE= NO
778 .if !make(showconfig)
779 .export MK_DIRDEPS_BUILD MK_STAGING UPDATE_DEPENDFILE
783 # we do not want a failure of one branch abort all.
784 MAKE_JOB_ERROR_TOKEN= no
785 .export MAKE_JOB_ERROR_TOKEN
789 .endif # DIRDEPS_BUILD