I have the following piece of makefile:
CXXFLAGS = -std=c++0x -Wall
SRCS = test1.cpp test2.cpp
OBJDIR = object
OBJS = $(SRCS:%.cpp=$(OBJDIR)/%.o)
all:
In the release case, you need to ensure that clean
completes before any compiling. Thus you (just) add it as a dependency to the compile rule (and not to the phony target). Several ways of doing this, like target-specific variables, or:
$(OBJDIR)/%.o: %.cpp $(if $(filter release,${MAKECMDGOALS}),clean)
...