#!/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, Andrea Giammarchi # GNU LibreJS 5.0 compatible license string # * See LICENSE = magnet:?xt=urn:btih:b8999bbaf509c08d127678643c515b9ab0836bae&dn=ISC.txt ISC override_dh_auto_build: $(DOCS) \ cjs/index.js esm/index.js debian/js/flatted.js debian/js/flatted.min.js.gz cjs/index.js: index.js mkdir --parents $(dir $@) cp $< $@ echo 'module.exports = Flatted;' >> $@ esm/index.js: index.js mkdir --parents $(dir $@) cp $< $@ echo 'export default Flatted;' >> $@ echo 'export var parse = Flatted.parse;' >> $@ echo 'export var stringify = Flatted.stringify;' >> $@ debian/js/flatted.min.js: index.js debian/js/flatted.js: index.js mkdir --parents $(dir $@) echo '// @license $(LICENSE)' >> $@ cat $< >> $@ echo '// @license-end' >> $@ override_dh_auto_test: istanbul cover test/index.js override_dh_installdocs: dh_installdocs --all -- $(DOCS) override_dh_clean: dh_clean -- $(DOCS) # optimize JavaScript for browser use # * include source-map debian/js/%.min.js: $(if $<,,$(error source missing for browser library of $*)) mkdir --parents $(dir $@) $(strip uglifyjs --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 $@~ # pre-compress for browser use %.gz: % pigz --force --keep -11 -- $< brotli --force --keep --best -- $< %.html: %.md pandoc --from gfm-raw_html --to html --standalone --output $@ $< %.txt: %.md pandoc --from gfm-raw_html --to plain --output $@ $< %: dh $@ .SECONDARY: