-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
174 lines (152 loc) · 6.93 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
## ********************************************************************* ##
## Copyright 2016 ##
## Alex Jordan ##
## ##
## This file is part of the PCC Calculsu Lab Manual. ##
## ##
## ********************************************************************* ##
#######################
# DO NOT EDIT THIS FILE
#######################
# 1) Do make a copy of Makefile.paths.original
# as Makefile.paths
# 2) Edit Makefile.paths as directed there
# 3) This file (Makefile) and Makefile.paths.original
# are managed by revision control and edits will conflict
# 4) See updated history in Makefile.paths.original
# for changes, or follow the revision control history
##############
# Introduction
##############
# This is not a "true" makefile, since it does not
# operate on dependencies. It is more of a shell
# script, sharing common configurations
######################
# System Prerequisites
######################
# install (system tool to make directories)
# xsltproc (xml/xsl text processor)
# 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 <some-target>
# 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 Calculus-Lab-Manual distribution
SRC = $(CLM)/src
CLMXSL = $(CLM)/xsl
CLMCSS = $(CLM)/css
IMAGESSRC = $(SRC)/images
GGBSRC = $(SRC)/geogebra
# 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
DTD = $(MB)/schema/dtd
# These paths are subdirectories of
# the scratch directory
PGOUT = $(OUTPUT)/pg
HTMLOUT = $(OUTPUT)/html
PDFOUT = $(OUTPUT)/pdf
EPUBOUT = $(OUTPUT)/epub
IMAGESOUT = $(OUTPUT)/images
# 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.pcc.edu
# 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 --stringparam chunk.level 2 $(MBXSL)/extract-webwork.xsl $(SRC)/clm.xml
# HTML output
# Output lands in the subdirectory: $(HTMLOUT)
html:
install -d $(HTMLOUT)
-rm $(HTMLOUT)/*.html
-rm $(HTMLOUT)/knowl/*.html
install -d $(HTMLOUT)/images
-rm $(HTMLOUT)/images/*.svg
cp -a $(IMAGESOUT) $(HTMLOUT)
cp -a $(IMAGESSRC) $(HTMLOUT)
cp -a $(GGBSRC) $(HTMLOUT)
install -d $(HTMLOUT)/css
cp -a $(CLMCSS) $(HTMLOUT)
cd $(HTMLOUT); \
xsltproc -xinclude --stringparam html.knowl.exercise.inline no $(CLMXSL)/clm-html.xsl $(SRC)/clm.xml; \
perl -pi -e 's/<\/div><\/main>/<footer><a rel="license" href="http:\/\/creativecommons\.org\/licenses\/by-sa\/4\.0\/"><img alt="Creative Commons License" style="border-width:0" src="https:\/\/i\.creativecommons\.org\/l\/by-sa\/4\.0\/88x31\.png" \/><\/a><br \/>This work is licensed under a <a rel="license" href="http:\/\/creativecommons\.org\/licenses\/by-sa\/4\.0\/">Creative Commons Attribution-ShareAlike 4\.0 International License<\/a>\.<\/footer><\/div><\/main>/g' *.html; \
perl -pi -e 's/<footer><a rel="license" href="http:\/\/creativecommons\.org\/licenses\/by-sa\/4\.0\/"><img alt="Creative Commons License" style="border-width:0" src="https:\/\/i\.creativecommons\.org\/l\/by-sa\/4\.0\/88x31\.png" \/><\/a><br \/>This work is licensed under a <a rel="license" href="http:\/\/creativecommons\.org\/licenses\/by-sa\/4\.0\/">Creative Commons Attribution-ShareAlike 4\.0 International License<\/a>\.<\/footer>//g' colophon-1.html; \
perl -pi -e 's/^<div class="svg-and-links">/<div style="width:90%;" class="svg-and-links">/g' functions-derivatives-antiderivatives-supplementary-exercises.html; \
perl -pi -e 's/<figure class="figure-like" id="figure-inflection-points"><div class="svg-and-links">/<figure class="figure-like" id="figure-inflection-points"><div style="width:75%; min-width:220px" class="svg-and-links">/g' section-graphical-derivatives.html; \
perl -pi -e 's/width:10%;min-width:[0-9]*px;/width:23%;min-width:100px;/g' section-graphical-features-from-derivatives.html; \
# make all the image files, in all formats
# To more surgically create a subset of the image files, use mbx
# script directly
images:
install -d $(IMAGESOUT)
$(MB)/script/mbx -c latex-image -f all -d $(IMAGESOUT) $(SRC)/clm.xml
# 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 $(SRC)/clm.xml
# LaTeX for print
# see prerequisite just above
# the "webwork-tex" directory must be given here
# [note trailing slash (subject to change)]
latex:
install -d $(PDFOUT)
-rm $(PDFOUT)/*.tex
cd $(PDFOUT); \
xsltproc -xinclude --stringparam whitespace flexible --stringparam webwork.server.latex $(PDFOUT)/webwork-tex/ $(CLMXSL)/clm-print.xsl $(SRC)/clm.xml; \
# PDF for print
# see prerequisite just above
# the "webwork-tex" directory must be given here
# [note trailing slash (subject to change)]
pdf:
install -d $(PDFOUT)
-rm $(PDFOUT)/*.tex
cd $(PDFOUT); \
xsltproc -xinclude --stringparam webwork.server.latex $(PDFOUT)/webwork-tex/ $(CLMXSL)/clm-print.xsl $(SRC)/clm.xml; \
xelatex clm.tex; \
xelatex clm.tex
# EPUB
epub:
install -d $(EPUBOUT)
-rm $(EPUBOUT)/*.epub
cd $(EPUBOUT); \
xsltproc -xinclude $(MBXSL)/mathbook-epub.xsl $(SRC)/clm.xml; \
###########
# Utilities
###########
# Verify Source integrity
# Leaves "dtderrors.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)/dtderrors.*
-xmllint --xinclude --postvalid --noout --dtdvalid $(DTD)/mathbook.dtd $(SRC)/clm.xml 2> $(OUTPUT)/dtderrors.txt
# less $(OUTPUT)/dtderrors.txt