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

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

js-compressor := $(or $(notdir $(shell which uglifyjs)),yui-compressor)

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# This has to be exported to make some magic below work.
export DH_OPTIONS


%:
	dh $@

override_dh_auto_test-arch:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	tape test/unit/*
endif

override_dh_install-arch:
	dh_install
	chmod 644 $(CURDIR)/debian/node-websocket/usr/lib/nodejs/websocket/build/Release/*.node

override_dh_auto_clean:
	rm -rf debian/build
	rm -rf build
	dh_auto_clean

override_dh_auto_build-indep:
	dh_auto_build
	for _FILE in index.js lib/*.js vendor/*.js ; \
	do \
		install -D $${_FILE} debian/build/$${_FILE}; \
		$(js-compressor)  -o debian/build/$$(dirname $${_FILE})/$$(basename $${_FILE} .js).min.js $${_FILE}; \
	done

