#!/usr/bin/make -f

package     := wmmail

tmpdir      := $(shell pwd)/debian/$(package)

appspath    := usr/lib/GNUstep/Apps
sharepath   := usr/share/GNUstep/Apps
defaultsdir := etc/GNUstep/Defaults

build: build-stamp
build-stamp:
	dh_testdir
	cp -vf /usr/share/misc/config.sub .
	cp -vf /usr/share/misc/config.guess .
	./configure --with-appspath=/$(appspath)
	$(MAKE)
	touch $@

clean:
	dh_testdir
	dh_testroot
	[ ! -f Makefile ] || $(MAKE) distclean
	-rm -rf *-stamp .deps
	dh_clean

install-stamp: build
	dh_testdir
	dh_prep

	dh_installdirs
	$(MAKE) install DESTDIR=$(tmpdir)

	mv $(tmpdir)/$(appspath)/WMMail.app/WMMail \
		$(tmpdir)/usr/bin/WMMail

	rm -rf $(tmpdir)/$(appspath)/WMMail.app/Defaults
	install -m 0644 -p debian/system.WMMail \
		$(tmpdir)/$(defaultsdir)/WMMail

# move images and sounds to /usr/share
	mv $(tmpdir)/$(appspath)/WMMail.app/Anims \
		$(tmpdir)/$(sharepath)/WMMail.app/Anims
	mv $(tmpdir)/$(appspath)/WMMail.app/Sounds \
		$(tmpdir)/$(sharepath)/WMMail.app/Sounds

	dh_installman debian/WMMail.1
	dh_installdocs
	dh_installchangelogs ChangeLog
	dh_installexamples
	dh_installmenu
	dh_link
	touch $@

# Build architecture-independent files here.
binary-indep: build
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install-stamp
#	dh_testversion
	dh_testdir
	dh_testroot
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

source diff:                                                                  
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install-stamp
