X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=Makefile;h=656105b1c1de1d9709988bf77591889dabe78111;hb=0c3c99510dbda9c562787b5d08f69b68a969f561;hp=e03bf66b81765e6def5abb7a416c956c6c589aa5;hpb=4618e826a4ebe5e60e1d2c419fca7da71657bf9b;p=odcread.git diff --git a/Makefile b/Makefile index e03bf66..656105b 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,45 @@ -HEADERS=oberon.h store.h reader.h domain.h +# Modules, each containing: +# * $(MODULE)/Make.inc -- makefile include +# * $(MODULE)/$(MODULE).h -- minimal "interface" header file +# * $(MODULE)/$(MODULE).ih -- internal/implementation header file +# (only to be included by sources within the module) +# * $(MODULE)/*.cc -- module source files +MODULES := reader store alien typeregister textmodel fold typepath -odcread: odcread.o reader.o store.o util.o +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) + + +# TODO: +# Each module has a .ih file that should be *the only* include from the .cc +# files. These .ih files should be pre-compiled, and dependency caching should +# be based on the .ih files, not the .cc files.