#!/usr/bin/make -f

BUILDDIR = $(CURDIR)/debian/build

%:
	dh $@ --buildsystem=cmake --builddirectory=$(BUILDDIR)

override_dh_fixperms:
	dh_fixperms
	test -e /usr/bin/dh_buildinfo && dh_buildinfo

override_dh_auto_build:
	dh_auto_build
	make -C $(BUILDDIR) unit
	make -C $(BUILDDIR) doc

override_dh_auto_install:
	dh_auto_install
	dh_installdocs -plibwibble-dev -n $(BUILDDIR)/doc/html

tarball:
	if darcs wh -l; then (echo "There are uncommitted changes or spurious files"; /bin/false); fi
	sh debian/check_versions
	VER=`grep '^set( *VERSION' CMakeLists.txt |sed -r 's/.+"([^"]+)".+/\1/'` && tar --transform "s/^./libwibble-$$VER/" --exclude=_darcs --exclude=debian -zcf ../libwibble-$$VER.tar.gz . && ln -f ../libwibble-$$VER.tar.gz ../libwibble_$$VER.orig.tar.gz

debsrc: tarball
	debuild -us -uc -S -i_darcs -I_darcs
