#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# try resolve from shlibdep of libnodeXX, or use full nodejs version
NODEJS_VERSION = $(shell \
 grep -Po '^shlibs:Depends=.*libnode\d+ \(>= \K\S+(?=\))' \
  debian/node-node-expat.substvars \
 || dpkg-query --showformat='$${source:Version}' --show nodejs)

override_dh_auto_configure:
	node-gyp configure

override_dh_auto_build:
	node-gyp rebuild

override_dh_auto_test:
	NODE_PATH=lib vows --spec ./test/**/*.js

execute_after_dh_install:
	find debian/node-node-expat/usr/lib -name *.node -exec chmod 644 '{}' \;

override_dh_gencontrol:
	dh_gencontrol -- -V"nodejs:Depends=$(NODEJS_VERSION)"

%:
	dh $@
