4 # The common user-driven targets are (for a complete list, see build(7)):
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 # list-old-dirs - Raw list of possibly obsolete directories.
37 # list-old-files - Raw list of possibly obsolete files.
38 # list-old-libs - Raw list of possibly obsolete libraries.
39 # targets - Print a list of supported TARGET/TARGET_ARCH pairs
40 # for world and kernel targets.
41 # toolchains - Build a toolchain for all world and kernel targets.
42 # makeman - Regenerate src.conf(5)
43 # sysent - (Re)build syscall entries from syscalls.master.
44 # xdev - xdev-build + xdev-install for the architecture
45 # specified with TARGET and TARGET_ARCH.
46 # xdev-build - Build cross-development tools.
47 # xdev-install - Install cross-development tools.
48 # xdev-links - Create traditional links in /usr/bin for cc, etc
49 # native-xtools - Create host binaries that produce target objects
50 # for use in qemu user-mode jails. TARGET and
51 # TARGET_ARCH should be defined.
52 # native-xtools-install
53 # - Install the files to the given DESTDIR/NXTP where
54 # NXTP defaults to /nxb-bin.
56 # This makefile is simple by design. The FreeBSD make automatically reads
57 # the /usr/share/mk/sys.mk unless the -m argument is specified on the
58 # command line. By keeping this makefile simple, it doesn't matter too
59 # much how different the installed mk files are from those in the source
60 # tree. This makefile executes a child make process, forcing it to use
61 # the mk files from the source tree which are supposed to DTRT.
63 # Most of the user-driven targets (as listed above) are implemented in
64 # Makefile.inc1. The exceptions are universe, tinderbox and targets.
66 # If you want to build your system from source, be sure that /usr/obj has
67 # at least 6 GB of disk space available. A complete 'universe' build of
68 # r340283 (2018-11) required 167 GB of space. ZFS lz4 compression
69 # achieved a 2.18x ratio, reducing actual space to 81 GB.
71 # For individuals wanting to build from the sources currently on their
72 # system, the simple instructions are:
74 # 1. `cd /usr/src' (or to the directory containing your source tree).
75 # 2. Define `HISTORICAL_MAKE_WORLD' variable (see README).
78 # For individuals wanting to upgrade their sources (even if only a
79 # delta of a few days):
81 # 1. `cd /usr/src' (or to the directory containing your source tree).
82 # 2. `make buildworld'
83 # 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
84 # 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
85 # [steps 3. & 4. can be combined by using the "kernel" target]
86 # 5. `reboot' (in single user mode: boot -s from the loader prompt).
88 # 7. `make installworld'
90 # 9. `make delete-old'
92 # 11. `make delete-old-libs' (in case no 3rd party program uses them anymore)
94 # For individuals wanting to build from source with GCC from ports, first
95 # install the appropriate GCC cross toolchain package:
96 # `pkg install ${TARGET_ARCH}-gccN`
98 # Once you have installed the necessary cross toolchain, simply pass
99 # CROSS_TOOLCHAIN=${TARGET_ARCH}-gccN while building with the above steps,
100 # e.g., `make buildworld CROSS_TOOLCHAIN=amd64-gcc6`.
102 # The ${TARGET_ARCH}-gccN packages are provided as flavors of the
103 # devel/freebsd-gccN ports.
105 # See src/UPDATING `COMMON ITEMS' for more complete information.
107 # If TARGET=machine (e.g. powerpc, arm64, ...) is specified you can
108 # cross build world for other machine types using the buildworld target,
109 # and once the world is built you can cross build a kernel using the
110 # buildkernel target.
112 # Define the user-driven targets. These are listed here in alphabetical
113 # order, but that's not important.
115 # Targets that begin with underscore are internal targets intended for
116 # developer convenience only. They are intentionally not documented and
117 # completely subject to change without notice.
119 # For more information, see the build(7) manual page.
122 # Include jobs.mk early if we need it.
124 # make buildworld-jobs
126 # make -j${JOB_MAX} buildworld > ../buildworld.log 2>&1
132 .if defined(UNIVERSE_TARGET) || defined(MAKE_JUST_WORLDS) || defined(WITHOUT_KERNELS)
135 .if defined(MAKE_JUST_KERNELS) || defined(WITHOUT_WORLDS)
141 # This is included so CC is set to ccache for -V, and COMPILER_TYPE/VERSION
142 # can be cached for sub-makes. We can't do this while still running on the
143 # old fmake from FreeBSD 9.x or older, so avoid including it then to avoid
144 # heartburn upgrading from older systems. The need for CC is done with new
145 # make later in the build, and caching COMPILER_TYPE/VERSION is only an
146 # optimization. Also sinclude it to be friendlier to foreign OS hosted builds.
147 .if ${MAKE_VERSION} >= 20140620 && defined(.PARSEDIR)
148 .sinclude <bsd.compiler.mk>
151 # Note: we use this awkward construct to be compatible with FreeBSD's
152 # old make used in 10.0 and 9.2 and earlier.
153 .if defined(MK_DIRDEPS_BUILD) && ${MK_DIRDEPS_BUILD} == "yes" && \
154 !make(showconfig) && !make(print-dir)
155 # targets/Makefile plays the role of top-level
156 .include "targets/Makefile"
159 TGTS= all all-man buildenv buildenvvars buildkernel buildworld \
160 check check-old check-old-dirs check-old-files check-old-libs \
161 checkdpadd checkworld clean cleandepend cleandir cleankernel \
162 cleanworld cleanuniverse \
163 delete-old delete-old-dirs delete-old-files delete-old-libs \
164 depend distribute distributekernel distributekernel.debug \
165 distributeworld distrib-dirs distribution doxygen \
166 everything hier hierarchy install installcheck installkernel \
167 installkernel.debug packagekernel packageworld \
168 reinstallkernel reinstallkernel.debug \
169 installworld kernel-toolchain libraries maninstall \
170 list-old-dirs list-old-files list-old-libs \
171 obj objlink showconfig tags toolchain \
173 _worldtmp _legacy _bootstrap-tools _cleanobj _obj \
174 _build-tools _build-metadata _cross-tools _includes _libraries \
175 build32 distribute32 install32 \
176 builddtb xdev xdev-build xdev-install \
177 xdev-links native-xtools native-xtools-install stageworld stagekernel \
178 stage-packages stage-packages-kernel stage-packages-world \
179 create-packages-world create-packages-kernel create-packages \
180 update-packages packages installconfig real-packages real-update-packages \
181 sign-packages package-pkg print-dir test-system-compiler test-system-linker \
184 # These targets require a TARGET and TARGET_ARCH be defined.
185 XTGTS= native-xtools native-xtools-install xdev xdev-build xdev-install \
188 # XXX: r156740: This can't work since bsd.subdir.mk is not included ever.
189 # It will only work for SUBDIR_TARGETS in make.conf.
190 TGTS+= ${SUBDIR_TARGETS}
192 BITGTS= files includes
193 BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
196 # Only some targets are allowed to use meta mode. Others get it
197 # disabled. In some cases, such as 'install', meta mode can be dangerous
198 # as a cookie may be used to prevent redundant installations (such as
199 # for WORLDTMP staging). For DESTDIR=/ we always want to install though.
200 # For other cases, such as delete-old-libs, meta mode may break
201 # the interactive tty prompt. The safest route is to just whitelist
202 # the ones that benefit from it.
203 META_TGT_WHITELIST+= \
204 _* build32 buildfiles buildincludes buildkernel \
205 buildworld everything kernel-toolchain kernel-toolchains kernel \
206 kernels libraries native-xtools showconfig test-includes \
207 test-system-compiler test-system-linker tinderbox toolchain \
208 toolchains universe universe-toolchain world worlds xdev xdev-build
210 .ORDER: buildworld installworld
211 .ORDER: buildworld distrib-dirs
212 .ORDER: buildworld distribution
213 .ORDER: buildworld distribute
214 .ORDER: buildworld distributeworld
215 .ORDER: buildworld buildkernel
216 .ORDER: distrib-dirs distribute
217 .ORDER: distrib-dirs distributeworld
218 .ORDER: distrib-dirs installworld
219 .ORDER: distribution distribute
220 .ORDER: distributeworld distribute
221 .ORDER: distributeworld distribution
222 .ORDER: installworld distribute
223 .ORDER: installworld distribution
224 .ORDER: installworld installkernel
225 .ORDER: buildkernel installkernel
226 .ORDER: buildkernel installkernel.debug
227 .ORDER: buildkernel reinstallkernel
228 .ORDER: buildkernel reinstallkernel.debug
230 # Only sanitize PATH on FreeBSD.
231 # PATH may include tools that are required to cross-build
232 # on non-FreeBSD systems.
233 .if ${.MAKE.OS} == "FreeBSD"
234 PATH= /sbin:/bin:/usr/sbin:/usr/bin
236 MAKEOBJDIRPREFIX?= /usr/obj
237 _MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH:Q} ${MAKE} MK_AUTO_OBJ=no \
238 ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
239 SRCCONF=${SRCCONF} SRC_ENV_CONF= \
240 -f /dev/null -V MAKEOBJDIRPREFIX dummy
241 .if !empty(_MAKEOBJDIRPREFIX) || !empty(.MAKEOVERRIDES:MMAKEOBJDIRPREFIX)
242 .error MAKEOBJDIRPREFIX can only be set in environment or src-env.conf(5),\
243 not as a global (in make.conf(5) or src.conf(5)) or command-line variable.
246 # We often need to use the tree's version of make to build it.
247 # Choices add to complexity though.
248 # We cannot blindly use a make which may not be the one we want
249 # so be explicit - until all choice is removed.
251 .if !empty(.MAKE.MODE:Mmeta)
252 # 20160604 - support missing-meta,missing-filemon and performance improvements
253 WANT_MAKE_VERSION= 20160604
255 # 20160220 - support .dinclude for FAST_DEPEND.
256 WANT_MAKE_VERSION= 20160220
258 MYMAKE= ${OBJROOT}make.${MACHINE}/${WANT_MAKE}
259 .if defined(.PARSEDIR)
264 .if defined(ALWAYS_BOOTSTRAP_MAKE) || \
265 ${HAVE_MAKE} != ${WANT_MAKE} || \
266 (defined(WANT_MAKE_VERSION) && ${MAKE_VERSION} < ${WANT_MAKE_VERSION})
269 .if exists(${MYMAKE})
270 SUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
271 .elif defined(NEED_MAKE_UPGRADE)
272 # It may not exist yet but we may cause it to.
273 # In the case of fmake, upgrade_checks may cause a newer version to be built.
274 SUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
275 -m ${.CURDIR}/share/mk
277 SUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
280 _MAKE= PATH=${PATH:Q} MAKE_CMD="${MAKE}" ${SUB_MAKE} -f Makefile.inc1 \
281 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH} ${_MAKEARGS}
283 .if defined(MK_META_MODE) && ${MK_META_MODE} == "yes"
284 # Only allow meta mode for the whitelisted targets. See META_TGT_WHITELIST
285 # above. If overridden as a make argument then don't bother trying to
287 .if empty(.MAKEOVERRIDES:MMK_META_MODE)
288 .for _tgt in ${META_TGT_WHITELIST}
290 _CAN_USE_META_MODE?= yes
293 .if !defined(_CAN_USE_META_MODE)
294 _MAKE+= MK_META_MODE=no
296 .if defined(.PARSEDIR)
299 .endif # !defined(_CAN_USE_META_MODE)
300 .endif # empty(.MAKEOVERRIDES:MMK_META_MODE)
302 .if ${MK_META_MODE} == "yes"
303 .if !exists(/dev/filemon) && !defined(NO_FILEMON) && !make(showconfig)
304 # Require filemon be loaded to provide a working incremental build
305 .error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded. \
306 ${.newline}ERROR: WITH_META_MODE is enabled but requires filemon for an incremental build. \
307 ${.newline}ERROR: 'kldload filemon' or pass -DNO_FILEMON to suppress this error.
308 .endif # !exists(/dev/filemon) && !defined(NO_FILEMON)
309 .endif # ${MK_META_MODE} == yes
310 .endif # defined(MK_META_MODE) && ${MK_META_MODE} == yes
312 # Guess target architecture from target type, and vice versa, based on
313 # historic FreeBSD practice of tending to have TARGET == TARGET_ARCH
314 # expanding to TARGET == TARGET_CPUARCH in recent times, with known
316 .if !defined(TARGET_ARCH) && defined(TARGET)
317 # T->TA mapping is usually TARGET with arm64 the odd man out
318 _TARGET_ARCH= ${TARGET:S/arm64/aarch64/:S/riscv/riscv64/:S/arm/armv7/}
319 .elif !defined(TARGET) && defined(TARGET_ARCH) && \
320 ${TARGET_ARCH} != ${MACHINE_ARCH}
321 # TA->T mapping is accidentally CPUARCH with aarch64 the odd man out
322 _TARGET= ${TARGET_ARCH:${__TO_CPUARCH}:C/aarch64/arm64/}
324 .if defined(TARGET) && !defined(_TARGET)
327 .if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
328 _TARGET_ARCH=${TARGET_ARCH}
330 # for historical compatibility for xdev targets
334 .if defined(XDEV_ARCH)
335 _TARGET_ARCH= ${XDEV_ARCH}
337 # Some targets require a set TARGET/TARGET_ARCH, check before the default
338 # MACHINE and after the compatibility handling.
339 .if !defined(_TARGET) || !defined(_TARGET_ARCH)
340 ${XTGTS}: _assert_target
342 # Otherwise, default to current machine type and architecture.
344 _TARGET_ARCH?= ${MACHINE_ARCH}
346 .if make(native-xtools*)
347 NXB_TARGET:= ${_TARGET}
348 NXB_TARGET_ARCH:= ${_TARGET_ARCH}
350 _TARGET_ARCH= ${MACHINE_ARCH}
351 _MAKE+= NXB_TARGET=${NXB_TARGET} \
352 NXB_TARGET_ARCH=${NXB_TARGET_ARCH}
359 _assert_target: .PHONY .MAKE
360 .for _tgt in ${XTGTS}
362 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${_tgt}\" target"
368 # Make sure we have an up-to-date make(1). Only world and buildworld
369 # should do this as those are the initial targets used for upgrades.
370 # The user can define ALWAYS_CHECK_MAKE to have this check performed
373 .if defined(ALWAYS_CHECK_MAKE) || !defined(.PARSEDIR)
374 ${TGTS}: upgrade_checks
376 buildworld: upgrade_checks
380 # Handle the user-driven targets, using the source relative mk files.
383 tinderbox toolchains kernel-toolchains: .MAKE
384 ${TGTS}: .PHONY .MAKE
385 ${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
387 # The historic default "all" target creates files which may cause stale
388 # or (in the cross build case) unlinkable results. Fail with an error
389 # when no target is given. The users can explicitly specify "all"
390 # if they want the historic behavior.
395 @echo "Explicit target required. Likely \"${SUBDIR_OVERRIDE:Dall:Ubuildworld}\" is wanted. See build(7)."
399 STARTTIME!= LC_ALL=C date
400 CHECK_TIME!= cmp=`mktemp`; find ${.CURDIR}/sys/sys/param.h -newer "$$cmp" && rm "$$cmp"; echo
401 .if !empty(CHECK_TIME)
402 .error check your date/time: ${STARTTIME}
405 .if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
409 # Attempt to rebuild and reinstall everything. This target is not to be
410 # used for upgrading an existing FreeBSD system, because the kernel is
411 # not included. One can argue that this target doesn't build everything
414 world: upgrade_checks .PHONY
415 @echo "--------------------------------------------------------------"
416 @echo ">>> make world started on ${STARTTIME}"
417 @echo "--------------------------------------------------------------"
418 .if target(pre-world)
420 @echo "--------------------------------------------------------------"
421 @echo ">>> Making 'pre-world' target"
422 @echo "--------------------------------------------------------------"
423 ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
425 ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
426 ${_+_}@cd ${.CURDIR}; ${_MAKE} installworld MK_META_MODE=no
427 .if target(post-world)
429 @echo "--------------------------------------------------------------"
430 @echo ">>> Making 'post-world' target"
431 @echo "--------------------------------------------------------------"
432 ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
435 @echo "--------------------------------------------------------------"
436 @echo ">>> make world completed on `LC_ALL=C date`"
437 @echo " (started ${STARTTIME})"
438 @echo "--------------------------------------------------------------"
441 @echo "WARNING: make world will overwrite your existing FreeBSD"
442 @echo "installation without also building and installing a new"
443 @echo "kernel. This can be dangerous. Please read the handbook,"
444 @echo "'Rebuilding world', for how to upgrade your system."
445 @echo "Define DESTDIR to where you want to install FreeBSD,"
446 @echo "including /, to override this warning and proceed as usual."
448 @echo "Bailing out now..."
455 # Short hand for `make buildkernel installkernel'
457 kernel: buildkernel installkernel .PHONY
460 # Perform a few tests to determine if the installed tools are adequate
461 # for building the world.
463 upgrade_checks: .PHONY
464 .if defined(NEED_MAKE_UPGRADE)
465 @${_+_}(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
469 # Upgrade make(1) to the current version using the installed
470 # headers, libraries and tools. Also, allow the location of
471 # the system bsdmake-like utility to be overridden.
475 INSTALL="sh ${.CURDIR}/tools/install.sh"
476 MMAKE= ${MMAKEENV} ${MAKE} \
477 OBJTOP=${MYMAKE:H}/obj \
478 OBJROOT='$${OBJTOP}/' \
480 MK_MAN=no -DNO_SHARED \
481 -DNO_CPU_CFLAGS MK_WERROR=no \
483 DESTDIR= PROGNAME=${MYMAKE:T}
487 @echo "--------------------------------------------------------------"
488 @echo ">>> Building an up-to-date ${.TARGET}(1)"
489 @echo "--------------------------------------------------------------"
490 ${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
494 ${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR=
497 @echo "'make regress' has been renamed 'make check'" | /usr/bin/fmt
500 tinderbox toolchains kernel-toolchains kernels worlds: upgrade_checks
503 @cd ${.CURDIR}; ${SUB_MAKE} DOING_TINDERBOX=YES universe
506 @cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
508 kernel-toolchains: .PHONY
509 @cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
512 @cd ${.CURDIR}; ${SUB_MAKE} universe -DWITHOUT_WORLDS
515 @cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=buildworld universe
520 # Attempt to rebuild *everything* for all supported architectures,
521 # with a reasonable chance of success, regardless of how old your
522 # existing system is.
524 .if make(universe) || make(universe_kernels) || make(tinderbox) || \
525 make(targets) || make(universe-toolchain)
527 # Don't build rarely used, semi-supported architectures unless requested.
529 .if defined(EXTRA_TARGETS)
530 # powerpcspe excluded from main list until clang fixed
531 EXTRA_ARCHES_powerpc= powerpcspe
533 TARGETS?= ${TARGET_MACHINE_LIST}
534 _UNIVERSE_TARGETS= ${TARGETS}
535 .for target in ${TARGETS}
536 TARGET_ARCHES_${target}= ${MACHINE_ARCH_LIST_${target}}
539 .if defined(USE_GCC_TOOLCHAINS)
540 TOOLCHAINS_amd64= amd64-gcc12
541 TOOLCHAINS_arm= armv6-gcc12 armv7-gcc12
542 TOOLCHAIN_armv7= armv7-gcc12
543 TOOLCHAINS_arm64= aarch64-gcc12
544 TOOLCHAINS_i386= i386-gcc12
545 TOOLCHAINS_powerpc= powerpc-gcc12 powerpc64-gcc12
546 TOOLCHAIN_powerpc64= powerpc64-gcc12
547 TOOLCHAINS_riscv= riscv64-gcc12
550 # If a target is using an external toolchain, set MAKE_PARAMS to enable use
551 # of the toolchain. If the external toolchain is missing, exclude the target
553 .for target in ${_UNIVERSE_TARGETS}
554 .if !empty(TOOLCHAINS_${target})
555 .for toolchain in ${TOOLCHAINS_${target}}
556 .if !exists(/usr/local/share/toolchains/${toolchain}.mk)
557 _UNIVERSE_TARGETS:= ${_UNIVERSE_TARGETS:N${target}}
558 universe: universe_${toolchain}_skip .PHONY
559 universe_epilogue: universe_${toolchain}_skip .PHONY
560 universe_${toolchain}_skip: universe_prologue .PHONY
561 @echo ">> ${target} skipped - install ${toolchain} port or package to build"
564 .for arch in ${TARGET_ARCHES_${target}}
565 TOOLCHAIN_${arch}?= ${TOOLCHAINS_${target}:[1]}
566 MAKE_PARAMS_${arch}?= CROSS_TOOLCHAIN=${TOOLCHAIN_${arch}}
571 UNIVERSE_TARGET?= buildworld
572 KERNSRCDIR?= ${.CURDIR}/sys
575 @echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
576 .for target in ${TARGETS}
577 .for target_arch in ${TARGET_ARCHES_${target}}
578 @echo " ${target}/${target_arch}"
582 .if defined(DOING_TINDERBOX)
583 FAILFILE=${.CURDIR}/_.tinderbox.failed
584 MAKEFAIL=tee -a ${FAILFILE}
589 universe_prologue: upgrade_checks
590 universe: universe_prologue
591 universe_prologue: .PHONY
592 @echo "--------------------------------------------------------------"
593 @echo ">>> make universe started on ${STARTTIME}"
594 @echo "--------------------------------------------------------------"
595 .if defined(DOING_TINDERBOX)
599 universe-toolchain: .PHONY universe_prologue
600 @echo "--------------------------------------------------------------"
601 @echo "> Toolchain bootstrap started on `LC_ALL=C date`"
602 @echo "--------------------------------------------------------------"
603 ${_+_}@cd ${.CURDIR}; \
604 env PATH=${PATH:Q} ${SUB_MAKE} ${JFLAG} kernel-toolchain \
605 TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH} \
606 OBJTOP="${HOST_OBJTOP}" \
607 WITHOUT_SYSTEM_COMPILER=yes \
608 WITHOUT_SYSTEM_LINKER=yes \
609 TOOLS_PREFIX_UNDEF= \
611 MK_LLVM_TARGET_ALL=yes \
612 > _.${.TARGET} 2>&1 || \
613 (echo "${.TARGET} failed," \
614 "check _.${.TARGET} for details" | \
616 @if [ ! -e "${HOST_OBJTOP}/tmp/usr/bin/cc" ]; then \
617 echo "Missing host compiler at ${HOST_OBJTOP}/tmp/usr/bin/cc?" >&2; \
620 @if [ ! -e "${HOST_OBJTOP}/tmp/usr/bin/ld" ]; then \
621 echo "Missing host linker at ${HOST_OBJTOP}/tmp/usr/bin/ld?" >&2; \
624 @echo "--------------------------------------------------------------"
625 @echo "> Toolchain bootstrap completed on `LC_ALL=C date`"
626 @echo "--------------------------------------------------------------"
628 .for target in ${_UNIVERSE_TARGETS}
629 universe: universe_${target}
630 universe_epilogue: universe_${target}
631 universe_${target}: universe_${target}_prologue .PHONY
632 universe_${target}_prologue: universe_prologue .PHONY
633 @echo ">> ${target} started on `LC_ALL=C date`"
634 universe_${target}_worlds: .PHONY
636 .if !make(targets) && !make(universe-toolchain)
637 .for target_arch in ${TARGET_ARCHES_${target}}
638 .if !defined(_need_clang_${target}_${target_arch})
639 _need_clang_${target}_${target_arch} != \
640 env TARGET=${target} TARGET_ARCH=${target_arch} \
641 ${SUB_MAKE} -C ${.CURDIR} -f Makefile.inc1 test-system-compiler \
642 ${MAKE_PARAMS_${target_arch}} -V MK_CLANG_BOOTSTRAP 2>/dev/null || \
644 .export _need_clang_${target}_${target_arch}
646 .if !defined(_need_lld_${target}_${target_arch})
647 _need_lld_${target}_${target_arch} != \
648 env TARGET=${target} TARGET_ARCH=${target_arch} \
649 ${SUB_MAKE} -C ${.CURDIR} -f Makefile.inc1 test-system-linker \
650 ${MAKE_PARAMS_${target_arch}} -V MK_LLD_BOOTSTRAP 2>/dev/null || \
652 .export _need_lld_${target}_${target_arch}
654 # Setup env for each arch to use the one clang.
655 .if defined(_need_clang_${target}_${target_arch}) && \
656 ${_need_clang_${target}_${target_arch}} == "yes"
657 # No check on existing XCC or CROSS_BINUTILS_PREFIX, etc, is needed since
658 # we use the test-system-compiler logic to determine if clang needs to be
659 # built. It will be no from that logic if already using an external
660 # toolchain or /usr/bin/cc.
661 # XXX: Passing HOST_OBJTOP into the PATH would allow skipping legacy,
662 # bootstrap-tools, and cross-tools. Need to ensure each tool actually
663 # supports all TARGETS though.
664 # For now we only pass UNIVERSE_TOOLCHAIN_PATH which will be added at the end
665 # of STRICTTMPPATH to ensure that the target-specific binaries come first.
666 MAKE_PARAMS_${target_arch}+= \
667 XCC="${HOST_OBJTOP}/tmp/usr/bin/cc" \
668 XCXX="${HOST_OBJTOP}/tmp/usr/bin/c++" \
669 XCPP="${HOST_OBJTOP}/tmp/usr/bin/cpp" \
670 UNIVERSE_TOOLCHAIN_PATH=${HOST_OBJTOP}/tmp/usr/bin
672 .if defined(_need_lld_${target}_${target_arch}) && \
673 ${_need_lld_${target}_${target_arch}} == "yes"
674 MAKE_PARAMS_${target_arch}+= \
675 XLD="${HOST_OBJTOP}/tmp/usr/bin/ld"
678 .endif # !make(targets)
680 .if ${__DO_WORLDS} == "yes"
681 universe_${target}_done: universe_${target}_worlds .PHONY
682 .for target_arch in ${TARGET_ARCHES_${target}}
683 universe_${target}_worlds: universe_${target}_${target_arch} .PHONY
684 .if (defined(_need_clang_${target}_${target_arch}) && \
685 ${_need_clang_${target}_${target_arch}} == "yes") || \
686 (defined(_need_lld_${target}_${target_arch}) && \
687 ${_need_lld_${target}_${target_arch}} == "yes")
688 universe_${target}_${target_arch}: universe-toolchain
689 universe_${target}_prologue: universe-toolchain
691 universe_${target}_${target_arch}: universe_${target}_prologue .MAKE .PHONY
692 @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
693 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
694 ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
696 TARGET_ARCH=${target_arch} \
697 ${MAKE_PARAMS_${target_arch}} \
698 > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
699 (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
700 "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
702 @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
704 .endif # ${__DO_WORLDS} == "yes"
706 .if ${__DO_KERNELS} == "yes"
707 universe_${target}_done: universe_${target}_kernels .PHONY
708 universe_${target}_kernels: universe_${target}_worlds .PHONY
709 universe_${target}_kernels: universe_${target}_prologue .MAKE .PHONY
710 @cd ${.CURDIR}; ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
712 .endif # ${__DO_KERNELS} == "yes"
714 # Tell the user the worlds and kernels have completed
715 universe_${target}: universe_${target}_done
716 universe_${target}_done:
717 @echo ">> ${target} completed on `LC_ALL=C date`"
719 .if make(universe_kernconfs) || make(universe_kernels)
723 universe_kernels_prologue: .PHONY
724 @echo ">> ${TARGET} kernels started on `LC_ALL=C date`"
725 universe_kernels: universe_kernconfs .PHONY
726 @echo ">> ${TARGET} kernels completed on `LC_ALL=C date`"
727 .if defined(MAKE_ALL_KERNELS)
729 .elif defined(MAKE_LINT_KERNELS)
730 _THINNER=grep 'LINT' || true
732 _THINNER=xargs grep -L "^.NO_UNIVERSE" || true
734 KERNCONFS!= cd ${KERNSRCDIR}/${TARGET}/conf && \
735 find [[:upper:][:digit:]]*[[:upper:][:digit:]] \
736 -type f -maxdepth 0 \
737 ! -name DEFAULTS ! -name NOTES | \
739 universe_kernconfs: universe_kernels_prologue .PHONY
740 .for kernel in ${KERNCONFS}
741 TARGET_ARCH_${kernel}!= cd ${KERNSRCDIR}/${TARGET}/conf && \
742 env PATH=${HOST_OBJTOP}/tmp/legacy/bin:${PATH:Q} \
743 config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
744 grep -v WARNING: | cut -f 2
745 .if empty(TARGET_ARCH_${kernel})
746 .error Target architecture for ${TARGET}/conf/${kernel} unknown. config(8) likely too old.
748 universe_kernconfs_${TARGET_ARCH_${kernel}}: universe_kernconf_${TARGET}_${kernel}
749 universe_kernconf_${TARGET}_${kernel}: .MAKE
750 @echo ">> ${TARGET}.${TARGET_ARCH_${kernel}} ${kernel} kernel started on `LC_ALL=C date`"
751 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
752 ${SUB_MAKE} ${JFLAG} buildkernel \
754 TARGET_ARCH=${TARGET_ARCH_${kernel}} \
755 ${MAKE_PARAMS_${TARGET_ARCH_${kernel}}} \
757 > _.${TARGET}.${kernel} 2>&1 || \
758 (echo "${TARGET} ${kernel} kernel failed," \
759 "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
760 @echo ">> ${TARGET}.${TARGET_ARCH_${kernel}} ${kernel} kernel completed on `LC_ALL=C date`"
762 .for target_arch in ${TARGET_ARCHES_${TARGET}}
763 universe_kernconfs: universe_kernconfs_${target_arch} .PHONY
764 universe_kernconfs_${target_arch}:
766 .endif # make(universe_kernels)
767 universe: universe_epilogue
768 universe_epilogue: .PHONY
769 @echo "--------------------------------------------------------------"
770 @echo ">>> make universe completed on `LC_ALL=C date`"
771 @echo " (started ${STARTTIME})"
772 @echo "--------------------------------------------------------------"
773 .if defined(DOING_TINDERBOX)
774 @if [ -e ${FAILFILE} ] ; then \
775 echo "Tinderbox failed:" ;\
782 .if defined(.PARSEDIR)
783 # This makefile does not run in meta mode
785 # Normally the things we run from here don't either.
786 # Using -DWITH_META_MODE
787 # we can buildworld with meta files created which are useful
788 # for debugging, but without any of the rest of a meta mode build.
791 # tell meta.autodep.mk to not even think about updating anything.
792 UPDATE_DEPENDFILE= NO
793 .if !make(showconfig)
794 .export MK_DIRDEPS_BUILD MK_STAGING UPDATE_DEPENDFILE
798 # we do not want a failure of one branch abort all.
799 MAKE_JOB_ERROR_TOKEN= no
800 .export MAKE_JOB_ERROR_TOKEN
804 .endif # DIRDEPS_BUILD