Hi folks,
I am trying to create a standardized Makefile construct for my projects. Standardized means i do not need to specify the targets all one by one but with pattern matching like
Code:
%.o: %.cc %.h
$(CXX) ...
Now there comes up a problem: If i got a headerfile named equal as the sourcefile all works right. But if not make will not find a target to compile.
Example:
Code:
...
SOURCES:=main.cc test.cc
HEADERS:=test.h
TARGETDIR:=../objects
...
$(TARGETDIR)/%.o: %.cc %.h
$(CXX) $(CXXFLAGS) -o $@ $<
depend:
$(CXX) -E -MM $(SOURCES) $(HEADERS) > .depend
This snippet will compile test.cc if test.h is changed. But it will not compile main.cc because there is no header.
Now the question: How can I modify the makefile so that it can check if a header exists and than and only than include it to the rule?
I am grateful for any suggestions
Greetz Mea