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

include /usr/share/GNUstep/debian/config.mk

d_app := $(CURDIR)/debian/plopfolio.app
export DEB_BUILD_MAINT_OPTIONS = hardening=+all 
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--no-undefined -Wl,--as-needed

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_install:
# Remove invalid .desktop file and install ours.
	dh_install debian/PlopFolio.desktop usr/share/applications
	rm $(d_app)$(GNUSTEP_SYSTEM_APPS)/*.app/Resources/*.desktop
# Move arch-independent files to /usr/share.
	dh_installdirs usr/share/GNUstep
	mv $(d_app)$(GNUSTEP_SYSTEM_APPS)/PlopFolio.app/Resources \
	  $(d_app)/usr/share/GNUstep/PlopFolio.app
	dh_link usr/share/GNUstep/PlopFolio.app \
	  $(GNUSTEP_SYSTEM_APPS)/PlopFolio.app/Resources
