summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2014-02-16 06:47:22 +0100
committerJonas Smedegaard <dr@jones.dk>2014-02-16 06:47:22 +0100
commita2fa4571850f4e9e927801df6b5a16f361b92c97 (patch)
treee27475aa7ca07a7b1626ab479992d1afb63af2e1 /Makefile
parent38cf88d361976fe9cb985713a943ef5db05ad337 (diff)
Add Makefile.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile24
1 files changed, 24 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..d68e709
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,24 @@
+infiles := $(wildcard data/*.ttl data/*/*.ttl)
+turtlefiles := $(infiles:data/%.ttl=build/%/index.ttl)
+textfiles = $(turtlefiles:%.ttl=%.txt)
+rdfxmlfiles = $(turtlefiles:%.ttl=%.rdf)
+
+getbase = $(shell perl -ne '/^\@base\s+<(http.+)>/ and print $$1 and exit;' "$1")
+
+all: $(textfiles) $(rdfxmlfiles)
+
+clean:
+ rm -rf build
+
+$(turtlefiles): build/%/index.ttl : data/%.ttl
+ mkdir -p $(dir $@)
+ $(eval base = $(call getbase, $<))
+ rapper $(base:%=-I "%") -i turtle -o turtle "$<" > "$@"
+ perl -i -pe 's/ {4}/\t/g' "$@"
+
+$(textfiles): %.txt : %.ttl
+ ln -s $(notdir $<) $@
+
+$(rdfxmlfiles): %.rdf : %.ttl
+ $(eval base = $(call getbase, $<))
+ rapper $(base:%=-I "%") -i turtle -o rdfxml-abbrev "$<" > "$@"