#!/usr/bin/make -f


VERSION			:=	$(shell dpkg-parsechangelog \
				|grep ^Version \
				|awk '{print $$2}' \
				|sed 's/-[0-9]\+$$//')

UPSTREAM_VERSION	:=	$(shell echo $(VERSION)|sed 's/+.*//')

LEVEL_DIR		:=	/usr/share/games/rocksndiamonds

include /usr/share/cdbs/1/rules/debhelper.mk

build/rocksndiamonds::
	make RO_GAME_DIR=$(LEVEL_DIR) sdl2

install/rocksndiamonds::
	set -e; \
	for file in postinst preinst prerm; do \
		cp debian/$$file.in debian/$$file; \
		perl -pi -e 's/#VERSION#/$(UPSTREAM_VERSION)/g' \
			debian/$$file; \
	done
	mv rocksndiamonds rocksndiamonds-bin
	install -m 0755 debian/start_binary.sh rocksndiamonds

clean::
	make clean
	rm -fr src/conftime.h rocksndiamonds-bin \
		debian/postinst debian/preinst debian/prerm
	debconf-updatepo
