michael@0: ifdef FOO michael@0: $(error FOO is not defined!) michael@0: endif michael@0: michael@0: FOO = foo michael@0: FOOFOUND = false michael@0: BARFOUND = false michael@0: BAZFOUND = false michael@0: michael@0: ifdef FOO michael@0: FOOFOUND = true michael@0: else ifdef BAR michael@0: BARFOUND = true michael@0: else michael@0: BAZFOUND = true michael@0: endif michael@0: michael@0: BAR2 = bar2 michael@0: FOO2FOUND = false michael@0: BAR2FOUND = false michael@0: BAZ2FOUND = false michael@0: michael@0: ifdef FOO2 michael@0: FOO2FOUND = true michael@0: else ifdef BAR2 michael@0: BAR2FOUND = true michael@0: else michael@0: BAZ2FOUND = true michael@0: endif michael@0: michael@0: FOO3FOUND = false michael@0: BAR3FOUND = false michael@0: BAZ3FOUND = false michael@0: michael@0: ifdef FOO3 michael@0: FOO3FOUND = true michael@0: else ifdef BAR3 michael@0: BAR3FOUND = true michael@0: else michael@0: BAZ3FOUND = true michael@0: endif michael@0: michael@0: ifdef RANDOM michael@0: CONTINUATION = \ michael@0: else \ michael@0: endif michael@0: endif michael@0: michael@0: ifndef ASDFJK michael@0: else michael@0: $(error ASFDJK was not set) michael@0: endif michael@0: michael@0: TESTSET = michael@0: michael@0: ifdef TESTSET michael@0: $(error TESTSET was not set) michael@0: endif michael@0: michael@0: TESTEMPTY = $(NULL) michael@0: ifndef TESTEMPTY michael@0: $(error TEST-FAIL TESTEMPTY was probably expanded!) michael@0: endif michael@0: michael@0: # ifneq ( a,a) michael@0: # $(error Arguments to ifeq should be stripped before evaluation) michael@0: # endif michael@0: michael@0: XSPACE = x # trick michael@0: michael@0: ifneq ($(NULL),$(NULL)) michael@0: $(error TEST-FAIL ifneq) michael@0: endif michael@0: michael@0: ifneq (x , x) michael@0: $(error argument-stripping1) michael@0: endif michael@0: michael@0: ifeq ( x,x ) michael@0: $(error argument-stripping2) michael@0: endif michael@0: michael@0: ifneq ($(XSPACE), x ) michael@0: $(error argument-stripping3) michael@0: endif michael@0: michael@0: ifeq 'x ' ' x' michael@0: $(error TEST-FAIL argument-stripping4) michael@0: endif michael@0: michael@0: all: michael@0: test $(FOOFOUND) = true # FOOFOUND michael@0: test $(BARFOUND) = false # BARFOUND michael@0: test $(BAZFOUND) = false # BAZFOUND michael@0: test $(FOO2FOUND) = false # FOO2FOUND michael@0: test $(BAR2FOUND) = true # BAR2FOUND michael@0: test $(BAZ2FOUND) = false # BAZ2FOUND michael@0: test $(FOO3FOUND) = false # FOO3FOUND michael@0: test $(BAR3FOUND) = false # BAR3FOUND michael@0: test $(BAZ3FOUND) = true # BAZ3FOUND michael@0: ifneq ($(FOO),foo) michael@0: echo TEST-FAIL 'FOO neq foo: "$(FOO)"' michael@0: endif michael@0: ifneq ($(FOO), foo) # Whitespace after the comma is stripped michael@0: echo TEST-FAIL 'FOO plus whitespace' michael@0: endif michael@0: ifeq ($(FOO), foo ) # But not trailing whitespace michael@0: echo TEST-FAIL 'FOO plus trailing whitespace' michael@0: endif michael@0: ifeq ( $(FOO),foo) # Not whitespace after the paren michael@0: echo TEST-FAIL 'FOO with leading whitespace' michael@0: endif michael@0: ifeq ($(FOO),$(NULL) foo) # Nor whitespace after expansion michael@0: echo TEST-FAIL 'FOO with embedded ws' michael@0: endif michael@0: ifeq ($(BAR2),bar) michael@0: echo TEST-FAIL 'BAR2 eq bar' michael@0: endif michael@0: ifeq '$(BAR3FOUND)' 'false' michael@0: echo BAR3FOUND is ok michael@0: else michael@0: echo TEST-FAIL BAR3FOUND is not ok michael@0: endif michael@0: ifndef FOO michael@0: echo TEST-FAIL "foo not defined?" michael@0: endif michael@0: @echo TEST-PASS