Makefile revision 313790
12061Sjkh#
250479Speter# $FreeBSD: stable/10/Makefile 313790 2017-02-16 05:14:07Z ngie $
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).
24313790Sngie# checkworld          - Run test suite on installed world.
25169597Sdes# check-old           - List obsolete directories/files/libraries.
26169597Sdes# check-old-dirs      - List obsolete directories.
27169597Sdes# check-old-files     - List obsolete files.
28169597Sdes# check-old-libs      - List obsolete libraries.
29231821Spluknet# delete-old          - Delete obsolete directories/files.
30169597Sdes# delete-old-dirs     - Delete obsolete directories.
31169597Sdes# delete-old-files    - Delete obsolete files.
32169597Sdes# delete-old-libs     - Delete obsolete libraries.
33217815Sbz# targets             - Print a list of supported TARGET/TARGET_ARCH pairs
34217815Sbz#                       for world and kernel targets.
35218524Sjhb# toolchains          - Build a toolchain for all world and kernel targets.
36264811Sbrueffer# xdev                - xdev-build + xdev-install for the architecture
37264811Sbrueffer#                       specified with XDEV and XDEV_ARCH.
38264811Sbrueffer# xdev-build          - Build cross-development tools.
39264811Sbrueffer# xdev-install        - Install cross-development tools.
40281836Sgarga# native-xtools       - Create host binaries that produce target objects
41281836Sgarga#                       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#
88162147Sru# If TARGET=machine (e.g. ia64, 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#
102169597SdesTGTS=	all all-man buildenv buildenvvars buildkernel buildworld \
103313790Sngie	check check-old check-old-dirs check-old-files check-old-libs \
104313790Sngie	checkdpadd checkworld clean cleandepend cleandir \
105169597Sdes	delete-old delete-old-dirs delete-old-files delete-old-libs \
106219177Snwhitehorn	depend distribute distributekernel distributekernel.debug \
107219177Snwhitehorn	distributeworld distrib-dirs distribution doxygen \
108238051Sobrien	everything hier hierarchy install installcheck installkernel \
109219177Snwhitehorn	installkernel.debug packagekernel packageworld \
110219177Snwhitehorn	reinstallkernel reinstallkernel.debug \
111158962Snetchild	installworld kernel-toolchain libraries lint maninstall \
112313790Sngie	obj objlink rerelease showconfig tags toolchain update \
113123311Speter	_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
114137288Speter	_build-tools _cross-tools _includes _libraries _depend \
115209128Sraj	build32 builddtb distribute32 install32 xdev xdev-build xdev-install \
116281836Sgarga	native-xtools \
117209128Sraj
118156740SruTGTS+=	${SUBDIR_TARGETS}
1192061Sjkh
12097769SruBITGTS=	files includes
12197252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
122119579SruTGTS+=	${BITGTS}
12397252Sru
12495730Sru.ORDER: buildworld installworld
12595793Sru.ORDER: buildworld distributeworld
126111617Sru.ORDER: buildworld buildkernel
127296748Sbdrewery.ORDER: installworld distribution
128296748Sbdrewery.ORDER: installworld installkernel
12995730Sru.ORDER: buildkernel installkernel
130116679Ssimokawa.ORDER: buildkernel installkernel.debug
13195730Sru.ORDER: buildkernel reinstallkernel
132116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug
13395730Sru
134110035SruPATH=	/sbin:/bin:/usr/sbin:/usr/bin
135107516SruMAKEOBJDIRPREFIX?=	/usr/obj
136138921Sru_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
137156145Syar    ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
138138921Sru    -f /dev/null -V MAKEOBJDIRPREFIX dummy
139133942Sru.if !empty(_MAKEOBJDIRPREFIX)
140133942Sru.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
141156145Syar	(in make.conf(5)) or command-line variable.
142133942Sru.endif
143253616Ssjg
144253616Ssjg# We often need to use the tree's version of make to build it.
145253616Ssjg# Choices add to complexity though.
146253616Ssjg# We cannot blindly use a make which may not be the one we want
147253616Ssjg# so be exlicit - until all choice is removed.
148253616Ssjg.if !defined(WITHOUT_BMAKE)
149253616SsjgWANT_MAKE=	bmake
150253616Ssjg.else
151253616SsjgWANT_MAKE=	fmake
152253616Ssjg.endif
153253616SsjgMYMAKE=		${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}/${WANT_MAKE}
154253616Ssjg.if defined(.PARSEDIR)
155253616SsjgHAVE_MAKE=	bmake
156253616Ssjg.else
157253616SsjgHAVE_MAKE=	fmake
158253616Ssjg.endif
159301738Sbdrewery.if ${HAVE_MAKE} != ${WANT_MAKE} || \
160301738Sbdrewery    (defined(WANT_MAKE_VERSION) && ${MAKE_VERSION} < ${WANT_MAKE_VERSION})
161301738SbdreweryNEED_MAKE_UPGRADE= t
162301738Sbdrewery.endif
163253616Ssjg.if exists(${MYMAKE})
164253616SsjgSUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
165301738Sbdrewery.elif defined(NEED_MAKE_UPGRADE) || ${WANT_MAKE} != "bmake"
166253616Ssjg# It may not exist yet but we may cause it to.
167253616Ssjg# In the case of fmake, upgrade_checks may cause a newer version to be built.
168253616SsjgSUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
169117229Sru	-m ${.CURDIR}/share/mk
170253616Ssjg.else
171253616SsjgSUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
172253616Ssjg.endif
17354324Smarcel
174253616Ssjg_MAKE=	PATH=${PATH} ${SUB_MAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
175253616Ssjg
176218130Simp# Guess machine architecture from machine type, and vice versa.
177218130Simp.if !defined(TARGET_ARCH) && defined(TARGET)
178233644Sjmallett_TARGET_ARCH=	${TARGET:S/pc98/i386/}
179218130Simp.elif !defined(TARGET) && defined(TARGET_ARCH) && \
180218130Simp    ${TARGET_ARCH} != ${MACHINE_ARCH}
181239272Sgonzo_TARGET=		${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/}
182218130Simp.endif
183233644Sjmallett# Legacy names, for another transition period mips:mips(n32|64)?eb -> mips:mips\1
184218130Simp.if defined(TARGET) && defined(TARGET_ARCH) && \
185233644Sjmallett    ${TARGET} == "mips" && ${TARGET_ARCH:Mmips*eb}
186233644Sjmallett_TARGET_ARCH=		${TARGET_ARCH:C/eb$//}
187233644Sjmallett.warning "TARGET_ARCH of ${TARGET_ARCH} is deprecated in favor of ${_TARGET_ARCH}"
188218130Simp.endif
189233644Sjmallett.if defined(TARGET) && ${TARGET} == "mips" && defined(TARGET_BIG_ENDIAN)
190233644Sjmallett.warning "TARGET_BIG_ENDIAN is no longer necessary for MIPS.  Big-endian is not the default."
191218130Simp.endif
192218130Simp# arm with TARGET_BIG_ENDIAN -> armeb
193218130Simp.if defined(TARGET_ARCH) && ${TARGET_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN)
194218130Simp.warning "TARGET_ARCH of arm with TARGET_BIG_ENDIAN is deprecated.  use armeb"
195218130Simp_TARGET_ARCH=armeb
196218130Simp.endif
197218130Simp.if defined(TARGET) && !defined(_TARGET)
198218130Simp_TARGET=${TARGET}
199218130Simp.endif
200218130Simp.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
201218130Simp_TARGET_ARCH=${TARGET_ARCH}
202218130Simp.endif
203218130Simp# Otherwise, default to current machine type and architecture.
204218130Simp_TARGET?=	${MACHINE}
205218130Simp_TARGET_ARCH?=	${MACHINE_ARCH}
206218130Simp
20717308Speter#
208119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld
209119519Smarcel# should do this as those are the initial targets used for upgrades.
210119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed
211119519Smarcel# for all targets.
212119519Smarcel#
213294045Sbdrewery.if defined(ALWAYS_CHECK_MAKE) || !defined(.PARSEDIR)
214119579Sru${TGTS}: upgrade_checks
215119519Smarcel.else
216119519Smarcelbuildworld: upgrade_checks
217119519Smarcel.endif
218119519Smarcel
219119519Smarcel#
220126031Sgad# This 'cleanworld' target is not included in TGTS, because it is not a
221126024Sgad# recursive target.  All of the work for it is done right here.   It is
222126024Sgad# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
223126024Sgad# created by bsd.obj.mk, except that we don't want to .include that file
224126024Sgad# in this makefile.  
225126024Sgad#
226126024Sgad# In the following, the first 'rm' in a series will usually remove all
227126024Sgad# files and directories.  If it does not, then there are probably some
228227771Sgjb# files with file flags set, so this unsets them and tries the 'rm' a
229126024Sgad# second time.  There are situations where this target will be cleaning
230126024Sgad# some directories via more than one method, but that duplication is
231227769Sgjb# needed to correctly handle all the possible situations.  Removing all
232227771Sgjb# files without file flags set in the first 'rm' instance saves time,
233227771Sgjb# because 'chflags' will need to operate on fewer files afterwards.
234126024Sgad#
235126024SgadBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
236126031Sgadcleanworld:
237126024Sgad.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
238126024Sgad.if exists(${BW_CANONICALOBJDIR}/)
239126024Sgad	-rm -rf ${BW_CANONICALOBJDIR}/*
240172744Sdelphij	-chflags -R 0 ${BW_CANONICALOBJDIR}
241126024Sgad	rm -rf ${BW_CANONICALOBJDIR}/*
242126024Sgad.endif
243126024Sgad	#   To be safe in this case, fall back to a 'make cleandir'
244133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
245126024Sgad.else
246126024Sgad	-rm -rf ${.OBJDIR}/*
247172744Sdelphij	-chflags -R 0 ${.OBJDIR}
248126024Sgad	rm -rf ${.OBJDIR}/*
249126024Sgad.endif
250125885Sgad
251125885Sgad#
25238666Sjb# Handle the user-driven targets, using the source relative mk files.
25317308Speter#
254119519Smarcel
255289248Sbdrewery.if !(!empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n")
256251750Ssjg# skip this for -n to avoid changing previous behavior of 
257289248Sbdrewery# 'make -n buildworld' etc.  Using -n -n will run it.
258251750Ssjg${TGTS}: .MAKE
259254417Ssjgtinderbox toolchains kernel-toolchains: .MAKE
260251750Ssjg.endif
261251750Ssjg
262291777Sbdrewery${TGTS}: .PHONY
263218206Simp	${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
2642302Spaul
265265449Sbrooks# The historic default "all" target creates files which may cause stale
266265449Sbrooks# or (in the cross build case) unlinkable results. Fail with an error
267265449Sbrooks# when no target is given. The users can explicitly specify "all"
268265449Sbrooks# if they want the historic behavior.
269265449Sbrooks.MAIN:	_guard
27039206Sjkh
271265449Sbrooks_guard:
272265449Sbrooks	@echo
273265449Sbrooks	@echo "Explicit target required (use \"all\" for historic behavior)"
274265449Sbrooks	@echo
275265449Sbrooks	@false
276265449Sbrooks
277133945SruSTARTTIME!= LC_ALL=C date
278240403SobrienCHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo
279177609Sru.if !empty(CHECK_TIME)
280177609Sru.error check your date/time: ${STARTTIME}
281177609Sru.endif
282133945Sru
283132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
28417308Speter#
28554324Smarcel# world
28654324Smarcel#
287132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be
288132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is
289132234Smarcel# not included. One can argue that this target doesn't build everything
290132234Smarcel# then.
29154324Smarcel#
29254324Smarcelworld: upgrade_checks
29354324Smarcel	@echo "--------------------------------------------------------------"
294118531Sru	@echo ">>> make world started on ${STARTTIME}"
29554324Smarcel	@echo "--------------------------------------------------------------"
29654324Smarcel.if target(pre-world)
29754324Smarcel	@echo
29854324Smarcel	@echo "--------------------------------------------------------------"
29954324Smarcel	@echo ">>> Making 'pre-world' target"
30054324Smarcel	@echo "--------------------------------------------------------------"
301133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
30254324Smarcel.endif
303133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
304133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
30554324Smarcel.if target(post-world)
30654324Smarcel	@echo
30754324Smarcel	@echo "--------------------------------------------------------------"
30854324Smarcel	@echo ">>> Making 'post-world' target"
30954324Smarcel	@echo "--------------------------------------------------------------"
310133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
31154324Smarcel.endif
31254324Smarcel	@echo
31354324Smarcel	@echo "--------------------------------------------------------------"
314118531Sru	@echo ">>> make world completed on `LC_ALL=C date`"
315118531Sru	@echo "                   (started ${STARTTIME})"
31654324Smarcel	@echo "--------------------------------------------------------------"
317132234Smarcel.else
318132234Smarcelworld:
319132234Smarcel	@echo "WARNING: make world will overwrite your existing FreeBSD"
320132234Smarcel	@echo "installation without also building and installing a new"
321132234Smarcel	@echo "kernel.  This can be dangerous.  Please read the handbook,"
322132588Skensmith	@echo "'Rebuilding world', for how to upgrade your system."
323132358Smarkm	@echo "Define DESTDIR to where you want to install FreeBSD,"
324132234Smarcel	@echo "including /, to override this warning and proceed as usual."
325132358Smarkm	@echo ""
326132234Smarcel	@echo "Bailing out now..."
327132234Smarcel	@false
328132234Smarcel.endif
32954324Smarcel
33054324Smarcel#
33195730Sru# kernel
33295730Sru#
33395730Sru# Short hand for `make buildkernel installkernel'
33495730Sru#
33595730Srukernel: buildkernel installkernel
33695730Sru
33795730Sru#
33838666Sjb# Perform a few tests to determine if the installed tools are adequate
339107374Sru# for building the world.
34017308Speter#
34155678Smarcelupgrade_checks:
342301738Sbdrewery.if defined(NEED_MAKE_UPGRADE)
343297035Sbdrewery	@${_+_}(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
344253616Ssjg.elif ${WANT_MAKE} == "fmake"
345143032Sharti	@if ! (cd ${.CURDIR}/tools/build/make_check && \
346138515Sharti	    PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \
347117793Sru	    PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
348110035Sru	then \
349174564Simp	    (cd ${.CURDIR} && ${MAKE} make); \
350110035Sru	fi
351241298Smarcel.endif
3522061Sjkh
35317308Speter#
354107516Sru# Upgrade make(1) to the current version using the installed
355174539Simp# headers, libraries and tools.  Also, allow the location of
356174539Simp# the system bsdmake-like utility to be overridden.
35755678Smarcel#
358253616SsjgMMAKEENV=	MAKEOBJDIRPREFIX=${MYMAKE:H} \
359107516Sru		DESTDIR= \
360107516Sru		INSTALL="sh ${.CURDIR}/tools/install.sh"
361174564SimpMMAKE=		${MMAKEENV} ${MAKE} \
362107516Sru		-D_UPGRADING \
363139112Sru		-DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \
364264996Sjmmv		-DNO_CPU_CFLAGS -DNO_WERROR \
365294044Sbdrewery		DESTDIR= -DNO_TESTS PROGNAME=${MYMAKE:T}
366107516Sru
367249395Ssjgmake bmake: .PHONY
36855678Smarcel	@echo
36955678Smarcel	@echo "--------------------------------------------------------------"
370116696Sru	@echo ">>> Building an up-to-date make(1)"
37155678Smarcel	@echo "--------------------------------------------------------------"
372249395Ssjg	${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
373291976Sbdrewery		${MMAKE} obj; \
374291976Sbdrewery		${MMAKE} depend; \
375291976Sbdrewery		${MMAKE} all; \
376255713Semaste		${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR=
37755678Smarcel
378313790Sngieregress: .PHONY
379313790Sngie	@echo "'make regress' has been renamed 'make check'" | /usr/bin/fmt
380313790Sngie	@false
381313790Sngie
382254417Ssjgtinderbox toolchains kernel-toolchains: upgrade_checks
383254417Ssjg
384185499Salfredtinderbox:
385291976Sbdrewery	@cd ${.CURDIR}; ${SUB_MAKE} DOING_TINDERBOX=YES universe
386185499Salfred
387218524Sjhbtoolchains:
388291976Sbdrewery	@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
389218524Sjhb
390232907Sjmallettkernel-toolchains:
391291976Sbdrewery	@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
392232907Sjmallett
39355678Smarcel#
394111131Sru# universe
395111131Sru#
396111131Sru# Attempt to rebuild *everything* for all supported architectures,
397133945Sru# with a reasonable chance of success, regardless of how old your
398111131Sru# existing system is.
399111131Sru#
400217125Simp.if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets)
401221869SattilioTARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64
402255784SandrewTARGET_ARCHES_arm?=	arm armeb armv6
403233644SjmallettTARGET_ARCHES_mips?=	mipsel mips mips64el mips64 mipsn32
404216520SnwhitehornTARGET_ARCHES_powerpc?=	powerpc powerpc64
405216520SnwhitehornTARGET_ARCHES_pc98?=	i386
406216520Snwhitehorn.for target in ${TARGETS}
407216520SnwhitehornTARGET_ARCHES_${target}?= ${target}
408216520Snwhitehorn.endfor
409168280Smarcel
410218524Sjhb.if defined(UNIVERSE_TARGET)
411218524SjhbMAKE_JUST_WORLDS=	YES
412218524Sjhb.else
413218524SjhbUNIVERSE_TARGET?=	buildworld
414218524Sjhb.endif
415219137SjhbKERNSRCDIR?=		${.CURDIR}/sys
416218524Sjhb
417217125Simptargets:
418217815Sbz	@echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
419217125Simp.for target in ${TARGETS}
420217125Simp.for target_arch in ${TARGET_ARCHES_${target}}
421217125Simp	@echo "    ${target}/${target_arch}"
422217125Simp.endfor
423217125Simp.endfor
424217125Simp
425185499Salfred.if defined(DOING_TINDERBOX)
426217735SbzFAILFILE=${.CURDIR}/_.tinderbox.failed
427185499SalfredMAKEFAIL=tee -a ${FAILFILE}
428185499Salfred.else
429185499SalfredMAKEFAIL=cat
430185499Salfred.endif
431185499Salfred
432253616Ssjguniverse_prologue:  upgrade_checks
433253616Ssjguniverse: universe_prologue
434133945Sruuniverse_prologue:
435103985Sphk	@echo "--------------------------------------------------------------"
436103985Sphk	@echo ">>> make universe started on ${STARTTIME}"
437103985Sphk	@echo "--------------------------------------------------------------"
438185499Salfred.if defined(DOING_TINDERBOX)
439217754Sbz	@rm -f ${FAILFILE}
440185499Salfred.endif
441168280Smarcel.for target in ${TARGETS}
442162147Sruuniverse: universe_${target}
443253616Ssjguniverse_epilogue: universe_${target}
444216520Snwhitehornuniverse_${target}: universe_${target}_prologue
445253616Ssjguniverse_${target}_prologue: universe_prologue
446216520Snwhitehorn	@echo ">> ${target} started on `LC_ALL=C date`"
447179232Sjb.if !defined(MAKE_JUST_KERNELS)
448216520Snwhitehorn.for target_arch in ${TARGET_ARCHES_${target}}
449216520Snwhitehornuniverse_${target}: universe_${target}_${target_arch}
450254417Ssjguniverse_${target}_${target_arch}: universe_${target}_prologue .MAKE
451218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
452185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
453253616Ssjg	    ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
454162147Sru	    TARGET=${target} \
455216520Snwhitehorn	    TARGET_ARCH=${target_arch} \
456218524Sjhb	    > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
457218524Sjhb	    (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
458218524Sjhb	    "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
459216520Snwhitehorn	    ${MAKEFAIL}))
460218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
461216520Snwhitehorn.endfor
462179232Sjb.endif
463205290Sdougb.if !defined(MAKE_JUST_WORLDS)
464248937Sandrew# If we are building world and kernels wait for the required worlds to finish
465248937Sandrew.if !defined(MAKE_JUST_KERNELS)
466248937Sandrew.for target_arch in ${TARGET_ARCHES_${target}}
467248937Sandrewuniverse_${target}_kernels: universe_${target}_${target_arch}
468248937Sandrew.endfor
469248937Sandrew.endif
470248937Sandrewuniverse_${target}: universe_${target}_kernels
471254417Ssjguniverse_${target}_kernels: universe_${target}_prologue .MAKE
472219137Sjhb.if exists(${KERNSRCDIR}/${target}/conf/NOTES)
473219137Sjhb	@(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
474253616Ssjg	    ${SUB_MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
475185499Salfred	    (echo "${target} 'make LINT' failed," \
476185499Salfred	    "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
477103985Sphk.endif
478291976Sbdrewery	@cd ${.CURDIR}; ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
479201815Sbz	    universe_kernels
480205290Sdougb.endif
481201815Sbz	@echo ">> ${target} completed on `LC_ALL=C date`"
482201815Sbz.endfor
483201815Sbzuniverse_kernels: universe_kernconfs
484202095Sbz.if !defined(TARGET)
485202095SbzTARGET!=	uname -m
486202095Sbz.endif
487266383Sian.if defined(MAKE_ALL_KERNELS)
488266383Sian_THINNER=cat
489266383Sian.else
490276281Sian_THINNER=xargs grep -L "^.NO_UNIVERSE" || true
491266383Sian.endif
492219137SjhbKERNCONFS!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
493295679Sbapt		find [[:upper:][:digit:]]*[[:upper:][:digit:]] \
494295679Sbapt		-type f -maxdepth 0 \
495266383Sian		! -name DEFAULTS ! -name NOTES | \
496266383Sian		${_THINNER}
497201815Sbzuniverse_kernconfs:
498148154Sru.for kernel in ${KERNCONFS}
499219137SjhbTARGET_ARCH_${kernel}!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
500219137Sjhb	config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
501216934Simp	grep -v WARNING: | cut -f 2
502216934Simp.if empty(TARGET_ARCH_${kernel})
503216934Simp.error "Target architecture for ${TARGET}/conf/${kernel} unknown.  config(8) likely too old."
504216934Simp.endif
505216520Snwhitehornuniverse_kernconfs: universe_kernconf_${TARGET}_${kernel}
506254417Ssjguniverse_kernconf_${TARGET}_${kernel}: .MAKE
507185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
508253616Ssjg	    ${SUB_MAKE} ${JFLAG} buildkernel \
509201815Sbz	    TARGET=${TARGET} \
510216520Snwhitehorn	    TARGET_ARCH=${TARGET_ARCH_${kernel}} \
511148154Sru	    KERNCONF=${kernel} \
512201815Sbz	    > _.${TARGET}.${kernel} 2>&1 || \
513201815Sbz	    (echo "${TARGET} ${kernel} kernel failed," \
514201815Sbz	    "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
515148154Sru.endfor
516133945Sruuniverse: universe_epilogue
517133945Sruuniverse_epilogue:
518103985Sphk	@echo "--------------------------------------------------------------"
519118531Sru	@echo ">>> make universe completed on `LC_ALL=C date`"
520118531Sru	@echo "                      (started ${STARTTIME})"
521103985Sphk	@echo "--------------------------------------------------------------"
522185499Salfred.if defined(DOING_TINDERBOX)
523185499Salfred	@if [ -e ${FAILFILE} ] ; then \
524185499Salfred		echo "Tinderbox failed:" ;\
525185499Salfred		cat ${FAILFILE} ;\
526185499Salfred		exit 1 ;\
527185499Salfred	fi
528133945Sru.endif
529185499Salfred.endif
530242522Smarcel
531242522SmarcelbuildLINT:
532242522Smarcel	${MAKE} -C ${.CURDIR}/sys/${_TARGET}/conf LINT
533255286Ssjg
534255286Ssjg.if defined(.PARSEDIR)
535255286Ssjg.if make(universe)
536255286Ssjg# we do not want a failure of one branch abort all.
537255286SsjgMAKE_JOB_ERROR_TOKEN= no
538255286Ssjg.export MAKE_JOB_ERROR_TOKEN
539255286Ssjg.endif
540255286Ssjg.endif
541