Makefile revision 256281
174465Srwatson#
274465Srwatson# $FreeBSD: stable/10/Makefile 255784 2013-09-22 07:30:17Z andrew $
374465Srwatson#
474465Srwatson# The user-driven targets are:
574465Srwatson#
674465Srwatson# universe            - *Really* build *everything* (buildworld and
774465Srwatson#                       all kernels on all architectures).
874465Srwatson# tinderbox           - Same as universe, but presents a list of failed build
974465Srwatson#                       targets and exits with an error if there were any.
1074465Srwatson# buildworld          - Rebuild *everything*, including glue to help do
1174465Srwatson#                       upgrades.
1274465Srwatson# installworld        - Install everything built by "buildworld".
1374465Srwatson# world               - buildworld + installworld, no kernel.
1474465Srwatson# buildkernel         - Rebuild the kernel and the kernel-modules.
1574465Srwatson# installkernel       - Install the kernel and the kernel-modules.
1674465Srwatson# installkernel.debug
1774465Srwatson# reinstallkernel     - Reinstall the kernel and the kernel-modules.
1874465Srwatson# reinstallkernel.debug
1974465Srwatson# kernel              - buildkernel + installkernel.
2074465Srwatson# kernel-toolchain    - Builds the subset of world necessary to build a kernel
2174465Srwatson# kernel-toolchains   - Build kernel-toolchain for all universe targets.
2274465Srwatson# doxygen             - Build API documentation of the kernel, needs doxygen.
2374465Srwatson# update              - Convenient way to update your source tree(s).
2474465Srwatson# check-old           - List obsolete directories/files/libraries.
2574465Srwatson# check-old-dirs      - List obsolete directories.
2674465Srwatson# check-old-files     - List obsolete files.
2799110Sobrien# check-old-libs      - List obsolete libraries.
2899110Sobrien# delete-old          - Delete obsolete directories/files.
2999110Sobrien# delete-old-dirs     - Delete obsolete directories.
3074465Srwatson# delete-old-files    - Delete obsolete files.
3174465Srwatson# delete-old-libs     - Delete obsolete libraries.
3274465Srwatson# targets             - Print a list of supported TARGET/TARGET_ARCH pairs
3374465Srwatson#                       for world and kernel targets.
3474465Srwatson# toolchains          - Build a toolchain for all world and kernel targets.
3574465Srwatson# 
3674465Srwatson# "quick" way to test all kernel builds:
3774465Srwatson# 	_jflag=`sysctl -n hw.ncpu`
3874465Srwatson# 	_jflag=$(($_jflag * 2))
3974465Srwatson# 	[ $_jflag -gt 12 ] && _jflag=12
4074465Srwatson# 	make universe -DMAKE_JUST_KERNELS JFLAG=-j${_jflag}
4174465Srwatson#
4274465Srwatson# This makefile is simple by design. The FreeBSD make automatically reads
4374465Srwatson# the /usr/share/mk/sys.mk unless the -m argument is specified on the
4474465Srwatson# command line. By keeping this makefile simple, it doesn't matter too
4574465Srwatson# much how different the installed mk files are from those in the source
4674465Srwatson# tree. This makefile executes a child make process, forcing it to use
4774465Srwatson# the mk files from the source tree which are supposed to DTRT.
4874465Srwatson#
4974465Srwatson# Most of the user-driven targets (as listed above) are implemented in
5074465Srwatson# Makefile.inc1.  The exceptions are universe, tinderbox and targets.
5174465Srwatson#
5274465Srwatson# If you want to build your system from source be sure that /usr/obj has
5374465Srwatson# at least 1GB of diskspace available.  A complete 'universe' build requires
5474465Srwatson# about 15GB of space.
5574465Srwatson#
5674465Srwatson# For individuals wanting to build from the sources currently on their
5774465Srwatson# system, the simple instructions are:
5874465Srwatson#
5975928Sjedgar# 1.  `cd /usr/src'  (or to the directory containing your source tree).
6074465Srwatson# 2.  Define `HISTORICAL_MAKE_WORLD' variable (see README).
6174465Srwatson# 3.  `make world'
6274465Srwatson#
6374465Srwatson# For individuals wanting to upgrade their sources (even if only a
6474465Srwatson# delta of a few days):
6574465Srwatson#
6674465Srwatson#  1.  `cd /usr/src'       (or to the directory containing your source tree).
6774465Srwatson#  2.  `make buildworld'
6874465Srwatson#  3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
6974465Srwatson#  4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
7087254Sjedgar#       [steps 3. & 4. can be combined by using the "kernel" target]
7174465Srwatson#  5.  `reboot'        (in single user mode: boot -s from the loader prompt).
7274465Srwatson#  6.  `mergemaster -p'
7374465Srwatson#  7.  `make installworld'
74108450Srwatson#  8.  `mergemaster'		(you may wish to use -i, along with -U or -F).
75108450Srwatson#  9.  `make delete-old'
76108450Srwatson# 10.  `reboot'
77108450Srwatson# 11.  `make delete-old-libs' (in case no 3rd party program uses them anymore)
7887259Sjedgar#
7987254Sjedgar# See src/UPDATING `COMMON ITEMS' for more complete information.
8074465Srwatson#
81108450Srwatson# If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can
82108450Srwatson# cross build world for other machine types using the buildworld target,
83108450Srwatson# and once the world is built you can cross build a kernel using the
84108450Srwatson# buildkernel target.
85108450Srwatson#
86108450Srwatson# Define the user-driven targets. These are listed here in alphabetical
8787259Sjedgar# order, but that's not important.
8887254Sjedgar#
8974465Srwatson# Targets that begin with underscore are internal targets intended for
9087259Sjedgar# developer convenience only.  They are intentionally not documented and
9174465Srwatson# completely subject to change without notice.
9287254Sjedgar#
9374465Srwatson# For more information, see the build(7) manual page.
9474465Srwatson#
9574465SrwatsonTGTS=	all all-man buildenv buildenvvars buildkernel buildworld \
9674465Srwatson	check-old check-old-dirs check-old-files check-old-libs \
9774465Srwatson	checkdpadd clean cleandepend cleandir \
9874465Srwatson	delete-old delete-old-dirs delete-old-files delete-old-libs \
99108450Srwatson	depend distribute distributekernel distributekernel.debug \
10074465Srwatson	distributeworld distrib-dirs distribution doxygen \
10187254Sjedgar	everything hier hierarchy install installcheck installkernel \
10274465Srwatson	installkernel.debug packagekernel packageworld \
10374465Srwatson	reinstallkernel reinstallkernel.debug \
10474465Srwatson	installworld kernel-toolchain libraries lint maninstall \
10574465Srwatson	obj objlink regress rerelease showconfig tags toolchain update \
10674465Srwatson	_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
10774465Srwatson	_build-tools _cross-tools _includes _libraries _depend \
10874465Srwatson	build32 builddtb distribute32 install32 xdev xdev-build xdev-install \
10974465Srwatson
11074465SrwatsonTGTS+=	${SUBDIR_TARGETS}
11174465Srwatson
11274465SrwatsonBITGTS=	files includes
11374465SrwatsonBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
11474465SrwatsonTGTS+=	${BITGTS}
115108450Srwatson
11674465Srwatson.ORDER: buildworld installworld
11775928Sjedgar.ORDER: buildworld distributeworld
11875928Sjedgar.ORDER: buildworld buildkernel
11974465Srwatson.ORDER: buildkernel installkernel
120108450Srwatson.ORDER: buildkernel installkernel.debug
12174465Srwatson.ORDER: buildkernel reinstallkernel
12274465Srwatson.ORDER: buildkernel reinstallkernel.debug
12374465Srwatson
12474465SrwatsonPATH=	/sbin:/bin:/usr/sbin:/usr/bin
12587254SjedgarMAKEOBJDIRPREFIX?=	/usr/obj
12687254Sjedgar_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
12774465Srwatson    ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
12875928Sjedgar    -f /dev/null -V MAKEOBJDIRPREFIX dummy
12974465Srwatson.if !empty(_MAKEOBJDIRPREFIX)
13074465Srwatson.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
13174465Srwatson	(in make.conf(5)) or command-line variable.
13274465Srwatson.endif
13374465Srwatson
13475928Sjedgar# We often need to use the tree's version of make to build it.
13574465Srwatson# Choices add to complexity though.
13674465Srwatson# We cannot blindly use a make which may not be the one we want
13774465Srwatson# so be exlicit - until all choice is removed.
13874465Srwatson.if !defined(WITHOUT_BMAKE)
13975928SjedgarWANT_MAKE=	bmake
14074465Srwatson.else
14174465SrwatsonWANT_MAKE=	fmake
14274465Srwatson.endif
14374465SrwatsonMYMAKE=		${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}/${WANT_MAKE}
144108450Srwatson.if defined(.PARSEDIR)
145108450SrwatsonHAVE_MAKE=	bmake
146108450Srwatson.else
14774465SrwatsonHAVE_MAKE=	fmake
14874465Srwatson.endif
14974465Srwatson.if exists(${MYMAKE})
15075928SjedgarSUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
15174465Srwatson.elif ${WANT_MAKE} != ${HAVE_MAKE} || ${WANT_MAKE} != "bmake"
15274465Srwatson# It may not exist yet but we may cause it to.
15374465Srwatson# In the case of fmake, upgrade_checks may cause a newer version to be built.
15474465SrwatsonSUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
15587254Sjedgar	-m ${.CURDIR}/share/mk
156117734Srwatson.else
15774465SrwatsonSUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
15875928Sjedgar.endif
15974465Srwatson
16074465Srwatson_MAKE=	PATH=${PATH} ${SUB_MAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
16174465Srwatson
16274465Srwatson# Guess machine architecture from machine type, and vice versa.
16374465Srwatson.if !defined(TARGET_ARCH) && defined(TARGET)
16474465Srwatson_TARGET_ARCH=	${TARGET:S/pc98/i386/}
16574465Srwatson.elif !defined(TARGET) && defined(TARGET_ARCH) && \
16687254Sjedgar    ${TARGET_ARCH} != ${MACHINE_ARCH}
167117734Srwatson_TARGET=		${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/}
16874465Srwatson.endif
16975928Sjedgar# Legacy names, for another transition period mips:mips(n32|64)?eb -> mips:mips\1
17074465Srwatson.if defined(TARGET) && defined(TARGET_ARCH) && \
17174465Srwatson    ${TARGET} == "mips" && ${TARGET_ARCH:Mmips*eb}
17274465Srwatson_TARGET_ARCH=		${TARGET_ARCH:C/eb$//}
17374465Srwatson.warning "TARGET_ARCH of ${TARGET_ARCH} is deprecated in favor of ${_TARGET_ARCH}"
17474465Srwatson.endif
17574465Srwatson.if defined(TARGET) && ${TARGET} == "mips" && defined(TARGET_BIG_ENDIAN)
17674465Srwatson.warning "TARGET_BIG_ENDIAN is no longer necessary for MIPS.  Big-endian is not the default."
17774465Srwatson.endif
17887254Sjedgar# arm with TARGET_BIG_ENDIAN -> armeb
17974465Srwatson.if defined(TARGET_ARCH) && ${TARGET_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN)
18074465Srwatson.warning "TARGET_ARCH of arm with TARGET_BIG_ENDIAN is deprecated.  use armeb"
18174465Srwatson_TARGET_ARCH=armeb
18287254Sjedgar.endif
18374465Srwatson.if defined(TARGET) && !defined(_TARGET)
18487254Sjedgar_TARGET=${TARGET}
18574465Srwatson.endif
18674465Srwatson.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
18776881Skris_TARGET_ARCH=${TARGET_ARCH}
18874465Srwatson.endif
18974465Srwatson# Otherwise, default to current machine type and architecture.
19074465Srwatson_TARGET?=	${MACHINE}
19174465Srwatson_TARGET_ARCH?=	${MACHINE_ARCH}
19274465Srwatson
19374465Srwatson#
19474465Srwatson# Make sure we have an up-to-date make(1). Only world and buildworld
19574465Srwatson# should do this as those are the initial targets used for upgrades.
19674465Srwatson# The user can define ALWAYS_CHECK_MAKE to have this check performed
19775928Sjedgar# for all targets.
19874465Srwatson#
19974465Srwatson.if defined(ALWAYS_CHECK_MAKE)
20087254Sjedgar${TGTS}: upgrade_checks
20174465Srwatson.else
20274465Srwatsonbuildworld: upgrade_checks
20374465Srwatson.endif
20474465Srwatson
20574465Srwatson#
20674465Srwatson# This 'cleanworld' target is not included in TGTS, because it is not a
20774465Srwatson# recursive target.  All of the work for it is done right here.   It is
20874465Srwatson# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
20974465Srwatson# created by bsd.obj.mk, except that we don't want to .include that file
21075928Sjedgar# in this makefile.  
21174465Srwatson#
21274465Srwatson# In the following, the first 'rm' in a series will usually remove all
21374465Srwatson# files and directories.  If it does not, then there are probably some
21474465Srwatson# files with file flags set, so this unsets them and tries the 'rm' a
21574465Srwatson# second time.  There are situations where this target will be cleaning
21674465Srwatson# some directories via more than one method, but that duplication is
21774465Srwatson# needed to correctly handle all the possible situations.  Removing all
21874465Srwatson# files without file flags set in the first 'rm' instance saves time,
21974465Srwatson# because 'chflags' will need to operate on fewer files afterwards.
22074465Srwatson#
22174465SrwatsonBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
22274465Srwatsoncleanworld:
22374465Srwatson.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
22474465Srwatson.if exists(${BW_CANONICALOBJDIR}/)
22574465Srwatson	-rm -rf ${BW_CANONICALOBJDIR}/*
22674465Srwatson	-chflags -R 0 ${BW_CANONICALOBJDIR}
22774465Srwatson	rm -rf ${BW_CANONICALOBJDIR}/*
22874465Srwatson.endif
22974465Srwatson	#   To be safe in this case, fall back to a 'make cleandir'
23074465Srwatson	${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
23174465Srwatson.else
23274465Srwatson	-rm -rf ${.OBJDIR}/*
23374465Srwatson	-chflags -R 0 ${.OBJDIR}
23474465Srwatson	rm -rf ${.OBJDIR}/*
23574465Srwatson.endif
23674465Srwatson
23774465Srwatson#
23874465Srwatson# Handle the user-driven targets, using the source relative mk files.
23974465Srwatson#
24074465Srwatson
24174465Srwatson.if empty(.MAKEFLAGS:M-n)
24274465Srwatson# skip this for -n to avoid changing previous behavior of 
24374465Srwatson# 'make -n buildworld' etc.
24474465Srwatson${TGTS}: .MAKE
24587259Sjedgartinderbox toolchains kernel-toolchains: .MAKE
24674465Srwatson.endif
24787259Sjedgar
24874465Srwatson${TGTS}:
24975928Sjedgar	${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
25074465Srwatson
25174465Srwatson# Set a reasonable default
25274465Srwatson.MAIN:	all
25374465Srwatson
25474465SrwatsonSTARTTIME!= LC_ALL=C date
25574465SrwatsonCHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo
25674465Srwatson.if !empty(CHECK_TIME)
25774465Srwatson.error check your date/time: ${STARTTIME}
25887259Sjedgar.endif
25987259Sjedgar
26074465Srwatson.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
26174465Srwatson#
26274465Srwatson# world
26387254Sjedgar#
26474465Srwatson# Attempt to rebuild and reinstall everything. This target is not to be
265# used for upgrading an existing FreeBSD system, because the kernel is
266# not included. One can argue that this target doesn't build everything
267# then.
268#
269world: upgrade_checks
270	@echo "--------------------------------------------------------------"
271	@echo ">>> make world started on ${STARTTIME}"
272	@echo "--------------------------------------------------------------"
273.if target(pre-world)
274	@echo
275	@echo "--------------------------------------------------------------"
276	@echo ">>> Making 'pre-world' target"
277	@echo "--------------------------------------------------------------"
278	${_+_}@cd ${.CURDIR}; ${_MAKE} pre-world
279.endif
280	${_+_}@cd ${.CURDIR}; ${_MAKE} buildworld
281	${_+_}@cd ${.CURDIR}; ${_MAKE} -B installworld
282.if target(post-world)
283	@echo
284	@echo "--------------------------------------------------------------"
285	@echo ">>> Making 'post-world' target"
286	@echo "--------------------------------------------------------------"
287	${_+_}@cd ${.CURDIR}; ${_MAKE} post-world
288.endif
289	@echo
290	@echo "--------------------------------------------------------------"
291	@echo ">>> make world completed on `LC_ALL=C date`"
292	@echo "                   (started ${STARTTIME})"
293	@echo "--------------------------------------------------------------"
294.else
295world:
296	@echo "WARNING: make world will overwrite your existing FreeBSD"
297	@echo "installation without also building and installing a new"
298	@echo "kernel.  This can be dangerous.  Please read the handbook,"
299	@echo "'Rebuilding world', for how to upgrade your system."
300	@echo "Define DESTDIR to where you want to install FreeBSD,"
301	@echo "including /, to override this warning and proceed as usual."
302	@echo ""
303	@echo "Bailing out now..."
304	@false
305.endif
306
307#
308# kernel
309#
310# Short hand for `make buildkernel installkernel'
311#
312kernel: buildkernel installkernel
313
314#
315# Perform a few tests to determine if the installed tools are adequate
316# for building the world.
317#
318# Note: if we ever need to care about the version of bmake, simply testing
319# MAKE_VERSION against a required version should suffice.
320#
321upgrade_checks:
322.if ${HAVE_MAKE} != ${WANT_MAKE}
323	@(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
324.elif ${WANT_MAKE} == "fmake"
325	@if ! (cd ${.CURDIR}/tools/build/make_check && \
326	    PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \
327	    PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
328	then \
329	    (cd ${.CURDIR} && ${MAKE} make); \
330	fi
331.endif
332
333#
334# Upgrade make(1) to the current version using the installed
335# headers, libraries and tools.  Also, allow the location of
336# the system bsdmake-like utility to be overridden.
337#
338MMAKEENV=	MAKEOBJDIRPREFIX=${MYMAKE:H} \
339		DESTDIR= \
340		INSTALL="sh ${.CURDIR}/tools/install.sh"
341MMAKE=		${MMAKEENV} ${MAKE} \
342		-D_UPGRADING \
343		-DNOMAN -DNO_MAN -DNOSHARED -DNO_SHARED \
344		-DNO_CPU_CFLAGS -DNO_WERROR DESTDIR= PROGNAME=${MYMAKE:T}
345
346make bmake: .PHONY
347	@echo
348	@echo "--------------------------------------------------------------"
349	@echo ">>> Building an up-to-date make(1)"
350	@echo "--------------------------------------------------------------"
351	${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
352		${MMAKE} obj && \
353		${MMAKE} depend && \
354		${MMAKE} all && \
355		${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR=
356
357tinderbox toolchains kernel-toolchains: upgrade_checks
358
359tinderbox:
360	@cd ${.CURDIR} && ${SUB_MAKE} DOING_TINDERBOX=YES universe
361
362toolchains:
363	@cd ${.CURDIR} && ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
364
365kernel-toolchains:
366	@cd ${.CURDIR} && ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
367
368#
369# universe
370#
371# Attempt to rebuild *everything* for all supported architectures,
372# with a reasonable chance of success, regardless of how old your
373# existing system is.
374#
375.if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets)
376TARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64
377TARGET_ARCHES_arm?=	arm armeb armv6
378TARGET_ARCHES_mips?=	mipsel mips mips64el mips64 mipsn32
379TARGET_ARCHES_powerpc?=	powerpc powerpc64
380TARGET_ARCHES_pc98?=	i386
381.for target in ${TARGETS}
382TARGET_ARCHES_${target}?= ${target}
383.endfor
384
385.if defined(UNIVERSE_TARGET)
386MAKE_JUST_WORLDS=	YES
387.else
388UNIVERSE_TARGET?=	buildworld
389.endif
390KERNSRCDIR?=		${.CURDIR}/sys
391
392targets:
393	@echo "Supported TARGET/TARGET_ARCH pairs for world and kernel targets"
394.for target in ${TARGETS}
395.for target_arch in ${TARGET_ARCHES_${target}}
396	@echo "    ${target}/${target_arch}"
397.endfor
398.endfor
399
400.if defined(DOING_TINDERBOX)
401FAILFILE=${.CURDIR}/_.tinderbox.failed
402MAKEFAIL=tee -a ${FAILFILE}
403.else
404MAKEFAIL=cat
405.endif
406
407universe_prologue:  upgrade_checks
408universe: universe_prologue
409universe_prologue:
410	@echo "--------------------------------------------------------------"
411	@echo ">>> make universe started on ${STARTTIME}"
412	@echo "--------------------------------------------------------------"
413.if defined(DOING_TINDERBOX)
414	@rm -f ${FAILFILE}
415.endif
416.for target in ${TARGETS}
417universe: universe_${target}
418universe_epilogue: universe_${target}
419universe_${target}: universe_${target}_prologue
420universe_${target}_prologue: universe_prologue
421	@echo ">> ${target} started on `LC_ALL=C date`"
422.if !defined(MAKE_JUST_KERNELS)
423.for target_arch in ${TARGET_ARCHES_${target}}
424universe_${target}: universe_${target}_${target_arch}
425universe_${target}_${target_arch}: universe_${target}_prologue .MAKE
426	@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
427	@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
428	    ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
429	    TARGET=${target} \
430	    TARGET_ARCH=${target_arch} \
431	    > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
432	    (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
433	    "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