#!/usr/bin/make -f
#
# Debug builds:
#   If the environment variable DEB_BUILD_OPTIONS contains the substring 
#   debug , then the package is built with debugging info included.
#
#   To go with this, you'll probably want to leave the binaries unstripped;
#   having the substring nostrip in DEB_BUILD_OPTIONS will achieve this.
# 
#   Alternatively, just uncomment the line below

#export DEB_BUILD_OPTIONS=debug:nostrip:$DEB_BUILD_OPTIONS

# For normal, everyday builds, you can leave DEB_BUILD_OPTIONS blank
# or unset or whatever.
#
# NOTE, as of now (2001-12-12), the gimp plugin is not included in exult-tools,
# as it requires a more recent version of gimp than is available in debian.
#
# Based on:
# Sample debian rules that uses debhelper
# GNU copyright 1997 by Joey Hess.
#
# Modified for exult and exult-tools by 
# Michael `Wumpus' Zinn <michael.z@acm.org>

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

# This is the debhelper compatability version to use.
export DH_COMPAT=3

ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
CONFIGURE_DEBUG = --enable-debug
endif

configure: configure-stamp
configure-stamp:
	dh_testdir

	# Generate configure and various other things
	sh autogen.sh

	# Run configure; at time of writing, libdir, sbindir, etc, are not used
	./configure $(CONFIGURE_DEBUG) --prefix=/usr --bindir=/usr/games --datadir=/usr/share/games --enable-exult-studio

	# Back to template land...

	touch configure-stamp

build: configure-stamp build-stamp
build-stamp:
	dh_testdir

	# Do the making :-)
	$(MAKE)

	# Back to template land...

	touch build-stamp

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

	# Clean up after ourselves
	-$(MAKE) clean

	# Back to template land...

	dh_clean

install: DH_OPTIONS=
install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Install the package into debian/tmp; dh_movefiles then puts
	# the files into debian/exult or debian/exult-tools as
	# required.
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp

	# Back to template land...

	dh_movefiles

# Build architecture-independent files here.
# Pass -i to all debhelper commands in this target to reduce clutter.
binary-indep:
	# Nothing to do here (NB if there was, prerequisites of
	# `build' and `install' should be included)

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir -a
	dh_testroot -a
#	dh_installdebconf -a
	dh_installdocs -a
	dh_installexamples -a
	dh_installmenu -a
#	dh_installlogrotate -a
#	dh_installemacsen -a
#	dh_installpam -a
#	dh_installmime -a
#	dh_installinit -a
	dh_installcron -a
#	dh_installman -a
	dh_installinfo -a
#	dh_undocumented -a
	dh_installchangelogs ChangeLog -a
	dh_strip -a
	dh_link -a
	dh_compress -a
	dh_fixperms -a
#	dh_makeshlibs -a
	dh_installdeb -a
#	dh_perl -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

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