X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=Makefile;h=260da917104710eaf8c5c5f7a0f6dca5c2015ed2;hb=067f77e22bace6d17204e3f1f677dd6a5ca6f563;hp=4ad7260b49abef09e303cfabd32437671153d4ff;hpb=d7f2452e20b04d1559b7bdd3aa49b6fbf7d0abaf;p=odcread.git diff --git a/Makefile b/Makefile index 4ad7260..260da91 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,34 @@ -HEADERS=oberon.h store.h reader.h domain.h alien.h typeregister.h textmodel.h fold.h visitor.h +MODULES := reader store alien typeregister textmodel fold typepath -odcread: odcread.o reader.o store.o util.o alien.o typeregister.o textmodel.o fold.o +# Add module directories to the include path +CFLAGS += -I. + +# Variables for the modules to write to +SRCS := odcread.cc + +# Include module definitions +include $(patsubst %,%/Make.inc,$(MODULES)) + +# This rule just links the object files together +odcread: $(SRCS:.cc=.o) g++ -o $@ $^ -%.o: %.cc $(HEADERS) - g++ -c -I. -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++ $(CFLAGS) $< -MM -MF $*.d -MP -MT $@ + g++ $(CFLAGS) $< -c -o $@ + +clean: + rm -f odcread *.d *.o */*.o */*.d + +# Include the generated dependency files (if they exist) +-include $(SRCS:.cc=.d)