#!/usr/bin/make -f
#
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

#include /usr/share/quilt/quilt.make

export DH_OPTIONS=
export DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


configure-stamp:
	dh_testdir
	dh_autoreconf
	./configure \
	--prefix=/usr \
	--mandir=\$${prefix}/share/man
	touch configure-stamp


build-arch-stamp: configure-stamp
	dh_testdir
	$(MAKE)
	touch build-arch-stamp


build-arch: DH_OPTIONS=-a
build-arch: build-arch-stamp

install-arch: build-arch-stamp
	rm -f config.log
	dh_testdir
	dh_testroot
	dh_prep
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
	dh_installdirs
	dh_install -Xkeymap.example -Xconfig.example
	dh_installdocs AUTHORS README THANKS TODO
	dh_installexamples config.example keymap.example
	#remove rpath from /usr/lib/moc/decoder_plugins/libsidplay2_decoder.so
	chrpath -d $(CURDIR)/debian/moc/usr/lib/moc/decoder_plugins/libsidplay2_decoder.so
	dh_installmenu
	dh_installman
	#dh_installchangelogs debian/changelog.svn
	dh_installchangelogs NEWS
	dh_strip
	dh_lintian
	dh_link
	dh_compress
	dh_fixperms

binary-arch: DH_options=-a
binary-arch: install-arch
	dh_installdeb
	dh_shlibdeps -- --warnings=0
	dh_gencontrol
	dh_md5sums
	dh_builddeb


binary: binary-arch

binary-indep:

build:
	@echo "*** Nothing to do for build target ***"

clean:  
	dh_testdir
	dh_testroot
	#[ ! -f Makefile ] || $(MAKE) distclean
	dh_autoreconf_clean
	dh_clean

.PHONY: configure build-arch build-indep build install-arch install-indep binary-arch binary-indep binary clean stampdir prepare unpack
