#! /usr/bin/make -f

PACKAGE = $(shell dh_listpackages)
TMP     = $(CURDIR)/debian/$(PACKAGE)
EXAMPLES = $(TMP)/usr/share/doc/$(PACKAGE)/examples

TEST_FILES=$(wildcard t/*.t)
FILTERED_TEST_FILES=$(filter-out t/shader.t, ${TEST_FILES})

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@

override_dh_auto_build:
	( cd $(CURDIR)/utils; perl glext_procs.pl )
	dh_auto_build

override_dh_auto_test:
	# run t/*.t, skip test.pl
	dh_auto_test -- TEST_FILES="$(FILTERED_TEST_FILES)" TEST_FILE=/dev/null

override_dh_auto_install:
	mv --no-clobber --verbose blib/lib/*.pl examples/
	dh_auto_install
	find $(TMP) -type f -name "*.pod" -print0 | xargs -r0 chmod -x

override_dh_installexamples:
	dh_installexamples
	find $(EXAMPLES) -type f -print0 | \
		xargs -r0 sed -i -e '1s|^#!/usr/local/bin/perl|#!/usr/bin/perl|'
	chmod -x $(EXAMPLES)/glxgears.pl
