]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile
Add UPDATING entries and bump version.
[FreeBSD/FreeBSD.git] / Makefile
1 #
2 # $FreeBSD$
3 #
4 # The user-driven targets are:
5 #
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
12 #                       upgrades.
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.
17 # installkernel.debug
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 # makeman             - Regenerate src.conf(5)
38 # sysent              - (Re)build syscall entries from syscalls.master.
39 # xdev                - xdev-build + xdev-install for the architecture
40 #                       specified with TARGET and TARGET_ARCH.
41 # xdev-build          - Build cross-development tools.
42 # xdev-install        - Install cross-development tools.
43 # xdev-links          - Create traditional links in /usr/bin for cc, etc
44 # native-xtools       - Create host binaries that produce target objects
45 #                       for use in qemu user-mode jails.  TARGET and
46 #                       TARGET_ARCH should be defined.
47 # native-xtools-install
48 #                     - Install the files to the given DESTDIR/NXTP where
49 #                       NXTP defaults to /nxb-bin.
50 #
51 # This makefile is simple by design. The FreeBSD make automatically reads
52 # the /usr/share/mk/sys.mk unless the -m argument is specified on the
53 # command line. By keeping this makefile simple, it doesn't matter too
54 # much how different the installed mk files are from those in the source
55 # tree. This makefile executes a child make process, forcing it to use
56 # the mk files from the source tree which are supposed to DTRT.
57 #
58 # Most of the user-driven targets (as listed above) are implemented in
59 # Makefile.inc1.  The exceptions are universe, tinderbox and targets.
60 #
61 # If you want to build your system from source, be sure that /usr/obj has
62 # at least 6 GB of disk space available.  A complete 'universe' build of
63 # r340283 (2018-11) required 167 GB of space.  ZFS lz4 compression
64 # achieved a 2.18x ratio, reducing actual space to 81 GB.
65 #
66 # For individuals wanting to build from the sources currently on their
67 # system, the simple instructions are:
68 #
69 # 1.  `cd /usr/src'  (or to the directory containing your source tree).
70 # 2.  Define `HISTORICAL_MAKE_WORLD' variable (see README).
71 # 3.  `make world'
72 #
73 # For individuals wanting to upgrade their sources (even if only a
74 # delta of a few days):
75 #
76 #  1.  `cd /usr/src'       (or to the directory containing your source tree).
77 #  2.  `make buildworld'
78 #  3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
79 #  4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
80 #       [steps 3. & 4. can be combined by using the "kernel" target]
81 #  5.  `reboot'        (in single user mode: boot -s from the loader prompt).
82 #  6.  `mergemaster -p'
83 #  7.  `make installworld'
84 #  8.  `mergemaster'            (you may wish to use -i, along with -U or -F).
85 #  9.  `make delete-old'
86 # 10.  `reboot'
87 # 11.  `make delete-old-libs' (in case no 3rd party program uses them anymore)
88 #
89 # For individuals wanting to build from source with GCC from ports, first
90 # install the appropriate GCC cross toolchain package:
91 #   `pkg install ${TARGET_ARCH}-gccN`
92 #
93 # Once you have installed the necessary cross toolchain, simply pass
94 # CROSS_TOOLCHAIN=${TARGET_ARCH}-gccN while building with the above steps,
95 # e.g., `make buildworld CROSS_TOOLCHAIN=amd64-gcc6`.
96 #
97 # The ${TARGET_ARCH}-gccN packages are provided as flavors of the
98 # devel/freebsd-gccN ports.
99 #
100 # See src/UPDATING `COMMON ITEMS' for more complete information.
101 #
102 # If TARGET=machine (e.g. powerpc, sparc64, ...) is specified you can
103 # cross build world for other machine types using the buildworld target,
104 # and once the world is built you can cross build a kernel using the
105 # buildkernel target.
106 #
107 # Define the user-driven targets. These are listed here in alphabetical
108 # order, but that's not important.
109 #
110 # Targets that begin with underscore are internal targets intended for
111 # developer convenience only.  They are intentionally not documented and
112 # completely subject to change without notice.
113 #
114 # For more information, see the build(7) manual page.
115 #
116
117 # This is included so CC is set to ccache for -V, and COMPILER_TYPE/VERSION
118 # can be cached for sub-makes. We can't do this while still running on the
119 # old fmake from FreeBSD 9.x or older, so avoid including it then to avoid
120 # heartburn upgrading from older systems. The need for CC is done with new
121 # make later in the build, and caching COMPILER_TYPE/VERSION is only an
122 # optimization. Also sinclude it to be friendlier to foreign OS hosted builds.
123 .if ${MAKE_VERSION} >= 20140620 && defined(.PARSEDIR)
124 .sinclude <bsd.compiler.mk>
125 .endif
126
127 # Note: we use this awkward construct to be compatible with FreeBSD's
128 # old make used in 10.0 and 9.2 and earlier.
129 .if defined(MK_DIRDEPS_BUILD) && ${MK_DIRDEPS_BUILD} == "yes" && \
130     !make(showconfig) && !make(print-dir)
131 # targets/Makefile plays the role of top-level
132 .include "targets/Makefile"
133 .else
134
135 TGTS=   all all-man buildenv buildenvvars buildkernel buildworld \
136         check check-old check-old-dirs check-old-files check-old-libs \
137         checkdpadd checkworld clean cleandepend cleandir cleanworld \
138         cleanuniverse \
139         delete-old delete-old-dirs delete-old-files delete-old-libs \
140         depend distribute distributekernel distributekernel.debug \
141         distributeworld distrib-dirs distribution doxygen \
142         everything hier hierarchy install installcheck installkernel \
143         installkernel.debug packagekernel packageworld \
144         reinstallkernel reinstallkernel.debug \
145         installworld kernel-toolchain libraries maninstall \
146         obj objlink showconfig tags toolchain update \
147         makeman sysent \
148         _worldtmp _legacy _bootstrap-tools _cleanobj _obj \
149         _build-tools _build-metadata _cross-tools _includes _libraries \
150         build32 distribute32 install32 buildsoft distributesoft installsoft \
151         builddtb xdev xdev-build xdev-install \
152         xdev-links native-xtools native-xtools-install stageworld stagekernel \
153         stage-packages \
154         create-packages-world create-packages-kernel create-packages \
155         packages installconfig real-packages sign-packages package-pkg \
156         print-dir test-system-compiler test-system-linker
157
158 # These targets require a TARGET and TARGET_ARCH be defined.
159 XTGTS=  native-xtools native-xtools-install xdev xdev-build xdev-install \
160         xdev-links
161
162 # XXX: r156740: This can't work since bsd.subdir.mk is not included ever.
163 # It will only work for SUBDIR_TARGETS in make.conf.
164 TGTS+=  ${SUBDIR_TARGETS}
165
166 BITGTS= files includes
167 BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
168 TGTS+=  ${BITGTS}
169
170 # Only some targets are allowed to use meta mode.  Others get it
171 # disabled.  In some cases, such as 'install', meta mode can be dangerous
172 # as a cookie may be used to prevent redundant installations (such as
173 # for WORLDTMP staging).  For DESTDIR=/ we always want to install though.
174 # For other cases, such as delete-old-libs, meta mode may break
175 # the interactive tty prompt.  The safest route is to just whitelist
176 # the ones that benefit from it.
177 META_TGT_WHITELIST+= \
178         _* build32 buildfiles buildincludes buildkernel buildsoft \
179         buildworld everything kernel-toolchain kernel-toolchains kernel \
180         kernels libraries native-xtools showconfig test-system-compiler \
181         test-system-linker tinderbox toolchain \
182         toolchains universe universe-toolchain world worlds xdev xdev-build
183
184 .ORDER: buildworld installworld
185 .ORDER: buildworld distrib-dirs
186 .ORDER: buildworld distribution
187 .ORDER: buildworld distribute
188 .ORDER: buildworld distributeworld
189 .ORDER: buildworld buildkernel
190 .ORDER: distrib-dirs distribute
191 .ORDER: distrib-dirs distributeworld
192 .ORDER: distrib-dirs installworld
193 .ORDER: distribution distribute
194 .ORDER: distributeworld distribute
195 .ORDER: distributeworld distribution
196 .ORDER: installworld distribute
197 .ORDER: installworld distribution
198 .ORDER: installworld installkernel
199 .ORDER: buildkernel installkernel
200 .ORDER: buildkernel installkernel.debug
201 .ORDER: buildkernel reinstallkernel
202 .ORDER: buildkernel reinstallkernel.debug
203
204 PATH=   /sbin:/bin:/usr/sbin:/usr/bin
205 MAKEOBJDIRPREFIX?=      /usr/obj
206 _MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} MK_AUTO_OBJ=no \
207     ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
208     SRCCONF=${SRCCONF} SRC_ENV_CONF= \
209     -f /dev/null -V MAKEOBJDIRPREFIX dummy
210 .if !empty(_MAKEOBJDIRPREFIX)
211 .error MAKEOBJDIRPREFIX can only be set in environment or src-env.conf(5),\
212     not as a global (in make.conf(5) or src.conf(5)) or command-line variable.
213 .endif
214
215 # We often need to use the tree's version of make to build it.
216 # Choices add to complexity though.
217 # We cannot blindly use a make which may not be the one we want
218 # so be explicit - until all choice is removed.
219 WANT_MAKE=      bmake
220 .if !empty(.MAKE.MODE:Mmeta)
221 # 20160604 - support missing-meta,missing-filemon and performance improvements
222 WANT_MAKE_VERSION= 20160604
223 .else
224 # 20160220 - support .dinclude for FAST_DEPEND.
225 WANT_MAKE_VERSION= 20160220
226 .endif
227 MYMAKE=         ${OBJROOT}make.${MACHINE}/${WANT_MAKE}
228 .if defined(.PARSEDIR)
229 HAVE_MAKE=      bmake
230 .else
231 HAVE_MAKE=      fmake
232 .endif
233 .if defined(ALWAYS_BOOTSTRAP_MAKE) || \
234     ${HAVE_MAKE} != ${WANT_MAKE} || \
235     (defined(WANT_MAKE_VERSION) && ${MAKE_VERSION} < ${WANT_MAKE_VERSION})
236 NEED_MAKE_UPGRADE= t
237 .endif
238 .if exists(${MYMAKE})
239 SUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
240 .elif defined(NEED_MAKE_UPGRADE)
241 # It may not exist yet but we may cause it to.
242 # In the case of fmake, upgrade_checks may cause a newer version to be built.
243 SUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
244         -m ${.CURDIR}/share/mk
245 .else
246 SUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
247 .endif
248
249 _MAKE=  PATH=${PATH} MAKE_CMD="${MAKE}" ${SUB_MAKE} -f Makefile.inc1 \
250         TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH} ${_MAKEARGS}
251
252 .if defined(MK_META_MODE) && ${MK_META_MODE} == "yes"
253 # Only allow meta mode for the whitelisted targets.  See META_TGT_WHITELIST
254 # above.  If overridden as a make argument then don't bother trying to
255 # disable it.
256 .if empty(.MAKEOVERRIDES:MMK_META_MODE)
257 .for _tgt in ${META_TGT_WHITELIST}
258 .if make(${_tgt})
259 _CAN_USE_META_MODE?= yes
260 .endif
261 .endfor
262 .if !defined(_CAN_USE_META_MODE)
263 _MAKE+= MK_META_MODE=no
264 MK_META_MODE= no
265 .if defined(.PARSEDIR)
266 .unexport META_MODE
267 .endif
268 .endif  # !defined(_CAN_USE_META_MODE)
269 .endif  # empty(.MAKEOVERRIDES:MMK_META_MODE)
270
271 .if ${MK_META_MODE} == "yes"
272 .if !exists(/dev/filemon) && !defined(NO_FILEMON) && !make(showconfig)
273 # Require filemon be loaded to provide a working incremental build
274 .error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded. \
275     ${.newline}ERROR: WITH_META_MODE is enabled but requires filemon for an incremental build. \
276     ${.newline}ERROR: 'kldload filemon' or pass -DNO_FILEMON to suppress this error.
277 .endif  # !exists(/dev/filemon) && !defined(NO_FILEMON)
278 .endif  # ${MK_META_MODE} == yes
279 .endif  # defined(MK_META_MODE) && ${MK_META_MODE} == yes
280
281 # Guess target architecture from target type, and vice versa, based on
282 # historic FreeBSD practice of tending to have TARGET == TARGET_ARCH
283 # expanding to TARGET == TARGET_CPUARCH in recent times, with known
284 # exceptions.
285 .if !defined(TARGET_ARCH) && defined(TARGET)
286 # T->TA mapping is usually TARGET with arm64 the odd man out
287 _TARGET_ARCH=   ${TARGET:S/arm64/aarch64/:S/riscv/riscv64/}
288 .elif !defined(TARGET) && defined(TARGET_ARCH) && \
289     ${TARGET_ARCH} != ${MACHINE_ARCH}
290 # TA->T mapping is accidentally CPUARCH with aarch64 the odd man out
291 _TARGET=        ${TARGET_ARCH:${__TO_CPUARCH}:C/aarch64/arm64/}
292 .endif
293 .if defined(TARGET) && !defined(_TARGET)
294 _TARGET=${TARGET}
295 .endif
296 .if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
297 _TARGET_ARCH=${TARGET_ARCH}
298 .endif
299 # for historical compatibility for xdev targets
300 .if defined(XDEV)
301 _TARGET=        ${XDEV}
302 .endif
303 .if defined(XDEV_ARCH)
304 _TARGET_ARCH=   ${XDEV_ARCH}
305 .endif
306 # Some targets require a set TARGET/TARGET_ARCH, check before the default
307 # MACHINE and after the compatibility handling.
308 .if !defined(_TARGET) || !defined(_TARGET_ARCH)
309 ${XTGTS}: _assert_target
310 .endif
311 # Otherwise, default to current machine type and architecture.
312 _TARGET?=       ${MACHINE}
313 _TARGET_ARCH?=  ${MACHINE_ARCH}
314
315 .if make(native-xtools*)
316 NXB_TARGET:=            ${_TARGET}
317 NXB_TARGET_ARCH:=       ${_TARGET_ARCH}
318 _TARGET=                ${MACHINE}
319 _TARGET_ARCH=           ${MACHINE_ARCH}
320 _MAKE+=                 NXB_TARGET=${NXB_TARGET} \
321                         NXB_TARGET_ARCH=${NXB_TARGET_ARCH}
322 .endif
323
324 .if make(print-dir)
325 .SILENT:
326 .endif
327
328 _assert_target: .PHONY .MAKE
329 .for _tgt in ${XTGTS}
330 .if make(${_tgt})
331         @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${_tgt}\" target"
332         @false
333 .endif
334 .endfor
335
336 #
337 # Make sure we have an up-to-date make(1). Only world and buildworld
338 # should do this as those are the initial targets used for upgrades.
339 # The user can define ALWAYS_CHECK_MAKE to have this check performed
340 # for all targets.
341 #
342 .if defined(ALWAYS_CHECK_MAKE) || !defined(.PARSEDIR)
343 ${TGTS}: upgrade_checks
344 .else
345 buildworld: upgrade_checks
346 .endif
347
348 #
349 # Handle the user-driven targets, using the source relative mk files.
350 #
351
352 tinderbox toolchains kernel-toolchains: .MAKE
353 ${TGTS}: .PHONY .MAKE
354         ${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
355
356 # The historic default "all" target creates files which may cause stale
357 # or (in the cross build case) unlinkable results. Fail with an error
358 # when no target is given. The users can explicitly specify "all"
359 # if they want the historic behavior.
360 .MAIN:  _guard
361
362 _guard: .PHONY
363         @echo
364         @echo "Explicit target required.  Likely \"${SUBDIR_OVERRIDE:Dall:Ubuildworld}\" is wanted.  See build(7)."
365         @echo
366         @false
367
368 STARTTIME!= LC_ALL=C date
369 CHECK_TIME!= cmp=`mktemp`; find ${.CURDIR}/sys/sys/param.h -newer "$$cmp" && rm "$$cmp"; echo
370 .if !empty(CHECK_TIME)
371 .error check your date/time: ${STARTTIME}
372 .endif
373
374 .if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
375 #
376 # world
377 #
378 # Attempt to rebuild and reinstall everything. This target is not to be
379 # used for upgrading an existing FreeBSD system, because the kernel is
380 # not included. One can argue that this target doesn't build everything
381 # then.
382 #
383 world: upgrade_checks .PHONY
384         @echo "--------------------------------------------------------------"
385         @echo ">>> make world started on ${STARTTIME}"
386         @echo "--------------------------------------------------------------"
387 .if target(pre-world)
388         @echo
389         @echo "--------------------------------------------------------------"
390         @echo ">>> Making 'pre-world' target"
391         @echo "--------------------------------------------------------------"
392         ${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
393 .endif
394         ${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
395         ${_+_}@cd ${.CURDIR}; ${_MAKE} installworld MK_META_MODE=no
396 .if target(post-world)
397         @echo
398         @echo "--------------------------------------------------------------"
399         @echo ">>> Making 'post-world' target"
400         @echo "--------------------------------------------------------------"
401         ${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
402 .endif
403         @echo
404         @echo "--------------------------------------------------------------"
405         @echo ">>> make world completed on `LC_ALL=C date`"
406         @echo "                   (started ${STARTTIME})"
407         @echo "--------------------------------------------------------------"
408 .else
409 world: .PHONY
410         @echo "WARNING: make world will overwrite your existing FreeBSD"
411         @echo "installation without also building and installing a new"
412         @echo "kernel.  This can be dangerous.  Please read the handbook,"
413         @echo "'Rebuilding world', for how to upgrade your system."
414         @echo "Define DESTDIR to where you want to install FreeBSD,"
415         @echo "including /, to override this warning and proceed as usual."
416         @echo ""
417         @echo "Bailing out now..."
418         @false
419 .endif
420
421 #
422 # kernel
423 #
424 # Short hand for `make buildkernel installkernel'
425 #
426 kernel: buildkernel installkernel .PHONY
427
428 #
429 # Perform a few tests to determine if the installed tools are adequate
430 # for building the world.
431 #
432 upgrade_checks: .PHONY
433 .if defined(NEED_MAKE_UPGRADE)
434         @${_+_}(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
435 .endif
436
437 #
438 # Upgrade make(1) to the current version using the installed
439 # headers, libraries and tools.  Also, allow the location of
440 # the system bsdmake-like utility to be overridden.
441 #
442 MMAKEENV=       \
443                 DESTDIR= \
444                 INSTALL="sh ${.CURDIR}/tools/install.sh"
445 MMAKE=          ${MMAKEENV} ${MAKE} \
446                 OBJTOP=${MYMAKE:H}/obj \
447                 OBJROOT='$${OBJTOP}/' \
448                 MAKEOBJDIRPREFIX= \
449                 MAN= -DNO_SHARED \
450                 -DNO_CPU_CFLAGS -DNO_WERROR \
451                 -DNO_SUBDIR \
452                 DESTDIR= PROGNAME=${MYMAKE:T}
453
454 bmake: .PHONY
455         @echo
456         @echo "--------------------------------------------------------------"
457         @echo ">>> Building an up-to-date ${.TARGET}(1)"
458         @echo "--------------------------------------------------------------"
459         ${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
460                 ${MMAKE} obj; \
461                 ${MMAKE} depend; \
462                 ${MMAKE} all; \
463                 ${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR=
464
465 regress: .PHONY
466         @echo "'make regress' has been renamed 'make check'" | /usr/bin/fmt
467         @false
468
469 tinderbox toolchains kernel-toolchains kernels worlds: upgrade_checks
470
471 tinderbox: .PHONY
472         @cd ${.CURDIR}; ${SUB_MAKE} DOING_TINDERBOX=YES universe
473
474 toolchains: .PHONY
475         @cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
476
477 kernel-toolchains: .PHONY
478         @cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
479
480 kernels: .PHONY
481         @cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=buildkernel universe
482
483 worlds: .PHONY
484         @cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=buildworld universe
485
486 #
487 # universe
488 #
489 # Attempt to rebuild *everything* for all supported architectures,
490 # with a reasonable chance of success, regardless of how old your
491 # existing system is.
492 #
493 .if make(universe) || make(universe_kernels) || make(tinderbox) || \
494     make(targets) || make(universe-toolchain)
495 TARGETS?=amd64 arm arm64 i386 mips powerpc riscv sparc64
496 _UNIVERSE_TARGETS=      ${TARGETS}
497 TARGET_ARCHES_arm?=     arm armv6 armv7
498 TARGET_ARCHES_arm64?=   aarch64
499 TARGET_ARCHES_mips?=    mipsel mips mips64el mips64 mipsn32 mipselhf mipshf mips64elhf mips64hf
500 TARGET_ARCHES_powerpc?= powerpc powerpc64 powerpcspe
501 TARGET_ARCHES_riscv?=   riscv64 riscv64sf
502 .for target in ${TARGETS}
503 TARGET_ARCHES_${target}?= ${target}
504 .endfor
505
506 .if defined(UNIVERSE_TARGET)
507 MAKE_JUST_WORLDS=       YES
508 .else
509 UNIVERSE_TARGET?=       buildworld
510 .endif
511 KERNSRCDIR?=            ${.CURDIR}/sys
512
513 targets:        .PHONY
514         @echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
515 .for target in ${TARGETS}
516 .for target_arch in ${TARGET_ARCHES_${target}}
517         @echo "    ${target}/${target_arch}"
518 .endfor
519 .endfor
520
521 .if defined(DOING_TINDERBOX)
522 FAILFILE=${.CURDIR}/_.tinderbox.failed
523 MAKEFAIL=tee -a ${FAILFILE}
524 .else
525 MAKEFAIL=cat
526 .endif
527
528 universe_prologue:  upgrade_checks
529 universe: universe_prologue
530 universe_prologue: .PHONY
531         @echo "--------------------------------------------------------------"
532         @echo ">>> make universe started on ${STARTTIME}"
533         @echo "--------------------------------------------------------------"
534 .if defined(DOING_TINDERBOX)
535         @rm -f ${FAILFILE}
536 .endif
537
538 universe-toolchain: .PHONY universe_prologue
539         @echo "--------------------------------------------------------------"
540         @echo "> Toolchain bootstrap started on `LC_ALL=C date`"
541         @echo "--------------------------------------------------------------"
542         ${_+_}@cd ${.CURDIR}; \
543             env PATH=${PATH} ${SUB_MAKE} ${JFLAG} kernel-toolchain \
544             TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH} \
545             OBJTOP="${HOST_OBJTOP}" \
546             WITHOUT_SYSTEM_COMPILER=yes \
547             WITHOUT_SYSTEM_LINKER=yes \
548             TOOLS_PREFIX_UNDEF= \
549             kernel-toolchain \
550             MK_LLVM_TARGET_ALL=yes \
551             > _.${.TARGET} 2>&1 || \
552             (echo "${.TARGET} failed," \
553             "check _.${.TARGET} for details" | \
554             ${MAKEFAIL}; false)
555         @if [ ! -e "${HOST_OBJTOP}/tmp/usr/bin/cc" ]; then \
556             echo "Missing host compiler at ${HOST_OBJTOP}/tmp/usr/bin/cc?" >&2; \
557             false; \
558         fi
559         @if [ ! -e "${HOST_OBJTOP}/tmp/usr/bin/ld" ]; then \
560             echo "Missing host linker at ${HOST_OBJTOP}/tmp/usr/bin/ld?" >&2; \
561             false; \
562         fi
563         @echo "--------------------------------------------------------------"
564         @echo "> Toolchain bootstrap completed on `LC_ALL=C date`"
565         @echo "--------------------------------------------------------------"
566
567 .for target in ${_UNIVERSE_TARGETS}
568 universe: universe_${target}
569 universe_epilogue: universe_${target}
570 universe_${target}: universe_${target}_prologue .PHONY
571 universe_${target}_prologue: universe_prologue .PHONY
572         @echo ">> ${target} started on `LC_ALL=C date`"
573 universe_${target}_worlds: .PHONY
574
575 .if !make(targets) && !make(universe-toolchain)
576 .for target_arch in ${TARGET_ARCHES_${target}}
577 .if !defined(_need_clang_${target}_${target_arch})
578 _need_clang_${target}_${target_arch} != \
579         env TARGET=${target} TARGET_ARCH=${target_arch} \
580         ${SUB_MAKE} -C ${.CURDIR} -f Makefile.inc1 test-system-compiler \
581             ${MAKE_PARAMS_${target}} -V MK_CLANG_BOOTSTRAP 2>/dev/null || \
582             echo unknown
583 .export _need_clang_${target}_${target_arch}
584 .endif
585 .if !defined(_need_lld_${target}_${target_arch})
586 _need_lld_${target}_${target_arch} != \
587         env TARGET=${target} TARGET_ARCH=${target_arch} \
588         ${SUB_MAKE} -C ${.CURDIR} -f Makefile.inc1 test-system-linker \
589             ${MAKE_PARAMS_${target}} -V MK_LLD_BOOTSTRAP 2>/dev/null || \
590             echo unknown
591 .export _need_lld_${target}_${target_arch}
592 .endif
593 # Setup env for each arch to use the one clang.
594 .if defined(_need_clang_${target}_${target_arch}) && \
595     ${_need_clang_${target}_${target_arch}} == "yes"
596 # No check on existing XCC or CROSS_BINUTILS_PREFIX, etc, is needed since
597 # we use the test-system-compiler logic to determine if clang needs to be
598 # built.  It will be no from that logic if already using an external
599 # toolchain or /usr/bin/cc.
600 # XXX: Passing HOST_OBJTOP into the PATH would allow skipping legacy,
601 #      bootstrap-tools, and cross-tools.  Need to ensure each tool actually
602 #      supports all TARGETS though.
603 MAKE_PARAMS_${target}+= \
604         XCC="${HOST_OBJTOP}/tmp/usr/bin/cc" \
605         XCXX="${HOST_OBJTOP}/tmp/usr/bin/c++" \
606         XCPP="${HOST_OBJTOP}/tmp/usr/bin/cpp"
607 .endif
608 .if defined(_need_lld_${target}_${target_arch}) && \
609     ${_need_lld_${target}_${target_arch}} == "yes"
610 MAKE_PARAMS_${target}+= \
611         XLD="${HOST_OBJTOP}/tmp/usr/bin/ld"
612 .endif
613 .endfor
614 .endif  # !make(targets)
615
616 .if !defined(MAKE_JUST_KERNELS)
617 universe_${target}_done: universe_${target}_worlds .PHONY
618 .for target_arch in ${TARGET_ARCHES_${target}}
619 universe_${target}_worlds: universe_${target}_${target_arch} .PHONY
620 .if (defined(_need_clang_${target}_${target_arch}) && \
621     ${_need_clang_${target}_${target_arch}} == "yes") || \
622     (defined(_need_lld_${target}_${target_arch}) && \
623     ${_need_lld_${target}_${target_arch}} == "yes")
624 universe_${target}_${target_arch}: universe-toolchain
625 universe_${target}_prologue: universe-toolchain
626 .endif
627 universe_${target}_${target_arch}: universe_${target}_prologue .MAKE .PHONY
628         @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
629         @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
630             ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
631             TARGET=${target} \
632             TARGET_ARCH=${target_arch} \
633             ${MAKE_PARAMS_${target}} \
634             > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
635             (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
636             "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
637             ${MAKEFAIL}))
638         @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
639 .endfor
640 .endif # !MAKE_JUST_KERNELS
641
642 .if !defined(MAKE_JUST_WORLDS)
643 universe_${target}_done: universe_${target}_kernels .PHONY
644 universe_${target}_kernels: universe_${target}_worlds .PHONY
645 universe_${target}_kernels: universe_${target}_prologue .MAKE .PHONY
646         @if [ -e "${KERNSRCDIR}/${target}/conf/NOTES" ]; then \
647           (cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
648             ${SUB_MAKE} LINT \
649             > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
650             (echo "${target} 'make LINT' failed," \
651             "check _.${target}.makeLINT for details"| ${MAKEFAIL})); \
652         fi
653         @cd ${.CURDIR}; ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
654             universe_kernels
655 .endif # !MAKE_JUST_WORLDS
656
657 # Tell the user the worlds and kernels have completed
658 universe_${target}: universe_${target}_done
659 universe_${target}_done:
660         @echo ">> ${target} completed on `LC_ALL=C date`"
661 .endfor
662 .if make(universe_kernconfs) || make(universe_kernels)
663 .if !defined(TARGET)
664 TARGET!=        uname -m
665 .endif
666 universe_kernels_prologue: .PHONY
667         @echo ">> ${TARGET} kernels started on `LC_ALL=C date`"
668 universe_kernels: universe_kernconfs .PHONY
669         @echo ">> ${TARGET} kernels completed on `LC_ALL=C date`"
670 .if defined(MAKE_ALL_KERNELS)
671 _THINNER=cat
672 .elif defined(MAKE_LINT_KERNELS)
673 _THINNER=grep 'LINT' || true
674 .else
675 _THINNER=xargs grep -L "^.NO_UNIVERSE" || true
676 .endif
677 KERNCONFS!=     cd ${KERNSRCDIR}/${TARGET}/conf && \
678                 find [[:upper:][:digit:]]*[[:upper:][:digit:]] \
679                 -type f -maxdepth 0 \
680                 ! -name DEFAULTS ! -name NOTES | \
681                 ${_THINNER}
682 universe_kernconfs: universe_kernels_prologue .PHONY
683 .for kernel in ${KERNCONFS}
684 TARGET_ARCH_${kernel}!= cd ${KERNSRCDIR}/${TARGET}/conf && \
685         config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
686         grep -v WARNING: | cut -f 2
687 .if empty(TARGET_ARCH_${kernel})
688 .error "Target architecture for ${TARGET}/conf/${kernel} unknown.  config(8) likely too old."
689 .endif
690 universe_kernconfs: universe_kernconf_${TARGET}_${kernel}
691 universe_kernconf_${TARGET}_${kernel}: .MAKE
692         @echo ">> ${TARGET}.${TARGET_ARCH_${kernel}} ${kernel} kernel started on `LC_ALL=C date`"
693         @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
694             ${SUB_MAKE} ${JFLAG} buildkernel \
695             TARGET=${TARGET} \
696             TARGET_ARCH=${TARGET_ARCH_${kernel}} \
697             ${MAKE_PARAMS_${TARGET}} \
698             KERNCONF=${kernel} \
699             > _.${TARGET}.${kernel} 2>&1 || \
700             (echo "${TARGET} ${kernel} kernel failed," \
701             "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
702         @echo ">> ${TARGET}.${TARGET_ARCH_${kernel}} ${kernel} kernel completed on `LC_ALL=C date`"
703 .endfor
704 .endif  # make(universe_kernels)
705 universe: universe_epilogue
706 universe_epilogue: .PHONY
707         @echo "--------------------------------------------------------------"
708         @echo ">>> make universe completed on `LC_ALL=C date`"
709         @echo "                      (started ${STARTTIME})"
710         @echo "--------------------------------------------------------------"
711 .if defined(DOING_TINDERBOX)
712         @if [ -e ${FAILFILE} ] ; then \
713                 echo "Tinderbox failed:" ;\
714                 cat ${FAILFILE} ;\
715                 exit 1 ;\
716         fi
717 .endif
718 .endif
719
720 buildLINT: .PHONY
721         ${MAKE} -C ${.CURDIR}/sys/${_TARGET}/conf LINT
722
723 .if defined(.PARSEDIR)
724 # This makefile does not run in meta mode
725 .MAKE.MODE= normal
726 # Normally the things we run from here don't either.
727 # Using -DWITH_META_MODE
728 # we can buildworld with meta files created which are useful 
729 # for debugging, but without any of the rest of a meta mode build.
730 MK_DIRDEPS_BUILD= no
731 MK_STAGING= no
732 # tell meta.autodep.mk to not even think about updating anything.
733 UPDATE_DEPENDFILE= NO
734 .if !make(showconfig)
735 .export MK_DIRDEPS_BUILD MK_STAGING UPDATE_DEPENDFILE
736 .endif
737
738 .if make(universe)
739 # we do not want a failure of one branch abort all.
740 MAKE_JOB_ERROR_TOKEN= no
741 .export MAKE_JOB_ERROR_TOKEN
742 .endif
743 .endif # bmake
744
745 .endif                          # DIRDEPS_BUILD