#!/usr/bin/make -f

build: build-stamp
build-stamp:
	dh_testdir
	# Sometimes, you just have to be amazed at the lengths upstream
	# will go to break things in new, perverted ways. This configure
	# script uses an Imakefile to generate a Makefile that outputs
	# variable settings, that are evaled, to set configure variables,
	# used in generating the output makefile. This fails if MAKELEVEL
	# is not 0, because gnu make outputs extra verbiage which messes up
	# the eval. Thus, this hack. Make. It. Stop.
	MAKELEVEL=0 ./configure
	$(MAKE) SCOREDIR=/var/games/xbl
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	[ ! -f Makefile ] || $(MAKE) -i clean
	dh_clean config.log config.cache Makefile

binary-indep: build

binary-arch: build
	dh_testdir
	dh_testroot
	dh_clean
	dh_installdirs usr/games var/games/xbl etc/X11/app-defaults
	install bl debian/xbl/usr/games/xbl
	install -m 644 Xbl.ad debian/xbl/etc/X11/app-defaults/Xbl
	dh_installdocs xbl-README *.gif *.html
	dh_installexamples
	dh_installmenu
	dh_installman xbl.man
	dh_installchangelogs
	dh_strip
	dh_compress
	dh_fixperms
	# no longer necessary; per-user score files default
	#chown root.games debian/xbl/usr/games/xbl
	#chmod g+s debian/xbl/usr/games/xbl
	chown root.games debian/xbl/var/games/xbl
	chmod g+rws debian/xbl/var/games/xbl
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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