#!/usr/bin/make -f
# this is a -*- Makefile -*-, believe it or not
# Based on sample debhelper debian/rules. GNU copyright 1997 by Joey Hess.
# GNU copyright 1998-2001 Marcelo Magallon
# (C) 2008-2009 Helge Kreutzmann

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

CDEBUGFLAGS=-O2 -Wall
MANDIR=debian/manpage

ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
CDEBUGFLAGS += -g
endif

build: build-stamp
build-stamp: 
	dh_testdir
	( echo classic ; echo ) | ./configure
	# Choose classic theme
	make CDEBUGFLAGS="$(CDEBUGFLAGS)"
	cp -ivp asclock.man $(MANDIR)
	cd $(MANDIR) && po4a-updatepo -f man -m asclock.man -p asclock.de.po
	cd $(MANDIR) && po4a-updatepo -f man -m asclock.man -p asclock.pt.po
	cd $(MANDIR) && po4a-updatepo -f man -m asclock.man -p asclock.sv.po
	cd $(MANDIR) && po4a-translate -k 20 -f man -m asclock.man -p asclock.de.po -a asclock.de.add -l asclock.de.man
	cd $(MANDIR) && po4a-translate -k 20 -f man -m asclock.man -p asclock.pt.po -l asclock.pt.man
	cd $(MANDIR) && po4a-translate -k 20 -f man -m asclock.man -p asclock.sv.po -l asclock.sv.man

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	-rm -r build-stamp default_theme configure-stamp
	[ ! -f Makefile ] || $(MAKE) clean
	-rm -f Makefile
	-rm -f default.h
	-rm -f $(MANDIR)/asclock.*man
	dh_clean

binary-indep: DH_OPTIONS=-i
binary-indep:
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs usr/share/asclock
	( cd themes && tar cf - $$(find \( -name CVS -o -name themes \) -prune -o \! -type d -print) ) | ( cd debian/asclock-themes/usr/share/asclock && tar xf - )
# The upstream tarball contains some cruft.
	find debian/asclock-themes/usr/share/asclock -type f -name classic | xargs rm
	chmod +x debian/install-i18n
	debian/install-i18n
	dh_installdocs
	dh_installchangelogs
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary-arch: DH_OPTIONS=-a
binary-arch: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs usr/bin
	install -m 0755 asclock debian/asclock/usr/bin/asclock
	dh_installdocs
	dh_installmenu
	dh_installman asclock.man $(MANDIR)/asclock.de.man $(MANDIR)/asclock.pt.man $(MANDIR)/asclock.sv.man
	dh_installchangelogs
	dh_strip
	dh_compress
	dh_fixperms
	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
