summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0c3c995)
raw | patch | inline | side by side (parent: 0c3c995)
author | Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl> | |
Tue, 15 Nov 2011 19:39:55 +0000 (19:39 +0000) | ||
committer | Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl> | |
Tue, 15 Nov 2011 20:26:07 +0000 (20:26 +0000) |
13 files changed:
Makefile | patch | blob | history | |
fold/fold.cc | patch | blob | history | |
fold/fold.ih | [new file with mode: 0644] | patch | blob |
main/Make.inc | [new file with mode: 0644] | patch | blob |
main/main.ih | [new file with mode: 0644] | patch | blob |
main/odcread.cc | [moved from odcread.cc with 90% similarity] | patch | blob | history |
reader/Make.inc | patch | blob | history | |
store/store.cc | patch | blob | history | |
store/store.ih | [new file with mode: 0644] | patch | blob |
textmodel/textmodel.cc | patch | blob | history | |
textmodel/textmodel.ih | [new file with mode: 0644] | patch | blob |
typeregister/typeregister.cc | patch | blob | history | |
typeregister/typeregister.ih | [new file with mode: 0644] | patch | blob |
diff --git a/Makefile b/Makefile
index 656105b1c1de1d9709988bf77591889dabe78111..415e3250cebaf0cde6ad7c7995e9f02e2ba2c42a 100644 (file)
--- a/Makefile
+++ b/Makefile
# * $(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
+MODULES := main reader store alien typeregister textmodel fold typepath
-CFLAGS += -I.
+CFLAGS := -I.
# Variables for the modules to write to
-SRCS := odcread.cc
+SRCS :=
# Include module definitions
include $(patsubst %,%/Make.inc,$(MODULES))
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.
+%.o: %.cc
+ g++ $(CFLAGS) $< -c -o $@
+
+# For each implementation header (.ih) generate a dependency (.d) file which
+# will ensure that the compiled header (.ih.gch) is rebuilt whenever the header
+# files included by the .ih 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 $@
+# if and only if the .ih.gch needs to be rebuilt.
+%.ih.gch: %.ih
+ g++ $(CFLAGS) -x c++-header $< -MM -MF $(dir $@)module.d -MP -MT $@
+ g++ $(CFLAGS) -x c++-header $< -o $@
+
+# This rule build an object (.o) from a source (.cc).
+# Each module has a .ih file that should be *the only* include from the .cc
+# files. These .ih files are pre-compiled to .ih.gch, and dependency caching
+# is based on the .ih files, not the .cc files.
+define depend_on_compiled_header
+$(patsubst %.cc,%.o,$(1)) : $(dir $(1))$(patsubst %/,%,$(dir $(1))).ih.gch
+endef
+$(foreach src,$(SRCS),$(eval $(call depend_on_compiled_header,$(src))))
clean:
- rm -f odcread *.d *.o */*.o */*.d
+ rm -f odcread *.o */*.o */*.d */*.ih.gch
# Include the generated dependency files (if they exist)
--include $(SRCS:.cc=.d)
+-include $(patsubst %,%/module.d,$(MODULES))
-
-# 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.
+# TODO: rename all %/%.ih files to %/module.ih for simplicity of matching rules
diff --git a/fold/fold.cc b/fold/fold.cc
index 7fdf01b6d66d0bfe53a833325576abd0aada23d2..94ed5878f6f00a1831f2f3b671f3285118ac925d 100644 (file)
--- a/fold/fold.cc
+++ b/fold/fold.cc
-#include "fold/fold.h"
-#include "reader/reader.h"
+#include "fold/fold.ih"
namespace odc {
diff --git a/fold/fold.ih b/fold/fold.ih
--- /dev/null
+++ b/fold/fold.ih
@@ -0,0 +1,2 @@
+#include "fold/fold.h"
+#include "reader/reader.h"
diff --git a/main/Make.inc b/main/Make.inc
--- /dev/null
+++ b/main/Make.inc
@@ -0,0 +1 @@
+SRCS += main/odcread.cc
diff --git a/main/main.ih b/main/main.ih
--- /dev/null
+++ b/main/main.ih
@@ -0,0 +1,18 @@
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <stack>
+
+#include "oberon.h"
+#include "reader/reader.h"
+#include "store/store.h"
+#include "textmodel/textmodel.h"
+#include "visitor/visitor.h"
+
+// Character encoding conversions
+#include <langinfo.h> // determine the current charset
+#include <locale.h> // locale support
+#include <iconv.h> // charset conversions
+#include <errno.h> // error codes
+#include <string.h> // string descriptions of error codes
+
diff --git a/odcread.cc b/main/odcread.cc
similarity index 90%
rename from odcread.cc
rename to main/odcread.cc
index a509ab6bc7a72468e72243815aaf794a47057240..075671fadc1c9dddb39c74cc1b81c64f9d8639ed 100644 (file)
rename from odcread.cc
rename to main/odcread.cc
index a509ab6bc7a72468e72243815aaf794a47057240..075671fadc1c9dddb39c74cc1b81c64f9d8639ed 100644 (file)
--- a/odcread.cc
+++ b/main/odcread.cc
-#include <iostream>
-#include <fstream>
-#include <string>
-#include <stack>
-
-#include "oberon.h"
-#include "reader/reader.h"
-#include "store/store.h"
-#include "textmodel/textmodel.h"
-#include "visitor/visitor.h"
-
-// Character encoding conversions
-#include <langinfo.h> // determine the current charset
-#include <locale.h> // locale support
-#include <iconv.h> // charset conversions
-#include <errno.h> // error codes
-#include <string.h> // string descriptions of error codes
+#include "main/main.ih"
namespace odc {
class Context {
diff --git a/reader/Make.inc b/reader/Make.inc
index 6f5e81a97d9327feabe88724a99cf777d276c321..c61b0f06af8193b8724e5e1d6b51a36b8c14ed52 100644 (file)
--- a/reader/Make.inc
+++ b/reader/Make.inc
-READER_SRC := addPathComponent.cc fixTypeName.cc readAlien.cc reader.cc \
- readLinkStore.cc readNewLinkStore.cc readNilStore.cc readPath.cc \
- readStore.cc readStoreOrElemStore.cc readVersion.cc util.cc
-SRCS += $(patsubst %,reader/%,$(READER_SRC))
+SRCS += $(wildcard reader/*.cc)
diff --git a/store/store.cc b/store/store.cc
index 76f0586f3fcf6d714114366bfdd4c80bec024d4f..a967518550e594006e06d24ded0ebbe16157605c 100644 (file)
--- a/store/store.cc
+++ b/store/store.cc
-#include "store/store.h"
-#include "reader/reader.h"
-#include "visitor/visitor.h"
-
-#include <iostream>
+#include "store/store.ih"
namespace odc {
diff --git a/store/store.ih b/store/store.ih
--- /dev/null
+++ b/store/store.ih
@@ -0,0 +1,5 @@
+#include "store/store.h"
+#include "reader/reader.h"
+#include "visitor/visitor.h"
+
+#include <iostream>
diff --git a/textmodel/textmodel.cc b/textmodel/textmodel.cc
index 720654a1492e4def31ba5da0b330a8e689ed7ca3..aa2819304f10de7203ad066ac47d8983100f85ac 100644 (file)
--- a/textmodel/textmodel.cc
+++ b/textmodel/textmodel.cc
-#include "textmodel/textmodel.h"
-#include "reader/reader.h"
-
-#include <vector>
-#include <assert.h>
+#include "textmodel/textmodel.ih"
namespace odc {
diff --git a/textmodel/textmodel.ih b/textmodel/textmodel.ih
--- /dev/null
+++ b/textmodel/textmodel.ih
@@ -0,0 +1,5 @@
+#include "textmodel/textmodel.h"
+#include "reader/reader.h"
+
+#include <vector>
+#include <assert.h>
index 91120c6b6c504f116207aebab59cce3a4d5d543a..0093b9a0618b929c9f887cc5cbbdaab7965f1742 100644 (file)
-#include "typeregister/typeregister.h"
-
-#include <iostream>
+#include "typeregister/typeregister.ih"
namespace odc {
diff --git a/typeregister/typeregister.ih b/typeregister/typeregister.ih
--- /dev/null
@@ -0,0 +1,3 @@
+#include "typeregister/typeregister.h"
+
+#include <iostream>