X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=Makefile;h=441faf9a7e82cf364d1f069d029307221b7bbdba;hb=149d7ca4cf84c3c9b7eb55b02d6b152fb00894bf;hp=12f5f8ae4114bea2c4b816b92018e2e1e5085e1c;hpb=31a441b1a6d2d87e1c05101290c59c4c5b9523ad;p=odcread.git diff --git a/Makefile b/Makefile index 12f5f8a..441faf9 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,27 @@ -odcread: odcread.cc - g++ -o odcread odcread.cc +# List all source files to be compiled +SRCS=odcread.cc reader.cc store.cc util.cc alien.cc typeregister.cc \ + textmodel.cc fold.cc + +# This rule just links the object files together +odcread: $(SRCS:.cc=.o) + g++ -o $@ $^ + +# This rule build an object (.o) from a source (.cc). It first builds a +# dependency (.d) file which will ensure that the .o is rebuilt whenever the +# header files included by the .cc are updated. +# The options given to GCC for this are as follows: +# -MM : calculate dependencies, but exclude system headers +# -MF : output dependencies to the given file +# -MP : generate "header.h:" rules to avoid errors on deletion of headers +# -MT : the main rule has the given target (to handle subdirs correctly) +# The .d file is not an explicit target because it will need to be (re-)built +# if and only if the .o needs to be rebuilt. +%.o: %.cc + g++ -I. $< -MM -MF $*.d -MP -MT $@ + g++ -I. $< -c -o $@ + +clean: + rm -f odcread *.d *.o + +# Include the generated dependency files (if they exist) +-include $(SRCS:.cc=.d)