#!/usr/bin/make -f

PACKAGE = $(shell dh_listpackages)
TMP     = $(CURDIR)/debian/$(PACKAGE)

DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH)

CFLAGS = -Wall -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
  CFLAGS += -O0
else
  ifeq (sparc,$(DEB_HOST_ARCH))
    CFLAGS+="-O1"
  else
    CFLAGS+="-O2"
  endif
endif

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- OPTIMIZE="$(CFLAGS)"

override_dh_installexamples:
	dh_installexamples
	sed -i '1s|^#!/opt/bin/perl|#!/usr/bin/perl|' $(TMP)/usr/share/doc/$(PACKAGE)/examples/*
