#!/usr/bin/make -f

TMPDIR=maelstrom
BINDIR=debian/${TMPDIR}/usr/games
LIBDIR=debian/${TMPDIR}/usr/lib/games/maelstrom
BMPDIR=debian/${TMPDIR}/usr/share/games/maelstrom
ICONDIR=debian/${TMPDIR}/usr/share/icons/hicolor/48x48/apps

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

export DEB_CFLAGS_MAINT_APPEND = -Wall
export DEB_CXXFLAGS_MAINT_APPEND = -Wall

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
	  --bindir='$${exec_prefix}/games' \
	  --datadir='$${prefix}/share/games' \
	  --localstatedir=/var/games \
	  --libdir='$${exec_prefix}/lib/games/maelstrom'

execute_after_dh_auto_install:
#move lib files
	mv ${BINDIR}/Images ${BMPDIR}
	mv ${BINDIR}/icon.* ${BMPDIR}
	mv ${BINDIR}/Maelstrom_* ${LIBDIR}
	sh debian/handle_underscores ${BMPDIR}
	sh debian/handle_underscores ${LIBDIR}
# highscores should be in /var/games this is handled by postinst and
# postrm as highscore files shouldn't be overwritten during updates etc.
	mv ${BINDIR}/Maelstrom-Scores ${LIBDIR}/Maelstrom-Scores.debian
	chmod 644 ${LIBDIR}/Maelstrom-Scores.debian
	rm -f ${BMPDIR}/Images/Makefile*
# PNG icon for the desktop file
	convert icon.xpm ${ICONDIR}/maelstrom.png

override_dh_installchangelogs:
	dh_installchangelogs Changelog

execute_after_dh_fixperms:
	chown root:games ${BINDIR}/Maelstrom
	chmod 2755 ${BINDIR}/Maelstrom
