Rewrite the Mage basics, temporarily removing the dependency-logging command
[mgear/mgear.git] / experiments / prereq-predict.mk
1 .SECONDEXPANSION:
2
3 #dir/x.foo:
4
5 #ding=$(@:.foo=.bar)
6 #
7 #%.foo: $$(info got here) /./proc/self/cwd/$$(ding)
8 #       echo "Prerequisites: $^"
9 #
10 #%.bar:
11 #       echo "We want $@"
12
13 # $(call save-and-use,/,prereqs)
14 #save-and-use=$(eval $@=$(if $1,$2,$(foreach p,$2,$(dir $@)$p)))$2
15
16 pr1=$(info in pr1, $$@ is $@)$(eval $@@gdeps:=$(subst %,$*,$1))$1
17 pr2=$(info in pr2, $$@ is $@)$(eval $@@gdeps:=$(addprefix $(dir $@),$(subst %,$*,$1)))$1
18
19 FORCE:
20
21 define define-rule
22 $(eval 
23 $1: $(if $(findstring /,$1),$$$$(call pr1,$2),$$$$(call pr2,$2)) FORCE
24         $$(info +++ $$$$^ is $$^, gdeps is $$($$@@gdeps))
25 )
26 endef
27
28 $(call define-rule,%.foo,%.bar)
29
30 x/%.bar:
31         $(info +++ Making $@)
32