12061Sjkh#
250479Speter# $FreeBSD$
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.
35253002Salfred# 
36253002Salfred# "quick" way to test all kernel builds:
37253002Salfred# 	_jflag=`sysctl -n hw.ncpu`
38253002Salfred# 	_jflag=$(($_jflag * 2))
39253002Salfred# 	[ $_jflag -gt 12 ] && _jflag=12
40253003Salfred# 	make universe -DMAKE_JUST_KERNELS JFLAG=-j${_jflag}
4132427Sjb#
4238666Sjb# This makefile is simple by design. The FreeBSD make automatically reads
43108451Sschweikh# the /usr/share/mk/sys.mk unless the -m argument is specified on the
4438666Sjb# command line. By keeping this makefile simple, it doesn't matter too
4538666Sjb# much how different the installed mk files are from those in the source
4638666Sjb# tree. This makefile executes a child make process, forcing it to use
4738666Sjb# the mk files from the source tree which are supposed to DTRT.
4817308Speter#
49217273Simp# Most of the user-driven targets (as listed above) are implemented in
50217294Simp# Makefile.inc1.  The exceptions are universe, tinderbox and targets.
5119175Sbde#
5296205Sjwd# If you want to build your system from source be sure that /usr/obj has
53217297Simp# at least 1GB of diskspace available.  A complete 'universe' build requires
54217297Simp# about 15GB of space.
5538042Sbde#
5696205Sjwd# For individuals wanting to build from the sources currently on their
5796205Sjwd# system, the simple instructions are:
5838042Sbde#
5996205Sjwd# 1.  `cd /usr/src'  (or to the directory containing your source tree).
60159363Strhodes# 2.  Define `HISTORICAL_MAKE_WORLD' variable (see README).
61159363Strhodes# 3.  `make world'
6217308Speter#
6396205Sjwd# For individuals wanting to upgrade their sources (even if only a
6496205Sjwd# delta of a few days):
6517308Speter#
66148330Snetchild#  1.  `cd /usr/src'       (or to the directory containing your source tree).
67148330Snetchild#  2.  `make buildworld'
68148330Snetchild#  3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
69148330Snetchild#  4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
70159831Sobrien#       [steps 3. & 4. can be combined by using the "kernel" target]
71148330Snetchild#  5.  `reboot'        (in single user mode: boot -s from the loader prompt).
72148330Snetchild#  6.  `mergemaster -p'
73148330Snetchild#  7.  `make installworld'
74251107Screes#  8.  `mergemaster'		(you may wish to use -i, along with -U or -F).
75251107Screes#  9.  `make delete-old'
76148330Snetchild# 10.  `reboot'
77148330Snetchild# 11.  `make delete-old-libs' (in case no 3rd party program uses them anymore)
7896205Sjwd#
7996205Sjwd# See src/UPDATING `COMMON ITEMS' for more complete information.
8096205Sjwd#
81162147Sru# If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can
82162147Sru# cross build world for other machine types using the buildworld target,
8398723Sdillon# and once the world is built you can cross build a kernel using the
8498723Sdillon# buildkernel target.
8598723Sdillon#
8638666Sjb# Define the user-driven targets. These are listed here in alphabetical
8738666Sjb# order, but that's not important.
8817308Speter#
89123311Speter# Targets that begin with underscore are internal targets intended for
90123311Speter# developer convenience only.  They are intentionally not documented and
91123311Speter# completely subject to change without notice.
92123311Speter#
93175833Sjhb# For more information, see the build(7) manual page.
94175833Sjhb#
95169597SdesTGTS=	all all-man buildenv buildenvvars buildkernel buildworld \
96169597Sdes	check-old check-old-dirs check-old-files check-old-libs \
97169597Sdes	checkdpadd clean cleandepend cleandir \
98169597Sdes	delete-old delete-old-dirs delete-old-files delete-old-libs \
99219177Snwhitehorn	depend distribute distributekernel distributekernel.debug \
100219177Snwhitehorn	distributeworld distrib-dirs distribution doxygen \
101238051Sobrien	everything hier hierarchy install installcheck installkernel \
102219177Snwhitehorn	installkernel.debug packagekernel packageworld \
103219177Snwhitehorn	reinstallkernel reinstallkernel.debug \
104158962Snetchild	installworld kernel-toolchain libraries lint maninstall \
105156840Sru	obj objlink regress rerelease showconfig tags toolchain update \
106123311Speter	_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
107137288Speter	_build-tools _cross-tools _includes _libraries _depend \
108209128Sraj	build32 builddtb distribute32 install32 xdev xdev-build xdev-install \
109209128Sraj
110156740SruTGTS+=	${SUBDIR_TARGETS}
1112061Sjkh
11297769SruBITGTS=	files includes
11397252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
114119579SruTGTS+=	${BITGTS}
11597252Sru
11695730Sru.ORDER: buildworld installworld
11795793Sru.ORDER: buildworld distributeworld
118111617Sru.ORDER: buildworld buildkernel
11995730Sru.ORDER: buildkernel installkernel
120116679Ssimokawa.ORDER: buildkernel installkernel.debug
12195730Sru.ORDER: buildkernel reinstallkernel
122116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug
12395730Sru
124110035SruPATH=	/sbin:/bin:/usr/sbin:/usr/bin
125107516SruMAKEOBJDIRPREFIX?=	/usr/obj
126138921Sru_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
127156145Syar    ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
128138921Sru    -f /dev/null -V MAKEOBJDIRPREFIX dummy
129133942Sru.if !empty(_MAKEOBJDIRPREFIX)
130133942Sru.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
131156145Syar	(in make.conf(5)) or command-line variable.
132133942Sru.endif
133253616Ssjg
134253616Ssjg# We often need to use the tree's version of make to build it.
135253616Ssjg# Choices add to complexity though.
136253616Ssjg# We cannot blindly use a make which may not be the one we want
137253616Ssjg# so be exlicit - until all choice is removed.
138253616Ssjg.if !defined(WITHOUT_BMAKE)
139253616SsjgWANT_MAKE=	bmake
140253616Ssjg.else
141253616SsjgWANT_MAKE=	fmake
142253616Ssjg.endif
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
151253616Ssjg.elif ${WANT_MAKE} != ${HAVE_MAKE} || ${WANT_MAKE} != "bmake"
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}
167239272Sgonzo_TARGET=		${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/}
168218130Simp.endif
169233644Sjmallett# Legacy names, for another transition period mips:mips(n32|64)?eb -> mips:mips\1
170218130Simp.if defined(TARGET) && defined(TARGET_ARCH) && \
171233644Sjmallett    ${TARGET} == "mips" && ${TARGET_ARCH:Mmips*eb}
172233644Sjmallett_TARGET_ARCH=		${TARGET_ARCH:C/eb$//}
173233644Sjmallett.warning "TARGET_ARCH of ${TARGET_ARCH} is deprecated in favor of ${_TARGET_ARCH}"
174218130Simp.endif
175233644Sjmallett.if defined(TARGET) && ${TARGET} == "mips" && defined(TARGET_BIG_ENDIAN)
176233644Sjmallett.warning "TARGET_BIG_ENDIAN is no longer necessary for MIPS.  Big-endian is not the default."
177218130Simp.endif
178218130Simp# arm with TARGET_BIG_ENDIAN -> armeb
179218130Simp.if defined(TARGET_ARCH) && ${TARGET_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN)
180218130Simp.warning "TARGET_ARCH of arm with TARGET_BIG_ENDIAN is deprecated.  use armeb"
181218130Simp_TARGET_ARCH=armeb
182218130Simp.endif
183218130Simp.if defined(TARGET) && !defined(_TARGET)
184218130Simp_TARGET=${TARGET}
185218130Simp.endif
186218130Simp.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
187218130Simp_TARGET_ARCH=${TARGET_ARCH}
188218130Simp.endif
189218130Simp# Otherwise, default to current machine type and architecture.
190218130Simp_TARGET?=	${MACHINE}
191218130Simp_TARGET_ARCH?=	${MACHINE_ARCH}
192218130Simp
19317308Speter#
194119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld
195119519Smarcel# should do this as those are the initial targets used for upgrades.
196119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed
197119519Smarcel# for all targets.
198119519Smarcel#
199119519Smarcel.if defined(ALWAYS_CHECK_MAKE)
200119579Sru${TGTS}: upgrade_checks
201119519Smarcel.else
202119519Smarcelbuildworld: upgrade_checks
203119519Smarcel.endif
204119519Smarcel
205119519Smarcel#
206126031Sgad# This 'cleanworld' target is not included in TGTS, because it is not a
207126024Sgad# recursive target.  All of the work for it is done right here.   It is
208126024Sgad# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
209126024Sgad# created by bsd.obj.mk, except that we don't want to .include that file
210126024Sgad# in this makefile.  
211126024Sgad#
212126024Sgad# In the following, the first 'rm' in a series will usually remove all
213126024Sgad# files and directories.  If it does not, then there are probably some
214227771Sgjb# files with file flags set, so this unsets them and tries the 'rm' a
215126024Sgad# second time.  There are situations where this target will be cleaning
216126024Sgad# some directories via more than one method, but that duplication is
217227769Sgjb# needed to correctly handle all the possible situations.  Removing all
218227771Sgjb# files without file flags set in the first 'rm' instance saves time,
219227771Sgjb# because 'chflags' will need to operate on fewer files afterwards.
220126024Sgad#
221126024SgadBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
222126031Sgadcleanworld:
223126024Sgad.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
224126024Sgad.if exists(${BW_CANONICALOBJDIR}/)
225126024Sgad	-rm -rf ${BW_CANONICALOBJDIR}/*
226172744Sdelphij	-chflags -R 0 ${BW_CANONICALOBJDIR}
227126024Sgad	rm -rf ${BW_CANONICALOBJDIR}/*
228126024Sgad.endif
229126024Sgad	#   To be safe in this case, fall back to a 'make cleandir'
230133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
231126024Sgad.else
232126024Sgad	-rm -rf ${.OBJDIR}/*
233172744Sdelphij	-chflags -R 0 ${.OBJDIR}
234126024Sgad	rm -rf ${.OBJDIR}/*
235126024Sgad.endif
236125885Sgad
237125885Sgad#
23838666Sjb# Handle the user-driven targets, using the source relative mk files.
23917308Speter#
240119519Smarcel
241251750Ssjg.if empty(.MAKEFLAGS:M-n)
242251750Ssjg# skip this for -n to avoid changing previous behavior of 
243251750Ssjg# 'make -n buildworld' etc.
244251750Ssjg${TGTS}: .MAKE
245254417Ssjgtinderbox toolchains kernel-toolchains: .MAKE
246251750Ssjg.endif
247251750Ssjg
248119579Sru${TGTS}:
249218206Simp	${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
2502302Spaul
25139206Sjkh# Set a reasonable default
25239206Sjkh.MAIN:	all
25339206Sjkh
254133945SruSTARTTIME!= LC_ALL=C date
255240403SobrienCHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo
256177609Sru.if !empty(CHECK_TIME)
257177609Sru.error check your date/time: ${STARTTIME}
258177609Sru.endif
259133945Sru
260132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
26117308Speter#
26254324Smarcel# world
26354324Smarcel#
264132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be
265132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is
266132234Smarcel# not included. One can argue that this target doesn't build everything
267132234Smarcel# then.
26854324Smarcel#
26954324Smarcelworld: upgrade_checks
27054324Smarcel	@echo "--------------------------------------------------------------"
271118531Sru	@echo ">>> make world started on ${STARTTIME}"
27254324Smarcel	@echo "--------------------------------------------------------------"
27354324Smarcel.if target(pre-world)
27454324Smarcel	@echo
27554324Smarcel	@echo "--------------------------------------------------------------"
27654324Smarcel	@echo ">>> Making 'pre-world' target"
27754324Smarcel	@echo "--------------------------------------------------------------"
278133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
27954324Smarcel.endif
280133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
281133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
28254324Smarcel.if target(post-world)
28354324Smarcel	@echo
28454324Smarcel	@echo "--------------------------------------------------------------"
28554324Smarcel	@echo ">>> Making 'post-world' target"
28654324Smarcel	@echo "--------------------------------------------------------------"
287133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
28854324Smarcel.endif
28954324Smarcel	@echo
29054324Smarcel	@echo "--------------------------------------------------------------"
291118531Sru	@echo ">>> make world completed on `LC_ALL=C date`"
292118531Sru	@echo "                   (started ${STARTTIME})"
29354324Smarcel	@echo "--------------------------------------------------------------"
294132234Smarcel.else
295132234Smarcelworld:
296132234Smarcel	@echo "WARNING: make world will overwrite your existing FreeBSD"
297132234Smarcel	@echo "installation without also building and installing a new"
298132234Smarcel	@echo "kernel.  This can be dangerous.  Please read the handbook,"
299132588Skensmith	@echo "'Rebuilding world', for how to upgrade your system."
300132358Smarkm	@echo "Define DESTDIR to where you want to install FreeBSD,"
301132234Smarcel	@echo "including /, to override this warning and proceed as usual."
302132358Smarkm	@echo ""
303132234Smarcel	@echo "Bailing out now..."
304132234Smarcel	@false
305132234Smarcel.endif
30654324Smarcel
30754324Smarcel#
30895730Sru# kernel
30995730Sru#
31095730Sru# Short hand for `make buildkernel installkernel'
31195730Sru#
31295730Srukernel: buildkernel installkernel
31395730Sru
31495730Sru#
31538666Sjb# Perform a few tests to determine if the installed tools are adequate
316107374Sru# for building the world.
31717308Speter#
318253616Ssjg# Note: if we ever need to care about the version of bmake, simply testing
319253616Ssjg# MAKE_VERSION against a required version should suffice.
320253616Ssjg#
32155678Smarcelupgrade_checks:
322253616Ssjg.if ${HAVE_MAKE} != ${WANT_MAKE}
323253616Ssjg	@(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
324253616Ssjg.elif ${WANT_MAKE} == "fmake"
325143032Sharti	@if ! (cd ${.CURDIR}/tools/build/make_check && \
326138515Sharti	    PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \
327117793Sru	    PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
328110035Sru	then \
329174564Simp	    (cd ${.CURDIR} && ${MAKE} make); \
330110035Sru	fi
331241298Smarcel.endif
3322061Sjkh
33317308Speter#
334107516Sru# Upgrade make(1) to the current version using the installed
335174539Simp# headers, libraries and tools.  Also, allow the location of
336174539Simp# the system bsdmake-like utility to be overridden.
33755678Smarcel#
338253616SsjgMMAKEENV=	MAKEOBJDIRPREFIX=${MYMAKE:H} \
339107516Sru		DESTDIR= \
340107516Sru		INSTALL="sh ${.CURDIR}/tools/install.sh"
341174564SimpMMAKE=		${MMAKEENV} ${MAKE} \
342107516Sru		-D_UPGRADING \
343139112Sru		-DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \
344255713Semaste		-DNO_CPU_CFLAGS -DNO_WERROR DESTDIR= PROGNAME=${MYMAKE:T}
345107516Sru
346249395Ssjgmake bmake: .PHONY
34755678Smarcel	@echo
34855678Smarcel	@echo "--------------------------------------------------------------"
349116696Sru	@echo ">>> Building an up-to-date make(1)"
35055678Smarcel	@echo "--------------------------------------------------------------"
351249395Ssjg	${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
352255713Semaste		${MMAKE} obj && \
353255713Semaste		${MMAKE} depend && \
354255713Semaste		${MMAKE} all && \
355255713Semaste		${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)
376221869SattilioTARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64
377255784SandrewTARGET_ARCHES_arm?=	arm armeb armv6
378233644SjmallettTARGET_ARCHES_mips?=	mipsel mips mips64el mips64 mipsn32
379216520SnwhitehornTARGET_ARCHES_powerpc?=	powerpc powerpc64
380216520SnwhitehornTARGET_ARCHES_pc98?=	i386
381216520Snwhitehorn.for target in ${TARGETS}
382216520SnwhitehornTARGET_ARCHES_${target}?= ${target}
383216520Snwhitehorn.endfor
384168280Smarcel
385218524Sjhb.if defined(UNIVERSE_TARGET)
386218524SjhbMAKE_JUST_WORLDS=	YES
387218524Sjhb.else
388218524SjhbUNIVERSE_TARGET?=	buildworld
389218524Sjhb.endif
390219137SjhbKERNSRCDIR?=		${.CURDIR}/sys
391218524Sjhb
392217125Simptargets:
393217815Sbz	@echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
394217125Simp.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
416168280Smarcel.for target in ${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`"
422179232Sjb.if !defined(MAKE_JUST_KERNELS)
423216520Snwhitehorn.for target_arch in ${TARGET_ARCHES_${target}}
424216520Snwhitehornuniverse_${target}: universe_${target}_${target_arch}
425254417Ssjguniverse_${target}_${target_arch}: universe_${target}_prologue .MAKE
426218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
427185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
428253616Ssjg	    ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
429162147Sru	    TARGET=${target} \
430216520Snwhitehorn	    TARGET_ARCH=${target_arch} \
431218524Sjhb	    > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
432218524Sjhb	    (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
433218524Sjhb	    "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
434216520Snwhitehorn	    ${MAKEFAIL}))
435218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
436216520Snwhitehorn.endfor
437179232Sjb.endif
438205290Sdougb.if !defined(MAKE_JUST_WORLDS)
439248937Sandrew# If we are building world and kernels wait for the required worlds to finish
440248937Sandrew.if !defined(MAKE_JUST_KERNELS)
441248937Sandrew.for target_arch in ${TARGET_ARCHES_${target}}
442248937Sandrewuniverse_${target}_kernels: universe_${target}_${target_arch}
443248937Sandrew.endfor
444248937Sandrew.endif
445248937Sandrewuniverse_${target}: universe_${target}_kernels
446254417Ssjguniverse_${target}_kernels: universe_${target}_prologue .MAKE
447219137Sjhb.if exists(${KERNSRCDIR}/${target}/conf/NOTES)
448219137Sjhb	@(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
449253616Ssjg	    ${SUB_MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
450185499Salfred	    (echo "${target} 'make LINT' failed," \
451185499Salfred	    "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
452103985Sphk.endif
453253616Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
454201815Sbz	    universe_kernels
455205290Sdougb.endif
456201815Sbz	@echo ">> ${target} completed on `LC_ALL=C date`"
457201815Sbz.endfor
458201815Sbzuniverse_kernels: universe_kernconfs
459202095Sbz.if !defined(TARGET)
460202095SbzTARGET!=	uname -m
461202095Sbz.endif
462219137SjhbKERNCONFS!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
463201815Sbz		find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \
464201815Sbz		! -name DEFAULTS ! -name NOTES
465201815Sbzuniverse_kernconfs:
466148154Sru.for kernel in ${KERNCONFS}
467219137SjhbTARGET_ARCH_${kernel}!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
468219137Sjhb	config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
469216934Simp	grep -v WARNING: | cut -f 2
470216934Simp.if empty(TARGET_ARCH_${kernel})
471216934Simp.error "Target architecture for ${TARGET}/conf/${kernel} unknown.  config(8) likely too old."
472216934Simp.endif
473216520Snwhitehornuniverse_kernconfs: universe_kernconf_${TARGET}_${kernel}
474254417Ssjguniverse_kernconf_${TARGET}_${kernel}: .MAKE
475185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
476253616Ssjg	    ${SUB_MAKE} ${JFLAG} buildkernel \
477201815Sbz	    TARGET=${TARGET} \
478216520Snwhitehorn	    TARGET_ARCH=${TARGET_ARCH_${kernel}} \
479148154Sru	    KERNCONF=${kernel} \
480201815Sbz	    > _.${TARGET}.${kernel} 2>&1 || \
481201815Sbz	    (echo "${TARGET} ${kernel} kernel failed," \
482201815Sbz	    "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
483148154Sru.endfor
484133945Sruuniverse: universe_epilogue
485133945Sruuniverse_epilogue:
486103985Sphk	@echo "--------------------------------------------------------------"
487118531Sru	@echo ">>> make universe completed on `LC_ALL=C date`"
488118531Sru	@echo "                      (started ${STARTTIME})"
489103985Sphk	@echo "--------------------------------------------------------------"
490185499Salfred.if defined(DOING_TINDERBOX)
491185499Salfred	@if [ -e ${FAILFILE} ] ; then \
492185499Salfred		echo "Tinderbox failed:" ;\
493185499Salfred		cat ${FAILFILE} ;\
494185499Salfred		exit 1 ;\
495185499Salfred	fi
496133945Sru.endif
497185499Salfred.endif
498242522Smarcel
499242522SmarcelbuildLINT:
500242522Smarcel	${MAKE} -C ${.CURDIR}/sys/${_TARGET}/conf LINT
501255286Ssjg
502255286Ssjg.if defined(.PARSEDIR)
503255286Ssjg.if make(universe)
504255286Ssjg# we do not want a failure of one branch abort all.
505255286SsjgMAKE_JOB_ERROR_TOKEN= no
506255286Ssjg.export MAKE_JOB_ERROR_TOKEN
507255286Ssjg.endif
508255286Ssjg.endif
509