#!/usr/bin/make -f

export DPKG_EXPORT_BUILDFLAGS = 1
export DEB_BUILD_MAINT_OPTIONS := hardening=+all
export DEB_CFLAGS_MAINT_APPEND = $(shell dpkg-buildflags --get CPPFLAGS)

include /usr/share/dpkg/buildflags.mk
include /usr/share/dpkg/default.mk

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -Dsetupdb -- --with-libxml2
	dh_auto_configure -Dpatch -- --with-setupdb=../setupdb

override_dh_auto_build:
	dh_auto_build -Dsetupdb
	dh_auto_build -Dpatch
	dh_auto_build -Duninstall -- DATADIR=/usr/share/loki_update GTK=4
	dh_auto_build -- DATADIR=/usr/share/loki_update UI_LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH)/loki_update GTK=4

override_dh_auto_install:

override_dh_auto_test:

override_dh_auto_clean:
	dh_auto_clean -Dpatch
	dh_auto_clean -Dsetupdb
	dh_auto_clean -Duninstall
	dh_auto_clean

execute_after_dh_install:
	gm convert icon.xpm           debian/loki-update/usr/share/icons/hicolor/48x48/apps/com.lokigames.loki_update.png
	gm convert uninstall/icon.xpm debian/loki-update/usr/share/icons/hicolor/48x48/apps/com.lokigames.loki_uninstall.png
	chmod 755 debian/loki-update/usr/share/loki_update/detect/*.sh
	fs=`echo debian/loki-update/usr/share/loki_update/pixmaps/*.xpm | sort -u`; \
	for f in $$fs; do \
	    png=`printf '%s' "$$f" | sed -e 's@\.xpm$$@.png@g'` ; \
	    gm convert $$f $$png; \
	done ; \
	rm $$fs
