-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathMakefile
142 lines (106 loc) · 3.9 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
.PHONY : all clean chapters commands crossrefs fixme html links nbspref pdf settings tex-packages
HTML=_book/index.html
PDF=_book/py-rse.pdf
CHAPTERS=index.Rmd $(wildcard chapters/*.Rmd)
OBJECTIVES_KEYPOINTS=$(wildcard objectives/*.md) $(wildcard keypoints/*.md)
GLOSSARY=glossary/glossary.md
GLOSARIO=${HOME}/proj/glosario
COMMON_FILES=\
krantz.cls \
_bookdown.yml \
_output.yml \
_common.R \
appendix.Rmd \
LICENSE.md \
CONDUCT.md \
CONTRIBUTING.md \
${GLOSSARY} \
references.Rmd \
links.md \
book.bib
SOURCE=${CHAPTERS} ${OBJECTIVES_KEYPOINTS} ${COMMON_FILES}
EXTRA=\
src\
zipf
LINE_LENGTH=70
PYTHON_FILES=\
$(wildcard src/*/*/*.py) \
$(wildcard src/*/*/*/*.py) \
$(wildcard zipf/*/*.py)
#-------------------------------------------------------------------------------
all : commands
## commands : show all commands.
commands :
@grep -h -E '^##' ${MAKEFILE_LIST} | sed -e 's/## //g' | column -t -s ':'
## everything : rebuild HTML and PDF.
everything : ${HTML} ${PDF}
#-------------------------------------------------------------------------------
## html : build all HTML versions.
html : _book/index.html
_book/index.html : ${SOURCE} glossary/glossary-html.lua $(wildcard includes/*.html)
rm -f py-rse.Rmd
Rscript -e "options(bookdown.render.file_scope = FALSE); bookdown::render_book(input='index.Rmd', output_format='bookdown::gitbook', quiet = TRUE); warnings()"
cp -r ${EXTRA} _book
#-------------------------------------------------------------------------------
## pdf : build PDF version.
pdf : _book/py-rse.pdf
_book/py-rse.pdf : ${SOURCE} $(wildcard includes/*.tex)
rm -f py-rse.Rmd
Rscript -e "options(bookdown.render.file_scope = FALSE); bookdown::render_book(input='index.Rmd', output_format='bookdown::pdf_book', quiet = TRUE); warnings()"
#-------------------------------------------------------------------------------
## clean : clean up generated files.
clean :
@rm -rf _book _bookdown_files py-rse.Rmd
@rm -f *.aux *.idx *.lof *.log *.lot *.out *.toc
@find . -name '*~' -exec rm {} \;
## captions : check that image captions are OK.
captions :
@bin/captions.py ${SOURCE}
## chapters : check consistency of chapters.
chapters :
@make settings | bin/chapters.py _bookdown.yml CHAPTERS
## citations : check bibliography citations.
citations :
@bin/citations.py book.bib ${CHAPTERS}
## crossrefs : check cross-references.
crossrefs :
@bin/crossrefs.py "RSE PY" ${SOURCE}
## fixme : list all the FIXME markers
fixme :
@fgrep FIXME ${SOURCE}
## gloss : rebuild the Markdown glossary file.
# Target cannot be called 'glossary' because there is a directory with that name.
gloss : bin/glossary-merge.py bin/glossarize.py glossary/glossary.yml
echo '# Glossary {#glossary}' > ${GLOSSARY}
echo '' >> ${GLOSSARY}
bin/glossary-merge.py ${GLOSARIO}/glossary.yml glossary/glossary.yml \
| bin/glossarize.py glossary/glossary-slugs.txt \
>> ${GLOSSARY}
## glosscheck : check that glossary entries are defined and used.
glosscheck :
@bin/glosscheck.py ${GLOSSARY} ${CHAPTERS}
## images : check that all images are defined and used.
images :
@bin/images.py ./figures ${SOURCE}
## linelength : check lengths of lines in source files
linelength :
@bin/line-length.py ${LINE_LENGTH} ${PYTHON_FILES}
## linkcheck : check that links are defined and used.
linkcheck :
@bin/linkcheck.py ./links.md ${CHAPTERS}
## exercises : check that exercises have solutions and solutions have exercises.
exercises :
@bin/exercises.py chapters/solutions.Rmd ${CHAPTERS}
## nbspref : check that all cross-references are prefixed with a non-breaking space.
nbspref :
@bin/nbspref.py ${SOURCE}
## settings : echo all variable values.
settings :
@echo HTML: ${HTML}
@echo PDF: ${PDF}
@echo CHAPTERS: ${CHAPTERS}
@echo OBJECTIVES_KEYPOINTS: ${OBJECTIVES_KEYPOINTS}
@echo COMMON_FILES: ${COMMON_FILES}
## tex-packages : install required LaTeX packages.
tex-packages :
-tlmgr install $$(cat ./tex-packages.txt)