Module Name: src
Committed By: rillig
Date: Mon Jun 19 20:44:06 UTC 2023
Modified Files:
src/usr.bin/make/unit-tests: directive-ifndef.exp directive-ifndef.mk
Log Message:
tests/make: test triple negation in '.ifndef'
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/directive-ifndef.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/directive-ifndef.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/directive-ifndef.exp
diff -u src/usr.bin/make/unit-tests/directive-ifndef.exp:1.5 src/usr.bin/make/unit-tests/directive-ifndef.exp:1.6
--- src/usr.bin/make/unit-tests/directive-ifndef.exp:1.5 Thu Jun 1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/directive-ifndef.exp Mon Jun 19 20:44:06 2023
@@ -1,2 +1,2 @@
-make: "directive-ifndef.mk" line 11: guarded section
+make: "directive-ifndef.mk" line 14: guarded section
exit status 0
Index: src/usr.bin/make/unit-tests/directive-ifndef.mk
diff -u src/usr.bin/make/unit-tests/directive-ifndef.mk:1.7 src/usr.bin/make/unit-tests/directive-ifndef.mk:1.8
--- src/usr.bin/make/unit-tests/directive-ifndef.mk:1.7 Thu Jun 1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/directive-ifndef.mk Mon Jun 19 20:44:06 2023
@@ -1,9 +1,12 @@
-# $NetBSD: directive-ifndef.mk,v 1.7 2023/06/01 20:56:35 rillig Exp $
+# $NetBSD: directive-ifndef.mk,v 1.8 2023/06/19 20:44:06 rillig Exp $
#
# Tests for the .ifndef directive, which can be used for multiple-inclusion
# guards. In contrast to C, where #ifndef and #define nicely line up the
# macro name, there is no such syntax in make. Therefore, it is more
# common to use .if !defined(GUARD) instead.
+#
+# See also:
+# directive-include-guard.mk
.ifndef GUARD
GUARD= # defined
@@ -21,5 +24,30 @@ GUARD= # defined
. info guarded section
.endif
+
+# The '.ifndef' directive can be used with multiple arguments, even negating
+# them. Since these conditions are confusing for humans, they should be
+# replaced with easier-to-understand plain '.if' directives.
+DEFINED=
+.ifndef UNDEFINED && UNDEFINED
+.else
+. error
+.endif
+.ifndef UNDEFINED && DEFINED
+. error
+.endif
+.ifndef DEFINED && DEFINED
+. error
+.endif
+.ifndef !UNDEFINED && !UNDEFINED
+. error
+.endif
+.ifndef !UNDEFINED && !DEFINED
+. error
+.endif
+.ifndef !DEFINED && !DEFINED
+.else
+. error
+.endif
+
all:
- @:;