DEADSOFTWARE

Makefile: proper dependency management
[odcread.git] / Makefile
1 # List all source files to be compiled
2 SRCS=odcread.cc reader.cc store.cc util.cc alien.cc typeregister.cc \
3 textmodel.cc fold.cc
5 # This rule just links the object files together
6 odcread: $(SRCS:.cc=.o)
7 g++ -o $@ $^
9 # This rule build an object (.o) from a source (.cc). It first builds a
10 # dependency (.d) file which will ensure that the .o is rebuilt whenever the
11 # header files included by the .cc are updated.
12 # The options given to GCC for this are as follows:
13 # -MM : calculate dependencies, but exclude system headers
14 # -MF : output dependencies to the given file
15 # -MP : generate "header.h:" rules to avoid errors on deletion of headers
16 # -MT : the main rule has the given target (to handle subdirs correctly)
17 # The .d file is not an explicit target because it will need to be (re-)built
18 # if and only if the .o needs to be rebuilt.
19 %.o: %.cc
20 g++ -I. $< -MM -MF $*.d -MP -MT $@
21 g++ -I. $< -c -o $@
23 clean:
24 rm -f odcread *.d *.o
26 # Include the generated dependency files (if they exist)
27 -include $(SRCS:.cc=.d)