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