Makefile revision 284457
12061Sjkh#
250479Speter# $FreeBSD: head/Makefile 284457 2015-06-16 19:23:34Z 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#
102284454Simp
103284454Simp# Note: we use this awkward construct to be compatible with FreeBSD's
104284454Simp# old make used in 10.0 and 9.2 and earlier.
105284454Simp.if defined(MK_META_MODE) && ${MK_META_MODE} == "yes"
106284345Ssjg# targets/Makefile plays the role of top-level
107284345Ssjg.include "targets/Makefile"
108284345Ssjg.else
109284345Ssjg
110169597SdesTGTS=	all all-man buildenv buildenvvars buildkernel buildworld \
111169597Sdes	check-old check-old-dirs check-old-files check-old-libs \
112169597Sdes	checkdpadd clean cleandepend cleandir \
113169597Sdes	delete-old delete-old-dirs delete-old-files delete-old-libs \
114219177Snwhitehorn	depend distribute distributekernel distributekernel.debug \
115219177Snwhitehorn	distributeworld distrib-dirs distribution doxygen \
116238051Sobrien	everything hier hierarchy install installcheck installkernel \
117219177Snwhitehorn	installkernel.debug packagekernel packageworld \
118219177Snwhitehorn	reinstallkernel reinstallkernel.debug \
119158962Snetchild	installworld kernel-toolchain libraries lint maninstall \
120156840Sru	obj objlink regress rerelease showconfig tags toolchain update \
121123311Speter	_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
122137288Speter	_build-tools _cross-tools _includes _libraries _depend \
123209128Sraj	build32 builddtb distribute32 install32 xdev xdev-build xdev-install \
124270155Simp	xdev-links native-xtools \
125209128Sraj
126156740SruTGTS+=	${SUBDIR_TARGETS}
1272061Sjkh
12897769SruBITGTS=	files includes
12997252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
130119579SruTGTS+=	${BITGTS}
13197252Sru
13295730Sru.ORDER: buildworld installworld
13395793Sru.ORDER: buildworld distributeworld
134111617Sru.ORDER: buildworld buildkernel
13595730Sru.ORDER: buildkernel installkernel
136116679Ssimokawa.ORDER: buildkernel installkernel.debug
13795730Sru.ORDER: buildkernel reinstallkernel
138116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug
13995730Sru
140110035SruPATH=	/sbin:/bin:/usr/sbin:/usr/bin
141107516SruMAKEOBJDIRPREFIX?=	/usr/obj
142138921Sru_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
143156145Syar    ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
144138921Sru    -f /dev/null -V MAKEOBJDIRPREFIX dummy
145133942Sru.if !empty(_MAKEOBJDIRPREFIX)
146133942Sru.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
147156145Syar	(in make.conf(5)) or command-line variable.
148133942Sru.endif
149253616Ssjg
150253616Ssjg# We often need to use the tree's version of make to build it.
151253616Ssjg# Choices add to complexity though.
152253616Ssjg# We cannot blindly use a make which may not be the one we want
153253616Ssjg# so be exlicit - until all choice is removed.
154253616SsjgWANT_MAKE=	bmake
155253616SsjgMYMAKE=		${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}/${WANT_MAKE}
156253616Ssjg.if defined(.PARSEDIR)
157253616SsjgHAVE_MAKE=	bmake
158253616Ssjg.else
159253616SsjgHAVE_MAKE=	fmake
160253616Ssjg.endif
161253616Ssjg.if exists(${MYMAKE})
162253616SsjgSUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
163265423Simp.elif ${WANT_MAKE} != ${HAVE_MAKE}
164253616Ssjg# It may not exist yet but we may cause it to.
165253616Ssjg# In the case of fmake, upgrade_checks may cause a newer version to be built.
166253616SsjgSUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
167117229Sru	-m ${.CURDIR}/share/mk
168253616Ssjg.else
169253616SsjgSUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
170253616Ssjg.endif
17154324Smarcel
172253616Ssjg_MAKE=	PATH=${PATH} ${SUB_MAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
173253616Ssjg
174218130Simp# Guess machine architecture from machine type, and vice versa.
175218130Simp.if !defined(TARGET_ARCH) && defined(TARGET)
176280259Sandrew_TARGET_ARCH=	${TARGET:S/pc98/i386/:S/arm64/aarch64/}
177218130Simp.elif !defined(TARGET) && defined(TARGET_ARCH) && \
178218130Simp    ${TARGET_ARCH} != ${MACHINE_ARCH}
179280326Simp_TARGET=		${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb|hf)?/arm/:C/aarch64/arm64/:C/powerpc64/powerpc/}
180218130Simp.endif
181218130Simp.if defined(TARGET) && !defined(_TARGET)
182218130Simp_TARGET=${TARGET}
183218130Simp.endif
184218130Simp.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
185218130Simp_TARGET_ARCH=${TARGET_ARCH}
186218130Simp.endif
187269048Simp# for historical compatibility for xdev targets
188269048Simp.if defined(XDEV)
189269048Simp_TARGET=	${XDEV}
190269048Simp.endif
191269048Simp.if defined(XDEV_ARCH)
192269048Simp_TARGET_ARCH=	${XDEV_ARCH}
193269048Simp.endif
194218130Simp# Otherwise, default to current machine type and architecture.
195218130Simp_TARGET?=	${MACHINE}
196218130Simp_TARGET_ARCH?=	${MACHINE_ARCH}
197218130Simp
19817308Speter#
199119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld
200119519Smarcel# should do this as those are the initial targets used for upgrades.
201119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed
202119519Smarcel# for all targets.
203119519Smarcel#
204119519Smarcel.if defined(ALWAYS_CHECK_MAKE)
205119579Sru${TGTS}: upgrade_checks
206119519Smarcel.else
207119519Smarcelbuildworld: upgrade_checks
208119519Smarcel.endif
209119519Smarcel
210119519Smarcel#
211126031Sgad# This 'cleanworld' target is not included in TGTS, because it is not a
212126024Sgad# recursive target.  All of the work for it is done right here.   It is
213126024Sgad# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
214126024Sgad# created by bsd.obj.mk, except that we don't want to .include that file
215126024Sgad# in this makefile.  
216126024Sgad#
217126024Sgad# In the following, the first 'rm' in a series will usually remove all
218126024Sgad# files and directories.  If it does not, then there are probably some
219227771Sgjb# files with file flags set, so this unsets them and tries the 'rm' a
220126024Sgad# second time.  There are situations where this target will be cleaning
221126024Sgad# some directories via more than one method, but that duplication is
222227769Sgjb# needed to correctly handle all the possible situations.  Removing all
223227771Sgjb# files without file flags set in the first 'rm' instance saves time,
224227771Sgjb# because 'chflags' will need to operate on fewer files afterwards.
225126024Sgad#
226126024SgadBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
227126031Sgadcleanworld:
228126024Sgad.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
229126024Sgad.if exists(${BW_CANONICALOBJDIR}/)
230126024Sgad	-rm -rf ${BW_CANONICALOBJDIR}/*
231172744Sdelphij	-chflags -R 0 ${BW_CANONICALOBJDIR}
232126024Sgad	rm -rf ${BW_CANONICALOBJDIR}/*
233126024Sgad.endif
234126024Sgad	#   To be safe in this case, fall back to a 'make cleandir'
235133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
236126024Sgad.else
237126024Sgad	-rm -rf ${.OBJDIR}/*
238172744Sdelphij	-chflags -R 0 ${.OBJDIR}
239126024Sgad	rm -rf ${.OBJDIR}/*
240126024Sgad.endif
241125885Sgad
242125885Sgad#
24338666Sjb# Handle the user-driven targets, using the source relative mk files.
24417308Speter#
245119519Smarcel
246251750Ssjg.if empty(.MAKEFLAGS:M-n)
247251750Ssjg# skip this for -n to avoid changing previous behavior of 
248251750Ssjg# 'make -n buildworld' etc.
249251750Ssjg${TGTS}: .MAKE
250254417Ssjgtinderbox toolchains kernel-toolchains: .MAKE
251251750Ssjg.endif
252251750Ssjg
253119579Sru${TGTS}:
254218206Simp	${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
2552302Spaul
256265097Sbrooks# The historic default "all" target creates files which may cause stale
257265097Sbrooks# or (in the cross build case) unlinkable results. Fail with an error
258265097Sbrooks# when no target is given. The users can explicitly specify "all"
259265097Sbrooks# if they want the historic behavior.
260265097Sbrooks.MAIN:	_guard
26139206Sjkh
262265097Sbrooks_guard:
263265097Sbrooks	@echo
264265097Sbrooks	@echo "Explicit target required (use \"all\" for historic behavior)"
265265097Sbrooks	@echo
266265097Sbrooks	@false
267265097Sbrooks
268133945SruSTARTTIME!= LC_ALL=C date
269240403SobrienCHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo
270177609Sru.if !empty(CHECK_TIME)
271177609Sru.error check your date/time: ${STARTTIME}
272177609Sru.endif
273133945Sru
274132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
27517308Speter#
27654324Smarcel# world
27754324Smarcel#
278132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be
279132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is
280132234Smarcel# not included. One can argue that this target doesn't build everything
281132234Smarcel# then.
28254324Smarcel#
28354324Smarcelworld: upgrade_checks
28454324Smarcel	@echo "--------------------------------------------------------------"
285118531Sru	@echo ">>> make world started on ${STARTTIME}"
28654324Smarcel	@echo "--------------------------------------------------------------"
28754324Smarcel.if target(pre-world)
28854324Smarcel	@echo
28954324Smarcel	@echo "--------------------------------------------------------------"
29054324Smarcel	@echo ">>> Making 'pre-world' target"
29154324Smarcel	@echo "--------------------------------------------------------------"
292133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
29354324Smarcel.endif
294133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
295133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
29654324Smarcel.if target(post-world)
29754324Smarcel	@echo
29854324Smarcel	@echo "--------------------------------------------------------------"
29954324Smarcel	@echo ">>> Making 'post-world' target"
30054324Smarcel	@echo "--------------------------------------------------------------"
301133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
30254324Smarcel.endif
30354324Smarcel	@echo
30454324Smarcel	@echo "--------------------------------------------------------------"
305118531Sru	@echo ">>> make world completed on `LC_ALL=C date`"
306118531Sru	@echo "                   (started ${STARTTIME})"
30754324Smarcel	@echo "--------------------------------------------------------------"
308132234Smarcel.else
309132234Smarcelworld:
310132234Smarcel	@echo "WARNING: make world will overwrite your existing FreeBSD"
311132234Smarcel	@echo "installation without also building and installing a new"
312132234Smarcel	@echo "kernel.  This can be dangerous.  Please read the handbook,"
313132588Skensmith	@echo "'Rebuilding world', for how to upgrade your system."
314132358Smarkm	@echo "Define DESTDIR to where you want to install FreeBSD,"
315132234Smarcel	@echo "including /, to override this warning and proceed as usual."
316132358Smarkm	@echo ""
317132234Smarcel	@echo "Bailing out now..."
318132234Smarcel	@false
319132234Smarcel.endif
32054324Smarcel
32154324Smarcel#
32295730Sru# kernel
32395730Sru#
32495730Sru# Short hand for `make buildkernel installkernel'
32595730Sru#
32695730Srukernel: buildkernel installkernel
32795730Sru
32895730Sru#
32938666Sjb# Perform a few tests to determine if the installed tools are adequate
330107374Sru# for building the world.
33117308Speter#
332253616Ssjg# Note: if we ever need to care about the version of bmake, simply testing
333253616Ssjg# MAKE_VERSION against a required version should suffice.
334253616Ssjg#
33555678Smarcelupgrade_checks:
336253616Ssjg.if ${HAVE_MAKE} != ${WANT_MAKE}
337253616Ssjg	@(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
338241298Smarcel.endif
3392061Sjkh
34017308Speter#
341107516Sru# Upgrade make(1) to the current version using the installed
342174539Simp# headers, libraries and tools.  Also, allow the location of
343174539Simp# the system bsdmake-like utility to be overridden.
34455678Smarcel#
345253616SsjgMMAKEENV=	MAKEOBJDIRPREFIX=${MYMAKE:H} \
346107516Sru		DESTDIR= \
347107516Sru		INSTALL="sh ${.CURDIR}/tools/install.sh"
348174564SimpMMAKE=		${MMAKEENV} ${MAKE} \
349265837Simp		-DNO_MAN -DNO_SHARED \
350264742Sjmmv		-DNO_CPU_CFLAGS -DNO_WERROR \
351268598Sjmmv		MK_TESTS=no \
352265827Simp		DESTDIR= PROGNAME=${MYMAKE:T}
353107516Sru
354265827Simpbmake: .PHONY
35555678Smarcel	@echo
35655678Smarcel	@echo "--------------------------------------------------------------"
357265827Simp	@echo ">>> Building an up-to-date ${.TARGET}(1)"
35855678Smarcel	@echo "--------------------------------------------------------------"
359249395Ssjg	${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
360255713Semaste		${MMAKE} obj && \
361255713Semaste		${MMAKE} depend && \
362255713Semaste		${MMAKE} all && \
363265827Simp		${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR=
36455678Smarcel
365254417Ssjgtinderbox toolchains kernel-toolchains: upgrade_checks
366254417Ssjg
367185499Salfredtinderbox:
368254417Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} DOING_TINDERBOX=YES universe
369185499Salfred
370218524Sjhbtoolchains:
371254417Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
372218524Sjhb
373232907Sjmallettkernel-toolchains:
374254417Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
375232907Sjmallett
37655678Smarcel#
377111131Sru# universe
378111131Sru#
379111131Sru# Attempt to rebuild *everything* for all supported architectures,
380133945Sru# with a reasonable chance of success, regardless of how old your
381111131Sru# existing system is.
382111131Sru#
383217125Simp.if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets)
384281629Semaste# XXX Add arm64 to universe only if we have an external binutils installed.
385282108Sngie# It does not build with the in-tree linker.
386281629Semaste.if exists(/usr/local/aarch64-freebsd/bin/ld)
387282156SemasteUNIVERSE_arm64=arm64
388282156Semaste.elif empty(${TARGETS})
389281629Semasteuniverse: universe_arm64_skip
390281629Semasteuniverse_epilogue: universe_arm64_skip
391281629Semasteuniverse_arm64_skip: universe_prologue
392281629Semaste	@echo ">> arm64 skipped - install aarch64-binutils port or package to build"
393281629Semaste.endif
394282156SemasteTARGETS?=amd64 arm ${UNIVERSE_arm64} i386 mips pc98 powerpc sparc64
395263660SandrewTARGET_ARCHES_arm?=	arm armeb armv6 armv6hf
396282156SemasteTARGET_ARCHES_arm64?=	aarch64
397233644SjmallettTARGET_ARCHES_mips?=	mipsel mips mips64el mips64 mipsn32
398216520SnwhitehornTARGET_ARCHES_powerpc?=	powerpc powerpc64
399216520SnwhitehornTARGET_ARCHES_pc98?=	i386
400216520Snwhitehorn.for target in ${TARGETS}
401216520SnwhitehornTARGET_ARCHES_${target}?= ${target}
402216520Snwhitehorn.endfor
403168280Smarcel
404218524Sjhb.if defined(UNIVERSE_TARGET)
405218524SjhbMAKE_JUST_WORLDS=	YES
406218524Sjhb.else
407218524SjhbUNIVERSE_TARGET?=	buildworld
408218524Sjhb.endif
409219137SjhbKERNSRCDIR?=		${.CURDIR}/sys
410218524Sjhb
411217125Simptargets:
412217815Sbz	@echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
413217125Simp.for target in ${TARGETS}
414217125Simp.for target_arch in ${TARGET_ARCHES_${target}}
415217125Simp	@echo "    ${target}/${target_arch}"
416217125Simp.endfor
417217125Simp.endfor
418217125Simp
419185499Salfred.if defined(DOING_TINDERBOX)
420217735SbzFAILFILE=${.CURDIR}/_.tinderbox.failed
421185499SalfredMAKEFAIL=tee -a ${FAILFILE}
422185499Salfred.else
423185499SalfredMAKEFAIL=cat
424185499Salfred.endif
425185499Salfred
426253616Ssjguniverse_prologue:  upgrade_checks
427253616Ssjguniverse: universe_prologue
428133945Sruuniverse_prologue:
429103985Sphk	@echo "--------------------------------------------------------------"
430103985Sphk	@echo ">>> make universe started on ${STARTTIME}"
431103985Sphk	@echo "--------------------------------------------------------------"
432185499Salfred.if defined(DOING_TINDERBOX)
433217754Sbz	@rm -f ${FAILFILE}
434185499Salfred.endif
435168280Smarcel.for target in ${TARGETS}
436162147Sruuniverse: universe_${target}
437253616Ssjguniverse_epilogue: universe_${target}
438216520Snwhitehornuniverse_${target}: universe_${target}_prologue
439253616Ssjguniverse_${target}_prologue: universe_prologue
440216520Snwhitehorn	@echo ">> ${target} started on `LC_ALL=C date`"
441284456Sandrewuniverse_${target}_worlds:
442284456Sandrew
443179232Sjb.if !defined(MAKE_JUST_KERNELS)
444216520Snwhitehorn.for target_arch in ${TARGET_ARCHES_${target}}
445216520Snwhitehornuniverse_${target}: universe_${target}_${target_arch}
446284456Sandrewuniverse_${target}_worlds: universe_${target}_${target_arch}
447284457Sandrewuniverse_${target}_done: universe_${target}_worlds
448254417Ssjguniverse_${target}_${target_arch}: universe_${target}_prologue .MAKE
449218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
450185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
451253616Ssjg	    ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
452162147Sru	    TARGET=${target} \
453216520Snwhitehorn	    TARGET_ARCH=${target_arch} \
454218524Sjhb	    > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
455218524Sjhb	    (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
456218524Sjhb	    "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
457216520Snwhitehorn	    ${MAKEFAIL}))
458218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
459216520Snwhitehorn.endfor
460284453Sandrew.endif # !MAKE_JUST_KERNELS
461284453Sandrew
462205290Sdougb.if !defined(MAKE_JUST_WORLDS)
463248937Sandrewuniverse_${target}: universe_${target}_kernels
464284457Sandrewuniverse_${target}_done: universe_${target}_kernels
465284456Sandrewuniverse_${target}_kernels: universe_${target}_worlds
466254417Ssjguniverse_${target}_kernels: universe_${target}_prologue .MAKE
467219137Sjhb.if exists(${KERNSRCDIR}/${target}/conf/NOTES)
468219137Sjhb	@(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
469253616Ssjg	    ${SUB_MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
470185499Salfred	    (echo "${target} 'make LINT' failed," \
471185499Salfred	    "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
472103985Sphk.endif
473253616Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
474201815Sbz	    universe_kernels
475284453Sandrew.endif # !MAKE_JUST_WORLDS
476284457Sandrew
477284457Sandrew# Tell the user the worlds and kernels have completed
478284457Sandrewuniverse_${target}: universe_${target}_done
479284457Sandrewuniverse_${target}_done:
480201815Sbz	@echo ">> ${target} completed on `LC_ALL=C date`"
481201815Sbz.endfor
482201815Sbzuniverse_kernels: universe_kernconfs
483202095Sbz.if !defined(TARGET)
484202095SbzTARGET!=	uname -m
485202095Sbz.endif
486265155Simp.if defined(MAKE_ALL_KERNELS)
487265155Simp_THINNER=cat
488265155Simp.else
489265840Simp_THINNER=xargs grep -L "^.NO_UNIVERSE" || true
490265155Simp.endif
491219137SjhbKERNCONFS!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
492201815Sbz		find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \
493265155Simp		! -name DEFAULTS ! -name NOTES | \
494265155Simp		${_THINNER}
495201815Sbzuniverse_kernconfs:
496148154Sru.for kernel in ${KERNCONFS}
497219137SjhbTARGET_ARCH_${kernel}!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
498219137Sjhb	config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
499216934Simp	grep -v WARNING: | cut -f 2
500216934Simp.if empty(TARGET_ARCH_${kernel})
501216934Simp.error "Target architecture for ${TARGET}/conf/${kernel} unknown.  config(8) likely too old."
502216934Simp.endif
503216520Snwhitehornuniverse_kernconfs: universe_kernconf_${TARGET}_${kernel}
504254417Ssjguniverse_kernconf_${TARGET}_${kernel}: .MAKE
505185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
506253616Ssjg	    ${SUB_MAKE} ${JFLAG} buildkernel \
507201815Sbz	    TARGET=${TARGET} \
508216520Snwhitehorn	    TARGET_ARCH=${TARGET_ARCH_${kernel}} \
509148154Sru	    KERNCONF=${kernel} \
510201815Sbz	    > _.${TARGET}.${kernel} 2>&1 || \
511201815Sbz	    (echo "${TARGET} ${kernel} kernel failed," \
512201815Sbz	    "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
513148154Sru.endfor
514133945Sruuniverse: universe_epilogue
515133945Sruuniverse_epilogue:
516103985Sphk	@echo "--------------------------------------------------------------"
517118531Sru	@echo ">>> make universe completed on `LC_ALL=C date`"
518118531Sru	@echo "                      (started ${STARTTIME})"
519103985Sphk	@echo "--------------------------------------------------------------"
520185499Salfred.if defined(DOING_TINDERBOX)
521185499Salfred	@if [ -e ${FAILFILE} ] ; then \
522185499Salfred		echo "Tinderbox failed:" ;\
523185499Salfred		cat ${FAILFILE} ;\
524185499Salfred		exit 1 ;\
525185499Salfred	fi
526133945Sru.endif
527185499Salfred.endif
528242522Smarcel
529242522SmarcelbuildLINT:
530242522Smarcel	${MAKE} -C ${.CURDIR}/sys/${_TARGET}/conf LINT
531255286Ssjg
532284454Simp.if defined(.PARSEDIR)
533284345Ssjg# This makefile does not run in meta mode
534284345Ssjg.MAKE.MODE= normal
535284345Ssjg# Normally the things we run from here don't either.
536284345Ssjg# Using -DWITH_META_FILES
537284345Ssjg# we can buildworld with meta files created which are useful 
538284345Ssjg# for debugging, but without any of the rest of a meta mode build.
539284345SsjgMK_META_MODE= no
540284345SsjgMK_STAGING= no
541284345Ssjg# tell meta.autodep.mk to not even think about updating anything.
542284345SsjgUPDATE_DEPENDFILE= NO
543284345Ssjg.export MK_META_MODE MK_STAGING UPDATE_DEPENDFILE
544284345Ssjg
545255286Ssjg.if make(universe)
546255286Ssjg# we do not want a failure of one branch abort all.
547255286SsjgMAKE_JOB_ERROR_TOKEN= no
548255286Ssjg.export MAKE_JOB_ERROR_TOKEN
549255286Ssjg.endif
550284454Simp.endif # bmake
551284345Ssjg
552284345Ssjg.endif				# META_MODE
553