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: demonstrate what happens...



details:   https://anonhg.NetBSD.org/src/rev/8834f04a5733
branches:  trunk
changeset: 366756:8834f04a5733
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jun 12 14:27:06 2022 +0000

description:
tests/make: demonstrate what happens for 'make -DVAR=value'

diffstat:

 usr.bin/make/unit-tests/opt-define.mk |  16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diffs (33 lines):

diff -r 754f845b8315 -r 8834f04a5733 usr.bin/make/unit-tests/opt-define.mk
--- a/usr.bin/make/unit-tests/opt-define.mk     Sun Jun 12 13:37:32 2022 +0000
+++ b/usr.bin/make/unit-tests/opt-define.mk     Sun Jun 12 14:27:06 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: opt-define.mk,v 1.3 2022/01/23 16:09:38 rillig Exp $
+# $NetBSD: opt-define.mk,v 1.4 2022/06/12 14:27:06 rillig Exp $
 #
 # Tests for the -D command line option, which defines global variables to the
 # value 1, like in the C preprocessor.
@@ -19,10 +19,22 @@
 .endif
 
 # The variable can be undefined.  If the variable had been defined in the
-# "Internal" scope instead, undefining it would have no effect.
+# "Internal" or in the "Command" scope instead, undefining it would have no
+# effect.
 .undef VAR
 .if defined(VAR)
 .  error
 .endif
 
+# The C preprocessor allows to define a macro with a specific value.  Make
+# behaves differently, it defines a variable with the name 'VAR=value' and the
+# value 1.
+.MAKEFLAGS: -DVAR=value
+.if defined(VAR)
+.  error
+.endif
+.if ${VAR=value} != "1"
+.  error
+.endif
+
 all: .PHONY



Home | Main Index | Thread Index | Old Index