#!/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/charmap.app

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

%:
	dh $@

override_dh_auto_build:
	$(MAKE) messages=yes $(optim) $(shell dpkg-buildflags --export=cmdline)
	convert Charmap.png -resize 32x32 Charmap.xpm

override_dh_clean:
	dh_clean Charmap.xpm

override_dh_link:
	gsdh_gnustep
	dh_installdirs usr/share/GNUstep
	rm $(d_app)$(GNUSTEP_SYSTEM_APPS)/*.app/Resources/*.desktop
	mv $(d_app)$(GNUSTEP_SYSTEM_APPS)/Charmap.app/Resources \
	  $(d_app)/usr/share/GNUstep/Charmap.app
	dh_link /usr/share/GNUstep/Charmap.app \
	  $(GNUSTEP_SYSTEM_APPS)/Charmap.app/Resources
# A hack to move arch-indep stuff into -common.  Cannot be done in the
# install-* targets as usual because /usr/share has been just
# populated by this recipe.
	mkdir -p $(CURDIR)/debian/charmap.app-common/usr/share
	mv $(d_app)/usr/share/GNUstep \
	  $(CURDIR)/debian/charmap.app-common/usr/share
