Makefile revision 282156
12061Sjkh#
250479Speter# $FreeBSD: head/Makefile 282156 2015-04-28 17:13:05Z emaste $
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#
102169597SdesTGTS=	all all-man buildenv buildenvvars buildkernel buildworld \
103169597Sdes	check-old check-old-dirs check-old-files check-old-libs \
104169597Sdes	checkdpadd clean cleandepend cleandir \
105169597Sdes	delete-old delete-old-dirs delete-old-files delete-old-libs \
106219177Snwhitehorn	depend distribute distributekernel distributekernel.debug \
107219177Snwhitehorn	distributeworld distrib-dirs distribution doxygen \
108238051Sobrien	everything hier hierarchy install installcheck installkernel \
109219177Snwhitehorn	installkernel.debug packagekernel packageworld \
110219177Snwhitehorn	reinstallkernel reinstallkernel.debug \
111158962Snetchild	installworld kernel-toolchain libraries lint maninstall \
112156840Sru	obj objlink regress rerelease showconfig tags toolchain update \
113123311Speter	_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
114137288Speter	_build-tools _cross-tools _includes _libraries _depend \
115209128Sraj	build32 builddtb distribute32 install32 xdev xdev-build xdev-install \
116270155Simp	xdev-links native-xtools \
117209128Sraj
118156740SruTGTS+=	${SUBDIR_TARGETS}
1192061Sjkh
12097769SruBITGTS=	files includes
12197252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
122119579SruTGTS+=	${BITGTS}
12397252Sru
12495730Sru.ORDER: buildworld installworld
12595793Sru.ORDER: buildworld distributeworld
126111617Sru.ORDER: buildworld buildkernel
12795730Sru.ORDER: buildkernel installkernel
128116679Ssimokawa.ORDER: buildkernel installkernel.debug
12995730Sru.ORDER: buildkernel reinstallkernel
130116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug
13195730Sru
132110035SruPATH=	/sbin:/bin:/usr/sbin:/usr/bin
133107516SruMAKEOBJDIRPREFIX?=	/usr/obj
134138921Sru_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
135156145Syar    ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
136138921Sru    -f /dev/null -V MAKEOBJDIRPREFIX dummy
137133942Sru.if !empty(_MAKEOBJDIRPREFIX)
138133942Sru.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
139156145Syar	(in make.conf(5)) or command-line variable.
140133942Sru.endif
141253616Ssjg
142253616Ssjg# We often need to use the tree's version of make to build it.
143253616Ssjg# Choices add to complexity though.
144253616Ssjg# We cannot blindly use a make which may not be the one we want
145253616Ssjg# so be exlicit - until all choice is removed.
146253616SsjgWANT_MAKE=	bmake
147253616SsjgMYMAKE=		${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}/${WANT_MAKE}
148253616Ssjg.if defined(.PARSEDIR)
149253616SsjgHAVE_MAKE=	bmake
150253616Ssjg.else
151253616SsjgHAVE_MAKE=	fmake
152253616Ssjg.endif
153253616Ssjg.if exists(${MYMAKE})
154253616SsjgSUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
155265423Simp.elif ${WANT_MAKE} != ${HAVE_MAKE}
156253616Ssjg# It may not exist yet but we may cause it to.
157253616Ssjg# In the case of fmake, upgrade_checks may cause a newer version to be built.
158253616SsjgSUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
159117229Sru	-m ${.CURDIR}/share/mk
160253616Ssjg.else
161253616SsjgSUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
162253616Ssjg.endif
16354324Smarcel
164253616Ssjg_MAKE=	PATH=${PATH} ${SUB_MAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
165253616Ssjg
166218130Simp# Guess machine architecture from machine type, and vice versa.
167218130Simp.if !defined(TARGET_ARCH) && defined(TARGET)
168280259Sandrew_TARGET_ARCH=	${TARGET:S/pc98/i386/:S/arm64/aarch64/}
169218130Simp.elif !defined(TARGET) && defined(TARGET_ARCH) && \
170218130Simp    ${TARGET_ARCH} != ${MACHINE_ARCH}
171280326Simp_TARGET=		${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb|hf)?/arm/:C/aarch64/arm64/:C/powerpc64/powerpc/}
172218130Simp.endif
173218130Simp.if defined(TARGET) && !defined(_TARGET)
174218130Simp_TARGET=${TARGET}
175218130Simp.endif
176218130Simp.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
177218130Simp_TARGET_ARCH=${TARGET_ARCH}
178218130Simp.endif
179269048Simp# for historical compatibility for xdev targets
180269048Simp.if defined(XDEV)
181269048Simp_TARGET=	${XDEV}
182269048Simp.endif
183269048Simp.if defined(XDEV_ARCH)
184269048Simp_TARGET_ARCH=	${XDEV_ARCH}
185269048Simp.endif
186218130Simp# Otherwise, default to current machine type and architecture.
187218130Simp_TARGET?=	${MACHINE}
188218130Simp_TARGET_ARCH?=	${MACHINE_ARCH}
189218130Simp
19017308Speter#
191119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld
192119519Smarcel# should do this as those are the initial targets used for upgrades.
193119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed
194119519Smarcel# for all targets.
195119519Smarcel#
196119519Smarcel.if defined(ALWAYS_CHECK_MAKE)
197119579Sru${TGTS}: upgrade_checks
198119519Smarcel.else
199119519Smarcelbuildworld: upgrade_checks
200119519Smarcel.endif
201119519Smarcel
202119519Smarcel#
203126031Sgad# This 'cleanworld' target is not included in TGTS, because it is not a
204126024Sgad# recursive target.  All of the work for it is done right here.   It is
205126024Sgad# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
206126024Sgad# created by bsd.obj.mk, except that we don't want to .include that file
207126024Sgad# in this makefile.  
208126024Sgad#
209126024Sgad# In the following, the first 'rm' in a series will usually remove all
210126024Sgad# files and directories.  If it does not, then there are probably some
211227771Sgjb# files with file flags set, so this unsets them and tries the 'rm' a
212126024Sgad# second time.  There are situations where this target will be cleaning
213126024Sgad# some directories via more than one method, but that duplication is
214227769Sgjb# needed to correctly handle all the possible situations.  Removing all
215227771Sgjb# files without file flags set in the first 'rm' instance saves time,
216227771Sgjb# because 'chflags' will need to operate on fewer files afterwards.
217126024Sgad#
218126024SgadBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
219126031Sgadcleanworld:
220126024Sgad.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
221126024Sgad.if exists(${BW_CANONICALOBJDIR}/)
222126024Sgad	-rm -rf ${BW_CANONICALOBJDIR}/*
223172744Sdelphij	-chflags -R 0 ${BW_CANONICALOBJDIR}
224126024Sgad	rm -rf ${BW_CANONICALOBJDIR}/*
225126024Sgad.endif
226126024Sgad	#   To be safe in this case, fall back to a 'make cleandir'
227133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
228126024Sgad.else
229126024Sgad	-rm -rf ${.OBJDIR}/*
230172744Sdelphij	-chflags -R 0 ${.OBJDIR}
231126024Sgad	rm -rf ${.OBJDIR}/*
232126024Sgad.endif
233125885Sgad
234125885Sgad#
23538666Sjb# Handle the user-driven targets, using the source relative mk files.
23617308Speter#
237119519Smarcel
238251750Ssjg.if empty(.MAKEFLAGS:M-n)
239251750Ssjg# skip this for -n to avoid changing previous behavior of 
240251750Ssjg# 'make -n buildworld' etc.
241251750Ssjg${TGTS}: .MAKE
242254417Ssjgtinderbox toolchains kernel-toolchains: .MAKE
243251750Ssjg.endif
244251750Ssjg
245119579Sru${TGTS}:
246218206Simp	${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
2472302Spaul
248265097Sbrooks# The historic default "all" target creates files which may cause stale
249265097Sbrooks# or (in the cross build case) unlinkable results. Fail with an error
250265097Sbrooks# when no target is given. The users can explicitly specify "all"
251265097Sbrooks# if they want the historic behavior.
252265097Sbrooks.MAIN:	_guard
25339206Sjkh
254265097Sbrooks_guard:
255265097Sbrooks	@echo
256265097Sbrooks	@echo "Explicit target required (use \"all\" for historic behavior)"
257265097Sbrooks	@echo
258265097Sbrooks	@false
259265097Sbrooks
260133945SruSTARTTIME!= LC_ALL=C date
261240403SobrienCHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo
262177609Sru.if !empty(CHECK_TIME)
263177609Sru.error check your date/time: ${STARTTIME}
264177609Sru.endif
265133945Sru
266132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
26717308Speter#
26854324Smarcel# world
26954324Smarcel#
270132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be
271132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is
272132234Smarcel# not included. One can argue that this target doesn't build everything
273132234Smarcel# then.
27454324Smarcel#
27554324Smarcelworld: upgrade_checks
27654324Smarcel	@echo "--------------------------------------------------------------"
277118531Sru	@echo ">>> make world started on ${STARTTIME}"
27854324Smarcel	@echo "--------------------------------------------------------------"
27954324Smarcel.if target(pre-world)
28054324Smarcel	@echo
28154324Smarcel	@echo "--------------------------------------------------------------"
28254324Smarcel	@echo ">>> Making 'pre-world' target"
28354324Smarcel	@echo "--------------------------------------------------------------"
284133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
28554324Smarcel.endif
286133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
287133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
28854324Smarcel.if target(post-world)
28954324Smarcel	@echo
29054324Smarcel	@echo "--------------------------------------------------------------"
29154324Smarcel	@echo ">>> Making 'post-world' target"
29254324Smarcel	@echo "--------------------------------------------------------------"
293133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
29454324Smarcel.endif
29554324Smarcel	@echo
29654324Smarcel	@echo "--------------------------------------------------------------"
297118531Sru	@echo ">>> make world completed on `LC_ALL=C date`"
298118531Sru	@echo "                   (started ${STARTTIME})"
29954324Smarcel	@echo "--------------------------------------------------------------"
300132234Smarcel.else
301132234Smarcelworld:
302132234Smarcel	@echo "WARNING: make world will overwrite your existing FreeBSD"
303132234Smarcel	@echo "installation without also building and installing a new"
304132234Smarcel	@echo "kernel.  This can be dangerous.  Please read the handbook,"
305132588Skensmith	@echo "'Rebuilding world', for how to upgrade your system."
306132358Smarkm	@echo "Define DESTDIR to where you want to install FreeBSD,"
307132234Smarcel	@echo "including /, to override this warning and proceed as usual."
308132358Smarkm	@echo ""
309132234Smarcel	@echo "Bailing out now..."
310132234Smarcel	@false
311132234Smarcel.endif
31254324Smarcel
31354324Smarcel#
31495730Sru# kernel
31595730Sru#
31695730Sru# Short hand for `make buildkernel installkernel'
31795730Sru#
31895730Srukernel: buildkernel installkernel
31995730Sru
32095730Sru#
32138666Sjb# Perform a few tests to determine if the installed tools are adequate
322107374Sru# for building the world.
32317308Speter#
324253616Ssjg# Note: if we ever need to care about the version of bmake, simply testing
325253616Ssjg# MAKE_VERSION against a required version should suffice.
326253616Ssjg#
32755678Smarcelupgrade_checks:
328253616Ssjg.if ${HAVE_MAKE} != ${WANT_MAKE}
329253616Ssjg	@(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
330241298Smarcel.endif
3312061Sjkh
33217308Speter#
333107516Sru# Upgrade make(1) to the current version using the installed
334174539Simp# headers, libraries and tools.  Also, allow the location of
335174539Simp# the system bsdmake-like utility to be overridden.
33655678Smarcel#
337253616SsjgMMAKEENV=	MAKEOBJDIRPREFIX=${MYMAKE:H} \
338107516Sru		DESTDIR= \
339107516Sru		INSTALL="sh ${.CURDIR}/tools/install.sh"
340174564SimpMMAKE=		${MMAKEENV} ${MAKE} \
341265837Simp		-DNO_MAN -DNO_SHARED \
342264742Sjmmv		-DNO_CPU_CFLAGS -DNO_WERROR \
343268598Sjmmv		MK_TESTS=no \
344265827Simp		DESTDIR= PROGNAME=${MYMAKE:T}
345107516Sru
346265827Simpbmake: .PHONY
34755678Smarcel	@echo
34855678Smarcel	@echo "--------------------------------------------------------------"
349265827Simp	@echo ">>> Building an up-to-date ${.TARGET}(1)"
35055678Smarcel	@echo "--------------------------------------------------------------"
351249395Ssjg	${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
352255713Semaste		${MMAKE} obj && \
353255713Semaste		${MMAKE} depend && \
354255713Semaste		${MMAKE} all && \
355265827Simp		${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR=
35655678Smarcel
357254417Ssjgtinderbox toolchains kernel-toolchains: upgrade_checks
358254417Ssjg
359185499Salfredtinderbox:
360254417Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} DOING_TINDERBOX=YES universe
361185499Salfred
362218524Sjhbtoolchains:
363254417Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
364218524Sjhb
365232907Sjmallettkernel-toolchains:
366254417Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
367232907Sjmallett
36855678Smarcel#
369111131Sru# universe
370111131Sru#
371111131Sru# Attempt to rebuild *everything* for all supported architectures,
372133945Sru# with a reasonable chance of success, regardless of how old your
373111131Sru# existing system is.
374111131Sru#
375217125Simp.if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets)
376281629Semaste# XXX Add arm64 to universe only if we have an external binutils installed.
377282108Sngie# It does not build with the in-tree linker.
378281629Semaste.if exists(/usr/local/aarch64-freebsd/bin/ld)
379282156SemasteUNIVERSE_arm64=arm64
380282156Semaste.elif empty(${TARGETS})
381281629Semasteuniverse: universe_arm64_skip
382281629Semasteuniverse_epilogue: universe_arm64_skip
383281629Semasteuniverse_arm64_skip: universe_prologue
384281629Semaste	@echo ">> arm64 skipped - install aarch64-binutils port or package to build"
385281629Semaste.endif
386282156SemasteTARGETS?=amd64 arm ${UNIVERSE_arm64} i386 mips pc98 powerpc sparc64
387263660SandrewTARGET_ARCHES_arm?=	arm armeb armv6 armv6hf
388282156SemasteTARGET_ARCHES_arm64?=	aarch64
389233644SjmallettTARGET_ARCHES_mips?=	mipsel mips mips64el mips64 mipsn32
390216520SnwhitehornTARGET_ARCHES_powerpc?=	powerpc powerpc64
391216520SnwhitehornTARGET_ARCHES_pc98?=	i386
392216520Snwhitehorn.for target in ${TARGETS}
393216520SnwhitehornTARGET_ARCHES_${target}?= ${target}
394216520Snwhitehorn.endfor
395168280Smarcel
396218524Sjhb.if defined(UNIVERSE_TARGET)
397218524SjhbMAKE_JUST_WORLDS=	YES
398218524Sjhb.else
399218524SjhbUNIVERSE_TARGET?=	buildworld
400218524Sjhb.endif
401219137SjhbKERNSRCDIR?=		${.CURDIR}/sys
402218524Sjhb
403217125Simptargets:
404217815Sbz	@echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
405217125Simp.for target in ${TARGETS}
406217125Simp.for target_arch in ${TARGET_ARCHES_${target}}
407217125Simp	@echo "    ${target}/${target_arch}"
408217125Simp.endfor
409217125Simp.endfor
410217125Simp
411185499Salfred.if defined(DOING_TINDERBOX)
412217735SbzFAILFILE=${.CURDIR}/_.tinderbox.failed
413185499SalfredMAKEFAIL=tee -a ${FAILFILE}
414185499Salfred.else
415185499SalfredMAKEFAIL=cat
416185499Salfred.endif
417185499Salfred
418253616Ssjguniverse_prologue:  upgrade_checks
419253616Ssjguniverse: universe_prologue
420133945Sruuniverse_prologue:
421103985Sphk	@echo "--------------------------------------------------------------"
422103985Sphk	@echo ">>> make universe started on ${STARTTIME}"
423103985Sphk	@echo "--------------------------------------------------------------"
424185499Salfred.if defined(DOING_TINDERBOX)
425217754Sbz	@rm -f ${FAILFILE}
426185499Salfred.endif
427168280Smarcel.for target in ${TARGETS}
428162147Sruuniverse: universe_${target}
429253616Ssjguniverse_epilogue: universe_${target}
430216520Snwhitehornuniverse_${target}: universe_${target}_prologue
431253616Ssjguniverse_${target}_prologue: universe_prologue
432216520Snwhitehorn	@echo ">> ${target} started on `LC_ALL=C date`"
433179232Sjb.if !defined(MAKE_JUST_KERNELS)
434216520Snwhitehorn.for target_arch in ${TARGET_ARCHES_${target}}
435216520Snwhitehornuniverse_${target}: universe_${target}_${target_arch}
436254417Ssjguniverse_${target}_${target_arch}: universe_${target}_prologue .MAKE
437218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
438185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
439253616Ssjg	    ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
440162147Sru	    TARGET=${target} \
441216520Snwhitehorn	    TARGET_ARCH=${target_arch} \
442218524Sjhb	    > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
443218524Sjhb	    (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
444218524Sjhb	    "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
445216520Snwhitehorn	    ${MAKEFAIL}))
446218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
447216520Snwhitehorn.endfor
448179232Sjb.endif
449205290Sdougb.if !defined(MAKE_JUST_WORLDS)
450248937Sandrew# If we are building world and kernels wait for the required worlds to finish
451248937Sandrew.if !defined(MAKE_JUST_KERNELS)
452248937Sandrew.for target_arch in ${TARGET_ARCHES_${target}}
453248937Sandrewuniverse_${target}_kernels: universe_${target}_${target_arch}
454248937Sandrew.endfor
455248937Sandrew.endif
456248937Sandrewuniverse_${target}: universe_${target}_kernels
457254417Ssjguniverse_${target}_kernels: universe_${target}_prologue .MAKE
458219137Sjhb.if exists(${KERNSRCDIR}/${target}/conf/NOTES)
459219137Sjhb	@(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
460253616Ssjg	    ${SUB_MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
461185499Salfred	    (echo "${target} 'make LINT' failed," \
462185499Salfred	    "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
463103985Sphk.endif
464253616Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
465201815Sbz	    universe_kernels
466205290Sdougb.endif
467201815Sbz	@echo ">> ${target} completed on `LC_ALL=C date`"
468201815Sbz.endfor
469201815Sbzuniverse_kernels: universe_kernconfs
470202095Sbz.if !defined(TARGET)
471202095SbzTARGET!=	uname -m
472202095Sbz.endif
473265155Simp.if defined(MAKE_ALL_KERNELS)
474265155Simp_THINNER=cat
475265155Simp.else
476265840Simp_THINNER=xargs grep -L "^.NO_UNIVERSE" || true
477265155Simp.endif
478219137SjhbKERNCONFS!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
479201815Sbz		find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \
480265155Simp		! -name DEFAULTS ! -name NOTES | \
481265155Simp		${_THINNER}
482201815Sbzuniverse_kernconfs:
483148154Sru.for kernel in ${KERNCONFS}
484219137SjhbTARGET_ARCH_${kernel}!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
485219137Sjhb	config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
486216934Simp	grep -v WARNING: | cut -f 2
487216934Simp.if empty(TARGET_ARCH_${kernel})
488216934Simp.error "Target architecture for ${TARGET}/conf/${kernel} unknown.  config(8) likely too old."
489216934Simp.endif
490216520Snwhitehornuniverse_kernconfs: universe_kernconf_${TARGET}_${kernel}
491254417Ssjguniverse_kernconf_${TARGET}_${kernel}: .MAKE
492185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
493253616Ssjg	    ${SUB_MAKE} ${JFLAG} buildkernel \
494201815Sbz	    TARGET=${TARGET} \
495216520Snwhitehorn	    TARGET_ARCH=${TARGET_ARCH_${kernel}} \
496148154Sru	    KERNCONF=${kernel} \
497201815Sbz	    > _.${TARGET}.${kernel} 2>&1 || \
498201815Sbz	    (echo "${TARGET} ${kernel} kernel failed," \
499201815Sbz	    "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
500148154Sru.endfor
501133945Sruuniverse: universe_epilogue
502133945Sruuniverse_epilogue:
503103985Sphk	@echo "--------------------------------------------------------------"
504118531Sru	@echo ">>> make universe completed on `LC_ALL=C date`"
505118531Sru	@echo "                      (started ${STARTTIME})"
506103985Sphk	@echo "--------------------------------------------------------------"
507185499Salfred.if defined(DOING_TINDERBOX)
508185499Salfred	@if [ -e ${FAILFILE} ] ; then \
509185499Salfred		echo "Tinderbox failed:" ;\
510185499Salfred		cat ${FAILFILE} ;\
511185499Salfred		exit 1 ;\
512185499Salfred	fi
513133945Sru.endif
514185499Salfred.endif
515242522Smarcel
516242522SmarcelbuildLINT:
517242522Smarcel	${MAKE} -C ${.CURDIR}/sys/${_TARGET}/conf LINT
518255286Ssjg
519255286Ssjg.if defined(.PARSEDIR)
520255286Ssjg.if make(universe)
521255286Ssjg# we do not want a failure of one branch abort all.
522255286SsjgMAKE_JOB_ERROR_TOKEN= no
523255286Ssjg.export MAKE_JOB_ERROR_TOKEN
524255286Ssjg.endif
525255286Ssjg.endif
526