summaryrefslogtreecommitdiffstats
path: root/build/pymake/tests/ifdefs.mk
blob: a779d197b834ab8fc35520597d1c47f2bd10e1e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
ifdef FOO
$(error FOO is not defined!)
endif

FOO = foo
FOOFOUND = false
BARFOUND = false
BAZFOUND = false

ifdef FOO
FOOFOUND = true
else ifdef BAR
BARFOUND = true
else
BAZFOUND = true
endif

BAR2 = bar2
FOO2FOUND = false
BAR2FOUND = false
BAZ2FOUND = false

ifdef FOO2
FOO2FOUND = true
else ifdef BAR2
BAR2FOUND = true
else
BAZ2FOUND = true
endif

FOO3FOUND = false
BAR3FOUND = false
BAZ3FOUND = false

ifdef FOO3
FOO3FOUND = true
else ifdef BAR3
BAR3FOUND = true
else
BAZ3FOUND = true
endif

ifdef RANDOM
CONTINUATION = \
else           \
endif
endif

ifndef ASDFJK
else
$(error ASFDJK was not set)
endif

TESTSET =

ifdef TESTSET
$(error TESTSET was not set)
endif

TESTEMPTY = $(NULL)
ifndef TESTEMPTY
$(error TEST-FAIL TESTEMPTY was probably expanded!)
endif

# ifneq ( a,a)
# $(error Arguments to ifeq should be stripped before evaluation)
# endif

XSPACE = x # trick

ifneq ($(NULL),$(NULL))
$(error TEST-FAIL ifneq)
endif

ifneq (x , x)
$(error argument-stripping1)
endif

ifeq ( x,x )
$(error argument-stripping2)
endif

ifneq ($(XSPACE), x )
$(error argument-stripping3)
endif

ifeq 'x ' ' x'
$(error TEST-FAIL argument-stripping4)
endif

all:
	test $(FOOFOUND) = true   # FOOFOUND
	test $(BARFOUND) = false  # BARFOUND
	test $(BAZFOUND) = false  # BAZFOUND
	test $(FOO2FOUND) = false # FOO2FOUND
	test $(BAR2FOUND) = true  # BAR2FOUND
	test $(BAZ2FOUND) = false # BAZ2FOUND
	test $(FOO3FOUND) = false # FOO3FOUND
	test $(BAR3FOUND) = false # BAR3FOUND
	test $(BAZ3FOUND) = true  # BAZ3FOUND
ifneq ($(FOO),foo)
	echo TEST-FAIL 'FOO neq foo: "$(FOO)"'
endif
ifneq ($(FOO), foo) # Whitespace after the comma is stripped
	echo TEST-FAIL 'FOO plus whitespace'
endif
ifeq ($(FOO), foo ) # But not trailing whitespace
	echo TEST-FAIL 'FOO plus trailing whitespace'
endif
ifeq ( $(FOO),foo) # Not whitespace after the paren
	echo TEST-FAIL 'FOO with leading whitespace'
endif
ifeq ($(FOO),$(NULL) foo) # Nor whitespace after expansion
	echo TEST-FAIL 'FOO with embedded ws'
endif
ifeq ($(BAR2),bar)
	echo TEST-FAIL 'BAR2 eq bar'
endif
ifeq '$(BAR3FOUND)' 'false'
	echo BAR3FOUND is ok
else
	echo TEST-FAIL BAR3FOUND is not ok
endif
ifndef FOO
	echo TEST-FAIL "foo not defined?"
endif
	@echo TEST-PASS