about summary refs log tree commit diff stats
path: root/makefile
diff options
context:
space:
mode:
authorCase Duckworth2015-04-01 23:16:18 -0700
committerCase Duckworth2015-04-01 23:20:18 -0700
commitd161be120c22faf222ec15ca618ee367e4d56575 (patch)
treeb945633e680e5682a967f63bad88a2b262b4d4c6 /makefile
parentMerge branch 'gh-pages' of https://github.com/duckwork/autocento into gh-pages (diff)
downloadautocento-d161be120c22faf222ec15ca618ee367e4d56575.tar.gz
autocento-d161be120c22faf222ec15ca618ee367e4d56575.zip
Refactor makefile; Add hapax preprocessor
Diffstat (limited to 'makefile')
-rw-r--r--makefile189
1 files changed, 87 insertions, 102 deletions
diff --git a/makefile b/makefile index 56b4f6a..4808e11 100644 --- a/makefile +++ b/makefile
@@ -1,110 +1,95 @@
1# Produce HTML & RIVER outputs with pandoc 1# MAKEFILE for Autocento of the breakfast table
2# Case Duckworth | autocento.me 2# by Case Duckworth | case.duckworth@gmail.com | autocento.me
3# inspired by Lincoln Mullen | lincolnmullen.com 3# inspired by Lincoln Mullen | lincolnmullen.com
4 4# vim: fdm=marker
5# Define directories, file lists, and options 5
6TEXTs := $(wildcard *.txt) 6# Define variables {{{
7 7srcs := $(wildcard *.txt)
8VERSIFYer = trunk/versify.exe 8templates := $(wildcard _template.*)
9 9trunk := trunk
10HTMLbl := index.html template.html index-txt.html 10metas = hapax first-lines common-titles index
11HTMLs := $(filter-out $(HTMLbl),$(patsubst %.txt,%.html,$(TEXTs))) 11metas += $(templates)
12HTMopts = --template=template.html 12
13HTMopts+= --filter=$(VERSIFYer) 13htmls = $(filter-out \
14HTMopts+= --smart --mathml --section-divs 14 $(patsubst %,%.html,$(metas)),\
15 15 $(patsubst %.txt,%.html,$(srcs)))
16BKTXTbl = "hapax.txt|first-lines.txt|common-titles.txt" 16htmlPre = $(trunk)/versify.exe
17BKTXTs = $(patsubst %.html,%.back,$(HTMLs)) 17htmlPreSrc = $(trunk)/versify.hs
18BKTXThd = trunk/backlink.head 18htmlTemplate = _template.html
19BKHTMLs = $(patsubst %.back,%_backlinks.htm,$(BKTXTs)) 19htmlPandocOptions = --template=$(htmlTemplate)
20 20htmlPandocOptions+= --filter=$(htmlPre)
21RIVERbl:= first-lines.river common-titles.river hapax.river 21htmlPandocOptions+= --smart --mathml --section-divs
22RIVERer = trunk/river.lua 22
23RIVERs := $(filter-out $(RIVERbl),$(patsubst %.txt,%.river,$(TEXTs))) 23lozenger = $(trunk)/lozenge.sh
24 24lozengeOut = $(trunk)/lozenge.js
25HAPAXs := $(RIVERs) 25
26HAPAXer = trunk/hapax.lua 26hapaxs = $(filter-out \
27HAPAXhd:= trunk/hapax.head 27 $(patsubst %,%.hapax,$(metas)),\
28HAPAXtmp= hapax.tmp 28 $(patsubst %.txt,%.hapax,$(srcs)))
29HAPAX = hapax.txt 29hapaxer = $(trunk)/hapax.lua
30 30hapaxPre = $(trunk)/forceascii.exe
31LOZENGE = trunk/lozenge.js 31hapaxPreSrc = $(trunk)/forceascii.hs
32hapaxPandocOptions = --filter=$(hapaxPre)
33hapaxOut = hapax.txt
34hapaxHead = $(trunk)/hapax.head
35hapaxLinker = $(trunk)/hapaxlink.sh
36
37backTxts = $(patsubst %.html,%.back,$(htmls))
38backHtms = $(patsubst %.back,%_backlinks.htm,$(backTxts))
39backHead = $(trunk)/backlink.head
40backlinker = $(trunk)/backlink.sh
41backPandocOptions = --template=$(htmlTemplate) --smart
42# }}}
32 43
33.PHONY: all 44.PHONY: all
34all : river hapax $(VERSIFYer) html lozenge backlinks 45all: $(hapaxOut)\
35 46 $(htmlPre) $(htmls) $(lozengeOut)\
36.PHONY: hapax 47 $(backTxts) $(backHtms)
37hapax : $(HAPAX) 48
38.PHONY: html 49# HTML {{{
39html : $(HTMLs) 50$(htmlPre): $(htmlPreSrc)
40.PHONY: river 51 ghc --make $(htmlPreSrc)
41river : $(RIVERs) 52
42.PHONY: lozenge 53%.html: %.txt | $(htmlTemplate) $(htmlPre)
43lozenge : $(LOZENGE) 54 pandoc $< -t html5 $(htmlPandocOptions) -o $@
44.PHONY: backlinks 55
45backlinks : $(BKHTMLs) 56$(lozengeOut): $(htmls)
46 57 @bash $(lozenger) $(lozengeOut) $(htmls)
47%.html : %.txt template.html $(VERSIFYer) 58# }}}
48 pandoc $< -f markdown -t html5 $(HTMopts) -o $@ 59# BACKLINKS {{{
49 60%.back: %.html | $(backHead)
50%_backlinks.htm : %.back 61 @bash $(backlinker) $< $@ $(backHead) $(htmls)
51 pandoc $< -f markdown -t html5 $(HTMopts) -o $@ 62
52 63%_backlinks.htm: %.back | $(htmlTemplate)
53%.back : %.txt $(BKTXThd) 64 pandoc $< -t html5 $(backPandocOptions) -o $@ && rm $<
54 @echo -n "Back-linking $<" 65# }}}
55 @cat $(BKTXThd) > $@ 66# HAPAX {{{
56 -@grep -ql "$(patsubst %.txt,%.html,$<)" *.txt |\ 67$(hapaxPre): $(hapaxPreSrc)
57 grep -vE $(BKTXTbl) >> $@ || \ 68 ghc --make $(hapaxPreSrc)
58 echo "_Nothing links here!_" >> $@; 69
59 @echo -n "." 70%.hapax: %.txt | $(hapaxPre)
60 @title=`grep '^title:' $< | cut -d' ' -f2-`; \ 71 pandoc $< -t $(hapaxer) $(hapaxPandocOptions) -o $@
61 sed -i "s/_TITLE_/$$title/" $@; 72
62 @echo -n "." 73$(hapaxOut): $(hapaxs) | $(hapaxPre) $(hapaxLinker) $(hapaxHead)
63 @for file in `cat $@ | grep '.txt'`; do \ 74 pandoc $^ -t $(hapaxer) -o $(hapaxOut)
64 title=`grep '^title:' $$file | cut -d' ' -f2-`; \ 75 @bash $(hapaxLinker) $@ $(hapaxHead) $^
65 replace=`basename $$file .txt`; \ 76 -rm *.hapax
66 sed -i "s/^\($$replace\).txt$$/- [$$title](\1.html)/" $@;\ 77# }}}
67 echo -n "."; \ 78# FIRST LINES & COMMON TITLES {{{
68 done 79# TODO
69 @echo "Done." 80# }}}
70 81# CLEAN {{{
71%.river : %.txt
72 @echo River-ing $@
73 @sed -e '/^---$$/,/^...$$/d'\
74 -e "s/[^][A-Za-z0-9\/\"':.-]/ /g" $< |\
75 pandoc - -f markdown -t $(RIVERer) -o $@
76
77$(VERSIFYer) : trunk/versify.hs
78 ghc --make trunk/versify.hs
79
80$(LOZENGE) : $(HTMLs)
81 @echo "Updating lozenge.js..."
82 @list=`echo $(HTMLs) |\
83 sed -e 's/\(\S\+.html\) \?/"\1",/g'\
84 -e 's/^\(.*\),$$/var files=[\1]/'` &&\
85 sed -i "s/var files=.*/$$list/" $(LOZENGE)
86
87$(HAPAX) : $(RIVERs) $(HAPAXhd)
88 -rm -f $(HAPAXbl)
89 @echo "Compiling $(HAPAX)..."
90 pandoc -f markdown -t $(HAPAXer) -o $(HAPAX) *.river
91 @echo -n "Linking $(HAPAX)"
92 @cat $(HAPAXhd) > $(HAPAXtmp) &&\
93 for word in `sort hapax.txt`; do\
94 file=`grep -liwq "^$$word$$" *.river | grep -v '$(HAPAX)'`;\
95 echo "[$$word](`basename $$file river`html)">>$(HAPAXtmp);\
96 echo -n '.';\
97 done && mv $(HAPAXtmp) $(HAPAX)
98 @echo "Done."
99
100# TODO: Add indices compilers (first-lines, common-titles)
101
102.PHONY: clean 82.PHONY: clean
103clean: 83clean:
104 -rm -f hapax.txt hapax.tmp 84 -rm -f $(hapaxs) $(hapaxOut)
105 -rm -f $(RIVERs) 85 -rm -f $(htmls)
106 -rm -f $(HTMLs) 86 -rm -f $(backHtms)
107 -rm -f $(BKTXTs) $(BKHTMLs) 87 -rm -f *.tmp trunk/*.tmp
88
89.PHONY: nuke
90nuke: clean
91 -rm -f $(hapaxPre) $(htmlPre)
108 92
109.PHONY: again 93.PHONY: again
110again: clean all 94again: clean all
95# }}}