#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

# Hardening
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

# Using HAVE_CSTDDEF to include the stddef header (see patch add_missing_cstddef.patch)
CPPFLAGS += -I/usr/include/mumps_seq -DHAVE_CSTDDEF
LDFLAGS += -llapack -lblas -ldmumps_seq -ldl

%:
	dh $@ --without autoreconf

override_dh_auto_configure:
	./configure --prefix=/usr --libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
	    --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) \
	    --enable-static --with-mumps-lflags='-ldmumps_seq' \
	    --disable-sipopt

override_dh_auto_build-indep:
	make doc

# No tests for the doc package.
override_dh_auto_test-indep:

execute_before_dh_installexamples:
	# Remove full build path from example Makefiles
	for F in $$(find examples -name "Makefile"); do \
	    sed -i -e "s,prefix-map=$(CURDIR),prefix-map=BUILDPATH,g" $$F; \
	done

execute_after_dh_installdocs:
	for F in $$(find debian/ -name "*.html"); do\
	    sed -i 's|<script.*mathjax.*/script>||g' $$F;\
	done

execute_before_dh_link:
	# Removing the installed jquery.js file, a symlink will be created by dh_link
	# from the libjs-jquery package
	find debian/ -name "jquery.js" -delete
