#!/usr/bin/make -f
# vim: set noet ft=make
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

BIN:=$(shell ls tools/)
MANPAGE:=$(BIN:=.1)
FILEEXCLUDEDSOURCE:=$(shell ls dh_nodejs/dh_*)
export NPMIGNOREDEFAULT=$(shell pwd)/dh_nodejs/npmignore.default

%:
	dh $@

%.1:
	PERL5LIB=lib help2man -n $* -N --help-option=-h ./tools/$* > $*.1

override_dh_auto_configure: lib/Debian/Debhelper/Buildsystem/nodejs.pm
	dh_auto_configure

lib/Debian/Debhelper/Buildsystem/nodejs.pm: $(FILEEXCLUDEDSOURCE)
	echo OK
	./dh_nodejs/mk_regexp lib/Debian/Debhelper/Buildsystem/nodejs.pm \
		autopkgtest/runner

override_dh_auto_install: lib/Debian/Debhelper/Buildsystem/nodejs.pm $(MANPAGE)
	dh_auto_install

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	dh_auto_test
	debian/tests/pkg-js-autopkgtest
endif
