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

DEB_HOST_GNU_TYPE=$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE=$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
CROSS= --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
else
CROSS= --build $(DEB_BUILD_GNU_TYPE)
endif

ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -g
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif

configure: configure-stamp
configure-stamp:
	dh_testdir
	./configure --enable-gtk-doc --prefix=/usr $(CROSS)
	touch configure-stamp

build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp
build-stamp: configure-stamp
	dh_testdir
	$(MAKE)
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp
	[ ! -f Makefile ] || $(MAKE) distclean
	$(RM) doc/libgpewidget-scan.*
	$(RM) doc/libgpewidget.types
	$(RM) doc/*.txt patch-stamp
	$(RM) -r doc/html doc/xml
	$(RM) doc/tmpl/color-slider.sgml doc/tmpl/colordialog.sgml \
	doc/tmpl/dirbrowser.sgml doc/tmpl/errorbox.sgml \
	doc/tmpl/gpeclockface.sgml doc/tmpl/gpehelp.sgml \
	doc/tmpl/gpeiconlistitem.sgml doc/tmpl/gpeiconlistview.sgml \
	doc/tmpl/gpetimesel.sgml doc/tmpl/gpewindowlist.sgml \
	doc/tmpl/gtkdatecombo.sgml doc/tmpl/gtksimplemenu.sgml \
	doc/tmpl/infoprint.sgml doc/tmpl/init.sgml \
	doc/tmpl/libgpewidget-unused.sgml doc/tmpl/pixmaps.sgml \
	doc/tmpl/popup.sgml doc/tmpl/popup_menu.sgml doc/tmpl/question.sgml \
	doc/tmpl/smallbox.sgml doc/tmpl/spacing.sgml doc/tmpl/stylus.sgml \
	doc/tmpl/translabel.sgml doc/tmpl/tray.sgml \
	doc/tmpl/colorrenderer.sgml doc/tmpl/gpedialog.sgml \
	doc/tmpl/link-warning.sgml
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	$(MAKE) install PREFIX=/usr DESTDIR=$(CURDIR)/debian/tmp
	install -d debian/tmp/usr/share/doc/libgpewidget-doc/
	ln -s -T /usr/share/gtk-doc/html/libgpewidget/ debian/tmp/usr/share/doc/libgpewidget-doc/html

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_install
	dh_installdocs
	dh_installchangelogs ChangeLog
	dh_link
	dh_compress
	dh_fixperms
	dh_installdeb

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_install
	dh_installdocs
	dh_installman
	dh_installchangelogs ChangeLog
	dh_link
	dh_strip --dbg-package=libgpewidget1-dbg
	dh_compress
	dh_fixperms
	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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