#!/usr/bin/make -f

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
  NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
  MAKEFLAGS += -j$(NUMJOBS)
endif

TMP=$(CURDIR)/debian/tmp/

%:
	dh $@

override_dh_auto_clean:
	dh_testdir
	dh_auto_clean
	dh_clean
	-${RM} -rf docs/drizzled docs/html docs/pyext/*.pyc  Makefile.in aclocal.m4 config/config.guess config/config.sub config/ltmain.sh config/pandora-plugin.am config/pandora-plugin.list doxerr.log config/plugin.stamp config/compile config/depcomp \
	config/install-sh config/ylwrap configure m4/libtool.m4 m4/ltoptions.m4 m4/ltversion.m4 m4/lt~obsolete.m4 tests/Makefile.in

override_dh_auto_configure:
	bash config/autorun.sh
	dh_auto_configure -- \
	  --disable-rpath \
	  --localstatedir=/var/lib/drizzle \
	  --disable-mysql-protocol-plugin \
	  --disable-mysql-unix-socket-protocol-plugin \
	  --with-comment="Debian"

override_dh_auto_build:
	${MAKE}
	${MAKE} doxygen
	${MAKE} html

override_dh_auto_install:
	dh_auto_install
	mkdir -p $(TMP)/etc/drizzle
	cp -a debian/conf.d $(TMP)/etc/drizzle

override_dh_strip:
	dh_strip -Xdrizzled -Xplugin -Xbin --dbg-package=libdrizzle-dbg
	dh_strip -Xlibdrizzle.so --dbg-package=drizzle-dbg

override_dh_auto_test:
	echo "skipping tests"

override_dh_installdocs:
	dh_installdocs -A
	rm -f $(CURDIR)/debian/drizzle-doc/usr/share/doc/drizzle-doc/html/_sources/license.txt

grepdiff:
	bzr diff | grepdiff Copyright

scan-copyright:
	for f in `bzr status  --short | grep '^.[NM]' | awk '{print $$2}'` ; do [ -f $$f ] && bzr diff $$f | grep 'Copyright' && echo $$f; done

get-orig-source:
	# Uscan will read debian/watch, grab the correct version, repack, and
	# leave it in the current directory
	uscan --noconf --force-download --rename --repack \
	  --download-current-version --destdir=.
