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