Debian Codegraph @

debian/rules

raw
1 #!/usr/bin/make -f
2
3 # generate documentation unless nodoc requested
4 ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
5 DOCS = README.html README.txt
6 endif
7
8 # resolve copyright from upstream hint, or fail
9 COPYRIGHT = $(shell grep -Po '^Copyright( \(c\))? \K.*' LICENSE)
10 $(if $(COPYRIGHT),,$(error ERROR: Failed to resolve copyright hint))
11
12 # GNU LibreJS 5.0 compatible license string
13 # * See <https://www.gnu.org/software/librejs/free-your-javascript.html>
14 LICENSE = magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
15
16 override_dh_auto_build: $(DOCS) \
17 debian/js/rbtree.js debian/js/rbtree.min.js.gz
18
19 override_dh_auto_test:
20 tape test/*.js
21
22 override_dh_installdocs:
23 dh_installdocs --all -- $(DOCS)
24
25 override_dh_clean:
26 dh_clean -- $(DOCS)
27
28 debian/js/rbtree.min.js: rbtree.js
29 debian/js/rbtree.js: rbtree.js
30 mkdir --parents $(dir $@)
31 echo '// @copyright $(COPYRIGHT)' >> $@
32 echo '// @license $(LICENSE)' >> $@
33 cat $< >> $@
34 echo '// @license-end' >> $@
35
36 # optimize JavaScript for browser use
37 # * include source-map
38 debian/js/%.min.js:
39 $(if $<,,$(error source missing for browser library of $*))
40 mkdir --parents $(dir $@)
41 $(strip uglifyjs --compress --mangle \
42 --source-map "base='$(abspath $(dir $@))',url='$(notdir $@).map'" \
43 --output $@ \
44 -- $<)
45 mv -f $@ $@~
46 $(if $(COPYRIGHT),echo '// @copyright $(COPYRIGHT)' >> $@)
47 $(if $(LICENSE),echo '// @license $(LICENSE)' >> $@)
48 cat $@~ >> $@
49 $(if $(LICENSE),echo '// @license-end' >> $@)
50 rm -f $@~
51
52 # pre-compress for browser use
53 %.gz: %
54 pigz --force --keep -11 -- $<
55 brotli --force --keep --best -- $<
56
57 %.html: %.md
58 pandoc --from gfm-raw_html --to html --standalone --output $@ $<
59
60 %.txt: %.md
61 pandoc --from gfm-raw_html --to plain --output $@ $<
62
63 %:
64 dh $@
65
66 .SECONDARY: