#!/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/wrapperfactory.app
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# Make sure there are no undefined symbols.
export DEB_LDFLAGS_MAINT_APPEND := -Wl,--no-undefined \
                                     -Wl,-rpath,/usr/lib/wrapperfactory.app

%:
	dh $@

override_dh_auto_build:
	dh_auto_build -- $(optim) $(verbose) \
	  $(shell dpkg-buildflags --export=cmdline)
	convert WrapperFactory/Icons/WrapperFactory.tiff \
	  -resize 64x64 WrapperFactory.png

override_dh_auto_install:
# Install libGSWrapper as a private library.
	dh_auto_install -- GNUSTEP_SYSTEM_LIBRARIES=/usr/lib/wrapperfactory.app
# Remove invalid .desktop file and install ours.
	rm $(d_app)$(GNUSTEP_SYSTEM_APPS)/*.app/Resources/*.desktop
	install -D -m 644 debian/WrapperFactory.desktop \
	  $(d_app)/usr/share/applications/WrapperFactory.desktop
	install -D -m 644 WrapperFactory.png \
	  $(d_app)/usr/share/pixmaps/GNUstep/WrapperFactory.png

override_dh_link:
	gsdh_gnustep
	dh_installdirs usr/share/GNUstep/WrapperFactory.app
# Move the images only; the helper tool must be in Resources, and it's
# arch-dependent so we can't symlink the whole directory.
	for i in $(d_app)$(GNUSTEP_SYSTEM_APPS)/*.app/Resources/*.tiff; do \
	  mv $$i $(d_app)/usr/share/GNUstep/WrapperFactory.app/ \
	  && dh_link usr/share/GNUstep/WrapperFactory.app/`basename $$i` \
	  $(GNUSTEP_SYSTEM_APPS)/WrapperFactory.app/Resources/`basename $$i`; \
        done
# Now move the .gorm files to /usr/share.  Should be done in a loop as
# above if more translations are added in the future.
	mv $(d_app)$(GNUSTEP_SYSTEM_APPS)/*.app/Resources/English.lproj \
	  $(d_app)/usr/share/GNUstep/WrapperFactory.app
	dh_link usr/share/GNUstep/WrapperFactory.app/English.lproj \
	  $(GNUSTEP_SYSTEM_APPS)/WrapperFactory.app/Resources/English.lproj

override_dh_makeshlibs:
# Avoid lintian warning for the private library.
	dh_makeshlibs --noscripts
