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

include /usr/share/GNUstep/debian/config.mk
export DEB_LDFLAGS_MAINT_APPEND := -Wl,--no-undefined -Wl,--as-needed
d_app := $(CURDIR)/debian/gtamsanalyzer.app

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
optim := debug=yes
endif

%:
	dh $@ --parallel

override_dh_auto_build:
	$(MAKE) -C Source $(optim) messages=yes \
	  $(shell dpkg-buildflags --export=cmdline)
	convert Source/largeApp.tif -resize 32x32 GTAMSAnalyzer.xpm

override_dh_clean:
	$(MAKE) -C Source distclean
	dh_clean GTAMSAnalyzer.xpm

override_dh_auto_install:
	$(MAKE) -C Source install DESTDIR=$(d_app)

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

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
