#! /usr/bin/make -f
## debian/rules for saytime
## (C) 2001 Gergely Nagy <algernon@debian.org>
## updated by Holger Levsen <holger@debian.org> in 2010 and 2011
##
## Released under the terms of the GNU GPLv2.

include /usr/share/quilt/quilt.make

## Debian-specific variables
PACKAGE		 = saytime
PKGDIR		 = $(CURDIR)/debian/$(PACKAGE)
DEBIAN_BINDIR	 = $(PKGDIR)/usr/bin
DEBIAN_SHAREDIR	 = $(PKGDIR)/usr/share/$(PACKAGE)

build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp
build-stamp: patch
	$(testdir)
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
# don't optimize
	$(MAKE) CFLAGS="-g -O0 -Wall"
else
# do optimize
	$(MAKE) CFLAGS="-g -O2 -Wall"
endif
	(cd debian && unshar sounds-david.shar)
	touch build-stamp

clean: unpatch
	dh_testdir
	dh_testroot
	rm -f build-stamp #debian/files debian/saytime.substvars
	$(MAKE) clean
	#rm -rf $(PKGDIR)
	rm -rf debian/sounds
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
## The upstream makefile does not have an install target, so
## copy the files by hand
	install -m 0755 saytime $(DEBIAN_BINDIR)/saytime
	(cd debian && install -m 0644 sounds/*.au $(DEBIAN_SHAREDIR)/)
	dh_installchangelogs
	dh_installdocs
	dh_installman

binary-saytime: build install
	dh_testdir
	dh_testroot
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

## Mandatory targets
binary-indep:
binary-arch: binary-saytime
binary: binary-indep binary-arch


.PHONY: build clean binary-indep binary-arch binary install binary-saytime \
	clean1
