1 # $NetBSD: impsrc.mk,v 1.3 2020/08/07 13:43:50 rillig Exp $
3 # Does ${.IMPSRC} work properly?
4 # It should be set, in order of precedence, to ${.TARGET} of:
5 # 1) the implied source of a transformation rule,
6 # 2) the first prerequisite from the dependency line of an explicit rule, or
7 # 3) the first prerequisite of an explicit rule.
9 # Items 2 and 3 work in GNU make.
10 # Items 2 and 3 are not required by POSIX 2018.
12 all: target1.z target2 target3 target4
17 @echo 'expected: target1.x'
21 @echo 'expected: target1.y'
24 # (3) Making target1.z out of target1.y is done because of an inference rule.
25 # Therefore $< is available here.
27 # (2) This is an additional dependency on the inference rule .x.y.
28 # The dependency target1.x comes from the inference rule,
29 # therefore it is available as $<.
32 # (1) This is an explicit dependency, not an inference rule.
33 # Therefore POSIX does not specify that $< be available here.
35 @echo 'expected: ' # either 'source4' or ''
38 # (4) This is an explicit dependency, independent of any inference rule.
39 # Therefore $< is not available here.
40 target2: source1 source2
44 # (5) These are two explicit dependency rules.
45 # The first doesn't have any dependencies, only the second has.
46 # If any, the value of $< would be 'source2'.
48 target3: source2 source3
52 # (6) The explicit rule does not have associated commands.
53 # The value of $< might come from that rule,
54 # but it's equally fine to leave $< undefined.
60 source1 source2 source3 source4: