I have the following Makefile
SHELL=/bin/bash
.SHELLFLAGS=-O extglob -o errexit -o pipefail -o nounset -c
.PHONY: testing
define getFileContents
$(shell cat ./test.txt)
endef
TEST_STATIC=dummy
deploy:
$(eval TEST=$(getFileContents))
@echo "$(TEST)"
ifeq ($(TEST),dummy)
@echo "$(TEST) is FAILED"
else
@echo "$(TEST) is PASS"
endif
ifneq (,$(findstring dummy,$(TEST)))
@echo "$(TEST) is FAILED"
else
@echo "$(TEST) is PASS"
endif
ifeq ($(TEST_STATIC),dummy)
@echo "$(TEST) is FAILED"
else
@echo "$(TEST) is PASS"
endif
ifneq (,$(findstring dummy,$(TEST_STATIC)))
@echo "$(TEST) is FAILED"
else
@echo "$(TEST) is PASS"
endif
No matter what value I put in ./test.txt, I always go into PASS in both the ifeq & the findstring conditions but the variable's values show up properly in the echo statements. So the value is not available during the evaluation of ifeq
However, the if-else behaves properly for the TEST_STATIC variable.
Any help would be appreciated. Thanks.
evalline betweenendefanddeploy:lines, and modify toTEST := $(getFileContents); then reverse all your echo lines for PASS and FAIL; also instead oftestingdid you mean.PHONY: deploy? - Milag