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

export LIBS=-lblas -llapack -lpthread

export CXXFLAGS=-g1 -O2 -DNDEBUG -DZDOT_RETURN

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
B_LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH)

%:
	dh $@ --max-parallel=1 --with autoreconf

override_dh_auto_clean:
	dh_auto_clean
	rm -rf $(CURDIR)/src/testsuite

override_dh_auto_configure:
	if [ -f /proc/meminfo ]; then cat /proc/meminfo; fi
	dh_auto_configure -- 			\
		--datadir=/usr/share/bagel	\
		--libdir=/usr/lib/bagel		\
		--enable-static			\
		--disable-shared		\
		--with-boost			\
		--with-boost-libdir=$(B_LIBDIR)	\
		--with-libxc=yes		\
		--with-mpi=openmpi		\
		--disable-scalapack		\
		--enable-smith

override_dh_auto_install:
	dh_auto_install --destdir=$(CURDIR)/debian/tmp
	(cd docs; cp -a _static _images searchindex.js $(CURDIR)/debian/bagel/usr/share/doc/bagel/html)
	(cd docs; cp --parents `find -name \*.html*` $(CURDIR)/debian/bagel/usr/share/doc/bagel/html)

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	dh_auto_test
	mkdir -p $(CURDIR)/src/testsuite
	-(cd $(CURDIR)/src/testsuite; ../TestSuite --log_level=all)
endif

override_dh_installchangelogs:
	dh_installchangelogs -XChangeLog
