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

include /usr/share/GNUstep/debian/config.mk
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# Extract version from Xcode's project file.  Apparently it is set on
# muckOS when building with Xcode but GNU make knows nothing about it.
curver := $(shell grep --max-count=1 CURRENT_PROJECT_VERSION \
  Lynkeos.xcodeproj/project.pbxproj | awk '{ print $$3 }' | sed 's/;//')
export DEB_CPPFLAGS_MAINT_APPEND = -DCURRENT_PROJECT_VERSION=$(curver)
d_app := $(CURDIR)/debian/tmp
d_com := $(CURDIR)/debian/lynkeos.app-common

%:
	dh $@ --sourcedirectory=GNUstep

override_dh_auto_build:
	dh_auto_build -- $(optim) $(verbose) \
	  $(shell dpkg-buildflags --export=cmdline)
	icns2png --extract --size 48 Resources/Lynkeos.icns

override_dh_link-indep:
	dh_installdirs usr/share/GNUstep
	$(RM) $(d_app)$(GNUSTEP_SYSTEM_APPS)/Lynkeos.app/stamp.make
	$(RM) $(d_app)$(GNUSTEP_SYSTEM_APPS)/Lynkeos.app/Resources/*.desktop
	mv $(d_app)$(GNUSTEP_SYSTEM_APPS)/Lynkeos.app/Resources \
	  $(d_com)/usr/share/GNUstep/Lynkeos.app
	dh_link /usr/share/GNUstep/Lynkeos.app \
	  $(GNUSTEP_SYSTEM_APPS)/Lynkeos.app/Resources

override_dh_fixperms-indep:
	dh_fixperms
	chmod -x $(d_com)/usr/share/GNUstep/*.app/it.lproj/*
