4 # The user-driven targets are:
6 # universe - *Really* build *everything* (buildworld and
7 # all kernels on all architectures). Define the
8 # MAKE_JUST_KERNELS variable to only build kernels.
9 # tinderbox - Same as universe, but presents a list of failed build
10 # targets and exits with an error if there were any.
11 # buildworld - Rebuild *everything*, including glue to help do
13 # installworld - Install everything built by "buildworld".
14 # world - buildworld + installworld, no kernel.
15 # buildkernel - Rebuild the kernel and the kernel-modules.
16 # installkernel - Install the kernel and the kernel-modules.
18 # reinstallkernel - Reinstall the kernel and the kernel-modules.
19 # reinstallkernel.debug
20 # kernel - buildkernel + installkernel.
21 # kernel-toolchain - Builds the subset of world necessary to build a kernel
22 # kernel-toolchains - Build kernel-toolchain for all universe targets.
23 # doxygen - Build API documentation of the kernel, needs doxygen.
24 # update - Convenient way to update your source tree(s).
25 # checkworld - Run test suite on installed world.
26 # check-old - List obsolete directories/files/libraries.
27 # check-old-dirs - List obsolete directories.
28 # check-old-files - List obsolete files.
29 # check-old-libs - List obsolete libraries.
30 # delete-old - Delete obsolete directories/files.
31 # delete-old-dirs - Delete obsolete directories.
32 # delete-old-files - Delete obsolete files.
33 # delete-old-libs - Delete obsolete libraries.
34 # targets - Print a list of supported TARGET/TARGET_ARCH pairs
35 # for world and kernel targets.
36 # toolchains - Build a toolchain for all world and kernel targets.
37 # sysent - (Re)build syscall entries from syscalls.master.
38 # xdev - xdev-build + xdev-install for the architecture
39 # specified with TARGET and TARGET_ARCH.
40 # xdev-build - Build cross-development tools.
41 # xdev-install - Install cross-development tools.
42 # xdev-links - Create traditional links in /usr/bin for cc, etc
43 # native-xtools - Create host binaries that produce target objects
44 # for use in qemu user-mode jails. TARGET and
45 # TARGET_ARCH should be defined.
46 # native-xtools-install
47 # - Install the files to the given DESTDIR/NXTP where
48 # NXTP defaults to /nxb-bin.
50 # This makefile is simple by design. The FreeBSD make automatically reads
51 # the /usr/share/mk/sys.mk unless the -m argument is specified on the
52 # command line. By keeping this makefile simple, it doesn't matter too
53 # much how different the installed mk files are from those in the source
54 # tree. This makefile executes a child make process, forcing it to use
55 # the mk files from the source tree which are supposed to DTRT.
57 # Most of the user-driven targets (as listed above) are implemented in
58 # Makefile.inc1. The exceptions are universe, tinderbox and targets.
60 # If you want to build your system from source, be sure that /usr/obj has
61 # at least 6 GB of disk space available. A complete 'universe' build of
62 # r340283 (2018-11) required 167 GB of space. ZFS lz4 compression
63 # achieved a 2.18x ratio, reducing actual space to 81 GB.
65 # For individuals wanting to build from the sources currently on their
66 # system, the simple instructions are:
68 # 1. `cd /usr/src' (or to the directory containing your source tree).
69 # 2. Define `HISTORICAL_MAKE_WORLD' variable (see README).
72 # For individuals wanting to upgrade their sources (even if only a
73 # delta of a few days):
75 # 1. `cd /usr/src' (or to the directory containing your source tree).
76 # 2. `make buildworld'
77 # 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
78 # 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
79 # [steps 3. & 4. can be combined by using the "kernel" target]
80 # 5. `reboot' (in single user mode: boot -s from the loader prompt).
82 # 7. `make installworld'
83 # 8. `mergemaster' (you may wish to use -i, along with -U or -F).
84 # 9. `make delete-old'
86 # 11. `make delete-old-libs' (in case no 3rd party program uses them anymore)
88 # See src/UPDATING `COMMON ITEMS' for more complete information.
90 # If TARGET=machine (e.g. powerpc, sparc64, ...) is specified you can
91 # cross build world for other machine types using the buildworld target,
92 # and once the world is built you can cross build a kernel using the
95 # Define the user-driven targets. These are listed here in alphabetical
96 # order, but that's not important.
98 # Targets that begin with underscore are internal targets intended for
99 # developer convenience only. They are intentionally not documented and
100 # completely subject to change without notice.
102 # For more information, see the build(7) manual page.
105 # This is included so CC is set to ccache for -V, and COMPILER_TYPE/VERSION
106 # can be cached for sub-makes. We can't do this while still running on the
107 # old fmake from FreeBSD 9.x or older, so avoid including it then to avoid
108 # heartburn upgrading from older systems. The need for CC is done with new
109 # make later in the build, and caching COMPILER_TYPE/VERSION is only an
110 # optimization. Also sinclude it to be friendlier to foreign OS hosted builds.
111 .if ${MAKE_VERSION} >= 20140620 && defined(.PARSEDIR)
112 .sinclude <bsd.compiler.mk>
115 # Note: we use this awkward construct to be compatible with FreeBSD's
116 # old make used in 10.0 and 9.2 and earlier.
117 .if defined(MK_DIRDEPS_BUILD) && ${MK_DIRDEPS_BUILD} == "yes" && \
118 !make(showconfig) && !make(print-dir)
119 # targets/Makefile plays the role of top-level
120 .include "targets/Makefile"
123 TGTS= all all-man buildenv buildenvvars buildkernel buildworld \
124 check check-old check-old-dirs check-old-files check-old-libs \
125 checkdpadd checkworld clean cleandepend cleandir cleanworld \
127 delete-old delete-old-dirs delete-old-files delete-old-libs \
128 depend distribute distributekernel distributekernel.debug \
129 distributeworld distrib-dirs distribution doxygen \
130 everything hier hierarchy install installcheck installkernel \
131 installkernel.debug packagekernel packageworld \
132 reinstallkernel reinstallkernel.debug \
133 installworld kernel-toolchain libraries maninstall \
134 obj objlink showconfig tags toolchain update \
136 _worldtmp _legacy _bootstrap-tools _cleanobj _obj \
137 _build-tools _build-metadata _cross-tools _includes _libraries \
138 build32 distribute32 install32 buildsoft distributesoft installsoft \
139 builddtb xdev xdev-build xdev-install \
140 xdev-links native-xtools native-xtools-install stageworld stagekernel \
141 stage-packages stage-packages-kernel stage-packages-world \
142 create-packages-world create-packages-kernel create-packages \
143 packages installconfig real-packages sign-packages package-pkg \
144 print-dir test-system-compiler test-system-linker
146 # These targets require a TARGET and TARGET_ARCH be defined.
147 XTGTS= native-xtools native-xtools-install xdev xdev-build xdev-install \
150 # XXX: r156740: This can't work since bsd.subdir.mk is not included ever.
151 # It will only work for SUBDIR_TARGETS in make.conf.
152 TGTS+= ${SUBDIR_TARGETS}
154 BITGTS= files includes
155 BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
158 # Only some targets are allowed to use meta mode. Others get it
159 # disabled. In some cases, such as 'install', meta mode can be dangerous
160 # as a cookie may be used to prevent redundant installations (such as
161 # for WORLDTMP staging). For DESTDIR=/ we always want to install though.
162 # For other cases, such as delete-old-libs, meta mode may break
163 # the interactive tty prompt. The safest route is to just whitelist
164 # the ones that benefit from it.
165 META_TGT_WHITELIST+= \
166 _* build32 buildfiles buildincludes buildkernel buildsoft \
167 buildworld everything kernel-toolchain kernel-toolchains kernel \
168 kernels libraries native-xtools showconfig test-system-compiler \
169 test-system-linker tinderbox toolchain \
170 toolchains universe universe-toolchain world worlds xdev xdev-build
172 .ORDER: buildworld installworld
173 .ORDER: buildworld distrib-dirs
174 .ORDER: buildworld distribution
175 .ORDER: buildworld distribute
176 .ORDER: buildworld distributeworld
177 .ORDER: buildworld buildkernel
178 .ORDER: distrib-dirs distribute
179 .ORDER: distrib-dirs distributeworld
180 .ORDER: distrib-dirs installworld
181 .ORDER: distribution distribute
182 .ORDER: distributeworld distribute
183 .ORDER: distributeworld distribution
184 .ORDER: installworld distribute
185 .ORDER: installworld distribution
186 .ORDER: installworld installkernel
187 .ORDER: buildkernel installkernel
188 .ORDER: buildkernel installkernel.debug
189 .ORDER: buildkernel reinstallkernel
190 .ORDER: buildkernel reinstallkernel.debug
192 PATH= /sbin:/bin:/usr/sbin:/usr/bin
193 MAKEOBJDIRPREFIX?= /usr/obj
194 _MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} MK_AUTO_OBJ=no \
195 ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
196 SRCCONF=${SRCCONF} SRC_ENV_CONF= \
197 -f /dev/null -V MAKEOBJDIRPREFIX dummy
198 .if !empty(_MAKEOBJDIRPREFIX)
199 .error MAKEOBJDIRPREFIX can only be set in environment or src-env.conf(5),\
200 not as a global (in make.conf(5) or src.conf(5)) or command-line variable.
203 # We often need to use the tree's version of make to build it.
204 # Choices add to complexity though.
205 # We cannot blindly use a make which may not be the one we want
206 # so be explicit - until all choice is removed.
208 .if !empty(.MAKE.MODE:Mmeta)
209 # 20160604 - support missing-meta,missing-filemon and performance improvements
210 WANT_MAKE_VERSION= 20160604
212 # 20160220 - support .dinclude for FAST_DEPEND.
213 WANT_MAKE_VERSION= 20160220
215 MYMAKE= ${OBJROOT}make.${MACHINE}/${WANT_MAKE}
216 .if defined(.PARSEDIR)
221 .if defined(ALWAYS_BOOTSTRAP_MAKE) || \
222 ${HAVE_MAKE} != ${WANT_MAKE} || \
223 (defined(WANT_MAKE_VERSION) && ${MAKE_VERSION} < ${WANT_MAKE_VERSION})
226 .if exists(${MYMAKE})
227 SUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
228 .elif defined(NEED_MAKE_UPGRADE)
229 # It may not exist yet but we may cause it to.
230 # In the case of fmake, upgrade_checks may cause a newer version to be built.
231 SUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
232 -m ${.CURDIR}/share/mk
234 SUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
237 _MAKE= PATH=${PATH} MAKE_CMD="${MAKE}" ${SUB_MAKE} -f Makefile.inc1 \
238 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH} ${_MAKEARGS}
240 .if defined(MK_META_MODE) && ${MK_META_MODE} == "yes"
241 # Only allow meta mode for the whitelisted targets. See META_TGT_WHITELIST
242 # above. If overridden as a make argument then don't bother trying to
244 .if empty(.MAKEOVERRIDES:MMK_META_MODE)
245 .for _tgt in ${META_TGT_WHITELIST}
247 _CAN_USE_META_MODE?= yes
250 .if !defined(_CAN_USE_META_MODE)
251 _MAKE+= MK_META_MODE=no
253 .if defined(.PARSEDIR)
256 .endif # !defined(_CAN_USE_META_MODE)
257 .endif # empty(.MAKEOVERRIDES:MMK_META_MODE)
259 .if ${MK_META_MODE} == "yes"
260 .if !exists(/dev/filemon) && !defined(NO_FILEMON) && !make(showconfig)
261 # Require filemon be loaded to provide a working incremental build
262 .error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded. \
263 ${.newline}ERROR: WITH_META_MODE is enabled but requires filemon for an incremental build. \
264 ${.newline}ERROR: 'kldload filemon' or pass -DNO_FILEMON to suppress this error.
265 .endif # !exists(/dev/filemon) && !defined(NO_FILEMON)
266 .endif # ${MK_META_MODE} == yes
267 .endif # defined(MK_META_MODE) && ${MK_META_MODE} == yes
269 # Guess target architecture from target type, and vice versa, based on
270 # historic FreeBSD practice of tending to have TARGET == TARGET_ARCH
271 # expanding to TARGET == TARGET_CPUARCH in recent times, with known
273 .if !defined(TARGET_ARCH) && defined(TARGET)
274 # T->TA mapping is usually TARGET with arm64 the odd man out
275 _TARGET_ARCH= ${TARGET:S/arm64/aarch64/:S/riscv/riscv64/}
276 .elif !defined(TARGET) && defined(TARGET_ARCH) && \
277 ${TARGET_ARCH} != ${MACHINE_ARCH}
278 # TA->T mapping is accidentally CPUARCH with aarch64 the odd man out
279 _TARGET= ${TARGET_ARCH:${__TO_CPUARCH}:C/aarch64/arm64/}
281 .if defined(TARGET) && !defined(_TARGET)
284 .if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
285 _TARGET_ARCH=${TARGET_ARCH}
287 # for historical compatibility for xdev targets
291 .if defined(XDEV_ARCH)
292 _TARGET_ARCH= ${XDEV_ARCH}
294 # Some targets require a set TARGET/TARGET_ARCH, check before the default
295 # MACHINE and after the compatibility handling.
296 .if !defined(_TARGET) || !defined(_TARGET_ARCH)
297 ${XTGTS}: _assert_target
299 # Otherwise, default to current machine type and architecture.
301 _TARGET_ARCH?= ${MACHINE_ARCH}
303 .if make(native-xtools*)
304 NXB_TARGET:= ${_TARGET}
305 NXB_TARGET_ARCH:= ${_TARGET_ARCH}
307 _TARGET_ARCH= ${MACHINE_ARCH}
308 _MAKE+= NXB_TARGET=${NXB_TARGET} \
309 NXB_TARGET_ARCH=${NXB_TARGET_ARCH}
316 _assert_target: .PHONY .MAKE
317 .for _tgt in ${XTGTS}
319 @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${_tgt}\" target"
325 # Make sure we have an up-to-date make(1). Only world and buildworld
326 # should do this as those are the initial targets used for upgrades.
327 # The user can define ALWAYS_CHECK_MAKE to have this check performed
330 .if defined(ALWAYS_CHECK_MAKE) || !defined(.PARSEDIR)
331 ${TGTS}: upgrade_checks
333 buildworld: upgrade_checks
337 # Handle the user-driven targets, using the source relative mk files.
340 tinderbox toolchains kernel-toolchains: .MAKE
341 ${TGTS}: .PHONY .MAKE
342 ${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
344 # The historic default "all" target creates files which may cause stale
345 # or (in the cross build case) unlinkable results. Fail with an error
346 # when no target is given. The users can explicitly specify "all"
347 # if they want the historic behavior.
352 @echo "Explicit target required. Likely \"${SUBDIR_OVERRIDE:Dall:Ubuildworld}\" is wanted. See build(7)."
356 STARTTIME!= LC_ALL=C date
357 CHECK_TIME!= cmp=`mktemp`; find ${.CURDIR}/sys/sys/param.h -newer "$$cmp" && rm "$$cmp"; echo
358 .if !empty(CHECK_TIME)
359 .error check your date/time: ${STARTTIME}
362 .if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
366 # Attempt to rebuild and reinstall everything. This target is not to be
367 # used for upgrading an existing FreeBSD system, because the kernel is
368 # not included. One can argue that this target doesn't build everything
371 world: upgrade_checks .PHONY
372 @echo "--------------------------------------------------------------"
373 @echo ">>> make world started on ${STARTTIME}"
374 @echo "--------------------------------------------------------------"
375 .if target(pre-world)
377 @echo "--------------------------------------------------------------"
378 @echo ">>> Making 'pre-world' target"
379 @echo "--------------------------------------------------------------"
380 ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
382 ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
383 ${_+_}@cd ${.CURDIR}; ${_MAKE} installworld MK_META_MODE=no
384 .if target(post-world)
386 @echo "--------------------------------------------------------------"
387 @echo ">>> Making 'post-world' target"
388 @echo "--------------------------------------------------------------"
389 ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
392 @echo "--------------------------------------------------------------"
393 @echo ">>> make world completed on `LC_ALL=C date`"
394 @echo " (started ${STARTTIME})"
395 @echo "--------------------------------------------------------------"
398 @echo "WARNING: make world will overwrite your existing FreeBSD"
399 @echo "installation without also building and installing a new"
400 @echo "kernel. This can be dangerous. Please read the handbook,"
401 @echo "'Rebuilding world', for how to upgrade your system."
402 @echo "Define DESTDIR to where you want to install FreeBSD,"
403 @echo "including /, to override this warning and proceed as usual."
405 @echo "Bailing out now..."
412 # Short hand for `make buildkernel installkernel'
414 kernel: buildkernel installkernel .PHONY
417 # Perform a few tests to determine if the installed tools are adequate
418 # for building the world.
420 upgrade_checks: .PHONY
421 .if defined(NEED_MAKE_UPGRADE)
422 @${_+_}(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
426 # Upgrade make(1) to the current version using the installed
427 # headers, libraries and tools. Also, allow the location of
428 # the system bsdmake-like utility to be overridden.
432 INSTALL="sh ${.CURDIR}/tools/install.sh"
433 MMAKE= ${MMAKEENV} ${MAKE} \
434 OBJTOP=${MYMAKE:H}/obj \
435 OBJROOT='$${OBJTOP}/' \
438 -DNO_CPU_CFLAGS -DNO_WERROR \
440 DESTDIR= PROGNAME=${MYMAKE:T}
444 @echo "--------------------------------------------------------------"
445 @echo ">>> Building an up-to-date ${.TARGET}(1)"
446 @echo "--------------------------------------------------------------"
447 ${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
451 ${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR=
454 @echo "'make regress' has been renamed 'make check'" | /usr/bin/fmt
457 tinderbox toolchains kernel-toolchains kernels worlds: upgrade_checks
460 @cd ${.CURDIR}; ${SUB_MAKE} DOING_TINDERBOX=YES universe
463 @cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
465 kernel-toolchains: .PHONY
466 @cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
469 @cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=buildkernel universe
472 @cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=buildworld universe
477 # Attempt to rebuild *everything* for all supported architectures,
478 # with a reasonable chance of success, regardless of how old your
479 # existing system is.
481 .if make(universe) || make(universe_kernels) || make(tinderbox) || \
482 make(targets) || make(universe-toolchain)
483 TARGETS?=amd64 arm arm64 i386 mips powerpc riscv sparc64
484 _UNIVERSE_TARGETS= ${TARGETS}
485 TARGET_ARCHES_arm?= arm armv6 armv7
486 TARGET_ARCHES_arm64?= aarch64
487 TARGET_ARCHES_mips?= mipsel mips mips64el mips64 mipsn32 mipselhf mipshf mips64elhf mips64hf
488 TARGET_ARCHES_powerpc?= powerpc powerpc64 powerpcspe
489 # riscv64sf excluded due to PR 232085
490 TARGET_ARCHES_riscv?= riscv64
491 .for target in ${TARGETS}
492 TARGET_ARCHES_${target}?= ${target}
495 MAKE_PARAMS_riscv?= CROSS_TOOLCHAIN=riscv64-gcc
497 # XXX Remove architectures only supported by external toolchain from universe
498 # if required toolchain packages are missing.
499 TOOLCHAINS_riscv= riscv64
501 .if ${_UNIVERSE_TARGETS:M${target}}
502 .for toolchain in ${TOOLCHAINS_${target}}
503 .if !exists(/usr/local/share/toolchains/${toolchain}-gcc.mk)
504 _UNIVERSE_TARGETS:= ${_UNIVERSE_TARGETS:N${target}}
505 universe: universe_${toolchain}_skip .PHONY
506 universe_epilogue: universe_${toolchain}_skip .PHONY
507 universe_${toolchain}_skip: universe_prologue .PHONY
508 @echo ">> ${target} skipped - install ${toolchain}-xtoolchain-gcc port or package to build"
514 .if defined(UNIVERSE_TARGET)
515 MAKE_JUST_WORLDS= YES
517 UNIVERSE_TARGET?= buildworld
519 KERNSRCDIR?= ${.CURDIR}/sys
522 @echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
523 .for target in ${TARGETS}
524 .for target_arch in ${TARGET_ARCHES_${target}}
525 @echo " ${target}/${target_arch}"
529 .if defined(DOING_TINDERBOX)
530 FAILFILE=${.CURDIR}/_.tinderbox.failed
531 MAKEFAIL=tee -a ${FAILFILE}
536 universe_prologue: upgrade_checks
537 universe: universe_prologue
538 universe_prologue: .PHONY
539 @echo "--------------------------------------------------------------"
540 @echo ">>> make universe started on ${STARTTIME}"
541 @echo "--------------------------------------------------------------"
542 .if defined(DOING_TINDERBOX)
546 universe-toolchain: .PHONY universe_prologue
547 @echo "--------------------------------------------------------------"
548 @echo "> Toolchain bootstrap started on `LC_ALL=C date`"
549 @echo "--------------------------------------------------------------"
550 ${_+_}@cd ${.CURDIR}; \
551 env PATH=${PATH} ${SUB_MAKE} ${JFLAG} kernel-toolchain \
552 TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH} \
553 OBJTOP="${HOST_OBJTOP}" \
554 WITHOUT_SYSTEM_COMPILER=yes \
555 WITHOUT_SYSTEM_LINKER=yes \
556 TOOLS_PREFIX_UNDEF= \
558 MK_LLVM_TARGET_ALL=yes \
559 > _.${.TARGET} 2>&1 || \
560 (echo "${.TARGET} failed," \
561 "check _.${.TARGET} for details" | \
563 @if [ ! -e "${HOST_OBJTOP}/tmp/usr/bin/cc" ]; then \
564 echo "Missing host compiler at ${HOST_OBJTOP}/tmp/usr/bin/cc?" >&2; \
567 @if [ ! -e "${HOST_OBJTOP}/tmp/usr/bin/ld" ]; then \
568 echo "Missing host linker at ${HOST_OBJTOP}/tmp/usr/bin/ld?" >&2; \
571 @echo "--------------------------------------------------------------"
572 @echo "> Toolchain bootstrap completed on `LC_ALL=C date`"
573 @echo "--------------------------------------------------------------"
575 .for target in ${_UNIVERSE_TARGETS}
576 universe: universe_${target}
577 universe_epilogue: universe_${target}
578 universe_${target}: universe_${target}_prologue .PHONY
579 universe_${target}_prologue: universe_prologue .PHONY
580 @echo ">> ${target} started on `LC_ALL=C date`"
581 universe_${target}_worlds: .PHONY
583 .if !make(targets) && !make(universe-toolchain)
584 .for target_arch in ${TARGET_ARCHES_${target}}
585 .if !defined(_need_clang_${target}_${target_arch})
586 _need_clang_${target}_${target_arch} != \
587 env TARGET=${target} TARGET_ARCH=${target_arch} \
588 ${SUB_MAKE} -C ${.CURDIR} -f Makefile.inc1 test-system-compiler \
589 ${MAKE_PARAMS_${target}} -V MK_CLANG_BOOTSTRAP 2>/dev/null || \
591 .export _need_clang_${target}_${target_arch}
593 .if !defined(_need_lld_${target}_${target_arch})
594 _need_lld_${target}_${target_arch} != \
595 env TARGET=${target} TARGET_ARCH=${target_arch} \
596 ${SUB_MAKE} -C ${.CURDIR} -f Makefile.inc1 test-system-linker \
597 ${MAKE_PARAMS_${target}} -V MK_LLD_BOOTSTRAP 2>/dev/null || \
599 .export _need_lld_${target}_${target_arch}
601 # Setup env for each arch to use the one clang.
602 .if defined(_need_clang_${target}_${target_arch}) && \
603 ${_need_clang_${target}_${target_arch}} == "yes"
604 # No check on existing XCC or CROSS_BINUTILS_PREFIX, etc, is needed since
605 # we use the test-system-compiler logic to determine if clang needs to be
606 # built. It will be no from that logic if already using an external
607 # toolchain or /usr/bin/cc.
608 # XXX: Passing HOST_OBJTOP into the PATH would allow skipping legacy,
609 # bootstrap-tools, and cross-tools. Need to ensure each tool actually
610 # supports all TARGETS though.
611 # For now we only pass UNIVERSE_TOOLCHAIN_PATH which will be added at the end
612 # of STRICTTMPPATH to ensure that the target-specific binaries come first.
613 MAKE_PARAMS_${target}+= \
614 XCC="${HOST_OBJTOP}/tmp/usr/bin/cc" \
615 XCXX="${HOST_OBJTOP}/tmp/usr/bin/c++" \
616 XCPP="${HOST_OBJTOP}/tmp/usr/bin/cpp" \
617 UNIVERSE_TOOLCHAIN_PATH=${HOST_OBJTOP}/tmp/usr/bin
619 .if defined(_need_lld_${target}_${target_arch}) && \
620 ${_need_lld_${target}_${target_arch}} == "yes"
621 MAKE_PARAMS_${target}+= \
622 XLD="${HOST_OBJTOP}/tmp/usr/bin/ld"
625 .endif # !make(targets)
627 .if !defined(MAKE_JUST_KERNELS)
628 universe_${target}_done: universe_${target}_worlds .PHONY
629 .for target_arch in ${TARGET_ARCHES_${target}}
630 universe_${target}_worlds: universe_${target}_${target_arch} .PHONY
631 .if (defined(_need_clang_${target}_${target_arch}) && \
632 ${_need_clang_${target}_${target_arch}} == "yes") || \
633 (defined(_need_lld_${target}_${target_arch}) && \
634 ${_need_lld_${target}_${target_arch}} == "yes")
635 universe_${target}_${target_arch}: universe-toolchain
636 universe_${target}_prologue: universe-toolchain
638 universe_${target}_${target_arch}: universe_${target}_prologue .MAKE .PHONY
639 @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
640 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
641 ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
643 TARGET_ARCH=${target_arch} \
644 ${MAKE_PARAMS_${target}} \
645 > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
646 (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
647 "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
649 @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
651 .endif # !MAKE_JUST_KERNELS
653 .if !defined(MAKE_JUST_WORLDS)
654 universe_${target}_done: universe_${target}_kernels .PHONY
655 universe_${target}_kernels: universe_${target}_worlds .PHONY
656 universe_${target}_kernels: universe_${target}_prologue .MAKE .PHONY
657 @if [ -e "${KERNSRCDIR}/${target}/conf/NOTES" ]; then \
658 (cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
660 > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
661 (echo "${target} 'make LINT' failed," \
662 "check _.${target}.makeLINT for details"| ${MAKEFAIL})); \
664 @cd ${.CURDIR}; ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
666 .endif # !MAKE_JUST_WORLDS
668 # Tell the user the worlds and kernels have completed
669 universe_${target}: universe_${target}_done
670 universe_${target}_done:
671 @echo ">> ${target} completed on `LC_ALL=C date`"
673 .if make(universe_kernconfs) || make(universe_kernels)
677 universe_kernels_prologue: .PHONY
678 @echo ">> ${TARGET} kernels started on `LC_ALL=C date`"
679 universe_kernels: universe_kernconfs .PHONY
680 @echo ">> ${TARGET} kernels completed on `LC_ALL=C date`"
681 .if defined(MAKE_ALL_KERNELS)
683 .elif defined(MAKE_LINT_KERNELS)
684 _THINNER=grep 'LINT' || true
686 _THINNER=xargs grep -L "^.NO_UNIVERSE" || true
688 KERNCONFS!= cd ${KERNSRCDIR}/${TARGET}/conf && \
689 find [[:upper:][:digit:]]*[[:upper:][:digit:]] \
690 -type f -maxdepth 0 \
691 ! -name DEFAULTS ! -name NOTES | \
693 universe_kernconfs: universe_kernels_prologue .PHONY
694 .for kernel in ${KERNCONFS}
695 TARGET_ARCH_${kernel}!= cd ${KERNSRCDIR}/${TARGET}/conf && \
696 config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
697 grep -v WARNING: | cut -f 2
698 .if empty(TARGET_ARCH_${kernel})
699 .error "Target architecture for ${TARGET}/conf/${kernel} unknown. config(8) likely too old."
701 universe_kernconfs: universe_kernconf_${TARGET}_${kernel}
702 universe_kernconf_${TARGET}_${kernel}: .MAKE
703 @echo ">> ${TARGET}.${TARGET_ARCH_${kernel}} ${kernel} kernel started on `LC_ALL=C date`"
704 @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
705 ${SUB_MAKE} ${JFLAG} buildkernel \
707 TARGET_ARCH=${TARGET_ARCH_${kernel}} \
708 ${MAKE_PARAMS_${TARGET}} \
710 > _.${TARGET}.${kernel} 2>&1 || \
711 (echo "${TARGET} ${kernel} kernel failed," \
712 "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
713 @echo ">> ${TARGET}.${TARGET_ARCH_${kernel}} ${kernel} kernel completed on `LC_ALL=C date`"
715 .endif # make(universe_kernels)
716 universe: universe_epilogue
717 universe_epilogue: .PHONY
718 @echo "--------------------------------------------------------------"
719 @echo ">>> make universe completed on `LC_ALL=C date`"
720 @echo " (started ${STARTTIME})"
721 @echo "--------------------------------------------------------------"
722 .if defined(DOING_TINDERBOX)
723 @if [ -e ${FAILFILE} ] ; then \
724 echo "Tinderbox failed:" ;\
732 ${MAKE} -C ${.CURDIR}/sys/${_TARGET}/conf LINT
734 .if defined(.PARSEDIR)
735 # This makefile does not run in meta mode
737 # Normally the things we run from here don't either.
738 # Using -DWITH_META_MODE
739 # we can buildworld with meta files created which are useful
740 # for debugging, but without any of the rest of a meta mode build.
743 # tell meta.autodep.mk to not even think about updating anything.
744 UPDATE_DEPENDFILE= NO
745 .if !make(showconfig)
746 .export MK_DIRDEPS_BUILD MK_STAGING UPDATE_DEPENDFILE
750 # we do not want a failure of one branch abort all.
751 MAKE_JOB_ERROR_TOKEN= no
752 .export MAKE_JOB_ERROR_TOKEN
756 .endif # DIRDEPS_BUILD