#!/usr/bin/make -f
#export DH_VERBOSE=1

include /usr/share/GNUstep/debian/config.mk
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_OBJCFLAGS_MAINT_APPEND = -Wno-unknown-pragmas
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--no-undefined
d_app := $(CURDIR)/debian/edenmath.app

%:
	dh $@

override_dh_auto_build:
	buildtool generate makefile
	mv GNUmakefile_EdenMathUpgraded GNUmakefile
	sed --in-place 's/EdenMathUpgraded/EdenMath/g' GNUmakefile
	dh_auto_build -- $(optim) $(verbose) \
	  $(shell dpkg-buildflags --export=cmdline)
	icns2png --extract --size 128 --depth 32 EdenMath.icns

override_dh_clean:
	dh_clean GNUmakefile EdenMathInfo.plist

execute_before_dh_link:
	gsdh_gnustep --app
	mv EdenMath_128x128x32.png $(d_app)/usr/share/GNUstep/EdenMath.app

execute_before_dh_fixperms:
	iconv -f UTF-16BE -t UTF-8 < English.lproj/InfoPlist.strings \
	  > $(d_app)/usr/share/GNUstep/EdenMath.app/InfoPlist.strings
	chmod -x $(d_app)/usr/share/GNUstep/EdenMath.app/InfoPlist.strings \
	  $(d_app)/usr/share/GNUstep/EdenMath.app/EdenMath.icns
