summaryrefslogtreecommitdiff
path: root/unit-tests/deptgt-makeflags.mk
diff options
context:
space:
mode:
Diffstat (limited to 'unit-tests/deptgt-makeflags.mk')
-rw-r--r--unit-tests/deptgt-makeflags.mk49
1 files changed, 46 insertions, 3 deletions
diff --git a/unit-tests/deptgt-makeflags.mk b/unit-tests/deptgt-makeflags.mk
index 958751b64cfa..70a9cd0b590b 100644
--- a/unit-tests/deptgt-makeflags.mk
+++ b/unit-tests/deptgt-makeflags.mk
@@ -1,8 +1,51 @@
-# $NetBSD: deptgt-makeflags.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: deptgt-makeflags.mk,v 1.4 2020/10/23 14:48:49 rillig Exp $
#
-# Tests for the special target .MAKEFLAGS in dependency declarations.
+# Tests for the special target .MAKEFLAGS in dependency declarations,
+# which adds command line options later, at parse time.
-# TODO: Implementation
+# The -D option sets a variable in the "Global" scope and thus can be
+# undefined later.
+.MAKEFLAGS: -D VAR
+
+.if ${VAR} != 1
+. error
+.endif
+
+.undef VAR
+
+.if defined(VAR)
+. error
+.endif
+
+.MAKEFLAGS: -D VAR
+
+.if ${VAR} != 1
+. error
+.endif
+
+.MAKEFLAGS: VAR="value"' with'\ spaces
+
+.if ${VAR} != "value with spaces"
+. error
+.endif
+
+# Variables set on the command line as VAR=value are placed in the
+# "Command" scope and thus cannot be undefined.
+.undef VAR
+
+.if ${VAR} != "value with spaces"
+. error
+.endif
+
+# When parsing this line, each '$$' becomes '$', resulting in '$$$$'.
+# This is assigned to the variable DOLLAR.
+# In the condition, that variable is expanded, and at that point, each '$$'
+# becomes '$' again, the final expression is thus '$$'.
+.MAKEFLAGS: -dcv
+.MAKEFLAGS: DOLLAR=$$$$$$$$
+.if ${DOLLAR} != "\$\$"
+.endif
+.MAKEFLAGS: -d0
all:
@:;