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
|
#!/usr/bin/make -f
# generate documentation unless nodoc requested
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
DOCS = README.html README.txt SPECS.html SPECS.txt
endif
COPYRIGHT = 2018-2020, Andrea Giammarchi
# GNU LibreJS 5.0 compatible license string
# * See <https://www.gnu.org/software/librejs/free-your-javascript.html>
LICENSE = magnet:?xt=urn:btih:b8999bbaf509c08d127678643c515b9ab0836bae&dn=ISC.txt ISC
%:
dh $@
# pre-compress for browser use
%.gz: %
pigz --force --keep -11 -- $<
brotli --force --keep --best --suffix=.brotli -- $<
%.html: %.md
cmark-gfm $< > $@
%.txt: %.md
cmark-gfm --to plaintext $< > $@
# optimize JavaScript for browser use
# * include source-map
debian/js/es.min.js debian/js/esm.min.js: debian/js/%.min.js: %.js
debian/js/flatted.min.js: index.js
debian/js/%.min.js:
$(if $<,,$(error source missing for browser library of $*))
mkdir --parents $(dir $@)
$(strip terser --compress --mangle \
--source-map "base='$(abspath $(dir $@))',url='$(notdir $@).map'" \
--output $@ \
-- $<)
mv -f $@ $@~
$(if $(COPYRIGHT),echo '// @copyright $(COPYRIGHT)' >> $@)
$(if $(LICENSE),echo '// @license $(LICENSE)' >> $@)
cat $@~ >> $@
$(if $(LICENSE),echo '// @license-end' >> $@)
rm -f $@~
cjs/index.js: esm/index.js
mkdir --parents $(dir $@)
ascjs esm cjs
es.js: esm/index.js
rollup --config rollup/es.config.js
sed -i -e 's/^var /self./' es.js
esm.js: esm/index.js
rollup --config rollup/esm.config.js
index.js: esm/index.js
rollup --config rollup/babel.config.js
sed -i -e 's/^var /self./' index.js
debian/js/es.js debian/js/esm.js: debian/js/%.js: %.js
debian/js/flatted.js: index.js
debian/js/%.js:
$(if $<,,$(error source missing for browser library of $*))
mkdir --parents $(dir $@)
echo '// @license $(LICENSE)' >> $@
cat $< >> $@
echo '// @license-end' >> $@
override_dh_clean:
dh_clean -- $(DOCS)
override_dh_auto_configure:
mkdir -p node_modules/@rollup
ln -s /usr/share/nodejs/@rollup/plugin-babel node_modules/@rollup/
ln -s /usr/share/nodejs/rollup-plugin-terser node_modules/
override_dh_auto_build: $(DOCS) \
cjs/index.js esm/index.js \
$(patsubst %,debian/js/%.js,es esm flatted) \
$(patsubst %,debian/js/%.min.js.gz,es esm flatted)
override_dh_auto_test:
node test/index.js
override_dh_installdocs:
dh_installdocs --all -- $(DOCS)
.SECONDARY:
|