#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
# export DH_VERBOSE=1

# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
export INSTALL_PREFIX  = /usr
#xport INSTALL_DESTDIR = /debian/chroma$(INSTALL_PREFIX)
export INSTALL_DESTDIR = /debian/tmp$(INSTALL_PREFIX)

%:
	dh $@

override_dh_auto_configure:
	mkdir -p $(CURDIR)/locale/ru_RU/LC_MESSAGES/
	msgfmt -c -v -o $(CURDIR)/locale/ru_RU/LC_MESSAGES/chroma.mo $(CURDIR)/debian/ru_RU.po
	dh_auto_configure --

override_dh_install:
	icotool -b 32 -x $(CURDIR)/iconcurses.ico
	install -Dm 0644 $(CURDIR)/iconcurses_*_16x16x32.png $(CURDIR)$(INSTALL_DESTDIR)/share/icons/hicolor/16x16/apps/chroma-curses.png
	install -Dm 0644 $(CURDIR)/iconcurses_*_32x32x32.png $(CURDIR)$(INSTALL_DESTDIR)/share/icons/hicolor/32x32/apps/chroma-curses.png
	install -Dm 0644 $(CURDIR)/iconcurses_*_48x48x32.png $(CURDIR)$(INSTALL_DESTDIR)/share/icons/hicolor/48x48/apps/chroma-curses.png
	icotool -b 32 -x $(CURDIR)/iconsdl.ico
	install -Dm 0644 $(CURDIR)/iconsdl_*_16x16x32.png $(CURDIR)$(INSTALL_DESTDIR)/share/icons/hicolor/16x16/apps/chroma.png
	install -Dm 0644 $(CURDIR)/iconsdl_*_32x32x32.png $(CURDIR)$(INSTALL_DESTDIR)/share/icons/hicolor/32x32/apps/chroma.png
	install -Dm 0644 $(CURDIR)/iconsdl_*_48x48x32.png $(CURDIR)$(INSTALL_DESTDIR)/share/icons/hicolor/48x48/apps/chroma.png
	install -dm 0755 $(CURDIR)$(INSTALL_DESTDIR)/share/applications/
	echo '[Desktop Entry]\nName=Chroma\nGenericName=Chroma (console version)\nComment=Minimal, text based version of Chroma.\nExec=chroma-curses\nIcon=chroma-curses\nCategories=Game;BlocksGame;\nType=Application\nTerminal=true\nNoDisplay=true' > $(CURDIR)$(INSTALL_DESTDIR)/share/applications/chroma-curses.desktop
	echo '[Desktop Entry]\nName=Chroma\nGenericName=Chroma\nComment=Chroma is an abstract puzzle game.\nExec=chroma\nIcon=chroma\nCategories=Game;BlocksGame;\nType=Application' > $(CURDIR)$(INSTALL_DESTDIR)/share/applications/chroma.desktop
	dh_install --

override_dh_missing:
	dh_missing --fail-missing
