#!/usr/bin/make -f
# Made with the aid of debmake, by Christoph Lameter,
# based on the sample debian/rules file for GNU hello by Ian Jackson.

export DH_COMPAT=3

package=chaos
pwd=$(shell pwd)

build: build-stamp
build-stamp:
	dh_testdir
	./configure --prefix=/usr
	touch build-stamp

	(cd texi ; make MAKEINFO=no)

	## make info.ja need Emacs20
	(cd texi ; make ja MAKEINFO=no)

clean:
	dh_testdir
	dh_testroot
	-rm -f build-stamp
	-make clean
	-cd texi && make clean
	dh_clean
	-rm -f texi/gnus texi/gnus-[0-9]* texi/message
	-rm -f texi/gnus-ja texi/gnus-ja-[0-9]* texi/message-ja
	-rm -f texi/.#*

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

# Build architecture-dependent files here.
binary-arch: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	cp -pr lisp/* ${pwd}/debian/${package}/usr/share/emacs/site-lisp/chaos
	rm -f ${pwd}/debian/${package}/usr/share/emacs/site-lisp/chaos/{ChangeLog,Makefile,in}
	cp ${PWD}/debian/chaos-init.el \
		${pwd}/debian/${package}/usr/share/emacs/site-lisp/${package}

	mv texi/gnus texi/gnus-[0-9]* texi/message \
		${pwd}/debian/${package}/usr/share/info
	mv texi/gnus-ja texi/gnus-ja-[0-9]* texi/message-ja \
		${pwd}/debian/${package}/usr/share/info

	rm -f texi/.\#*
	cp -r texi  ${pwd}/debian/${package}/usr/share/doc/${package}/
	rm -f ${pwd}/debian/${package}/usr/share/doc/${package}/texi/Makefile*

	cp -r lisp/ChangeLog  ${pwd}/debian/${package}/usr/share/doc/${package}/ChangeLog.lisp

	## install emacsen install/remove file
	dh_installemacsen
	dh_installdocs

	dh_installchangelogs ChangeLog
#	dh_strip
	dh_compress
	dh_fixperms

#	dh_suidregister
	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
