Makefile revision 265827
12061Sjkh#
250479Speter# $FreeBSD: head/Makefile 265827 2014-05-10 16:37:33Z imp $
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.
39253002Salfred# 
40253002Salfred# "quick" way to test all kernel builds:
41253002Salfred# 	_jflag=`sysctl -n hw.ncpu`
42253002Salfred# 	_jflag=$(($_jflag * 2))
43253002Salfred# 	[ $_jflag -gt 12 ] && _jflag=12
44253003Salfred# 	make universe -DMAKE_JUST_KERNELS JFLAG=-j${_jflag}
4532427Sjb#
4638666Sjb# This makefile is simple by design. The FreeBSD make automatically reads
47108451Sschweikh# the /usr/share/mk/sys.mk unless the -m argument is specified on the
4838666Sjb# command line. By keeping this makefile simple, it doesn't matter too
4938666Sjb# much how different the installed mk files are from those in the source
5038666Sjb# tree. This makefile executes a child make process, forcing it to use
5138666Sjb# the mk files from the source tree which are supposed to DTRT.
5217308Speter#
53217273Simp# Most of the user-driven targets (as listed above) are implemented in
54217294Simp# Makefile.inc1.  The exceptions are universe, tinderbox and targets.
5519175Sbde#
5696205Sjwd# If you want to build your system from source be sure that /usr/obj has
57217297Simp# at least 1GB of diskspace available.  A complete 'universe' build requires
58217297Simp# about 15GB of space.
5938042Sbde#
6096205Sjwd# For individuals wanting to build from the sources currently on their
6196205Sjwd# system, the simple instructions are:
6238042Sbde#
6396205Sjwd# 1.  `cd /usr/src'  (or to the directory containing your source tree).
64159363Strhodes# 2.  Define `HISTORICAL_MAKE_WORLD' variable (see README).
65159363Strhodes# 3.  `make world'
6617308Speter#
6796205Sjwd# For individuals wanting to upgrade their sources (even if only a
6896205Sjwd# delta of a few days):
6917308Speter#
70148330Snetchild#  1.  `cd /usr/src'       (or to the directory containing your source tree).
71148330Snetchild#  2.  `make buildworld'
72148330Snetchild#  3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
73148330Snetchild#  4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
74159831Sobrien#       [steps 3. & 4. can be combined by using the "kernel" target]
75148330Snetchild#  5.  `reboot'        (in single user mode: boot -s from the loader prompt).
76148330Snetchild#  6.  `mergemaster -p'
77148330Snetchild#  7.  `make installworld'
78251107Screes#  8.  `mergemaster'		(you may wish to use -i, along with -U or -F).
79251107Screes#  9.  `make delete-old'
80148330Snetchild# 10.  `reboot'
81148330Snetchild# 11.  `make delete-old-libs' (in case no 3rd party program uses them anymore)
8296205Sjwd#
8396205Sjwd# See src/UPDATING `COMMON ITEMS' for more complete information.
8496205Sjwd#
85162147Sru# If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can
86162147Sru# cross build world for other machine types using the buildworld target,
8798723Sdillon# and once the world is built you can cross build a kernel using the
8898723Sdillon# buildkernel target.
8998723Sdillon#
9038666Sjb# Define the user-driven targets. These are listed here in alphabetical
9138666Sjb# order, but that's not important.
9217308Speter#
93123311Speter# Targets that begin with underscore are internal targets intended for
94123311Speter# developer convenience only.  They are intentionally not documented and
95123311Speter# completely subject to change without notice.
96123311Speter#
97175833Sjhb# For more information, see the build(7) manual page.
98175833Sjhb#
99169597SdesTGTS=	all all-man buildenv buildenvvars buildkernel buildworld \
100169597Sdes	check-old check-old-dirs check-old-files check-old-libs \
101169597Sdes	checkdpadd clean cleandepend cleandir \
102169597Sdes	delete-old delete-old-dirs delete-old-files delete-old-libs \
103219177Snwhitehorn	depend distribute distributekernel distributekernel.debug \
104219177Snwhitehorn	distributeworld distrib-dirs distribution doxygen \
105238051Sobrien	everything hier hierarchy install installcheck installkernel \
106219177Snwhitehorn	installkernel.debug packagekernel packageworld \
107219177Snwhitehorn	reinstallkernel reinstallkernel.debug \
108158962Snetchild	installworld kernel-toolchain libraries lint maninstall \
109156840Sru	obj objlink regress rerelease showconfig tags toolchain update \
110123311Speter	_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
111137288Speter	_build-tools _cross-tools _includes _libraries _depend \
112209128Sraj	build32 builddtb distribute32 install32 xdev xdev-build xdev-install \
113209128Sraj
114156740SruTGTS+=	${SUBDIR_TARGETS}
1152061Sjkh
11697769SruBITGTS=	files includes
11797252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
118119579SruTGTS+=	${BITGTS}
11997252Sru
12095730Sru.ORDER: buildworld installworld
12195793Sru.ORDER: buildworld distributeworld
122111617Sru.ORDER: buildworld buildkernel
12395730Sru.ORDER: buildkernel installkernel
124116679Ssimokawa.ORDER: buildkernel installkernel.debug
12595730Sru.ORDER: buildkernel reinstallkernel
126116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug
12795730Sru
128110035SruPATH=	/sbin:/bin:/usr/sbin:/usr/bin
129107516SruMAKEOBJDIRPREFIX?=	/usr/obj
130138921Sru_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
131156145Syar    ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
132138921Sru    -f /dev/null -V MAKEOBJDIRPREFIX dummy
133133942Sru.if !empty(_MAKEOBJDIRPREFIX)
134133942Sru.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
135156145Syar	(in make.conf(5)) or command-line variable.
136133942Sru.endif
137253616Ssjg
138253616Ssjg# We often need to use the tree's version of make to build it.
139253616Ssjg# Choices add to complexity though.
140253616Ssjg# We cannot blindly use a make which may not be the one we want
141253616Ssjg# so be exlicit - until all choice is removed.
142253616SsjgWANT_MAKE=	bmake
143253616SsjgMYMAKE=		${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}/${WANT_MAKE}
144253616Ssjg.if defined(.PARSEDIR)
145253616SsjgHAVE_MAKE=	bmake
146253616Ssjg.else
147253616SsjgHAVE_MAKE=	fmake
148253616Ssjg.endif
149253616Ssjg.if exists(${MYMAKE})
150253616SsjgSUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
151265423Simp.elif ${WANT_MAKE} != ${HAVE_MAKE}
152253616Ssjg# It may not exist yet but we may cause it to.
153253616Ssjg# In the case of fmake, upgrade_checks may cause a newer version to be built.
154253616SsjgSUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
155117229Sru	-m ${.CURDIR}/share/mk
156253616Ssjg.else
157253616SsjgSUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
158253616Ssjg.endif
15954324Smarcel
160253616Ssjg_MAKE=	PATH=${PATH} ${SUB_MAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
161253616Ssjg
162218130Simp# Guess machine architecture from machine type, and vice versa.
163218130Simp.if !defined(TARGET_ARCH) && defined(TARGET)
164233644Sjmallett_TARGET_ARCH=	${TARGET:S/pc98/i386/}
165218130Simp.elif !defined(TARGET) && defined(TARGET_ARCH) && \
166218130Simp    ${TARGET_ARCH} != ${MACHINE_ARCH}
167263660Sandrew_TARGET=		${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb|hf)?/arm/}
168218130Simp.endif
169218130Simp.if defined(TARGET) && !defined(_TARGET)
170218130Simp_TARGET=${TARGET}
171218130Simp.endif
172218130Simp.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
173218130Simp_TARGET_ARCH=${TARGET_ARCH}
174218130Simp.endif
175218130Simp# Otherwise, default to current machine type and architecture.
176218130Simp_TARGET?=	${MACHINE}
177218130Simp_TARGET_ARCH?=	${MACHINE_ARCH}
178218130Simp
17917308Speter#
180119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld
181119519Smarcel# should do this as those are the initial targets used for upgrades.
182119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed
183119519Smarcel# for all targets.
184119519Smarcel#
185119519Smarcel.if defined(ALWAYS_CHECK_MAKE)
186119579Sru${TGTS}: upgrade_checks
187119519Smarcel.else
188119519Smarcelbuildworld: upgrade_checks
189119519Smarcel.endif
190119519Smarcel
191119519Smarcel#
192126031Sgad# This 'cleanworld' target is not included in TGTS, because it is not a
193126024Sgad# recursive target.  All of the work for it is done right here.   It is
194126024Sgad# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
195126024Sgad# created by bsd.obj.mk, except that we don't want to .include that file
196126024Sgad# in this makefile.  
197126024Sgad#
198126024Sgad# In the following, the first 'rm' in a series will usually remove all
199126024Sgad# files and directories.  If it does not, then there are probably some
200227771Sgjb# files with file flags set, so this unsets them and tries the 'rm' a
201126024Sgad# second time.  There are situations where this target will be cleaning
202126024Sgad# some directories via more than one method, but that duplication is
203227769Sgjb# needed to correctly handle all the possible situations.  Removing all
204227771Sgjb# files without file flags set in the first 'rm' instance saves time,
205227771Sgjb# because 'chflags' will need to operate on fewer files afterwards.
206126024Sgad#
207126024SgadBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
208126031Sgadcleanworld:
209126024Sgad.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
210126024Sgad.if exists(${BW_CANONICALOBJDIR}/)
211126024Sgad	-rm -rf ${BW_CANONICALOBJDIR}/*
212172744Sdelphij	-chflags -R 0 ${BW_CANONICALOBJDIR}
213126024Sgad	rm -rf ${BW_CANONICALOBJDIR}/*
214126024Sgad.endif
215126024Sgad	#   To be safe in this case, fall back to a 'make cleandir'
216133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
217126024Sgad.else
218126024Sgad	-rm -rf ${.OBJDIR}/*
219172744Sdelphij	-chflags -R 0 ${.OBJDIR}
220126024Sgad	rm -rf ${.OBJDIR}/*
221126024Sgad.endif
222125885Sgad
223125885Sgad#
22438666Sjb# Handle the user-driven targets, using the source relative mk files.
22517308Speter#
226119519Smarcel
227251750Ssjg.if empty(.MAKEFLAGS:M-n)
228251750Ssjg# skip this for -n to avoid changing previous behavior of 
229251750Ssjg# 'make -n buildworld' etc.
230251750Ssjg${TGTS}: .MAKE
231254417Ssjgtinderbox toolchains kernel-toolchains: .MAKE
232251750Ssjg.endif
233251750Ssjg
234119579Sru${TGTS}:
235218206Simp	${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
2362302Spaul
237265097Sbrooks# The historic default "all" target creates files which may cause stale
238265097Sbrooks# or (in the cross build case) unlinkable results. Fail with an error
239265097Sbrooks# when no target is given. The users can explicitly specify "all"
240265097Sbrooks# if they want the historic behavior.
241265097Sbrooks.MAIN:	_guard
24239206Sjkh
243265097Sbrooks_guard:
244265097Sbrooks	@echo
245265097Sbrooks	@echo "Explicit target required (use \"all\" for historic behavior)"
246265097Sbrooks	@echo
247265097Sbrooks	@false
248265097Sbrooks
249133945SruSTARTTIME!= LC_ALL=C date
250240403SobrienCHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo
251177609Sru.if !empty(CHECK_TIME)
252177609Sru.error check your date/time: ${STARTTIME}
253177609Sru.endif
254133945Sru
255132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
25617308Speter#
25754324Smarcel# world
25854324Smarcel#
259132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be
260132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is
261132234Smarcel# not included. One can argue that this target doesn't build everything
262132234Smarcel# then.
26354324Smarcel#
26454324Smarcelworld: upgrade_checks
26554324Smarcel	@echo "--------------------------------------------------------------"
266118531Sru	@echo ">>> make world started on ${STARTTIME}"
26754324Smarcel	@echo "--------------------------------------------------------------"
26854324Smarcel.if target(pre-world)
26954324Smarcel	@echo
27054324Smarcel	@echo "--------------------------------------------------------------"
27154324Smarcel	@echo ">>> Making 'pre-world' target"
27254324Smarcel	@echo "--------------------------------------------------------------"
273133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
27454324Smarcel.endif
275133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
276133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
27754324Smarcel.if target(post-world)
27854324Smarcel	@echo
27954324Smarcel	@echo "--------------------------------------------------------------"
28054324Smarcel	@echo ">>> Making 'post-world' target"
28154324Smarcel	@echo "--------------------------------------------------------------"
282133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
28354324Smarcel.endif
28454324Smarcel	@echo
28554324Smarcel	@echo "--------------------------------------------------------------"
286118531Sru	@echo ">>> make world completed on `LC_ALL=C date`"
287118531Sru	@echo "                   (started ${STARTTIME})"
28854324Smarcel	@echo "--------------------------------------------------------------"
289132234Smarcel.else
290132234Smarcelworld:
291132234Smarcel	@echo "WARNING: make world will overwrite your existing FreeBSD"
292132234Smarcel	@echo "installation without also building and installing a new"
293132234Smarcel	@echo "kernel.  This can be dangerous.  Please read the handbook,"
294132588Skensmith	@echo "'Rebuilding world', for how to upgrade your system."
295132358Smarkm	@echo "Define DESTDIR to where you want to install FreeBSD,"
296132234Smarcel	@echo "including /, to override this warning and proceed as usual."
297132358Smarkm	@echo ""
298132234Smarcel	@echo "Bailing out now..."
299132234Smarcel	@false
300132234Smarcel.endif
30154324Smarcel
30254324Smarcel#
30395730Sru# kernel
30495730Sru#
30595730Sru# Short hand for `make buildkernel installkernel'
30695730Sru#
30795730Srukernel: buildkernel installkernel
30895730Sru
30995730Sru#
31038666Sjb# Perform a few tests to determine if the installed tools are adequate
311107374Sru# for building the world.
31217308Speter#
313253616Ssjg# Note: if we ever need to care about the version of bmake, simply testing
314253616Ssjg# MAKE_VERSION against a required version should suffice.
315253616Ssjg#
31655678Smarcelupgrade_checks:
317253616Ssjg.if ${HAVE_MAKE} != ${WANT_MAKE}
318253616Ssjg	@(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
319241298Smarcel.endif
3202061Sjkh
32117308Speter#
322107516Sru# Upgrade make(1) to the current version using the installed
323174539Simp# headers, libraries and tools.  Also, allow the location of
324174539Simp# the system bsdmake-like utility to be overridden.
32555678Smarcel#
326253616SsjgMMAKEENV=	MAKEOBJDIRPREFIX=${MYMAKE:H} \
327107516Sru		DESTDIR= \
328107516Sru		INSTALL="sh ${.CURDIR}/tools/install.sh"
329174564SimpMMAKE=		${MMAKEENV} ${MAKE} \
330264397Simp		-D_UPGRADING -DNO_MAN -DNO_SHARED \
331264742Sjmmv		-DNO_CPU_CFLAGS -DNO_WERROR \
332265827Simp		DESTDIR= PROGNAME=${MYMAKE:T}
333107516Sru
334265827Simpbmake: .PHONY
33555678Smarcel	@echo
33655678Smarcel	@echo "--------------------------------------------------------------"
337265827Simp	@echo ">>> Building an up-to-date ${.TARGET}(1)"
33855678Smarcel	@echo "--------------------------------------------------------------"
339249395Ssjg	${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
340255713Semaste		${MMAKE} obj && \
341255713Semaste		${MMAKE} depend && \
342255713Semaste		${MMAKE} all && \
343265827Simp		${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR=
34455678Smarcel
345254417Ssjgtinderbox toolchains kernel-toolchains: upgrade_checks
346254417Ssjg
347185499Salfredtinderbox:
348254417Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} DOING_TINDERBOX=YES universe
349185499Salfred
350218524Sjhbtoolchains:
351254417Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
352218524Sjhb
353232907Sjmallettkernel-toolchains:
354254417Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
355232907Sjmallett
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)
364221869SattilioTARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64
365263660SandrewTARGET_ARCHES_arm?=	arm armeb armv6 armv6hf
366233644SjmallettTARGET_ARCHES_mips?=	mipsel mips mips64el mips64 mipsn32
367216520SnwhitehornTARGET_ARCHES_powerpc?=	powerpc powerpc64
368216520SnwhitehornTARGET_ARCHES_pc98?=	i386
369216520Snwhitehorn.for target in ${TARGETS}
370216520SnwhitehornTARGET_ARCHES_${target}?= ${target}
371216520Snwhitehorn.endfor
372168280Smarcel
373218524Sjhb.if defined(UNIVERSE_TARGET)
374218524SjhbMAKE_JUST_WORLDS=	YES
375218524Sjhb.else
376218524SjhbUNIVERSE_TARGET?=	buildworld
377218524Sjhb.endif
378219137SjhbKERNSRCDIR?=		${.CURDIR}/sys
379218524Sjhb
380217125Simptargets:
381217815Sbz	@echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
382217125Simp.for target in ${TARGETS}
383217125Simp.for target_arch in ${TARGET_ARCHES_${target}}
384217125Simp	@echo "    ${target}/${target_arch}"
385217125Simp.endfor
386217125Simp.endfor
387217125Simp
388185499Salfred.if defined(DOING_TINDERBOX)
389217735SbzFAILFILE=${.CURDIR}/_.tinderbox.failed
390185499SalfredMAKEFAIL=tee -a ${FAILFILE}
391185499Salfred.else
392185499SalfredMAKEFAIL=cat
393185499Salfred.endif
394185499Salfred
395253616Ssjguniverse_prologue:  upgrade_checks
396253616Ssjguniverse: universe_prologue
397133945Sruuniverse_prologue:
398103985Sphk	@echo "--------------------------------------------------------------"
399103985Sphk	@echo ">>> make universe started on ${STARTTIME}"
400103985Sphk	@echo "--------------------------------------------------------------"
401185499Salfred.if defined(DOING_TINDERBOX)
402217754Sbz	@rm -f ${FAILFILE}
403185499Salfred.endif
404168280Smarcel.for target in ${TARGETS}
405162147Sruuniverse: universe_${target}
406253616Ssjguniverse_epilogue: universe_${target}
407216520Snwhitehornuniverse_${target}: universe_${target}_prologue
408253616Ssjguniverse_${target}_prologue: universe_prologue
409216520Snwhitehorn	@echo ">> ${target} started on `LC_ALL=C date`"
410179232Sjb.if !defined(MAKE_JUST_KERNELS)
411216520Snwhitehorn.for target_arch in ${TARGET_ARCHES_${target}}
412216520Snwhitehornuniverse_${target}: universe_${target}_${target_arch}
413254417Ssjguniverse_${target}_${target_arch}: universe_${target}_prologue .MAKE
414218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
415185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
416253616Ssjg	    ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
417162147Sru	    TARGET=${target} \
418216520Snwhitehorn	    TARGET_ARCH=${target_arch} \
419218524Sjhb	    > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
420218524Sjhb	    (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
421218524Sjhb	    "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
422216520Snwhitehorn	    ${MAKEFAIL}))
423218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
424216520Snwhitehorn.endfor
425179232Sjb.endif
426205290Sdougb.if !defined(MAKE_JUST_WORLDS)
427248937Sandrew# If we are building world and kernels wait for the required worlds to finish
428248937Sandrew.if !defined(MAKE_JUST_KERNELS)
429248937Sandrew.for target_arch in ${TARGET_ARCHES_${target}}
430248937Sandrewuniverse_${target}_kernels: universe_${target}_${target_arch}
431248937Sandrew.endfor
432248937Sandrew.endif
433248937Sandrewuniverse_${target}: universe_${target}_kernels
434254417Ssjguniverse_${target}_kernels: universe_${target}_prologue .MAKE
435219137Sjhb.if exists(${KERNSRCDIR}/${target}/conf/NOTES)
436219137Sjhb	@(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
437253616Ssjg	    ${SUB_MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
438185499Salfred	    (echo "${target} 'make LINT' failed," \
439185499Salfred	    "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
440103985Sphk.endif
441253616Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
442201815Sbz	    universe_kernels
443205290Sdougb.endif
444201815Sbz	@echo ">> ${target} completed on `LC_ALL=C date`"
445201815Sbz.endfor
446201815Sbzuniverse_kernels: universe_kernconfs
447202095Sbz.if !defined(TARGET)
448202095SbzTARGET!=	uname -m
449202095Sbz.endif
450265155Simp.if defined(MAKE_ALL_KERNELS)
451265155Simp_THINNER=cat
452265155Simp.else
453265155Simp_THINNER=xargs grep -L "^.NO_UNIVERSE"
454265155Simp.endif
455219137SjhbKERNCONFS!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
456201815Sbz		find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \
457265155Simp		! -name DEFAULTS ! -name NOTES | \
458265155Simp		${_THINNER}
459201815Sbzuniverse_kernconfs:
460148154Sru.for kernel in ${KERNCONFS}
461219137SjhbTARGET_ARCH_${kernel}!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
462219137Sjhb	config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
463216934Simp	grep -v WARNING: | cut -f 2
464216934Simp.if empty(TARGET_ARCH_${kernel})
465216934Simp.error "Target architecture for ${TARGET}/conf/${kernel} unknown.  config(8) likely too old."
466216934Simp.endif
467216520Snwhitehornuniverse_kernconfs: universe_kernconf_${TARGET}_${kernel}
468254417Ssjguniverse_kernconf_${TARGET}_${kernel}: .MAKE
469185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
470253616Ssjg	    ${SUB_MAKE} ${JFLAG} buildkernel \
471201815Sbz	    TARGET=${TARGET} \
472216520Snwhitehorn	    TARGET_ARCH=${TARGET_ARCH_${kernel}} \
473148154Sru	    KERNCONF=${kernel} \
474201815Sbz	    > _.${TARGET}.${kernel} 2>&1 || \
475201815Sbz	    (echo "${TARGET} ${kernel} kernel failed," \
476201815Sbz	    "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
477148154Sru.endfor
478133945Sruuniverse: universe_epilogue
479133945Sruuniverse_epilogue:
480103985Sphk	@echo "--------------------------------------------------------------"
481118531Sru	@echo ">>> make universe completed on `LC_ALL=C date`"
482118531Sru	@echo "                      (started ${STARTTIME})"
483103985Sphk	@echo "--------------------------------------------------------------"
484185499Salfred.if defined(DOING_TINDERBOX)
485185499Salfred	@if [ -e ${FAILFILE} ] ; then \
486185499Salfred		echo "Tinderbox failed:" ;\
487185499Salfred		cat ${FAILFILE} ;\
488185499Salfred		exit 1 ;\
489185499Salfred	fi
490133945Sru.endif
491185499Salfred.endif
492242522Smarcel
493242522SmarcelbuildLINT:
494242522Smarcel	${MAKE} -C ${.CURDIR}/sys/${_TARGET}/conf LINT
495255286Ssjg
496255286Ssjg.if defined(.PARSEDIR)
497255286Ssjg.if make(universe)
498255286Ssjg# we do not want a failure of one branch abort all.
499255286SsjgMAKE_JOB_ERROR_TOKEN= no
500255286Ssjg.export MAKE_JOB_ERROR_TOKEN
501255286Ssjg.endif
502255286Ssjg.endif
503