#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# Remove this if https://github.com/linbox-team/givaro/issues/25 is resolved
# in a future release.
# Inspired by patch for Fedora package by Dan Horák <dan@danny.cz>:
# http://pkgs.fedoraproject.org/cgit/rpms/givaro.git/commit/?id=2755bb0
ifeq ($(DEB_HOST_ARCH_CPU), $(filter $(DEB_HOST_ARCH_CPU), mips64el mipsel s390x))
	export DEB_CXXFLAGS_MAINT_APPEND = -ffp-contract=off
endif

# Remove this if https://github.com/linbox-team/givaro/issues/25 is resolved
# on i386 in a future release.
# Inspired by patch for Fedora package by Dan Horák <dan@danny.cz>:
# http://pkgs.fedoraproject.org/cgit/rpms/givaro.git/commit/?id=e33a38c
ifeq ($(DEB_HOST_ARCH_CPU), $(filter $(DEB_HOST_ARCH_CPU), i386))
	export DEB_CXXFLAGS_MAINT_APPEND = -ffloat-store
endif

override_dh_auto_configure:
	dh_auto_configure -- --with-gmp --enable-shared \
		--libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
		--disable-simd

override_dh_installexamples:
	dh_installexamples -XMakefile -XMakefile.am -XMakefile.in

override_dh_auto_build-indep:
	#mkdir -p docs/givaro-dev-html
	#$(MAKE) -C docs docs_dev
	$(MAKE) docs
	rm -f docs/givaro-*html/COPYING
	rm -f docs/givaro-*html/INSTALL

override_dh_auto_test:
	dh_auto_test --max-parallel=1

# Remove this in next release; fixed upstream:
# https://github.com/linbox-team/givaro/commit/47baccc
override_dh_fixperms-arch:
	dh_fixperms
	chmod -x debian/libgivaro-dev/usr/share/doc/libgivaro-dev/examples/Polynomial/isgenerator.C

override_dh_makeshlibs:
	dh_makeshlibs -V'libgivaro9 (>= 4.0.2-8~)'

dhopts :=

%:
	dh $@ --with autoreconf $(dhopts)
