#! /usr/bin/make -f

DOC_FILES := doc/org doc/org.pdf
DOC_TMP_FILES := doc/org.aux doc/org.cp doc/org.cps doc/org.fn doc/org.fns doc/org.ky doc/org.kys \
	doc/org.log doc/org.pg doc/org.toc doc/org.tp doc/org.vr

clean:
	dh_testdir
	dh_testroot
	dh_clean
	rm -f $(DOC_FILES) $(DOC_TMP_FILES)

build:
	make $(DOC_FILES)
	rm -f $(DOC_TMP_FILES)

install: build
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_installdirs
	cp lisp/* $(CURDIR)/debian/org-mode/usr/share/emacs/site-lisp/org-mode
#	cp xemacs/*.el $(CURDIR)/debian/org-mode/usr/share/xemacs/site-lisp/org-mode
	cp -r contrib $(CURDIR)/debian/org-mode/usr/share/org-mode/
	find $(CURDIR)/debian/org-mode/usr/share/org-mode/ -type f -exec chmod 644 "{}" \;
	find $(CURDIR)/debian/org-mode/usr/share/org-mode/ -name .DS_Store -exec rm -f {} \;
	find $(CURDIR)/debian/org-mode/usr/share/org-mode/ -name .gitignore -exec rm -f {} \;

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs doc/*
	rm -f $(CURDIR)/debian/org-mode/usr/share/doc/org-mode/org
	dh_installemacsen -v
	dh_fixperms
	dh_installinfo doc/org
	dh_compress
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-dependent files here.
binary-arch: build install
# We have nothing to do by default.

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