#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-

include /usr/share/cdbs/1/rules/patchsys-quilt.mk
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/gnustep.mk
include /usr/share/cdbs/1/class/gnumakefile.mk

PAJE=paje.app

DEB_MAKE_BUILD_TARGET= CPPFLAGS="-I/usr/include/GNUstep/Headers" messages=yes
DEB_MAKE_CLEAN_TARGET= clean distclean

DEB_INSTALL_DOCS_$(PAJE)=TODO Documentation/UserManual/user.ps \
	Documentation/lang-paje/lang-paje.ps

DEB_INSTALL_MANPAGES_$(PAJE)=debian/Paje.1

###########################################
# Documentation is not build upstream...
build/$(PAJE)::
	$(MAKE) -C Documentation/UserManual
	$(MAKE) -C Documentation/lang-paje

clean::
	$(MAKE) -C Documentation/UserManual clean 
	$(MAKE) -C Documentation/lang-paje clean
	$(RM) -r Paje/Paje.gorm
	# if this is a git repository, restore removed files that would have
	# been ignored by dpkg-source
	-test -d .git && git checkout -- $$(git status | \
		sed -e '/^#[[:space:]]*deleted:[[:space:]]*/s/^#[[:space:]]*deleted:[[:space:]]*//p;d' | \
		grep -v '^debian/')


###########################################
# GNUstep layout needs to circumvent FHS...
binary-install/$(PAJE)::
	install -m 644 debian/lintian-override $(CURDIR)/debian/$(PAJE)/usr/share/lintian/overrides/$(PAJE)

###########################################
# Desktop file
binary-install/$(PAJE)::
	install -m 644 debian/paje.desktop $(CURDIR)/debian/$(PAJE)/usr/share/applications
	chmod 644 $(CURDIR)/debian/$(PAJE)/usr/lib/GNUstep/Applications/Paje.app/Resources/Paje.desktop

###########################################
# GNUstep layout needs adaptation to comply with FHS...
binary-install/$(PAJE)::
	gsdh_gnustep
