#!/usr/bin/make -f include /usr/share/dpkg/pkg-info.mk # detect if build targets experimental suite (or is a draft) DEB_SUITE_EXP = $(filter experimental% UNRELEASED,$(DEB_DISTRIBUTION)) # GNU LibreJS 5.0 compatible license string # * See LICENSE = // @license magnet:?xt=urn:btih:87f119ba0b429ba17a44b4bffcab33165ebdacc0&dn=freebsd.txt BSD-2-Clause # generate documentation unless nodoc requested ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS))) DOCS = README.html README.txt MANPAGES = debian-man/terser.1 endif ESLINT = eslint --format tap MOCHA = mocha --no-timeout --reporter tap # generate manpage with help2man from --help option of Node.js script _mkman = help2man $(if $3,--name "$(strip $3)") --no-info --output $2 $1 \ || { $1 --help; false; } override_dh_auto_configure: mkdir -p node_modules for l in acorn escodegen rimraf semver source-map source-map-support; do \ ln -s /usr/share/nodejs/$$l node_modules/; \ done mkdir -p node_modules/@jridgewell ln -s /usr/share/nodejs/@jridgewell/source-map node_modules/@jridgewell override_dh_auto_build: \ debian/js/bundle.js.gz $(DOCS) $(MANPAGES) # build manpage debian-man/terser.1: debian-man/%.1: bin/% debian/js/bundle.js.gz mkdir --parents $(dir $@) $(call _mkman, $<, $@, \ JavaScript parser and mangler/compressor and beautifier toolkit) # * don't fail on experimental builds # * trick testsuite into not using mochallel # * ignore tests relying on NodeJS module astring (we use escodegen) override_dh_auto_test: $(ESLINT) lib node test/compress.js $(MOCHA) test/mocha | debian/tap-todo \ '^input sourcemaps Should preserve unmapped segments in output source map$$' \ '^spidermonkey export/import sanity test should produce a spidermonkey AST w/ .format.spidermonkey: true.$$' \ '^spidermonkey export/import sanity test should produce an AST compatible with astring$$' \ $(if $(DEB_SUITE_EXP),|| true) # install core documentation with all binary packages override_dh_installdocs: dh_installdocs -- $(DOCS) # build browser and test libraries debian/js/%.js: rollup --no-esModule -c cp --force dist/bundle.min.cjs dist/bundle.js mkdir --parents debian/js install --mode a=r,u+w -D --target-directory debian/js \ -- dist/bundle* mv debian/js/bundle.min.cjs debian/js/bundle.min.js mv --force dist/bundle.js dist/bundle.min.cjs # 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 $< > $@ %: dh $@ .SECONDARY: