about summary refs log tree commit diff stats
path: root/makefile
diff options
context:
space:
mode:
authorCase Duckworth2015-04-14 16:36:17 -0700
committerCase Duckworth2015-04-14 16:36:17 -0700
commit9fce418b46c9f0894f429384ef9e3dabaeffbeb4 (patch)
treeb2339220ee50cf48b8887f0cc1fed4813a95901b /makefile
parentAdd toc metadata (diff)
downloadautocento-9fce418b46c9f0894f429384ef9e3dabaeffbeb4.tar.gz
autocento-9fce418b46c9f0894f429384ef9e3dabaeffbeb4.zip
Change file hierarchy and rewrite makefile
- File hierarchy is now as follows:
    - /
        - appendix/  < appendix source files
        - backlinks/ < backlink sources & builds
        - hapax/     < *.hapax source files
        - scripts/   < scripts, like *.js, *.hs, etc.
        - templates/ < templates for outputs
        - text/      < source files
        - trunk/     < assets, like css, images, heads, etc.
        - index.html
        - *.html
        - Makefile
Diffstat (limited to 'makefile')
-rw-r--r--makefile267
1 files changed, 137 insertions, 130 deletions
diff --git a/makefile b/makefile index 1c1bc7a..978e3f7 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 {{{
7srcs := $(wildcard *.txt) 6appendixd := appendix
8templates := $(wildcard _template.*) 7backlinkd := backlinks
9trunk := trunk 8hapaxd := hapax
10metas = hapax first-lines common-titles index island 9scriptd := scripts
11metas += $(templates) $(wildcard _*) 10templated := templates
12 11textd := text
13txts = $(filter-out \ 12trunkd := trunk
14 $(patsubst %,%.txt,$(metas)),\ 13wipd := wip
15 $(srcs)) 14
16 15compiler := bash $(scriptd)/compile.sh
17htmls = $(filter-out \ 16texts := $(wildcard $(textd)/*.txt)
18 $(patsubst %,%.html,$(metas)),\ 17
19 $(patsubst %.txt,%.html,$(srcs))) 18htmls = $(patsubst $(textd)/%.txt,%.html,$(texts))
20htmlPre = $(trunk)/versify.exe 19htmlWriter := html5
21htmlPreSrc = $(trunk)/versify.hs 20htmlTemplate := $(templated)/page.html
22htmlTemplate = _template.html 21htmlFilter := $(scriptd)/versify.exe
23htmlPandocOptions = --template=$(htmlTemplate) 22htmlFilterSrc := $(scriptd)/versify.hs # Converts <br />s to <span>s
24htmlPandocOptions+= --filter=$(htmlPre) 23htmlOptions := --template=$(htmlTemplate)
25htmlPandocOptions+= --smart --mathml --section-divs 24htmlOptions += --filter=$(htmlFilter)
26 25htmlOptions += --smart # Smart "correct" typeography
27lozenger = $(trunk)/lozenge.sh 26htmlOptions += --mathml # Use mathml for TeX math in HTML
28lozengeOut = $(trunk)/lozenge.js 27htmlOptions += --section-divs # Add a <section> around sections
29 28htmlOptions += --normalize # merge adjacent `Str`, `Emph`, `Space`
30hapaxs = $(filter-out \ 29
31 $(patsubst %,%.hapax,$(metas)),\ 30randomize := $(scriptd)/randomize.js
32 $(patsubst %.txt,%.hapax,$(srcs))) 31
33hapaxer = $(trunk)/hapax.lua 32backTexts = $(patsubst $(textd)/%.txt,$(backlinkd)/%.back,$(texts))
34hapaxPre = $(trunk)/forceascii.exe 33backTextHead := $(trunkd)/backlink.head
35hapaxPreSrc = $(trunk)/forceascii.hs 34backHtmls := $(patsubst %.back,%.html,$(backTexts))
36hapaxPandocOptions = --filter=$(hapaxPre) 35backHtmlWriter := $(htmlWriter)
37hapaxOut = hapax.txt 36backHtmlTemplate := $(templated)/backlinks.html
38hapaxHead = $(trunk)/hapax.head 37backHtmlOptions := --template=$(backHtmlTemplate)
39hapaxLinker = $(trunk)/hapaxlink.sh 38backHtmlOptions += --smart
40 39
41backTxts = $(patsubst %.html,%.back,$(htmls)) 40hapaxSrcs = $(patsubst $(textd)/%.txt,$(hapaxd)/%.hapax,$(texts))
42backHtms = $(patsubst %.back,%_backlinks.htm,$(backTxts)) 41hapax := $(appendixd)/hapax.txt
43backHead = $(trunk)/backlink.head 42hapaxWriter := $(scriptd)/hapax.lua
44backlinker = $(trunk)/backlink.sh 43hapaxFilter := $(scriptd)/forceascii.exe
45backHtmTemplate = _backlinks_template.htm 44hapaxFilterSrc := $(scriptd)/forceascii.hs
46backPandocOptions = --template=$(backHtmTemplate) --smart 45hapaxOptions := --filter=$(hapaxFilter)
47 46hapaxHead := $(trunkd)/hapax.head
48islandHead = $(trunk)/island.head 47hapaxTmp := $(trunkd)/_HAPAXTMP.tmp
49islandTxt = island.txt 48hapaxHtml := hapax.html
50islandHtm = island.htm 49
51 50island := $(appendixd)/islands.txt
52firstLinesTxt = first-lines.txt 51islandHead := $(trunkd)/islands.head
53firstLinesOut = first-lines.html 52islandHtml := islands.html
54firstLiner = $(trunk)/first-lines.sh 53firstLines := $(appendixd)/first-lines.txt
55firstLinesHead = $(trunk)/first-lines.head 54firstLinesHead := $(trunkd)/first-lines.head
56commonTitlesTxt = common-titles.txt 55firstLinesHtml := first-lines.html
57commonTitlesOut = common-titles.html 56commonTitles := $(appendixd)/common-titles.txt
58commonTitler = $(trunk)/common-titles.sh 57commonTitlesHead := $(trunkd)/common-titles.head
59commonTitlesHead = $(trunk)/common-titles.head 58commonTitlesHtml := common-titles.html
60 59toc := $(appendixd)/toc.txt
61tocTxt = _toc.txt 60tocHead := $(trunkd)/toc.head
62tocHtml = _toc.html 61tocHtml := toc.html
63tocer = $(trunk)/toc.sh 62appendices := $(island) $(firstLines) $(commonTitles) $(toc) $(hapax)
64tocHead = $(trunk)/toc.head 63appendixHtmls := $(patsubst $(appendixd)/%.txt,%.html,$(appendices))
65tocInc = $(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
69all: meta \ 67all : appendices backlinks htmls
70 $(htmlPre) $(htmls) $(lozengeOut)\ 68htmls: $(htmls)
71 $(backHtms) $(islandHtm) 69backlinks: $(backHtmls)
72 70appendices: $(appendixHtmls)
73clean: 71clean :
74 -rm -f $(hapaxs)
75 -rm -f $(firstLinesTxt)
76 -rm -f $(commonTitlesTxt)
77 -rm -f $(backTxts)
78 -rm -f *.tmp trunk/*.tmp
79
80distclean: 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)/*
86again: clean all 74 -rm -f $(appendixd)/*
87remake: distclean all 75 -rm -f $(hapaxd)/*
88 76 -rm -f $(appendixHtmls)
89meta: $(hapaxOut) $(firstLinesOut) $(commonTitlesOut) $(tocHtml) 77again : 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# }}}