#!/usr/bin/make -f
#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/affiche.app

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

%:
	dh $@

override_dh_auto_build:
	$(MAKE) $(optim) messages=yes $(shell dpkg-buildflags --export=cmdline)

override_dh_link:
	dh_gnustep
	dh_installdirs usr/share/GNUstep
	rm $(d_app)$(GNUSTEP_SYSTEM_APPS)/*.app/Resources/*.desktop
	mv $(d_app)$(GNUSTEP_SYSTEM_APPS)/Affiche.app/Resources \
	  $(d_app)/usr/share/GNUstep/Affiche.app
	dh_link /usr/share/GNUstep/Affiche.app \
	  $(GNUSTEP_SYSTEM_APPS)/Affiche.app/Resources

override_dh_fixperms:
	dh_fixperms
	find debian -name '*.desktop' -exec chmod -x {} +
