Module Name: src
Committed By: rillig
Date: Sat Jan 29 10:09:37 UTC 2022
Modified Files:
src/usr.bin/make/unit-tests: var-recursive.exp var-recursive.mk
Log Message:
tests/make: demonstrate recursive variable in target
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-recursive.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-recursive.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/unit-tests/var-recursive.exp
diff -u src/usr.bin/make/unit-tests/var-recursive.exp:1.3 src/usr.bin/make/unit-tests/var-recursive.exp:1.4
--- src/usr.bin/make/unit-tests/var-recursive.exp:1.3 Sat Jan 29 09:38:27 2022
+++ src/usr.bin/make/unit-tests/var-recursive.exp Sat Jan 29 10:09:37 2022
@@ -12,4 +12,8 @@ Variable V is recursive.
in var-recursive.mk:43
make: stopped in unit-tests
+: OK
+Variable VAR is recursive.
+
+make: stopped in unit-tests
exit status 0
Index: src/usr.bin/make/unit-tests/var-recursive.mk
diff -u src/usr.bin/make/unit-tests/var-recursive.mk:1.2 src/usr.bin/make/unit-tests/var-recursive.mk:1.3
--- src/usr.bin/make/unit-tests/var-recursive.mk:1.2 Sat Oct 31 13:45:00 2020
+++ src/usr.bin/make/unit-tests/var-recursive.mk Sat Jan 29 10:09:37 2022
@@ -1,9 +1,9 @@
-# $NetBSD: var-recursive.mk,v 1.2 2020/10/31 13:45:00 rillig Exp $
+# $NetBSD: var-recursive.mk,v 1.3 2022/01/29 10:09:37 rillig Exp $
#
# Tests for variable expressions that refer to themselves and thus
# cannot be evaluated.
-TESTS= direct indirect conditional short
+TESTS= direct indirect conditional short target
# Since make exits immediately when it detects a recursive expression,
# the actual tests are run in sub-makes.
@@ -42,6 +42,18 @@ CONDITIONAL= ${1:?ok:${CONDITIONAL}}
V= $V
. info $V
+.elif ${TEST} == target
+
+# If a recursive variable is accessed in a command of a target, the makefiles
+# are not parsed anymore, so there is no location information from the
+# .includes and .for directives. TODO: In such a case, use the target
+# definition to provide at least a hint to the location.
+VAR= ${VAR}
+target:
+ : OK
+ : ${VAR}
+ : OK
+
.else
. error Unknown test "${TEST}"
.endif