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

include /usr/share/GNUstep/debian/config.mk
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
d_app := $(CURDIR)/debian/gtamsanalyzer.app

%:
	dh $@ --sourcedirectory=Source

override_dh_auto_build:
	dh_auto_build -- $(optim) $(verbose) \
	  $(shell dpkg-buildflags --export=cmdline)

override_dh_link:
	gsdh_gnustep
	dh_installdirs usr/share/GNUstep
	mv $(d_app)$(GNUSTEP_SYSTEM_APPS)/GTAMSAnalyzer.app/Resources \
	  $(d_app)/usr/share/GNUstep/GTAMSAnalyzer.app
	dh_link /usr/share/GNUstep/GTAMSAnalyzer.app \
	  $(GNUSTEP_SYSTEM_APPS)/GTAMSAnalyzer.app/Resources
	convert Source/largeApp.tif -resize 64x64 \
	  $(d_app)/usr/share/GNUstep/GTAMSAnalyzer.app/app-icon.png
# Convert .strings file to UTF-8 to placate lintian.
	iconv -f UTF-16BE -t UTF-8 Source/FindPanel.strings > \
	  $(d_app)/usr/share/GNUstep/GTAMSAnalyzer.app/FindPanel.strings

override_dh_fixperms:
	dh_fixperms
	rm $(d_app)/usr/share/GNUstep/*.app/*.desktop
	find $(d_app)/usr/share/GNUstep -name \*.tif* -exec chmod -x '{}' \;
	chmod -x $(d_app)/usr/share/GNUstep/*.app/*.strings
