Makefile revision 293342
12061Sjkh#
250479Speter# $FreeBSD: head/Makefile 293342 2016-01-07 19:37:11Z bdrewery $
32061Sjkh#
438666Sjb# The user-driven targets are:
532427Sjb#
6111131Sru# universe            - *Really* build *everything* (buildworld and
7111131Sru#                       all kernels on all architectures).
8217733Sbz# tinderbox           - Same as universe, but presents a list of failed build
9217733Sbz#                       targets and exits with an error if there were any.
1038666Sjb# buildworld          - Rebuild *everything*, including glue to help do
1138666Sjb#                       upgrades.
1238666Sjb# installworld        - Install everything built by "buildworld".
13159363Strhodes# world               - buildworld + installworld, no kernel.
1464049Salex# buildkernel         - Rebuild the kernel and the kernel-modules.
1564049Salex# installkernel       - Install the kernel and the kernel-modules.
16116679Ssimokawa# installkernel.debug
1766071Smarkm# reinstallkernel     - Reinstall the kernel and the kernel-modules.
18116679Ssimokawa# reinstallkernel.debug
1973504Sobrien# kernel              - buildkernel + installkernel.
20204661Simp# kernel-toolchain    - Builds the subset of world necessary to build a kernel
21232907Sjmallett# kernel-toolchains   - Build kernel-toolchain for all universe targets.
22158962Snetchild# doxygen             - Build API documentation of the kernel, needs doxygen.
23223148Sru# update              - Convenient way to update your source tree(s).
24169597Sdes# check-old           - List obsolete directories/files/libraries.
25169597Sdes# check-old-dirs      - List obsolete directories.
26169597Sdes# check-old-files     - List obsolete files.
27169597Sdes# check-old-libs      - List obsolete libraries.
28231821Spluknet# delete-old          - Delete obsolete directories/files.
29169597Sdes# delete-old-dirs     - Delete obsolete directories.
30169597Sdes# delete-old-files    - Delete obsolete files.
31169597Sdes# delete-old-libs     - Delete obsolete libraries.
32217815Sbz# targets             - Print a list of supported TARGET/TARGET_ARCH pairs
33217815Sbz#                       for world and kernel targets.
34218524Sjhb# toolchains          - Build a toolchain for all world and kernel targets.
35264460Sbrueffer# xdev                - xdev-build + xdev-install for the architecture
36264460Sbrueffer#                       specified with XDEV and XDEV_ARCH.
37264460Sbrueffer# xdev-build          - Build cross-development tools.
38264460Sbrueffer# xdev-install        - Install cross-development tools.
39268503Simp# xdev-links          - Create traditional links in /usr/bin for cc, etc
40270155Simp# native-xtools       - Create host binaries that produce target objects
41270155Simp#                       for use in qemu user-mode jails.
42253002Salfred# 
43253002Salfred# "quick" way to test all kernel builds:
44253002Salfred# 	_jflag=`sysctl -n hw.ncpu`
45253002Salfred# 	_jflag=$(($_jflag * 2))
46253002Salfred# 	[ $_jflag -gt 12 ] && _jflag=12
47253003Salfred# 	make universe -DMAKE_JUST_KERNELS JFLAG=-j${_jflag}
4832427Sjb#
4938666Sjb# This makefile is simple by design. The FreeBSD make automatically reads
50108451Sschweikh# the /usr/share/mk/sys.mk unless the -m argument is specified on the
5138666Sjb# command line. By keeping this makefile simple, it doesn't matter too
5238666Sjb# much how different the installed mk files are from those in the source
5338666Sjb# tree. This makefile executes a child make process, forcing it to use
5438666Sjb# the mk files from the source tree which are supposed to DTRT.
5517308Speter#
56217273Simp# Most of the user-driven targets (as listed above) are implemented in
57217294Simp# Makefile.inc1.  The exceptions are universe, tinderbox and targets.
5819175Sbde#
5996205Sjwd# If you want to build your system from source be sure that /usr/obj has
60292217Semaste# at least 6GB of diskspace available.  A complete 'universe' build requires
61292217Semaste# about 100GB of space.
6238042Sbde#
6396205Sjwd# For individuals wanting to build from the sources currently on their
6496205Sjwd# system, the simple instructions are:
6538042Sbde#
6696205Sjwd# 1.  `cd /usr/src'  (or to the directory containing your source tree).
67159363Strhodes# 2.  Define `HISTORICAL_MAKE_WORLD' variable (see README).
68159363Strhodes# 3.  `make world'
6917308Speter#
7096205Sjwd# For individuals wanting to upgrade their sources (even if only a
7196205Sjwd# delta of a few days):
7217308Speter#
73148330Snetchild#  1.  `cd /usr/src'       (or to the directory containing your source tree).
74148330Snetchild#  2.  `make buildworld'
75148330Snetchild#  3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
76148330Snetchild#  4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
77159831Sobrien#       [steps 3. & 4. can be combined by using the "kernel" target]
78148330Snetchild#  5.  `reboot'        (in single user mode: boot -s from the loader prompt).
79148330Snetchild#  6.  `mergemaster -p'
80148330Snetchild#  7.  `make installworld'
81251107Screes#  8.  `mergemaster'		(you may wish to use -i, along with -U or -F).
82251107Screes#  9.  `make delete-old'
83148330Snetchild# 10.  `reboot'
84148330Snetchild# 11.  `make delete-old-libs' (in case no 3rd party program uses them anymore)
8596205Sjwd#
8696205Sjwd# See src/UPDATING `COMMON ITEMS' for more complete information.
8796205Sjwd#
88268191Smarcel# If TARGET=machine (e.g. powerpc, sparc64, ...) is specified you can
89162147Sru# cross build world for other machine types using the buildworld target,
9098723Sdillon# and once the world is built you can cross build a kernel using the
9198723Sdillon# buildkernel target.
9298723Sdillon#
9338666Sjb# Define the user-driven targets. These are listed here in alphabetical
9438666Sjb# order, but that's not important.
9517308Speter#
96123311Speter# Targets that begin with underscore are internal targets intended for
97123311Speter# developer convenience only.  They are intentionally not documented and
98123311Speter# completely subject to change without notice.
99123311Speter#
100175833Sjhb# For more information, see the build(7) manual page.
101175833Sjhb#
102284454Simp
103290526Sbdrewery# This is included so CC is set to ccache for -V, and COMPILER_TYPE/VERSION
104290526Sbdrewery# can be cached for sub-makes.
105290526Sbdrewery.include <bsd.compiler.mk>
106290526Sbdrewery
107284454Simp# Note: we use this awkward construct to be compatible with FreeBSD's
108284454Simp# old make used in 10.0 and 9.2 and earlier.
109290816Ssjg.if defined(MK_DIRDEPS_BUILD) && ${MK_DIRDEPS_BUILD} == "yes" && !make(showconfig)
110284345Ssjg# targets/Makefile plays the role of top-level
111284345Ssjg.include "targets/Makefile"
112284345Ssjg.else
113284345Ssjg
114169597SdesTGTS=	all all-man buildenv buildenvvars buildkernel buildworld \
115169597Sdes	check-old check-old-dirs check-old-files check-old-libs \
116290626Sbdrewery	checkdpadd clean cleandepend cleandir cleanworld \
117169597Sdes	delete-old delete-old-dirs delete-old-files delete-old-libs \
118219177Snwhitehorn	depend distribute distributekernel distributekernel.debug \
119219177Snwhitehorn	distributeworld distrib-dirs distribution doxygen \
120238051Sobrien	everything hier hierarchy install installcheck installkernel \
121219177Snwhitehorn	installkernel.debug packagekernel packageworld \
122219177Snwhitehorn	reinstallkernel reinstallkernel.debug \
123158962Snetchild	installworld kernel-toolchain libraries lint maninstall \
124156840Sru	obj objlink regress rerelease showconfig tags toolchain update \
125123311Speter	_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
126137288Speter	_build-tools _cross-tools _includes _libraries _depend \
127209128Sraj	build32 builddtb distribute32 install32 xdev xdev-build xdev-install \
128289089Sbapt	xdev-links native-xtools installconfig \
129209128Sraj
130156740SruTGTS+=	${SUBDIR_TARGETS}
1312061Sjkh
13297769SruBITGTS=	files includes
13397252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
134119579SruTGTS+=	${BITGTS}
13597252Sru
13695730Sru.ORDER: buildworld installworld
13795793Sru.ORDER: buildworld distributeworld
138111617Sru.ORDER: buildworld buildkernel
13995730Sru.ORDER: buildkernel installkernel
140116679Ssimokawa.ORDER: buildkernel installkernel.debug
14195730Sru.ORDER: buildkernel reinstallkernel
142116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug
14395730Sru
144110035SruPATH=	/sbin:/bin:/usr/sbin:/usr/bin
145107516SruMAKEOBJDIRPREFIX?=	/usr/obj
146293288Sbdrewery_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
147293288Sbdrewery    ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
148293288Sbdrewery    -f /dev/null -V MAKEOBJDIRPREFIX dummy
149293288Sbdrewery.if !empty(_MAKEOBJDIRPREFIX)
150293288Sbdrewery.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
151293288Sbdrewery	(in make.conf(5)) or command-line variable.
152293288Sbdrewery.endif
153253616Ssjg
154253616Ssjg# We often need to use the tree's version of make to build it.
155253616Ssjg# Choices add to complexity though.
156253616Ssjg# We cannot blindly use a make which may not be the one we want
157253616Ssjg# so be exlicit - until all choice is removed.
158253616SsjgWANT_MAKE=	bmake
159253616SsjgMYMAKE=		${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}/${WANT_MAKE}
160253616Ssjg.if defined(.PARSEDIR)
161253616SsjgHAVE_MAKE=	bmake
162253616Ssjg.else
163253616SsjgHAVE_MAKE=	fmake
164253616Ssjg.endif
165253616Ssjg.if exists(${MYMAKE})
166253616SsjgSUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
167265423Simp.elif ${WANT_MAKE} != ${HAVE_MAKE}
168253616Ssjg# It may not exist yet but we may cause it to.
169253616Ssjg# In the case of fmake, upgrade_checks may cause a newer version to be built.
170253616SsjgSUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
171117229Sru	-m ${.CURDIR}/share/mk
172253616Ssjg.else
173253616SsjgSUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
174253616Ssjg.endif
17554324Smarcel
176253616Ssjg_MAKE=	PATH=${PATH} ${SUB_MAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
177253616Ssjg
178218130Simp# Guess machine architecture from machine type, and vice versa.
179218130Simp.if !defined(TARGET_ARCH) && defined(TARGET)
180280259Sandrew_TARGET_ARCH=	${TARGET:S/pc98/i386/:S/arm64/aarch64/}
181218130Simp.elif !defined(TARGET) && defined(TARGET_ARCH) && \
182218130Simp    ${TARGET_ARCH} != ${MACHINE_ARCH}
183292124Sbr_TARGET=		${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb|hf)?/arm/:C/aarch64/arm64/:C/powerpc64/powerpc/:C/riscv64/riscv/}
184218130Simp.endif
185218130Simp.if defined(TARGET) && !defined(_TARGET)
186218130Simp_TARGET=${TARGET}
187218130Simp.endif
188218130Simp.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
189218130Simp_TARGET_ARCH=${TARGET_ARCH}
190218130Simp.endif
191269048Simp# for historical compatibility for xdev targets
192269048Simp.if defined(XDEV)
193269048Simp_TARGET=	${XDEV}
194269048Simp.endif
195269048Simp.if defined(XDEV_ARCH)
196269048Simp_TARGET_ARCH=	${XDEV_ARCH}
197269048Simp.endif
198218130Simp# Otherwise, default to current machine type and architecture.
199218130Simp_TARGET?=	${MACHINE}
200218130Simp_TARGET_ARCH?=	${MACHINE_ARCH}
201218130Simp
20217308Speter#
203119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld
204119519Smarcel# should do this as those are the initial targets used for upgrades.
205119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed
206119519Smarcel# for all targets.
207119519Smarcel#
208293342Sbdrewery.if defined(ALWAYS_CHECK_MAKE) || !defined(.PARSEDIR)
209119579Sru${TGTS}: upgrade_checks
210119519Smarcel.else
211119519Smarcelbuildworld: upgrade_checks
212119519Smarcel.endif
213119519Smarcel
214119519Smarcel#
21538666Sjb# Handle the user-driven targets, using the source relative mk files.
21617308Speter#
217119519Smarcel
218254417Ssjgtinderbox toolchains kernel-toolchains: .MAKE
219289460Sbdrewery${TGTS}: .PHONY .MAKE
220218206Simp	${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
2212302Spaul
222265097Sbrooks# The historic default "all" target creates files which may cause stale
223265097Sbrooks# or (in the cross build case) unlinkable results. Fail with an error
224265097Sbrooks# when no target is given. The users can explicitly specify "all"
225265097Sbrooks# if they want the historic behavior.
226265097Sbrooks.MAIN:	_guard
22739206Sjkh
228289411Sbdrewery_guard: .PHONY
229265097Sbrooks	@echo
230289432Sbdrewery	@echo "Explicit target required.  Likely \"${SUBDIR_OVERRIDE:Dall:Ubuildworld}\" is wanted.  See build(7)."
231265097Sbrooks	@echo
232265097Sbrooks	@false
233265097Sbrooks
234133945SruSTARTTIME!= LC_ALL=C date
235240403SobrienCHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo
236177609Sru.if !empty(CHECK_TIME)
237177609Sru.error check your date/time: ${STARTTIME}
238177609Sru.endif
239133945Sru
240132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
24117308Speter#
24254324Smarcel# world
24354324Smarcel#
244132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be
245132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is
246132234Smarcel# not included. One can argue that this target doesn't build everything
247132234Smarcel# then.
24854324Smarcel#
24954324Smarcelworld: upgrade_checks
25054324Smarcel	@echo "--------------------------------------------------------------"
251118531Sru	@echo ">>> make world started on ${STARTTIME}"
25254324Smarcel	@echo "--------------------------------------------------------------"
25354324Smarcel.if target(pre-world)
25454324Smarcel	@echo
25554324Smarcel	@echo "--------------------------------------------------------------"
25654324Smarcel	@echo ">>> Making 'pre-world' target"
25754324Smarcel	@echo "--------------------------------------------------------------"
258133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
25954324Smarcel.endif
260133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
261133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
26254324Smarcel.if target(post-world)
26354324Smarcel	@echo
26454324Smarcel	@echo "--------------------------------------------------------------"
26554324Smarcel	@echo ">>> Making 'post-world' target"
26654324Smarcel	@echo "--------------------------------------------------------------"
267133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
26854324Smarcel.endif
26954324Smarcel	@echo
27054324Smarcel	@echo "--------------------------------------------------------------"
271118531Sru	@echo ">>> make world completed on `LC_ALL=C date`"
272118531Sru	@echo "                   (started ${STARTTIME})"
27354324Smarcel	@echo "--------------------------------------------------------------"
274132234Smarcel.else
275132234Smarcelworld:
276132234Smarcel	@echo "WARNING: make world will overwrite your existing FreeBSD"
277132234Smarcel	@echo "installation without also building and installing a new"
278132234Smarcel	@echo "kernel.  This can be dangerous.  Please read the handbook,"
279132588Skensmith	@echo "'Rebuilding world', for how to upgrade your system."
280132358Smarkm	@echo "Define DESTDIR to where you want to install FreeBSD,"
281132234Smarcel	@echo "including /, to override this warning and proceed as usual."
282132358Smarkm	@echo ""
283132234Smarcel	@echo "Bailing out now..."
284132234Smarcel	@false
285132234Smarcel.endif
28654324Smarcel
28754324Smarcel#
28895730Sru# kernel
28995730Sru#
29095730Sru# Short hand for `make buildkernel installkernel'
29195730Sru#
29295730Srukernel: buildkernel installkernel
29395730Sru
29495730Sru#
29538666Sjb# Perform a few tests to determine if the installed tools are adequate
296107374Sru# for building the world.
29717308Speter#
298253616Ssjg# Note: if we ever need to care about the version of bmake, simply testing
299253616Ssjg# MAKE_VERSION against a required version should suffice.
300253616Ssjg#
30155678Smarcelupgrade_checks:
302253616Ssjg.if ${HAVE_MAKE} != ${WANT_MAKE}
303253616Ssjg	@(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
304241298Smarcel.endif
3052061Sjkh
30617308Speter#
307107516Sru# Upgrade make(1) to the current version using the installed
308174539Simp# headers, libraries and tools.  Also, allow the location of
309174539Simp# the system bsdmake-like utility to be overridden.
31055678Smarcel#
311253616SsjgMMAKEENV=	MAKEOBJDIRPREFIX=${MYMAKE:H} \
312107516Sru		DESTDIR= \
313107516Sru		INSTALL="sh ${.CURDIR}/tools/install.sh"
314174564SimpMMAKE=		${MMAKEENV} ${MAKE} \
315265837Simp		-DNO_MAN -DNO_SHARED \
316264742Sjmmv		-DNO_CPU_CFLAGS -DNO_WERROR \
317268598Sjmmv		MK_TESTS=no \
318265827Simp		DESTDIR= PROGNAME=${MYMAKE:T}
319107516Sru
320265827Simpbmake: .PHONY
32155678Smarcel	@echo
32255678Smarcel	@echo "--------------------------------------------------------------"
323265827Simp	@echo ">>> Building an up-to-date ${.TARGET}(1)"
32455678Smarcel	@echo "--------------------------------------------------------------"
325249395Ssjg	${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
326291605Sbdrewery		${MMAKE} obj; \
327291605Sbdrewery		${MMAKE} depend; \
328291605Sbdrewery		${MMAKE} all; \
329265827Simp		${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR=
33055678Smarcel
331254417Ssjgtinderbox toolchains kernel-toolchains: upgrade_checks
332254417Ssjg
333185499Salfredtinderbox:
334291605Sbdrewery	@cd ${.CURDIR}; ${SUB_MAKE} DOING_TINDERBOX=YES universe
335185499Salfred
336218524Sjhbtoolchains:
337291605Sbdrewery	@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
338218524Sjhb
339232907Sjmallettkernel-toolchains:
340291605Sbdrewery	@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
341232907Sjmallett
34255678Smarcel#
343111131Sru# universe
344111131Sru#
345111131Sru# Attempt to rebuild *everything* for all supported architectures,
346133945Sru# with a reasonable chance of success, regardless of how old your
347111131Sru# existing system is.
348111131Sru#
349217125Simp.if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets)
350287903SbdreweryTARGETS?=amd64 arm arm64 i386 mips pc98 powerpc sparc64
351287903Sbdrewery_UNIVERSE_TARGETS=	${TARGETS}
352263660SandrewTARGET_ARCHES_arm?=	arm armeb armv6 armv6hf
353282156SemasteTARGET_ARCHES_arm64?=	aarch64
354233644SjmallettTARGET_ARCHES_mips?=	mipsel mips mips64el mips64 mipsn32
355216520SnwhitehornTARGET_ARCHES_powerpc?=	powerpc powerpc64
356216520SnwhitehornTARGET_ARCHES_pc98?=	i386
357287903Sbdrewery.for target in ${TARGETS}
358216520SnwhitehornTARGET_ARCHES_${target}?= ${target}
359216520Snwhitehorn.endfor
360168280Smarcel
361287903Sbdrewery# XXX Add arm64 to universe only if we have an external binutils installed.
362287903Sbdrewery# It does not build with the in-tree linker.
363287903Sbdrewery.if !exists(/usr/local/aarch64-freebsd/bin/ld) && empty(${TARGETS})
364287903Sbdrewery_UNIVERSE_TARGETS:= ${_UNIVERSE_TARGETS:Narm64}
365287903Sbdreweryuniverse: universe_arm64_skip
366287903Sbdreweryuniverse_epilogue: universe_arm64_skip
367287903Sbdreweryuniverse_arm64_skip: universe_prologue
368287903Sbdrewery	@echo ">> arm64 skipped - install aarch64-binutils port or package to build"
369287903Sbdrewery.endif
370287903Sbdrewery
371218524Sjhb.if defined(UNIVERSE_TARGET)
372218524SjhbMAKE_JUST_WORLDS=	YES
373218524Sjhb.else
374218524SjhbUNIVERSE_TARGET?=	buildworld
375218524Sjhb.endif
376219137SjhbKERNSRCDIR?=		${.CURDIR}/sys
377218524Sjhb
378284699Ssjgtargets:	.PHONY
379217815Sbz	@echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
380287903Sbdrewery.for target in ${TARGETS}
381217125Simp.for target_arch in ${TARGET_ARCHES_${target}}
382217125Simp	@echo "    ${target}/${target_arch}"
383217125Simp.endfor
384217125Simp.endfor
385217125Simp
386185499Salfred.if defined(DOING_TINDERBOX)
387217735SbzFAILFILE=${.CURDIR}/_.tinderbox.failed
388185499SalfredMAKEFAIL=tee -a ${FAILFILE}
389185499Salfred.else
390185499SalfredMAKEFAIL=cat
391185499Salfred.endif
392185499Salfred
393253616Ssjguniverse_prologue:  upgrade_checks
394253616Ssjguniverse: universe_prologue
395133945Sruuniverse_prologue:
396103985Sphk	@echo "--------------------------------------------------------------"
397103985Sphk	@echo ">>> make universe started on ${STARTTIME}"
398103985Sphk	@echo "--------------------------------------------------------------"
399185499Salfred.if defined(DOING_TINDERBOX)
400217754Sbz	@rm -f ${FAILFILE}
401185499Salfred.endif
402287903Sbdrewery.for target in ${_UNIVERSE_TARGETS}
403162147Sruuniverse: universe_${target}
404253616Ssjguniverse_epilogue: universe_${target}
405216520Snwhitehornuniverse_${target}: universe_${target}_prologue
406253616Ssjguniverse_${target}_prologue: universe_prologue
407216520Snwhitehorn	@echo ">> ${target} started on `LC_ALL=C date`"
408284456Sandrewuniverse_${target}_worlds:
409284456Sandrew
410179232Sjb.if !defined(MAKE_JUST_KERNELS)
411284471Sandrewuniverse_${target}_done: universe_${target}_worlds
412216520Snwhitehorn.for target_arch in ${TARGET_ARCHES_${target}}
413284456Sandrewuniverse_${target}_worlds: universe_${target}_${target_arch}
414254417Ssjguniverse_${target}_${target_arch}: universe_${target}_prologue .MAKE
415218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
416185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
417253616Ssjg	    ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
418162147Sru	    TARGET=${target} \
419216520Snwhitehorn	    TARGET_ARCH=${target_arch} \
420218524Sjhb	    > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
421218524Sjhb	    (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
422218524Sjhb	    "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
423216520Snwhitehorn	    ${MAKEFAIL}))
424218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
425216520Snwhitehorn.endfor
426284453Sandrew.endif # !MAKE_JUST_KERNELS
427284453Sandrew
428205290Sdougb.if !defined(MAKE_JUST_WORLDS)
429284457Sandrewuniverse_${target}_done: universe_${target}_kernels
430284456Sandrewuniverse_${target}_kernels: universe_${target}_worlds
431254417Ssjguniverse_${target}_kernels: universe_${target}_prologue .MAKE
432219137Sjhb.if exists(${KERNSRCDIR}/${target}/conf/NOTES)
433219137Sjhb	@(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
434253616Ssjg	    ${SUB_MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
435185499Salfred	    (echo "${target} 'make LINT' failed," \
436185499Salfred	    "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
437103985Sphk.endif
438291605Sbdrewery	@cd ${.CURDIR}; ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
439201815Sbz	    universe_kernels
440284453Sandrew.endif # !MAKE_JUST_WORLDS
441284457Sandrew
442284457Sandrew# Tell the user the worlds and kernels have completed
443284457Sandrewuniverse_${target}: universe_${target}_done
444284457Sandrewuniverse_${target}_done:
445201815Sbz	@echo ">> ${target} completed on `LC_ALL=C date`"
446201815Sbz.endfor
447201815Sbzuniverse_kernels: universe_kernconfs
448202095Sbz.if !defined(TARGET)
449202095SbzTARGET!=	uname -m
450202095Sbz.endif
451265155Simp.if defined(MAKE_ALL_KERNELS)
452265155Simp_THINNER=cat
453265155Simp.else
454265840Simp_THINNER=xargs grep -L "^.NO_UNIVERSE" || true
455265155Simp.endif
456219137SjhbKERNCONFS!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
457201815Sbz		find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \
458265155Simp		! -name DEFAULTS ! -name NOTES | \
459265155Simp		${_THINNER}
460201815Sbzuniverse_kernconfs:
461148154Sru.for kernel in ${KERNCONFS}
462219137SjhbTARGET_ARCH_${kernel}!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
463219137Sjhb	config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
464216934Simp	grep -v WARNING: | cut -f 2
465216934Simp.if empty(TARGET_ARCH_${kernel})
466216934Simp.error "Target architecture for ${TARGET}/conf/${kernel} unknown.  config(8) likely too old."
467216934Simp.endif
468216520Snwhitehornuniverse_kernconfs: universe_kernconf_${TARGET}_${kernel}
469254417Ssjguniverse_kernconf_${TARGET}_${kernel}: .MAKE
470185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
471253616Ssjg	    ${SUB_MAKE} ${JFLAG} buildkernel \
472201815Sbz	    TARGET=${TARGET} \
473216520Snwhitehorn	    TARGET_ARCH=${TARGET_ARCH_${kernel}} \
474148154Sru	    KERNCONF=${kernel} \
475201815Sbz	    > _.${TARGET}.${kernel} 2>&1 || \
476201815Sbz	    (echo "${TARGET} ${kernel} kernel failed," \
477201815Sbz	    "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
478148154Sru.endfor
479133945Sruuniverse: universe_epilogue
480133945Sruuniverse_epilogue:
481103985Sphk	@echo "--------------------------------------------------------------"
482118531Sru	@echo ">>> make universe completed on `LC_ALL=C date`"
483118531Sru	@echo "                      (started ${STARTTIME})"
484103985Sphk	@echo "--------------------------------------------------------------"
485185499Salfred.if defined(DOING_TINDERBOX)
486185499Salfred	@if [ -e ${FAILFILE} ] ; then \
487185499Salfred		echo "Tinderbox failed:" ;\
488185499Salfred		cat ${FAILFILE} ;\
489185499Salfred		exit 1 ;\
490185499Salfred	fi
491133945Sru.endif
492185499Salfred.endif
493242522Smarcel
494242522SmarcelbuildLINT:
495242522Smarcel	${MAKE} -C ${.CURDIR}/sys/${_TARGET}/conf LINT
496255286Ssjg
497284454Simp.if defined(.PARSEDIR)
498284345Ssjg# This makefile does not run in meta mode
499284345Ssjg.MAKE.MODE= normal
500284345Ssjg# Normally the things we run from here don't either.
501290816Ssjg# Using -DWITH_META_MODE
502284345Ssjg# we can buildworld with meta files created which are useful 
503284345Ssjg# for debugging, but without any of the rest of a meta mode build.
504290816SsjgMK_DIRDEPS_BUILD= no
505284345SsjgMK_STAGING= no
506284345Ssjg# tell meta.autodep.mk to not even think about updating anything.
507284345SsjgUPDATE_DEPENDFILE= NO
508285080Ssjg.if !make(showconfig)
509290816Ssjg.export MK_DIRDEPS_BUILD MK_STAGING UPDATE_DEPENDFILE
510285080Ssjg.endif
511284345Ssjg
512255286Ssjg.if make(universe)
513255286Ssjg# we do not want a failure of one branch abort all.
514255286SsjgMAKE_JOB_ERROR_TOKEN= no
515255286Ssjg.export MAKE_JOB_ERROR_TOKEN
516255286Ssjg.endif
517284454Simp.endif # bmake
518284345Ssjg
519290816Ssjg.endif				# DIRDEPS_BUILD
520