#!/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/cynthiune.app
export DEB_LDFLAGS_MAINT_APPEND := -Wl,--no-undefined -Wl,--as-needed \
				     -Wl,-rpath,/usr/lib/cynthiune.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 Images/Cynthiune.tiff -resize 32x32 Cynthiune.xpm

override_dh_clean:
	dh_clean -XChangeLog.orig -XPlaylistController.m.orig Cynthiune.xpm

override_dh_auto_install:
# Cheat GNUstep Make to create the symlinks for the Cynthiune library
# in /usr/lib/cynthiune.app.
	$(MAKE) install DESTDIR=$(d_app) \
	  GNUSTEP_SYSTEM_LIBRARIES=/usr/lib/cynthiune.app
	rm $(d_app)$(GNUSTEP_SYSTEM_APPS)/*.app/Resources/COPYING
	rm $(d_app)$(GNUSTEP_SYSTEM_APPS)/*.app/Resources/*.desktop

override_dh_link:
	gsdh_gnustep
	dh_installdirs usr/share/GNUstep
	mv $(d_app)$(GNUSTEP_SYSTEM_APPS)/Cynthiune.app/Resources \
	  $(d_app)/usr/share/GNUstep/Cynthiune.app
	dh_link /usr/share/GNUstep/Cynthiune.app \
	  $(GNUSTEP_SYSTEM_APPS)/Cynthiune.app/Resources

override_dh_makeshlibs:
# libCynthiune is installed as a private library; avoid lintian warnings.
	dh_makeshlibs --noscripts
