#!/usr/bin/make -f

# Include dpatch stuff.
include /usr/share/dpatch/dpatch.make

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

configure: configure-stamp
configure-stamp:
	dh_testdir

	# need to run libtoolize before configure because
	# config.guess is out of date
	#libtoolize --force

        # Add here commands to configure the package.
	./configure --prefix=/usr \
		--infodir=/usr/share/info \
		--mandir=/usr/share/man \
		--without-xauth \
		--with-x

	touch configure-stamp

build: patch configure-stamp build-stamp
build-stamp:
	dh_testdir

	# Add here commands to compile the package.
	$(MAKE)

	perl -i -pe 's,-lglib-2.0,-lglib-2.0 $(CURDIR)/lib/libgtop-2.0.la,' sysdeps/common/Makefile
	rm sysdeps/common/*.lo

	$(MAKE) -C sysdeps/common

	perl -i -pe 's,-lglib-2.0,-lglib-2.0 $(CURDIR)/lib/libgtop-2.0.la,' sysdeps/linux/Makefile
	rm sysdeps/linux/*.lo

	$(MAKE) -C sysdeps/linux

	touch build-stamp

clean::	unpatch
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp

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

	dh_clean

install: DH_OPTIONS=
install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Add here commands to install the package into debian/tmp.
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp/

	dh_movefiles

# Build architecture-independent files here.
binary-indep: build install
#nothing

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir -a
	dh_testroot -a
	dh_installdocs -a
	dh_installexamples -a
#	dh_installmenu -a
#	dh_installinit -a
#	dh_installcron -a
	dh_installman -a
	dh_installinfo -a
#	dh_undocumented libgtop_daemon.1
	dh_installchangelogs -a
	dh_strip -a
	dh_link -a
	dh_compress -a
	dh_fixperms -a
	dh_makeshlibs -a
	dh_installdeb -a
#	dh_perl -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 configure
