summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 123f20a)
raw | patch | inline | side by side (parent: 123f20a)
author | Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl> | |
Tue, 15 Nov 2011 13:12:11 +0000 (13:12 +0000) | ||
committer | Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl> | |
Tue, 15 Nov 2011 13:22:01 +0000 (13:22 +0000) |
Makefile | patch | blob | history |
diff --git a/Makefile b/Makefile
index f54dabe5b55adae8d8c82dc3392a3327dca4c0c4..441faf9a7e82cf364d1f069d029307221b7bbdba 100644 (file)
--- a/Makefile
+++ b/Makefile
-HEADERS=oberon.h store.h reader.h alien.h typeregister.h textmodel.h fold.h visitor.h
+# List all source files to be compiled
+SRCS=odcread.cc reader.cc store.cc util.cc alien.cc typeregister.cc \
+ textmodel.cc fold.cc
-odcread: odcread.o reader.o store.o util.o alien.o typeregister.o textmodel.o fold.o
+# 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++ -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)