diff options
Diffstat (limited to 'makefile')
-rw-r--r-- | makefile | 58 |
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 |
6 | TEXTs := $(wildcard *.txt) | 6 | TEXTs := $(wildcard *.txt) |
7 | 7 | ||
8 | VERSIFY = trunk/versify.exe | 8 | VERSIFYer = trunk/versify.exe |
9 | 9 | ||
10 | HTMLbl := index.html template.html index-txt.html | 10 | HTMLbl := index.html template.html index-txt.html |
11 | HTMLs := $(filter-out $(HTMLbl),$(patsubst %.txt,%.html,$(TEXTs))) | 11 | HTMLs := $(filter-out $(HTMLbl),$(patsubst %.txt,%.html,$(TEXTs))) |
12 | HTMopts = --template=template.html | 12 | HTMopts = --template=template.html |
13 | HTMopts+= --filter=$(VERSIFY) | 13 | HTMopts+= --filter=$(VERSIFYer) |
14 | HTMopts+= --smart --mathml --section-divs | 14 | HTMopts+= --smart --mathml --section-divs |
15 | 15 | ||
16 | HAPAXbl:= first-lines.river common-titles.river hapax.river | 16 | BKTXTbl = "hapax.txt|first-lines.txt|common-titles.txt" |
17 | BKTXTs = $(patsubst %.html,%.back,$(HTMLs)) | ||
18 | BKTXThd = trunk/backlink.head | ||
19 | BKHTMLs = $(patsubst %.back,%_backlinks.htm,$(BKTXTs)) | ||
20 | |||
21 | RIVERbl:= first-lines.river common-titles.river hapax.river | ||
17 | RIVERer = trunk/river.lua | 22 | RIVERer = trunk/river.lua |
18 | RIVERs := $(filter-out $(HAPAXbl),$(patsubst %.txt,%.river,$(TEXTs))) | 23 | RIVERs := $(filter-out $(RIVERbl),$(patsubst %.txt,%.river,$(TEXTs))) |
19 | 24 | ||
20 | HAPAXs := $(filter-out $(HAPAXbl),$(RIVERs)) | 25 | HAPAXs := $(RIVERs) |
21 | HAPAXer = trunk/hapax.lua | 26 | HAPAXer = trunk/hapax.lua |
22 | HAPAXhd:= trunk/hapax.head | 27 | HAPAXhd:= trunk/hapax.head |
23 | HAPAXtmp= hapax.tmp | 28 | HAPAXtmp= hapax.tmp |
@@ -26,29 +31,50 @@ HAPAX = hapax.txt | |||
26 | LOZENGE = trunk/lozenge.js | 31 | LOZENGE = trunk/lozenge.js |
27 | 32 | ||
28 | .PHONY: all | 33 | .PHONY: all |
29 | all : hapax html river lozenge | 34 | all : river hapax $(VERSIFYer) html lozenge backlinks |
30 | 35 | ||
31 | .PHONY: hapax | 36 | .PHONY: hapax |
32 | hapax : $(HAPAX) | 37 | hapax : $(HAPAX) |
33 | .PHONY: html | 38 | .PHONY: html |
34 | html : $(HTMLs) | 39 | html : $(HTMLs) |
35 | .PHONY: river | 40 | .PHONY: river |
36 | river : $(RIVERs) | 41 | river : $(RIVERs) |
37 | .PHONY: lozenge | 42 | .PHONY: lozenge |
38 | lozenge : $(LOZENGE) | 43 | lozenge : $(LOZENGE) |
44 | .PHONY: backlinks | ||
45 | backlinks : $(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 |
77 | clean: | 103 | clean: |
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 |
82 | again: clean all | 110 | again: clean all |