I wrote a fairly simple Makefile test where I define two goals, all clean and clean. I have two different conditional statements. One checks for the existence of the special variable $(MAKECMDGOALS) , and the other determines whether any of the command line targets match those listed in the variable ( NODEPS ). The problem I am facing is that none of the branches inside my conditions are satisfied. Ultimately, I want to use a conditional expression to decide whether the target should deliver some files with auto-generated dependencies, but at the moment I'm struggling to get either an expression to evaluate. I am running GNU make version 3.81, and I have tried it under Ubuntu and Mac OS X to no avail.
NODEPS := clean INCLUDE = $(filter $(NODEPS),$(MAKECMDGOALS)) .PHONY : all clean ifndef $(MAKECMDGOALS) @echo "$$(MAKECMDGOALS) is not defined" else @echo "$(MAKECMDGOALS) is defined" endif ifneq (0, $(words $(INCLUDE))) @echo "INCLUDE = $(INCLUDE) != 0" else @echo "INCLUDE = $(INCLUDE) == 0" endif all : @echo "all : $(MAKECMDGOALS)" clean : @echo "clean : $(MAKECMDGOALS)"
source share