#!/usr/bin/make -f
# -*- makefile -*-

ORIGINAL_UPSTREAM_VERSION=0.4

get-orig-source:
	wget http://downloads.sourceforge.net/gebabbel/Gebabbel-$(ORIGINAL_UPSTREAM_VERSION)-Src.tar.gz
	mkdir gebabbel-download-tmp
	cd gebabbel-download-tmp; \
	tar -xzf ../Gebabbel-$(ORIGINAL_UPSTREAM_VERSION)-Src.tar.gz; \
	rm -rf Gebabbel-$(ORIGINAL_UPSTREAM_VERSION)/binincludes/gpsbabel* ; \
	mv Gebabbel-$(ORIGINAL_UPSTREAM_VERSION) gebabbel-$(ORIGINAL_UPSTREAM_VERSION)+repack ; \
	tar -czf ../gebabbel_$(ORIGINAL_UPSTREAM_VERSION)+repack.orig.tar.gz gebabbel-$(ORIGINAL_UPSTREAM_VERSION)+repack
	rm -rf gebabbel-download-tmp
	
configure:

config.status: configure
	dh_testdir
	
	qmake-qt4

build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp

build-stamp:  config.status
	dh_testdir
	
	cd debian/icons; for i in *.uu; do uudecode $$i ; done
	cd debian; pod2man -c "" -r "" manpage.pod > gebabbel.1
	
	$(MAKE)
	touch $@

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	
	# If Makefile still contains this path, we haven't configured yet.
	[ ! -f Makefile ] || if grep -q "/usr/local/Trolltech" Makefile; then rm Makefile; fi

	[ ! -f Makefile ] || $(MAKE) distclean

	rm -f debian/icons/*.png debian/icons/*.xpm
	rm -f debian/gebabbel.1

	dh_clean 

install: build
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_installdirs
	
	dh_install debian/gebabbel.desktop /usr/share/applications
	dh_install debian/icons/gebabbel-logo.png /usr/share/pixmaps
	dh_install debian/icons/gebabbel-logo.xpm /usr/share/pixmaps
	
	INSTALL_ROOT=$(CURDIR)/debian/gebabbel $(MAKE) install

binary-indep: build install

binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs CHANGELOG
	dh_installdocs
	dh_installman debian/gebabbel.1
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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