#!/usr/bin/make -f
# -*- makefile -*-

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

configure: configure-stamp
configure-stamp:
	dh_testdir

	touch configure-stamp

build-arch:
build-indep:
build: build-stamp

build-stamp: configure-stamp 
	dh_testdir

	perl Makefile.PL INSTALLDIRS=vendor
	$(MAKE) OPTIMIZE="-O2 -g -Wall"

	pod2man $(CURDIR)/collect-reminders > $(CURDIR)/collect-reminders.1
	pod2man $(CURDIR)/send-reminders > $(CURDIR)/send-reminders.1
	pod2man $(CURDIR)/email-reminder-editor > $(CURDIR)/email-reminder-editor.1

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp

	[ ! -f Makefile ] || $(MAKE) clean

	rm -f $(CURDIR)/collect-reminders.1 $(CURDIR)/send-reminders.1 $(CURDIR)/email-reminder-editor.1

	dh_clean
	debconf-updatepo

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	$(MAKE) install DESTDIR=$(CURDIR)/debian/email-reminder
	[ ! -d $(CURDIR)/debian/email-reminder/usr/lib/perl5 ] || rmdir --ignore-fail-on-non-empty --parents --verbose $(CURDIR)/debian/email-reminder/usr/lib/perl5
	mv $(CURDIR)/debian/email-reminder/usr/bin/collect-reminders $(CURDIR)/debian/email-reminder/usr/sbin/

	cp $(CURDIR)/email-reminder.desktop $(CURDIR)/debian/email-reminder/usr/share/applications

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

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installdebconf
	dh_installchangelogs Changes
	dh_installdocs
	dh_installexamples $(CURDIR)/examples/email-reminders
	dh_installmenu
	dh_installcron
	dh_installman
	dh_link
	dh_compress
	dh_fixperms
	dh_perl
	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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