#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

BUILD       := $(CURDIR)/debian/build
PACKAGE_DIR := $(CURDIR)/debian/xtla
TARGET      := $(PACKAGE_DIR)/usr

configure: configure-stamp
configure-stamp:
	dh_testdir
	autoconf
	[ -d $(BUILD) ] || mkdir $(BUILD)
	cd $(BUILD) && $(CURDIR)/configure --prefix $(TARGET) --with-emacs=xemacs
	cd ${BUILD}/lisp && \
           make auto-autoloads.el && mv auto-autoloads.el xtla-xemacs-autoloads.el
	cd $(BUILD) && $(CURDIR)/configure --prefix $(TARGET) --with-emacs=emacs21
	cd ${BUILD}/lisp && \
           make xtla-autoloads.el && mv xtla-autoloads.el xtla-emacs21-autoloads.el
	cd $(BUILD) && $(CURDIR)/configure --prefix $(TARGET) --with-emacs=emacs-snapshot
	touch configure-stamp

build: build-stamp
build-stamp: configure-stamp
	dh_testdir
	$(MAKE) -C $(BUILD) generated-files
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp
	rm -rf $(BUILD)
	rm -rf $(PACKAGE_DIR)
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	$(MAKE) -C $(BUILD) info
	$(MAKE) -C $(BUILD) install-deb

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_installexamples
	dh_installemacsen
	dh_installinfo $(BUILD)/texinfo/*.info*
	dh_link
	dh_compress
	dh_fixperms
	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
