#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

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

# This is the debhelper compatibility version to use.
export DH_COMPAT=4

include /usr/share/gnome-pkg-tools/1/rules/uploaders.mk

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

COMMON_FILES=$(shell ls gtk-common)

dest_dir=$(CURDIR)/debian/tmp/usr

config.status: configure.ac autogen.sh Makefile.am
	dh_testdir
	./autogen.sh --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr

build: build-stamp
build-stamp: config.status gtk-common-stamp
	dh_testdir
	$(MAKE)
	touch build-stamp

gtk-common-stamp:
	for i in $(COMMON_FILES); do \
		ln -s ../gtk-common/$$i gtk1-engine && \
		ln -s ../gtk-common/$$i gtk2-engine ; done
	touch gtk-common-stamp

clean::
	dh_testdir
	dh_testroot
	rm -f build-stamp
	-$(MAKE) distclean
	find . -name Makefile.in | xargs rm -f
	cd gtk1-engine && rm -f $(COMMON_FILES)
	cd gtk2-engine && rm -f $(COMMON_FILES)
	dh_clean aclocal.m4 config.guess config.h.in config.sub \
		config.status configure INSTALL install-sh \
		ltmain.sh missing mkinstalldirs stamp-h.in depcomp \
		stamp-h1 Makefile config.log config.h libtool \
		intltool-* po/Makefile.in.in po/*.gmo index.theme \
		gtk-common-stamp

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	$(MAKE) install prefix=$(dest_dir)
	dh_install

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installchangelogs ChangeLog
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-independent files here.
binary-indep: build install
# Nothing to do here

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