diff options
Diffstat (limited to 'makefile')
-rw-r--r-- | makefile | 73 |
1 files changed, 54 insertions, 19 deletions
diff --git a/makefile b/makefile index 34eda34..be0806a 100644 --- a/makefile +++ b/makefile | |||
@@ -3,19 +3,35 @@ | |||
3 | # inspired by Lincoln Mullen | lincolnmullen.com | 3 | # inspired by Lincoln Mullen | lincolnmullen.com |
4 | 4 | ||
5 | # Define directories, file lists, and options | 5 | # Define directories, file lists, and options |
6 | HTMLs := $(patsubst %.txt,%.html,$(wildcard *.txt)) | 6 | TEXTs := $(wildcard *.txt) |
7 | HTMopts = --template=.template.html | 7 | |
8 | HTMLbl := index.html template.html index-txt.html | ||
9 | HTMLs := $(filter-out $(HTMLbl),$(patsubst %.txt,%.html,$(TEXTs))) | ||
10 | HTMopts = --template=template.html | ||
8 | HTMopts+= --smart --mathml --section-divs | 11 | HTMopts+= --smart --mathml --section-divs |
9 | RIVERer = lua/river.lua | 12 | |
10 | RIVERs := $(patsubst %.txt,%.river,$(wildcard *.txt)) | 13 | HAPAXbl:= first-lines.river common-titles.river hapax.river |
11 | RIVopts = | 14 | RIVERer = trunk/river.lua |
12 | LOZENGE = js/lozenge.js | 15 | RIVERs := $(filter-out $(HAPAXbl),$(patsubst %.txt,%.river,$(TEXTs))) |
13 | 16 | ||
14 | # Do everything | 17 | HAPAXs := $(filter-out $(HAPAXbl),$(RIVERs)) |
15 | .PHONY: all html river lozenge | 18 | HAPAXer = trunk/hapax.lua |
16 | all : html river lozenge | 19 | HAPAXhd = trunk/hapax.head |
20 | HAPAXtmp= hapax.tmp | ||
21 | HAPAX = hapax.txt | ||
22 | |||
23 | LOZENGE = trunk/lozenge.js | ||
24 | |||
25 | .PHONY: all | ||
26 | all : hapax html river lozenge | ||
27 | |||
28 | .PHONY: hapax | ||
29 | hapax : $(HAPAX) | ||
30 | .PHONY: html | ||
17 | html : $(HTMLs) | 31 | html : $(HTMLs) |
32 | .PHONY: river | ||
18 | river : $(RIVERs) | 33 | river : $(RIVERs) |
34 | .PHONY: lozenge | ||
19 | lozenge : $(LOZENGE) | 35 | lozenge : $(LOZENGE) |
20 | 36 | ||
21 | # Generic rule for HTML targets and Markdown sources | 37 | # Generic rule for HTML targets and Markdown sources |
@@ -27,15 +43,34 @@ lozenge : $(LOZENGE) | |||
27 | @echo River-ing $@ | 43 | @echo River-ing $@ |
28 | @sed -e '/^---$$/,/^...$$/d'\ | 44 | @sed -e '/^---$$/,/^...$$/d'\ |
29 | -e "s/[^][A-Za-z0-9\/\"':.-]/ /g" $< |\ | 45 | -e "s/[^][A-Za-z0-9\/\"':.-]/ /g" $< |\ |
30 | pandoc - -f markdown -t $(RIVERer) $(RIVopts) -o $@ | 46 | pandoc - -f markdown -t $(RIVERer) -o $@ |
31 | 47 | ||
32 | $(LOZENGE) : $(HTMLs) | 48 | $(LOZENGE) : $(HTMLs) |
33 | @echo "Updating lozenge.js..." | 49 | @echo "Updating lozenge.js..." |
34 | @list=`ls *.html |\ | 50 | @list=`echo $(HTMLs) |\ |
35 | sed -e 's,../,,g' |\ | 51 | sed -e 's/\(\S\+.html\) \?/"\1",/g'\ |
36 | tr '\n' ' ' |\ | 52 | -e 's/^\(.*\),$$/var files=[\1]/'` &&\ |
37 | sed -e 's/\(\S\+.html\) /"\1",/g'\ | 53 | sed -i "s/var files=.*/$$list/" $(LOZENGE) |
38 | -e 's/^\(.*\),$$/var files=[\1]/'` &&\ | 54 | |
39 | sed -i "s/var files=.*/$$list/" $(LOZENGE) | 55 | $(HAPAX) : $(RIVERs) $(HAPAXhd) |
40 | # TODO: add compiling hapax | 56 | -rm -f $(HAPAXbl) |
41 | # TODO: add first line compiler | 57 | @echo "Compiling $(HAPAX)..." |
58 | pandoc -f markdown -t $(HAPAXer) -o $(HAPAX) *.river | ||
59 | @echo -n "Linking $(HAPAX)..." | ||
60 | @cat $(HAPAXhd) > $(HAPAXtmp) &&\ | ||
61 | for word in `sort hapax.txt`; do\ | ||
62 | file=`grep -liwq "^$$word$$" *.river | grep -v '$(HAPAX)'`;\ | ||
63 | echo "[$$word](`basename $$file river`html)">>$(HAPAXtmp);\ | ||
64 | echo -n '.';\ | ||
65 | done && mv $(HAPAXtmp) $(HAPAX) | ||
66 | @echo "Done." | ||
67 | |||
68 | # TODO: Add indices compilers (first-lines, common-titles) | ||
69 | |||
70 | .PHONY: clean | ||
71 | clean: | ||
72 | -rm -f hapax.txt hapax.tmp *.river | ||
73 | -rm -f $(HTMLs) | ||
74 | |||
75 | .PHONY: again | ||
76 | again: clean all | ||