#!/usr/bin/make -f

package=remembrance-agent

build:
	$(checkdir)
	./configure --prefix debian/tmp/usr
	make
	touch build

clean:
	$(checkdir)
	-rm -f build
	make clean
	-rm -rf *~ debian/tmp debian/*~ debian/files*

binary-indep: checkroot build
	$(checkdir)
# There are no architecture-independent files to be uploaded
# generated by this package.  If there were any they would be
# made here.

binary-arch: checkroot build
	$(checkdir)
	-rm -rf debian/tmp
	install -d debian/tmp
	cd debian/tmp && install -d `cat ../dirs`
	dh_installdocs other/README* other/savantrc other/vector.doc
#	gzip -9 `find debian/tmp/usr/man -type f 2>/dev/null`
	gzip -9 `find debian/tmp/usr/doc -type f -size +4k ! -name "*.htm*"`
#	install -m 644 REVISION-HISTORY debian/tmp/usr/doc/$(package)/changelog
#	gzip -9 debian/tmp/usr/doc/$(package)/changelog
	dh_installchangelogs 
	dh_undocumented ra-index.1 ra-retrieve.1 ra-merge.1
	install -m 644 debian/copyright debian/tmp/usr/doc/$(package)/
	install -m 644 other/savantrc debian/tmp/etc/savantrc
	install -m 644 debian/${package}.el \
		debian/tmp/etc/emacs19/site-start.d/50${package}.el
# Move program files:
# main/ra-index main/ra-retrieve other/remem-display-mode.el other/remem-display-mode.elc
	install -m 755 main/ra-* debian/tmp/usr/bin
	install -m 644 other/remem-display-mode.* debian/tmp/usr/share/emacs/site-lisp/
	strip `find debian/tmp -type f -perm +111 | xargs file | fgrep ELF | sed 's/^\([^:]*\):.*$$/\1/'`
	install -d debian/tmp/DEBIAN
	install -m 755 debian/postinst debian/tmp/DEBIAN
	install -m 755 debian/prerm debian/tmp/DEBIAN
	dpkg-shlibdeps `find debian/tmp -type f -perm +111 | xargs file | fgrep ELF | sed 's/^\([^:]*\):.*$$/\1/'`
	dh_md5sums
	dpkg-gencontrol -isp
	chown -R root.root debian/tmp
	chmod -R go=rX debian/tmp
	dpkg --build debian/tmp ..

define checkdir
	test -f debian/rules
endef

# Below here is fairly generic really

binary: binary-indep binary-arch

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

checkroot:
	$(checkdir)
	test root = "`whoami`"

.PHONY: binary binary-arch binary-indep clean checkroot

#Local variables:
#mode: makefile
#End:

