Makefile revision 255286
1199044Sgabor#
2199044Sgabor# $FreeBSD: head/Makefile 255286 2013-09-06 02:57:15Z sjg $
3199044Sgabor#
4199044Sgabor# The user-driven targets are:
5199044Sgabor#
6199044Sgabor# universe            - *Really* build *everything* (buildworld and
7199044Sgabor#                       all kernels on all architectures).
8199044Sgabor# tinderbox           - Same as universe, but presents a list of failed build
9199044Sgabor#                       targets and exits with an error if there were any.
10199044Sgabor# buildworld          - Rebuild *everything*, including glue to help do
11199044Sgabor#                       upgrades.
12199044Sgabor# installworld        - Install everything built by "buildworld".
13199044Sgabor# world               - buildworld + installworld, no kernel.
14199044Sgabor# buildkernel         - Rebuild the kernel and the kernel-modules.
15199044Sgabor# installkernel       - Install the kernel and the kernel-modules.
16199044Sgabor# installkernel.debug
17199044Sgabor# reinstallkernel     - Reinstall the kernel and the kernel-modules.
18199044Sgabor# reinstallkernel.debug
19199044Sgabor# kernel              - buildkernel + installkernel.
20199044Sgabor# kernel-toolchain    - Builds the subset of world necessary to build a kernel
21199044Sgabor# kernel-toolchains   - Build kernel-toolchain for all universe targets.
22199044Sgabor# doxygen             - Build API documentation of the kernel, needs doxygen.
23199044Sgabor# update              - Convenient way to update your source tree(s).
24199044Sgabor# check-old           - List obsolete directories/files/libraries.
25199044Sgabor# check-old-dirs      - List obsolete directories.
26199044Sgabor# check-old-files     - List obsolete files.
27199044Sgabor# check-old-libs      - List obsolete libraries.
28199044Sgabor# delete-old          - Delete obsolete directories/files.
29199044Sgabor# delete-old-dirs     - Delete obsolete directories.
30199044Sgabor# delete-old-files    - Delete obsolete files.
31199044Sgabor# delete-old-libs     - Delete obsolete libraries.
32199044Sgabor# targets             - Print a list of supported TARGET/TARGET_ARCH pairs
33199044Sgabor#                       for world and kernel targets.
34199044Sgabor# toolchains          - Build a toolchain for all world and kernel targets.
35199044Sgabor# 
36199044Sgabor# "quick" way to test all kernel builds:
37199044Sgabor# 	_jflag=`sysctl -n hw.ncpu`
38199044Sgabor# 	_jflag=$(($_jflag * 2))
39199044Sgabor# 	[ $_jflag -gt 12 ] && _jflag=12
40199044Sgabor# 	make universe -DMAKE_JUST_KERNELS JFLAG=-j${_jflag}
41199044Sgabor#
42199044Sgabor# This makefile is simple by design. The FreeBSD make automatically reads
43199044Sgabor# the /usr/share/mk/sys.mk unless the -m argument is specified on the
44199044Sgabor# command line. By keeping this makefile simple, it doesn't matter too
45199044Sgabor# much how different the installed mk files are from those in the source
46199044Sgabor# tree. This makefile executes a child make process, forcing it to use
47199044Sgabor# the mk files from the source tree which are supposed to DTRT.
48199044Sgabor#
49199044Sgabor# Most of the user-driven targets (as listed above) are implemented in
50199044Sgabor# Makefile.inc1.  The exceptions are universe, tinderbox and targets.
51199044Sgabor#
52199044Sgabor# If you want to build your system from source be sure that /usr/obj has
53199044Sgabor# at least 1GB of diskspace available.  A complete 'universe' build requires
54199044Sgabor# about 15GB of space.
55199044Sgabor#
56199044Sgabor# For individuals wanting to build from the sources currently on their
57199044Sgabor# system, the simple instructions are:
58199044Sgabor#
59199044Sgabor# 1.  `cd /usr/src'  (or to the directory containing your source tree).
60199044Sgabor# 2.  Define `HISTORICAL_MAKE_WORLD' variable (see README).
61199044Sgabor# 3.  `make world'
62199044Sgabor#
63199044Sgabor# For individuals wanting to upgrade their sources (even if only a
64199044Sgabor# delta of a few days):
65199044Sgabor#
66199044Sgabor#  1.  `cd /usr/src'       (or to the directory containing your source tree).
67199044Sgabor#  2.  `make buildworld'
68199044Sgabor#  3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
69199044Sgabor#  4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
70199044Sgabor#       [steps 3. & 4. can be combined by using the "kernel" target]
71199044Sgabor#  5.  `reboot'        (in single user mode: boot -s from the loader prompt).
72199044Sgabor#  6.  `mergemaster -p'
73199044Sgabor#  7.  `make installworld'
74199044Sgabor#  8.  `mergemaster'		(you may wish to use -i, along with -U or -F).
75199044Sgabor#  9.  `make delete-old'
76199044Sgabor# 10.  `reboot'
77199044Sgabor# 11.  `make delete-old-libs' (in case no 3rd party program uses them anymore)
78199044Sgabor#
79199044Sgabor# See src/UPDATING `COMMON ITEMS' for more complete information.
80199044Sgabor#
81199044Sgabor# If TARGET=machine (e.g. ia64, sparc64, ...) is specified you can
82199044Sgabor# cross build world for other machine types using the buildworld target,
83199044Sgabor# and once the world is built you can cross build a kernel using the
84199044Sgabor# buildkernel target.
85199044Sgabor#
86199044Sgabor# Define the user-driven targets. These are listed here in alphabetical
87199044Sgabor# order, but that's not important.
88199044Sgabor#
89199044Sgabor# Targets that begin with underscore are internal targets intended for
90199044Sgabor# developer convenience only.  They are intentionally not documented and
91199044Sgabor# completely subject to change without notice.
92199044Sgabor#
93199044Sgabor# For more information, see the build(7) manual page.
94199044Sgabor#
95199044SgaborTGTS=	all all-man buildenv buildenvvars buildkernel buildworld \
96199044Sgabor	check-old check-old-dirs check-old-files check-old-libs \
97199044Sgabor	checkdpadd clean cleandepend cleandir \
98199044Sgabor	delete-old delete-old-dirs delete-old-files delete-old-libs \
99199044Sgabor	depend distribute distributekernel distributekernel.debug \
100199044Sgabor	distributeworld distrib-dirs distribution doxygen \
101199044Sgabor	everything hier hierarchy install installcheck installkernel \
102199044Sgabor	installkernel.debug packagekernel packageworld \
103199044Sgabor	reinstallkernel reinstallkernel.debug \
104199044Sgabor	installworld kernel-toolchain libraries lint maninstall \
105199044Sgabor	obj objlink regress rerelease showconfig tags toolchain update \
106199044Sgabor	_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
107199044Sgabor	_build-tools _cross-tools _includes _libraries _depend \
108199044Sgabor	build32 builddtb distribute32 install32 xdev xdev-build xdev-install \
109199044Sgabor
110199044SgaborTGTS+=	${SUBDIR_TARGETS}
111199044Sgabor
112199044SgaborBITGTS=	files includes
113199044SgaborBITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
114199044SgaborTGTS+=	${BITGTS}
115199044Sgabor
116199044Sgabor.ORDER: buildworld installworld
117199044Sgabor.ORDER: buildworld distributeworld
118199044Sgabor.ORDER: buildworld buildkernel
119199044Sgabor.ORDER: buildkernel installkernel
120199044Sgabor.ORDER: buildkernel installkernel.debug
121199044Sgabor.ORDER: buildkernel reinstallkernel
122199044Sgabor.ORDER: buildkernel reinstallkernel.debug
123199044Sgabor
124199044SgaborPATH=	/sbin:/bin:/usr/sbin:/usr/bin
125199044SgaborMAKEOBJDIRPREFIX?=	/usr/obj
126199044Sgabor_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
127199044Sgabor    ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
128199044Sgabor    -f /dev/null -V MAKEOBJDIRPREFIX dummy
129199044Sgabor.if !empty(_MAKEOBJDIRPREFIX)
130199044Sgabor.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
131199044Sgabor	(in make.conf(5)) or command-line variable.
132199044Sgabor.endif
133199044Sgabor
134199044Sgabor# We often need to use the tree's version of make to build it.
135199044Sgabor# Choices add to complexity though.
136199044Sgabor# We cannot blindly use a make which may not be the one we want
137199044Sgabor# so be exlicit - until all choice is removed.
138199044Sgabor.if !defined(WITHOUT_BMAKE)
139199044SgaborWANT_MAKE=	bmake
140199044Sgabor.else
141199044SgaborWANT_MAKE=	fmake
142199044Sgabor.endif
143199044SgaborMYMAKE=		${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}/${WANT_MAKE}
144199044Sgabor.if defined(.PARSEDIR)
145199044SgaborHAVE_MAKE=	bmake
146199044Sgabor.else
147199044SgaborHAVE_MAKE=	fmake
148199044Sgabor.endif
149199044Sgabor.if exists(${MYMAKE})
150199044SgaborSUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
151199044Sgabor.elif ${WANT_MAKE} != ${HAVE_MAKE} || ${WANT_MAKE} != "bmake"
152199044Sgabor# It may not exist yet but we may cause it to.
153199044Sgabor# In the case of fmake, upgrade_checks may cause a newer version to be built.
154199044SgaborSUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
155199044Sgabor	-m ${.CURDIR}/share/mk
156199044Sgabor.else
157199044SgaborSUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
158199044Sgabor.endif
159199044Sgabor
160199044Sgabor_MAKE=	PATH=${PATH} ${SUB_MAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
161199044Sgabor
162199044Sgabor# Guess machine architecture from machine type, and vice versa.
163199044Sgabor.if !defined(TARGET_ARCH) && defined(TARGET)
164199044Sgabor_TARGET_ARCH=	${TARGET:S/pc98/i386/}
165199044Sgabor.elif !defined(TARGET) && defined(TARGET_ARCH) && \
166199044Sgabor    ${TARGET_ARCH} != ${MACHINE_ARCH}
167199044Sgabor_TARGET=		${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/}
168199044Sgabor.endif
169199044Sgabor# Legacy names, for another transition period mips:mips(n32|64)?eb -> mips:mips\1
170199044Sgabor.if defined(TARGET) && defined(TARGET_ARCH) && \
171199044Sgabor    ${TARGET} == "mips" && ${TARGET_ARCH:Mmips*eb}
172199044Sgabor_TARGET_ARCH=		${TARGET_ARCH:C/eb$//}
173199044Sgabor.warning "TARGET_ARCH of ${TARGET_ARCH} is deprecated in favor of ${_TARGET_ARCH}"
174199044Sgabor.endif
175199044Sgabor.if defined(TARGET) && ${TARGET} == "mips" && defined(TARGET_BIG_ENDIAN)
176199044Sgabor.warning "TARGET_BIG_ENDIAN is no longer necessary for MIPS.  Big-endian is not the default."
177199044Sgabor.endif
178199044Sgabor# arm with TARGET_BIG_ENDIAN -> armeb
179199044Sgabor.if defined(TARGET_ARCH) && ${TARGET_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN)
180199044Sgabor.warning "TARGET_ARCH of arm with TARGET_BIG_ENDIAN is deprecated.  use armeb"
181199044Sgabor_TARGET_ARCH=armeb
182199044Sgabor.endif
183199044Sgabor.if defined(TARGET) && !defined(_TARGET)
184199044Sgabor_TARGET=${TARGET}
185199044Sgabor.endif
186199044Sgabor.if defined(TARGET_ARCH) && !defined(_TARGET_ARCH)
187199044Sgabor_TARGET_ARCH=${TARGET_ARCH}
188199044Sgabor.endif
189199044Sgabor# Otherwise, default to current machine type and architecture.
190199044Sgabor_TARGET?=	${MACHINE}
191199044Sgabor_TARGET_ARCH?=	${MACHINE_ARCH}
192199044Sgabor
193199044Sgabor#
194199044Sgabor# Make sure we have an up-to-date make(1). Only world and buildworld
195199044Sgabor# should do this as those are the initial targets used for upgrades.
196199044Sgabor# The user can define ALWAYS_CHECK_MAKE to have this check performed
197199044Sgabor# for all targets.
198199044Sgabor#
199199044Sgabor.if defined(ALWAYS_CHECK_MAKE)
200199044Sgabor${TGTS}: upgrade_checks
201199044Sgabor.else
202199044Sgaborbuildworld: upgrade_checks
203199044Sgabor.endif
204199044Sgabor
205199044Sgabor#
206199044Sgabor# This 'cleanworld' target is not included in TGTS, because it is not a
207199044Sgabor# recursive target.  All of the work for it is done right here.   It is
208199044Sgabor# expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
209199044Sgabor# created by bsd.obj.mk, except that we don't want to .include that file
210199044Sgabor# in this makefile.  
211199044Sgabor#
212199044Sgabor# In the following, the first 'rm' in a series will usually remove all
213199044Sgabor# files and directories.  If it does not, then there are probably some
214199044Sgabor# files with file flags set, so this unsets them and tries the 'rm' a
215199044Sgabor# second time.  There are situations where this target will be cleaning
216199044Sgabor# some directories via more than one method, but that duplication is
217199044Sgabor# needed to correctly handle all the possible situations.  Removing all
218199044Sgabor# files without file flags set in the first 'rm' instance saves time,
219199044Sgabor# because 'chflags' will need to operate on fewer files afterwards.
220199044Sgabor#
221199044SgaborBW_CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR}
222199044Sgaborcleanworld:
223199044Sgabor.if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
224199044Sgabor.if exists(${BW_CANONICALOBJDIR}/)
225199044Sgabor	-rm -rf ${BW_CANONICALOBJDIR}/*
226199044Sgabor	-chflags -R 0 ${BW_CANONICALOBJDIR}
227199044Sgabor	rm -rf ${BW_CANONICALOBJDIR}/*
228199044Sgabor.endif
229199044Sgabor	#   To be safe in this case, fall back to a 'make cleandir'
230199044Sgabor	${_+_}@cd ${.CURDIR}; ${_MAKE} cleandir
231199044Sgabor.else
232199044Sgabor	-rm -rf ${.OBJDIR}/*
233199044Sgabor	-chflags -R 0 ${.OBJDIR}
234199044Sgabor	rm -rf ${.OBJDIR}/*
235199044Sgabor.endif
236199044Sgabor
237199044Sgabor#
238199044Sgabor# Handle the user-driven targets, using the source relative mk files.
239199044Sgabor#
240199044Sgabor
241199044Sgabor.if empty(.MAKEFLAGS:M-n)
242199044Sgabor# skip this for -n to avoid changing previous behavior of 
243199044Sgabor# 'make -n buildworld' etc.
244199044Sgabor${TGTS}: .MAKE
245199044Sgabortinderbox toolchains kernel-toolchains: .MAKE
246199044Sgabor.endif
247199044Sgabor
248199044Sgabor${TGTS}:
249199044Sgabor	${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
250199044Sgabor
251199044Sgabor# Set a reasonable default
252199044Sgabor.MAIN:	all
253199044Sgabor
254199044SgaborSTARTTIME!= LC_ALL=C date
255199044SgaborCHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo
256199044Sgabor.if !empty(CHECK_TIME)
257199044Sgabor.error check your date/time: ${STARTTIME}
258199044Sgabor.endif
259199044Sgabor
260.if defined(HISTORICAL_MAKE_WORLD) || defined(DESTDIR)
261#
262# world
263#
264# 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
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 DESTDIR= && \
353		${MMAKE} depend DESTDIR= && \
354		${MMAKE} all DESTDIR= && \
355		${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR= PROGNAME=${MYMAKE:T}
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 armv6eb
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