-
Notifications
You must be signed in to change notification settings - Fork 67
/
Makefile
349 lines (287 loc) · 11.1 KB
/
Makefile
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
## This file is part of the book ##
## ##
## Discrete Mathematics: An Open Introduction ##
## ##
## Copyright (C) 2015-2018 Oscar Levin ##
## See the file COPYING for copying conditions. ##
## Based on the corresponding file from ##
## Abstract Algebra: Theory and Applications ##
## by Tom Judson ##
#######################
# DO NOT EDIT THIS FILE
#######################
# 1) Do make a copy of Makefile.paths.original
# as Makefile.paths
# 2) Edit Makefile.paths to provide full paths to the root folders
# of your local clones of the project repository and the mathbook
# repository as described below.
# 3) The files Makefile and Makefile.paths.original
# are managed by git revision control and any edits you make to
# these will conflict. You should only be editing Makefile.paths.
##############
# Introduction
##############
# This is not a "true" makefile, since it does not
# operate on dependencies. It is more of a shell
# script, sharing common configurations
# This is mostly offered as an example of one approach
# to managing a project with multiple output formats. and
# is not claimed to be "best practice"
######################
# System Prerequisites
######################
# install (system tool to make directories)
# xsltproc (xml/xsl text processor)
# tar (to package SageMathCloud worksheets for upload)
# xmllint (only to check source against DTD)
# <helpers> (PDF viewer, web browser, pager, Sage executable, etc)
#####
# Use
#####
# A) Set default directory to be the location of this file
# B) At command line: make solutions (and employ targets)
# The included file contains customized versions
# of locations of the principal components of this
# project and names of various helper executables
include Makefile.paths
# This is to ensure that latex is not skipped
.PHONY: latex html
# These paths are subdirectories of
# the Mathbook XML distribution
# MBUSR is where extension files get copied
# so relative paths work properly
PTXXSL = $(PTX)/xsl
PTXSCRIPT = $(PTX)/pretext
PTXUSR = $(PTX)/user
PTXRELAXNG = $(PTX)/schema
# These are source and custom XSL subdirectories
# for the two DMOI repositories
SRC = $(DMOI)/ptx
XSL = $(DMOI)/xsl
# These are the files to apply templates to
MAIN = $(SRC)/dmoi.ptx
MERGED = $(LOCALBUILD)/dmoi-merge.ptx
# These paths are subdirectories of
# a scratch directory
HTMLOUT = $(SCRATCH)/html
PDFOUT = $(SCRATCH)/latex
SMCOUT = $(SCRATCH)/dmoi-smc
DOCTEST = $(SCRATCH)/doctest
EPUBOUT = $(SCRATCH)/epub
SAGENBOUT = $(SCRATCH)/sagenb
JUPYTEROUT = $(SCRATCH)/jupyter
LOCALBUILD = $(SCRATCH)/localbuild
# Some aspects of producing these examples require a WeBWorK server.
# Either specify only the protocol and domain (like https://webwork.yourschool.edu)
# or specify a 5-tuple with quotes exactly as in this example
# SERVER = "(https://webwork-ptx.aimath.org,courseID,userID,password,course_password)"
SERVER = https://webwork-ptx.aimath.org
RSSERVER = http://webwork.runestone.academy/
# Following regularly presumes xml:id="dmoi" on
# the <book> element, so xsltproc creates dmoi.tex
###############
# Preliminaries
###############
# Diagrams
# invoke mbx script to manufacture diagrams
# tikz as SVG for HTML
# sageplot as PDF for LaTeX, SVG for HTML
# these outputs are in source repo now, and
# are typically just copied out
# this should be run if diagram source changes
# NB: targets below copy versions out of repo and clobber these
diagrams:
install -d $(HTMLOUT)/images
-rm $(HTMLOUT)/images/*.svg
$(PTXSCRIPT)/pretext -v -c latex-image -f svg -d $(HTMLOUT)/images $(MAIN)
# $(PTXSCRIPT)/mbx -v -c sageplot -f pdf -d $(HTMLOUT)/images $(MAIN)
# $(PTXSCRIPT)/mbx -v -c sageplot -f svg -d $(HTMLOUT)/images $(MAIN)
# WeBWorK extraction
# This happens in two steps (for now), first extract WW problems into a single xml file called webwork-extraction.xml in localbuild, which holds multiple versions of each problem.
ww-extraction:
$(PTXSCRIPT)/pretext -c webwork -s $(SERVER) -d $(SRC) $(MAIN)
sed -i.bak 's/label="a."/label="(a)"/g' $(SRC)/webwork-representations.ptx
rm $(SRC)/webwork-representations.ptx.bak
# install -d $(LOCALBUILD)
# -rm $(LOCALBUILD)/webwork-extraction.xml
# $(PTXSCRIPT)/mbx -v -c webwork -d $(LOCALBUILD) -s $(SERVER) $(MAIN)
# sed -i.bak 's/label="a."/label="(a)"/g' $(LOCALBUILD)/webwork-extraction.xml
# rm $(LOCALBUILD)/webwork-extraction.xml.bak
ww-extraction-rs:
$(PTXSCRIPT)/pretext -vv -a -c webwork -s $(RSSERVER) -d $(SRC) $(MAIN)
sed -i.bak 's/label="a."/label="(a)"/g' $(SRC)/webwork-representations.ptx
rm $(SRC)/webwork-representations.ptx.bak
# Then we merge this with the main source
# ww-merge:
# cd $(SCRATCH); \
# xsltproc --xinclude --stringparam webwork.extraction $(LOCALBUILD)/webwork-extraction.xml $(PTXXSL)/pretext-merge.xsl $(MAIN) > $(LOCALBUILD)/dmoi-merge.ptx
# ww-fresh: ww-extraction ww-merge
##########
# Products
##########
# HTML version
# Copies in image files from source directory
# Move to server: generated *.html and
# entire directories - /images and /knowl
html:
install -d $(HTMLOUT)
-rm $(HTMLOUT)/*.html
-rm $(HTMLOUT)/knowl/*.html
cp -a images $(HTMLOUT)
install -d $(PTXUSR)
install -b $(XSL)/dmoi-html.xsl $(PTXUSR)
install -b $(XSL)/dmoi-common.xsl $(PTXUSR)
cd $(HTMLOUT); \
xsltproc -xinclude -stringparam publisher "pub-standard.xml" $(PTXUSR)/dmoi-html.xsl $(MAIN);
html-fresh: diagrams ww-extraction html
viewhtml:
$(HTMLVIEWER) $(HTMLOUT)/dmoi.html &
#Runestone target - just like html but with runestone host set through pubfile
runestone:
install -d $(HTMLOUT)
-rm $(HTMLOUT)/*.html
-rm $(HTMLOUT)/knowl/*.html
cp -a images $(HTMLOUT)
install -d $(PTXUSR)
install -b $(XSL)/dmoi-html.xsl $(PTXUSR)
install -b $(XSL)/dmoi-common.xsl $(PTXUSR)
cd $(HTMLOUT); \
xsltproc -xinclude -stringparam publisher ../ptx/pub-runestone.xml $(PTXUSR)/dmoi-html.xsl $(MAIN);
# Full PDF version
# copies in all image files, which is overkill (SVG's)
# produces aata-sage.tex in scratch directory
# which becomes PDF, along with index entries
# Includes *all* material, and is fully electronic
# This is the DMOI/Sage downloadable Annual Edition
# sage:
# # delete old xsltproc output
# # dash prevents error if not found
# -rm $(PDFOUT)/aata.tex
# install -d $(PDFOUT) $(MBUSR)
# cp -a $(SRC)/images $(PDFOUT)
# cp $(XSL)/aata-common.xsl $(XSL)/aata-latex.xsl $(XSL)/aata-sage.xsl $(MBUSR)
# cd $(PDFOUT); \
# xsltproc --xinclude $(MBUSR)/aata-sage.xsl $(SRC)/dmoi.ptx; \
# $(ENGINE) aata.tex; $(ENGINE) aata.tex; \
# mv aata.pdf aata-sage.pdf
#
# # View PDF from correct directory
# viewsage:
# $(PDFVIEWER) $(PDFOUT)/aata-sage.pdf &
# Print PDF version
# A print version for print-on-demand
# This will be source for the Annual Edition,
# as sent to Orthogonal Publishing for modification
# Black on white, no live URLs, etc
# This is the "printable" downloadable Annual Edition
latex:
-rm $(PDFOUT)/dmoi.tex
install -d $(PDFOUT)
cp -a images $(PDFOUT)
install -d $(PTXUSR)
install -b $(XSL)/dmoi-latex.xsl $(PTXUSR)
install -b $(XSL)/pretext-latex-dmoi.xsl $(PTXUSR)
install -b $(XSL)/dmoi-common.xsl $(PTXUSR)
cd $(PDFOUT); \
xsltproc -xinclude -stringparam publisher "pub-standard.xml" $(PTXUSR)/dmoi-latex.xsl $(MAIN) > dmoi.tex;
latex-fresh: ww-extraction latex
pdf:
cd $(PDFOUT); \
$(ENGINE) dmoi.tex;
print: latex
cd $(PDFOUT); \
$(ENGINE) dmoi.tex; $(ENGINE) dmoi.tex; \
mv dmoi.pdf dmoi-print.pdf
# View PDF from correct directory
viewpdf:
$(PDFVIEWER) $(PDFOUT)/dmoi.pdf
viewprint:
$(PDFVIEWER) $(PDFOUT)/dmoi-print.pdf
# # Electronic PDF version
# # copies in all image files, which is overkill (SVG's)
# # produces aata-electronic.tex in scratch directory
# # which becomes PDF, along with index entries
# # Similar to "print" but with links, etc.
# # No Sage material
# # This is default downloadable Annual Edition
# # ie, aata-YYYYMMDD.pdf in repository download section
# latex-tablet:
# -rm $(PDFOUT)/dmoi.tex
# install -d $(PDFOUT)
# # cp -a images $(PDFOUT)
# cd $(PDFOUT); \
# xsltproc --xinclude $(XSL)/custom-latex-tablet.xsl $(MERGED); \
# tablet: latex-tablet
# cd $(PDFOUT); \
# $(ENGINE) dmoi.tex; $(ENGINE) dmoi.tex; \
# mv dmoi.pdf dmoi-tablet.pdf
# # View PDF from correct directory
# viewtablet:
# $(PDFVIEWER) $(PDFOUT)/dmoi-tablet.pdf &
# # Author's Draft
# # Like electronic PDF version, but for:
# # No index created, since showidx is used
# # Various markup for author's use, todo's etc
# draft:
# # delete old xsltproc output
# # dash prevents error if not found
# -rm $(PDFOUT)/aata.tex
# install -d $(PDFOUT) $(MBUSR)
# cp -a $(SRC)/images $(PDFOUT)
# cp $(XSL)/aata-common.xsl $(XSL)/aata-latex.xsl $(XSL)/aata-electronic.xsl $(MBUSR)
# cd $(PDFOUT); \
# xsltproc --xinclude --stringparam author-tools 'yes' \
# --stringparam latex.draft 'yes' $(MBUSR)/aata-electronic.xsl $(SRC)/dmoi.ptx; \
# $(ENGINE) aata.tex; $(ENGINE) aata.tex; \
# mv aata.pdf aata-draft.pdf
# viewdraft:
# $(PDFVIEWER) $(PDFOUT)/aata-draft.pdf &
######
# Sage
######
# DMOI has extensive support for Sage
# These targets are all related to that
# # Doctest
# # All Sage material, but not solutions to exercises
# # Prepare location, remove *.py from previous runs
# # XSL dumps into current directory, Sage processes whole directory
# # chunk level 2 gives sections (commentaries, exercises)
# doctest:
# -rm $(DOCTEST)/*.py; \
# install -d $(DOCTEST)
# cd $(DOCTEST); \
# xsltproc --xinclude --stringparam chunk.level 2 $(MBXSL)/mathbook-sage-doctest.xsl $(SRC)/dmoi.ptx; \
# $(SAGE) -tp 0 .
# # SageMathCloud worksheets
# # can upload, extract tarball
# # that has "aata-smc" as root directory
# # $ tar -xvf aata-smc.tgz
# smc:
# install -d $(SMCOUT) $(MBUSR)
# cp -a $(SRC)/images $(SMCOUT)
# cp -a $(MB)/css/mathbook-content.css $(MB)/css/mathbook-add-on.css $(SMCOUT)
# cp $(XSL)/aata-common.xsl $(XSL)/aata-smc.xsl $(MBUSR)
# cd $(SMCOUT); \
# xsltproc --xinclude $(MBUSR)/aata-smc.xsl $(SRC)/dmoi.ptx
# # wrap up into a tarball in SCRATCH
# # NB: subdir must match with SMCOUT
# tar -c -z -f $(SCRATCH)/aata-smc.tgz -C $(SCRATCH) aata-smc
###########
# Utilities
###########
## Clean solutions for student version ##
cleansols:
install -d $(SCRATCH)
install -d $(SCRATCH)/ptx-clean
install -d $(SCRATCH)/ptx-clean/exercises
# -rm $(SCRATCH)/ptx-clean/*.ptx
# # -rm $(SCRATCH)/ptx-clean/exercises/*.ptx
# for f in ptx/*.ptx; do \
# xsltproc -o ptx-clean/$${f##*/} xsl/clean-solutions.xsl $$f; \
# done
# $(foreach var,$(wildcard ptx/*.ptx), \
# xsltproc -o ptx-clean/$(notdir $(var)) xsl/clean-solutions.xsl $(var);)
$(foreach var,$(wildcard ptx/exercises/*.ptx), \
xsltproc -o ptx-clean/exercises/$(notdir $(var)) xsl/clean-solutions.xsl $(var);)
# xsltproc -o $(SCRATCH)/ptx-clean/ xsl/clean-solutions.xsl $(widcard $(DMOI)/ptx/*.ptx)
# xsltproc xsl/clean-solutions.xsl $(widcard $(DMOI)/ptx/*.ptx)