#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS=optimize=+lto

include /usr/share/octave/debian/defs.make

# The following is used by dh_elpa(1) for determining the package version number
include /usr/share/dpkg/pkg-info.mk
export DEB_VERSION_UPSTREAM

# Needed for texlive to respect SOURCE_DATE_EPOCH when setting date (#974957)
export FORCE_SOURCE_DATE=1

%:
	dh $@ --with sphinxdoc,elpa

override_dh_auto_configure:
	dh_auto_configure -- -Dbuild_for=octave -Dmathjax_path=/usr/share/javascript/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML

override_dh_auto_build:
# Also build PDF and HTML docs (unless nodoc is given)
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	dh_auto_build -- all doc
	rm -rf doc/manual/utils/__pycache__/ # This must not end up in dynare-matlab
else
	dh_auto_build
endif

# Don't run the testsuite
override_dh_auto_test:

override_dh_link:
	dh_link --package=dynare /usr/lib/dynare/matlab/dynare.m $(MDIR)/dynare.m

# See #1114630
override_dh_shlibdeps:
	dh_shlibdeps -l/usr/lib/${DEB_HOST_MULTIARCH}/octave/$(shell octave-config -p VERSION)

# Generate a versioned dependency on octave, and a dependency on the virtual octave-abi-NN
execute_before_dh_gencontrol:
	dh_octave_substvar
