build/pymake/tests/ifdefs.mk

branch
TOR_BUG_9701
changeset 3
141e0f1194b1
equal deleted inserted replaced
-1:000000000000 0:4abec6b31ee0
1 ifdef FOO
2 $(error FOO is not defined!)
3 endif
4
5 FOO = foo
6 FOOFOUND = false
7 BARFOUND = false
8 BAZFOUND = false
9
10 ifdef FOO
11 FOOFOUND = true
12 else ifdef BAR
13 BARFOUND = true
14 else
15 BAZFOUND = true
16 endif
17
18 BAR2 = bar2
19 FOO2FOUND = false
20 BAR2FOUND = false
21 BAZ2FOUND = false
22
23 ifdef FOO2
24 FOO2FOUND = true
25 else ifdef BAR2
26 BAR2FOUND = true
27 else
28 BAZ2FOUND = true
29 endif
30
31 FOO3FOUND = false
32 BAR3FOUND = false
33 BAZ3FOUND = false
34
35 ifdef FOO3
36 FOO3FOUND = true
37 else ifdef BAR3
38 BAR3FOUND = true
39 else
40 BAZ3FOUND = true
41 endif
42
43 ifdef RANDOM
44 CONTINUATION = \
45 else \
46 endif
47 endif
48
49 ifndef ASDFJK
50 else
51 $(error ASFDJK was not set)
52 endif
53
54 TESTSET =
55
56 ifdef TESTSET
57 $(error TESTSET was not set)
58 endif
59
60 TESTEMPTY = $(NULL)
61 ifndef TESTEMPTY
62 $(error TEST-FAIL TESTEMPTY was probably expanded!)
63 endif
64
65 # ifneq ( a,a)
66 # $(error Arguments to ifeq should be stripped before evaluation)
67 # endif
68
69 XSPACE = x # trick
70
71 ifneq ($(NULL),$(NULL))
72 $(error TEST-FAIL ifneq)
73 endif
74
75 ifneq (x , x)
76 $(error argument-stripping1)
77 endif
78
79 ifeq ( x,x )
80 $(error argument-stripping2)
81 endif
82
83 ifneq ($(XSPACE), x )
84 $(error argument-stripping3)
85 endif
86
87 ifeq 'x ' ' x'
88 $(error TEST-FAIL argument-stripping4)
89 endif
90
91 all:
92 test $(FOOFOUND) = true # FOOFOUND
93 test $(BARFOUND) = false # BARFOUND
94 test $(BAZFOUND) = false # BAZFOUND
95 test $(FOO2FOUND) = false # FOO2FOUND
96 test $(BAR2FOUND) = true # BAR2FOUND
97 test $(BAZ2FOUND) = false # BAZ2FOUND
98 test $(FOO3FOUND) = false # FOO3FOUND
99 test $(BAR3FOUND) = false # BAR3FOUND
100 test $(BAZ3FOUND) = true # BAZ3FOUND
101 ifneq ($(FOO),foo)
102 echo TEST-FAIL 'FOO neq foo: "$(FOO)"'
103 endif
104 ifneq ($(FOO), foo) # Whitespace after the comma is stripped
105 echo TEST-FAIL 'FOO plus whitespace'
106 endif
107 ifeq ($(FOO), foo ) # But not trailing whitespace
108 echo TEST-FAIL 'FOO plus trailing whitespace'
109 endif
110 ifeq ( $(FOO),foo) # Not whitespace after the paren
111 echo TEST-FAIL 'FOO with leading whitespace'
112 endif
113 ifeq ($(FOO),$(NULL) foo) # Nor whitespace after expansion
114 echo TEST-FAIL 'FOO with embedded ws'
115 endif
116 ifeq ($(BAR2),bar)
117 echo TEST-FAIL 'BAR2 eq bar'
118 endif
119 ifeq '$(BAR3FOUND)' 'false'
120 echo BAR3FOUND is ok
121 else
122 echo TEST-FAIL BAR3FOUND is not ok
123 endif
124 ifndef FOO
125 echo TEST-FAIL "foo not defined?"
126 endif
127 @echo TEST-PASS

mercurial