#! /usr/bin/make -f

PACKAGE = $(shell dh_listpackages)
TMP     = $(CURDIR)/debian/$(PACKAGE)
EXAMPLES = $(TMP)/usr/share/doc/$(PACKAGE)/examples
ARCHLIB := $(shell perl -MConfig -e 'print $$Config{vendorarch}')

TEST_FILES=$(wildcard t/*.t)

export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow

%:
	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="$(TEST_FILES)" TEST_FILE=/dev/null

override_dh_auto_install:
	dh_auto_install
	chmod -x $(TMP)/$(ARCHLIB)/*.pod \
		$(TMP)/$(ARCHLIB)/OpenGL/*.pod

override_dh_installchangelogs:
	dh_installchangelogs Release_Notes

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)/README $(EXAMPLES)/*.txt $(EXAMPLES)/stan.ppm \
		$(EXAMPLES)/spaceship.nff $(EXAMPLES)/wolf.bin