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