forked from apertium/apertium-html-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
212 lines (154 loc) · 8.48 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
all: js css html fonts build/sitemap.xml build/strings/locales.json localhtml images
debug: debugjs debugcss build/index.debug.html build/not-found.html fonts build/js/compat.js build/js/jquery.min.js build/js/bootstrap.min.js build/sitemap.xml build/strings/locales.json build/index.eng.html build/strings/eng.json images
js: build/js/min.js build/js/compat.js build/js/jquery.min.js build/js/bootstrap.min.js debugjs
debugjs: build/js/jquery.jsonp-2.4.0.min.js build/js/config.js build/js/util.js build/js/persistence.js build/js/caching.js build/js/localization.js build/js/translator.js build/js/analyzer.js build/js/generator.js build/js/sandbox.js
css: build/css/min.css build/css/font-awesome.min.css build/css/bootstrap-rtl.min.css debugcss
debugcss: build/css/bootstrap.css build/css/style.css
html: build/index.html build/index.debug.html build/not-found.html
fonts: build/fonts/fontawesome-webfont.woff build/fonts/fontawesome-webfont.ttf build/fonts/fontawesome-webfont.svg build/fonts/fontawesome-webfont.eot
# Note: the min.{js,css} are equal to all.{js,css}; minification gives
# negligible improvements over just enabling gzip in the server, and
# brings with it lots of dependencies and a more complicated build.
### Directories ###
%/.d:
test -d $(@D) || mkdir -p $(@D)
touch $@
# Don't autoremove
.PRECIOUS: build/.d build/js/.d build/css/.d build/strings/.d
### JS ###
JSFILES= \
assets/js/jquery.jsonp-2.4.0.min.js \
assets/js/config.js \
build/js/locales.js \
build/js/listrequests.js \
assets/js/util.js \
assets/js/persistence.js \
assets/js/caching.js \
assets/js/localization.js \
assets/js/translator.js \
assets/js/analyzer.js \
assets/js/generator.js \
assets/js/sandbox.js
assets/js/config.js: config.conf read-conf.py
./read-conf.py -c $< js > $@
# Only create the file based on the example if it doesn't exist
# already; otherwise just give a message that the user might want to
# merge it in:
config.conf: config.conf.example
@if test -f $@; then \
touch $@; \
echo; echo You may have to merge new changes from $^ into $@; echo; \
else \
cp $^ $@; \
echo; echo You should edit $@; echo; \
fi
build/js/locales.js: assets/strings/locales.json build/js/.d
echo "config.LOCALES = `cat $<`;" > $@
build/js/listrequests.js: config.conf read-conf.py build/js/.d
echo -n "config.PAIRS = " > $@
curl -s "$(shell ./read-conf.py -c $< get APY_URL)/list?q=pairs" >> $@ || ( rm $@; false; )
echo ";" >> $@
echo -n "config.GENERATORS = " >> $@
curl -s "$(shell ./read-conf.py -c $< get APY_URL)/list?q=generators" >> $@ || ( rm $@; false; )
echo ";" >> $@
echo -n "config.ANALYZERS = " >> $@
curl -s "$(shell ./read-conf.py -c $< get APY_URL)/list?q=analyzers" >> $@ || ( rm $@; false; )
echo ";" >> $@
echo -n "config.TAGGERS = " >> $@
curl -s "$(shell ./read-conf.py -c $< get APY_URL)/list?q=taggers" >> $@ || ( rm $@; false; )
echo ";" >> $@
build/js/all.js: $(JSFILES) build/js/.d
@awk '/\xEF\xBB\xBF/{print "\nERROR: Byte Order Mark found in "FILENAME"\n"; exit(1)}' $(JSFILES)
cat $(JSFILES) > $@
build/js/min.js: build/js/all.js
cp $< $@
build/js/compat.js: assets/js/compat.js build/js/.d
cp $< $@
build/js/jquery.min.js: build/js/.d
curl -s 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js' -o $@
build/js/bootstrap.min.js: build/js/.d
curl -s 'http://netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js' -o $@
build/js/%.js: assets/js/%.js build/js/.d
cp $< $@
### HTML ###
build/index.debug.html: index.html.in debug-head.html build/l10n-rel.html build/.PIWIK_URL build/.PIWIK_SITEID build/strings/eng.json config.conf read-conf.py localise-html.py build/.d
sed -e '/@include_head@/r debug-head.html' -e '/@include_head@/r build/l10n-rel.html' -e '/@include_head@/d' -e "s%@include_piwik_url@%$(shell cat build/.PIWIK_URL)%" -e "s%@include_piwik_siteid@%$(shell cat build/.PIWIK_SITEID)%" $< > $@
./localise-html.py -c config.conf $@ build/strings/eng.json $@
# timestamp links, only double quotes supported :>
build/prod-head.html: prod-head.html build/js/all.js build/css/all.css
ts=`date +%s`; sed "s/\(href\|src\)=\"\([^\"]*\)\"/\1=\"\2?$${ts}\"/" $< > $@
build/.PIWIK_URL: config.conf read-conf.py build/.d
./read-conf.py -c $< get PIWIK_URL > $@
build/.PIWIK_SITEID: config.conf read-conf.py build/.d
./read-conf.py -c $< get PIWIK_SITEID > $@
build/index.localiseme.html: index.html.in build/prod-head.html build/l10n-rel.html build/.PIWIK_URL build/.PIWIK_SITEID
sed -e '/@include_head@/r build/prod-head.html' -e '/@include_head@/r build/l10n-rel.html' -e '/@include_head@/d' -e "s%@include_piwik_url@%$(shell cat build/.PIWIK_URL)%" -e "s%@include_piwik_siteid@%$(shell cat build/.PIWIK_SITEID)%" $< > $@
## HTML localisation
# JSON-parsing-regex ahoy:
localhtml: $(shell sed -n 's%^[^"]*"\([^"]*\)":.*%build/index.\1.html build/strings/\1.json% p' assets/strings/locales.json)
# hreflang requires iso639-1 :/ Fight ugly with ugly:
build/l10n-rel.html: assets/strings/locales.json isobork build/.d
awk 'BEGIN{while(getline<"isobork")i[$$1]=$$2} /:/{sub(/^[^"]*"/,""); sub(/".*/,""); borkd=i[$$0]; if(!borkd)borkd=$$0; print "<link rel=\"alternate\" hreflang=\""borkd"\" href=\"index."$$0".html\">"}' $^ > $@
build/index.%.html: build/strings/%.json build/index.localiseme.html config.conf read-conf.py localise-html.py
./localise-html.py -c config.conf build/index.localiseme.html $< $@
build/index.html: build/index.eng.html
cp $^ $@
build/not-found.html: build/index.html not-found.html
sed -e '/<!-- Not found warning -->/r not-found.html' $< > $@
build/strings/%.json: assets/strings/%.json config.conf read-conf.py minify-json.py build/strings/.d
@echo -n ' "@langNames": ' > [email protected]
curl -s "$(shell ./read-conf.py -c config.conf get APY_URL)/listLanguageNames?locale=$*" >> [email protected]
@echo ',' >> [email protected]
@sed "0,/{/ s/{/{\n/" $< | sed "1r [email protected]" > $@
./minify-json.py $@
# the first sed to ensure inserting after line 1 is unproblematic
build/strings/locales.json: assets/strings/locales.json build/strings/.d
cp $< $@
## Sitemap
build/.HTML_URL: config.conf read-conf.py build/.d
./read-conf.py -c $< get HTML_URL > $@
build/sitemap.xml: sitemap.xml.in build/l10n-rel.html build/.HTML_URL
sed -e 's%^<link%<xhtml:link%' -e "s%href=\"%&$(shell cat build/.HTML_URL)/%" build/l10n-rel.html > build/l10n-rel.html.tmp
sed -e "s%@include_url@%$(shell cat build/.HTML_URL)%" -e '/@include_linkrel@/r build/l10n-rel.html.tmp' -e '/@include_linkrel@/d' $< > $@
rm -f build/l10n-rel.html.tmp
# TODO: is there a way to have prerequisites of _variables_? (could do away with the intermediate file)
.INTERMEDIATE: build/.HTML_URL build/.PIWIK_SITEID build/.PIWIK_URL
### CSS ###
THEMES= cerulean cosmo cyborg darkly journal lumen paper readable sandstone simplex slate spacelab superhero united yeti
$(THEMES): % : all build/css/bootstrap.%.css build/css/.d
theme = $(filter $(THEMES), $(MAKECMDGOALS))
build/css/bootstrap.%.css: build/css/.d
curl -s 'http://maxcdn.bootstrapcdn.com/bootswatch/3.3.1/$*/bootstrap.min.css' -o $@
build/css/all.css: $(if $(theme), build/css/bootstrap.$(theme).css, assets/css/bootstrap.css) build/css/style.css build/css/.d
cat $^ > $@
build/css/min.css: build/css/all.css
cp $< $@
build/css/style.css: assets/css/style.css $(if $(theme), assets/css/themes/style.$(theme).css, ) build/css/.d
cat $^ > $@
build/css/font-awesome.min.css: build/css/.d
curl -s 'http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css' -o $@
build/css/bootstrap-rtl.min.css: build/css/.d
curl -s 'http://cdnjs.cloudflare.com/ajax/libs/bootstrap-rtl/3.1.1/css/bootstrap-rtl.min.css' -o $@
build/css/%.css: assets/css/%.css build/css/.d
cp $< $@
### Fonts ###
build/fonts/fontawesome-webfont.woff: build/fonts/.d
curl -s "http://netdna.bootstrapcdn.com/font-awesome/4.0.3/fonts/fontawesome-webfont.woff" -o $@
build/fonts/fontawesome-webfont.ttf: build/fonts/.d
curl -s "http://netdna.bootstrapcdn.com/font-awesome/4.0.3/fonts/fontawesome-webfont.ttf" -o $@
build/fonts/fontawesome-webfont.svg: build/fonts/.d
curl -s 'http://netdna.bootstrapcdn.com/font-awesome/4.0.3/fonts/fontawesome-webfont.svg' -o $@
build/fonts/fontawesome-webfont.eot: build/fonts/.d
curl -s 'http://netdna.bootstrapcdn.com/font-awesome/4.0.3/fonts/fontawesome-webfont.eot' -o $@
### Images ###
# Images just copied over
IMAGES_ASSETS=$(shell find assets/img -path '*/.svn' -prune -o -type f -print)
IMAGES_BUILD=$(patsubst assets/%, build/%, $(IMAGES_ASSETS))
build/img/%: assets/img/%
@mkdir -p $(@D)
cp $< $@
images: $(IMAGES_BUILD)
### Clean ###
clean:
rm -rf build/