forked from active-calculus/active-calculus-single-mbx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
317 lines (279 loc) · 12 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
## ********************************************************************* ##
## Copyright 2016-2019 ##
## Matt Boelkins ##
## ##
## This file is part of Active Calculus ##
## ##
## ********************************************************************* ##
#######################
# DO NOT EDIT THIS FILE
#######################
# 1) Make a copy of Makefile.paths.original
# as Makefile.paths, which git will ignore.
# 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
# operates on very few dependencies. It is more of a shell
# script, sharing common configurations
# Useful targets:
# make acs-extraction --- Run this any time a change is made to a WeBWorK
# exercise. Do not run if no such changes have been
# made.
# make html --- Build the HTML version. Requires that make acs-extraction have
# been run in the past, but need not run it immediately before.
# make pdf --- Build the PDF version. Requires that make acs-extraction have
# been run in the past, but need not run it immediately before.
# make soln-pdf --- Make a PDF of the full solutions manual.
# make workbook-pdf --- Make a PDF of the activity workbook.
# make check --- Validate against the schema and report errors. List of errors
# is displayed on screen and stored in output/schema_errors.txt
######################
# System Prerequisites
######################
# install (system tool to make directories)
# xsltproc (xml/xsl text processor)
# <helpers> (PDF viewer, web browser, pager, Sage executable, etc)
#####
# Use
#####
# A) Navigate to the location of this file
# B) At command line: make <some-target-from-the-options-below>
# The included file contains customized versions
# of locations of the principal components of this
# project and names of various helper executables
include Makefile.paths
# These paths are subdirectories of
# the project distribution
PRJSRC = $(PRJ)/src
OUTPUT = $(PRJ)/output
STYLE = $(PRJ)/style
IMAGESSRC = $(PRJSRC)/images
# The project's main hub file
MAINFILE = $(PRJSRC)/index.xml
SOLNMAIN = $(PRJSRC)/acs-solution-manual.xml
WKBKMAIN = $(PRJSRC)/acs-activity-workbook.xml
WKBKMAIN14 = $(PRJSRC)/acs-activity-workbook-14.xml
WKBKMAIN58 = $(PRJSRC)/acs-activity-workbook-58.xml
RQMAIN = $(PRJSRC)/acs-reading-questions.xml
# These paths are subdirectories of
# the Mathbook XML distribution
# MBUSR is where extension files get copied
# so relative paths work properly
MBXSL = $(MB)/xsl
MBUSR = $(MB)/user
# These paths are subdirectories of
# the scratch directory
PGOUT = $(OUTPUT)/pg
# HTMLOUT set in Makefile.paths
# HTMLOUT = $(OUTPUT)/html
PDFOUT = $(OUTPUT)/pdf
WWOUT = $(OUTPUT)/webwork-extraction
IMAGESOUT = $(OUTPUT)/images
SOLNOUT = $(OUTPUT)/soln-man
WKBKOUT = $(OUTPUT)/workbook
RQOUT = $(OUTPUT)/reading-questions
# Some aspects of producing these examples require a WeBWorK server.
# For all but trivial testing or examples, please look into setting
# up your own WeBWorK server, or consult Alex Jordan about the use
# of PCC's server in a nontrivial capacity. <[email protected]>
SERVER = https://webwork-ptx.aimath.org
# Write out each WW problem as a standalone problem in PGML ready
# for use on a WW server. "def" files and "header" files are
# produced. Directories and filenames are derived from titles of
# chapters, sections, etc., in addition to the titles of the
# problems themselves.
#
# Results land in the subdirectory: $(PGOUT)/local
#
pg:
install -d $(PGOUT)
cd $(PGOUT); \
xsltproc -xinclude --stringparam chunk.level 2 $(MBXSL)/mathbook-webwork-archive.xsl $(MAINFILE)
# Extract webwork problems into a single XML file called
# webwork-extraction.xml which holds multiple versions of each problem.
# Also locally store images from the WeBWorK server.
acs-extraction:
install -d $(WWOUT)
-rm $(WWOUT)/webwork-representations.ptx
$(MB)/pretext/pretext -c webwork -d $(WWOUT) -s $(SERVER) $(MAINFILE)
# Make a new PTX file from the source tree, with webwork elements replaced
# by the webwork-reps from webwork-extraction.xml. (So run the above at
# least once first.) Subsequent templates are applied to the result.
acs-merge:
cd $(WWOUT); \
xsltproc -xinclude --stringparam webwork.extraction $(WWOUT)/webwork-extraction.xml $(MBXSL)/pretext-merge.xsl $(MAINFILE) > acs-merge.ptx
# HTML output
# Output lands in the subdirectory: $(HTMLOUT)
# Remove the entire $(HTMLOUT)/knowl directory because of how PTX now
# seems to make a knowl for everything and rm throws an error.
html:
install -d $(HTMLOUT)
-rm -rf $(HTMLOUT)/knowl
install -d $(HTMLOUT)/knowl
install -d $(HTMLOUT)/images
install -d $(OUTPUT)
install -d $(OUTPUT)/images
install -d $(MBUSR)
install -b xsl/acs-html.xsl $(MBUSR)
install -b xsl/acs-common.xsl $(MBUSR)
-rm $(HTMLOUT)/*.html
cp -a $(WWOUT)/webwork*image* $(HTMLOUT)/images
cp -a $(IMAGESSRC) $(HTMLOUT)
cd $(HTMLOUT); \
xsltproc -xinclude -stringparam publisher $(PRJ)/pub/publication.xml $(MBUSR)/acs-html.xsl $(MAINFILE)
# make all the image files in svg format
images:
install -d $(IMAGESOUT)
-rm $(IMAGESOUT)/*.svg
$(MB)/script/mbx -c latex-image -f svg -d $(IMAGESOUT) $(MAINFILE)
# $(MB)/script/mbx -c asymptote -f svg -d $(IMAGESOUT) $(MAINFILE)
# make all the image files in pdf format
pdfimages:
install -d $(IMAGESOUT)
-rm $(IMAGESOUT)/*.pdf
$(MB)/script/mbx -c latex-image -f pdf -d $(IMAGESOUT) $(MAINFILE)
# for pdf output, a one-time prerequisite for LaTeX conversion of
# problems living on a server, and image construction at server
# our "webwork-tex" is a subdirectory of where the PDF is compiled
# -s specifies an existing WW server to use (ignore security warnings)
webwork-server-tex:
install -d $(PDFOUT)/webwork-tex
$(MB)/script/mbx -v -c webwork-tex -s $(SERVER) -d $(PDFOUT)/webwork-tex $(MAINFILE)
# LaTeX and PDF versions,
# see prerequisite just above about merge files.
# xsltproc may be passed --stringparam latex.fillin.style box for box answer blanks
pdf: acs-merge
install -d $(PDFOUT)
install -d $(PDFOUT)/images
-rm $(PDFOUT)/*.*
-rm $(PDFOUT)/images/*
cp -a $(WWOUT)/*.png $(PDFOUT)/images
install -d $(MBUSR)
install -b xsl/acs-latex.xsl $(MBUSR)
install -b xsl/acs-common.xsl $(MBUSR)
cp -a $(IMAGESSRC) $(PDFOUT)
cd $(PDFOUT); \
xsltproc -o acs.tex -xinclude $(MBUSR)/acs-latex.xsl $(WWOUT)/acs-merge.ptx; \
xelatex acs; \
xelatex acs; \
xelatex acs
# Solutions manual (LaTeX only for PDF)
# see prerequisite just above
# the "webwork-tex" directory must be given here
# [note trailing slash (subject to change)]
# Need this to ensure all the numbering is right.
soln-latex:
install -d $(SOLNOUT)
install -d $(MBUSR)
install -b xsl/acs-solution-manual.xsl $(MBUSR)
install -b xsl/acs-common.xsl $(MBUSR)
-rm $(SOLNOUT)/*.tex
cp -a $(IMAGESSRC) $(SOLNOUT)
cd $(SOLNOUT); \
xsltproc -o acs-solution-manual.tex -xinclude $(MBUSR)/acs-solution-manual.xsl $(SOLNMAIN) \
# Solutions manual for PDF
# Automatically builds LaTeX source for solutions manual
# The call to sed below works with BSD sed (macOS) but will be problematic
# if using GNU sed (Linux and Windows Subsystem for Linux).
# We can fix this if anyone needs to build on other platforms.
soln-pdf: soln-latex
cd $(SOLNOUT); \
sed -i '' -e 's/solutionstyle, /solutionstyle, after={\\clearpage}, /g' acs-solution-manual.tex; \
sed -i '' -e 's/for\\\\/for\\\\[0.25\\baselineskip]/' acs-solution-manual.tex; \
xelatex acs-solution-manual; \
xelatex acs-solution-manual; \
xelatex acs-solution-manual
# Activity workbook (LaTeX only for PDF)
# see prerequisite just above
# the "webwork-tex" directory must be given here
# [note trailing slash (subject to change)]
# Need this to ensure all the numbering is right.
workbook-latex:
install -d $(WKBKOUT)
install -d $(MBUSR)
install -b xsl/acs-activity-workbook.xsl $(MBUSR)
install -b xsl/acs-common.xsl $(MBUSR)
-rm $(WKBKOUT)/*.tex
cp -a $(IMAGESSRC) $(WKBKOUT)
cd $(WKBKOUT); \
xsltproc -o acs-activity-workbook.tex -xinclude $(MBUSR)/acs-activity-workbook.xsl $(WKBKMAIN)
# Activity workbook for PDF
# Automatically builds LaTeX source for solutions manual
workbook-pdf: workbook-latex
cd $(WKBKOUT); \
sed -i '' -e 's/for\\\\/for\\\\[0.25\\baselineskip]/' acs-activity-workbook.tex; \
xelatex acs-activity-workbook; \
xelatex acs-activity-workbook; \
xelatex acs-activity-workbook
workbook-kdp:
install -d $(WKBKOUT)
install -d $(MBUSR)
install -b xsl/acs-activity-workbook.xsl $(MBUSR)
install -b xsl/acs-common.xsl $(MBUSR)
-rm $(WKBKOUT)/*.tex
cp -a $(IMAGESSRC) $(WKBKOUT)
cd $(WKBKOUT); \
xsltproc -o acs-activity-workbook-14.tex -xinclude $(MBUSR)/acs-activity-workbook.xsl $(WKBKMAIN14); \
xsltproc --stringparam debug.chapter.start 5 -o acs-activity-workbook-58.tex -xinclude $(MBUSR)/acs-activity-workbook.xsl $(WKBKMAIN58); \
xelatex acs-activity-workbook-14; \
xelatex acs-activity-workbook-14; \
xelatex acs-activity-workbook-14; \
xelatex acs-activity-workbook-58; \
xelatex acs-activity-workbook-58; \
xelatex acs-activity-workbook-58; \
awk 'BEGIN { del=0 } /%% Cover image, not numbered/ { del=1 } del<=0 { print } /%% begin: title page/ { del -= 1 }' acs-activity-workbook-14.tex > acs-activity-workbook-14-kdp.tex; \
awk 'BEGIN { del=0 } /%% Cover image, not numbered/ { del=1 } del<=0 { print } /%% begin: title page/ { del -= 1 }' acs-activity-workbook-58.tex > acs-activity-workbook-58-kdp.tex; \
xelatex acs-activity-workbook-14-kdp; \
xelatex acs-activity-workbook-14-kdp; \
xelatex acs-activity-workbook-14-kdp; \
xelatex acs-activity-workbook-58-kdp; \
xelatex acs-activity-workbook-58-kdp; \
xelatex acs-activity-workbook-58-kdp
workbook-parts:
cd $(WKBKOUT); \
qpdf acs-activity-workbook.pdf --pages . 1-210,r1 -- acs-activity-workbook-14.pdf; \
qpdf acs-activity-workbook-14.pdf --pages . 3-r1 -- acs-activity-workbook-14-kdp.pdf; \
sed -i '' -e 's/act-wkbk-cover-2018u-14.pdf/act-wkbk-cover-2018u-58.pdf/' acs-activity-workbook.tex; \
xelatex acs-activity-workbook; \
qpdf acs-activity-workbook.pdf --pages . 1-8,211-r1 -- acs-activity-workbook-58.pdf; \
qpdf acs-activity-workbook-58.pdf --pages . 3-r1 -- acs-activity-workbook-58-kdp.pdf
# Reading Questions Supplement (LaTeX only for PDF)
rq-latex:
install -d $(RQOUT)
install -d $(MBUSR)
install -b xsl/acs-reading-questions.xsl $(MBUSR)
install -b xsl/acs-common.xsl $(MBUSR)
-rm $(RQOUT)/*.tex
cp -a $(IMAGESSRC) $(RQOUT)
cd $(RQOUT); \
xsltproc -o acs-reading-questions.tex -xinclude $(MBUSR)/acs-reading-questions.xsl $(RQMAIN) \
# Activity workbook for PDF
# Automatically builds LaTeX source for solutions manual
rq-pdf: rq-latex
cd $(RQOUT); \
xelatex acs-reading-questions; \
xelatex acs-reading-questions
###########
# Utilities
###########
# Verify Source integrity
# Leaves "schema_errors.txt" in OUTPUT
# can then grep on, e.g.
# "element XXX:"
# "does not follow"
# "Element XXXX content does not follow"
# "No declaration for"
# Automatically invokes the "less" pager, could configure as $(PAGER)
check:
install -d $(OUTPUT)
-rm $(OUTPUT)/schema_errors.*
-java -classpath $(JING_DIR)/build -Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration -jar $(JING_DIR)/build/jing.jar $(MB)/schema/pretext.rng $(MAINFILE) > $(OUTPUT)/schema_errors.txt
xsltproc --xinclude $(MB)/schema/pretext-schematron.xsl $(MAINFILE) >> $(OUTPUT)/schema_errors.txt
less $(OUTPUT)/schema_errors.txt