#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# Stuff taken from autotools-dev
export DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

include /usr/share/quilt/quilt.make

ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
        confflags += --build $(DEB_HOST_GNU_TYPE)
else
        confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
endif

configure: configure-stamp
configure-stamp:
	dh_testdir
	./configure $(confflags) --prefix=/opt --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --bindir=\$${prefix}/burgerspace --datadir=\$${prefix}

	touch configure-stamp

build: configure-stamp build-stamp
build-stamp: $(QUILT_STAMPFN)
	dh_testdir

	$(MAKE)

	touch build-stamp

clean: unpatch
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp

	[ ! -f Makefile ] || $(MAKE) distclean

	dh_clean

        # Update config.sub and config.guess
	-test -r /usr/share/misc/config.sub && \
	  cp -f /usr/share/misc/config.sub config.sub
	-test -r /usr/share/misc/config.guess && \
	  cp -f /usr/share/misc/config.guess config.guess

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	$(MAKE) DESTDIR=$(CURDIR)/debian/burgerspace install
	rm -rf $(CURDIR)/debian/burgerspace/usr/share/doc/burgerspace-*

	cp -p $(CURDIR)/debian/data/burgerspace-64x64.png $(CURDIR)/debian/burgerspace/usr/share/icons/hicolor/scalable/hildon/burgerspace.png
	cp -p $(CURDIR)/debian/data/burgerspace-48x48.png $(CURDIR)/debian/burgerspace/usr/share/icons/hicolor/48x48/hildon/burgerspace.png
	cp -p $(CURDIR)/src/images/burgerspace.png $(CURDIR)/debian/burgerspace/usr/share/icons/hicolor/32x32/hildon/
	cp -p $(CURDIR)/debian/data/burgerspace.desktop $(CURDIR)/debian/burgerspace/usr/share/applications/hildon
	rm -rf $(CURDIR)/debian/burgerspace/opt/applications
	rm -rf $(CURDIR)/debian/burgerspace/opt/pixmaps

# 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_installdocs
	dh_installcron
	dh_installman
	dh_installchangelogs NEWS
	dh_link
	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 configure
