#!/usr/bin/make -f
# -*- mode: makefile -*-

include /usr/share/quilt/quilt.make

export LDFLAGS += -Wl,--as-needed -Wl,-z,defs

build: build-stamp
build-stamp: $(QUILT_STAMPFN) debian/gmult.6
	# we patch configure.ac, so regenerate configure
	[ -d m4 ] || mkdir m4
	autoreconf

	dh build --before configure
	dh_auto_configure -- --bindir='$${prefix}/games'
	dh_auto_build

	# We don't run dh_auto_test because `make check` fails
	# due to intltool-update looking in .pc/*...
	
	dh build --after test
	touch $@

debian/gmult.6: debian/gmult.dbk
	xsltproc --nonet -o $@ \
	  /usr/share/xml/docbook/stylesheet/nwalsh/manpages/docbook.xsl $<

clean: clean-patched unpatch
clean-patched:
	dh clean
	rm -f debian/gmult.6
	rm -f po/stamp-po po/*.gmo
	rm -rf configure m4

install: build
	# upstream ships an empty changelog, installing it would be useless.
	# Removing it is the easiest way to prevent dh_installchangelog from
	# installing it.
	[ -s ChangeLog -o ! -f ChangeLog ] || rm ChangeLog

	dh install

binary-arch: install
	dh binary-arch

binary: binary-arch

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

