xref: /freebsd/targets/pseudo/universe/Makefile (revision 325151a3)
1# $FreeBSD$
2
3# This target is "special".
4#
5# The actual work is done via another target;
6# UNIVERSE_TARGET_RELDIR is used to identify it.
7#
8# We leverage dirdeps.mk to run a sub-make per
9# MACHINE/ARCH to each build ${UNIVERSE_TARGET_RELDIR}
10# in meta mode.
11#
12# We simply override the level at which dirdeps.mk normally does
13# its thing, and give it a DIRDEPS list that corresponds to
14# ${UNIVERSE_TARGET_RELDIR}.${TARGET_SPEC} for each TARGET_SPEC we
15# want.
16#
17# This allows the computation of dependencies for each ${TARGET_SPEC}
18# to happen in parallel - avoiding a very long startup time.
19# We can even export each sub-make to a different machine if using a
20# cluster.
21#
22# The above works fine so long as our sub-makes remain independent.
23# That is; none of them  attempts to visit any directory for a machine
24# other than the TARGET_SPEC we gave it.
25# For example; to build some tool for the pseudo machine "host".
26# To avoid that, our Makefile.depend lists all the hosttools we might
27# need and these will thus be built before we launch the
28# ${UNIVERSE_TARGET_RELDIR} sub-makes.
29# Further we add a filter to skip any "host" dirdeps during those
30# sub-makes.
31#
32#
33
34# this is the RELDIR of the target we build
35UNIVERSE_TARGET_RELDIR?= targets/pseudo/the-lot
36
37# the list of machines
38TARGET_MACHINE_LIST = i386 amd64
39# some machines have more than one arch
40TARGET_ARCHES_arm?=     arm armeb armv6 armv6hf
41
42# avoid ../Makefile.inc defining this
43all:
44
45.include "../Makefile.inc"
46
47.if ${.MAKE.LEVEL} > 0
48# ok our prerequisites have been built
49.if !defined(UNIVERSE_GUARD)
50# just incase we end up back here,
51# we cannot rely on .MAKE.LEVEL as we normally would
52UNIVERSE_GUARD=1
53.export UNIVERSE_GUARD
54
55# we want to re-use dirdeps
56_DIRDEP_USE_LEVEL = ${.MAKE.LEVEL}
57
58# we want our sub-makes to think they are level 0
59# and we don't want failure of one to stop all.
60DIRDEP_USE_ENV= \
61	MAKELEVEL=0 \
62	MAKE_JOB_ERROR_TOKEN=no
63
64
65_target_specs:= ${TARGET_MACHINE_LIST:@m@${TARGET_ARCHES_$m:U$m:@a@$m,$a@}@:O:u}
66
67DIRDEPS:= ${_target_specs:@t@${UNIVERSE_TARGET_RELDIR}.$t@}
68
69all: dirdeps
70
71.include <dirdeps.mk>
72.endif
73.endif
74