12061Sjkh#
250479Speter# $FreeBSD: releng/10.2/Makefile 281836 2015-04-21 17:02:55Z garga $
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.
39281836Sgarga# native-xtools       - Create host binaries that produce target objects
40281836Sgarga#                       for use in qemu user-mode jails.
41253002Salfred# 
42253002Salfred# "quick" way to test all kernel builds:
43253002Salfred# 	_jflag=`sysctl -n hw.ncpu`
44253002Salfred# 	_jflag=$(($_jflag * 2))
45253002Salfred# 	[ $_jflag -gt 12 ] && _jflag=12
46253003Salfred# 	make universe -DMAKE_JUST_KERNELS JFLAG=-j${_jflag}
4732427Sjb#
4838666Sjb# This makefile is simple by design. The FreeBSD make automatically reads
49108451Sschweikh# the /usr/share/mk/sys.mk unless the -m argument is specified on the
5038666Sjb# command line. By keeping this makefile simple, it doesn't matter too
5138666Sjb# much how different the installed mk files are from those in the source
5238666Sjb# tree. This makefile executes a child make process, forcing it to use
5338666Sjb# the mk files from the source tree which are supposed to DTRT.
5417308Speter#
55217273Simp# Most of the user-driven targets (as listed above) are implemented in
56217294Simp# Makefile.inc1.  The exceptions are universe, tinderbox and targets.
5719175Sbde#
5896205Sjwd# If you want to build your system from source be sure that /usr/obj has
59217297Simp# at least 1GB of diskspace available.  A complete 'universe' build requires
60217297Simp# about 15GB of space.
6138042Sbde#
6296205Sjwd# For individuals wanting to build from the sources currently on their
6396205Sjwd# system, the simple instructions are:
6438042Sbde#
6596205Sjwd# 1.  `cd /usr/src'  (or to the directory containing your source tree).
66159363Strhodes# 2.  Define `HISTORICAL_MAKE_WORLD' variable (see README).
67159363Strhodes# 3.  `make world'
6817308Speter#
6996205Sjwd# For individuals wanting to upgrade their sources (even if only a
7096205Sjwd# delta of a few days):
7117308Speter#
72148330Snetchild#  1.  `cd /usr/src'       (or to the directory containing your source tree).
73148330Snetchild#  2.  `make buildworld'
74148330Snetchild#  3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
75148330Snetchild#  4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
76159831Sobrien#       [steps 3. & 4. can be combined by using the "kernel" target]
77148330Snetchild#  5.  `reboot'        (in single user mode: boot -s from the loader prompt).
78148330Snetchild#  6.  `mergemaster -p'
79148330Snetchild#  7.  `make installworld'
80251107Screes#  8.  `mergemaster'		(you may wish to use -i, along with -U or -F).
81251107Screes#  9.  `make delete-old'
82148330Snetchild# 10.  `reboot'
83148330Snetchild# 11.  `make delete-old-libs' (in case no 3rd party program uses them anymore)
8496205Sjwd#
8596205Sjwd# See src/UPDATING `COMMON ITEMS' for more complete information.
8696205Sjwd#
87162147Sru# If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can
88162147Sru# cross build world for other machine types using the buildworld target,
8998723Sdillon# and once the world is built you can cross build a kernel using the
9098723Sdillon# buildkernel target.
9198723Sdillon#
9238666Sjb# Define the user-driven targets. These are listed here in alphabetical
9338666Sjb# order, but that's not important.
9417308Speter#
95123311Speter# Targets that begin with underscore are internal targets intended for
96123311Speter# developer convenience only.  They are intentionally not documented and
97123311Speter# completely subject to change without notice.
98123311Speter#
99175833Sjhb# For more information, see the build(7) manual page.
100175833Sjhb#
101169597SdesTGTS=	all all-man buildenv buildenvvars buildkernel buildworld \
102169597Sdes	check-old check-old-dirs check-old-files check-old-libs \
103169597Sdes	checkdpadd clean cleandepend cleandir \
104169597Sdes	delete-old delete-old-dirs delete-old-files delete-old-libs \
105219177Snwhitehorn	depend distribute distributekernel distributekernel.debug \
106219177Snwhitehorn	distributeworld distrib-dirs distribution doxygen \
107238051Sobrien	everything hier hierarchy install installcheck installkernel \
108219177Snwhitehorn	installkernel.debug packagekernel packageworld \
109219177Snwhitehorn	reinstallkernel reinstallkernel.debug \
110158962Snetchild	installworld kernel-toolchain libraries lint maninstall \
111156840Sru	obj objlink regress rerelease showconfig tags toolchain update \
112123311Speter	_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
113137288Speter	_build-tools _cross-tools _includes _libraries _depend \
114209128Sraj	build32 builddtb distribute32 install32 xdev xdev-build xdev-install \
115281836Sgarga	native-xtools \
116209128Sraj
117156740SruTGTS+=	${SUBDIR_TARGETS}
1182061Sjkh
11997769SruBITGTS=	files includes
12097252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
121119579SruTGTS+=	${BITGTS}
12297252Sru
12395730Sru.ORDER: buildworld installworld
12495793Sru.ORDER: buildworld distributeworld
125111617Sru.ORDER: buildworld buildkernel
12695730Sru.ORDER: buildkernel installkernel
127116679Ssimokawa.ORDER: buildkernel installkernel.debug
12895730Sru.ORDER: buildkernel reinstallkernel
129116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug
13095730Sru
131110035SruPATH=	/sbin:/bin:/usr/sbin:/usr/bin
132107516SruMAKEOBJDIRPREFIX?=	/usr/obj
133138921Sru_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
134156145Syar    ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
135138921Sru    -f /dev/null -V MAKEOBJDIRPREFIX dummy
136133942Sru.if !empty(_MAKEOBJDIRPREFIX)
137133942Sru.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
138156145Syar	(in make.conf(5)) or command-line variable.
139133942Sru.endif
140253616Ssjg
141253616Ssjg# We often need to use the tree's version of make to build it.
142253616Ssjg# Choices add to complexity though.
143253616Ssjg# We cannot blindly use a make which may not be the one we want
144253616Ssjg# so be exlicit - until all choice is removed.
145253616Ssjg.if !defined(WITHOUT_BMAKE)
146253616SsjgWANT_MAKE=	bmake
147253616Ssjg.else
148253616SsjgWANT_MAKE=	fmake
149253616Ssjg.endif
150253616SsjgMYMAKE=		${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}/${WANT_MAKE}
151253616Ssjg.if defined(.PARSEDIR)
152253616SsjgHAVE_MAKE=	bmake
153253616Ssjg.else
154253616SsjgHAVE_MAKE=	fmake
155253616Ssjg.endif
156253616Ssjg.if exists(${MYMAKE})
157253616SsjgSUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
158253616Ssjg.elif ${WANT_MAKE} != ${HAVE_MAKE} || ${WANT_MAKE} != "bmake"
159253616Ssjg# It may not exist yet but we may cause it to.
160253616Ssjg# In the case of fmake, upgrade_checks may cause a newer version to be built.
161253616SsjgSUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
162117229Sru	-m ${.CURDIR}/share/mk
163253616Ssjg.else
164253616SsjgSUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
165253616Ssjg.endif
16654324Smarcel
167253616Ssjg_MAKE=	PATH=${PATH} ${SUB_MAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
168253616Ssjg
169218130Simp# Guess machine architecture from machine type, and vice versa.
170218130Simp.if !defined(TARGET_ARCH) && defined(TARGET)
171233644Sjmallett_TARGET_ARCH=	${TARGET:S/pc98/i386/}
172218130Simp.elif !defined(TARGET) && defined(TARGET_ARCH) && \
173218130Simp    ${TARGET_ARCH} != ${MACHINE_ARCH}
174239272Sgonzo_TARGET=		${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/}
175218130Simp.endif
176233644Sjmallett# Legacy names, for another transition period mips:mips(n32|64)?eb -> mips:mips\1
177218130Simp.if defined(TARGET) && defined(TARGET_ARCH) && \
178233644Sjmallett    ${TARGET} == "mips" && ${TARGET_ARCH:Mmips*eb}
179233644Sjmallett_TARGET_ARCH=		${TARGET_ARCH:C/eb$//}
180233644Sjmallett.warning "TARGET_ARCH of ${TARGET_ARCH} is deprecated in favor of ${_TARGET_ARCH}"
181218130Simp.endif
182233644Sjmallett.if defined(TARGET) && ${TARGET} == "mips" && defined(TARGET_BIG_ENDIAN)
183233644Sjmallett.warning "TARGET_BIG_ENDIAN is no longer necessary for MIPS.  Big-endian is not the default."
184218130Simp.endif
185218130Simp# arm with TARGET_BIG_ENDIAN -> armeb
186218130Simp.if defined(TARGET_ARCH) && ${TARGET_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN)
187218130Simp.warning "TARGET_ARCH of arm with TARGET_BIG_ENDIAN is deprecated.  use armeb"
188218130Simp_TARGET_ARCH=armeb
189218130Simp.endif
190218130Simp.if defined(TARGET) && !defined(_TARGET)
191218130Simp_TARGET=${TARGET}
192218130Simp.endif
193218130Simp.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
194218130Simp_TARGET_ARCH=${TARGET_ARCH}
195218130Simp.endif
196218130Simp# Otherwise, default to current machine type and architecture.
197218130Simp_TARGET?=	${MACHINE}
198218130Simp_TARGET_ARCH?=	${MACHINE_ARCH}
199218130Simp
20017308Speter#
201119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld
202119519Smarcel# should do this as those are the initial targets used for upgrades.
203119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed
204119519Smarcel# for all targets.
205119519Smarcel#
206119519Smarcel.if defined(ALWAYS_CHECK_MAKE)
207119579Sru${TGTS}: upgrade_checks
208119519Smarcel.else
209119519Smarcelbuildworld: upgrade_checks
210119519Smarcel.endif
211119519Smarcel
212119519Smarcel#
213126031Sgad# This 'cleanworld' target is not included in TGTS, because it is not a
214126024Sgad# recursive target.  All of the work for it is done right here.   It is
215126024Sgad# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
216126024Sgad# created by bsd.obj.mk, except that we don't want to .include that file
217126024Sgad# in this makefile.  
218126024Sgad#
219126024Sgad# In the following, the first 'rm' in a series will usually remove all
220126024Sgad# files and directories.  If it does not, then there are probably some
221227771Sgjb# files with file flags set, so this unsets them and tries the 'rm' a
222126024Sgad# second time.  There are situations where this target will be cleaning
223126024Sgad# some directories via more than one method, but that duplication is
224227769Sgjb# needed to correctly handle all the possible situations.  Removing all
225227771Sgjb# files without file flags set in the first 'rm' instance saves time,
226227771Sgjb# because 'chflags' will need to operate on fewer files afterwards.
227126024Sgad#
228126024SgadBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
229126031Sgadcleanworld:
230126024Sgad.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
231126024Sgad.if exists(${BW_CANONICALOBJDIR}/)
232126024Sgad	-rm -rf ${BW_CANONICALOBJDIR}/*
233172744Sdelphij	-chflags -R 0 ${BW_CANONICALOBJDIR}
234126024Sgad	rm -rf ${BW_CANONICALOBJDIR}/*
235126024Sgad.endif
236126024Sgad	#   To be safe in this case, fall back to a 'make cleandir'
237133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
238126024Sgad.else
239126024Sgad	-rm -rf ${.OBJDIR}/*
240172744Sdelphij	-chflags -R 0 ${.OBJDIR}
241126024Sgad	rm -rf ${.OBJDIR}/*
242126024Sgad.endif
243125885Sgad
244125885Sgad#
24538666Sjb# Handle the user-driven targets, using the source relative mk files.
24617308Speter#
247119519Smarcel
248251750Ssjg.if empty(.MAKEFLAGS:M-n)
249251750Ssjg# skip this for -n to avoid changing previous behavior of 
250251750Ssjg# 'make -n buildworld' etc.
251251750Ssjg${TGTS}: .MAKE
252254417Ssjgtinderbox toolchains kernel-toolchains: .MAKE
253251750Ssjg.endif
254251750Ssjg
255119579Sru${TGTS}:
256218206Simp	${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
2572302Spaul
258265449Sbrooks# The historic default "all" target creates files which may cause stale
259265449Sbrooks# or (in the cross build case) unlinkable results. Fail with an error
260265449Sbrooks# when no target is given. The users can explicitly specify "all"
261265449Sbrooks# if they want the historic behavior.
262265449Sbrooks.MAIN:	_guard
26339206Sjkh
264265449Sbrooks_guard:
265265449Sbrooks	@echo
266265449Sbrooks	@echo "Explicit target required (use \"all\" for historic behavior)"
267265449Sbrooks	@echo
268265449Sbrooks	@false
269265449Sbrooks
270133945SruSTARTTIME!= LC_ALL=C date
271240403SobrienCHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo
272177609Sru.if !empty(CHECK_TIME)
273177609Sru.error check your date/time: ${STARTTIME}
274177609Sru.endif
275133945Sru
276132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
27717308Speter#
27854324Smarcel# world
27954324Smarcel#
280132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be
281132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is
282132234Smarcel# not included. One can argue that this target doesn't build everything
283132234Smarcel# then.
28454324Smarcel#
28554324Smarcelworld: upgrade_checks
28654324Smarcel	@echo "--------------------------------------------------------------"
287118531Sru	@echo ">>> make world started on ${STARTTIME}"
28854324Smarcel	@echo "--------------------------------------------------------------"
28954324Smarcel.if target(pre-world)
29054324Smarcel	@echo
29154324Smarcel	@echo "--------------------------------------------------------------"
29254324Smarcel	@echo ">>> Making 'pre-world' target"
29354324Smarcel	@echo "--------------------------------------------------------------"
294133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
29554324Smarcel.endif
296133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
297133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
29854324Smarcel.if target(post-world)
29954324Smarcel	@echo
30054324Smarcel	@echo "--------------------------------------------------------------"
30154324Smarcel	@echo ">>> Making 'post-world' target"
30254324Smarcel	@echo "--------------------------------------------------------------"
303133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
30454324Smarcel.endif
30554324Smarcel	@echo
30654324Smarcel	@echo "--------------------------------------------------------------"
307118531Sru	@echo ">>> make world completed on `LC_ALL=C date`"
308118531Sru	@echo "                   (started ${STARTTIME})"
30954324Smarcel	@echo "--------------------------------------------------------------"
310132234Smarcel.else
311132234Smarcelworld:
312132234Smarcel	@echo "WARNING: make world will overwrite your existing FreeBSD"
313132234Smarcel	@echo "installation without also building and installing a new"
314132234Smarcel	@echo "kernel.  This can be dangerous.  Please read the handbook,"
315132588Skensmith	@echo "'Rebuilding world', for how to upgrade your system."
316132358Smarkm	@echo "Define DESTDIR to where you want to install FreeBSD,"
317132234Smarcel	@echo "including /, to override this warning and proceed as usual."
318132358Smarkm	@echo ""
319132234Smarcel	@echo "Bailing out now..."
320132234Smarcel	@false
321132234Smarcel.endif
32254324Smarcel
32354324Smarcel#
32495730Sru# kernel
32595730Sru#
32695730Sru# Short hand for `make buildkernel installkernel'
32795730Sru#
32895730Srukernel: buildkernel installkernel
32995730Sru
33095730Sru#
33138666Sjb# Perform a few tests to determine if the installed tools are adequate
332107374Sru# for building the world.
33317308Speter#
334253616Ssjg# Note: if we ever need to care about the version of bmake, simply testing
335253616Ssjg# MAKE_VERSION against a required version should suffice.
336253616Ssjg#
33755678Smarcelupgrade_checks:
338253616Ssjg.if ${HAVE_MAKE} != ${WANT_MAKE}
339253616Ssjg	@(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
340253616Ssjg.elif ${WANT_MAKE} == "fmake"
341143032Sharti	@if ! (cd ${.CURDIR}/tools/build/make_check && \
342138515Sharti	    PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \
343117793Sru	    PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
344110035Sru	then \
345174564Simp	    (cd ${.CURDIR} && ${MAKE} make); \
346110035Sru	fi
347241298Smarcel.endif
3482061Sjkh
34917308Speter#
350107516Sru# Upgrade make(1) to the current version using the installed
351174539Simp# headers, libraries and tools.  Also, allow the location of
352174539Simp# the system bsdmake-like utility to be overridden.
35355678Smarcel#
354253616SsjgMMAKEENV=	MAKEOBJDIRPREFIX=${MYMAKE:H} \
355107516Sru		DESTDIR= \
356107516Sru		INSTALL="sh ${.CURDIR}/tools/install.sh"
357174564SimpMMAKE=		${MMAKEENV} ${MAKE} \
358107516Sru		-D_UPGRADING \
359139112Sru		-DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \
360264996Sjmmv		-DNO_CPU_CFLAGS -DNO_WERROR \
361264996Sjmmv		DESTDIR= MK_TESTS=no PROGNAME=${MYMAKE:T}
362107516Sru
363249395Ssjgmake bmake: .PHONY
36455678Smarcel	@echo
36555678Smarcel	@echo "--------------------------------------------------------------"
366116696Sru	@echo ">>> Building an up-to-date make(1)"
36755678Smarcel	@echo "--------------------------------------------------------------"
368249395Ssjg	${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
369255713Semaste		${MMAKE} obj && \
370255713Semaste		${MMAKE} depend && \
371255713Semaste		${MMAKE} all && \
372255713Semaste		${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR=
37355678Smarcel
374254417Ssjgtinderbox toolchains kernel-toolchains: upgrade_checks
375254417Ssjg
376185499Salfredtinderbox:
377254417Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} DOING_TINDERBOX=YES universe
378185499Salfred
379218524Sjhbtoolchains:
380254417Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
381218524Sjhb
382232907Sjmallettkernel-toolchains:
383254417Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
384232907Sjmallett
38555678Smarcel#
386111131Sru# universe
387111131Sru#
388111131Sru# Attempt to rebuild *everything* for all supported architectures,
389133945Sru# with a reasonable chance of success, regardless of how old your
390111131Sru# existing system is.
391111131Sru#
392217125Simp.if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets)
393221869SattilioTARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64
394255784SandrewTARGET_ARCHES_arm?=	arm armeb armv6
395233644SjmallettTARGET_ARCHES_mips?=	mipsel mips mips64el mips64 mipsn32
396216520SnwhitehornTARGET_ARCHES_powerpc?=	powerpc powerpc64
397216520SnwhitehornTARGET_ARCHES_pc98?=	i386
398216520Snwhitehorn.for target in ${TARGETS}
399216520SnwhitehornTARGET_ARCHES_${target}?= ${target}
400216520Snwhitehorn.endfor
401168280Smarcel
402218524Sjhb.if defined(UNIVERSE_TARGET)
403218524SjhbMAKE_JUST_WORLDS=	YES
404218524Sjhb.else
405218524SjhbUNIVERSE_TARGET?=	buildworld
406218524Sjhb.endif
407219137SjhbKERNSRCDIR?=		${.CURDIR}/sys
408218524Sjhb
409217125Simptargets:
410217815Sbz	@echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
411217125Simp.for target in ${TARGETS}
412217125Simp.for target_arch in ${TARGET_ARCHES_${target}}
413217125Simp	@echo "    ${target}/${target_arch}"
414217125Simp.endfor
415217125Simp.endfor
416217125Simp
417185499Salfred.if defined(DOING_TINDERBOX)
418217735SbzFAILFILE=${.CURDIR}/_.tinderbox.failed
419185499SalfredMAKEFAIL=tee -a ${FAILFILE}
420185499Salfred.else
421185499SalfredMAKEFAIL=cat
422185499Salfred.endif
423185499Salfred
424253616Ssjguniverse_prologue:  upgrade_checks
425253616Ssjguniverse: universe_prologue
426133945Sruuniverse_prologue:
427103985Sphk	@echo "--------------------------------------------------------------"
428103985Sphk	@echo ">>> make universe started on ${STARTTIME}"
429103985Sphk	@echo "--------------------------------------------------------------"
430185499Salfred.if defined(DOING_TINDERBOX)
431217754Sbz	@rm -f ${FAILFILE}
432185499Salfred.endif
433168280Smarcel.for target in ${TARGETS}
434162147Sruuniverse: universe_${target}
435253616Ssjguniverse_epilogue: universe_${target}
436216520Snwhitehornuniverse_${target}: universe_${target}_prologue
437253616Ssjguniverse_${target}_prologue: universe_prologue
438216520Snwhitehorn	@echo ">> ${target} started on `LC_ALL=C date`"
439179232Sjb.if !defined(MAKE_JUST_KERNELS)
440216520Snwhitehorn.for target_arch in ${TARGET_ARCHES_${target}}
441216520Snwhitehornuniverse_${target}: universe_${target}_${target_arch}
442254417Ssjguniverse_${target}_${target_arch}: universe_${target}_prologue .MAKE
443218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
444185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
445253616Ssjg	    ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
446162147Sru	    TARGET=${target} \
447216520Snwhitehorn	    TARGET_ARCH=${target_arch} \
448218524Sjhb	    > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
449218524Sjhb	    (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
450218524Sjhb	    "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
451216520Snwhitehorn	    ${MAKEFAIL}))
452218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
453216520Snwhitehorn.endfor
454179232Sjb.endif
455205290Sdougb.if !defined(MAKE_JUST_WORLDS)
456248937Sandrew# If we are building world and kernels wait for the required worlds to finish
457248937Sandrew.if !defined(MAKE_JUST_KERNELS)
458248937Sandrew.for target_arch in ${TARGET_ARCHES_${target}}
459248937Sandrewuniverse_${target}_kernels: universe_${target}_${target_arch}
460248937Sandrew.endfor
461248937Sandrew.endif
462248937Sandrewuniverse_${target}: universe_${target}_kernels
463254417Ssjguniverse_${target}_kernels: universe_${target}_prologue .MAKE
464219137Sjhb.if exists(${KERNSRCDIR}/${target}/conf/NOTES)
465219137Sjhb	@(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
466253616Ssjg	    ${SUB_MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
467185499Salfred	    (echo "${target} 'make LINT' failed," \
468185499Salfred	    "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
469103985Sphk.endif
470253616Ssjg	@cd ${.CURDIR} && ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
471201815Sbz	    universe_kernels
472205290Sdougb.endif
473201815Sbz	@echo ">> ${target} completed on `LC_ALL=C date`"
474201815Sbz.endfor
475201815Sbzuniverse_kernels: universe_kernconfs
476202095Sbz.if !defined(TARGET)
477202095SbzTARGET!=	uname -m
478202095Sbz.endif
479266383Sian.if defined(MAKE_ALL_KERNELS)
480266383Sian_THINNER=cat
481266383Sian.else
482276281Sian_THINNER=xargs grep -L "^.NO_UNIVERSE" || true
483266383Sian.endif
484219137SjhbKERNCONFS!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
485201815Sbz		find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \
486266383Sian		! -name DEFAULTS ! -name NOTES | \
487266383Sian		${_THINNER}
488201815Sbzuniverse_kernconfs:
489148154Sru.for kernel in ${KERNCONFS}
490219137SjhbTARGET_ARCH_${kernel}!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
491219137Sjhb	config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
492216934Simp	grep -v WARNING: | cut -f 2
493216934Simp.if empty(TARGET_ARCH_${kernel})
494216934Simp.error "Target architecture for ${TARGET}/conf/${kernel} unknown.  config(8) likely too old."
495216934Simp.endif
496216520Snwhitehornuniverse_kernconfs: universe_kernconf_${TARGET}_${kernel}
497254417Ssjguniverse_kernconf_${TARGET}_${kernel}: .MAKE
498185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
499253616Ssjg	    ${SUB_MAKE} ${JFLAG} buildkernel \
500201815Sbz	    TARGET=${TARGET} \
501216520Snwhitehorn	    TARGET_ARCH=${TARGET_ARCH_${kernel}} \
502148154Sru	    KERNCONF=${kernel} \
503201815Sbz	    > _.${TARGET}.${kernel} 2>&1 || \
504201815Sbz	    (echo "${TARGET} ${kernel} kernel failed," \
505201815Sbz	    "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
506148154Sru.endfor
507133945Sruuniverse: universe_epilogue
508133945Sruuniverse_epilogue:
509103985Sphk	@echo "--------------------------------------------------------------"
510118531Sru	@echo ">>> make universe completed on `LC_ALL=C date`"
511118531Sru	@echo "                      (started ${STARTTIME})"
512103985Sphk	@echo "--------------------------------------------------------------"
513185499Salfred.if defined(DOING_TINDERBOX)
514185499Salfred	@if [ -e ${FAILFILE} ] ; then \
515185499Salfred		echo "Tinderbox failed:" ;\
516185499Salfred		cat ${FAILFILE} ;\
517185499Salfred		exit 1 ;\
518185499Salfred	fi
519133945Sru.endif
520185499Salfred.endif
521242522Smarcel
522242522SmarcelbuildLINT:
523242522Smarcel	${MAKE} -C ${.CURDIR}/sys/${_TARGET}/conf LINT
524255286Ssjg
525255286Ssjg.if defined(.PARSEDIR)
526255286Ssjg.if make(universe)
527255286Ssjg# we do not want a failure of one branch abort all.
528255286SsjgMAKE_JOB_ERROR_TOKEN= no
529255286Ssjg.export MAKE_JOB_ERROR_TOKEN
530255286Ssjg.endif
531255286Ssjg.endif
532