-
Notifications
You must be signed in to change notification settings - Fork 0
/
source.make
265 lines (228 loc) · 9.5 KB
/
source.make
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# Example Makefile that includes this file:
#
# TITLE="Beej's Guide to Git"
# SUBTITLE=""
# AUTHOR='Brian “Beej Jorgensen” Hall'
# VERSION_DATE="v0.0.3, Copyright © July 8, 2024"
#
# GUIDE_ID=bggit
# BGBSPD_BUILD_DIR?=../../bgbspd
#
# WEB_IMAGES=$(wildcard img_*svg)
#
# include $(BGBSPD_BUILD_DIR)/source.make
export GUIDE_ID
PDF_MAINFONT="Liberation Serif"
PDF_SANSFONT="Liberation Sans"
PDF_MONOFONT="Liberation Mono"
#PDF_MAINFONT="DejaVu Serif"
#PDF_SANSFONT="DejaVu Sans"
#PDF_MONOFONT="DejaVu Sans Mono"
USLETTER_COLOR=$(GUIDE_ID)_usl_c_1.pdf $(GUIDE_ID)_usl_c_2.pdf
USLETTER_BW=$(GUIDE_ID)_usl_bw_1.pdf $(GUIDE_ID)_usl_bw_2.pdf
A4_COLOR=$(GUIDE_ID)_a4_c_1.pdf $(GUIDE_ID)_a4_c_2.pdf
A4_BW=$(GUIDE_ID)_a4_bw_1.pdf $(GUIDE_ID)_a4_bw_2.pdf
BOOKS=$(USLETTER_BW) $(USLETTER_COLOR) $(A4_BW) $(A4_COLOR)
HTML=$(GUIDE_ID).html $(GUIDE_ID)-wide.html
SPLIT_DIRS=split split-wide
GUIDE_MD=$(sort $(wildcard $(GUIDE_ID)_part_*.md))
PREPROC=$(BGBSPD_BUILD_DIR)/bin/preproc
TEMP_PREFIX=$(GUIDE_ID)_temp
PREPROC_TEMP_PREFIX=$(TEMP_PREFIX)_preproc
SPLIT=$(BGBSPD_BUILD_DIR)/bin/bgsplit.py
COMMON_OPTS= \
--variable title:$(TITLE) \
--variable subtitle:$(SUBTITLE) \
--variable author:$(AUTHOR) \
--variable date:$(VERSION_DATE) \
--number-sections \
--toc \
--wrap=none
PDF_OPTS= \
-H $(BGBSPD_BUILD_DIR)/latex/header_general.latex \
-A $(BGBSPD_BUILD_DIR)/latex/after_index.latex \
--pdf-engine=xelatex \
--variable mainfont=$(PDF_MAINFONT) \
--variable sansfont=$(PDF_SANSFONT) \
--variable monofont=$(PDF_MONOFONT) \
--variable geometry:"top=1in,bottom=1in" \
-V documentclass=book \
--lua-filter $(BGBSPD_BUILD_DIR)/lua/latex_filters.lua \
$(COMMON_OPTS)
# -o $(GUIDE_ID)_temp.tex \
# -H $(BGBSPD_BUILD_DIR)/latex/header_codebox.latex \
#-V indent \
HTML_OPTS=$(COMMON_OPTS) \
--metadata title:$(TITLE) \
--mathjax
ONESIDE=--variable classoption:oneside
TWOSIDE=--variable classoption:twoside
USLETTER=--variable papersize:letter
A4=--variable papersize:a4
CROWNQUARTO=--variable geometry:"paperwidth=7.444in,paperheight=9.681in,top=1in,bottom=1in,left=1in,right=1.5in" # Lulu press
CROWNQUARTO_AMAZON=--variable geometry:"paperwidth=7.444in,paperheight=9.681in,top=1in,bottom=1in,left=1.25in,right=1.25in" # Amazon
#SIZE_75x925_AMAZON=--variable geometry:"paperwidth=7.5in,paperheight=9.25in,top=1in,bottom=1in,left=1.125in,right=1.375in" # Amazon 7.5" x 9.25", margins too far inside
SIZE_75x925_AMAZON=--variable geometry:"paperwidth=7.5in,paperheight=9.25in,top=1in,bottom=1in,left=1.25in,right=1.25in" # Amazon 7.5" x 9.25"
BLANKLAST=-A $(BGBSPD_BUILD_DIR)/latex/after_blank.latex # add a blank last page
BW=--no-highlight # black and white options
COLOR=--highlight-style=tango # color options
BOLD=$(shell tput bold)
RESET=$(shell tput sgr0)
help:
@echo
@echo " $(BOLD)all$(RESET) build everything"
@echo " $(BOLD)clean$(RESET) remove temporary build products"
@echo " $(BOLD)pristine$(RESET) remove all build products"
@echo
@echo " Specific targets:"
@echo
@echo " $(GUIDE_ID).html"
@echo " $(GUIDE_ID)-wide.html"
@echo " split/index.html"
@echo " split-wide/index.html"
@echo " $(GUIDE_ID)_usl_c_1.pdf"
@echo " $(GUIDE_ID)_usl_c_2.pdf"
@echo " $(GUIDE_ID)_usl_bw_1.pdf"
@echo " $(GUIDE_ID)_usl_bw_2.pdf"
@echo " $(GUIDE_ID)_a4_c_1.pdf"
@echo " $(GUIDE_ID)_a4_c_2.pdf"
@echo " $(GUIDE_ID)_a4_bw_1.pdf"
@echo " $(GUIDE_ID)_a4_bw_2.pdf"
@echo " $(GUIDE_ID)_amazon.pdf"
@echo " $(GUIDE_ID)_lulu.pdf"
@echo
all: $(HTML) split/index.html split-wide/index.html $(BOOKS)
bg-css.html: $(BGBSPD_BUILD_DIR)/html/common-css-src.html
cat $^ > $@
bg-css-wide.html: $(BGBSPD_BUILD_DIR)/html/common-css-src.html $(BGBSPD_BUILD_DIR)/html/widescreen-css-src.html
cat $^ > $@
$(GUIDE_ID).html: $(GUIDE_MD) bg-css.html
$(PREPROC) $(GUIDE_MD) $(PREPROC_TEMP_PREFIX)_html.md
pandoc $(HTML_OPTS) -s $(PREPROC_TEMP_PREFIX)_html.md -o $@ -H bg-css.html
sed 's/src="\(.*\)\.pdf"/src="\1.svg"/g' $@ > $(TEMP_PREFIX)_html.html # use svg images
mv $(TEMP_PREFIX)_html.html $@
#rm -f $(TEMP_PREFIX)*_html.* texput.log
$(GUIDE_ID)-wide.html: $(GUIDE_MD) bg-css-wide.html
$(PREPROC) $(GUIDE_MD) $(PREPROC_TEMP_PREFIX)_html_wide.md
pandoc $(HTML_OPTS) -s $(PREPROC_TEMP_PREFIX)_html_wide.md -o $@ -H bg-css-wide.html
sed 's/src="\(.*\)\.pdf"/src="\1.svg"/g' $@ > $(TEMP_PREFIX)_html_wide.html # use svg images
mv $(TEMP_PREFIX)_html_wide.html $@
#rm -f $(TEMP_PREFIX)*_html_wide.* texput.log
split/index.html: $(GUIDE_ID).html
$(SPLIT) $< split
ifdef WEB_IMAGES
cp -v $(WEB_IMAGES) split
endif
split-wide/index.html: $(GUIDE_ID)-wide.html
$(SPLIT) $< split-wide
ifdef WEB_IMAGES
cp -v $(WEB_IMAGES) split-wide
endif
$(GUIDE_ID).epub: $(GUIDE_MD)
$(PREPROC) $^ $(PREPROC_TEMP_PREFIX)_epub.md
pandoc $(COMMON_OPTS) --webtex --metadata author=$(AUTHOR) --metadata title=$(TITLE) -o $@ $(PREPROC_TEMP_PREFIX)_epub.md
$(GUIDE_ID)_quick.pdf: $(GUIDE_MD)
$(PREPROC) $^ $(PREPROC_TEMP_PREFIX)_quick.md
pandoc $(PDF_OPTS) $(USLETTER) $(ONESIDE) $(COLOR) -o $(TEMP_PREFIX)_quick.tex $(PREPROC_TEMP_PREFIX)_quick.md
xelatex $(TEMP_PREFIX)_quick.tex
mv $(TEMP_PREFIX)_quick.pdf $@
#rm -f $(TEMP_PREFIX)*_quick.* texput.log
$(GUIDE_ID)_usl_c_1.pdf: $(GUIDE_MD)
$(PREPROC) $^ $(PREPROC_TEMP_PREFIX)_usl_c_1.md
pandoc $(PDF_OPTS) $(USLETTER) $(ONESIDE) $(COLOR) -o $(TEMP_PREFIX)_usl_c_1.tex $(PREPROC_TEMP_PREFIX)_usl_c_1.md
xelatex $(TEMP_PREFIX)_usl_c_1.tex
makeindex $(TEMP_PREFIX)_usl_c_1.idx
xelatex $(TEMP_PREFIX)_usl_c_1.tex
xelatex $(TEMP_PREFIX)_usl_c_1.tex
mv $(TEMP_PREFIX)_usl_c_1.pdf $@
#rm -f $(TEMP_PREFIX)*_usl_c_1.* texput.log
$(GUIDE_ID)_usl_c_2.pdf: $(GUIDE_MD)
$(PREPROC) $^ $(PREPROC_TEMP_PREFIX)_usl_c_2.md
pandoc $(PDF_OPTS) $(USLETTER) $(TWOSIDE) $(COLOR) -o $(TEMP_PREFIX)_usl_c_2.tex $(PREPROC_TEMP_PREFIX)_usl_c_2.md
xelatex $(TEMP_PREFIX)_usl_c_2.tex
makeindex $(TEMP_PREFIX)_usl_c_2.idx
xelatex $(TEMP_PREFIX)_usl_c_2.tex
xelatex $(TEMP_PREFIX)_usl_c_2.tex
mv $(TEMP_PREFIX)_usl_c_2.pdf $@
#rm -f $(TEMP_PREFIX)*_usl_c_2.* texput.log
$(GUIDE_ID)_a4_c_1.pdf: $(GUIDE_MD)
$(PREPROC) $^ $(PREPROC_TEMP_PREFIX)_a4_c_1.md
pandoc $(PDF_OPTS) $(A4) $(ONESIDE) $(COLOR) -o $(TEMP_PREFIX)_a4_c_1.tex $(PREPROC_TEMP_PREFIX)_a4_c_1.md
xelatex $(TEMP_PREFIX)_a4_c_1.tex
makeindex $(TEMP_PREFIX)_a4_c_1.idx
xelatex $(TEMP_PREFIX)_a4_c_1.tex
xelatex $(TEMP_PREFIX)_a4_c_1.tex
mv $(TEMP_PREFIX)_a4_c_1.pdf $@
#rm -f $(TEMP_PREFIX)*_a4_c_1.* texput.log
$(GUIDE_ID)_a4_c_2.pdf: $(GUIDE_MD)
$(PREPROC) $^ $(PREPROC_TEMP_PREFIX)_a4_c_2.md
pandoc $(PDF_OPTS) $(A4) $(TWOSIDE) $(COLOR) -o $(TEMP_PREFIX)_a4_c_2.tex $(PREPROC_TEMP_PREFIX)_a4_c_2.md
xelatex $(TEMP_PREFIX)_a4_c_2.tex
makeindex $(TEMP_PREFIX)_a4_c_2.idx
xelatex $(TEMP_PREFIX)_a4_c_2.tex
xelatex $(TEMP_PREFIX)_a4_c_2.tex
mv $(TEMP_PREFIX)_a4_c_2.pdf $@
#rm -f $(TEMP_PREFIX)*_a4_c_2.* texput.log
$(GUIDE_ID)_usl_bw_1.pdf: $(GUIDE_MD)
$(PREPROC) $^ $(PREPROC_TEMP_PREFIX)_usl_bw_1.md
pandoc $(PDF_OPTS) $(USLETTER) $(ONESIDE) $(BW) -o $(TEMP_PREFIX)_usl_bw_1.tex $(PREPROC_TEMP_PREFIX)_usl_bw_1.md
xelatex $(TEMP_PREFIX)_usl_bw_1.tex
makeindex $(TEMP_PREFIX)_usl_bw_1.idx
xelatex $(TEMP_PREFIX)_usl_bw_1.tex
xelatex $(TEMP_PREFIX)_usl_bw_1.tex
mv $(TEMP_PREFIX)_usl_bw_1.pdf $@
#rm -f $(TEMP_PREFIX)*_usl_bw_1.* texput.log
$(GUIDE_ID)_usl_bw_2.pdf: $(GUIDE_MD)
$(PREPROC) $^ $(PREPROC_TEMP_PREFIX)_usl_bw_2.md
pandoc $(PDF_OPTS) $(USLETTER) $(TWOSIDE) $(BW) -o $(TEMP_PREFIX)_usl_bw_2.tex $(PREPROC_TEMP_PREFIX)_usl_bw_2.md
xelatex $(TEMP_PREFIX)_usl_bw_2.tex
makeindex $(TEMP_PREFIX)_usl_bw_2.idx
xelatex $(TEMP_PREFIX)_usl_bw_2.tex
xelatex $(TEMP_PREFIX)_usl_bw_2.tex
mv $(TEMP_PREFIX)_usl_bw_2.pdf $@
#rm -f $(TEMP_PREFIX)*_usl_bw_2.* texput.log
$(GUIDE_ID)_a4_bw_1.pdf: $(GUIDE_MD)
$(PREPROC) $^ $(PREPROC_TEMP_PREFIX)_a4_bw_1.md
pandoc $(PDF_OPTS) $(A4) $(ONESIDE) $(BW) -o $(TEMP_PREFIX)_a4_bw_1.tex $(PREPROC_TEMP_PREFIX)_a4_bw_1.md
xelatex $(TEMP_PREFIX)_a4_bw_1.tex
makeindex $(TEMP_PREFIX)_a4_bw_1.idx
xelatex $(TEMP_PREFIX)_a4_bw_1.tex
xelatex $(TEMP_PREFIX)_a4_bw_1.tex
mv $(TEMP_PREFIX)_a4_bw_1.pdf $@
#rm -f $(TEMP_PREFIX)*_a4_bw_1.* texput.log
$(GUIDE_ID)_a4_bw_2.pdf: $(GUIDE_MD)
$(PREPROC) $^ $(PREPROC_TEMP_PREFIX)_a4_bw_2.md
pandoc $(PDF_OPTS) $(A4) $(TWOSIDE) $(BW) -o $(TEMP_PREFIX)_a4_bw_2.tex $(PREPROC_TEMP_PREFIX)_a4_bw_2.md
xelatex $(TEMP_PREFIX)_a4_bw_2.tex
makeindex $(TEMP_PREFIX)_a4_bw_2.idx
xelatex $(TEMP_PREFIX)_a4_bw_2.tex
xelatex $(TEMP_PREFIX)_a4_bw_2.tex
mv $(TEMP_PREFIX)_a4_bw_2.pdf $@
#rm -f $(TEMP_PREFIX)*_a4_bw_2.* texput.log
$(TEMP_PREFIX)_lulu.md: $(GUIDE_MD)
$(PREPROC) $^ $@
$(GUIDE_ID)_lulu.pdf: $(TEMP_PREFIX)_lulu.md
pandoc $(PDF_OPTS) $(TWOSIDE) $(CROWNQUARTO) $(BLANKLAST) $(COLOR) -o $(TEMP_PREFIX)_lulu.tex $<
xelatex $(TEMP_PREFIX)_lulu.tex
makeindex $(TEMP_PREFIX)_lulu.idx
xelatex $(TEMP_PREFIX)_lulu.tex
xelatex $(TEMP_PREFIX)_lulu.tex
mv $(TEMP_PREFIX)_lulu.pdf $@
#rm -f $(TEMP_PREFIX)*_lulu.* texput.log
$(TEMP_PREFIX)_amazon.md: $(GUIDE_MD)
$(PREPROC) $^ $@
$(GUIDE_ID)_amazon.pdf: $(TEMP_PREFIX)_amazon.md
pandoc $(PDF_OPTS) $(TWOSIDE) $(SIZE_75x925_AMAZON) $(BLANKLAST) $(COLOR) -o $(TEMP_PREFIX)_amazon.tex $<
xelatex $(TEMP_PREFIX)_amazon.tex
makeindex $(TEMP_PREFIX)_amazon.idx
xelatex $(TEMP_PREFIX)_amazon.tex
xelatex $(TEMP_PREFIX)_amazon.tex
mv $(TEMP_PREFIX)_amazon.pdf $@
#rm -f $(TEMP_PREFIX)*_amazon.* texput.log
clean:
rm -f $(GUIDE_ID)_temp* $(GUIDE_ID)_quick.pdf bg-css*.html
pristine: clean
rm -f $(HTML) $(BOOKS)
rm -rf $(SPLIT_DIRS)
rm -f $(GUIDE_ID)_lulu.pdf $(GUIDE_ID)_amazon.pdf
.PHONY: help all html clean pristine