From 15648f10d8f75d81c676bb73e4f63031896e79c7 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Mon, 4 Jan 2010 23:45:00 +0100 Subject: added dep-calculation to rebuild objectfile, if header changed --- test/Makefile | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/Makefile b/test/Makefile index 6dfcee98..2b8eef7b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -8,19 +8,28 @@ zip:=$(PROJECT).rar headers:=$(wildcard *.hpp) $(wildcard */*.hpp) $(wildcard ../src/*/*.hpp) $(wildcard ../src/*.hpp) sources:=$(wildcard *.cpp) $(wildcard */*.cpp) $(wildcard ../src/*/*.cpp) $(wildcard ../src/*.cpp) objects:=$(sources:.cpp=.o) +deps:=$(sources:.cpp=.d) -all: $(TARGET) +all: $(deps) $(TARGET) + +ifneq ($(MAKECMDGOALS),clean) +-include $(deps) +endif .PHONY: all clean run zip -$(TARGET): $(objects) +$(TARGET): $(objects) $(deps) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $(TARGET) $(objects) %.o: %.cpp $(CXX) $(CXXFLAGS) -MMD -c $< -o $@ +%.d: %.cpp + $(CXX) $(CXXFLAGS) -MMD -E -c $< -o $(@:.d=.tmp) + rm $(@:.d=.tmp) + clean: - -$(RM) $(TARGET) $(objects) + -$(RM) $(TARGET) $(objects) $(deps) run: $(TARGET) ./$(TARGET) -- cgit v1.2.3