diff options
Diffstat (limited to 'unit-tests/impsrc.mk')
-rw-r--r-- | unit-tests/impsrc.mk | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/unit-tests/impsrc.mk b/unit-tests/impsrc.mk index 95ae0c34f3b5b..6fb31adac9382 100644 --- a/unit-tests/impsrc.mk +++ b/unit-tests/impsrc.mk @@ -1,4 +1,4 @@ -# $NetBSD: impsrc.mk,v 1.2 2014/08/30 22:21:07 sjg Exp $ +# $NetBSD: impsrc.mk,v 1.3 2020/08/07 13:43:50 rillig Exp $ # Does ${.IMPSRC} work properly? # It should be set, in order of precedence, to ${.TARGET} of: @@ -6,6 +6,8 @@ # 2) the first prerequisite from the dependency line of an explicit rule, or # 3) the first prerequisite of an explicit rule. # +# Items 2 and 3 work in GNU make. +# Items 2 and 3 are not required by POSIX 2018. all: target1.z target2 target3 target4 @@ -19,25 +21,40 @@ all: target1.z target2 target3 target4 @echo 'expected: target1.y' @echo 'actual: $<' +# (3) Making target1.z out of target1.y is done because of an inference rule. +# Therefore $< is available here. + +# (2) This is an additional dependency on the inference rule .x.y. +# The dependency target1.x comes from the inference rule, +# therefore it is available as $<. target1.y: source3 +# (1) This is an explicit dependency, not an inference rule. +# Therefore POSIX does not specify that $< be available here. target1.x: source4 - @echo 'expected: source4' + @echo 'expected: ' # either 'source4' or '' @echo 'actual: $<' +# (4) This is an explicit dependency, independent of any inference rule. +# Therefore $< is not available here. target2: source1 source2 - @echo 'expected: source1' + @echo 'expected: ' @echo 'actual: $<' +# (5) These are two explicit dependency rules. +# The first doesn't have any dependencies, only the second has. +# If any, the value of $< would be 'source2'. target3: source1 target3: source2 source3 - @echo 'expected: source2' + @echo 'expected: ' @echo 'actual: $<' +# (6) The explicit rule does not have associated commands. +# The value of $< might come from that rule, +# but it's equally fine to leave $< undefined. target4: source1 target4: - @echo 'expected: source1' + @echo 'expected: ' @echo 'actual: $<' source1 source2 source3 source4: - |