#!/usr/bin/make -f
#export DH_VERBOSE=1


DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = ${INSTALL} -p -o root -g root  -m 755

#ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
#	CFLAGS += -g
#endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif

config.status: configure
	dh_testdir
	./configure --host=$(DEB_HOST_GNU_TYPE) \
                    --build=$(DEB_BUILD_GNU_TYPE) \
                    --prefix=/usr \
                    --mandir=\$${prefix}/share/man \
                    --with-data-dir=\$${prefix}/share/games/adonthell \
                    --with-adonthell-binary=/usr/games/adonthell \
                    --bindir=\$${prefix}/games

build: build-stamp

build-stamp:  config.status
	dh_testdir
	$(MAKE) INSTALL_PROGRAM="$(INSTALL_PROGRAM)" \
                DESTDIR="$(CURDIR)/debian/adonthell-data"
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp 

	-$(MAKE) distclean
	-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
	-rm -f config.status
	-rm -f `find . -name "*~"`
	-rm -f `find . -name "*.pyc"`

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	$(MAKE) install DESTDIR="$(CURDIR)/debian/adonthell-data" \
                INSTALL_PROGRAM="$(INSTALL_PROGRAM)"
#                gamedatadir="$(CURDIR)/debian/adonthell-data/usr/share/games/adonthell-data"


# 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_installmenu
	dh_installman debian/adonthell-wastesedge.6
	dh_installchangelogs ChangeLog
	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 
