From c697d06cb5c00d7450259da63725840b7705a256 Mon Sep 17 00:00:00 2001 From: rillig Date: Sun, 12 Jun 2022 14:27:06 +0000 Subject: [PATCH] tests/make: demonstrate what happens for 'make -DVAR=value' --- usr.bin/make/unit-tests/opt-define.mk | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/usr.bin/make/unit-tests/opt-define.mk b/usr.bin/make/unit-tests/opt-define.mk index 7c4bbc179316..f508a9b1592f 100644 --- a/usr.bin/make/unit-tests/opt-define.mk +++ b/usr.bin/make/unit-tests/opt-define.mk @@ -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