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

#export DH_VERBOSE=1

BIBUSDESTDIR = $(CURDIR)/debian/bibus
BIBUSDOCDESTDIR = $(CURDIR)/debian/bibus-doc-en

build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp
build-stamp: configure
	#dh_testdir
	#touch build-stamp

clean: 
	dh_testdir
	dh_testroot
	find . -name '*.py[co]' -exec rm {} \;
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs usr/bin etc usr/share/applications usr/share/icons/hicolor/48x48/apps

	# Add here commands to install the package into debian/bibus.
	$(MAKE) -f Setup/Makefile install-files DESTDIR=$(BIBUSDESTDIR)/usr sysconfdir=$(BIBUSDESTDIR)/etc
	
	chmod 755 $(BIBUSDESTDIR)/usr/share/bibus/bibus.py
	rm -f $(BIBUSDESTDIR)/usr/share/bibus/bibusStart.py
	rm -f $(BIBUSDESTDIR)/usr/share/doc/bibus/*
	rm -f $(BIBUSDESTDIR)/usr/share/man/man1/bibus.1
	rm -f $(BIBUSDESTDIR)/usr/share/bibus/Utilities/ClientForm.py
	dh_install -pbibus debian/bibus.cfg usr/share/bibus/
	dh_install -pbibus Pixmaps/bibus.xpm usr/share/pixmaps/
	
	# installing bibus-doc-en
	dh_installdirs -pbibus-doc-en usr/share/doc/bibus/html
	$(MAKE) -f Setup/Makefile install-doc-en DESTDIR=$(BIBUSDOCDESTDIR)/usr
	dh_link -pbibus-doc-en usr/share/common-licenses/GPL-2 usr/share/doc/bibus/html/en/license.txt

binary-indep: build install
	dh_testdir -i
	dh_testroot -i
	dh_installchangelogs -i Docs/CHANGELOG
	dh_installdocs  -i
	dh_installmenu -i
	dh_installman -i debian/bibus.1
	dh_lintian -i
	dh_link  -i usr/share/bibus/bibus.py usr/bin/bibus
	dh_strip -i
	dh_compress -i
	dh_fixperms -i
	dh_python2 -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

# Build architecture-dependent files here.
binary-arch: build install

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