#!/usr/bin/make -f
%:
	dh $@ --with python2 --parallel --with autoreconf

#=====================================================================

export CFLAGS := -Wall $(shell dpkg-buildflags --get CFLAGS)
export CXXFLAGS := -Wall $(shell dpkg-buildflags --get CXXFLAGS)
export CPPFLAGS := $(shell dpkg-buildflags --get CPPFLAGS)
export LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)

export LD_LIBRARY_PATH :=$(LD_LIBRARY_PATH):$(CURDIR)/./src/.libs/

configure_flags= $(CROSS) --prefix=/usr \
		--enable-boost --enable-shared --with-pic \
		--enable-python --enable-metis \
		--disable-matlab --disable-superlu \
		--enable-muparser --enable-mumps \
		--with-mumps="-lsmumps_seq -ldmumps_seq -lcmumps_seq -lzmumps_seq -lpord_seq"  

disable_scilab_archs   = mips kfreebsd-amd64 kfreebsd-i386 s390x hurd-i386
ifneq (,$(filter $(DEB_HOST_ARCH), $(disable_scilab_archs)))
	configure_flags += --disable-scilab
else
	configure_flags += --enable-scilab --with-scilab-toolbox-dir=$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/scilab-getfem++/
endif


#=====================================================================

override_dh_auto_configure:
	dh_auto_configure -- $(configure_flags)

override_dh_auto_build:
	dh_auto_build
	mkdir -p $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/scilab-getfem++/

override_dh_auto_install:
	dh_auto_install -- DESTDIR=$(CURDIR)/debian/tmp 
	# Workaround for the other archs without scilab getfem++
	mkdir -p $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/scilab-getfem++/
	mkdir -p $(CURDIR)/debian/scilab-getfem++/usr/share/scilab/contrib/
	cd $(CURDIR)/debian/scilab-getfem++/usr/share/scilab/contrib/; \
	rm -f scilab-getfem++; \
	ln -s ../../../lib/$(DEB_HOST_MULTIARCH)/scilab-getfem++/ getfem++

override_dh_install:
	dh_install --list-missing
	dh_numpy

override_dh_installchangelogs:
	dh_installchangelogs ChangeLog

override_dh_strip-arch:
	dh_strip -a --dbg-package=libgetfem++-dbg

override_dh_python2:
	dh_python2 --no-guessing-versions

override_dh_auto_test:
