summaryrefslogtreecommitdiff
path: root/solenv/gbuild/source_and_rerun.mk
blob: a2aaea0687a665279c591809d06c783f6f01f0ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

gb_MAKEFILEDIR:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))

define gb_SourceEnvAndRecurse_recurse
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) -j $${GMAKE_PARALLELISM} $(1) gb_SourceEnvAndRecurse_STAGE=$(2)
endef

ifneq ($(strip $(gb_PARTIALBUILD)),)

SRCDIR:=$(realpath $(gb_MAKEFILEDIR)/..)
gb_SourceEnvAndRecurse_reconfigure=true
gb_SourceEnvAndRecurse_buildpl=true

else

SRCDIR:=$(realpath $(gb_MAKEFILEDIR))
gb_SourceEnvAndRecurse_reconfigure=$(call gb_SourceEnvAndRecurse_recurse,$(SRCDIR)/Env.Host.sh,reconfigure)
gb_SourceEnvAndRecurse_buildpl=$(call gb_SourceEnvAndRecurse_recurse,$(MAKECMDGOALS),buildpl)

endif

source-env-and-recurse:
	@$(gb_SourceEnvAndRecurse_reconfigure) && \
	if test -f $(SRCDIR)/config.mk ; then . $(SRCDIR)/config.mk; fi && \
	if test -f $(SRCDIR)/Env.Host.sh; then . $(SRCDIR)/Env.Host.sh; fi && \
	if test -z "$${SOLARENV}"; then echo "no configuration found and could not create one" && exit 1; fi && \
	$(gb_SourceEnvAndRecurse_buildpl) && \
	$(call gb_SourceEnvAndRecurse_recurse,$(MAKECMDGOALS),gbuild) \


ifneq ($(strip $(MAKECMDGOALS)),)
ifneq ($(MAKECMDGOALS),$(SRCDIR)/Env.Host.sh)
$(eval $(MAKECMDGOALS) : source-env-and-recurse)
endif
endif