#!/usr/bin/make -f
#
# $Id: rules 8426 2006-11-28 20:59:17Z guillem $
#

DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

CFLAGS = -g -Wall

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif

ifneq (,$(findstring nohildon,$(DEB_BUILD_OPTIONS)))
	opt_hildon :=
else
	opt_hildon := --enable-hildon-booster
endif

# Nasty thing due to having the upstream and debian stuff merged.
configure: configure.ac
	autoreconf -f -i -Wall
	rm -rf autom4te.cache

config.status: configure
	dh_testdir
	
	CFLAGS="$(CFLAGS)" ./configure \
	  --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
	  $(opt_hildon) \
	  --mandir=\$${prefix}/share/man \
	  --prefix=/usr

build: config.status
	dh_testdir
	
	$(MAKE)

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	
	-$(MAKE) distclean
	
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs -a
	
	$(MAKE) install DESTDIR=$(CURDIR)/debian/maemo-launcher

binary-indep: build install
	# Nothing to do.

binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs -a ChangeLog
	dh_installdocs -a
	dh_installexamples -a
#	dh_install
#	dh_installlogrotate
#	dh_installpam
	dh_installinit -a -- start 45 2 3 4 . stop 45 0 1 5 6 .
	dh_installman -a
	dh_link -a
	dh_strip --dbg-package=maemo-launcher
	dh_compress -a
	dh_fixperms -a
	chmod u+s $(CURDIR)/debian/maemo-launcher/usr/lib/maemo-launcher/defender
#	dh_makeshlibs
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

binary: binary-indep binary-arch

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

