#!/usr/bin/make -f
# -*- makefile -*-

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

SHLIBSDIR = debian/node-ws/usr/lib/nodejs/ws/lib
SHLIBS = bufferutil.node validation.node

%:
	dh $@

override_dh_auto_build:
	dh_auto_build
	debian/rules debian/wscat.1

override_dh_auto_test:
	echo "skipping tests; test dependencies not yet in debian"

# since we're building the native libs, ignore the fallbacks
# also have to rename .node to .so so they are detected by dh_strip dh_shlibdeps etc
override_dh_install:
	dh_install -Xfallback.js -XValidation.js -XBufferUtil.js
	cd $(SHLIBSDIR) && { \
	  chmod -x $(SHLIBS); \
	  for i in $(SHLIBS); do mv "$$i" "$${i%.node}.so"; done; }

# restore .node name
override_dh_shlibdeps:
	dh_shlibdeps
	cd $(SHLIBSDIR) && { \
	  mv validation.so Validation.node; \
	  mv bufferutil.so BufferUtil.node; }

override_dh_installchangelogs:
	dh_installchangelogs History.md

debian/wscat.1:
	help2man -N -n "Communicate over websocket" debian/wscat -o "$@"

.PHONY: debian/clean
