#!/usr/bin/make -f
export DH_VERBOSE=1
build:
	dh_testdir

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	rm -rf build dist doc_temp
	find . -name "*.pyc" | xargs rm -f
	dh_clean

install: build gen-wader-doc
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	#XXX: It would be nicer if some option could avoid to mix both builds,
	# instead of clean them.
	rm -fr $(PWD)/build
	python setup.py install --root $(PWD)/debian/wader-core
	rm -fr $(PWD)/build
	python setup-gtk.py install --root $(PWD)/debian/wader-gtk
	dh_install

gen-wader-doc:
	mkdir -p doc_temp/guide/devel/api
	lore --config template=doc/devel/template.tpl \
		 --config baseurl=api/%s.html doc/devel/*.xhtml
	cp doc/devel/*.html doc/devel/*.css doc_temp/guide/devel
	cp -R doc/listings doc_temp/guide/listings
	rm doc/devel/*.html
	pydoctor --system-class=pydoctor.twistedmodel.TwistedSystem \
			 --project-name=wader-core \
			 --html-output=doc_temp/guide/devel/api \
			 --make-html \
			 --html-write-function-pages \
			 --add-package wader

binary-arch:  build install
	dh_testdir
	dh_testroot
	dh_installdebconf
	dh_installexamples -pwader-doc doc/examples/*
	dh_installdocs -pwader-doc doc_temp/guide LICENSE README
	DH_PYCENTRAL=nomove dh_pycentral
	dh_installchangelogs
	dh_installdirs
	dh_link
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_builddeb

binary: binary-indep binary-arch

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