#!/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:: rocksndiamonds.6
	make RO_GAME_DIR=$(LEVEL_DIR) sdl

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

rocksndiamonds.6: rocksndiamonds.1
	sed 's/^\.TH ROCKSNDIAMONDS 1L/.TH ROCKSNDIAMONDS 6/' $< > $@

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