Makefile revision 255286
10SN/A#
216811Smchung# $FreeBSD: head/Makefile 255286 2013-09-06 02:57:15Z sjg $
30SN/A#
40SN/A# The user-driven targets are:
50SN/A#
60SN/A# universe            - *Really* build *everything* (buildworld and
72362SN/A#                       all kernels on all architectures).
80SN/A# tinderbox           - Same as universe, but presents a list of failed build
92362SN/A#                       targets and exits with an error if there were any.
100SN/A# buildworld          - Rebuild *everything*, including glue to help do
110SN/A#                       upgrades.
120SN/A# installworld        - Install everything built by "buildworld".
130SN/A# world               - buildworld + installworld, no kernel.
140SN/A# buildkernel         - Rebuild the kernel and the kernel-modules.
150SN/A# installkernel       - Install the kernel and the kernel-modules.
160SN/A# installkernel.debug
170SN/A# reinstallkernel     - Reinstall the kernel and the kernel-modules.
180SN/A# reinstallkernel.debug
190SN/A# kernel              - buildkernel + installkernel.
200SN/A# kernel-toolchain    - Builds the subset of world necessary to build a kernel
212362SN/A# kernel-toolchains   - Build kernel-toolchain for all universe targets.
222362SN/A# doxygen             - Build API documentation of the kernel, needs doxygen.
232362SN/A# update              - Convenient way to update your source tree(s).
240SN/A# check-old           - List obsolete directories/files/libraries.
250SN/A# check-old-dirs      - List obsolete directories.
260SN/A# check-old-files     - List obsolete files.
270SN/A# check-old-libs      - List obsolete libraries.
2813484Spsandoz# delete-old          - Delete obsolete directories/files.
2912808Schegar# delete-old-dirs     - Delete obsolete directories.
3012808Schegar# delete-old-files    - Delete obsolete files.
3112808Schegar# delete-old-libs     - Delete obsolete libraries.
3213603Schegar# targets             - Print a list of supported TARGET/TARGET_ARCH pairs
330SN/A#                       for world and kernel targets.
340SN/A# toolchains          - Build a toolchain for all world and kernel targets.
350SN/A# 
360SN/A# "quick" way to test all kernel builds:
370SN/A# 	_jflag=`sysctl -n hw.ncpu`
380SN/A# 	_jflag=$(($_jflag * 2))
390SN/A# 	[ $_jflag -gt 12 ] && _jflag=12
400SN/A# 	make universe -DMAKE_JUST_KERNELS JFLAG=-j${_jflag}
410SN/A#
420SN/A# This makefile is simple by design. The FreeBSD make automatically reads
430SN/A# the /usr/share/mk/sys.mk unless the -m argument is specified on the
440SN/A# command line. By keeping this makefile simple, it doesn't matter too
450SN/A# much how different the installed mk files are from those in the source
460SN/A# tree. This makefile executes a child make process, forcing it to use
470SN/A# the mk files from the source tree which are supposed to DTRT.
480SN/A#
490SN/A# Most of the user-driven targets (as listed above) are implemented in
500SN/A# Makefile.inc1.  The exceptions are universe, tinderbox and targets.
510SN/A#
520SN/A# If you want to build your system from source be sure that /usr/obj has
530SN/A# at least 1GB of diskspace available.  A complete 'universe' build requires
540SN/A# about 15GB of space.
550SN/A#
560SN/A# For individuals wanting to build from the sources currently on their
570SN/A# system, the simple instructions are:
580SN/A#
590SN/A# 1.  `cd /usr/src'  (or to the directory containing your source tree).
600SN/A# 2.  Define `HISTORICAL_MAKE_WORLD' variable (see README).
610SN/A# 3.  `make world'
620SN/A#
630SN/A# For individuals wanting to upgrade their sources (even if only a
640SN/A# delta of a few days):
650SN/A#
660SN/A#  1.  `cd /usr/src'       (or to the directory containing your source tree).
670SN/A#  2.  `make buildworld'
680SN/A#  3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
690SN/A#  4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
700SN/A#       [steps 3. & 4. can be combined by using the "kernel" target]
710SN/A#  5.  `reboot'        (in single user mode: boot -s from the loader prompt).
720SN/A#  6.  `mergemaster -p'
730SN/A#  7.  `make installworld'
740SN/A#  8.  `mergemaster'		(you may wish to use -i, along with -U or -F).
754706SN/A#  9.  `make delete-old'
760SN/A# 10.  `reboot'
770SN/A# 11.  `make delete-old-libs' (in case no 3rd party program uses them anymore)
780SN/A#
790SN/A# See src/UPDATING `COMMON ITEMS' for more complete information.
800SN/A#
810SN/A# If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can
820SN/A# cross build world for other machine types using the buildworld target,
830SN/A# and once the world is built you can cross build a kernel using the
840SN/A# buildkernel target.
850SN/A#
860SN/A# Define the user-driven targets. These are listed here in alphabetical
874706SN/A# order, but that's not important.
880SN/A#
890SN/A# Targets that begin with underscore are internal targets intended for
904706SN/A# developer convenience only.  They are intentionally not documented and
914706SN/A# completely subject to change without notice.
920SN/A#
930SN/A# For more information, see the build(7) manual page.
940SN/A#
950SN/ATGTS=	all all-man buildenv buildenvvars buildkernel buildworld \
967671SN/A	check-old check-old-dirs check-old-files check-old-libs \
970SN/A	checkdpadd clean cleandepend cleandir \
984706SN/A	delete-old delete-old-dirs delete-old-files delete-old-libs \
994706SN/A	depend distribute distributekernel distributekernel.debug \
1004706SN/A	distributeworld distrib-dirs distribution doxygen \
1014706SN/A	everything hier hierarchy install installcheck installkernel \
1024706SN/A	installkernel.debug packagekernel packageworld \
1037739SN/A	reinstallkernel reinstallkernel.debug \
10412538Sdsamersoff	installworld kernel-toolchain libraries lint maninstall \
1054706SN/A	obj objlink regress rerelease showconfig tags toolchain update \
1064706SN/A	_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
1074706SN/A	_build-tools _cross-tools _includes _libraries _depend \
1084706SN/A	build32 builddtb distribute32 install32 xdev xdev-build xdev-install \
1094706SN/A
11012745SmartinTGTS+=	${SUBDIR_TARGETS}
1110SN/A
1120SN/ABITGTS=	files includes
1130SN/ABITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
1140SN/ATGTS+=	${BITGTS}
11513332Schegar
1160SN/A.ORDER: buildworld installworld
1179208SN/A.ORDER: buildworld distributeworld
1189208SN/A.ORDER: buildworld buildkernel
1199208SN/A.ORDER: buildkernel installkernel
1209208SN/A.ORDER: buildkernel installkernel.debug
1219208SN/A.ORDER: buildkernel reinstallkernel
1229208SN/A.ORDER: buildkernel reinstallkernel.debug
1239208SN/A
1249208SN/APATH=	/sbin:/bin:/usr/sbin:/usr/bin
1259208SN/AMAKEOBJDIRPREFIX?=	/usr/obj
12615606Skbarrett_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
12715606Skbarrett    ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
12815606Skbarrett    -f /dev/null -V MAKEOBJDIRPREFIX dummy
1299208SN/A.if !empty(_MAKEOBJDIRPREFIX)
1309208SN/A.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
1319208SN/A	(in make.conf(5)) or command-line variable.
1320SN/A.endif
13313332Schegar
1340SN/A# We often need to use the tree's version of make to build it.
1350SN/A# Choices add to complexity though.
1360SN/A# We cannot blindly use a make which may not be the one we want
1379329SN/A# so be exlicit - until all choice is removed.
13815606Skbarrett.if !defined(WITHOUT_BMAKE)
1390SN/AWANT_MAKE=	bmake
1400SN/A.else
1410SN/AWANT_MAKE=	fmake
1420SN/A.endif
14316811SmchungMYMAKE=		${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}/${WANT_MAKE}
14416811Smchung.if defined(.PARSEDIR)
14516811SmchungHAVE_MAKE=	bmake
14617014Skbarrett.else
14717014SkbarrettHAVE_MAKE=	fmake
14817014Skbarrett.endif
14917014Skbarrett.if exists(${MYMAKE})
15016811SmchungSUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
15116811Smchung.elif ${WANT_MAKE} != ${HAVE_MAKE} || ${WANT_MAKE} != "bmake"
15216811Smchung# It may not exist yet but we may cause it to.
15315606Skbarrett# In the case of fmake, upgrade_checks may cause a newer version to be built.
15415606SkbarrettSUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
15515606Skbarrett	-m ${.CURDIR}/share/mk
15616811Smchung.else
15716811SmchungSUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
15815606Skbarrett.endif
15915606Skbarrett
16015606Skbarrett_MAKE=	PATH=${PATH} ${SUB_MAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
16116811Smchung
16216811Smchung# Guess machine architecture from machine type, and vice versa.
1639329SN/A.if !defined(TARGET_ARCH) && defined(TARGET)
16415606Skbarrett_TARGET_ARCH=	${TARGET:S/pc98/i386/}
16515606Skbarrett.elif !defined(TARGET) && defined(TARGET_ARCH) && \
16615606Skbarrett    ${TARGET_ARCH} != ${MACHINE_ARCH}
16715606Skbarrett_TARGET=		${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/}
16815606Skbarrett.endif
16915606Skbarrett# Legacy names, for another transition period mips:mips(n32|64)?eb -> mips:mips\1
17015606Skbarrett.if defined(TARGET) && defined(TARGET_ARCH) && \
17115606Skbarrett    ${TARGET} == "mips" && ${TARGET_ARCH:Mmips*eb}
17215606Skbarrett_TARGET_ARCH=		${TARGET_ARCH:C/eb$//}
17315606Skbarrett.warning "TARGET_ARCH of ${TARGET_ARCH} is deprecated in favor of ${_TARGET_ARCH}"
17415606Skbarrett.endif
17515606Skbarrett.if defined(TARGET) && ${TARGET} == "mips" && defined(TARGET_BIG_ENDIAN)
17615606Skbarrett.warning "TARGET_BIG_ENDIAN is no longer necessary for MIPS.  Big-endian is not the default."
17715606Skbarrett.endif
17815606Skbarrett# arm with TARGET_BIG_ENDIAN -> armeb
17915606Skbarrett.if defined(TARGET_ARCH) && ${TARGET_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN)
18015606Skbarrett.warning "TARGET_ARCH of arm with TARGET_BIG_ENDIAN is deprecated.  use armeb"
18115606Skbarrett_TARGET_ARCH=armeb
18215606Skbarrett.endif
18315606Skbarrett.if defined(TARGET) && !defined(_TARGET)
18415606Skbarrett_TARGET=${TARGET}
18515606Skbarrett.endif
18615606Skbarrett.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
18715606Skbarrett_TARGET_ARCH=${TARGET_ARCH}
18815606Skbarrett.endif
18915606Skbarrett# Otherwise, default to current machine type and architecture.
19015606Skbarrett_TARGET?=	${MACHINE}
19115606Skbarrett_TARGET_ARCH?=	${MACHINE_ARCH}
1929329SN/A
19315606Skbarrett#
19415606Skbarrett# Make sure we have an up-to-date make(1). Only world and buildworld
19515606Skbarrett# should do this as those are the initial targets used for upgrades.
1969329SN/A# The user can define ALWAYS_CHECK_MAKE to have this check performed
19715606Skbarrett# for all targets.
19815606Skbarrett#
19915606Skbarrett.if defined(ALWAYS_CHECK_MAKE)
20015606Skbarrett${TGTS}: upgrade_checks
20115606Skbarrett.else
2029329SN/Abuildworld: upgrade_checks
20315606Skbarrett.endif
2049329SN/A
20515606Skbarrett#
20615606Skbarrett# This 'cleanworld' target is not included in TGTS, because it is not a
20715606Skbarrett# recursive target.  All of the work for it is done right here.   It is
20815606Skbarrett# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
20915606Skbarrett# created by bsd.obj.mk, except that we don't want to .include that file
21015606Skbarrett# in this makefile.  
21115606Skbarrett#
21215606Skbarrett# In the following, the first 'rm' in a series will usually remove all
21315606Skbarrett# files and directories.  If it does not, then there are probably some
21415606Skbarrett# files with file flags set, so this unsets them and tries the 'rm' a
21515606Skbarrett# second time.  There are situations where this target will be cleaning
21615606Skbarrett# some directories via more than one method, but that duplication is
21715606Skbarrett# needed to correctly handle all the possible situations.  Removing all
21815606Skbarrett# files without file flags set in the first 'rm' instance saves time,
21915606Skbarrett# because 'chflags' will need to operate on fewer files afterwards.
22015606Skbarrett#
22115606SkbarrettBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
2229329SN/Acleanworld:
2239329SN/A.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
2249329SN/A.if exists(${BW_CANONICALOBJDIR}/)
2250SN/A	-rm -rf ${BW_CANONICALOBJDIR}/*
2260SN/A	-chflags -R 0 ${BW_CANONICALOBJDIR}
2270SN/A	rm -rf ${BW_CANONICALOBJDIR}/*
2280SN/A.endif
2290SN/A	#   To be safe in this case, fall back to a 'make cleandir'
2300SN/A	${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
2310SN/A.else
2320SN/A	-rm -rf ${.OBJDIR}/*
2330SN/A	-chflags -R 0 ${.OBJDIR}
2340SN/A	rm -rf ${.OBJDIR}/*
2350SN/A.endif
2360SN/A
2379329SN/A#
2389329SN/A# Handle the user-driven targets, using the source relative mk files.
2399329SN/A#
2409329SN/A
24115606Skbarrett.if empty(.MAKEFLAGS:M-n)
24215606Skbarrett# skip this for -n to avoid changing previous behavior of 
24315606Skbarrett# 'make -n buildworld' etc.
24415606Skbarrett${TGTS}: .MAKE
2459329SN/Atinderbox toolchains kernel-toolchains: .MAKE
2469329SN/A.endif
2470SN/A
2480SN/A${TGTS}:
2490SN/A	${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
2500SN/A
2510SN/A# Set a reasonable default
2520SN/A.MAIN:	all
2530SN/A
2540SN/ASTARTTIME!= LC_ALL=C date
2550SN/ACHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo
2560SN/A.if !empty(CHECK_TIME)
2570SN/A.error check your date/time: ${STARTTIME}
2580SN/A.endif
25912352Szmajo
2600SN/A.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
2610SN/A#
2620SN/A# world
2630SN/A#
2640SN/A# Attempt to rebuild and reinstall everything. This target is not to be
2650SN/A# used for upgrading an existing FreeBSD system, because the kernel is
2660SN/A# not included. One can argue that this target doesn't build everything
2670SN/A# then.
2680SN/A#
2690SN/Aworld: upgrade_checks
2700SN/A	@echo "--------------------------------------------------------------"
2710SN/A	@echo ">>> make world started on ${STARTTIME}"
2720SN/A	@echo "--------------------------------------------------------------"
2730SN/A.if target(pre-world)
2740SN/A	@echo
2750SN/A	@echo "--------------------------------------------------------------"
2760SN/A	@echo ">>> Making 'pre-world' target"
2770SN/A	@echo "--------------------------------------------------------------"
2780SN/A	${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
2790SN/A.endif
2800SN/A	${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
2810SN/A	${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
2820SN/A.if target(post-world)
2830SN/A	@echo
2840SN/A	@echo "--------------------------------------------------------------"
2850SN/A	@echo ">>> Making 'post-world' target"
2860SN/A	@echo "--------------------------------------------------------------"
2877671SN/A	${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
2880SN/A.endif
2890SN/A	@echo
2900SN/A	@echo "--------------------------------------------------------------"
29116811Smchung	@echo ">>> make world completed on `LC_ALL=C date`"
29216811Smchung	@echo "                   (started ${STARTTIME})"
2930SN/A	@echo "--------------------------------------------------------------"
2940SN/A.else
2950SN/Aworld:
2960SN/A	@echo "WARNING: make world will overwrite your existing FreeBSD"
2970SN/A	@echo "installation without also building and installing a new"
2980SN/A	@echo "kernel.  This can be dangerous.  Please read the handbook,"
2990SN/A	@echo "'Rebuilding world', for how to upgrade your system."
3000SN/A	@echo "Define DESTDIR to where you want to install FreeBSD,"
3010SN/A	@echo "including /, to override this warning and proceed as usual."
30217014Skbarrett	@echo ""
30316811Smchung	@echo "Bailing out now..."
3040SN/A	@false
3050SN/A.endif
3060SN/A
3070SN/A#
3080SN/A# kernel
3090SN/A#
3100SN/A# Short hand for `make buildkernel installkernel'
3110SN/A#
3120SN/Akernel: buildkernel installkernel
3130SN/A
3140SN/A#
3150SN/A# Perform a few tests to determine if the installed tools are adequate
3160SN/A# for building the world.
3170SN/A#
31813484Spsandoz# Note: if we ever need to care about the version of bmake, simply testing
31913484Spsandoz# MAKE_VERSION against a required version should suffice.
32013484Spsandoz#
32113484Spsandozupgrade_checks:
32213484Spsandoz.if ${HAVE_MAKE} != ${WANT_MAKE}
32313484Spsandoz	@(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
32413484Spsandoz.elif ${WANT_MAKE} == "fmake"
32513484Spsandoz	@if ! (cd ${.CURDIR}/tools/build/make_check && \
32613484Spsandoz	    PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \
32713484Spsandoz	    PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
32813484Spsandoz	then \
32913484Spsandoz	    (cd ${.CURDIR} && ${MAKE} make); \
33013484Spsandoz	fi
33113484Spsandoz.endif
33213484Spsandoz
33313484Spsandoz#
33413484Spsandoz# Upgrade make(1) to the current version using the installed
33513484Spsandoz# headers, libraries and tools.  Also, allow the location of
33613484Spsandoz# the system bsdmake-like utility to be overridden.
33713484Spsandoz#
33813484SpsandozMMAKEENV=	MAKEOBJDIRPREFIX=${MYMAKE:H} \
33913484Spsandoz		DESTDIR= \
34013484Spsandoz		INSTALL="sh ${.CURDIR}/tools/install.sh"
34113484SpsandozMMAKE=		${MMAKEENV} ${MAKE} \
34213484Spsandoz		-D_UPGRADING \
34313484Spsandoz		-DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \
34413484Spsandoz		-DNO_CPU_CFLAGS -DNO_WERROR
34513484Spsandoz
34613484Spsandozmake bmake: .PHONY
34713484Spsandoz	@echo
34813484Spsandoz	@echo "--------------------------------------------------------------"
34913484Spsandoz	@echo ">>> Building an up-to-date make(1)"
35013484Spsandoz	@echo "--------------------------------------------------------------"
35113484Spsandoz	${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
35213484Spsandoz		${MMAKE} obj DESTDIR= && \
35313484Spsandoz		${MMAKE} depend DESTDIR= && \
35413484Spsandoz		${MMAKE} all DESTDIR= && \
35513484Spsandoz		${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR= PROGNAME=${MYMAKE:T}
35613484Spsandoz
35713484Spsandoztinderbox toolchains kernel-toolchains: upgrade_checks
35813484Spsandoz
35913484Spsandoztinderbox:
36013484Spsandoz	@cd ${.CURDIR} && ${SUB_MAKE} DOING_TINDERBOX=YES universe
36113484Spsandoz
36213484Spsandoztoolchains:
36313484Spsandoz	@cd ${.CURDIR} && ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
36413484Spsandoz
36513484Spsandozkernel-toolchains:
36613484Spsandoz	@cd ${.CURDIR} && ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
36713484Spsandoz
36813484Spsandoz#
36913484Spsandoz# universe
37013484Spsandoz#
37113484Spsandoz# Attempt to rebuild *everything* for all supported architectures,
37213484Spsandoz# with a reasonable chance of success, regardless of how old your
37313484Spsandoz# existing system is.
37413484Spsandoz#
37513484Spsandoz.if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets)
37613484SpsandozTARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64
37713484SpsandozTARGET_ARCHES_arm?=	arm armeb armv6 armv6eb
37813484SpsandozTARGET_ARCHES_mips?=	mipsel mips mips64el mips64 mipsn32
37913484SpsandozTARGET_ARCHES_powerpc?=	powerpc powerpc64
38013484SpsandozTARGET_ARCHES_pc98?=	i386
38113484Spsandoz.for target in ${TARGETS}
38213484SpsandozTARGET_ARCHES_${target}?= ${target}
38313484Spsandoz.endfor
38413484Spsandoz
38513484Spsandoz.if defined(UNIVERSE_TARGET)
38613484SpsandozMAKE_JUST_WORLDS=	YES
38713484Spsandoz.else
38813484SpsandozUNIVERSE_TARGET?=	buildworld
38913484Spsandoz.endif
39013484SpsandozKERNSRCDIR?=		${.CURDIR}/sys
39113484Spsandoz
39213484Spsandoztargets:
39313484Spsandoz	@echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
39413484Spsandoz.for target in ${TARGETS}
39513484Spsandoz.for target_arch in ${TARGET_ARCHES_${target}}
39613484Spsandoz	@echo "    ${target}/${target_arch}"
39713484Spsandoz.endfor
39813484Spsandoz.endfor
39913484Spsandoz
40013484Spsandoz.if defined(DOING_TINDERBOX)
40113484SpsandozFAILFILE=${.CURDIR}/_.tinderbox.failed
40213484SpsandozMAKEFAIL=tee -a ${FAILFILE}
40313484Spsandoz.else
40413484SpsandozMAKEFAIL=cat
40513484Spsandoz.endif
40613484Spsandoz
40713484Spsandozuniverse_prologue:  upgrade_checks
40813484Spsandozuniverse: universe_prologue
40913484Spsandozuniverse_prologue:
41013484Spsandoz	@echo "--------------------------------------------------------------"
41113484Spsandoz	@echo ">>> make universe started on ${STARTTIME}"
41213484Spsandoz	@echo "--------------------------------------------------------------"
41313484Spsandoz.if defined(DOING_TINDERBOX)
41413484Spsandoz	@rm -f ${FAILFILE}
41513484Spsandoz.endif
41613484Spsandoz.for target in ${TARGETS}
41713484Spsandozuniverse: universe_${target}
41813484Spsandozuniverse_epilogue: universe_${target}
41913484Spsandozuniverse_${target}: universe_${target}_prologue
42013484Spsandozuniverse_${target}_prologue: universe_prologue
42113484Spsandoz	@echo ">> ${target} started on `LC_ALL=C date`"
42213484Spsandoz.if !defined(MAKE_JUST_KERNELS)
42313484Spsandoz.for target_arch in ${TARGET_ARCHES_${target}}
42413484Spsandozuniverse_${target}: universe_${target}_${target_arch}
42513484Spsandozuniverse_${target}_${target_arch}: universe_${target}_prologue .MAKE
42613484Spsandoz	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
42713484Spsandoz	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
42813484Spsandoz	    ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
42913484Spsandoz	    TARGET=${target} \
43013484Spsandoz	    TARGET_ARCH=${target_arch} \
43113484Spsandoz	    > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
43213484Spsandoz	    (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
4330SN/A	    "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
434	    ${MAKEFAIL}))
435	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} completed on `LC_ALL=C date`"
436.endfor
437.endif
438.if !defined(MAKE_JUST_WORLDS)
439# If we are building world and kernels wait for the required worlds to finish
440.if !defined(MAKE_JUST_KERNELS)
441.for target_arch in ${TARGET_ARCHES_${target}}
442universe_${target}_kernels: universe_${target}_${target_arch}
443.endfor
444.endif
445universe_${target}: universe_${target}_kernels
446universe_${target}_kernels: universe_${target}_prologue .MAKE
447.if exists(${KERNSRCDIR}/${target}/conf/NOTES)
448	@(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
449	    ${SUB_MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
450	    (echo "${target} 'make LINT' failed," \
451	    "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
452.endif
453	@cd ${.CURDIR} && ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
454	    universe_kernels
455.endif
456	@echo ">> ${target} completed on `LC_ALL=C date`"
457.endfor
458universe_kernels: universe_kernconfs
459.if !defined(TARGET)
460TARGET!=	uname -m
461.endif
462KERNCONFS!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
463		find [A-Z0-9]*[A-Z0-9] -type f -maxdepth 0 \
464		! -name DEFAULTS ! -name NOTES
465universe_kernconfs:
466.for kernel in ${KERNCONFS}
467TARGET_ARCH_${kernel}!=	cd ${KERNSRCDIR}/${TARGET}/conf && \
468	config -m ${KERNSRCDIR}/${TARGET}/conf/${kernel} 2> /dev/null | \
469	grep -v WARNING: | cut -f 2
470.if empty(TARGET_ARCH_${kernel})
471.error "Target architecture for ${TARGET}/conf/${kernel} unknown.  config(8) likely too old."
472.endif
473universe_kernconfs: universe_kernconf_${TARGET}_${kernel}
474universe_kernconf_${TARGET}_${kernel}: .MAKE
475	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
476	    ${SUB_MAKE} ${JFLAG} buildkernel \
477	    TARGET=${TARGET} \
478	    TARGET_ARCH=${TARGET_ARCH_${kernel}} \
479	    KERNCONF=${kernel} \
480	    > _.${TARGET}.${kernel} 2>&1 || \
481	    (echo "${TARGET} ${kernel} kernel failed," \
482	    "check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
483.endfor
484universe: universe_epilogue
485universe_epilogue:
486	@echo "--------------------------------------------------------------"
487	@echo ">>> make universe completed on `LC_ALL=C date`"
488	@echo "                      (started ${STARTTIME})"
489	@echo "--------------------------------------------------------------"
490.if defined(DOING_TINDERBOX)
491	@if [ -e ${FAILFILE} ] ; then \
492		echo "Tinderbox failed:" ;\
493		cat ${FAILFILE} ;\
494		exit 1 ;\
495	fi
496.endif
497.endif
498
499buildLINT:
500	${MAKE} -C ${.CURDIR}/sys/${_TARGET}/conf LINT
501
502.if defined(.PARSEDIR)
503.if make(universe)
504# we do not want a failure of one branch abort all.
505MAKE_JOB_ERROR_TOKEN= no
506.export MAKE_JOB_ERROR_TOKEN
507.endif
508.endif
509