Makefile revision 297988
12061Sjkh#
250479Speter# $FreeBSD: head/Makefile 297988 2016-04-14 19:29:35Z 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).
24295380Sngie# checkworld          - Run test suite on installed world.
25169597Sdes# check-old           - List obsolete directories/files/libraries.
26169597Sdes# check-old-dirs      - List obsolete directories.
27169597Sdes# check-old-files     - List obsolete files.
28169597Sdes# check-old-libs      - List obsolete libraries.
29231821Spluknet# delete-old          - Delete obsolete directories/files.
30169597Sdes# delete-old-dirs     - Delete obsolete directories.
31169597Sdes# delete-old-files    - Delete obsolete files.
32169597Sdes# delete-old-libs     - Delete obsolete libraries.
33217815Sbz# targets             - Print a list of supported TARGET/TARGET_ARCH pairs
34217815Sbz#                       for world and kernel targets.
35218524Sjhb# toolchains          - Build a toolchain for all world and kernel targets.
36264460Sbrueffer# xdev                - xdev-build + xdev-install for the architecture
37264460Sbrueffer#                       specified with XDEV and XDEV_ARCH.
38264460Sbrueffer# xdev-build          - Build cross-development tools.
39264460Sbrueffer# xdev-install        - Install cross-development tools.
40268503Simp# xdev-links          - Create traditional links in /usr/bin for cc, etc
41270155Simp# native-xtools       - Create host binaries that produce target objects
42270155Simp#                       for use in qemu user-mode jails.
43253002Salfred# 
44253002Salfred# "quick" way to test all kernel builds:
45253002Salfred# 	_jflag=`sysctl -n hw.ncpu`
46253002Salfred# 	_jflag=$(($_jflag * 2))
47253002Salfred# 	[ $_jflag -gt 12 ] && _jflag=12
48253003Salfred# 	make universe -DMAKE_JUST_KERNELS JFLAG=-j${_jflag}
4932427Sjb#
5038666Sjb# This makefile is simple by design. The FreeBSD make automatically reads
51108451Sschweikh# the /usr/share/mk/sys.mk unless the -m argument is specified on the
5238666Sjb# command line. By keeping this makefile simple, it doesn't matter too
5338666Sjb# much how different the installed mk files are from those in the source
5438666Sjb# tree. This makefile executes a child make process, forcing it to use
5538666Sjb# the mk files from the source tree which are supposed to DTRT.
5617308Speter#
57217273Simp# Most of the user-driven targets (as listed above) are implemented in
58217294Simp# Makefile.inc1.  The exceptions are universe, tinderbox and targets.
5919175Sbde#
6096205Sjwd# If you want to build your system from source be sure that /usr/obj has
61292217Semaste# at least 6GB of diskspace available.  A complete 'universe' build requires
62292217Semaste# about 100GB of space.
6338042Sbde#
6496205Sjwd# For individuals wanting to build from the sources currently on their
6596205Sjwd# system, the simple instructions are:
6638042Sbde#
6796205Sjwd# 1.  `cd /usr/src'  (or to the directory containing your source tree).
68159363Strhodes# 2.  Define `HISTORICAL_MAKE_WORLD' variable (see README).
69159363Strhodes# 3.  `make world'
7017308Speter#
7196205Sjwd# For individuals wanting to upgrade their sources (even if only a
7296205Sjwd# delta of a few days):
7317308Speter#
74148330Snetchild#  1.  `cd /usr/src'       (or to the directory containing your source tree).
75148330Snetchild#  2.  `make buildworld'
76148330Snetchild#  3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
77148330Snetchild#  4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
78159831Sobrien#       [steps 3. & 4. can be combined by using the "kernel" target]
79148330Snetchild#  5.  `reboot'        (in single user mode: boot -s from the loader prompt).
80148330Snetchild#  6.  `mergemaster -p'
81148330Snetchild#  7.  `make installworld'
82251107Screes#  8.  `mergemaster'		(you may wish to use -i, along with -U or -F).
83251107Screes#  9.  `make delete-old'
84148330Snetchild# 10.  `reboot'
85148330Snetchild# 11.  `make delete-old-libs' (in case no 3rd party program uses them anymore)
8696205Sjwd#
8796205Sjwd# See src/UPDATING `COMMON ITEMS' for more complete information.
8896205Sjwd#
89268191Smarcel# If TARGET=machine (e.g. powerpc, sparc64, ...) is specified you can
90162147Sru# cross build world for other machine types using the buildworld target,
9198723Sdillon# and once the world is built you can cross build a kernel using the
9298723Sdillon# buildkernel target.
9398723Sdillon#
9438666Sjb# Define the user-driven targets. These are listed here in alphabetical
9538666Sjb# order, but that's not important.
9617308Speter#
97123311Speter# Targets that begin with underscore are internal targets intended for
98123311Speter# developer convenience only.  They are intentionally not documented and
99123311Speter# completely subject to change without notice.
100123311Speter#
101175833Sjhb# For more information, see the build(7) manual page.
102175833Sjhb#
103284454Simp
104290526Sbdrewery# This is included so CC is set to ccache for -V, and COMPILER_TYPE/VERSION
105290526Sbdrewery# can be cached for sub-makes.
106290526Sbdrewery.include <bsd.compiler.mk>
107290526Sbdrewery
108284454Simp# Note: we use this awkward construct to be compatible with FreeBSD's
109284454Simp# old make used in 10.0 and 9.2 and earlier.
110290816Ssjg.if defined(MK_DIRDEPS_BUILD) && ${MK_DIRDEPS_BUILD} == "yes" && !make(showconfig)
111284345Ssjg# targets/Makefile plays the role of top-level
112284345Ssjg.include "targets/Makefile"
113284345Ssjg.else
114284345Ssjg
115169597SdesTGTS=	all all-man buildenv buildenvvars buildkernel buildworld \
116295380Sngie	check check-old check-old-dirs check-old-files check-old-libs \
117295380Sngie	checkdpadd checkworld clean cleandepend cleandir cleanworld \
118169597Sdes	delete-old delete-old-dirs delete-old-files delete-old-libs \
119219177Snwhitehorn	depend distribute distributekernel distributekernel.debug \
120219177Snwhitehorn	distributeworld distrib-dirs distribution doxygen \
121238051Sobrien	everything hier hierarchy install installcheck installkernel \
122219177Snwhitehorn	installkernel.debug packagekernel packageworld \
123219177Snwhitehorn	reinstallkernel reinstallkernel.debug \
124158962Snetchild	installworld kernel-toolchain libraries lint maninstall \
125295380Sngie	obj objlink rerelease showconfig tags toolchain update \
126123311Speter	_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
127297434Sbdrewery	_build-tools _cross-tools _includes _libraries \
128297988Sbdrewery	build32 distribute32 install32 buildsoft distributesoft installsoft \
129296779Simp	builddtb xdev xdev-build xdev-install \
130289089Sbapt	xdev-links native-xtools installconfig \
131209128Sraj
132156740SruTGTS+=	${SUBDIR_TARGETS}
1332061Sjkh
13497769SruBITGTS=	files includes
13597252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
136119579SruTGTS+=	${BITGTS}
13797252Sru
13895730Sru.ORDER: buildworld installworld
13995793Sru.ORDER: buildworld distributeworld
140111617Sru.ORDER: buildworld buildkernel
141295161Sbdrewery.ORDER: installworld distribution
142296014Sbdrewery.ORDER: installworld installkernel
14395730Sru.ORDER: buildkernel installkernel
144116679Ssimokawa.ORDER: buildkernel installkernel.debug
14595730Sru.ORDER: buildkernel reinstallkernel
146116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug
14795730Sru
148110035SruPATH=	/sbin:/bin:/usr/sbin:/usr/bin
149107516SruMAKEOBJDIRPREFIX?=	/usr/obj
150296549Sbdrewery_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} MK_AUTO_OBJ=no ${MAKE} \
151293288Sbdrewery    ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
152293288Sbdrewery    -f /dev/null -V MAKEOBJDIRPREFIX dummy
153293288Sbdrewery.if !empty(_MAKEOBJDIRPREFIX)
154293288Sbdrewery.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
155293288Sbdrewery	(in make.conf(5)) or command-line variable.
156293288Sbdrewery.endif
157253616Ssjg
158253616Ssjg# We often need to use the tree's version of make to build it.
159253616Ssjg# Choices add to complexity though.
160253616Ssjg# We cannot blindly use a make which may not be the one we want
161253616Ssjg# so be exlicit - until all choice is removed.
162253616SsjgWANT_MAKE=	bmake
163296646Sbdrewery# 20160220 - support .dinclude for FAST_DEPEND.
164296646SbdreweryWANT_MAKE_VERSION= 20160220
165253616SsjgMYMAKE=		${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}/${WANT_MAKE}
166253616Ssjg.if defined(.PARSEDIR)
167253616SsjgHAVE_MAKE=	bmake
168253616Ssjg.else
169253616SsjgHAVE_MAKE=	fmake
170253616Ssjg.endif
171253616Ssjg.if exists(${MYMAKE})
172253616SsjgSUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
173265423Simp.elif ${WANT_MAKE} != ${HAVE_MAKE}
174253616Ssjg# It may not exist yet but we may cause it to.
175253616Ssjg# In the case of fmake, upgrade_checks may cause a newer version to be built.
176253616SsjgSUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
177117229Sru	-m ${.CURDIR}/share/mk
178253616Ssjg.else
179253616SsjgSUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
180253616Ssjg.endif
18154324Smarcel
182253616Ssjg_MAKE=	PATH=${PATH} ${SUB_MAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
183253616Ssjg
184218130Simp# Guess machine architecture from machine type, and vice versa.
185218130Simp.if !defined(TARGET_ARCH) && defined(TARGET)
186280259Sandrew_TARGET_ARCH=	${TARGET:S/pc98/i386/:S/arm64/aarch64/}
187218130Simp.elif !defined(TARGET) && defined(TARGET_ARCH) && \
188218130Simp    ${TARGET_ARCH} != ${MACHINE_ARCH}
189292124Sbr_TARGET=		${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb|hf)?/arm/:C/aarch64/arm64/:C/powerpc64/powerpc/:C/riscv64/riscv/}
190218130Simp.endif
191218130Simp.if defined(TARGET) && !defined(_TARGET)
192218130Simp_TARGET=${TARGET}
193218130Simp.endif
194218130Simp.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
195218130Simp_TARGET_ARCH=${TARGET_ARCH}
196218130Simp.endif
197269048Simp# for historical compatibility for xdev targets
198269048Simp.if defined(XDEV)
199269048Simp_TARGET=	${XDEV}
200269048Simp.endif
201269048Simp.if defined(XDEV_ARCH)
202269048Simp_TARGET_ARCH=	${XDEV_ARCH}
203269048Simp.endif
204218130Simp# Otherwise, default to current machine type and architecture.
205218130Simp_TARGET?=	${MACHINE}
206218130Simp_TARGET_ARCH?=	${MACHINE_ARCH}
207218130Simp
20817308Speter#
209119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld
210119519Smarcel# should do this as those are the initial targets used for upgrades.
211119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed
212119519Smarcel# for all targets.
213119519Smarcel#
214293342Sbdrewery.if defined(ALWAYS_CHECK_MAKE) || !defined(.PARSEDIR)
215119579Sru${TGTS}: upgrade_checks
216119519Smarcel.else
217119519Smarcelbuildworld: upgrade_checks
218119519Smarcel.endif
219119519Smarcel
220119519Smarcel#
22138666Sjb# Handle the user-driven targets, using the source relative mk files.
22217308Speter#
223119519Smarcel
224254417Ssjgtinderbox toolchains kernel-toolchains: .MAKE
225289460Sbdrewery${TGTS}: .PHONY .MAKE
226218206Simp	${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
2272302Spaul
228265097Sbrooks# The historic default "all" target creates files which may cause stale
229265097Sbrooks# or (in the cross build case) unlinkable results. Fail with an error
230265097Sbrooks# when no target is given. The users can explicitly specify "all"
231265097Sbrooks# if they want the historic behavior.
232265097Sbrooks.MAIN:	_guard
23339206Sjkh
234289411Sbdrewery_guard: .PHONY
235265097Sbrooks	@echo
236289432Sbdrewery	@echo "Explicit target required.  Likely \"${SUBDIR_OVERRIDE:Dall:Ubuildworld}\" is wanted.  See build(7)."
237265097Sbrooks	@echo
238265097Sbrooks	@false
239265097Sbrooks
240133945SruSTARTTIME!= LC_ALL=C date
241240403SobrienCHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo
242177609Sru.if !empty(CHECK_TIME)
243177609Sru.error check your date/time: ${STARTTIME}
244177609Sru.endif
245133945Sru
246132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
24717308Speter#
24854324Smarcel# world
24954324Smarcel#
250132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be
251132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is
252132234Smarcel# not included. One can argue that this target doesn't build everything
253132234Smarcel# then.
25454324Smarcel#
25554324Smarcelworld: upgrade_checks
25654324Smarcel	@echo "--------------------------------------------------------------"
257118531Sru	@echo ">>> make world started on ${STARTTIME}"
25854324Smarcel	@echo "--------------------------------------------------------------"
25954324Smarcel.if target(pre-world)
26054324Smarcel	@echo
26154324Smarcel	@echo "--------------------------------------------------------------"
26254324Smarcel	@echo ">>> Making 'pre-world' target"
26354324Smarcel	@echo "--------------------------------------------------------------"
264133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
26554324Smarcel.endif
266133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
267133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
26854324Smarcel.if target(post-world)
26954324Smarcel	@echo
27054324Smarcel	@echo "--------------------------------------------------------------"
27154324Smarcel	@echo ">>> Making 'post-world' target"
27254324Smarcel	@echo "--------------------------------------------------------------"
273133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
27454324Smarcel.endif
27554324Smarcel	@echo
27654324Smarcel	@echo "--------------------------------------------------------------"
277118531Sru	@echo ">>> make world completed on `LC_ALL=C date`"
278118531Sru	@echo "                   (started ${STARTTIME})"
27954324Smarcel	@echo "--------------------------------------------------------------"
280132234Smarcel.else
281132234Smarcelworld:
282132234Smarcel	@echo "WARNING: make world will overwrite your existing FreeBSD"
283132234Smarcel	@echo "installation without also building and installing a new"
284132234Smarcel	@echo "kernel.  This can be dangerous.  Please read the handbook,"
285132588Skensmith	@echo "'Rebuilding world', for how to upgrade your system."
286132358Smarkm	@echo "Define DESTDIR to where you want to install FreeBSD,"
287132234Smarcel	@echo "including /, to override this warning and proceed as usual."
288132358Smarkm	@echo ""
289132234Smarcel	@echo "Bailing out now..."
290132234Smarcel	@false
291132234Smarcel.endif
29254324Smarcel
29354324Smarcel#
29495730Sru# kernel
29595730Sru#
29695730Sru# Short hand for `make buildkernel installkernel'
29795730Sru#
29895730Srukernel: buildkernel installkernel
29995730Sru
30095730Sru#
30138666Sjb# Perform a few tests to determine if the installed tools are adequate
302107374Sru# for building the world.
30317308Speter#
30455678Smarcelupgrade_checks:
305295980Sbdrewery.if ${HAVE_MAKE} != ${WANT_MAKE} || \
306295980Sbdrewery    (defined(WANT_MAKE_VERSION) && ${MAKE_VERSION} < ${WANT_MAKE_VERSION})
307296643Sbdrewery	@${_+_}(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
308241298Smarcel.endif
3092061Sjkh
31017308Speter#
311107516Sru# Upgrade make(1) to the current version using the installed
312174539Simp# headers, libraries and tools.  Also, allow the location of
313174539Simp# the system bsdmake-like utility to be overridden.
31455678Smarcel#
315253616SsjgMMAKEENV=	MAKEOBJDIRPREFIX=${MYMAKE:H} \
316107516Sru		DESTDIR= \
317107516Sru		INSTALL="sh ${.CURDIR}/tools/install.sh"
318174564SimpMMAKE=		${MMAKEENV} ${MAKE} \
319296675Sbdrewery		MAN= -DNO_SHARED \
320264742Sjmmv		-DNO_CPU_CFLAGS -DNO_WERROR \
321296676Sbdrewery		-DNO_SUBDIR \
322265827Simp		DESTDIR= PROGNAME=${MYMAKE:T}
323107516Sru
324265827Simpbmake: .PHONY
32555678Smarcel	@echo
32655678Smarcel	@echo "--------------------------------------------------------------"
327265827Simp	@echo ">>> Building an up-to-date ${.TARGET}(1)"
32855678Smarcel	@echo "--------------------------------------------------------------"
329249395Ssjg	${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
330291605Sbdrewery		${MMAKE} obj; \
331291605Sbdrewery		${MMAKE} depend; \
332291605Sbdrewery		${MMAKE} all; \
333265827Simp		${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR=
33455678Smarcel
335295380Sngieregress: .PHONY
336295380Sngie	@echo "'make regress' has been renamed 'make check'" | /usr/bin/fmt
337295380Sngie	@false
338295380Sngie
339295099Siantinderbox toolchains kernel-toolchains kernels worlds: upgrade_checks
340254417Ssjg
341185499Salfredtinderbox:
342291605Sbdrewery	@cd ${.CURDIR}; ${SUB_MAKE} DOING_TINDERBOX=YES universe
343185499Salfred
344218524Sjhbtoolchains:
345291605Sbdrewery	@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
346218524Sjhb
347232907Sjmallettkernel-toolchains:
348291605Sbdrewery	@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
349232907Sjmallett
350295099Siankernels:
351295099Sian	@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=buildkernel universe
352295099Sian
353295099Sianworlds:
354295099Sian	@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=buildworld universe
355295099Sian
35655678Smarcel#
357111131Sru# universe
358111131Sru#
359111131Sru# Attempt to rebuild *everything* for all supported architectures,
360133945Sru# with a reasonable chance of success, regardless of how old your
361111131Sru# existing system is.
362111131Sru#
363217125Simp.if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets)
364287903SbdreweryTARGETS?=amd64 arm arm64 i386 mips pc98 powerpc sparc64
365287903Sbdrewery_UNIVERSE_TARGETS=	${TARGETS}
366263660SandrewTARGET_ARCHES_arm?=	arm armeb armv6 armv6hf
367282156SemasteTARGET_ARCHES_arm64?=	aarch64
368233644SjmallettTARGET_ARCHES_mips?=	mipsel mips mips64el mips64 mipsn32
369216520SnwhitehornTARGET_ARCHES_powerpc?=	powerpc powerpc64
370216520SnwhitehornTARGET_ARCHES_pc98?=	i386
371287903Sbdrewery.for target in ${TARGETS}
372216520SnwhitehornTARGET_ARCHES_${target}?= ${target}
373216520Snwhitehorn.endfor
374168280Smarcel
375287903Sbdrewery# XXX Add arm64 to universe only if we have an external binutils installed.
376287903Sbdrewery# It does not build with the in-tree linker.
377287903Sbdrewery.if !exists(/usr/local/aarch64-freebsd/bin/ld) && empty(${TARGETS})
378287903Sbdrewery_UNIVERSE_TARGETS:= ${_UNIVERSE_TARGETS:Narm64}
379287903Sbdreweryuniverse: universe_arm64_skip
380287903Sbdreweryuniverse_epilogue: universe_arm64_skip
381287903Sbdreweryuniverse_arm64_skip: universe_prologue
382287903Sbdrewery	@echo ">> arm64 skipped - install aarch64-binutils port or package to build"
383287903Sbdrewery.endif
384287903Sbdrewery
385218524Sjhb.if defined(UNIVERSE_TARGET)
386218524SjhbMAKE_JUST_WORLDS=	YES
387218524Sjhb.else
388218524SjhbUNIVERSE_TARGET?=	buildworld
389218524Sjhb.endif
390219137SjhbKERNSRCDIR?=		${.CURDIR}/sys
391218524Sjhb
392284699Ssjgtargets:	.PHONY
393217815Sbz	@echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
394287903Sbdrewery.for target in ${TARGETS}
395217125Simp.for target_arch in ${TARGET_ARCHES_${target}}
396217125Simp	@echo "    ${target}/${target_arch}"
397217125Simp.endfor
398217125Simp.endfor
399217125Simp
400185499Salfred.if defined(DOING_TINDERBOX)
401217735SbzFAILFILE=${.CURDIR}/_.tinderbox.failed
402185499SalfredMAKEFAIL=tee -a ${FAILFILE}
403185499Salfred.else
404185499SalfredMAKEFAIL=cat
405185499Salfred.endif
406185499Salfred
407253616Ssjguniverse_prologue:  upgrade_checks
408253616Ssjguniverse: universe_prologue
409133945Sruuniverse_prologue:
410103985Sphk	@echo "--------------------------------------------------------------"
411103985Sphk	@echo ">>> make universe started on ${STARTTIME}"
412103985Sphk	@echo "--------------------------------------------------------------"
413185499Salfred.if defined(DOING_TINDERBOX)
414217754Sbz	@rm -f ${FAILFILE}
415185499Salfred.endif
416287903Sbdrewery.for target in ${_UNIVERSE_TARGETS}
417162147Sruuniverse: universe_${target}
418253616Ssjguniverse_epilogue: universe_${target}
419216520Snwhitehornuniverse_${target}: universe_${target}_prologue
420253616Ssjguniverse_${target}_prologue: universe_prologue
421216520Snwhitehorn	@echo ">> ${target} started on `LC_ALL=C date`"
422284456Sandrewuniverse_${target}_worlds:
423284456Sandrew
424179232Sjb.if !defined(MAKE_JUST_KERNELS)
425284471Sandrewuniverse_${target}_done: universe_${target}_worlds
426216520Snwhitehorn.for target_arch in ${TARGET_ARCHES_${target}}
427284456Sandrewuniverse_${target}_worlds: universe_${target}_${target_arch}
428254417Ssjguniverse_${target}_${target_arch}: universe_${target}_prologue .MAKE
429218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
430185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
431253616Ssjg	    ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
432162147Sru	    TARGET=${target} \
433216520Snwhitehorn	    TARGET_ARCH=${target_arch} \
434218524Sjhb	    > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
435218524Sjhb	    (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
436218524Sjhb	    "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
437216520Snwhitehorn	    ${MAKEFAIL}))
438218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
439216520Snwhitehorn.endfor
440284453Sandrew.endif # !MAKE_JUST_KERNELS
441284453Sandrew
442205290Sdougb.if !defined(MAKE_JUST_WORLDS)
443284457Sandrewuniverse_${target}_done: universe_${target}_kernels
444284456Sandrewuniverse_${target}_kernels: universe_${target}_worlds
445254417Ssjguniverse_${target}_kernels: universe_${target}_prologue .MAKE
446219137Sjhb.if exists(${KERNSRCDIR}/${target}/conf/NOTES)
447219137Sjhb	@(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
448253616Ssjg	    ${SUB_MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
449185499Salfred	    (echo "${target} 'make LINT' failed," \
450185499Salfred	    "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
451103985Sphk.endif
452291605Sbdrewery	@cd ${.CURDIR}; ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
453201815Sbz	    universe_kernels
454284453Sandrew.endif # !MAKE_JUST_WORLDS
455284457Sandrew
456284457Sandrew# Tell the user the worlds and kernels have completed
457284457Sandrewuniverse_${target}: universe_${target}_done
458284457Sandrewuniverse_${target}_done:
459201815Sbz	@echo ">> ${target} completed on `LC_ALL=C date`"
460201815Sbz.endfor
461201815Sbzuniverse_kernels: universe_kernconfs
462202095Sbz.if !defined(TARGET)
463202095SbzTARGET!=	uname -m
464202095Sbz.endif
465265155Simp.if defined(MAKE_ALL_KERNELS)
466265155Simp_THINNER=cat
467265155Simp.else
468265840Simp_THINNER=xargs grep -L "^.NO_UNIVERSE" || true
469265155Simp.endif
470219137SjhbKERNCONFS!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
471295455Sbapt		find [[:upper:][:digit:]]*[[:upper:][:digit:]] \
472295455Sbapt		-type f -maxdepth 0 \
473265155Simp		! -name DEFAULTS ! -name NOTES | \
474265155Simp		${_THINNER}
475201815Sbzuniverse_kernconfs:
476148154Sru.for kernel in ${KERNCONFS}
477219137SjhbTARGET_ARCH_${kernel}!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
478219137Sjhb	config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
479216934Simp	grep -v WARNING: | cut -f 2
480216934Simp.if empty(TARGET_ARCH_${kernel})
481216934Simp.error "Target architecture for ${TARGET}/conf/${kernel} unknown.  config(8) likely too old."
482216934Simp.endif
483216520Snwhitehornuniverse_kernconfs: universe_kernconf_${TARGET}_${kernel}
484254417Ssjguniverse_kernconf_${TARGET}_${kernel}: .MAKE
485185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
486253616Ssjg	    ${SUB_MAKE} ${JFLAG} buildkernel \
487201815Sbz	    TARGET=${TARGET} \
488216520Snwhitehorn	    TARGET_ARCH=${TARGET_ARCH_${kernel}} \
489148154Sru	    KERNCONF=${kernel} \
490201815Sbz	    > _.${TARGET}.${kernel} 2>&1 || \
491201815Sbz	    (echo "${TARGET} ${kernel} kernel failed," \
492201815Sbz	    "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
493148154Sru.endfor
494133945Sruuniverse: universe_epilogue
495133945Sruuniverse_epilogue:
496103985Sphk	@echo "--------------------------------------------------------------"
497118531Sru	@echo ">>> make universe completed on `LC_ALL=C date`"
498118531Sru	@echo "                      (started ${STARTTIME})"
499103985Sphk	@echo "--------------------------------------------------------------"
500185499Salfred.if defined(DOING_TINDERBOX)
501185499Salfred	@if [ -e ${FAILFILE} ] ; then \
502185499Salfred		echo "Tinderbox failed:" ;\
503185499Salfred		cat ${FAILFILE} ;\
504185499Salfred		exit 1 ;\
505185499Salfred	fi
506133945Sru.endif
507185499Salfred.endif
508242522Smarcel
509242522SmarcelbuildLINT:
510242522Smarcel	${MAKE} -C ${.CURDIR}/sys/${_TARGET}/conf LINT
511255286Ssjg
512284454Simp.if defined(.PARSEDIR)
513284345Ssjg# This makefile does not run in meta mode
514284345Ssjg.MAKE.MODE= normal
515284345Ssjg# Normally the things we run from here don't either.
516290816Ssjg# Using -DWITH_META_MODE
517284345Ssjg# we can buildworld with meta files created which are useful 
518284345Ssjg# for debugging, but without any of the rest of a meta mode build.
519290816SsjgMK_DIRDEPS_BUILD= no
520284345SsjgMK_STAGING= no
521284345Ssjg# tell meta.autodep.mk to not even think about updating anything.
522284345SsjgUPDATE_DEPENDFILE= NO
523285080Ssjg.if !make(showconfig)
524290816Ssjg.export MK_DIRDEPS_BUILD MK_STAGING UPDATE_DEPENDFILE
525285080Ssjg.endif
526284345Ssjg
527255286Ssjg.if make(universe)
528255286Ssjg# we do not want a failure of one branch abort all.
529255286SsjgMAKE_JOB_ERROR_TOKEN= no
530255286Ssjg.export MAKE_JOB_ERROR_TOKEN
531255286Ssjg.endif
532284454Simp.endif # bmake
533284345Ssjg
534290816Ssjg.endif				# DIRDEPS_BUILD
535