-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
111 lines (95 loc) · 3.79 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
SHELL := /bin/bash
CLOSURE_COMPILER=java -jar tools/closure-compiler/compiler.jar \
--warning_level VERBOSE \
--language_in ECMASCRIPT5 \
--compilation_level ADVANCED_OPTIMIZATIONS \
--charset US-ASCII
# Don't specify --charset=UTF-8. If we do, then non-ascii codepoints
# that do not correspond to line terminators are converted
# to UTF-8 sequences instead of being emitted as ASCII.
# This makes the resulting JavaScript less portable.
YUI_COMPRESSOR=java -jar tools/yui-compressor/yuicompressor-2.4.4.jar \
--charset UTF-8
TAR_ROOT=distrib/google-code-prettify
all: distrib
clean:
rm -rf distrib.tstamp distrib src/prettify.js src/run_prettify.js
src/prettify.js: js-modules/*.js js-modules/*.pl
@if [ -e "$@" ]; then chmod +w "$@"; fi
@perl js-modules/js_include.pl "$$(basename $@)" > "$@"
@if [ -e "$@" ]; then chmod -w "$@"; fi
src/run_prettify.js: js-modules/*.js js-modules/*.pl
@if [ -e "$@" ]; then chmod +w "$@"; fi
@perl js-modules/js_include.pl "$$(basename $@)" > "$@"
@if [ -e "$@" ]; then chmod -w "$@"; fi
distrib: distrib.tstamp distrib/prettify-small.tgz distrib/prettify-small.zip distrib/prettify-small.tar.bz2
@wc -c distrib/prettify-small.{tar.bz2,tgz,zip} \
| grep -v total
distrib.tstamp: src/prettify.js src/run_prettify.js src/*.js src/*.css
@echo Compiling
@mkdir -p $(TAR_ROOT)
@for f in src/*.css; do \
$(YUI_COMPRESSOR) --type css $$f \
> $(TAR_ROOT)/$$(basename $$f); \
wc -c $$f $(TAR_ROOT)/$$(basename $$f) \
| grep -v total; \
done
@$(CLOSURE_COMPILER) --js src/prettify.js \
--externs tools/closure-compiler/console-externs.js \
--externs tools/closure-compiler/amd-externs.js \
--define IN_GLOBAL_SCOPE=true \
--output_wrapper='!function(){%output%}()' \
> $(TAR_ROOT)/prettify.js
@wc -c src/prettify.js $(TAR_ROOT)/prettify.js \
| grep -v total
@$(CLOSURE_COMPILER) --js src/run_prettify.js \
--externs tools/closure-compiler/console-externs.js \
--externs tools/closure-compiler/amd-externs.js \
--define IN_GLOBAL_SCOPE=false \
--output_wrapper='!function(){%output%}()' \
> $(TAR_ROOT)/run_prettify.js
@wc -c src/run_prettify.js $(TAR_ROOT)/run_prettify.js \
| grep -v total
@for f in src/lang*.js; do \
if [ $$f -nt $(TAR_ROOT)/$$(basename $$f) ]; then \
$(CLOSURE_COMPILER) --js $$f --externs js-modules/externs.js \
| perl -pe 's/\bPR\.PR_ATTRIB_NAME\b/"atn"/g; \
s/\bPR\.PR_ATTRIB_VALUE\b/"atv"/g; \
s/\bPR\.PR_COMMENT\b/"com"/g; \
s/\bPR\.PR_DECLARATION\b/"dec"/g; \
s/\bPR\.PR_KEYWORD\b/"kwd"/g; \
s/\bPR\.PR_LITERAL\b/"lit"/g; \
s/\bPR\.PR_PLAIN\b/"pln"/g; \
s/\bPR\.PR_PUNCTUATION\b/"pun"/g; \
s/\bPR\.PR_STRING\b/"str"/g; \
s/\bPR\.PR_TAG\b/"tag"/g; \
s/\bPR\.PR_TYPE\b/"typ"/g;' \
> $(TAR_ROOT)/$$(basename $$f); \
wc -c $$f $(TAR_ROOT)/$$(basename $$f) \
| grep -v total; \
fi \
done
@touch distrib.tstamp
lang-aliases : lang-aliases.tstamp
lang-aliases.tstamp : distrib.tstamp
@tools/lang-handler-aliases.sh \
distrib/google-code-prettify \
| perl -ne 'system("cp $$1 $$2") if m/^(\S+) (\S+)$$/ && ! -e $$2' \
&& touch lang-aliases.tstamp
%.tgz: %.tar
@gzip -c -9 $^ > $@
%.tar.bz2: %.tar
@bzip2 -k -9f $^
distrib/prettify-small.tar: distrib.tstamp
tar cf $@ -C distrib google-code-prettify
distrib/prettify-small.zip: distrib.tstamp
@pushd distrib >& /dev/null; \
rm -f ../$@; \
zip -q -9 -r ../$@ google-code-prettify; \
popd >& /dev/null
distrib/prettify.tar: distrib.tstamp
mkdir -p distrib/sources/google-code-prettify
cp -fr CHANGES.html COPYING README.html Makefile \
examples js-modules src styles tests tools \
distrib/sources/google-code-prettify
tar cf distrib/prettify.tar -C distrib/sources google-code-prettify