#!/usr/bin/make -f

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

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

CFLAGS              := $(shell dpkg-buildflags --get CFLAGS)
CPPFLAGS            := $(shell dpkg-buildflags --get CPPFLAGS)
LDFLAGS             := $(shell dpkg-buildflags --get LDFLAGS)

LDFLAGS += -Wl,-z,defs

build-arch: build-stamp
build-indep:

build-stamp:
	dh_testdir
	$(MAKE) INSTLIBDIR=/var/games/snake4 \
		INCDIR='$(CPPFLAGS)' \
		CFLAGS='$(CFLAGS)' \
		LDOPT='$(LDFLAGS)' \
		OPTIM='' \
		EXTRA_LIBS='' \
		COMPILED_BY='Debian' \
		COMPILED_DATE="`date '+%Y-%m-%d %H:%M:%S'`" \
		HOSTTYPE='Debian' \
		all snake4.score
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp snake4
	$(MAKE) clean
	dh_clean

binary-indep:

binary-arch: build-stamp
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	dh_install
	dh_installchangelogs ChangeLog
	dh_installdocs
	dh_installmenu
	dh_installdebconf
	dh_installinfo
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	chown root:games debian/snake4/var/games/snake4
	chmod 755 debian/snake4/var/games/snake4
	chown root:games debian/snake4/usr/games/snake4
	chmod 2755 debian/snake4/usr/games/snake4
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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

