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

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

DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

config.status: configure
	dh_testdir
	./configure --host=$(DEB_HOST_GNU_TYPE) --prefix=/usr --bindir=\$${prefix}/bin --docdir=\$${prefix}/share/doc/gbsplay --mandir=\$${prefix}/share/man --enable-nas --enable-midi --enable-devdsp --enable-stdout --enable-alsa --enable-pulse --without-xmmsplugin CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"

build: build-arch build-indep

build-arch: build-stamp

build-indep: build-stamp

build-stamp:  config.status
	dh_testdir
	$(MAKE) V=1
	touch $@

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	[ ! -f Makefile ] || $(MAKE) distclean
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	$(MAKE) prefix=$(CURDIR)/debian/gbsplay/usr contribdir=$(CURDIR)/debian/gbsplay/usr/share/doc/gbsplay/contrib exampledir=$(CURDIR)/debian/gbsplay/usr/share/doc/gbsplay/examples localedir=$(CURDIR)/debian/gbsplay/usr/share/locale install
	rm -f $(CURDIR)/debian/gbsplay/usr/share/doc/gbsplay/COPYRIGHT $(CURDIR)/debian/gbsplay/usr/share/doc/gbsplay/README
	mv $(CURDIR)/debian/gbsplay/usr/share/doc/gbsplay/HISTORY $(CURDIR)/debian/gbsplay/usr/share/doc/gbsplay/changelog

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install
