#!/usr/bin/make -f
# -*- makefile -*-
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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

TARGET  := $(CURDIR)/debian/unnethack

include /usr/share/quilt/quilt.make

build: build-stamp

build-stamp: $(QUILT_STAMPFN)
	dh_testdir

	# compile the package.
	./configure --enable-curses-graphics --prefix=/opt/unnethack

	touch $@

clean: unpatch
	dh_testdir
	dh_testroot
	rm -f build-stamp

	# clean up after the build process.
	make clean

	dh_clean 

install: build
	dh_testdir
	dh_testroot
	dh_prep  
	dh_installdirs

	DESTDIR=$(TARGET) make install 
	#mkdir -p $(TARGET)/opt/unnethack
	mkdir -p $(TARGET)/home/user
	mkdir -p $(TARGET)/usr/bin
	mkdir -p $(TARGET)/usr/share/applications/hildon
	#cp -rfp /opt/unnethack/* $(TARGET)/opt/unnethack
	#chown -R games:bin $(TARGET)/opt/unnethack
	#chmod +s $(TARGET)/opt/unnethack/unnethackdir/unnethack
	install debian/unnethackrc $(TARGET)/home/user/.unnethackrc
	ln -s /opt/unnethack/bin/unnethack $(TARGET)/usr/bin/unnethack
	chmod +x $(TARGET)/usr/bin/unnethack
	cp debian/unnethack.desktop $(TARGET)/usr/share/applications/hildon/

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

# Build architecture-dependent files here.
binary-arch: install
	dh_testdir
	dh_testroot
	dh_installchangelogs 
	dh_installdocs
	dh_installexamples
	dh_install
#	dh_installmenu
#	dh_installdebconf
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_python
#	dh_installinit
#	dh_installcron
#	dh_installinfo
	dh_lintian
	dh_installman
	dh_link
	dh_strip
	dh_compress
#	dh_fixperms
#	dh_perl
#	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps -l"$(TARGET)/opt/unnethack/bin"
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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

