xref: /freebsd/Makefile (revision 9d5beec1)
13540f0e1SJordan K. Hubbard#
297d92980SPeter Wemm# $FreeBSD$
3cf763a57SJohn Birrell#
411fb97daSJohn Birrell# The user-driven targets are:
5cf763a57SJohn Birrell#
61f4f7670SRuslan Ermilov# universe            - *Really* build *everything* (buildworld and
71f4f7670SRuslan Ermilov#                       all kernels on all architectures).
8eee8163bSBjoern A. Zeeb# tinderbox           - Same as universe, but presents a list of failed build
9eee8163bSBjoern A. Zeeb#                       targets and exits with an error if there were any.
1011fb97daSJohn Birrell# buildworld          - Rebuild *everything*, including glue to help do
1111fb97daSJohn Birrell#                       upgrades.
1211fb97daSJohn Birrell# installworld        - Install everything built by "buildworld".
13fb55e855STom Rhodes# world               - buildworld + installworld, no kernel.
1400eb8cbdSAlexander Langer# buildkernel         - Rebuild the kernel and the kernel-modules.
1500eb8cbdSAlexander Langer# installkernel       - Install the kernel and the kernel-modules.
160147d2aaSHidetoshi Shimokawa# installkernel.debug
17737ffab7SMark Murray# reinstallkernel     - Reinstall the kernel and the kernel-modules.
180147d2aaSHidetoshi Shimokawa# reinstallkernel.debug
19bc4311beSDavid E. O'Brien# kernel              - buildkernel + installkernel.
20589fec8bSWarner Losh# kernel-toolchain    - Builds the subset of world necessary to build a kernel
213e95821fSJuli Mallett# kernel-toolchains   - Build kernel-toolchain for all universe targets.
22becc5c62SAlexander Leidinger# doxygen             - Build API documentation of the kernel, needs doxygen.
2369c488cdSRuslan Ermilov# update              - Convenient way to update your source tree(s).
2471b7fa12SEnji Cooper# checkworld          - Run test suite on installed world.
2532cd239bSDag-Erling Smørgrav# check-old           - List obsolete directories/files/libraries.
2632cd239bSDag-Erling Smørgrav# check-old-dirs      - List obsolete directories.
2732cd239bSDag-Erling Smørgrav# check-old-files     - List obsolete files.
2832cd239bSDag-Erling Smørgrav# check-old-libs      - List obsolete libraries.
29262eab04SSergey Kandaurov# delete-old          - Delete obsolete directories/files.
3032cd239bSDag-Erling Smørgrav# delete-old-dirs     - Delete obsolete directories.
3132cd239bSDag-Erling Smørgrav# delete-old-files    - Delete obsolete files.
3232cd239bSDag-Erling Smørgrav# delete-old-libs     - Delete obsolete libraries.
33f1d16bd8SBjoern A. Zeeb# targets             - Print a list of supported TARGET/TARGET_ARCH pairs
34f1d16bd8SBjoern A. Zeeb#                       for world and kernel targets.
354e889921SJohn Baldwin# toolchains          - Build a toolchain for all world and kernel targets.
362eabb61cSChristian Brueffer# xdev                - xdev-build + xdev-install for the architecture
37051c25dbSBryan Drewery#                       specified with TARGET and TARGET_ARCH.
382eabb61cSChristian Brueffer# xdev-build          - Build cross-development tools.
392eabb61cSChristian Brueffer# xdev-install        - Install cross-development tools.
409e488366SWarner Losh# xdev-links          - Create traditional links in /usr/bin for cc, etc
4175872267SWarner Losh# native-xtools       - Create host binaries that produce target objects
425bd47cc5SBryan Drewery#                       for use in qemu user-mode jails.  TARGET and
437441e255SBryan Drewery#                       TARGET_ARCH should be defined.
445bd47cc5SBryan Drewery# native-xtools-install
455bd47cc5SBryan Drewery#                     - Install the files to the given DESTDIR/NXTP where
465bd47cc5SBryan Drewery#                       NXTP defaults to /nxb-bin.
473540f0e1SJordan K. Hubbard#
48a7abf892SAlfred Perlstein# "quick" way to test all kernel builds:
49a7abf892SAlfred Perlstein# 	_jflag=`sysctl -n hw.ncpu`
50a7abf892SAlfred Perlstein# 	_jflag=$(($_jflag * 2))
51a7abf892SAlfred Perlstein# 	[ $_jflag -gt 12 ] && _jflag=12
520ff7433dSAlfred Perlstein# 	make universe -DMAKE_JUST_KERNELS JFLAG=-j${_jflag}
53a7abf892SAlfred Perlstein#
5411fb97daSJohn Birrell# This makefile is simple by design. The FreeBSD make automatically reads
5511fb97daSJohn Birrell# the /usr/share/mk/sys.mk unless the -m argument is specified on the
5611fb97daSJohn Birrell# command line. By keeping this makefile simple, it doesn't matter too
5711fb97daSJohn Birrell# much how different the installed mk files are from those in the source
5811fb97daSJohn Birrell# tree. This makefile executes a child make process, forcing it to use
5911fb97daSJohn Birrell# the mk files from the source tree which are supposed to DTRT.
6011fb97daSJohn Birrell#
613acc4367SWarner Losh# Most of the user-driven targets (as listed above) are implemented in
62ff34e7e3SWarner Losh# Makefile.inc1.  The exceptions are universe, tinderbox and targets.
6311fb97daSJohn Birrell#
6476fdd728SJohn W. De Boskey# If you want to build your system from source be sure that /usr/obj has
6543aa90e5SEd Maste# at least 6GB of diskspace available.  A complete 'universe' build requires
6643aa90e5SEd Maste# about 100GB of space.
6711fb97daSJohn Birrell#
6876fdd728SJohn W. De Boskey# For individuals wanting to build from the sources currently on their
6976fdd728SJohn W. De Boskey# system, the simple instructions are:
7011fb97daSJohn Birrell#
7176fdd728SJohn W. De Boskey# 1.  `cd /usr/src'  (or to the directory containing your source tree).
72fb55e855STom Rhodes# 2.  Define `HISTORICAL_MAKE_WORLD' variable (see README).
73fb55e855STom Rhodes# 3.  `make world'
7411fb97daSJohn Birrell#
7576fdd728SJohn W. De Boskey# For individuals wanting to upgrade their sources (even if only a
7676fdd728SJohn W. De Boskey# delta of a few days):
7776fdd728SJohn W. De Boskey#
7876fdd728SJohn W. De Boskey#  1.  `cd /usr/src'       (or to the directory containing your source tree).
7976fdd728SJohn W. De Boskey#  2.  `make buildworld'
8076fdd728SJohn W. De Boskey#  3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
8176fdd728SJohn W. De Boskey#  4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
822c5e89c2SDavid E. O'Brien#       [steps 3. & 4. can be combined by using the "kernel" target]
8376fdd728SJohn W. De Boskey#  5.  `reboot'        (in single user mode: boot -s from the loader prompt).
8476fdd728SJohn W. De Boskey#  6.  `mergemaster -p'
8576fdd728SJohn W. De Boskey#  7.  `make installworld'
86021a0587SChris Rees#  8.  `mergemaster'		(you may wish to use -i, along with -U or -F).
87021a0587SChris Rees#  9.  `make delete-old'
88e2a36081SAlexander Leidinger# 10.  `reboot'
89e2a36081SAlexander Leidinger# 11.  `make delete-old-libs' (in case no 3rd party program uses them anymore)
9076fdd728SJohn W. De Boskey#
9176fdd728SJohn W. De Boskey# See src/UPDATING `COMMON ITEMS' for more complete information.
9211fb97daSJohn Birrell#
9350f73640SMarcel Moolenaar# If TARGET=machine (e.g. powerpc, sparc64, ...) is specified you can
941fde59f3SRuslan Ermilov# cross build world for other machine types using the buildworld target,
95dbc3719dSMatthew Dillon# and once the world is built you can cross build a kernel using the
96dbc3719dSMatthew Dillon# buildkernel target.
97dbc3719dSMatthew Dillon#
9811fb97daSJohn Birrell# Define the user-driven targets. These are listed here in alphabetical
9911fb97daSJohn Birrell# order, but that's not important.
10011fb97daSJohn Birrell#
101ef7af95aSPeter Wemm# Targets that begin with underscore are internal targets intended for
102ef7af95aSPeter Wemm# developer convenience only.  They are intentionally not documented and
103ef7af95aSPeter Wemm# completely subject to change without notice.
104ef7af95aSPeter Wemm#
10579e19f08SJohn Baldwin# For more information, see the build(7) manual page.
10679e19f08SJohn Baldwin#
10735c9a2a9SWarner Losh
1089160419cSBryan Drewery# This is included so CC is set to ccache for -V, and COMPILER_TYPE/VERSION
109207efdb3SWarner Losh# can be cached for sub-makes. We can't do this while still running on the
110207efdb3SWarner Losh# old fmake from FreeBSD 9.x or older, so avoid including it then to avoid
111207efdb3SWarner Losh# heartburn upgrading from older systems. The need for CC is done with new
112207efdb3SWarner Losh# make later in the build, and caching COMPILER_TYPE/VERSION is only an
113207efdb3SWarner Losh# optimization. Also sinclude it to be friendlier to foreign OS hosted builds.
1149c8809d7SBryan Drewery.if ${MAKE_VERSION} >= 20140620 && defined(.PARSEDIR)
115207efdb3SWarner Losh.sinclude <bsd.compiler.mk>
1166f4b2e7fSBryan Drewery.endif
1179160419cSBryan Drewery
11835c9a2a9SWarner Losh# Note: we use this awkward construct to be compatible with FreeBSD's
11935c9a2a9SWarner Losh# old make used in 10.0 and 9.2 and earlier.
1209e2f435fSBryan Drewery.if defined(MK_DIRDEPS_BUILD) && ${MK_DIRDEPS_BUILD} == "yes" && \
1219e2f435fSBryan Drewery    !make(showconfig) && !make(print-dir)
122aa9bd11dSSimon J. Gerraty# targets/Makefile plays the role of top-level
123aa9bd11dSSimon J. Gerraty.include "targets/Makefile"
124aa9bd11dSSimon J. Gerraty.else
125aa9bd11dSSimon J. Gerraty
12632cd239bSDag-Erling SmørgravTGTS=	all all-man buildenv buildenvvars buildkernel buildworld \
12771b7fa12SEnji Cooper	check check-old check-old-dirs check-old-files check-old-libs \
12871b7fa12SEnji Cooper	checkdpadd checkworld clean cleandepend cleandir cleanworld \
129c10062b9SBryan Drewery	cleanuniverse \
13032cd239bSDag-Erling Smørgrav	delete-old delete-old-dirs delete-old-files delete-old-libs \
13199ad39c8SNathan Whitehorn	depend distribute distributekernel distributekernel.debug \
13299ad39c8SNathan Whitehorn	distributeworld distrib-dirs distribution doxygen \
133e324b4bcSDavid E. O'Brien	everything hier hierarchy install installcheck installkernel \
13499ad39c8SNathan Whitehorn	installkernel.debug packagekernel packageworld \
13599ad39c8SNathan Whitehorn	reinstallkernel reinstallkernel.debug \
1361cbb5888SWarner Losh	installworld kernel-toolchain libraries maninstall \
1376555da9cSBryan Drewery	obj objlink showconfig tags toolchain update \
138ef7af95aSPeter Wemm	_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
1391a9cc831SBryan Drewery	_build-tools _build-metadata _cross-tools _includes _libraries \
1409b8f7eafSBryan Drewery	build32 distribute32 install32 buildsoft distributesoft installsoft \
141bb52d711SWarner Losh	builddtb xdev xdev-build xdev-install \
1425bd47cc5SBryan Drewery	xdev-links native-xtools native-xtools-install stageworld stagekernel \
1435bd47cc5SBryan Drewery	stage-packages \
144275219cfSBryan Drewery	create-packages-world create-packages-kernel create-packages \
145b17f5b22SBryan Drewery	packages installconfig real-packages sign-packages package-pkg \
1469e2f435fSBryan Drewery	print-dir test-system-compiler
1473c5326bfSRafal Jaworowski
14824830684SBryan Drewery# These targets require a TARGET and TARGET_ARCH be defined.
1495bd47cc5SBryan DreweryXTGTS=	native-xtools native-xtools-install xdev xdev-build xdev-install \
1505bd47cc5SBryan Drewery	xdev-links
15124830684SBryan Drewery
1522c6fc926SBryan Drewery# XXX: r156740: This can't work since bsd.subdir.mk is not included ever.
1532c6fc926SBryan Drewery# It will only work for SUBDIR_TARGETS in make.conf.
154902f7c5bSRuslan ErmilovTGTS+=	${SUBDIR_TARGETS}
1556e59a256SMarcel Moolenaar
156af2dc868SRuslan ErmilovBITGTS=	files includes
15728d2080aSRuslan ErmilovBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
158b797df80SRuslan ErmilovTGTS+=	${BITGTS}
15928d2080aSRuslan Ermilov
1602c6fc926SBryan Drewery# Only some targets are allowed to use meta mode.  Others get it
1612c6fc926SBryan Drewery# disabled.  In some cases, such as 'install', meta mode can be dangerous
1622c6fc926SBryan Drewery# as a cookie may be used to prevent redundant installations (such as
1632c6fc926SBryan Drewery# for WORLDTMP staging).  For DESTDIR=/ we always want to install though.
1642c6fc926SBryan Drewery# For other cases, such as delete-old-libs, meta mode may break
1652c6fc926SBryan Drewery# the interactive tty prompt.  The safest route is to just whitelist
1662c6fc926SBryan Drewery# the ones that benefit from it.
1672c6fc926SBryan DreweryMETA_TGT_WHITELIST+= \
1682c6fc926SBryan Drewery	_* build32 buildfiles buildincludes buildkernel buildsoft \
169e5bf62aaSBryan Drewery	buildworld everything kernel-toolchain kernel-toolchains kernel \
170b17f5b22SBryan Drewery	kernels libraries native-xtools showconfig test-system-compiler \
171b17f5b22SBryan Drewery	tinderbox toolchain \
172e5bf62aaSBryan Drewery	toolchains universe world worlds xdev xdev-build
1732c6fc926SBryan Drewery
174d672a609SRuslan Ermilov.ORDER: buildworld installworld
17599eedcd6SBryan Drewery.ORDER: buildworld distrib-dirs
17699eedcd6SBryan Drewery.ORDER: buildworld distribution
17799eedcd6SBryan Drewery.ORDER: buildworld distribute
1788f1f55e9SRuslan Ermilov.ORDER: buildworld distributeworld
17920902bd3SRuslan Ermilov.ORDER: buildworld buildkernel
18099eedcd6SBryan Drewery.ORDER: distrib-dirs distribute
18199eedcd6SBryan Drewery.ORDER: distrib-dirs distributeworld
18299eedcd6SBryan Drewery.ORDER: distrib-dirs installworld
18399eedcd6SBryan Drewery.ORDER: distribution distribute
18499eedcd6SBryan Drewery.ORDER: distributeworld distribute
18599eedcd6SBryan Drewery.ORDER: distributeworld distribution
18699eedcd6SBryan Drewery.ORDER: installworld distribute
18783b79794SBryan Drewery.ORDER: installworld distribution
18889660f21SBryan Drewery.ORDER: installworld installkernel
189d672a609SRuslan Ermilov.ORDER: buildkernel installkernel
1900147d2aaSHidetoshi Shimokawa.ORDER: buildkernel installkernel.debug
191d672a609SRuslan Ermilov.ORDER: buildkernel reinstallkernel
1920147d2aaSHidetoshi Shimokawa.ORDER: buildkernel reinstallkernel.debug
193d672a609SRuslan Ermilov
19476499f15SRuslan ErmilovPATH=	/sbin:/bin:/usr/sbin:/usr/bin
1952e84ab94SRuslan ErmilovMAKEOBJDIRPREFIX?=	/usr/obj
196bb3f65eaSBryan Drewery_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} MK_AUTO_OBJ=no \
197f1fb2096SYaroslav Tykhiy    ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
1989d5beec1SBryan Drewery    SRCCONF=${SRCCONF} SRC_ENV_CONF= \
1990ec443a0SRuslan Ermilov    -f /dev/null -V MAKEOBJDIRPREFIX dummy
2000ec443a0SRuslan Ermilov.if !empty(_MAKEOBJDIRPREFIX)
2019d5beec1SBryan Drewery.error MAKEOBJDIRPREFIX can only be set in environment or src-env.conf(5),\
2029d5beec1SBryan Drewery    not as a global (in make.conf(5) or src.conf(5)) or command-line variable.
2030ec443a0SRuslan Ermilov.endif
2044234b977SSimon J. Gerraty
2054234b977SSimon J. Gerraty# We often need to use the tree's version of make to build it.
2064234b977SSimon J. Gerraty# Choices add to complexity though.
2074234b977SSimon J. Gerraty# We cannot blindly use a make which may not be the one we want
2084234b977SSimon J. Gerraty# so be exlicit - until all choice is removed.
2094234b977SSimon J. GerratyWANT_MAKE=	bmake
2103681768cSBryan Drewery.if !empty(.MAKE.MODE:Mmeta)
2113681768cSBryan Drewery# 20160604 - support missing-meta,missing-filemon and performance improvements
2123681768cSBryan DreweryWANT_MAKE_VERSION= 20160604
2133681768cSBryan Drewery.else
214e32a2cbeSBryan Drewery# 20160220 - support .dinclude for FAST_DEPEND.
215e32a2cbeSBryan DreweryWANT_MAKE_VERSION= 20160220
2163681768cSBryan Drewery.endif
2172f4c7d14SBryan DreweryMYMAKE=		${OBJROOT}make.${MACHINE}/${WANT_MAKE}
2184234b977SSimon J. Gerraty.if defined(.PARSEDIR)
2194234b977SSimon J. GerratyHAVE_MAKE=	bmake
2204234b977SSimon J. Gerraty.else
2214234b977SSimon J. GerratyHAVE_MAKE=	fmake
2224234b977SSimon J. Gerraty.endif
223e02aaf7bSBryan Drewery.if defined(ALWAYS_BOOTSTRAP_MAKE) || \
224e02aaf7bSBryan Drewery    ${HAVE_MAKE} != ${WANT_MAKE} || \
225bd246467SBryan Drewery    (defined(WANT_MAKE_VERSION) && ${MAKE_VERSION} < ${WANT_MAKE_VERSION})
226bd246467SBryan DreweryNEED_MAKE_UPGRADE= t
227bd246467SBryan Drewery.endif
2284234b977SSimon J. Gerraty.if exists(${MYMAKE})
2294234b977SSimon J. GerratySUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
230bd246467SBryan Drewery.elif defined(NEED_MAKE_UPGRADE)
2314234b977SSimon J. Gerraty# It may not exist yet but we may cause it to.
2324234b977SSimon J. Gerraty# In the case of fmake, upgrade_checks may cause a newer version to be built.
2334234b977SSimon J. GerratySUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
2345dc63117SRuslan Ermilov	-m ${.CURDIR}/share/mk
2354234b977SSimon J. Gerraty.else
2364234b977SSimon J. GerratySUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
2374234b977SSimon J. Gerraty.endif
2384234b977SSimon J. Gerraty
23996dd05ddSBryan Drewery_MAKE=	PATH=${PATH} MAKE_CMD="${MAKE}" ${SUB_MAKE} -f Makefile.inc1 \
240a7fa261eSBryan Drewery	TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH} ${_MAKEARGS}
241a962de47SPeter Wemm
242d8d24cecSBryan Drewery.if defined(MK_META_MODE) && ${MK_META_MODE} == "yes"
2432c6fc926SBryan Drewery# Only allow meta mode for the whitelisted targets.  See META_TGT_WHITELIST
244d8d24cecSBryan Drewery# above.  If overridden as a make argument then don't bother trying to
245d8d24cecSBryan Drewery# disable it.
246d8d24cecSBryan Drewery.if empty(.MAKEOVERRIDES:MMK_META_MODE)
2472c6fc926SBryan Drewery.for _tgt in ${META_TGT_WHITELIST}
2482c6fc926SBryan Drewery.if make(${_tgt})
2492c6fc926SBryan Drewery_CAN_USE_META_MODE?= yes
2502c6fc926SBryan Drewery.endif
2512c6fc926SBryan Drewery.endfor
2522c6fc926SBryan Drewery.if !defined(_CAN_USE_META_MODE)
253d7698c07SBryan Drewery_MAKE+=	MK_META_MODE=no
254d8d24cecSBryan DreweryMK_META_MODE= no
2559c8809d7SBryan Drewery.if defined(.PARSEDIR)
256f62610d7SBryan Drewery.unexport META_MODE
2579c8809d7SBryan Drewery.endif
258d8d24cecSBryan Drewery.endif	# !defined(_CAN_USE_META_MODE)
259d8d24cecSBryan Drewery.endif	# empty(.MAKEOVERRIDES:MMK_META_MODE)
260d8d24cecSBryan Drewery
261d8d24cecSBryan Drewery.if ${MK_META_MODE} == "yes"
262b8ef21b8SBryan Drewery.if !exists(/dev/filemon) && !defined(NO_FILEMON) && !make(showconfig)
263b8ef21b8SBryan Drewery# Require filemon be loaded to provide a working incremental build
264b8ef21b8SBryan Drewery.error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded. \
265b8ef21b8SBryan Drewery    ${.newline}ERROR: WITH_META_MODE is enabled but requires filemon for an incremental build. \
266b8ef21b8SBryan Drewery    ${.newline}ERROR: 'kldload filemon' or pass -DNO_FILEMON to suppress this error.
267b8ef21b8SBryan Drewery.endif	# !exists(/dev/filemon) && !defined(NO_FILEMON)
268d8d24cecSBryan Drewery.endif	# ${MK_META_MODE} == yes
269d8d24cecSBryan Drewery.endif	# defined(MK_META_MODE) && ${MK_META_MODE} == yes
270d7698c07SBryan Drewery
2717709b2aeSWarner Losh# Guess target architecture from target type, and vice versa, based on
2727709b2aeSWarner Losh# historic FreeBSD practice of tending to have TARGET == TARGET_ARCH
2737709b2aeSWarner Losh# expanding to TARGET == TARGET_CPUARCH in recent times, with known
2747709b2aeSWarner Losh# exceptions.
275fda074e4SWarner Losh.if !defined(TARGET_ARCH) && defined(TARGET)
2767709b2aeSWarner Losh# T->TA mapping is usually TARGET with arm64 the odd man out
277573a3ef0SWarner Losh_TARGET_ARCH=	${TARGET:S/arm64/aarch64/:S/riscv/riscv64/}
278fda074e4SWarner Losh.elif !defined(TARGET) && defined(TARGET_ARCH) && \
279fda074e4SWarner Losh    ${TARGET_ARCH} != ${MACHINE_ARCH}
2807709b2aeSWarner Losh# TA->T mapping is accidentally CPUARCH with aarch64 the odd man out
2817709b2aeSWarner Losh_TARGET=	${TARGET_ARCH:${__TO_CPUARCH}:C/aarch64/arm64/}
282fda074e4SWarner Losh.endif
283fda074e4SWarner Losh.if defined(TARGET) && !defined(_TARGET)
284fda074e4SWarner Losh_TARGET=${TARGET}
285fda074e4SWarner Losh.endif
286fda074e4SWarner Losh.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
287fda074e4SWarner Losh_TARGET_ARCH=${TARGET_ARCH}
288fda074e4SWarner Losh.endif
2890aafd404SWarner Losh# for historical compatibility for xdev targets
2900aafd404SWarner Losh.if defined(XDEV)
2910aafd404SWarner Losh_TARGET=	${XDEV}
2920aafd404SWarner Losh.endif
2930aafd404SWarner Losh.if defined(XDEV_ARCH)
2940aafd404SWarner Losh_TARGET_ARCH=	${XDEV_ARCH}
2950aafd404SWarner Losh.endif
29624830684SBryan Drewery# Some targets require a set TARGET/TARGET_ARCH, check before the default
29724830684SBryan Drewery# MACHINE and after the compatibility handling.
29824830684SBryan Drewery.if !defined(_TARGET) || !defined(_TARGET_ARCH)
29924830684SBryan Drewery${XTGTS}: _assert_target
30024830684SBryan Drewery.endif
301fda074e4SWarner Losh# Otherwise, default to current machine type and architecture.
302fda074e4SWarner Losh_TARGET?=	${MACHINE}
303fda074e4SWarner Losh_TARGET_ARCH?=	${MACHINE_ARCH}
304fda074e4SWarner Losh
3059cde684dSBryan Drewery.if make(native-xtools*)
3069cde684dSBryan DreweryNXB_TARGET:=		${_TARGET}
3079cde684dSBryan DreweryNXB_TARGET_ARCH:=	${_TARGET_ARCH}
3089cde684dSBryan Drewery_TARGET=		${MACHINE}
3099cde684dSBryan Drewery_TARGET_ARCH=		${MACHINE_ARCH}
3109cde684dSBryan Drewery_MAKE+=			NXB_TARGET=${NXB_TARGET} \
3119cde684dSBryan Drewery			NXB_TARGET_ARCH=${NXB_TARGET_ARCH}
3129cde684dSBryan Drewery.endif
3139cde684dSBryan Drewery
3149e2f435fSBryan Drewery.if make(print-dir)
3159e2f435fSBryan Drewery.SILENT:
3169e2f435fSBryan Drewery.endif
3179e2f435fSBryan Drewery
31824830684SBryan Drewery_assert_target: .PHONY .MAKE
31924830684SBryan Drewery.for _tgt in ${XTGTS}
32024830684SBryan Drewery.if make(${_tgt})
32124830684SBryan Drewery	@echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${_tgt}\" target"
32224830684SBryan Drewery	@false
32324830684SBryan Drewery.endif
32424830684SBryan Drewery.endfor
32524830684SBryan Drewery
326a962de47SPeter Wemm#
327d911f786SMarcel Moolenaar# Make sure we have an up-to-date make(1). Only world and buildworld
328d911f786SMarcel Moolenaar# should do this as those are the initial targets used for upgrades.
329d911f786SMarcel Moolenaar# The user can define ALWAYS_CHECK_MAKE to have this check performed
330d911f786SMarcel Moolenaar# for all targets.
331d911f786SMarcel Moolenaar#
33263c612deSBryan Drewery.if defined(ALWAYS_CHECK_MAKE) || !defined(.PARSEDIR)
333b797df80SRuslan Ermilov${TGTS}: upgrade_checks
334d911f786SMarcel Moolenaar.else
335d911f786SMarcel Moolenaarbuildworld: upgrade_checks
336d911f786SMarcel Moolenaar.endif
337d911f786SMarcel Moolenaar
338d911f786SMarcel Moolenaar#
33911fb97daSJohn Birrell# Handle the user-driven targets, using the source relative mk files.
340f3c4dd0dSBruce Evans#
341d911f786SMarcel Moolenaar
342a6822ce8SSimon J. Gerratytinderbox toolchains kernel-toolchains: .MAKE
34356585ab5SBryan Drewery${TGTS}: .PHONY .MAKE
344b3840844SWarner Losh	${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
345c3d9b0f0SRodney W. Grimes
3464b55d360SBrooks Davis# The historic default "all" target creates files which may cause stale
3474b55d360SBrooks Davis# or (in the cross build case) unlinkable results. Fail with an error
3484b55d360SBrooks Davis# when no target is given. The users can explicitly specify "all"
3494b55d360SBrooks Davis# if they want the historic behavior.
3504b55d360SBrooks Davis.MAIN:	_guard
3514b55d360SBrooks Davis
352824f98d3SBryan Drewery_guard: .PHONY
3534b55d360SBrooks Davis	@echo
354e07b2be5SBryan Drewery	@echo "Explicit target required.  Likely \"${SUBDIR_OVERRIDE:Dall:Ubuildworld}\" is wanted.  See build(7)."
3554b55d360SBrooks Davis	@echo
3564b55d360SBrooks Davis	@false
357ce53af53SJordan K. Hubbard
358afcf05e4SRuslan ErmilovSTARTTIME!= LC_ALL=C date
35995eff7c0SAlex RichardsonCHECK_TIME!= cmp=`mktemp`; find ${.CURDIR}/sys/sys/param.h -newer "$$cmp" && rm "$$cmp"; echo
360ec51d61fSRuslan Ermilov.if !empty(CHECK_TIME)
361ec51d61fSRuslan Ermilov.error check your date/time: ${STARTTIME}
362ec51d61fSRuslan Ermilov.endif
363d18c9906SRuslan Ermilov
364d18c9906SRuslan Ermilov.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
3656e59a256SMarcel Moolenaar#
3666e59a256SMarcel Moolenaar# world
3676e59a256SMarcel Moolenaar#
3680a945825SMarcel Moolenaar# Attempt to rebuild and reinstall everything. This target is not to be
3690a945825SMarcel Moolenaar# used for upgrading an existing FreeBSD system, because the kernel is
3700a945825SMarcel Moolenaar# not included. One can argue that this target doesn't build everything
3710a945825SMarcel Moolenaar# then.
3726e59a256SMarcel Moolenaar#
373341d14b4SBryan Dreweryworld: upgrade_checks .PHONY
3746e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
3755ab77811SRuslan Ermilov	@echo ">>> make world started on ${STARTTIME}"
3766e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
3776e59a256SMarcel Moolenaar.if target(pre-world)
3786e59a256SMarcel Moolenaar	@echo
3796e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
3806e59a256SMarcel Moolenaar	@echo ">>> Making 'pre-world' target"
3816e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
382088cf0fbSHartmut Brandt	${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
3836e59a256SMarcel Moolenaar.endif
384088cf0fbSHartmut Brandt	${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
3856597f1f8SBryan Drewery	${_+_}@cd ${.CURDIR}; ${_MAKE} installworld MK_META_MODE=no
3866e59a256SMarcel Moolenaar.if target(post-world)
3876e59a256SMarcel Moolenaar	@echo
3886e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
3896e59a256SMarcel Moolenaar	@echo ">>> Making 'post-world' target"
3906e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
391088cf0fbSHartmut Brandt	${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
3926e59a256SMarcel Moolenaar.endif
3936e59a256SMarcel Moolenaar	@echo
3946e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
3955ab77811SRuslan Ermilov	@echo ">>> make world completed on `LC_ALL=C date`"
3965ab77811SRuslan Ermilov	@echo "                   (started ${STARTTIME})"
3976e59a256SMarcel Moolenaar	@echo "--------------------------------------------------------------"
3980a945825SMarcel Moolenaar.else
399341d14b4SBryan Dreweryworld: .PHONY
4000a945825SMarcel Moolenaar	@echo "WARNING: make world will overwrite your existing FreeBSD"
4010a945825SMarcel Moolenaar	@echo "installation without also building and installing a new"
4020a945825SMarcel Moolenaar	@echo "kernel.  This can be dangerous.  Please read the handbook,"
4031f6483e4SKen Smith	@echo "'Rebuilding world', for how to upgrade your system."
404954c5b43SMark Murray	@echo "Define DESTDIR to where you want to install FreeBSD,"
4050a945825SMarcel Moolenaar	@echo "including /, to override this warning and proceed as usual."
406954c5b43SMark Murray	@echo ""
4070a945825SMarcel Moolenaar	@echo "Bailing out now..."
4080a945825SMarcel Moolenaar	@false
4090a945825SMarcel Moolenaar.endif
4106e59a256SMarcel Moolenaar
411cf94fb21SBruce Evans#
412d672a609SRuslan Ermilov# kernel
413d672a609SRuslan Ermilov#
414d672a609SRuslan Ermilov# Short hand for `make buildkernel installkernel'
415d672a609SRuslan Ermilov#
416341d14b4SBryan Drewerykernel: buildkernel installkernel .PHONY
417d672a609SRuslan Ermilov
418d672a609SRuslan Ermilov#
41911fb97daSJohn Birrell# Perform a few tests to determine if the installed tools are adequate
420113cf9e6SRuslan Ermilov# for building the world.
42111fb97daSJohn Birrell#
422341d14b4SBryan Dreweryupgrade_checks: .PHONY
423bd246467SBryan Drewery.if defined(NEED_MAKE_UPGRADE)
42412529798SBryan Drewery	@${_+_}(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
4250815243cSMarcel Moolenaar.endif
4266a8d432dSMark Murray
427a962de47SPeter Wemm#
4282e84ab94SRuslan Ermilov# Upgrade make(1) to the current version using the installed
4296029ad99SWarner Losh# headers, libraries and tools.  Also, allow the location of
4306029ad99SWarner Losh# the system bsdmake-like utility to be overridden.
431549f978aSMarcel Moolenaar#
4322f4c7d14SBryan DreweryMMAKEENV=	\
4332e84ab94SRuslan Ermilov		DESTDIR= \
4342e84ab94SRuslan Ermilov		INSTALL="sh ${.CURDIR}/tools/install.sh"
435e2be0fd0SWarner LoshMMAKE=		${MMAKEENV} ${MAKE} \
4362f4c7d14SBryan Drewery		OBJTOP=${MYMAKE:H}/obj \
4372f4c7d14SBryan Drewery		OBJROOT='$${OBJTOP}/' \
4382f4c7d14SBryan Drewery		MAKEOBJDIRPREFIX= \
439abaf3e4eSBryan Drewery		MAN= -DNO_SHARED \
4405b79f581SJulio Merino		-DNO_CPU_CFLAGS -DNO_WERROR \
441dfb898beSBryan Drewery		-DNO_SUBDIR \
4424d9b013aSWarner Losh		DESTDIR= PROGNAME=${MYMAKE:T}
4432e84ab94SRuslan Ermilov
4444d9b013aSWarner Loshbmake: .PHONY
445549f978aSMarcel Moolenaar	@echo
446549f978aSMarcel Moolenaar	@echo "--------------------------------------------------------------"
4474d9b013aSWarner Losh	@echo ">>> Building an up-to-date ${.TARGET}(1)"
448549f978aSMarcel Moolenaar	@echo "--------------------------------------------------------------"
44913c9cf4cSSimon J. Gerraty	${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
450b67490a3SBryan Drewery		${MMAKE} obj; \
451b67490a3SBryan Drewery		${MMAKE} depend; \
452b67490a3SBryan Drewery		${MMAKE} all; \
4534d9b013aSWarner Losh		${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR=
454549f978aSMarcel Moolenaar
45571b7fa12SEnji Cooperregress: .PHONY
45671b7fa12SEnji Cooper	@echo "'make regress' has been renamed 'make check'" | /usr/bin/fmt
45771b7fa12SEnji Cooper	@false
45871b7fa12SEnji Cooper
45994d8b152SIan Leporetinderbox toolchains kernel-toolchains kernels worlds: upgrade_checks
460a6822ce8SSimon J. Gerraty
461341d14b4SBryan Drewerytinderbox: .PHONY
462b67490a3SBryan Drewery	@cd ${.CURDIR}; ${SUB_MAKE} DOING_TINDERBOX=YES universe
4634e889921SJohn Baldwin
464341d14b4SBryan Drewerytoolchains: .PHONY
465b67490a3SBryan Drewery	@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
4664bb9ca57SAlfred Perlstein
467341d14b4SBryan Drewerykernel-toolchains: .PHONY
468b67490a3SBryan Drewery	@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
4693e95821fSJuli Mallett
470341d14b4SBryan Drewerykernels: .PHONY
47194d8b152SIan Lepore	@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=buildkernel universe
47294d8b152SIan Lepore
473341d14b4SBryan Dreweryworlds: .PHONY
47494d8b152SIan Lepore	@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=buildworld universe
47594d8b152SIan Lepore
476549f978aSMarcel Moolenaar#
4771f4f7670SRuslan Ermilov# universe
4781f4f7670SRuslan Ermilov#
4791f4f7670SRuslan Ermilov# Attempt to rebuild *everything* for all supported architectures,
480d18c9906SRuslan Ermilov# with a reasonable chance of success, regardless of how old your
4811f4f7670SRuslan Ermilov# existing system is.
4821f4f7670SRuslan Ermilov#
48364fe77a5SWarner Losh.if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets)
4846d7d1e1eSRuslan BukinTARGETS?=amd64 arm arm64 i386 mips powerpc riscv sparc64
485a87f765bSBryan Drewery_UNIVERSE_TARGETS=	${TARGETS}
4860b972ac9SWarner LoshTARGET_ARCHES_arm?=	arm armeb armv6 armv7
487504f34b3SEd MasteTARGET_ARCHES_arm64?=	aarch64
4885bca2215SRuslan BukinTARGET_ARCHES_mips?=	mipsel mips mips64el mips64 mipsn32 mipselhf mipshf mips64elhf mips64hf
489dc9b124dSJustin HibbitsTARGET_ARCHES_powerpc?=	powerpc powerpc64 powerpcspe
4906d7d1e1eSRuslan BukinTARGET_ARCHES_riscv?=	riscv64 riscv64sf
4918e7c4a05SNathan Whitehorn.for target in ${TARGETS}
4928e7c4a05SNathan WhitehornTARGET_ARCHES_${target}?= ${target}
4938e7c4a05SNathan Whitehorn.endfor
4941bdb3fb9SMarcel Moolenaar
4956d7d1e1eSRuslan BukinMAKE_PARAMS_riscv?=	CROSS_TOOLCHAIN=riscv64-gcc
4966d7d1e1eSRuslan Bukin
4976d2909f6SEd Maste# XXX Remove architectures only supported by external toolchain from universe
4986d2909f6SEd Maste# if required toolchain packages are missing.
4996d2909f6SEd MasteTOOLCHAINS_riscv=	riscv64
5006d2909f6SEd Maste.for target in riscv
5016d2909f6SEd Maste.if ${_UNIVERSE_TARGETS:M${target}}
5026d2909f6SEd Maste.for toolchain in ${TOOLCHAINS_${target}}
5036d2909f6SEd Maste.if !exists(/usr/local/share/toolchains/${toolchain}-gcc.mk)
5046d2909f6SEd Maste_UNIVERSE_TARGETS:= ${_UNIVERSE_TARGETS:N${target}}
5056d2909f6SEd Masteuniverse: universe_${toolchain}_skip .PHONY
5066d2909f6SEd Masteuniverse_epilogue: universe_${toolchain}_skip .PHONY
5076d2909f6SEd Masteuniverse_${toolchain}_skip: universe_prologue .PHONY
5086d2909f6SEd Maste	@echo ">> ${target} skipped - install ${toolchain}-xtoolchain-gcc port or package to build"
5096d7d1e1eSRuslan Bukin.endif
5106d2909f6SEd Maste.endfor
5116d2909f6SEd Maste.endif
5126d2909f6SEd Maste.endfor
5136d7d1e1eSRuslan Bukin
5144e889921SJohn Baldwin.if defined(UNIVERSE_TARGET)
5154e889921SJohn BaldwinMAKE_JUST_WORLDS=	YES
5164e889921SJohn Baldwin.else
5174e889921SJohn BaldwinUNIVERSE_TARGET?=	buildworld
5184e889921SJohn Baldwin.endif
519141aca1fSJohn BaldwinKERNSRCDIR?=		${.CURDIR}/sys
5204e889921SJohn Baldwin
52165faab7fSSimon J. Gerratytargets:	.PHONY
522f1d16bd8SBjoern A. Zeeb	@echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
52364fe77a5SWarner Losh.for target in ${TARGETS}
52464fe77a5SWarner Losh.for target_arch in ${TARGET_ARCHES_${target}}
52564fe77a5SWarner Losh	@echo "    ${target}/${target_arch}"
52664fe77a5SWarner Losh.endfor
52764fe77a5SWarner Losh.endfor
52864fe77a5SWarner Losh
5294bb9ca57SAlfred Perlstein.if defined(DOING_TINDERBOX)
5302933a1ceSBjoern A. ZeebFAILFILE=${.CURDIR}/_.tinderbox.failed
5314bb9ca57SAlfred PerlsteinMAKEFAIL=tee -a ${FAILFILE}
5324bb9ca57SAlfred Perlstein.else
5334bb9ca57SAlfred PerlsteinMAKEFAIL=cat
5344bb9ca57SAlfred Perlstein.endif
5354bb9ca57SAlfred Perlstein
5364234b977SSimon J. Gerratyuniverse_prologue:  upgrade_checks
5374234b977SSimon J. Gerratyuniverse: universe_prologue
538a561b106SBryan Dreweryuniverse_prologue: .PHONY
53977c1699fSPoul-Henning Kamp	@echo "--------------------------------------------------------------"
54077c1699fSPoul-Henning Kamp	@echo ">>> make universe started on ${STARTTIME}"
54177c1699fSPoul-Henning Kamp	@echo "--------------------------------------------------------------"
5424bb9ca57SAlfred Perlstein.if defined(DOING_TINDERBOX)
5431ffa3abdSBjoern A. Zeeb	@rm -f ${FAILFILE}
5444bb9ca57SAlfred Perlstein.endif
545a87f765bSBryan Drewery.for target in ${_UNIVERSE_TARGETS}
5461fde59f3SRuslan Ermilovuniverse: universe_${target}
5474234b977SSimon J. Gerratyuniverse_epilogue: universe_${target}
548341d14b4SBryan Dreweryuniverse_${target}: universe_${target}_prologue .PHONY
549341d14b4SBryan Dreweryuniverse_${target}_prologue: universe_prologue .PHONY
5501fde59f3SRuslan Ermilov	@echo ">> ${target} started on `LC_ALL=C date`"
551341d14b4SBryan Dreweryuniverse_${target}_worlds: .PHONY
552149da95cSAndrew Turner
5538e7c4a05SNathan Whitehorn.if !defined(MAKE_JUST_KERNELS)
554341d14b4SBryan Dreweryuniverse_${target}_done: universe_${target}_worlds .PHONY
5558e7c4a05SNathan Whitehorn.for target_arch in ${TARGET_ARCHES_${target}}
556341d14b4SBryan Dreweryuniverse_${target}_worlds: universe_${target}_${target_arch} .PHONY
557341d14b4SBryan Dreweryuniverse_${target}_${target_arch}: universe_${target}_prologue .MAKE .PHONY
5584e889921SJohn Baldwin	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
55933367c7fSDag-Erling Smørgrav	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
5604234b977SSimon J. Gerraty	    ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
5611fde59f3SRuslan Ermilov	    TARGET=${target} \
5628e7c4a05SNathan Whitehorn	    TARGET_ARCH=${target_arch} \
5636d7d1e1eSRuslan Bukin	    ${MAKE_PARAMS_${target}} \
5644e889921SJohn Baldwin	    > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
5654e889921SJohn Baldwin	    (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
5664e889921SJohn Baldwin	    "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
5678e7c4a05SNathan Whitehorn	    ${MAKEFAIL}))
5684e889921SJohn Baldwin	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
5698e7c4a05SNathan Whitehorn.endfor
5706cdaf31eSAndrew Turner.endif # !MAKE_JUST_KERNELS
5716cdaf31eSAndrew Turner
5723453d746SDoug Barton.if !defined(MAKE_JUST_WORLDS)
573341d14b4SBryan Dreweryuniverse_${target}_done: universe_${target}_kernels .PHONY
574341d14b4SBryan Dreweryuniverse_${target}_kernels: universe_${target}_worlds .PHONY
575341d14b4SBryan Dreweryuniverse_${target}_kernels: universe_${target}_prologue .MAKE .PHONY
576141aca1fSJohn Baldwin.if exists(${KERNSRCDIR}/${target}/conf/NOTES)
577141aca1fSJohn Baldwin	@(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
578d7a699d3SBryan Drewery	    ${SUB_MAKE} LINT \
5794556d079SBryan Drewery	    > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
5804bb9ca57SAlfred Perlstein	    (echo "${target} 'make LINT' failed," \
5814bb9ca57SAlfred Perlstein	    "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
58277c1699fSPoul-Henning Kamp.endif
583b67490a3SBryan Drewery	@cd ${.CURDIR}; ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
5849ef3e71cSBryan Drewery	    universe_kernels
5856cdaf31eSAndrew Turner.endif # !MAKE_JUST_WORLDS
5861272c4aaSAndrew Turner
5871272c4aaSAndrew Turner# Tell the user the worlds and kernels have completed
5881272c4aaSAndrew Turneruniverse_${target}: universe_${target}_done
5891272c4aaSAndrew Turneruniverse_${target}_done:
5903c55ed70SBjoern A. Zeeb	@echo ">> ${target} completed on `LC_ALL=C date`"
5913c55ed70SBjoern A. Zeeb.endfor
5921ccacaedSBryan Drewery.if make(universe_kernconfs) || make(universe_kernels)
593341d14b4SBryan Dreweryuniverse_kernels: universe_kernconfs .PHONY
5945f5bb1d1SBjoern A. Zeeb.if !defined(TARGET)
5955f5bb1d1SBjoern A. ZeebTARGET!=	uname -m
5965f5bb1d1SBjoern A. Zeeb.endif
5977621eebbSWarner Losh.if defined(MAKE_ALL_KERNELS)
5987621eebbSWarner Losh_THINNER=cat
5997e2482d6SIan Lepore.elif defined(MAKE_LINT_KERNELS)
6007e2482d6SIan Lepore_THINNER=grep 'LINT' || true
6017621eebbSWarner Losh.else
602e8bad5dcSWarner Losh_THINNER=xargs grep -L "^.NO_UNIVERSE" || true
6037621eebbSWarner Losh.endif
604141aca1fSJohn BaldwinKERNCONFS!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
605d29df4d0SBaptiste Daroussin		find [[:upper:][:digit:]]*[[:upper:][:digit:]] \
606d29df4d0SBaptiste Daroussin		-type f -maxdepth 0 \
6077621eebbSWarner Losh		! -name DEFAULTS ! -name NOTES | \
6087621eebbSWarner Losh		${_THINNER}
609341d14b4SBryan Dreweryuniverse_kernconfs: .PHONY
610dd0f3923SRuslan Ermilov.for kernel in ${KERNCONFS}
611141aca1fSJohn BaldwinTARGET_ARCH_${kernel}!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
612141aca1fSJohn Baldwin	config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
61392f64fb9SWarner Losh	grep -v WARNING: | cut -f 2
61492f64fb9SWarner Losh.if empty(TARGET_ARCH_${kernel})
61592f64fb9SWarner Losh.error "Target architecture for ${TARGET}/conf/${kernel} unknown.  config(8) likely too old."
61692f64fb9SWarner Losh.endif
6178e7c4a05SNathan Whitehornuniverse_kernconfs: universe_kernconf_${TARGET}_${kernel}
618a6822ce8SSimon J. Gerratyuniverse_kernconf_${TARGET}_${kernel}: .MAKE
61933367c7fSDag-Erling Smørgrav	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
6204234b977SSimon J. Gerraty	    ${SUB_MAKE} ${JFLAG} buildkernel \
6213c55ed70SBjoern A. Zeeb	    TARGET=${TARGET} \
6228e7c4a05SNathan Whitehorn	    TARGET_ARCH=${TARGET_ARCH_${kernel}} \
6236d7d1e1eSRuslan Bukin	    ${MAKE_PARAMS_${TARGET}} \
624dd0f3923SRuslan Ermilov	    KERNCONF=${kernel} \
6253c55ed70SBjoern A. Zeeb	    > _.${TARGET}.${kernel} 2>&1 || \
6263c55ed70SBjoern A. Zeeb	    (echo "${TARGET} ${kernel} kernel failed," \
6273c55ed70SBjoern A. Zeeb	    "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
628d18c9906SRuslan Ermilov.endfor
6291ccacaedSBryan Drewery.endif	# make(universe_kernels)
630d18c9906SRuslan Ermilovuniverse: universe_epilogue
631a561b106SBryan Dreweryuniverse_epilogue: .PHONY
63277c1699fSPoul-Henning Kamp	@echo "--------------------------------------------------------------"
6335ab77811SRuslan Ermilov	@echo ">>> make universe completed on `LC_ALL=C date`"
6345ab77811SRuslan Ermilov	@echo "                      (started ${STARTTIME})"
63577c1699fSPoul-Henning Kamp	@echo "--------------------------------------------------------------"
6364bb9ca57SAlfred Perlstein.if defined(DOING_TINDERBOX)
6374bb9ca57SAlfred Perlstein	@if [ -e ${FAILFILE} ] ; then \
6384bb9ca57SAlfred Perlstein		echo "Tinderbox failed:" ;\
6394bb9ca57SAlfred Perlstein		cat ${FAILFILE} ;\
6404bb9ca57SAlfred Perlstein		exit 1 ;\
6414bb9ca57SAlfred Perlstein	fi
6424bb9ca57SAlfred Perlstein.endif
643d18c9906SRuslan Ermilov.endif
6443c4ee57dSMarcel Moolenaar
645341d14b4SBryan DrewerybuildLINT: .PHONY
6463c4ee57dSMarcel Moolenaar	${MAKE} -C ${.CURDIR}/sys/${_TARGET}/conf LINT
6477261834dSSimon J. Gerraty
64835c9a2a9SWarner Losh.if defined(.PARSEDIR)
6491b169702SSimon J. Gerraty# This makefile does not run in meta mode
6505a968130SSimon J. Gerraty.MAKE.MODE= normal
6511b169702SSimon J. Gerraty# Normally the things we run from here don't either.
652948f327eSSimon J. Gerraty# Using -DWITH_META_MODE
6531b169702SSimon J. Gerraty# we can buildworld with meta files created which are useful
6541b169702SSimon J. Gerraty# for debugging, but without any of the rest of a meta mode build.
655948f327eSSimon J. GerratyMK_DIRDEPS_BUILD= no
6561fc3d968SSimon J. GerratyMK_STAGING= no
6571fc3d968SSimon J. Gerraty# tell meta.autodep.mk to not even think about updating anything.
6581b169702SSimon J. GerratyUPDATE_DEPENDFILE= NO
6591c9b3241SSimon J. Gerraty.if !make(showconfig)
660948f327eSSimon J. Gerraty.export MK_DIRDEPS_BUILD MK_STAGING UPDATE_DEPENDFILE
6611c9b3241SSimon J. Gerraty.endif
662d466a5b0SSimon J. Gerraty
6637261834dSSimon J. Gerraty.if make(universe)
6647261834dSSimon J. Gerraty# we do not want a failure of one branch abort all.
6657261834dSSimon J. GerratyMAKE_JOB_ERROR_TOKEN= no
6667261834dSSimon J. Gerraty.export MAKE_JOB_ERROR_TOKEN
6677261834dSSimon J. Gerraty.endif
66835c9a2a9SWarner Losh.endif # bmake
6691fc3d968SSimon J. Gerraty
670948f327eSSimon J. Gerraty.endif				# DIRDEPS_BUILD
671