Makefile revision 284453
12061Sjkh#
250479Speter# $FreeBSD: head/Makefile 284453 2015-06-16 17:27:53Z andrew $
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
60217297Simp# at least 1GB of diskspace available.  A complete 'universe' build requires
61217297Simp# about 15GB 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#
102284394Srodrigc.if ${MK_META_MODE:Uno} == "yes"
103284345Ssjg# targets/Makefile plays the role of top-level
104284345Ssjg.include "targets/Makefile"
105284345Ssjg.else
106284345Ssjg
107169597SdesTGTS=	all all-man buildenv buildenvvars buildkernel buildworld \
108169597Sdes	check-old check-old-dirs check-old-files check-old-libs \
109169597Sdes	checkdpadd clean cleandepend cleandir \
110169597Sdes	delete-old delete-old-dirs delete-old-files delete-old-libs \
111219177Snwhitehorn	depend distribute distributekernel distributekernel.debug \
112219177Snwhitehorn	distributeworld distrib-dirs distribution doxygen \
113238051Sobrien	everything hier hierarchy install installcheck installkernel \
114219177Snwhitehorn	installkernel.debug packagekernel packageworld \
115219177Snwhitehorn	reinstallkernel reinstallkernel.debug \
116158962Snetchild	installworld kernel-toolchain libraries lint maninstall \
117156840Sru	obj objlink regress rerelease showconfig tags toolchain update \
118123311Speter	_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
119137288Speter	_build-tools _cross-tools _includes _libraries _depend \
120209128Sraj	build32 builddtb distribute32 install32 xdev xdev-build xdev-install \
121270155Simp	xdev-links native-xtools \
122209128Sraj
123156740SruTGTS+=	${SUBDIR_TARGETS}
1242061Sjkh
12597769SruBITGTS=	files includes
12697252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
127119579SruTGTS+=	${BITGTS}
12897252Sru
12995730Sru.ORDER: buildworld installworld
13095793Sru.ORDER: buildworld distributeworld
131111617Sru.ORDER: buildworld buildkernel
13295730Sru.ORDER: buildkernel installkernel
133116679Ssimokawa.ORDER: buildkernel installkernel.debug
13495730Sru.ORDER: buildkernel reinstallkernel
135116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug
13695730Sru
137110035SruPATH=	/sbin:/bin:/usr/sbin:/usr/bin
138107516SruMAKEOBJDIRPREFIX?=	/usr/obj
139138921Sru_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
140156145Syar    ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
141138921Sru    -f /dev/null -V MAKEOBJDIRPREFIX dummy
142133942Sru.if !empty(_MAKEOBJDIRPREFIX)
143133942Sru.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
144156145Syar	(in make.conf(5)) or command-line variable.
145133942Sru.endif
146253616Ssjg
147253616Ssjg# We often need to use the tree's version of make to build it.
148253616Ssjg# Choices add to complexity though.
149253616Ssjg# We cannot blindly use a make which may not be the one we want
150253616Ssjg# so be exlicit - until all choice is removed.
151253616SsjgWANT_MAKE=	bmake
152253616SsjgMYMAKE=		${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}/${WANT_MAKE}
153253616Ssjg.if defined(.PARSEDIR)
154253616SsjgHAVE_MAKE=	bmake
155253616Ssjg.else
156253616SsjgHAVE_MAKE=	fmake
157253616Ssjg.endif
158253616Ssjg.if exists(${MYMAKE})
159253616SsjgSUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
160265423Simp.elif ${WANT_MAKE} != ${HAVE_MAKE}
161253616Ssjg# It may not exist yet but we may cause it to.
162253616Ssjg# In the case of fmake, upgrade_checks may cause a newer version to be built.
163253616SsjgSUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
164117229Sru	-m ${.CURDIR}/share/mk
165253616Ssjg.else
166253616SsjgSUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
167253616Ssjg.endif
16854324Smarcel
169253616Ssjg_MAKE=	PATH=${PATH} ${SUB_MAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
170253616Ssjg
171218130Simp# Guess machine architecture from machine type, and vice versa.
172218130Simp.if !defined(TARGET_ARCH) && defined(TARGET)
173280259Sandrew_TARGET_ARCH=	${TARGET:S/pc98/i386/:S/arm64/aarch64/}
174218130Simp.elif !defined(TARGET) && defined(TARGET_ARCH) && \
175218130Simp    ${TARGET_ARCH} != ${MACHINE_ARCH}
176280326Simp_TARGET=		${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb|hf)?/arm/:C/aarch64/arm64/:C/powerpc64/powerpc/}
177218130Simp.endif
178218130Simp.if defined(TARGET) && !defined(_TARGET)
179218130Simp_TARGET=${TARGET}
180218130Simp.endif
181218130Simp.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
182218130Simp_TARGET_ARCH=${TARGET_ARCH}
183218130Simp.endif
184269048Simp# for historical compatibility for xdev targets
185269048Simp.if defined(XDEV)
186269048Simp_TARGET=	${XDEV}
187269048Simp.endif
188269048Simp.if defined(XDEV_ARCH)
189269048Simp_TARGET_ARCH=	${XDEV_ARCH}
190269048Simp.endif
191218130Simp# Otherwise, default to current machine type and architecture.
192218130Simp_TARGET?=	${MACHINE}
193218130Simp_TARGET_ARCH?=	${MACHINE_ARCH}
194218130Simp
19517308Speter#
196119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld
197119519Smarcel# should do this as those are the initial targets used for upgrades.
198119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed
199119519Smarcel# for all targets.
200119519Smarcel#
201119519Smarcel.if defined(ALWAYS_CHECK_MAKE)
202119579Sru${TGTS}: upgrade_checks
203119519Smarcel.else
204119519Smarcelbuildworld: upgrade_checks
205119519Smarcel.endif
206119519Smarcel
207119519Smarcel#
208126031Sgad# This 'cleanworld' target is not included in TGTS, because it is not a
209126024Sgad# recursive target.  All of the work for it is done right here.   It is
210126024Sgad# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
211126024Sgad# created by bsd.obj.mk, except that we don't want to .include that file
212126024Sgad# in this makefile.  
213126024Sgad#
214126024Sgad# In the following, the first 'rm' in a series will usually remove all
215126024Sgad# files and directories.  If it does not, then there are probably some
216227771Sgjb# files with file flags set, so this unsets them and tries the 'rm' a
217126024Sgad# second time.  There are situations where this target will be cleaning
218126024Sgad# some directories via more than one method, but that duplication is
219227769Sgjb# needed to correctly handle all the possible situations.  Removing all
220227771Sgjb# files without file flags set in the first 'rm' instance saves time,
221227771Sgjb# because 'chflags' will need to operate on fewer files afterwards.
222126024Sgad#
223126024SgadBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
224126031Sgadcleanworld:
225126024Sgad.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
226126024Sgad.if exists(${BW_CANONICALOBJDIR}/)
227126024Sgad	-rm -rf ${BW_CANONICALOBJDIR}/*
228172744Sdelphij	-chflags -R 0 ${BW_CANONICALOBJDIR}
229126024Sgad	rm -rf ${BW_CANONICALOBJDIR}/*
230126024Sgad.endif
231126024Sgad	#   To be safe in this case, fall back to a 'make cleandir'
232133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
233126024Sgad.else
234126024Sgad	-rm -rf ${.OBJDIR}/*
235172744Sdelphij	-chflags -R 0 ${.OBJDIR}
236126024Sgad	rm -rf ${.OBJDIR}/*
237126024Sgad.endif
238125885Sgad
239125885Sgad#
24038666Sjb# Handle the user-driven targets, using the source relative mk files.
24117308Speter#
242119519Smarcel
243251750Ssjg.if empty(.MAKEFLAGS:M-n)
244251750Ssjg# skip this for -n to avoid changing previous behavior of 
245251750Ssjg# 'make -n buildworld' etc.
246251750Ssjg${TGTS}: .MAKE
247254417Ssjgtinderbox toolchains kernel-toolchains: .MAKE
248251750Ssjg.endif
249251750Ssjg
250119579Sru${TGTS}:
251218206Simp	${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
2522302Spaul
253265097Sbrooks# The historic default "all" target creates files which may cause stale
254265097Sbrooks# or (in the cross build case) unlinkable results. Fail with an error
255265097Sbrooks# when no target is given. The users can explicitly specify "all"
256265097Sbrooks# if they want the historic behavior.
257265097Sbrooks.MAIN:	_guard
25839206Sjkh
259265097Sbrooks_guard:
260265097Sbrooks	@echo
261265097Sbrooks	@echo "Explicit target required (use \"all\" for historic behavior)"
262265097Sbrooks	@echo
263265097Sbrooks	@false
264265097Sbrooks
265133945SruSTARTTIME!= LC_ALL=C date
266240403SobrienCHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo
267177609Sru.if !empty(CHECK_TIME)
268177609Sru.error check your date/time: ${STARTTIME}
269177609Sru.endif
270133945Sru
271132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
27217308Speter#
27354324Smarcel# world
27454324Smarcel#
275132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be
276132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is
277132234Smarcel# not included. One can argue that this target doesn't build everything
278132234Smarcel# then.
27954324Smarcel#
28054324Smarcelworld: upgrade_checks
28154324Smarcel	@echo "--------------------------------------------------------------"
282118531Sru	@echo ">>> make world started on ${STARTTIME}"
28354324Smarcel	@echo "--------------------------------------------------------------"
28454324Smarcel.if target(pre-world)
28554324Smarcel	@echo
28654324Smarcel	@echo "--------------------------------------------------------------"
28754324Smarcel	@echo ">>> Making 'pre-world' target"
28854324Smarcel	@echo "--------------------------------------------------------------"
289133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
29054324Smarcel.endif
291133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
292133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
29354324Smarcel.if target(post-world)
29454324Smarcel	@echo
29554324Smarcel	@echo "--------------------------------------------------------------"
29654324Smarcel	@echo ">>> Making 'post-world' target"
29754324Smarcel	@echo "--------------------------------------------------------------"
298133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
29954324Smarcel.endif
30054324Smarcel	@echo
30154324Smarcel	@echo "--------------------------------------------------------------"
302118531Sru	@echo ">>> make world completed on `LC_ALL=C date`"
303118531Sru	@echo "                   (started ${STARTTIME})"
30454324Smarcel	@echo "--------------------------------------------------------------"
305132234Smarcel.else
306132234Smarcelworld:
307132234Smarcel	@echo "WARNING: make world will overwrite your existing FreeBSD"
308132234Smarcel	@echo "installation without also building and installing a new"
309132234Smarcel	@echo "kernel.  This can be dangerous.  Please read the handbook,"
310132588Skensmith	@echo "'Rebuilding world', for how to upgrade your system."
311132358Smarkm	@echo "Define DESTDIR to where you want to install FreeBSD,"
312132234Smarcel	@echo "including /, to override this warning and proceed as usual."
313132358Smarkm	@echo ""
314132234Smarcel	@echo "Bailing out now..."
315132234Smarcel	@false
316132234Smarcel.endif
31754324Smarcel
31854324Smarcel#
31995730Sru# kernel
32095730Sru#
32195730Sru# Short hand for `make buildkernel installkernel'
32295730Sru#
32395730Srukernel: buildkernel installkernel
32495730Sru
32595730Sru#
32638666Sjb# Perform a few tests to determine if the installed tools are adequate
327107374Sru# for building the world.
32817308Speter#
329253616Ssjg# Note: if we ever need to care about the version of bmake, simply testing
330253616Ssjg# MAKE_VERSION against a required version should suffice.
331253616Ssjg#
33255678Smarcelupgrade_checks:
333253616Ssjg.if ${HAVE_MAKE} != ${WANT_MAKE}
334253616Ssjg	@(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
335241298Smarcel.endif
3362061Sjkh
33717308Speter#
338107516Sru# Upgrade make(1) to the current version using the installed
339174539Simp# headers, libraries and tools.  Also, allow the location of
340174539Simp# the system bsdmake-like utility to be overridden.
34155678Smarcel#
342253616SsjgMMAKEENV=	MAKEOBJDIRPREFIX=${MYMAKE:H} \
343107516Sru		DESTDIR= \
344107516Sru		INSTALL="sh ${.CURDIR}/tools/install.sh"
345174564SimpMMAKE=		${MMAKEENV} ${MAKE} \
346265837Simp		-DNO_MAN -DNO_SHARED \
347264742Sjmmv		-DNO_CPU_CFLAGS -DNO_WERROR \
348268598Sjmmv		MK_TESTS=no \
349265827Simp		DESTDIR= PROGNAME=${MYMAKE:T}
350107516Sru
351265827Simpbmake: .PHONY
35255678Smarcel	@echo
35355678Smarcel	@echo "--------------------------------------------------------------"
354265827Simp	@echo ">>> Building an up-to-date ${.TARGET}(1)"
35555678Smarcel	@echo "--------------------------------------------------------------"
356249395Ssjg	${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
357255713Semaste		${MMAKE} obj && \
358255713Semaste		${MMAKE} depend && \
359255713Semaste		${MMAKE} all && \
360265827Simp		${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR=
36155678Smarcel
362254417Ssjgtinderbox toolchains kernel-toolchains: upgrade_checks
363254417Ssjg
364185499Salfredtinderbox:
365254417Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} DOING_TINDERBOX=YES universe
366185499Salfred
367218524Sjhbtoolchains:
368254417Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
369218524Sjhb
370232907Sjmallettkernel-toolchains:
371254417Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
372232907Sjmallett
37355678Smarcel#
374111131Sru# universe
375111131Sru#
376111131Sru# Attempt to rebuild *everything* for all supported architectures,
377133945Sru# with a reasonable chance of success, regardless of how old your
378111131Sru# existing system is.
379111131Sru#
380217125Simp.if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets)
381281629Semaste# XXX Add arm64 to universe only if we have an external binutils installed.
382282108Sngie# It does not build with the in-tree linker.
383281629Semaste.if exists(/usr/local/aarch64-freebsd/bin/ld)
384282156SemasteUNIVERSE_arm64=arm64
385282156Semaste.elif empty(${TARGETS})
386281629Semasteuniverse: universe_arm64_skip
387281629Semasteuniverse_epilogue: universe_arm64_skip
388281629Semasteuniverse_arm64_skip: universe_prologue
389281629Semaste	@echo ">> arm64 skipped - install aarch64-binutils port or package to build"
390281629Semaste.endif
391282156SemasteTARGETS?=amd64 arm ${UNIVERSE_arm64} i386 mips pc98 powerpc sparc64
392263660SandrewTARGET_ARCHES_arm?=	arm armeb armv6 armv6hf
393282156SemasteTARGET_ARCHES_arm64?=	aarch64
394233644SjmallettTARGET_ARCHES_mips?=	mipsel mips mips64el mips64 mipsn32
395216520SnwhitehornTARGET_ARCHES_powerpc?=	powerpc powerpc64
396216520SnwhitehornTARGET_ARCHES_pc98?=	i386
397216520Snwhitehorn.for target in ${TARGETS}
398216520SnwhitehornTARGET_ARCHES_${target}?= ${target}
399216520Snwhitehorn.endfor
400168280Smarcel
401218524Sjhb.if defined(UNIVERSE_TARGET)
402218524SjhbMAKE_JUST_WORLDS=	YES
403218524Sjhb.else
404218524SjhbUNIVERSE_TARGET?=	buildworld
405218524Sjhb.endif
406219137SjhbKERNSRCDIR?=		${.CURDIR}/sys
407218524Sjhb
408217125Simptargets:
409217815Sbz	@echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
410217125Simp.for target in ${TARGETS}
411217125Simp.for target_arch in ${TARGET_ARCHES_${target}}
412217125Simp	@echo "    ${target}/${target_arch}"
413217125Simp.endfor
414217125Simp.endfor
415217125Simp
416185499Salfred.if defined(DOING_TINDERBOX)
417217735SbzFAILFILE=${.CURDIR}/_.tinderbox.failed
418185499SalfredMAKEFAIL=tee -a ${FAILFILE}
419185499Salfred.else
420185499SalfredMAKEFAIL=cat
421185499Salfred.endif
422185499Salfred
423253616Ssjguniverse_prologue:  upgrade_checks
424253616Ssjguniverse: universe_prologue
425133945Sruuniverse_prologue:
426103985Sphk	@echo "--------------------------------------------------------------"
427103985Sphk	@echo ">>> make universe started on ${STARTTIME}"
428103985Sphk	@echo "--------------------------------------------------------------"
429185499Salfred.if defined(DOING_TINDERBOX)
430217754Sbz	@rm -f ${FAILFILE}
431185499Salfred.endif
432168280Smarcel.for target in ${TARGETS}
433162147Sruuniverse: universe_${target}
434253616Ssjguniverse_epilogue: universe_${target}
435216520Snwhitehornuniverse_${target}: universe_${target}_prologue
436253616Ssjguniverse_${target}_prologue: universe_prologue
437216520Snwhitehorn	@echo ">> ${target} started on `LC_ALL=C date`"
438179232Sjb.if !defined(MAKE_JUST_KERNELS)
439216520Snwhitehorn.for target_arch in ${TARGET_ARCHES_${target}}
440216520Snwhitehornuniverse_${target}: universe_${target}_${target_arch}
441254417Ssjguniverse_${target}_${target_arch}: universe_${target}_prologue .MAKE
442218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
443185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
444253616Ssjg	    ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
445162147Sru	    TARGET=${target} \
446216520Snwhitehorn	    TARGET_ARCH=${target_arch} \
447218524Sjhb	    > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
448218524Sjhb	    (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
449218524Sjhb	    "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
450216520Snwhitehorn	    ${MAKEFAIL}))
451218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
452216520Snwhitehorn.endfor
453284453Sandrew.endif # !MAKE_JUST_KERNELS
454284453Sandrew
455205290Sdougb.if !defined(MAKE_JUST_WORLDS)
456248937Sandrew# If we are building world and kernels wait for the required worlds to finish
457248937Sandrew.if !defined(MAKE_JUST_KERNELS)
458248937Sandrew.for target_arch in ${TARGET_ARCHES_${target}}
459248937Sandrewuniverse_${target}_kernels: universe_${target}_${target_arch}
460248937Sandrew.endfor
461248937Sandrew.endif
462248937Sandrewuniverse_${target}: universe_${target}_kernels
463254417Ssjguniverse_${target}_kernels: universe_${target}_prologue .MAKE
464219137Sjhb.if exists(${KERNSRCDIR}/${target}/conf/NOTES)
465219137Sjhb	@(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
466253616Ssjg	    ${SUB_MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
467185499Salfred	    (echo "${target} 'make LINT' failed," \
468185499Salfred	    "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
469103985Sphk.endif
470253616Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
471201815Sbz	    universe_kernels
472284453Sandrew.endif # !MAKE_JUST_WORLDS
473201815Sbz	@echo ">> ${target} completed on `LC_ALL=C date`"
474201815Sbz.endfor
475201815Sbzuniverse_kernels: universe_kernconfs
476202095Sbz.if !defined(TARGET)
477202095SbzTARGET!=	uname -m
478202095Sbz.endif
479265155Simp.if defined(MAKE_ALL_KERNELS)
480265155Simp_THINNER=cat
481265155Simp.else
482265840Simp_THINNER=xargs grep -L "^.NO_UNIVERSE" || true
483265155Simp.endif
484219137SjhbKERNCONFS!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
485201815Sbz		find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \
486265155Simp		! -name DEFAULTS ! -name NOTES | \
487265155Simp		${_THINNER}
488201815Sbzuniverse_kernconfs:
489148154Sru.for kernel in ${KERNCONFS}
490219137SjhbTARGET_ARCH_${kernel}!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
491219137Sjhb	config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
492216934Simp	grep -v WARNING: | cut -f 2
493216934Simp.if empty(TARGET_ARCH_${kernel})
494216934Simp.error "Target architecture for ${TARGET}/conf/${kernel} unknown.  config(8) likely too old."
495216934Simp.endif
496216520Snwhitehornuniverse_kernconfs: universe_kernconf_${TARGET}_${kernel}
497254417Ssjguniverse_kernconf_${TARGET}_${kernel}: .MAKE
498185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
499253616Ssjg	    ${SUB_MAKE} ${JFLAG} buildkernel \
500201815Sbz	    TARGET=${TARGET} \
501216520Snwhitehorn	    TARGET_ARCH=${TARGET_ARCH_${kernel}} \
502148154Sru	    KERNCONF=${kernel} \
503201815Sbz	    > _.${TARGET}.${kernel} 2>&1 || \
504201815Sbz	    (echo "${TARGET} ${kernel} kernel failed," \
505201815Sbz	    "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
506148154Sru.endfor
507133945Sruuniverse: universe_epilogue
508133945Sruuniverse_epilogue:
509103985Sphk	@echo "--------------------------------------------------------------"
510118531Sru	@echo ">>> make universe completed on `LC_ALL=C date`"
511118531Sru	@echo "                      (started ${STARTTIME})"
512103985Sphk	@echo "--------------------------------------------------------------"
513185499Salfred.if defined(DOING_TINDERBOX)
514185499Salfred	@if [ -e ${FAILFILE} ] ; then \
515185499Salfred		echo "Tinderbox failed:" ;\
516185499Salfred		cat ${FAILFILE} ;\
517185499Salfred		exit 1 ;\
518185499Salfred	fi
519133945Sru.endif
520185499Salfred.endif
521242522Smarcel
522242522SmarcelbuildLINT:
523242522Smarcel	${MAKE} -C ${.CURDIR}/sys/${_TARGET}/conf LINT
524255286Ssjg
525284345Ssjg# This makefile does not run in meta mode
526284345Ssjg.MAKE.MODE= normal
527284345Ssjg# Normally the things we run from here don't either.
528284345Ssjg# Using -DWITH_META_FILES
529284345Ssjg# we can buildworld with meta files created which are useful 
530284345Ssjg# for debugging, but without any of the rest of a meta mode build.
531284345SsjgMK_META_MODE= no
532284345SsjgMK_STAGING= no
533284345Ssjg# tell meta.autodep.mk to not even think about updating anything.
534284345SsjgUPDATE_DEPENDFILE= NO
535284345Ssjg.export MK_META_MODE MK_STAGING UPDATE_DEPENDFILE
536284345Ssjg
537255286Ssjg.if make(universe)
538255286Ssjg# we do not want a failure of one branch abort all.
539255286SsjgMAKE_JOB_ERROR_TOKEN= no
540255286Ssjg.export MAKE_JOB_ERROR_TOKEN
541255286Ssjg.endif
542284345Ssjg
543284345Ssjg.endif				# META_MODE
544