diff options
Diffstat (limited to 'makefile')
-rw-r--r-- | makefile | 267 |
1 files changed, 137 insertions, 130 deletions
diff --git a/makefile b/makefile index 1c1bc7a..5ba127c 100644 --- a/makefile +++ b/makefile | |||
@@ -1,142 +1,149 @@ | |||
1 | # MAKEFILE for Autocento of the breakfast table | 1 | # Makefile for Autocento of the breakfast table |
2 | # by Case Duckworth | case.duckworth@gmail.com | autocento.me | 2 | # by Case Duckworth | autocento.me |
3 | # inspired by Lincoln Mullen | lincolnmullen.com | ||
4 | # vim: fdm=marker | 3 | # vim: fdm=marker |
5 | 4 | ||
6 | # Define variables {{{ | 5 | # variables {{{ |
7 | srcs := $(wildcard *.txt) | 6 | appendixd := appendix |
8 | templates := $(wildcard _template.*) | 7 | backlinkd := backlinks |
9 | trunk := trunk | 8 | hapaxd := hapax |
10 | metas = hapax first-lines common-titles index island | 9 | scriptd := scripts |
11 | metas += $(templates) $(wildcard _*) | 10 | templated := templates |
12 | 11 | textd := text | |
13 | txts = $(filter-out \ | 12 | trunkd := trunk |
14 | $(patsubst %,%.txt,$(metas)),\ | 13 | wipd := wip |
15 | $(srcs)) | 14 | |
16 | 15 | compiler := bash $(scriptd)/compile.sh | |
17 | htmls = $(filter-out \ | 16 | texts := $(wildcard $(textd)/*.txt) |
18 | $(patsubst %,%.html,$(metas)),\ | 17 | |
19 | $(patsubst %.txt,%.html,$(srcs))) | 18 | htmls = $(patsubst $(textd)/%.txt,%.html,$(texts)) |
20 | htmlPre = $(trunk)/versify.exe | 19 | htmlWriter := html5 |
21 | htmlPreSrc = $(trunk)/versify.hs | 20 | htmlTemplate := $(templated)/page.html |
22 | htmlTemplate = _template.html | 21 | htmlFilter := $(scriptd)/versify.exe |
23 | htmlPandocOptions = --template=$(htmlTemplate) | 22 | htmlFilterSrc := $(scriptd)/versify.hs # Converts <br />s to <span>s |
24 | htmlPandocOptions+= --filter=$(htmlPre) | 23 | htmlOptions := --template=$(htmlTemplate) |
25 | htmlPandocOptions+= --smart --mathml --section-divs | 24 | htmlOptions += --filter=$(htmlFilter) |
26 | 25 | htmlOptions += --smart # Smart "correct" typeography | |
27 | lozenger = $(trunk)/lozenge.sh | 26 | htmlOptions += --mathml # Use mathml for TeX math in HTML |
28 | lozengeOut = $(trunk)/lozenge.js | 27 | htmlOptions += --section-divs # Add a <section> around sections |
29 | 28 | htmlOptions += --normalize # merge adjacent `Str`, `Emph`, `Space` | |
30 | hapaxs = $(filter-out \ | 29 | |
31 | $(patsubst %,%.hapax,$(metas)),\ | 30 | randomize := $(scriptd)/randomize.js |
32 | $(patsubst %.txt,%.hapax,$(srcs))) | 31 | |
33 | hapaxer = $(trunk)/hapax.lua | 32 | backTexts = $(patsubst $(textd)/%.txt,$(backlinkd)/%.back,$(texts)) |
34 | hapaxPre = $(trunk)/forceascii.exe | 33 | backTextHead := $(trunkd)/backlink.head |
35 | hapaxPreSrc = $(trunk)/forceascii.hs | 34 | backHtmls := $(patsubst %.back,%.html,$(backTexts)) |
36 | hapaxPandocOptions = --filter=$(hapaxPre) | 35 | backHtmlWriter := $(htmlWriter) |
37 | hapaxOut = hapax.txt | 36 | backHtmlTemplate := $(templated)/backlinks.html |
38 | hapaxHead = $(trunk)/hapax.head | 37 | backHtmlOptions := --template=$(backHtmlTemplate) |
39 | hapaxLinker = $(trunk)/hapaxlink.sh | 38 | backHtmlOptions += --smart |
40 | 39 | ||
41 | backTxts = $(patsubst %.html,%.back,$(htmls)) | 40 | hapaxSrcs = $(patsubst $(textd)/%.txt,$(hapaxd)/%.hapax,$(texts)) |
42 | backHtms = $(patsubst %.back,%_backlinks.htm,$(backTxts)) | 41 | hapax := $(appendixd)/hapax.txt |
43 | backHead = $(trunk)/backlink.head | 42 | hapaxWriter := $(scriptd)/hapax.lua |
44 | backlinker = $(trunk)/backlink.sh | 43 | hapaxFilter := $(scriptd)/forceascii.exe |
45 | backHtmTemplate = _backlinks_template.htm | 44 | hapaxFilterSrc := $(scriptd)/forceascii.hs |
46 | backPandocOptions = --template=$(backHtmTemplate) --smart | 45 | hapaxOptions := --filter=$(hapaxFilter) |
47 | 46 | hapaxHead := $(trunkd)/hapax.head | |
48 | islandHead = $(trunk)/island.head | 47 | hapaxTmp := $(trunkd)/_HAPAXTMP.tmp |
49 | islandTxt = island.txt | 48 | hapaxHtml := hapax.html |
50 | islandHtm = island.htm | 49 | |
51 | 50 | island := $(appendixd)/islands.txt | |
52 | firstLinesTxt = first-lines.txt | 51 | islandHead := $(trunkd)/islands.head |
53 | firstLinesOut = first-lines.html | 52 | islandHtml := islands.html |
54 | firstLiner = $(trunk)/first-lines.sh | 53 | firstLines := $(appendixd)/first-lines.txt |
55 | firstLinesHead = $(trunk)/first-lines.head | 54 | firstLinesHead := $(trunkd)/first-lines.head |
56 | commonTitlesTxt = common-titles.txt | 55 | firstLinesHtml := first-lines.html |
57 | commonTitlesOut = common-titles.html | 56 | commonTitles := $(appendixd)/common-titles.txt |
58 | commonTitler = $(trunk)/common-titles.sh | 57 | commonTitlesHead := $(trunkd)/common-titles.head |
59 | commonTitlesHead = $(trunk)/common-titles.head | 58 | commonTitlesHtml := common-titles.html |
60 | 59 | toc := $(appendixd)/toc.txt | |
61 | tocTxt = _toc.txt | 60 | tocHead := $(trunkd)/toc.head |
62 | tocHtml = _toc.html | 61 | tocHtml := toc.html |
63 | tocer = $(trunk)/toc.sh | 62 | appendices := $(firstLines) $(commonTitles) $(toc) $(hapax) |
64 | tocHead = $(trunk)/toc.head | 63 | appendixHtmls := $(patsubst $(appendixd)/%.txt,%.html,$(appendices)) |
65 | tocInc = $(hapaxOut) $(islandTxt) $(firstLinesTxt) $(commonTitlesTxt) $(txts) | ||
66 | # }}} | 64 | # }}} |
67 | # PHONY {{{ | 65 | # PHONY TARGETS {{{ |
68 | .PHONY: all clean distclean again remake meta | 66 | .PHONY: all clean again appendices htmls backlinks |
69 | all: meta \ | 67 | all : appendices backlinks htmls |
70 | $(htmlPre) $(htmls) $(lozengeOut)\ | 68 | htmls: $(htmls) |
71 | $(backHtms) $(islandHtm) | 69 | backlinks: $(backHtmls) $(islandHtml) |
72 | 70 | appendices: $(appendixHtmls) | |
73 | clean: | 71 | clean : |
74 | -rm -f $(hapaxs) | ||
75 | -rm -f $(firstLinesTxt) | ||
76 | -rm -f $(commonTitlesTxt) | ||
77 | -rm -f $(backTxts) | ||
78 | -rm -f *.tmp trunk/*.tmp | ||
79 | |||
80 | distclean: clean | ||
81 | -rm -f $(hapaxPre) $(htmlPre) hapax.html | ||
82 | -rm -f $(hapaxOut) $(firstLinesOut) $(commonTitlesOut) | ||
83 | -rm -f $(backHtms) | ||
84 | -rm -f $(htmls) | 72 | -rm -f $(htmls) |
85 | 73 | -rm -f $(backlinkd)/* | |
86 | again: clean all | 74 | -rm -f $(appendixd)/* |
87 | remake: distclean all | 75 | -rm -f $(hapaxd)/* |
88 | 76 | -rm -f $(appendixHtmls) | |
89 | meta: $(hapaxOut) $(firstLinesOut) $(commonTitlesOut) $(tocHtml) | 77 | again : clean all |
90 | # }}} | 78 | # }}} |
91 | # HTML {{{ | 79 | # HTMLS {{{ |
92 | $(htmlPre): $(htmlPreSrc) | 80 | %.html : $(textd)/%.txt $(htmlFilter) $(htmlTemplate) |
93 | ghc --make $(htmlPreSrc) | 81 | pandoc $< -t $(htmlWriter) $(htmlOptions) -o $@ |
94 | 82 | ||
95 | %.html: %.txt | $(htmlTemplate) $(htmlPre) | 83 | $(htmlFilter) : $(htmlFilterSrc) |
96 | pandoc $< -t html5 $(htmlPandocOptions) -o $@ | 84 | ghc --make $< |
97 | 85 | # }}} | |
98 | $(lozengeOut): $(htmls) | 86 | # RANDOMIZE.JS {{{ |
99 | bash $(lozenger) $(lozengeOut) $(htmls) | 87 | $(randomize) : $(htmls) |
88 | @echo "Updating $@..." | ||
89 | @$(compiler) $@ $^ | ||
100 | # }}} | 90 | # }}} |
101 | # BACKLINKS {{{ | 91 | # BACKLINKS {{{ |
102 | %.back: %.html $(backHead) | 92 | $(backlinkd)/%.back : $(textd)/%.txt $(backTextHead) |
103 | @bash $(backlinker) $< $@ $(backHead) $(txts) | 93 | cat $(backTextHead) > $@ |
104 | 94 | $(compiler) $@ $< >> $@ | |
105 | %_backlinks.htm: %.back $(backHtmTemplate) | 95 | $(compiler) --fix-head $@ $< |
106 | pandoc $< -t html5 $(backPandocOptions) -o $@ | ||
107 | |||
108 | $(islandTxt): $(backTxts) | ||
109 | |||
110 | $(islandHtm): $(islandTxt) $(islandHead) $(backHtms) | ||
111 | pandoc $(islandHead) $< -t html5 $(htmlPandocOptions) -o $@ | ||
112 | 96 | ||
113 | $(tocTxt): $(tocInc) | $(tocead) $(tocer) | 97 | $(backlinkd)/%.html : $(backlinkd)/%.back $(backHtmlTemplate) |
114 | @bash $(tocer) $(tocTxt) $(tocInc) | 98 | pandoc $< -t $(backHtmlWriter) $(backHtmlOptions) -o $@ |
115 | |||
116 | $(tocHtml): $(tocTxt) $(tocHead) | ||
117 | pandoc $(tocHead) $< -t html5 $(htmlPandocOptions) -o $@ | ||
118 | # }}} | 99 | # }}} |
119 | # HAPAX {{{ | 100 | # APPENDICES {{{ |
120 | $(hapaxPre): $(hapaxPreSrc) | 101 | $(island) : $(backTexts) |
121 | ghc --make $(hapaxPreSrc) | 102 | cat $(islandHead) > $@ |
122 | 103 | @echo "Compiling $@..." | |
123 | %.hapax: %.txt $(hapaxPre) $(hapaxLinker) | 104 | @$(compiler) $@ $^ >> $@ |
124 | pandoc $< -t $(hapaxer) $(hapaxPandocOptions) -o $@ | 105 | |
125 | 106 | $(islandHtml) : $(island) | |
126 | $(hapaxOut): $(hapaxs) | 107 | pandoc $< -t $(htmlWriter) $(htmlOptions) -o $@ |
127 | pandoc $^ -t $(hapaxer) -o $@ | 108 | |
128 | bash $(hapaxLinker) $@ $(hapaxHead) $^ | 109 | $(firstLines) : $(texts) |
110 | cat $(firstLinesHead) > $@ | ||
111 | @echo "Compiling $@..." | ||
112 | @$(compiler) $@ $^ >> $@ | ||
113 | |||
114 | $(firstLinesHtml) : $(firstLines) | ||
115 | pandoc $< -t $(htmlWriter) $(htmlOptions) -o $@ | ||
116 | |||
117 | $(commonTitles) : $(texts) | ||
118 | cat $(commonTitlesHead) > $@ | ||
119 | @echo "Compiling $@..." | ||
120 | @$(compiler) $@ $^ >> $@ | ||
121 | |||
122 | $(commonTitlesHtml) : $(commonTitles) | ||
123 | pandoc $< -t $(htmlWriter) $(htmlOptions) -o $@ | ||
124 | |||
125 | $(toc) : $(texts) | ||
126 | cat $(tocHead) > $@ | ||
127 | @echo "Compiling $@..." | ||
128 | @$(compiler) $@ $^ >> $@ | ||
129 | |||
130 | $(tocHtml) : $(toc) | ||
131 | pandoc $< -t $(htmlWriter) $(htmlOptions) -o $@ | ||
129 | # }}} | 132 | # }}} |
130 | # FIRST LINES & COMMON TITLES {{{ | 133 | # HAPAX LEGOMENA {{{ |
131 | $(firstLinesTxt): $(txts) | $(firstLiner) $(firstLinesHead) | 134 | $(hapaxd)/%.hapax : $(textd)/%.txt $(hapaxWriter) |
132 | bash $(firstLiner) $@ $(firstLinesHead) $^ | 135 | pandoc $< -t $(hapaxWriter) $(hapaxOptions) -o $@ |
133 | 136 | ||
134 | $(firstLinesOut): $(firstLinesTxt) $(htmlTemplate) $(htmlPre) | 137 | $(hapaxFilter) : $(hapaxFilterSrc) |
135 | pandoc $< -t html5 $(htmlPandocOptions) -o $@ | 138 | ghc --make $< |
136 | 139 | ||
137 | $(commonTitlesTxt): $(txts) | $(commonTitler) $(commonTitlesHead) | 140 | $(hapax) : $(hapaxSrcs) |
138 | bash $(commonTitler) $@ $(commonTitlesHead) $^ | 141 | pandoc $^ -t $(hapaxWriter) $(hapaxOptions) -o $@ |
139 | 142 | cat $(hapaxHead) > $(hapaxTmp) | |
140 | $(commonTitlesOut): $(commonTitlesTxt) $(htmlTemplate) $(htmlPre) | 143 | @echo "Linking $@..." |
141 | pandoc $< -t html5 $(htmlPandocOptions) -o $@ | 144 | @$(compiler) $@ $^ >> $(hapaxTmp) |
145 | mv $(hapaxTmp) $@ | ||
146 | |||
147 | $(hapaxHtml) : $(hapax) | ||
148 | pandoc $< -t $(htmlWriter) $(htmlOptions) -o $@ | ||
142 | # }}} | 149 | # }}} |