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