#!/usr/bin/make -f

DPKG_EXPORT_BUILDFLAGS = 1
export DEB_BUILD_MAINT_OPTIONS=harderning=+all

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/dpkg/pkg-info.mk
include /usr/share/dpkg/buildflags.mk

UPSTREAM_VERSION := $(shell echo $(DEB_VERSION_UPSTREAM) | sed 's/+.*//')
LEVEL_DIR := /usr/share/games/rocksndiamonds

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
