Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests tests/make: test triple negation in ...



details:   https://anonhg.NetBSD.org/src/rev/4401745455ef
branches:  trunk
changeset: 376470:4401745455ef
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Jun 19 20:44:06 2023 +0000

description:
tests/make: test triple negation in '.ifndef'

diffstat:

 usr.bin/make/unit-tests/directive-ifndef.exp |   2 +-
 usr.bin/make/unit-tests/directive-ifndef.mk  |  32 ++++++++++++++++++++++++++-
 2 files changed, 31 insertions(+), 3 deletions(-)

diffs (56 lines):

diff -r 258cd80dfc87 -r 4401745455ef usr.bin/make/unit-tests/directive-ifndef.exp
--- a/usr.bin/make/unit-tests/directive-ifndef.exp      Mon Jun 19 20:14:45 2023 +0000
+++ b/usr.bin/make/unit-tests/directive-ifndef.exp      Mon Jun 19 20:44:06 2023 +0000
@@ -1,2 +1,2 @@
-make: "directive-ifndef.mk" line 11: guarded section
+make: "directive-ifndef.mk" line 14: guarded section
 exit status 0
diff -r 258cd80dfc87 -r 4401745455ef usr.bin/make/unit-tests/directive-ifndef.mk
--- a/usr.bin/make/unit-tests/directive-ifndef.mk       Mon Jun 19 20:14:45 2023 +0000
+++ b/usr.bin/make/unit-tests/directive-ifndef.mk       Mon Jun 19 20:44:06 2023 +0000
@@ -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:
-       @:;



Home | Main Index | Thread Index | Old Index