forked from swcarpentry/DEPRECATED-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
225 lines (181 loc) · 6.52 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
# This Makefile relies on two variables:
# OUT_DIR: where the web site is stored.
# SITE: the URL of the web site.
# By default, it builds into ./build. The special target 'install'
# overrides the two variables and calls make recursively to build
# into to the installation directory on software-carpentry.org.
# Default value for output directory.
OUT_DIR = $(PWD)/build
# Default value for web site URL.
SITE = $(OUT_DIR)
# Blog feed index.
BLOG_RSS_FILE = $(OUT_DIR)/feed.xml
# iCalendar feed
ICALENDAR_FILE = $(OUT_DIR)/bootcamps.ics
# Standard site compilation arguments.
COMPILE = \
python bin/compile.py \
-d $$(date "+%Y-%m-%d") \
-o $(OUT_DIR) \
-p . -p bootcamps -p 3_0 -p 4_0 -p blog \
-s $(SITE) \
-v
# Static files.
STATIC_SRC = $(wildcard ./3_0/*/*.jpg) \
$(wildcard ./3_0/*/*.png) \
$(wildcard ./4_0/*/*.odp) \
$(wildcard ./4_0/*/*.pdf) \
$(wildcard ./4_0/*/*/*.mp3) \
$(wildcard ./4_0/*/*/*.png) \
$(wildcard ./badges/*/*.json) \
$(wildcard ./badges/*/*.png) \
$(wildcard ./book/img/*/*.jpg) \
$(wildcard ./book/img/*/*.png) \
$(wildcard ./book/src/*/*.csv) \
$(wildcard ./book/src/*/*.html) \
$(wildcard ./book/src/*/*.py) \
$(wildcard ./book/src/*/*.sql) \
$(wildcard ./book/src/*/*.txt) \
$(wildcard ./book/src/*/*.xml) \
$(wildcard ./css/*.css) \
$(wildcard ./css/bootstrap/*.css) \
$(wildcard ./css/bootstrap/img/*.png) \
$(wildcard ./files/*.bib) \
$(wildcard ./files/*/*/*.*) \
$(wildcard ./files/papers/*.pdf) \
$(wildcard ./img/*.ico) \
$(wildcard ./img/*.png) \
$(wildcard ./img/*/*.gif) \
$(wildcard ./img/*/*.jpg) \
$(wildcard ./img/*/*.png) \
$(wildcard ./js/*.js) \
$(wildcard ./js/bootstrap/*.js)
STATIC_DST = $(subst ./,$(OUT_DIR)/,$(STATIC_SRC))
# Chapters in book version.
BOOK_SUBJECTS_STEMS = \
shell \
svn \
python \
funclib \
db \
numpy \
quality \
setdict \
dev \
web \
teach
BOOK_SUBJECTS_HTML = $(foreach stem,$(BOOK_SUBJECTS_STEMS),$(OUT_DIR)/book/$(stem).html)
# All chapters in book.
BOOK_CHAPTERS_STEMS = \
index \
intro \
$(BOOK_SUBJECTS_STEMS) \
concl \
ack \
bib \
ref
BOOK_CHAPTERS_HTML = $(foreach stem,$(BOOK_CHAPTERS_STEMS),$(OUT_DIR)/book/$(stem).html)
#------------------------------------------------------------
.default : commands
## commands : show all commands
commands :
@grep -E '^##' Makefile | sed -e 's/## //g'
#------------------------------------------------------------
## install : rebuild entire site for real.
install :
@make OUT_DIR=$(HOME)/software-carpentry.org SITE=http://software-carpentry.org check
## check : rebuild entire site locally for checking purposes.
check : $(STATIC_DST) $(OUT_DIR)/.htaccess
@make ascii-chars
$(COMPILE) -m blog/metadata.json -r $(BLOG_RSS_FILE) -c $(ICALENDAR_FILE) index.html
@make check-links
@make book-figref
@make blog-journal
## blog-next-id : find the next blog entry ID to use.
blog-next-id :
@expr 1 + $$(fgrep -h post_id blog/*/*/*.html \
| sed -e 's:<meta name="post_id" content="::g' -e 's:" />::g' \
| sort -n \
| tail -1)
## blog-journal : make journal-format version of blog
blog-journal :
python bin/journal.py ${OUT_DIR}/blog/*/*/*.html > ${OUT_DIR}/blog/journal.html
## check-links : check that local links resolve in generated HTML.
check-links :
@find $(OUT_DIR) -type f -print | python bin/links.py $(OUT_DIR)
## ascii-chars : check for non-ASCII characters or tab characters.
ascii-chars :
@python bin/chars.py $$(find . -name '*.html' -print)
#------------------------------------------------------------
# Copy static files.
$(STATIC_DST) : $(OUT_DIR)/% : %
@mkdir -p $$(dirname $@)
cp $< $@
$(OUT_DIR)/.htaccess : _htaccess
cp $< $@
#------------------------------------------------------------
## book-bib : check for undefined/unused bibliography references.
book-bib :
@bin/book.py bibundef $(BOOK_CHAPTERS_HTML)
@bin/book.py bibunused $(BOOK_CHAPTERS_HTML)
## book-book : run all checks.
book-book :
@for i in unknown gloss images source structure bib fig; do \
echo '----' $$i '----'; \
make book-$$i; \
done
## book-classes : list all classes used in the generated HTML files.
book-classes :
@bin/book.py classes $$(find $(OUT_DIR) -name '*.html' -print)
## book-fig : check figure formatting and for undefined/unused figures.
book-fig :
@bin/book.py figformat $(BOOK_CHAPTERS_HTML)
@bin/book.py figundef $(BOOK_CHAPTERS_HTML)
@bin/book.py figunused $(BOOK_CHAPTERS_HTML)
## book-figref : patch cross-references in figures
book-figref :
@python bin/fignumber.py $(BOOK_CHAPTERS_HTML)
## book-fix : count FIXME markers in files.
book-fix :
@bin/book.py fix $(BOOK_CHAPTERS_HTML)
## book-gloss : check glossary formatting and for undefined/unused glossary entries.
book-gloss :
@bin/book.py glossformat $(BOOK_CHAPTERS_HTML)
@bin/book.py glossundef $(BOOK_CHAPTERS_HTML)
@bin/book.py glossunused $(BOOK_CHAPTERS_HTML)
## book-ideas : extract key ideas.
book-ideas :
@bin/book.py ideas $(BOOK_CHAPTERS_HTML)
## book-images : check for undefined/unused images.
book-images :
@bin/book.py imgundef img $(BOOK_CHAPTERS_HTML)
@bin/book.py imgunused img $(BOOK_CHAPTERS_HTML)
## book-source : check for undefined/unused source code fragments.
book-source :
@bin/book.py srcundef src $(BOOK_CHAPTERS_HTML)
@bin/book.py srcunused src $(BOOK_CHAPTERS_HTML)
## book-struct : check overall structure of files.
book-struct :
@bin/book.py structure $(BOOK_CHAPTERS_HTML)
## book-summary : extract section summaries (learning goals and keypoints).
book-summary :
@bin/book.py summaries $(BOOK_CHAPTERS_HTML)
## book-unknown : check for unexpected HTML files.
book-unknown :
@bin/book.py unknown vol1 $(BOOK_CHAPTERS_HTML)
## book-words-a : count words in files (report alphabetically).
book-words-a :
@bin/book.py words $(BOOK_CHAPTERS_HTML)
## book-words-n : count words in files (report numerically).
book-words-n :
@bin/book.py words $(BOOK_CHAPTERS_HTML) | sort -n -r -k 2
#------------------------------------------------------------
## tidy : clean up local files.
tidy :
rm -f *~ */*~ */*/*~ */*/*/*~
## clean : clean up generated files (but not copied files).
clean : tidy
rm -f $$(find $(OUT_DIR) -name '*.html' -print)
## sterile : clean up everything.
sterile : tidy
rm -rf $(OUT_DIR)