Module Name: src Committed By: rillig Date: Sun Jun 12 14:27:06 UTC 2022
Modified Files: src/usr.bin/make/unit-tests: opt-define.mk Log Message: tests/make: demonstrate what happens for 'make -DVAR=value' To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-define.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/opt-define.mk diff -u src/usr.bin/make/unit-tests/opt-define.mk:1.3 src/usr.bin/make/unit-tests/opt-define.mk:1.4 --- src/usr.bin/make/unit-tests/opt-define.mk:1.3 Sun Jan 23 16:09:38 2022 +++ src/usr.bin/make/unit-tests/opt-define.mk Sun Jun 12 14:27:06 2022 @@ -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 @@ VAR= overwritten .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