xref: /freebsd/contrib/bmake/unit-tests/opt-define.mk (revision bc7512cc58af2e8bbe5bbf5ca0059b1daa1da897)
1# $NetBSD: opt-define.mk,v 1.3 2022/01/23 16:09:38 rillig Exp $
2#
3# Tests for the -D command line option, which defines global variables to the
4# value 1, like in the C preprocessor.
5
6.MAKEFLAGS: -DVAR
7
8# The variable has the exact value "1", not "1.0".
9.if ${VAR} != "1"
10.  error
11.endif
12
13# The variable can be overwritten by assigning another value to it.  This
14# would not be possible if the variable had been specified on the command line
15# as 'VAR=1' instead of '-DVAR'.
16VAR=		overwritten
17.if ${VAR} != "overwritten"
18.  error
19.endif
20
21# The variable can be undefined.  If the variable had been defined in the
22# "Internal" scope instead, undefining it would have no effect.
23.undef VAR
24.if defined(VAR)
25.  error
26.endif
27
28all: .PHONY
29