#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

export DH_VERBOSE=1

# generate documentation unless nodoc requested
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
DOCS = README.html README.txt
CHANGELOGS = CHANGELOG.html CHANGELOG.txt
endif

%:
	dh $@

%.html: %.md
	pandoc --from gfm-raw_html --to html --standalone --output $@ $<

%.txt: %.md
	pandoc --from gfm-raw_html --to plain --output $@ $<

override_dh_clean:
	dh_clean -- $(DOCS) $(CHANGELOGS)
	rm -rf dist dist-node .build

override_dh_auto_build: $(DOCS) $(CHANGELOGS)
	mkdir -p node_modules/@types
	ln -sfn /usr/share/nodejs/@types/node node_modules/@types/node
	bash scripts/build.sh --no-pack

execute_after_dh_install:
	# CLI binary lives only in the Node build (./dist-node/bin); strip it
	# from the installed module since we don't ship a uuid binary package
	rm -rf debian/node-uuid/usr/share/nodejs/uuid/dist-node/bin
