#! /usr/bin/make -f
# This file is public domain software, originally written by Joey Hess.

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

# This is the debhelper compatibility version to use.
export DH_COMPAT=2

tmp	:= $(shell pwd)/debian/tmp

ifeq ($(DEB_BUILD_GNU_TYPE),)
RETARGET=
else
RETARGET=	--host=$(DEB_BUILD_GNU_TYPE)
endif

configure: configure-stamp
configure-stamp:
	dh_testdir
	# Add here commands to configure the package.
#	[ -d CVS ] && tools/cvs2cl/cvs2cl.pl
	./bootstrap
	./configure --prefix=/usr $(RETARGET) --bindir=/usr/games \
		    --mandir=\$${prefix}/share/man \
		    --infodir=\$${prefix}/share/info \
#		    --with-3dfx=GL

	touch configure-stamp

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

	# Add here commands to compile the package.
	$(MAKE)
	$(MAKE) changelog

	touch build-stamp

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

	# Add here commands to clean up after the build process.
	-$(MAKE) distclean

	dh_clean

install:
install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Add here commands to install the package into debian/tmp.
	$(MAKE) prefix=$(tmp)/usr bindir=$(tmp)/usr/games install
	mkdir $(tmp)/etc
	cp debian/quakeforge.conf $(tmp)/etc

	dh_movefiles

# Build architecture-independent files here.
# Pass -i to all debhelper commands in this target to reduce clutter.
binary-indep: DH_OPTIONS=-i
binary-indep: build install
# We don't have any packages with Architecture: all

# Build architecture-dependent files here.
# Pass -a to all debhelper commands in this target to reduce clutter.
binary-arch: DH_OPTIONS=-a
binary-arch: build install
	dh_testversion 2
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installexamples
	dh_installmenu
	dh_undocumented
	dh_installchangelogs ChangeLog
	dh_strip
	dh_link
	dh_compress
	dh_fixperms
	# You may want to make some executables suid here.
	chmod 4755 debian/qf-client-svga/usr/games/qf-client-svga
	-chmod 4755 debian/qf-client-3dfx/usr/games/qf-client-3dfx
	dh_suidregister
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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