Makefile revision 302067
12061Sjkh#
250479Speter# $FreeBSD: head/Makefile 302067 2016-06-21 20:14:32Z 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).
24295380Sngie# 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.
36264460Sbrueffer# xdev                - xdev-build + xdev-install for the architecture
37264460Sbrueffer#                       specified with XDEV and XDEV_ARCH.
38264460Sbrueffer# xdev-build          - Build cross-development tools.
39264460Sbrueffer# xdev-install        - Install cross-development tools.
40268503Simp# xdev-links          - Create traditional links in /usr/bin for cc, etc
41270155Simp# native-xtools       - Create host binaries that produce target objects
42270155Simp#                       for use in qemu user-mode jails.
43253002Salfred# 
44253002Salfred# "quick" way to test all kernel builds:
45253002Salfred# 	_jflag=`sysctl -n hw.ncpu`
46253002Salfred# 	_jflag=$(($_jflag * 2))
47253002Salfred# 	[ $_jflag -gt 12 ] && _jflag=12
48253003Salfred# 	make universe -DMAKE_JUST_KERNELS JFLAG=-j${_jflag}
4932427Sjb#
5038666Sjb# This makefile is simple by design. The FreeBSD make automatically reads
51108451Sschweikh# the /usr/share/mk/sys.mk unless the -m argument is specified on the
5238666Sjb# command line. By keeping this makefile simple, it doesn't matter too
5338666Sjb# much how different the installed mk files are from those in the source
5438666Sjb# tree. This makefile executes a child make process, forcing it to use
5538666Sjb# the mk files from the source tree which are supposed to DTRT.
5617308Speter#
57217273Simp# Most of the user-driven targets (as listed above) are implemented in
58217294Simp# Makefile.inc1.  The exceptions are universe, tinderbox and targets.
5919175Sbde#
6096205Sjwd# If you want to build your system from source be sure that /usr/obj has
61292217Semaste# at least 6GB of diskspace available.  A complete 'universe' build requires
62292217Semaste# about 100GB of space.
6338042Sbde#
6496205Sjwd# For individuals wanting to build from the sources currently on their
6596205Sjwd# system, the simple instructions are:
6638042Sbde#
6796205Sjwd# 1.  `cd /usr/src'  (or to the directory containing your source tree).
68159363Strhodes# 2.  Define `HISTORICAL_MAKE_WORLD' variable (see README).
69159363Strhodes# 3.  `make world'
7017308Speter#
7196205Sjwd# For individuals wanting to upgrade their sources (even if only a
7296205Sjwd# delta of a few days):
7317308Speter#
74148330Snetchild#  1.  `cd /usr/src'       (or to the directory containing your source tree).
75148330Snetchild#  2.  `make buildworld'
76148330Snetchild#  3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
77148330Snetchild#  4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
78159831Sobrien#       [steps 3. & 4. can be combined by using the "kernel" target]
79148330Snetchild#  5.  `reboot'        (in single user mode: boot -s from the loader prompt).
80148330Snetchild#  6.  `mergemaster -p'
81148330Snetchild#  7.  `make installworld'
82251107Screes#  8.  `mergemaster'		(you may wish to use -i, along with -U or -F).
83251107Screes#  9.  `make delete-old'
84148330Snetchild# 10.  `reboot'
85148330Snetchild# 11.  `make delete-old-libs' (in case no 3rd party program uses them anymore)
8696205Sjwd#
8796205Sjwd# See src/UPDATING `COMMON ITEMS' for more complete information.
8896205Sjwd#
89268191Smarcel# If TARGET=machine (e.g. powerpc, sparc64, ...) is specified you can
90162147Sru# cross build world for other machine types using the buildworld target,
9198723Sdillon# and once the world is built you can cross build a kernel using the
9298723Sdillon# buildkernel target.
9398723Sdillon#
9438666Sjb# Define the user-driven targets. These are listed here in alphabetical
9538666Sjb# order, but that's not important.
9617308Speter#
97123311Speter# Targets that begin with underscore are internal targets intended for
98123311Speter# developer convenience only.  They are intentionally not documented and
99123311Speter# completely subject to change without notice.
100123311Speter#
101175833Sjhb# For more information, see the build(7) manual page.
102175833Sjhb#
103284454Simp
104290526Sbdrewery# This is included so CC is set to ccache for -V, and COMPILER_TYPE/VERSION
105290526Sbdrewery# can be cached for sub-makes.
106302067Sbdrewery.if ${MAKE_VERSION} >= 20140620 && defined(.PARSEDIR)
107290526Sbdrewery.include <bsd.compiler.mk>
108301472Sbdrewery.endif
109290526Sbdrewery
110284454Simp# Note: we use this awkward construct to be compatible with FreeBSD's
111284454Simp# old make used in 10.0 and 9.2 and earlier.
112290816Ssjg.if defined(MK_DIRDEPS_BUILD) && ${MK_DIRDEPS_BUILD} == "yes" && !make(showconfig)
113284345Ssjg# targets/Makefile plays the role of top-level
114284345Ssjg.include "targets/Makefile"
115284345Ssjg.else
116284345Ssjg
117169597SdesTGTS=	all all-man buildenv buildenvvars buildkernel buildworld \
118295380Sngie	check check-old check-old-dirs check-old-files check-old-libs \
119295380Sngie	checkdpadd checkworld clean cleandepend cleandir cleanworld \
120169597Sdes	delete-old delete-old-dirs delete-old-files delete-old-libs \
121219177Snwhitehorn	depend distribute distributekernel distributekernel.debug \
122219177Snwhitehorn	distributeworld distrib-dirs distribution doxygen \
123238051Sobrien	everything hier hierarchy install installcheck installkernel \
124219177Snwhitehorn	installkernel.debug packagekernel packageworld \
125219177Snwhitehorn	reinstallkernel reinstallkernel.debug \
126158962Snetchild	installworld kernel-toolchain libraries lint maninstall \
127295380Sngie	obj objlink rerelease showconfig tags toolchain update \
128123311Speter	_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
129297434Sbdrewery	_build-tools _cross-tools _includes _libraries \
130297988Sbdrewery	build32 distribute32 install32 buildsoft distributesoft installsoft \
131296779Simp	builddtb xdev xdev-build xdev-install \
132298107Sgjb	xdev-links native-xtools stageworld stagekernel stage-packages \
133298107Sgjb	create-world-packages create-kernel-packages create-packages \
134298107Sgjb	packages installconfig real-packages sign-packages package-pkg
135209128Sraj
136301887Sbdrewery# XXX: r156740: This can't work since bsd.subdir.mk is not included ever.
137301887Sbdrewery# It will only work for SUBDIR_TARGETS in make.conf.
138156740SruTGTS+=	${SUBDIR_TARGETS}
1392061Sjkh
14097769SruBITGTS=	files includes
14197252SruBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
142119579SruTGTS+=	${BITGTS}
14397252Sru
144301887Sbdrewery# Only some targets are allowed to use meta mode.  Others get it
145301887Sbdrewery# disabled.  In some cases, such as 'install', meta mode can be dangerous
146301887Sbdrewery# as a cookie may be used to prevent redundant installations (such as
147301887Sbdrewery# for WORLDTMP staging).  For DESTDIR=/ we always want to install though.
148301887Sbdrewery# For other cases, such as delete-old-libs, meta mode may break
149301887Sbdrewery# the interactive tty prompt.  The safest route is to just whitelist
150301887Sbdrewery# the ones that benefit from it.
151301887SbdreweryMETA_TGT_WHITELIST+= \
152301887Sbdrewery	_* build32 buildfiles buildincludes buildkernel buildsoft \
153301940Sbdrewery	buildworld everything kernel-toolchains kernel kernels libraries \
154301894Sbdrewery	native-xtools showconfig tinderbox toolchain toolchains universe \
155301940Sbdrewery	world worlds xdev xdev-build
156301887Sbdrewery
15795730Sru.ORDER: buildworld installworld
15895793Sru.ORDER: buildworld distributeworld
159111617Sru.ORDER: buildworld buildkernel
160295161Sbdrewery.ORDER: installworld distribution
161296014Sbdrewery.ORDER: installworld installkernel
16295730Sru.ORDER: buildkernel installkernel
163116679Ssimokawa.ORDER: buildkernel installkernel.debug
16495730Sru.ORDER: buildkernel reinstallkernel
165116679Ssimokawa.ORDER: buildkernel reinstallkernel.debug
16695730Sru
167110035SruPATH=	/sbin:/bin:/usr/sbin:/usr/bin
168107516SruMAKEOBJDIRPREFIX?=	/usr/obj
169296549Sbdrewery_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} MK_AUTO_OBJ=no ${MAKE} \
170293288Sbdrewery    ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
171293288Sbdrewery    -f /dev/null -V MAKEOBJDIRPREFIX dummy
172293288Sbdrewery.if !empty(_MAKEOBJDIRPREFIX)
173293288Sbdrewery.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
174293288Sbdrewery	(in make.conf(5)) or command-line variable.
175293288Sbdrewery.endif
176253616Ssjg
177253616Ssjg# We often need to use the tree's version of make to build it.
178253616Ssjg# Choices add to complexity though.
179253616Ssjg# We cannot blindly use a make which may not be the one we want
180253616Ssjg# so be exlicit - until all choice is removed.
181253616SsjgWANT_MAKE=	bmake
182301466Sbdrewery.if !empty(.MAKE.MODE:Mmeta)
183301466Sbdrewery# 20160604 - support missing-meta,missing-filemon and performance improvements
184301466SbdreweryWANT_MAKE_VERSION= 20160604
185301466Sbdrewery.else
186296646Sbdrewery# 20160220 - support .dinclude for FAST_DEPEND.
187296646SbdreweryWANT_MAKE_VERSION= 20160220
188301466Sbdrewery.endif
189253616SsjgMYMAKE=		${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}/${WANT_MAKE}
190253616Ssjg.if defined(.PARSEDIR)
191253616SsjgHAVE_MAKE=	bmake
192253616Ssjg.else
193253616SsjgHAVE_MAKE=	fmake
194253616Ssjg.endif
195301465Sbdrewery.if ${HAVE_MAKE} != ${WANT_MAKE} || \
196301465Sbdrewery    (defined(WANT_MAKE_VERSION) && ${MAKE_VERSION} < ${WANT_MAKE_VERSION})
197301465SbdreweryNEED_MAKE_UPGRADE= t
198301465Sbdrewery.endif
199253616Ssjg.if exists(${MYMAKE})
200253616SsjgSUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
201301465Sbdrewery.elif defined(NEED_MAKE_UPGRADE)
202253616Ssjg# It may not exist yet but we may cause it to.
203253616Ssjg# In the case of fmake, upgrade_checks may cause a newer version to be built.
204253616SsjgSUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
205117229Sru	-m ${.CURDIR}/share/mk
206253616Ssjg.else
207253616SsjgSUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
208253616Ssjg.endif
20954324Smarcel
210253616Ssjg_MAKE=	PATH=${PATH} ${SUB_MAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
211253616Ssjg
212301887Sbdrewery# Only allow meta mode for the whitelisted targets.  See META_TGT_WHITELIST
213301887Sbdrewery# above.
214301887Sbdrewery.for _tgt in ${META_TGT_WHITELIST}
215301887Sbdrewery.if make(${_tgt})
216301887Sbdrewery_CAN_USE_META_MODE?= yes
217301887Sbdrewery.endif
218301887Sbdrewery.endfor
219301887Sbdrewery.if !defined(_CAN_USE_META_MODE)
220298220Sbdrewery_MAKE+=	MK_META_MODE=no
221302067Sbdrewery.if defined(.PARSEDIR)
222298221Sbdrewery.unexport META_MODE
223302067Sbdrewery.endif
224301893Sbdrewery.elif defined(MK_META_MODE) && ${MK_META_MODE} == "yes"
225301888Sbdrewery.if !exists(/dev/filemon) && !defined(NO_FILEMON) && !make(showconfig)
226301888Sbdrewery# Require filemon be loaded to provide a working incremental build
227301888Sbdrewery.error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded. \
228301888Sbdrewery    ${.newline}ERROR: WITH_META_MODE is enabled but requires filemon for an incremental build. \
229301888Sbdrewery    ${.newline}ERROR: 'kldload filemon' or pass -DNO_FILEMON to suppress this error.
230301888Sbdrewery.endif	# !exists(/dev/filemon) && !defined(NO_FILEMON)
231301887Sbdrewery.endif	# !defined(_CAN_USE_META_MODE)
232298220Sbdrewery
233218130Simp# Guess machine architecture from machine type, and vice versa.
234218130Simp.if !defined(TARGET_ARCH) && defined(TARGET)
235280259Sandrew_TARGET_ARCH=	${TARGET:S/pc98/i386/:S/arm64/aarch64/}
236218130Simp.elif !defined(TARGET) && defined(TARGET_ARCH) && \
237218130Simp    ${TARGET_ARCH} != ${MACHINE_ARCH}
238300119Simp_TARGET=		${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/:C/aarch64/arm64/:C/powerpc64/powerpc/:C/riscv64/riscv/}
239218130Simp.endif
240218130Simp.if defined(TARGET) && !defined(_TARGET)
241218130Simp_TARGET=${TARGET}
242218130Simp.endif
243218130Simp.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
244218130Simp_TARGET_ARCH=${TARGET_ARCH}
245218130Simp.endif
246269048Simp# for historical compatibility for xdev targets
247269048Simp.if defined(XDEV)
248269048Simp_TARGET=	${XDEV}
249269048Simp.endif
250269048Simp.if defined(XDEV_ARCH)
251269048Simp_TARGET_ARCH=	${XDEV_ARCH}
252269048Simp.endif
253218130Simp# Otherwise, default to current machine type and architecture.
254218130Simp_TARGET?=	${MACHINE}
255218130Simp_TARGET_ARCH?=	${MACHINE_ARCH}
256218130Simp
25717308Speter#
258119519Smarcel# Make sure we have an up-to-date make(1). Only world and buildworld
259119519Smarcel# should do this as those are the initial targets used for upgrades.
260119519Smarcel# The user can define ALWAYS_CHECK_MAKE to have this check performed
261119519Smarcel# for all targets.
262119519Smarcel#
263293342Sbdrewery.if defined(ALWAYS_CHECK_MAKE) || !defined(.PARSEDIR)
264119579Sru${TGTS}: upgrade_checks
265119519Smarcel.else
266119519Smarcelbuildworld: upgrade_checks
267119519Smarcel.endif
268119519Smarcel
269119519Smarcel#
27038666Sjb# Handle the user-driven targets, using the source relative mk files.
27117308Speter#
272119519Smarcel
273254417Ssjgtinderbox toolchains kernel-toolchains: .MAKE
274289460Sbdrewery${TGTS}: .PHONY .MAKE
275218206Simp	${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
2762302Spaul
277265097Sbrooks# The historic default "all" target creates files which may cause stale
278265097Sbrooks# or (in the cross build case) unlinkable results. Fail with an error
279265097Sbrooks# when no target is given. The users can explicitly specify "all"
280265097Sbrooks# if they want the historic behavior.
281265097Sbrooks.MAIN:	_guard
28239206Sjkh
283289411Sbdrewery_guard: .PHONY
284265097Sbrooks	@echo
285289432Sbdrewery	@echo "Explicit target required.  Likely \"${SUBDIR_OVERRIDE:Dall:Ubuildworld}\" is wanted.  See build(7)."
286265097Sbrooks	@echo
287265097Sbrooks	@false
288265097Sbrooks
289133945SruSTARTTIME!= LC_ALL=C date
290240403SobrienCHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo
291177609Sru.if !empty(CHECK_TIME)
292177609Sru.error check your date/time: ${STARTTIME}
293177609Sru.endif
294133945Sru
295132358Smarkm.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
29617308Speter#
29754324Smarcel# world
29854324Smarcel#
299132234Smarcel# Attempt to rebuild and reinstall everything. This target is not to be
300132234Smarcel# used for upgrading an existing FreeBSD system, because the kernel is
301132234Smarcel# not included. One can argue that this target doesn't build everything
302132234Smarcel# then.
30354324Smarcel#
304301885Sbdreweryworld: upgrade_checks .PHONY
30554324Smarcel	@echo "--------------------------------------------------------------"
306118531Sru	@echo ">>> make world started on ${STARTTIME}"
30754324Smarcel	@echo "--------------------------------------------------------------"
30854324Smarcel.if target(pre-world)
30954324Smarcel	@echo
31054324Smarcel	@echo "--------------------------------------------------------------"
31154324Smarcel	@echo ">>> Making 'pre-world' target"
31254324Smarcel	@echo "--------------------------------------------------------------"
313133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
31454324Smarcel.endif
315133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
316133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
31754324Smarcel.if target(post-world)
31854324Smarcel	@echo
31954324Smarcel	@echo "--------------------------------------------------------------"
32054324Smarcel	@echo ">>> Making 'post-world' target"
32154324Smarcel	@echo "--------------------------------------------------------------"
322133376Sharti	${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
32354324Smarcel.endif
32454324Smarcel	@echo
32554324Smarcel	@echo "--------------------------------------------------------------"
326118531Sru	@echo ">>> make world completed on `LC_ALL=C date`"
327118531Sru	@echo "                   (started ${STARTTIME})"
32854324Smarcel	@echo "--------------------------------------------------------------"
329132234Smarcel.else
330301885Sbdreweryworld: .PHONY
331132234Smarcel	@echo "WARNING: make world will overwrite your existing FreeBSD"
332132234Smarcel	@echo "installation without also building and installing a new"
333132234Smarcel	@echo "kernel.  This can be dangerous.  Please read the handbook,"
334132588Skensmith	@echo "'Rebuilding world', for how to upgrade your system."
335132358Smarkm	@echo "Define DESTDIR to where you want to install FreeBSD,"
336132234Smarcel	@echo "including /, to override this warning and proceed as usual."
337132358Smarkm	@echo ""
338132234Smarcel	@echo "Bailing out now..."
339132234Smarcel	@false
340132234Smarcel.endif
34154324Smarcel
34254324Smarcel#
34395730Sru# kernel
34495730Sru#
34595730Sru# Short hand for `make buildkernel installkernel'
34695730Sru#
347301885Sbdrewerykernel: buildkernel installkernel .PHONY
34895730Sru
34995730Sru#
35038666Sjb# Perform a few tests to determine if the installed tools are adequate
351107374Sru# for building the world.
35217308Speter#
353301885Sbdreweryupgrade_checks: .PHONY
354301465Sbdrewery.if defined(NEED_MAKE_UPGRADE)
355296643Sbdrewery	@${_+_}(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
356241298Smarcel.endif
3572061Sjkh
35817308Speter#
359107516Sru# Upgrade make(1) to the current version using the installed
360174539Simp# headers, libraries and tools.  Also, allow the location of
361174539Simp# the system bsdmake-like utility to be overridden.
36255678Smarcel#
363253616SsjgMMAKEENV=	MAKEOBJDIRPREFIX=${MYMAKE:H} \
364107516Sru		DESTDIR= \
365107516Sru		INSTALL="sh ${.CURDIR}/tools/install.sh"
366174564SimpMMAKE=		${MMAKEENV} ${MAKE} \
367296675Sbdrewery		MAN= -DNO_SHARED \
368264742Sjmmv		-DNO_CPU_CFLAGS -DNO_WERROR \
369296676Sbdrewery		-DNO_SUBDIR \
370265827Simp		DESTDIR= PROGNAME=${MYMAKE:T}
371107516Sru
372265827Simpbmake: .PHONY
37355678Smarcel	@echo
37455678Smarcel	@echo "--------------------------------------------------------------"
375265827Simp	@echo ">>> Building an up-to-date ${.TARGET}(1)"
37655678Smarcel	@echo "--------------------------------------------------------------"
377249395Ssjg	${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
378291605Sbdrewery		${MMAKE} obj; \
379291605Sbdrewery		${MMAKE} depend; \
380291605Sbdrewery		${MMAKE} all; \
381265827Simp		${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR=
38255678Smarcel
383295380Sngieregress: .PHONY
384295380Sngie	@echo "'make regress' has been renamed 'make check'" | /usr/bin/fmt
385295380Sngie	@false
386295380Sngie
387295099Siantinderbox toolchains kernel-toolchains kernels worlds: upgrade_checks
388254417Ssjg
389301885Sbdrewerytinderbox: .PHONY
390291605Sbdrewery	@cd ${.CURDIR}; ${SUB_MAKE} DOING_TINDERBOX=YES universe
391185499Salfred
392301885Sbdrewerytoolchains: .PHONY
393291605Sbdrewery	@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
394218524Sjhb
395301885Sbdrewerykernel-toolchains: .PHONY
396291605Sbdrewery	@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
397232907Sjmallett
398301885Sbdrewerykernels: .PHONY
399295099Sian	@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=buildkernel universe
400295099Sian
401301885Sbdreweryworlds: .PHONY
402295099Sian	@cd ${.CURDIR}; ${SUB_MAKE} UNIVERSE_TARGET=buildworld universe
403295099Sian
40455678Smarcel#
405111131Sru# universe
406111131Sru#
407111131Sru# Attempt to rebuild *everything* for all supported architectures,
408133945Sru# with a reasonable chance of success, regardless of how old your
409111131Sru# existing system is.
410111131Sru#
411217125Simp.if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets)
412287903SbdreweryTARGETS?=amd64 arm arm64 i386 mips pc98 powerpc sparc64
413287903Sbdrewery_UNIVERSE_TARGETS=	${TARGETS}
414300119SimpTARGET_ARCHES_arm?=	arm armeb armv6
415282156SemasteTARGET_ARCHES_arm64?=	aarch64
416233644SjmallettTARGET_ARCHES_mips?=	mipsel mips mips64el mips64 mipsn32
417216520SnwhitehornTARGET_ARCHES_powerpc?=	powerpc powerpc64
418216520SnwhitehornTARGET_ARCHES_pc98?=	i386
419287903Sbdrewery.for target in ${TARGETS}
420216520SnwhitehornTARGET_ARCHES_${target}?= ${target}
421216520Snwhitehorn.endfor
422168280Smarcel
423301938Sbdrewery# XXX Remove arm64 from universe if the required binutils package is missing.
424287903Sbdrewery# It does not build with the in-tree linker.
425301938Sbdrewery.if !exists(/usr/local/aarch64-freebsd/bin/ld) && ${TARGETS:Marm64}
426287903Sbdrewery_UNIVERSE_TARGETS:= ${_UNIVERSE_TARGETS:Narm64}
427301885Sbdreweryuniverse: universe_arm64_skip .PHONY
428301885Sbdreweryuniverse_epilogue: universe_arm64_skip .PHONY
429301885Sbdreweryuniverse_arm64_skip: universe_prologue .PHONY
430287903Sbdrewery	@echo ">> arm64 skipped - install aarch64-binutils port or package to build"
431287903Sbdrewery.endif
432287903Sbdrewery
433218524Sjhb.if defined(UNIVERSE_TARGET)
434218524SjhbMAKE_JUST_WORLDS=	YES
435218524Sjhb.else
436218524SjhbUNIVERSE_TARGET?=	buildworld
437218524Sjhb.endif
438219137SjhbKERNSRCDIR?=		${.CURDIR}/sys
439218524Sjhb
440284699Ssjgtargets:	.PHONY
441217815Sbz	@echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
442287903Sbdrewery.for target in ${TARGETS}
443217125Simp.for target_arch in ${TARGET_ARCHES_${target}}
444217125Simp	@echo "    ${target}/${target_arch}"
445217125Simp.endfor
446217125Simp.endfor
447217125Simp
448185499Salfred.if defined(DOING_TINDERBOX)
449217735SbzFAILFILE=${.CURDIR}/_.tinderbox.failed
450185499SalfredMAKEFAIL=tee -a ${FAILFILE}
451185499Salfred.else
452185499SalfredMAKEFAIL=cat
453185499Salfred.endif
454185499Salfred
455253616Ssjguniverse_prologue:  upgrade_checks
456253616Ssjguniverse: universe_prologue
457297993Sbdreweryuniverse_prologue: .PHONY
458103985Sphk	@echo "--------------------------------------------------------------"
459103985Sphk	@echo ">>> make universe started on ${STARTTIME}"
460103985Sphk	@echo "--------------------------------------------------------------"
461185499Salfred.if defined(DOING_TINDERBOX)
462217754Sbz	@rm -f ${FAILFILE}
463185499Salfred.endif
464287903Sbdrewery.for target in ${_UNIVERSE_TARGETS}
465162147Sruuniverse: universe_${target}
466253616Ssjguniverse_epilogue: universe_${target}
467301885Sbdreweryuniverse_${target}: universe_${target}_prologue .PHONY
468301885Sbdreweryuniverse_${target}_prologue: universe_prologue .PHONY
469216520Snwhitehorn	@echo ">> ${target} started on `LC_ALL=C date`"
470301885Sbdreweryuniverse_${target}_worlds: .PHONY
471284456Sandrew
472179232Sjb.if !defined(MAKE_JUST_KERNELS)
473301885Sbdreweryuniverse_${target}_done: universe_${target}_worlds .PHONY
474216520Snwhitehorn.for target_arch in ${TARGET_ARCHES_${target}}
475301885Sbdreweryuniverse_${target}_worlds: universe_${target}_${target_arch} .PHONY
476301885Sbdreweryuniverse_${target}_${target_arch}: universe_${target}_prologue .MAKE .PHONY
477218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
478185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
479253616Ssjg	    ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
480162147Sru	    TARGET=${target} \
481216520Snwhitehorn	    TARGET_ARCH=${target_arch} \
482218524Sjhb	    > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
483218524Sjhb	    (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
484218524Sjhb	    "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
485216520Snwhitehorn	    ${MAKEFAIL}))
486218524Sjhb	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
487216520Snwhitehorn.endfor
488284453Sandrew.endif # !MAKE_JUST_KERNELS
489284453Sandrew
490205290Sdougb.if !defined(MAKE_JUST_WORLDS)
491301885Sbdreweryuniverse_${target}_done: universe_${target}_kernels .PHONY
492301885Sbdreweryuniverse_${target}_kernels: universe_${target}_worlds .PHONY
493301885Sbdreweryuniverse_${target}_kernels: universe_${target}_prologue .MAKE .PHONY
494219137Sjhb.if exists(${KERNSRCDIR}/${target}/conf/NOTES)
495219137Sjhb	@(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
496253616Ssjg	    ${SUB_MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
497185499Salfred	    (echo "${target} 'make LINT' failed," \
498185499Salfred	    "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
499103985Sphk.endif
500291605Sbdrewery	@cd ${.CURDIR}; ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
501201815Sbz	    universe_kernels
502284453Sandrew.endif # !MAKE_JUST_WORLDS
503284457Sandrew
504284457Sandrew# Tell the user the worlds and kernels have completed
505284457Sandrewuniverse_${target}: universe_${target}_done
506284457Sandrewuniverse_${target}_done:
507201815Sbz	@echo ">> ${target} completed on `LC_ALL=C date`"
508201815Sbz.endfor
509301885Sbdreweryuniverse_kernels: universe_kernconfs .PHONY
510202095Sbz.if !defined(TARGET)
511202095SbzTARGET!=	uname -m
512202095Sbz.endif
513265155Simp.if defined(MAKE_ALL_KERNELS)
514265155Simp_THINNER=cat
515265155Simp.else
516265840Simp_THINNER=xargs grep -L "^.NO_UNIVERSE" || true
517265155Simp.endif
518219137SjhbKERNCONFS!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
519295455Sbapt		find [[:upper:][:digit:]]*[[:upper:][:digit:]] \
520295455Sbapt		-type f -maxdepth 0 \
521265155Simp		! -name DEFAULTS ! -name NOTES | \
522265155Simp		${_THINNER}
523301885Sbdreweryuniverse_kernconfs: .PHONY
524148154Sru.for kernel in ${KERNCONFS}
525219137SjhbTARGET_ARCH_${kernel}!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
526219137Sjhb	config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
527216934Simp	grep -v WARNING: | cut -f 2
528216934Simp.if empty(TARGET_ARCH_${kernel})
529216934Simp.error "Target architecture for ${TARGET}/conf/${kernel} unknown.  config(8) likely too old."
530216934Simp.endif
531216520Snwhitehornuniverse_kernconfs: universe_kernconf_${TARGET}_${kernel}
532254417Ssjguniverse_kernconf_${TARGET}_${kernel}: .MAKE
533185250Sdes	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
534253616Ssjg	    ${SUB_MAKE} ${JFLAG} buildkernel \
535201815Sbz	    TARGET=${TARGET} \
536216520Snwhitehorn	    TARGET_ARCH=${TARGET_ARCH_${kernel}} \
537148154Sru	    KERNCONF=${kernel} \
538201815Sbz	    > _.${TARGET}.${kernel} 2>&1 || \
539201815Sbz	    (echo "${TARGET} ${kernel} kernel failed," \
540201815Sbz	    "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
541148154Sru.endfor
542133945Sruuniverse: universe_epilogue
543297993Sbdreweryuniverse_epilogue: .PHONY
544103985Sphk	@echo "--------------------------------------------------------------"
545118531Sru	@echo ">>> make universe completed on `LC_ALL=C date`"
546118531Sru	@echo "                      (started ${STARTTIME})"
547103985Sphk	@echo "--------------------------------------------------------------"
548185499Salfred.if defined(DOING_TINDERBOX)
549185499Salfred	@if [ -e ${FAILFILE} ] ; then \
550185499Salfred		echo "Tinderbox failed:" ;\
551185499Salfred		cat ${FAILFILE} ;\
552185499Salfred		exit 1 ;\
553185499Salfred	fi
554133945Sru.endif
555185499Salfred.endif
556242522Smarcel
557301885SbdrewerybuildLINT: .PHONY
558242522Smarcel	${MAKE} -C ${.CURDIR}/sys/${_TARGET}/conf LINT
559255286Ssjg
560284454Simp.if defined(.PARSEDIR)
561284345Ssjg# This makefile does not run in meta mode
562284345Ssjg.MAKE.MODE= normal
563284345Ssjg# Normally the things we run from here don't either.
564290816Ssjg# Using -DWITH_META_MODE
565284345Ssjg# we can buildworld with meta files created which are useful 
566284345Ssjg# for debugging, but without any of the rest of a meta mode build.
567290816SsjgMK_DIRDEPS_BUILD= no
568284345SsjgMK_STAGING= no
569284345Ssjg# tell meta.autodep.mk to not even think about updating anything.
570284345SsjgUPDATE_DEPENDFILE= NO
571285080Ssjg.if !make(showconfig)
572290816Ssjg.export MK_DIRDEPS_BUILD MK_STAGING UPDATE_DEPENDFILE
573285080Ssjg.endif
574284345Ssjg
575255286Ssjg.if make(universe)
576255286Ssjg# we do not want a failure of one branch abort all.
577255286SsjgMAKE_JOB_ERROR_TOKEN= no
578255286Ssjg.export MAKE_JOB_ERROR_TOKEN
579255286Ssjg.endif
580284454Simp.endif # bmake
581284345Ssjg
582290816Ssjg.endif				# DIRDEPS_BUILD
583