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