Makefile revision 296748
12061Sjkh#
250479Speter# $FreeBSD: stable/10/Makefile 296748 2016-03-12 19:02:20Z bdrewery $
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
126296748Sbdrewery.ORDER: installworld distribution
127296748Sbdrewery.ORDER: installworld installkernel
12895730Sru.ORDER: buildkernel installkernel
129116679Ssimokawa.ORDER: buildkernel installkernel.debug
13095730Sru.ORDER: buildkernel reinstallkernel
131116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug
13295730Sru
133110035SruPATH=	/sbin:/bin:/usr/sbin:/usr/bin
134107516SruMAKEOBJDIRPREFIX?=	/usr/obj
135138921Sru_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
136156145Syar    ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
137138921Sru    -f /dev/null -V MAKEOBJDIRPREFIX dummy
138133942Sru.if !empty(_MAKEOBJDIRPREFIX)
139133942Sru.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
140156145Syar	(in make.conf(5)) or command-line variable.
141133942Sru.endif
142253616Ssjg
143253616Ssjg# We often need to use the tree's version of make to build it.
144253616Ssjg# Choices add to complexity though.
145253616Ssjg# We cannot blindly use a make which may not be the one we want
146253616Ssjg# so be exlicit - until all choice is removed.
147253616Ssjg.if !defined(WITHOUT_BMAKE)
148253616SsjgWANT_MAKE=	bmake
149253616Ssjg.else
150253616SsjgWANT_MAKE=	fmake
151253616Ssjg.endif
152253616SsjgMYMAKE=		${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}/${WANT_MAKE}
153253616Ssjg.if defined(.PARSEDIR)
154253616SsjgHAVE_MAKE=	bmake
155253616Ssjg.else
156253616SsjgHAVE_MAKE=	fmake
157253616Ssjg.endif
158253616Ssjg.if exists(${MYMAKE})
159253616SsjgSUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
160253616Ssjg.elif ${WANT_MAKE} != ${HAVE_MAKE} || ${WANT_MAKE} != "bmake"
161253616Ssjg# It may not exist yet but we may cause it to.
162253616Ssjg# In the case of fmake, upgrade_checks may cause a newer version to be built.
163253616SsjgSUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
164117229Sru	-m ${.CURDIR}/share/mk
165253616Ssjg.else
166253616SsjgSUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
167253616Ssjg.endif
16854324Smarcel
169253616Ssjg_MAKE=	PATH=${PATH} ${SUB_MAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
170253616Ssjg
171218130Simp# Guess machine architecture from machine type, and vice versa.
172218130Simp.if !defined(TARGET_ARCH) && defined(TARGET)
173233644Sjmallett_TARGET_ARCH=	${TARGET:S/pc98/i386/}
174218130Simp.elif !defined(TARGET) && defined(TARGET_ARCH) && \
175218130Simp    ${TARGET_ARCH} != ${MACHINE_ARCH}
176239272Sgonzo_TARGET=		${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/}
177218130Simp.endif
178233644Sjmallett# Legacy names, for another transition period mips:mips(n32|64)?eb -> mips:mips\1
179218130Simp.if defined(TARGET) && defined(TARGET_ARCH) && \
180233644Sjmallett    ${TARGET} == "mips" && ${TARGET_ARCH:Mmips*eb}
181233644Sjmallett_TARGET_ARCH=		${TARGET_ARCH:C/eb$//}
182233644Sjmallett.warning "TARGET_ARCH of ${TARGET_ARCH} is deprecated in favor of ${_TARGET_ARCH}"
183218130Simp.endif
184233644Sjmallett.if defined(TARGET) && ${TARGET} == "mips" && defined(TARGET_BIG_ENDIAN)
185233644Sjmallett.warning "TARGET_BIG_ENDIAN is no longer necessary for MIPS.  Big-endian is not the default."
186218130Simp.endif
187218130Simp# arm with TARGET_BIG_ENDIAN -> armeb
188218130Simp.if defined(TARGET_ARCH) && ${TARGET_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN)
189218130Simp.warning "TARGET_ARCH of arm with TARGET_BIG_ENDIAN is deprecated.  use armeb"
190218130Simp_TARGET_ARCH=armeb
191218130Simp.endif
192218130Simp.if defined(TARGET) && !defined(_TARGET)
193218130Simp_TARGET=${TARGET}
194218130Simp.endif
195218130Simp.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
196218130Simp_TARGET_ARCH=${TARGET_ARCH}
197218130Simp.endif
198218130Simp# Otherwise, default to current machine type and architecture.
199218130Simp_TARGET?=	${MACHINE}
200218130Simp_TARGET_ARCH?=	${MACHINE_ARCH}
201218130Simp
20217308Speter#
203119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld
204119519Smarcel# should do this as those are the initial targets used for upgrades.
205119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed
206119519Smarcel# for all targets.
207119519Smarcel#
208294045Sbdrewery.if defined(ALWAYS_CHECK_MAKE) || !defined(.PARSEDIR)
209119579Sru${TGTS}: upgrade_checks
210119519Smarcel.else
211119519Smarcelbuildworld: upgrade_checks
212119519Smarcel.endif
213119519Smarcel
214119519Smarcel#
215126031Sgad# This 'cleanworld' target is not included in TGTS, because it is not a
216126024Sgad# recursive target.  All of the work for it is done right here.   It is
217126024Sgad# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
218126024Sgad# created by bsd.obj.mk, except that we don't want to .include that file
219126024Sgad# in this makefile.  
220126024Sgad#
221126024Sgad# In the following, the first 'rm' in a series will usually remove all
222126024Sgad# files and directories.  If it does not, then there are probably some
223227771Sgjb# files with file flags set, so this unsets them and tries the 'rm' a
224126024Sgad# second time.  There are situations where this target will be cleaning
225126024Sgad# some directories via more than one method, but that duplication is
226227769Sgjb# needed to correctly handle all the possible situations.  Removing all
227227771Sgjb# files without file flags set in the first 'rm' instance saves time,
228227771Sgjb# because 'chflags' will need to operate on fewer files afterwards.
229126024Sgad#
230126024SgadBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
231126031Sgadcleanworld:
232126024Sgad.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
233126024Sgad.if exists(${BW_CANONICALOBJDIR}/)
234126024Sgad	-rm -rf ${BW_CANONICALOBJDIR}/*
235172744Sdelphij	-chflags -R 0 ${BW_CANONICALOBJDIR}
236126024Sgad	rm -rf ${BW_CANONICALOBJDIR}/*
237126024Sgad.endif
238126024Sgad	#   To be safe in this case, fall back to a 'make cleandir'
239133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
240126024Sgad.else
241126024Sgad	-rm -rf ${.OBJDIR}/*
242172744Sdelphij	-chflags -R 0 ${.OBJDIR}
243126024Sgad	rm -rf ${.OBJDIR}/*
244126024Sgad.endif
245125885Sgad
246125885Sgad#
24738666Sjb# Handle the user-driven targets, using the source relative mk files.
24817308Speter#
249119519Smarcel
250289248Sbdrewery.if !(!empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n")
251251750Ssjg# skip this for -n to avoid changing previous behavior of 
252289248Sbdrewery# 'make -n buildworld' etc.  Using -n -n will run it.
253251750Ssjg${TGTS}: .MAKE
254254417Ssjgtinderbox toolchains kernel-toolchains: .MAKE
255251750Ssjg.endif
256251750Ssjg
257291777Sbdrewery${TGTS}: .PHONY
258218206Simp	${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
2592302Spaul
260265449Sbrooks# The historic default "all" target creates files which may cause stale
261265449Sbrooks# or (in the cross build case) unlinkable results. Fail with an error
262265449Sbrooks# when no target is given. The users can explicitly specify "all"
263265449Sbrooks# if they want the historic behavior.
264265449Sbrooks.MAIN:	_guard
26539206Sjkh
266265449Sbrooks_guard:
267265449Sbrooks	@echo
268265449Sbrooks	@echo "Explicit target required (use \"all\" for historic behavior)"
269265449Sbrooks	@echo
270265449Sbrooks	@false
271265449Sbrooks
272133945SruSTARTTIME!= LC_ALL=C date
273240403SobrienCHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo
274177609Sru.if !empty(CHECK_TIME)
275177609Sru.error check your date/time: ${STARTTIME}
276177609Sru.endif
277133945Sru
278132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
27917308Speter#
28054324Smarcel# world
28154324Smarcel#
282132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be
283132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is
284132234Smarcel# not included. One can argue that this target doesn't build everything
285132234Smarcel# then.
28654324Smarcel#
28754324Smarcelworld: upgrade_checks
28854324Smarcel	@echo "--------------------------------------------------------------"
289118531Sru	@echo ">>> make world started on ${STARTTIME}"
29054324Smarcel	@echo "--------------------------------------------------------------"
29154324Smarcel.if target(pre-world)
29254324Smarcel	@echo
29354324Smarcel	@echo "--------------------------------------------------------------"
29454324Smarcel	@echo ">>> Making 'pre-world' target"
29554324Smarcel	@echo "--------------------------------------------------------------"
296133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
29754324Smarcel.endif
298133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
299133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
30054324Smarcel.if target(post-world)
30154324Smarcel	@echo
30254324Smarcel	@echo "--------------------------------------------------------------"
30354324Smarcel	@echo ">>> Making 'post-world' target"
30454324Smarcel	@echo "--------------------------------------------------------------"
305133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
30654324Smarcel.endif
30754324Smarcel	@echo
30854324Smarcel	@echo "--------------------------------------------------------------"
309118531Sru	@echo ">>> make world completed on `LC_ALL=C date`"
310118531Sru	@echo "                   (started ${STARTTIME})"
31154324Smarcel	@echo "--------------------------------------------------------------"
312132234Smarcel.else
313132234Smarcelworld:
314132234Smarcel	@echo "WARNING: make world will overwrite your existing FreeBSD"
315132234Smarcel	@echo "installation without also building and installing a new"
316132234Smarcel	@echo "kernel.  This can be dangerous.  Please read the handbook,"
317132588Skensmith	@echo "'Rebuilding world', for how to upgrade your system."
318132358Smarkm	@echo "Define DESTDIR to where you want to install FreeBSD,"
319132234Smarcel	@echo "including /, to override this warning and proceed as usual."
320132358Smarkm	@echo ""
321132234Smarcel	@echo "Bailing out now..."
322132234Smarcel	@false
323132234Smarcel.endif
32454324Smarcel
32554324Smarcel#
32695730Sru# kernel
32795730Sru#
32895730Sru# Short hand for `make buildkernel installkernel'
32995730Sru#
33095730Srukernel: buildkernel installkernel
33195730Sru
33295730Sru#
33338666Sjb# Perform a few tests to determine if the installed tools are adequate
334107374Sru# for building the world.
33517308Speter#
33655678Smarcelupgrade_checks:
337296741Sbdrewery.if ${HAVE_MAKE} != ${WANT_MAKE} || \
338296741Sbdrewery    (defined(WANT_MAKE_VERSION) && ${MAKE_VERSION} < ${WANT_MAKE_VERSION})
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 \
361294044Sbdrewery		DESTDIR= -DNO_TESTS 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}; \
369291976Sbdrewery		${MMAKE} obj; \
370291976Sbdrewery		${MMAKE} depend; \
371291976Sbdrewery		${MMAKE} all; \
372255713Semaste		${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR=
37355678Smarcel
374254417Ssjgtinderbox toolchains kernel-toolchains: upgrade_checks
375254417Ssjg
376185499Salfredtinderbox:
377291976Sbdrewery	@cd ${.CURDIR}; ${SUB_MAKE} DOING_TINDERBOX=YES universe
378185499Salfred
379218524Sjhbtoolchains:
380291976Sbdrewery	@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
381218524Sjhb
382232907Sjmallettkernel-toolchains:
383291976Sbdrewery	@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
470291976Sbdrewery	@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 && \
485295679Sbapt		find [[:upper:][:digit:]]*[[:upper:][:digit:]] \
486295679Sbapt		-type f -maxdepth 0 \
487266383Sian		! -name DEFAULTS ! -name NOTES | \
488266383Sian		${_THINNER}
489201815Sbzuniverse_kernconfs:
490148154Sru.for kernel in ${KERNCONFS}
491219137SjhbTARGET_ARCH_${kernel}!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
492219137Sjhb	config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
493216934Simp	grep -v WARNING: | cut -f 2
494216934Simp.if empty(TARGET_ARCH_${kernel})
495216934Simp.error "Target architecture for ${TARGET}/conf/${kernel} unknown.  config(8) likely too old."
496216934Simp.endif
497216520Snwhitehornuniverse_kernconfs: universe_kernconf_${TARGET}_${kernel}
498254417Ssjguniverse_kernconf_${TARGET}_${kernel}: .MAKE
499185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
500253616Ssjg	    ${SUB_MAKE} ${JFLAG} buildkernel \
501201815Sbz	    TARGET=${TARGET} \
502216520Snwhitehorn	    TARGET_ARCH=${TARGET_ARCH_${kernel}} \
503148154Sru	    KERNCONF=${kernel} \
504201815Sbz	    > _.${TARGET}.${kernel} 2>&1 || \
505201815Sbz	    (echo "${TARGET} ${kernel} kernel failed," \
506201815Sbz	    "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
507148154Sru.endfor
508133945Sruuniverse: universe_epilogue
509133945Sruuniverse_epilogue:
510103985Sphk	@echo "--------------------------------------------------------------"
511118531Sru	@echo ">>> make universe completed on `LC_ALL=C date`"
512118531Sru	@echo "                      (started ${STARTTIME})"
513103985Sphk	@echo "--------------------------------------------------------------"
514185499Salfred.if defined(DOING_TINDERBOX)
515185499Salfred	@if [ -e ${FAILFILE} ] ; then \
516185499Salfred		echo "Tinderbox failed:" ;\
517185499Salfred		cat ${FAILFILE} ;\
518185499Salfred		exit 1 ;\
519185499Salfred	fi
520133945Sru.endif
521185499Salfred.endif
522242522Smarcel
523242522SmarcelbuildLINT:
524242522Smarcel	${MAKE} -C ${.CURDIR}/sys/${_TARGET}/conf LINT
525255286Ssjg
526255286Ssjg.if defined(.PARSEDIR)
527255286Ssjg.if make(universe)
528255286Ssjg# we do not want a failure of one branch abort all.
529255286SsjgMAKE_JOB_ERROR_TOKEN= no
530255286Ssjg.export MAKE_JOB_ERROR_TOKEN
531255286Ssjg.endif
532255286Ssjg.endif
533