xref: /freebsd/contrib/bmake/unit-tests/deptgt-makeflags.mk (revision 36d6566e5985030fd2f1100bd9c1387bbe0bd290)
1# $NetBSD: deptgt-makeflags.mk,v 1.4 2020/10/23 14:48:49 rillig Exp $
2#
3# Tests for the special target .MAKEFLAGS in dependency declarations,
4# which adds command line options later, at parse time.
5
6# The -D option sets a variable in the "Global" scope and thus can be
7# undefined later.
8.MAKEFLAGS: -D VAR
9
10.if ${VAR} != 1
11.  error
12.endif
13
14.undef VAR
15
16.if defined(VAR)
17.  error
18.endif
19
20.MAKEFLAGS: -D VAR
21
22.if ${VAR} != 1
23.  error
24.endif
25
26.MAKEFLAGS: VAR="value"' with'\ spaces
27
28.if ${VAR} != "value with spaces"
29.  error
30.endif
31
32# Variables set on the command line as VAR=value are placed in the
33# "Command" scope and thus cannot be undefined.
34.undef VAR
35
36.if ${VAR} != "value with spaces"
37.  error
38.endif
39
40# When parsing this line, each '$$' becomes '$', resulting in '$$$$'.
41# This is assigned to the variable DOLLAR.
42# In the condition, that variable is expanded, and at that point, each '$$'
43# becomes '$' again, the final expression is thus '$$'.
44.MAKEFLAGS: -dcv
45.MAKEFLAGS: DOLLAR=$$$$$$$$
46.if ${DOLLAR} != "\$\$"
47.endif
48.MAKEFLAGS: -d0
49
50all:
51	@:;
52