1 # This is free and unencumbered software released into the public
2 # domain. To the extent possible under law, the author of this file
3 # waives all copyright and related or neighboring rights to it.
5 $(call include-once.
,programs.mk
)
10 npmbindir
= $(NPMROOT
)/node_modules
/.bin
11 .PRECIOUS
: $(npmbindir
)/%
13 npmbin
= $(call command-v
,$1 $(npmbindir
)/$1)
15 JSTEST ?
= $(npmbindir
)/jstest
16 JSHINT ?
= $(call npmbin
,jshint
)
18 uglifyjs_npm_package
:= uglify-js
20 UGLIFY ?
= $(call npmbin
,uglifyjs
)
21 UGLIFYFLAGS ?
= --comments \
22 --compress
$(UGLIFYCOMPRESSFLAGS
) \
23 --mangle
$(UGLIFYMANGLEFLAGS
)
25 jsstampprefix ?
= $(stampprefix
)
28 JSTESTFLAGS
+= $(if
$(JSTESTFORMAT
),--format
$(JSTESTFORMAT
))
29 JSTEST_NODE_PATH ?
= $(VPATH
)
30 JSTESTENV
+= $(if
$(JSTEST_NODE_PATH
),NODE_PATH
=$(JSTEST_NODE_PATH
))
33 jshint-stampify
= $(patsubst %.js
,$(jsstampprefix
)%.js.lint
,$1)
34 jstest-stampify
= $(patsubst %.js
,$(jsstampprefix
)%.js.
test,$1)
35 uglify-stampify
= $(patsubst %.js
,$(jsuglyprefix
)%.min.js
,$1)
37 find-js
= $(shell find
$1 $(if
$2,$2 -o
) -type f
-name
'*.js' -print)
39 UGLIFY.js
= $(UGLIFY
) $(UGLIFYFLAGS
)
40 LINT.js
= $(JSHINT
) $(JSHINTFLAGS
)
41 TEST.js
= $(JSTESTENV
) $(JSTEST
) $(JSTESTFLAGS
)
43 $(jsuglyprefix
)/%.min.js
: %.js |
$(UGLIFY
)
45 $(UGLIFY.js
) < $< > $@
47 $(jsstampprefix
)%.js.lint
: %.js |
$(JSHINT
)
52 $(jsstampprefix
)%.js.
test: %.js |
$(JSTEST
)
54 $(call quiet
,$(TEST.js
) $<,$@
)
57 $(NPM
) install $(firstword $(value
$(@F
)_npm_package
) $(@F
))