#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-

include /usr/share/cdbs/1/rules/autoreconf.mk
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/gnome.mk
include /usr/share/cdbs/1/rules/utils.mk
include /usr/share/gnome-pkg-tools/1/rules/uploaders.mk
include /usr/share/gnome-pkg-tools/1/rules/gnome-version.mk
include /usr/share/gnome-pkg-tools/1/rules/gnome-get-source.mk

DEB_CONFIGURE_EXTRA_FLAGS := \
		--bindir=\$${prefix}/games \
		--libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
		--disable-gnuchess \
		--disable-scrollkeeper \
		--enable-introspection

DEB_DH_FIXPERMS_ARGS := -X/usr/games
DEB_DH_MAKESHLIBS_ARGS_gnome-games := --no-act
LDFLAGS += -Wl,-z,defs -Wl,-O1 -Wl,--as-needed

$(patsubst %,binary-install/%,$(DEB_PACKAGES)) :: binary-install/%:
	if [ -f debian/scores/$(cdbs_curpkg).inst ]; then \
		sed -e "s/@SCORE_FILES@/$(shell xargs echo < debian/scores/$(cdbs_curpkg).inst)/" debian/template_postinst \
			> debian/$(cdbs_curpkg).postinst ; \
	fi
	if [ -f debian/scores/$(cdbs_curpkg).inst ] || [ -f debian/scores/$(cdbs_curpkg).rm ]; then \
		sed -e "s/@SCORE_FILES@/$(shell cat debian/scores/$(cdbs_curpkg).* | xargs echo)/" debian/template_postrm \
			> debian/$(cdbs_curpkg).postrm ; \
	fi

$(patsubst %,binary-post-install/%,$(DEB_PACKAGES)) :: binary-post-install/%:
	if [ -d debian/$(cdbs_curpkg)/usr/games ]; then \
		chmod u+w debian/$(cdbs_curpkg)/usr/games/* ; \
	fi

binary-install/gnome-sudoku::
	dh_python2 -pgnome-sudoku

clean::
	rm -f debian/*.postinst debian/*.postrm

common-binary-post-install-arch:: list-missing
