1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/build/pymake/tests/ifdefs.mk Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,127 @@ 1.4 +ifdef FOO 1.5 +$(error FOO is not defined!) 1.6 +endif 1.7 + 1.8 +FOO = foo 1.9 +FOOFOUND = false 1.10 +BARFOUND = false 1.11 +BAZFOUND = false 1.12 + 1.13 +ifdef FOO 1.14 +FOOFOUND = true 1.15 +else ifdef BAR 1.16 +BARFOUND = true 1.17 +else 1.18 +BAZFOUND = true 1.19 +endif 1.20 + 1.21 +BAR2 = bar2 1.22 +FOO2FOUND = false 1.23 +BAR2FOUND = false 1.24 +BAZ2FOUND = false 1.25 + 1.26 +ifdef FOO2 1.27 +FOO2FOUND = true 1.28 +else ifdef BAR2 1.29 +BAR2FOUND = true 1.30 +else 1.31 +BAZ2FOUND = true 1.32 +endif 1.33 + 1.34 +FOO3FOUND = false 1.35 +BAR3FOUND = false 1.36 +BAZ3FOUND = false 1.37 + 1.38 +ifdef FOO3 1.39 +FOO3FOUND = true 1.40 +else ifdef BAR3 1.41 +BAR3FOUND = true 1.42 +else 1.43 +BAZ3FOUND = true 1.44 +endif 1.45 + 1.46 +ifdef RANDOM 1.47 +CONTINUATION = \ 1.48 +else \ 1.49 +endif 1.50 +endif 1.51 + 1.52 +ifndef ASDFJK 1.53 +else 1.54 +$(error ASFDJK was not set) 1.55 +endif 1.56 + 1.57 +TESTSET = 1.58 + 1.59 +ifdef TESTSET 1.60 +$(error TESTSET was not set) 1.61 +endif 1.62 + 1.63 +TESTEMPTY = $(NULL) 1.64 +ifndef TESTEMPTY 1.65 +$(error TEST-FAIL TESTEMPTY was probably expanded!) 1.66 +endif 1.67 + 1.68 +# ifneq ( a,a) 1.69 +# $(error Arguments to ifeq should be stripped before evaluation) 1.70 +# endif 1.71 + 1.72 +XSPACE = x # trick 1.73 + 1.74 +ifneq ($(NULL),$(NULL)) 1.75 +$(error TEST-FAIL ifneq) 1.76 +endif 1.77 + 1.78 +ifneq (x , x) 1.79 +$(error argument-stripping1) 1.80 +endif 1.81 + 1.82 +ifeq ( x,x ) 1.83 +$(error argument-stripping2) 1.84 +endif 1.85 + 1.86 +ifneq ($(XSPACE), x ) 1.87 +$(error argument-stripping3) 1.88 +endif 1.89 + 1.90 +ifeq 'x ' ' x' 1.91 +$(error TEST-FAIL argument-stripping4) 1.92 +endif 1.93 + 1.94 +all: 1.95 + test $(FOOFOUND) = true # FOOFOUND 1.96 + test $(BARFOUND) = false # BARFOUND 1.97 + test $(BAZFOUND) = false # BAZFOUND 1.98 + test $(FOO2FOUND) = false # FOO2FOUND 1.99 + test $(BAR2FOUND) = true # BAR2FOUND 1.100 + test $(BAZ2FOUND) = false # BAZ2FOUND 1.101 + test $(FOO3FOUND) = false # FOO3FOUND 1.102 + test $(BAR3FOUND) = false # BAR3FOUND 1.103 + test $(BAZ3FOUND) = true # BAZ3FOUND 1.104 +ifneq ($(FOO),foo) 1.105 + echo TEST-FAIL 'FOO neq foo: "$(FOO)"' 1.106 +endif 1.107 +ifneq ($(FOO), foo) # Whitespace after the comma is stripped 1.108 + echo TEST-FAIL 'FOO plus whitespace' 1.109 +endif 1.110 +ifeq ($(FOO), foo ) # But not trailing whitespace 1.111 + echo TEST-FAIL 'FOO plus trailing whitespace' 1.112 +endif 1.113 +ifeq ( $(FOO),foo) # Not whitespace after the paren 1.114 + echo TEST-FAIL 'FOO with leading whitespace' 1.115 +endif 1.116 +ifeq ($(FOO),$(NULL) foo) # Nor whitespace after expansion 1.117 + echo TEST-FAIL 'FOO with embedded ws' 1.118 +endif 1.119 +ifeq ($(BAR2),bar) 1.120 + echo TEST-FAIL 'BAR2 eq bar' 1.121 +endif 1.122 +ifeq '$(BAR3FOUND)' 'false' 1.123 + echo BAR3FOUND is ok 1.124 +else 1.125 + echo TEST-FAIL BAR3FOUND is not ok 1.126 +endif 1.127 +ifndef FOO 1.128 + echo TEST-FAIL "foo not defined?" 1.129 +endif 1.130 + @echo TEST-PASS