#!/usr/bin/make -f
DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)


configure:
	dh_testdir
	autoconf
	cp /usr/share/misc/config.guess /usr/share/misc/config.sub .

config.status: configure
	./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
	--prefix=/usr --sysconfdir=/etc --mandir=\$${prefix}/share/man \
	--localstatedir=/var --with-site-perl=/usr/share/perl5


build-arch: build
build-indep: build

build: config.status
	dh_testdir
	$(MAKE)
	touch build-stamp

clean:
	dh_testdir
	[ ! -f Makefile ] || $(MAKE) distclean
	dh_clean

	rm -f build-stamp config.guess config.sub configure
	rm -Rf debian/epylog

install: build
	dh_testdir
	$(MAKE) install DOCDIRS="doc/*" pkgdocdir="/usr/share/doc/epylog" DESTDIR="$(CURDIR)/debian/epylog"
	rm $(CURDIR)/debian/epylog/usr/share/doc/epylog/INSTALL \
	   $(CURDIR)/debian/epylog/usr/share/doc/epylog/LICENSE \
	   $(CURDIR)/debian/epylog/usr/share/doc/epylog/ChangeLog
	find $(CURDIR)/debian/epylog -name *.pyc | xargs rm -f
	chmod 755 $(CURDIR)/debian/epylog/usr/share/epylog/modules/*.py
	mv $(CURDIR)/debian/epylog/etc/cron.daily/epylog.cron $(CURDIR)/debian/epylog/etc/cron.daily/epylog

binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installman
	dh_installdocs -X.svn
	dh_installchangelogs ChangeLog
	dh_compress
	dh_pysupport
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary-arch:

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