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.
35264811Sbrueffer# xdev                - xdev-build + xdev-install for the architecture
36264811Sbrueffer#                       specified with XDEV and XDEV_ARCH.
37264811Sbrueffer# xdev-build          - Build cross-development tools.
38264811Sbrueffer# 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.
142253616Ssjg.if !defined(WITHOUT_BMAKE)
143253616SsjgWANT_MAKE=	bmake
144253616Ssjg.else
145253616SsjgWANT_MAKE=	fmake
146253616Ssjg.endif
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
155253616Ssjg.elif ${WANT_MAKE} != ${HAVE_MAKE} || ${WANT_MAKE} != "bmake"
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)
168233644Sjmallett_TARGET_ARCH=	${TARGET:S/pc98/i386/}
169218130Simp.elif !defined(TARGET) && defined(TARGET_ARCH) && \
170218130Simp    ${TARGET_ARCH} != ${MACHINE_ARCH}
171239272Sgonzo_TARGET=		${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/}
172218130Simp.endif
173233644Sjmallett# Legacy names, for another transition period mips:mips(n32|64)?eb -> mips:mips\1
174218130Simp.if defined(TARGET) && defined(TARGET_ARCH) && \
175233644Sjmallett    ${TARGET} == "mips" && ${TARGET_ARCH:Mmips*eb}
176233644Sjmallett_TARGET_ARCH=		${TARGET_ARCH:C/eb$//}
177233644Sjmallett.warning "TARGET_ARCH of ${TARGET_ARCH} is deprecated in favor of ${_TARGET_ARCH}"
178218130Simp.endif
179233644Sjmallett.if defined(TARGET) && ${TARGET} == "mips" && defined(TARGET_BIG_ENDIAN)
180233644Sjmallett.warning "TARGET_BIG_ENDIAN is no longer necessary for MIPS.  Big-endian is not the default."
181218130Simp.endif
182218130Simp# arm with TARGET_BIG_ENDIAN -> armeb
183218130Simp.if defined(TARGET_ARCH) && ${TARGET_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN)
184218130Simp.warning "TARGET_ARCH of arm with TARGET_BIG_ENDIAN is deprecated.  use armeb"
185218130Simp_TARGET_ARCH=armeb
186218130Simp.endif
187218130Simp.if defined(TARGET) && !defined(_TARGET)
188218130Simp_TARGET=${TARGET}
189218130Simp.endif
190218130Simp.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
191218130Simp_TARGET_ARCH=${TARGET_ARCH}
192218130Simp.endif
193218130Simp# Otherwise, default to current machine type and architecture.
194218130Simp_TARGET?=	${MACHINE}
195218130Simp_TARGET_ARCH?=	${MACHINE_ARCH}
196218130Simp
19717308Speter#
198119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld
199119519Smarcel# should do this as those are the initial targets used for upgrades.
200119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed
201119519Smarcel# for all targets.
202119519Smarcel#
203119519Smarcel.if defined(ALWAYS_CHECK_MAKE)
204119579Sru${TGTS}: upgrade_checks
205119519Smarcel.else
206119519Smarcelbuildworld: upgrade_checks
207119519Smarcel.endif
208119519Smarcel
209119519Smarcel#
210126031Sgad# This 'cleanworld' target is not included in TGTS, because it is not a
211126024Sgad# recursive target.  All of the work for it is done right here.   It is
212126024Sgad# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
213126024Sgad# created by bsd.obj.mk, except that we don't want to .include that file
214126024Sgad# in this makefile.  
215126024Sgad#
216126024Sgad# In the following, the first 'rm' in a series will usually remove all
217126024Sgad# files and directories.  If it does not, then there are probably some
218227771Sgjb# files with file flags set, so this unsets them and tries the 'rm' a
219126024Sgad# second time.  There are situations where this target will be cleaning
220126024Sgad# some directories via more than one method, but that duplication is
221227769Sgjb# needed to correctly handle all the possible situations.  Removing all
222227771Sgjb# files without file flags set in the first 'rm' instance saves time,
223227771Sgjb# because 'chflags' will need to operate on fewer files afterwards.
224126024Sgad#
225126024SgadBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
226126031Sgadcleanworld:
227126024Sgad.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
228126024Sgad.if exists(${BW_CANONICALOBJDIR}/)
229126024Sgad	-rm -rf ${BW_CANONICALOBJDIR}/*
230172744Sdelphij	-chflags -R 0 ${BW_CANONICALOBJDIR}
231126024Sgad	rm -rf ${BW_CANONICALOBJDIR}/*
232126024Sgad.endif
233126024Sgad	#   To be safe in this case, fall back to a 'make cleandir'
234133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
235126024Sgad.else
236126024Sgad	-rm -rf ${.OBJDIR}/*
237172744Sdelphij	-chflags -R 0 ${.OBJDIR}
238126024Sgad	rm -rf ${.OBJDIR}/*
239126024Sgad.endif
240125885Sgad
241125885Sgad#
24238666Sjb# Handle the user-driven targets, using the source relative mk files.
24317308Speter#
244119519Smarcel
245251750Ssjg.if empty(.MAKEFLAGS:M-n)
246251750Ssjg# skip this for -n to avoid changing previous behavior of 
247251750Ssjg# 'make -n buildworld' etc.
248251750Ssjg${TGTS}: .MAKE
249254417Ssjgtinderbox toolchains kernel-toolchains: .MAKE
250251750Ssjg.endif
251251750Ssjg
252119579Sru${TGTS}:
253218206Simp	${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
2542302Spaul
255265449Sbrooks# The historic default "all" target creates files which may cause stale
256265449Sbrooks# or (in the cross build case) unlinkable results. Fail with an error
257265449Sbrooks# when no target is given. The users can explicitly specify "all"
258265449Sbrooks# if they want the historic behavior.
259265449Sbrooks.MAIN:	_guard
26039206Sjkh
261265449Sbrooks_guard:
262265449Sbrooks	@echo
263265449Sbrooks	@echo "Explicit target required (use \"all\" for historic behavior)"
264265449Sbrooks	@echo
265265449Sbrooks	@false
266265449Sbrooks
267133945SruSTARTTIME!= LC_ALL=C date
268240403SobrienCHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo
269177609Sru.if !empty(CHECK_TIME)
270177609Sru.error check your date/time: ${STARTTIME}
271177609Sru.endif
272133945Sru
273132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
27417308Speter#
27554324Smarcel# world
27654324Smarcel#
277132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be
278132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is
279132234Smarcel# not included. One can argue that this target doesn't build everything
280132234Smarcel# then.
28154324Smarcel#
28254324Smarcelworld: upgrade_checks
28354324Smarcel	@echo "--------------------------------------------------------------"
284118531Sru	@echo ">>> make world started on ${STARTTIME}"
28554324Smarcel	@echo "--------------------------------------------------------------"
28654324Smarcel.if target(pre-world)
28754324Smarcel	@echo
28854324Smarcel	@echo "--------------------------------------------------------------"
28954324Smarcel	@echo ">>> Making 'pre-world' target"
29054324Smarcel	@echo "--------------------------------------------------------------"
291133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
29254324Smarcel.endif
293133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
294133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
29554324Smarcel.if target(post-world)
29654324Smarcel	@echo
29754324Smarcel	@echo "--------------------------------------------------------------"
29854324Smarcel	@echo ">>> Making 'post-world' target"
29954324Smarcel	@echo "--------------------------------------------------------------"
300133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
30154324Smarcel.endif
30254324Smarcel	@echo
30354324Smarcel	@echo "--------------------------------------------------------------"
304118531Sru	@echo ">>> make world completed on `LC_ALL=C date`"
305118531Sru	@echo "                   (started ${STARTTIME})"
30654324Smarcel	@echo "--------------------------------------------------------------"
307132234Smarcel.else
308132234Smarcelworld:
309132234Smarcel	@echo "WARNING: make world will overwrite your existing FreeBSD"
310132234Smarcel	@echo "installation without also building and installing a new"
311132234Smarcel	@echo "kernel.  This can be dangerous.  Please read the handbook,"
312132588Skensmith	@echo "'Rebuilding world', for how to upgrade your system."
313132358Smarkm	@echo "Define DESTDIR to where you want to install FreeBSD,"
314132234Smarcel	@echo "including /, to override this warning and proceed as usual."
315132358Smarkm	@echo ""
316132234Smarcel	@echo "Bailing out now..."
317132234Smarcel	@false
318132234Smarcel.endif
31954324Smarcel
32054324Smarcel#
32195730Sru# kernel
32295730Sru#
32395730Sru# Short hand for `make buildkernel installkernel'
32495730Sru#
32595730Srukernel: buildkernel installkernel
32695730Sru
32795730Sru#
32838666Sjb# Perform a few tests to determine if the installed tools are adequate
329107374Sru# for building the world.
33017308Speter#
331253616Ssjg# Note: if we ever need to care about the version of bmake, simply testing
332253616Ssjg# MAKE_VERSION against a required version should suffice.
333253616Ssjg#
33455678Smarcelupgrade_checks:
335253616Ssjg.if ${HAVE_MAKE} != ${WANT_MAKE}
336253616Ssjg	@(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
337253616Ssjg.elif ${WANT_MAKE} == "fmake"
338143032Sharti	@if ! (cd ${.CURDIR}/tools/build/make_check && \
339138515Sharti	    PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \
340117793Sru	    PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
341110035Sru	then \
342174564Simp	    (cd ${.CURDIR} && ${MAKE} make); \
343110035Sru	fi
344241298Smarcel.endif
3452061Sjkh
34617308Speter#
347107516Sru# Upgrade make(1) to the current version using the installed
348174539Simp# headers, libraries and tools.  Also, allow the location of
349174539Simp# the system bsdmake-like utility to be overridden.
35055678Smarcel#
351253616SsjgMMAKEENV=	MAKEOBJDIRPREFIX=${MYMAKE:H} \
352107516Sru		DESTDIR= \
353107516Sru		INSTALL="sh ${.CURDIR}/tools/install.sh"
354174564SimpMMAKE=		${MMAKEENV} ${MAKE} \
355107516Sru		-D_UPGRADING \
356139112Sru		-DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \
357264996Sjmmv		-DNO_CPU_CFLAGS -DNO_WERROR \
358264996Sjmmv		DESTDIR= MK_TESTS=no PROGNAME=${MYMAKE:T}
359107516Sru
360249395Ssjgmake bmake: .PHONY
36155678Smarcel	@echo
36255678Smarcel	@echo "--------------------------------------------------------------"
363116696Sru	@echo ">>> Building an up-to-date make(1)"
36455678Smarcel	@echo "--------------------------------------------------------------"
365249395Ssjg	${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
366255713Semaste		${MMAKE} obj && \
367255713Semaste		${MMAKE} depend && \
368255713Semaste		${MMAKE} all && \
369255713Semaste		${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR=
37055678Smarcel
371254417Ssjgtinderbox toolchains kernel-toolchains: upgrade_checks
372254417Ssjg
373185499Salfredtinderbox:
374254417Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} DOING_TINDERBOX=YES universe
375185499Salfred
376218524Sjhbtoolchains:
377254417Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
378218524Sjhb
379232907Sjmallettkernel-toolchains:
380254417Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
381232907Sjmallett
38255678Smarcel#
383111131Sru# universe
384111131Sru#
385111131Sru# Attempt to rebuild *everything* for all supported architectures,
386133945Sru# with a reasonable chance of success, regardless of how old your
387111131Sru# existing system is.
388111131Sru#
389217125Simp.if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets)
390221869SattilioTARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64
391255784SandrewTARGET_ARCHES_arm?=	arm armeb armv6
392233644SjmallettTARGET_ARCHES_mips?=	mipsel mips mips64el mips64 mipsn32
393216520SnwhitehornTARGET_ARCHES_powerpc?=	powerpc powerpc64
394216520SnwhitehornTARGET_ARCHES_pc98?=	i386
395216520Snwhitehorn.for target in ${TARGETS}
396216520SnwhitehornTARGET_ARCHES_${target}?= ${target}
397216520Snwhitehorn.endfor
398168280Smarcel
399218524Sjhb.if defined(UNIVERSE_TARGET)
400218524SjhbMAKE_JUST_WORLDS=	YES
401218524Sjhb.else
402218524SjhbUNIVERSE_TARGET?=	buildworld
403218524Sjhb.endif
404219137SjhbKERNSRCDIR?=		${.CURDIR}/sys
405218524Sjhb
406217125Simptargets:
407217815Sbz	@echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
408217125Simp.for target in ${TARGETS}
409217125Simp.for target_arch in ${TARGET_ARCHES_${target}}
410217125Simp	@echo "    ${target}/${target_arch}"
411217125Simp.endfor
412217125Simp.endfor
413217125Simp
414185499Salfred.if defined(DOING_TINDERBOX)
415217735SbzFAILFILE=${.CURDIR}/_.tinderbox.failed
416185499SalfredMAKEFAIL=tee -a ${FAILFILE}
417185499Salfred.else
418185499SalfredMAKEFAIL=cat
419185499Salfred.endif
420185499Salfred
421253616Ssjguniverse_prologue:  upgrade_checks
422253616Ssjguniverse: universe_prologue
423133945Sruuniverse_prologue:
424103985Sphk	@echo "--------------------------------------------------------------"
425103985Sphk	@echo ">>> make universe started on ${STARTTIME}"
426103985Sphk	@echo "--------------------------------------------------------------"
427185499Salfred.if defined(DOING_TINDERBOX)
428217754Sbz	@rm -f ${FAILFILE}
429185499Salfred.endif
430168280Smarcel.for target in ${TARGETS}
431162147Sruuniverse: universe_${target}
432253616Ssjguniverse_epilogue: universe_${target}
433216520Snwhitehornuniverse_${target}: universe_${target}_prologue
434253616Ssjguniverse_${target}_prologue: universe_prologue
435216520Snwhitehorn	@echo ">> ${target} started on `LC_ALL=C date`"
436179232Sjb.if !defined(MAKE_JUST_KERNELS)
437216520Snwhitehorn.for target_arch in ${TARGET_ARCHES_${target}}
438216520Snwhitehornuniverse_${target}: universe_${target}_${target_arch}
439254417Ssjguniverse_${target}_${target_arch}: universe_${target}_prologue .MAKE
440218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
441185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
442253616Ssjg	    ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
443162147Sru	    TARGET=${target} \
444216520Snwhitehorn	    TARGET_ARCH=${target_arch} \
445218524Sjhb	    > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
446218524Sjhb	    (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
447218524Sjhb	    "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
448216520Snwhitehorn	    ${MAKEFAIL}))
449218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
450216520Snwhitehorn.endfor
451179232Sjb.endif
452205290Sdougb.if !defined(MAKE_JUST_WORLDS)
453248937Sandrew# If we are building world and kernels wait for the required worlds to finish
454248937Sandrew.if !defined(MAKE_JUST_KERNELS)
455248937Sandrew.for target_arch in ${TARGET_ARCHES_${target}}
456248937Sandrewuniverse_${target}_kernels: universe_${target}_${target_arch}
457248937Sandrew.endfor
458248937Sandrew.endif
459248937Sandrewuniverse_${target}: universe_${target}_kernels
460254417Ssjguniverse_${target}_kernels: universe_${target}_prologue .MAKE
461219137Sjhb.if exists(${KERNSRCDIR}/${target}/conf/NOTES)
462219137Sjhb	@(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
463253616Ssjg	    ${SUB_MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
464185499Salfred	    (echo "${target} 'make LINT' failed," \
465185499Salfred	    "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
466103985Sphk.endif
467253616Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
468201815Sbz	    universe_kernels
469205290Sdougb.endif
470201815Sbz	@echo ">> ${target} completed on `LC_ALL=C date`"
471201815Sbz.endfor
472201815Sbzuniverse_kernels: universe_kernconfs
473202095Sbz.if !defined(TARGET)
474202095SbzTARGET!=	uname -m
475202095Sbz.endif
476266383Sian.if defined(MAKE_ALL_KERNELS)
477266383Sian_THINNER=cat
478266383Sian.else
479266383Sian_THINNER=xargs grep -L "^.NO_UNIVERSE"
480266383Sian.endif
481219137SjhbKERNCONFS!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
482201815Sbz		find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \
483266383Sian		! -name DEFAULTS ! -name NOTES | \
484266383Sian		${_THINNER}
485201815Sbzuniverse_kernconfs:
486148154Sru.for kernel in ${KERNCONFS}
487219137SjhbTARGET_ARCH_${kernel}!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
488219137Sjhb	config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
489216934Simp	grep -v WARNING: | cut -f 2
490216934Simp.if empty(TARGET_ARCH_${kernel})
491216934Simp.error "Target architecture for ${TARGET}/conf/${kernel} unknown.  config(8) likely too old."
492216934Simp.endif
493216520Snwhitehornuniverse_kernconfs: universe_kernconf_${TARGET}_${kernel}
494254417Ssjguniverse_kernconf_${TARGET}_${kernel}: .MAKE
495185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
496253616Ssjg	    ${SUB_MAKE} ${JFLAG} buildkernel \
497201815Sbz	    TARGET=${TARGET} \
498216520Snwhitehorn	    TARGET_ARCH=${TARGET_ARCH_${kernel}} \
499148154Sru	    KERNCONF=${kernel} \
500201815Sbz	    > _.${TARGET}.${kernel} 2>&1 || \
501201815Sbz	    (echo "${TARGET} ${kernel} kernel failed," \
502201815Sbz	    "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
503148154Sru.endfor
504133945Sruuniverse: universe_epilogue
505133945Sruuniverse_epilogue:
506103985Sphk	@echo "--------------------------------------------------------------"
507118531Sru	@echo ">>> make universe completed on `LC_ALL=C date`"
508118531Sru	@echo "                      (started ${STARTTIME})"
509103985Sphk	@echo "--------------------------------------------------------------"
510185499Salfred.if defined(DOING_TINDERBOX)
511185499Salfred	@if [ -e ${FAILFILE} ] ; then \
512185499Salfred		echo "Tinderbox failed:" ;\
513185499Salfred		cat ${FAILFILE} ;\
514185499Salfred		exit 1 ;\
515185499Salfred	fi
516133945Sru.endif
517185499Salfred.endif
518242522Smarcel
519242522SmarcelbuildLINT:
520242522Smarcel	${MAKE} -C ${.CURDIR}/sys/${_TARGET}/conf LINT
521255286Ssjg
522255286Ssjg.if defined(.PARSEDIR)
523255286Ssjg.if make(universe)
524255286Ssjg# we do not want a failure of one branch abort all.
525255286SsjgMAKE_JOB_ERROR_TOKEN= no
526255286Ssjg.export MAKE_JOB_ERROR_TOKEN
527255286Ssjg.endif
528255286Ssjg.endif
529