#!/usr/bin/make -f

# debian/rules file for sapwood Debian package
# written January 1999 by Ben Gertzfield <che@debian.org>
# modified 1999 by Ed Boraas <ed@debian.org>
# modified 2005 by Tommi Komulainen <tommi.komulainen@nokia.com>

gtk_binary_version=$(shell pkg-config --variable gtk_binary_version gtk+-2.0)

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

# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE	?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE	?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

CFLAGS = -Wall -g

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

configure:
	NOCONFIGURE=1 ./autogen.sh

build: build-stamp
build-stamp: configure
	dh_testdir
	./configure	--host=$(DEB_HOST_GNU_TYPE) \
			--build=$(DEB_BUILD_GNU_TYPE) \
			--prefix=/usr \
			--enable-abstract-sockets
	$(MAKE)
	touch $@

clean:
	dh_testdir
	dh_testroot

	# Add here commands to clean up after the build process.
	-$(MAKE) distclean

	dh_clean build-stamp install-stamp

install: install-stamp
install-stamp: build
	dh_testdir
	dh_testroot
	dh_clean
	$(MAKE) DESTDIR=$(CURDIR)/debian/tmp install

	install -d -m755 debian/tmp/etc/osso-af-init
	install -m755 debian/sapwood-server.sh debian/tmp/etc/osso-af-init

	for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
		sed -e "s/@BINVER@/${gtk_binary_version}/g" $$f > $${f%.in}; \
	done

	touch $@

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

# Build architecture-dependent files here.
binary-arch: build install 
	dh_testdir -a 
	dh_testroot -a
	dh_installdirs -a
	dh_install -a --sourcedir=debian/tmp
	dh_installdocs -a
	dh_installchangelogs -a ChangeLog
#	dh_installexamples -a
	dh_strip -a --dbg-package=gtk2-engines-sapwood
	dh_compress -a
	dh_fixperms -a
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_makeshlibs -a
	dh_md5sums -a
	dh_builddeb -a

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
