forked from swcarpentry/DEPRECATED-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
124 lines (98 loc) · 3.74 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
# 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 ./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))
#------------------------------------------------------------
.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
## install-bare : rebuild entire site for real, without checks.
install-bare :
@make OUT_DIR=$(HOME)/software-carpentry.org SITE=http://software-carpentry.org check-bare
## check : rebuild entire site locally for checking purposes.
check : $(STATIC_DST) $(OUT_DIR)/.htaccess
@make ascii-chars
@make check-bare
@make check-links
@make blog-journal
## check-bare : rebuild entire site locally, but do not validate html
check-bare: $(STATIC_DST) $(OUT_DIR)/.htaccess
$(COMPILE) -m metadata.json -r $(BLOG_RSS_FILE) -c $(ICALENDAR_FILE) index.html
## 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 $< $@
#------------------------------------------------------------
## 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)