#!/usr/bin/make -f
#export DH_VERBOSE=1

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
    NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
    MAKEFLAGS += -j$(NUMJOBS)
endif

build: build-stamp
build-stamp:
	dh_testdir
	$(MAKE) CFLAGS_DEBUG="$(CFLAGS)" \
			DP_FS_BASEDIR=/usr/share/games/nexuiz \
			sdl-debug sv-debug
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp
	rm -rf debian/tmp
	$(MAKE) clean
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	mkdir -p debian/tmp
	cp darkplaces-sdl debian/tmp/nexuiz
	cp darkplaces-dedicated debian/tmp/nexuiz-server
	convert nexuiz.xpm debian/tmp/nexuiz48x48.png
	convert -scale 32x32 nexuiz.xpm debian/tmp/nexuiz.xpm
	dh_install
	
binary-indep: build install
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs 
	dh_installdocs
	dh_installexamples
	dh_installmenu
	dh_icons -pnexuiz
	dh_installman -pnexuiz debian/nexuiz.6
	dh_installman -pnexuiz-server debian/nexuiz-server.6
	dh_strip -pnexuiz --dbg-package=nexuiz-dbg
	dh_strip -pnexuiz-server --dbg-package=nexuiz-server-dbg
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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