summary refs log tree commit diff stats
path: root/makefile
diff options
context:
space:
mode:
authorCase Duckworth2015-03-28 09:42:01 -0700
committerCase Duckworth2015-03-28 09:42:01 -0700
commitfb8cc7d92a20610776d9f6e0453d09cebed0bc3a (patch)
treed47d5ccc7bf1e9d44e2405b6a2c8a6f9d85bd8f2 /makefile
parentFix #5: Verse typesetting (diff)
downloadautocento-fb8cc7d92a20610776d9f6e0453d09cebed0bc3a.tar.gz
autocento-fb8cc7d92a20610776d9f6e0453d09cebed0bc3a.zip
Add backlinks pages (fixes #16).
Diffstat (limited to 'makefile')
-rw-r--r--makefile58
1 files changed, 43 insertions, 15 deletions
diff --git a/makefile b/makefile index 26b067f..56b4f6a 100644 --- a/makefile +++ b/makefile
@@ -5,19 +5,24 @@
5# Define directories, file lists, and options 5# Define directories, file lists, and options
6TEXTs := $(wildcard *.txt) 6TEXTs := $(wildcard *.txt)
7 7
8VERSIFY = trunk/versify.exe 8VERSIFYer = trunk/versify.exe
9 9
10HTMLbl := index.html template.html index-txt.html 10HTMLbl := index.html template.html index-txt.html
11HTMLs := $(filter-out $(HTMLbl),$(patsubst %.txt,%.html,$(TEXTs))) 11HTMLs := $(filter-out $(HTMLbl),$(patsubst %.txt,%.html,$(TEXTs)))
12HTMopts = --template=template.html 12HTMopts = --template=template.html
13HTMopts+= --filter=$(VERSIFY) 13HTMopts+= --filter=$(VERSIFYer)
14HTMopts+= --smart --mathml --section-divs 14HTMopts+= --smart --mathml --section-divs
15 15
16HAPAXbl:= first-lines.river common-titles.river hapax.river 16BKTXTbl = "hapax.txt|first-lines.txt|common-titles.txt"
17BKTXTs = $(patsubst %.html,%.back,$(HTMLs))
18BKTXThd = trunk/backlink.head
19BKHTMLs = $(patsubst %.back,%_backlinks.htm,$(BKTXTs))
20
21RIVERbl:= first-lines.river common-titles.river hapax.river
17RIVERer = trunk/river.lua 22RIVERer = trunk/river.lua
18RIVERs := $(filter-out $(HAPAXbl),$(patsubst %.txt,%.river,$(TEXTs))) 23RIVERs := $(filter-out $(RIVERbl),$(patsubst %.txt,%.river,$(TEXTs)))
19 24
20HAPAXs := $(filter-out $(HAPAXbl),$(RIVERs)) 25HAPAXs := $(RIVERs)
21HAPAXer = trunk/hapax.lua 26HAPAXer = trunk/hapax.lua
22HAPAXhd:= trunk/hapax.head 27HAPAXhd:= trunk/hapax.head
23HAPAXtmp= hapax.tmp 28HAPAXtmp= hapax.tmp
@@ -26,29 +31,50 @@ HAPAX = hapax.txt
26LOZENGE = trunk/lozenge.js 31LOZENGE = trunk/lozenge.js
27 32
28.PHONY: all 33.PHONY: all
29all : hapax html river lozenge 34all : river hapax $(VERSIFYer) html lozenge backlinks
30 35
31.PHONY: hapax 36.PHONY: hapax
32hapax : $(HAPAX) 37hapax : $(HAPAX)
33.PHONY: html 38.PHONY: html
34html : $(HTMLs) 39html : $(HTMLs)
35.PHONY: river 40.PHONY: river
36river : $(RIVERs) 41river : $(RIVERs)
37.PHONY: lozenge 42.PHONY: lozenge
38lozenge : $(LOZENGE) 43lozenge : $(LOZENGE)
44.PHONY: backlinks
45backlinks : $(BKHTMLs)
46
47%.html : %.txt template.html $(VERSIFYer)
48 pandoc $< -f markdown -t html5 $(HTMopts) -o $@
39 49
40# Generic rule for HTML targets and Markdown sources 50%_backlinks.htm : %.back
41%.html : %.txt template.html $(VERSIFY)
42 pandoc $< -f markdown -t html5 $(HTMopts) -o $@ 51 pandoc $< -f markdown -t html5 $(HTMopts) -o $@
43 52
44# Generic rule for RIVER targets and Markdown sources 53%.back : %.txt $(BKTXThd)
54 @echo -n "Back-linking $<"
55 @cat $(BKTXThd) > $@
56 -@grep -ql "$(patsubst %.txt,%.html,$<)" *.txt |\
57 grep -vE $(BKTXTbl) >> $@ || \
58 echo "_Nothing links here!_" >> $@;
59 @echo -n "."
60 @title=`grep '^title:' $< | cut -d' ' -f2-`; \
61 sed -i "s/_TITLE_/$$title/" $@;
62 @echo -n "."
63 @for file in `cat $@ | grep '.txt'`; do \
64 title=`grep '^title:' $$file | cut -d' ' -f2-`; \
65 replace=`basename $$file .txt`; \
66 sed -i "s/^\($$replace\).txt$$/- [$$title](\1.html)/" $@;\
67 echo -n "."; \
68 done
69 @echo "Done."
70
45%.river : %.txt 71%.river : %.txt
46 @echo River-ing $@ 72 @echo River-ing $@
47 @sed -e '/^---$$/,/^...$$/d'\ 73 @sed -e '/^---$$/,/^...$$/d'\
48 -e "s/[^][A-Za-z0-9\/\"':.-]/ /g" $< |\ 74 -e "s/[^][A-Za-z0-9\/\"':.-]/ /g" $< |\
49 pandoc - -f markdown -t $(RIVERer) -o $@ 75 pandoc - -f markdown -t $(RIVERer) -o $@
50 76
51$(VERSIFY) : trunk/versify.hs 77$(VERSIFYer) : trunk/versify.hs
52 ghc --make trunk/versify.hs 78 ghc --make trunk/versify.hs
53 79
54$(LOZENGE) : $(HTMLs) 80$(LOZENGE) : $(HTMLs)
@@ -62,7 +88,7 @@ $(HAPAX) : $(RIVERs) $(HAPAXhd)
62 -rm -f $(HAPAXbl) 88 -rm -f $(HAPAXbl)
63 @echo "Compiling $(HAPAX)..." 89 @echo "Compiling $(HAPAX)..."
64 pandoc -f markdown -t $(HAPAXer) -o $(HAPAX) *.river 90 pandoc -f markdown -t $(HAPAXer) -o $(HAPAX) *.river
65 @echo -n "Linking $(HAPAX)..." 91 @echo -n "Linking $(HAPAX)"
66 @cat $(HAPAXhd) > $(HAPAXtmp) &&\ 92 @cat $(HAPAXhd) > $(HAPAXtmp) &&\
67 for word in `sort hapax.txt`; do\ 93 for word in `sort hapax.txt`; do\
68 file=`grep -liwq "^$$word$$" *.river | grep -v '$(HAPAX)'`;\ 94 file=`grep -liwq "^$$word$$" *.river | grep -v '$(HAPAX)'`;\
@@ -75,8 +101,10 @@ $(HAPAX) : $(RIVERs) $(HAPAXhd)
75 101
76.PHONY: clean 102.PHONY: clean
77clean: 103clean:
78 -rm -f hapax.txt hapax.tmp *.river 104 -rm -f hapax.txt hapax.tmp
105 -rm -f $(RIVERs)
79 -rm -f $(HTMLs) 106 -rm -f $(HTMLs)
107 -rm -f $(BKTXTs) $(BKHTMLs)
80 108
81.PHONY: again 109.PHONY: again
82again: clean all 110again: clean all