#!/usr/bin/make -f

ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
 CFLAGS += -O0
else
 CFLAGS += -O2
endif

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

TMP=$(CURDIR)/debian/tmp/

%:
	dh $@ --with sphinxdoc --with autoreconf

override_dh_auto_clean:
	dh_testdir
	dh_auto_clean
	dh_clean
	debconf-updatepo
	-${RM} -rf docs/drizzled docs/html docs/pyext/*.pyc tests/kewpie config/top.h

override_dh_autoreconf:
	python config/pandora-plugin write
	python config/pandora-plugin plugin-list
	dh_autoreconf config/autorun.sh


override_dh_auto_configure:
	dh_auto_configure -- \
	  --disable-rpath \
	  --localstatedir=/var/lib/drizzle \
	  --with-comment="Debian" $(shell dpkg-buildflags --export=configure) \
	  --disable-silent-rules

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


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

override_dh_sphinxdoc:
	(test -d $(CURDIR)/debian/drizzle-doc && dh_sphinxdoc -Xlicense.txt) || /bin/true

