-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
163 lines (139 loc) · 4.08 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
##############
# parameters #
##############
# do the javascript stuff ?
DO_JS:=0
# should we do documentation ?
DO_DOCS:=0
# do you want to validate html?
DO_CHECKHTML:=0
# do you want to debug the makefile?
DO_MKDBG?=0
# where is the web folder?
DOCS:=docs
# do you want dependency on the Makefile itself ?
DO_ALLDEP:=1
########
# code #
########
ALL:=
PROJECT_NAME=jschess
JSCHECK:=out/$(PROJECT_NAME).stamp
JSFULL:=$(DOCS)/$(PROJECT_NAME).js
JSMIN:=$(DOCS)/$(PROJECT_NAME).min.js
JSMIN_JSMIN:=out/$(PROJECT_NAME).min.jsmin.js
JSMIN_YUI:=out/$(PROJECT_NAME).min.yui.js
JSMIN_CLOSURE:=out/$(PROJECT_NAME).min.closure.js
JSPACKFULL:=$(DOCS)/$(PROJECT_NAME).pack.js
JSPACKMIN:=$(DOCS)/$(PROJECT_NAME).pack.min.js
JSZIP:=out/$(PROJECT_NAME).zip
ifeq ($(DO_MKDBG),1)
Q=
# we are not silent in this branch
else # DO_MKDBG
Q=@
#.SILENT:
endif # DO_MKDBG
ifeq ($(DO_JS),1)
ALL+=$(JSPACKFULL) $(JSPACKMIN) $(JSZIP)
endif # DO_JS
JSDOC_FOLDER=$(DOCS)/jsdoc
JSDOC_FILE=$(DOCS)/jsdoc/index.html
ifeq ($(DO_DOCS),1)
ALL+=$(JSDOC_FILE)
endif # DO_DOCS
SOURCES_HTML_MAKO:=$(shell find templates/docs \( -type f -or -type l \) -and -name "*.mako" 2> /dev/null)
SOURCES_HTML:=$(shell pymakehelper remove_folders $(SOURCES_HTML_MAKO))
ifndef SOURCES_HTML
$(error SOURCES_HTML not set)
endif
HTMLCHECK:=out/html.stamp
ifeq ($(DO_CHECKHTML),1)
ALL+=$(HTMLCHECK)
endif # DO_CHECKHTML
# this line guarantees that if a receipe fails then the target file
# will be deleted.
.DELETE_ON_ERROR:
#########
# rules #
#########
# do not touch this rule
all: $(ALL)
@true
$(JSZIP): $(tdefs.jschess_sources)
$(info doing [$@])
$(Q)zip -qr $@ $(tdefs.jschess_sources)
$(JSCHECK): $(tdefs.jschess_sources)
$(info doing [$@])
$(Q)tools/jsl/jsl --conf=support/jsl.conf --quiet --nologo --nosummary --nofilelisting $(tdefs.jschess_sources)
$(Q)pymakehelper only_print_on_error gjslint --flagfile support/gjslint.cfg $(tdefs.jschess_sources)
$(Q)node_modules/jshint/bin/jshint $(tdefs.jschess_sources)
$(Q)node_modules/jslint/bin/jslint.js --browser --terse --todo --plusplus --forin --vars --sloppy --white --config support/jslintrc $(tdefs.jschess_sources) 2> /dev/null
$(Q)pymakehelper touch_mkdir $@
$(JSFULL): $(tdefs.jschess_sources) $(JSCHECK)
$(info doing [$@])
$(Q)mkdir -p $(dir $@)
$(Q)cat $(tdefs.jschess_sources) > $@
$(JSMIN): $(JSFULL)
$(info doing [$@])
$(Q)mkdir -p $(dir $@)
$(Q)tools/jsmin < $< > $(JSMIN_JSMIN)
$(Q)yui-compressor $< -o $(JSMIN_YUI)
$(Q)cp $(JSMIN_YUI) $@
# $(Q)cp $(JSMIN_CLOSURE) $@
# $(Q)tools/closure.jar --jscomp_error '*' --externs templates/out/src/externs.js.mako --jscomp_off checkTypes $< --js_output_file $(JSMIN_CLOSURE)
$(JSPACKFULL): $(JSFULL)
$(info doing [$@])
$(Q)mkdir -p $(dir $@)
$(Q)cat $(tdefs.jschess_depslist) $(JSFULL) > $@
$(JSPACKMIN): $(JSMIN)
$(info doing [$@])
$(Q)mkdir -p $(dir $@)
$(Q)cat $(tdefs.jschess_depslist) $(JSMIN) > $@
$(JSDOC_FILE): $(tdefs.jschess_sources)
$(info doing [$@])
$(Q)rm -rf jsdoc
$(Q)mkdir -p $(dir $@)
$(Q)nodejs node_modules/jsdoc/jsdoc.js -d $(JSDOC_FOLDER) -c support/jsdoc.json out/src 1> /dev/null
.PHONY: check_js
check_js: $(JSCHECK)
$(info doing [$@])
.PHONY: check_html
check_html: $(HTMLCHECK)
$(info doing [$@])
.PHONY: check_grep
check_grep:
$(info doing [$@])
$(Q)pymakehelper only_print_on_error git grep "\"" src/
$(Q)pymakehelper only_print_on_error git grep " $$" src/
$(Q)pymakehelper only_print_on_error git grep "eval" src/
.PHONY: check_all
check_all: check_grep
.PHONY: jsdoc
jsdoc: $(JSDOC_FILE)
$(info doing [$@])
.PHONY: jsdoc_rm
jsdoc_rm:
$(info doing [$@])
$(Q)rm -rf $(JSDOC_FOLDER)
.PHONY: debug
debug:
$(info ALL is $(ALL))
$(info JSFULL is $(JSFULL))
$(info JSMIN is $(JSMIN))
$(info SOURCES_HTML is $(SOURCES_HTML))
.PHONY: sloccount
sloccount:
$(info doing [$@])
$(Q)sloccount .
$(HTMLCHECK): $(SOURCES_HTML)
$(info doing [$@])
$(Q)tidy -errors -q -utf8 $(SOURCES_HTML)
$(Q)pymakehelper only_print_on_error node_modules/.bin/htmlhint $(SOURCES_HTML)
$(Q)pymakehelper touch_mkdir $@
##########
# alldep #
##########
ifeq ($(DO_ALLDEP),1)
.EXTRA_PREREQS+=$(foreach mk, ${MAKEFILE_LIST},$(abspath ${mk}))
endif # DO_ALLDEP