#!/usr/bin/make -f

export PYBUILD_DESTDIR_python3=debian/python3-sympy/
export PYBUILD_TEST_ARGS=-k 'not (TestUpdateArgsWithPaths)'

include /usr/share/dpkg/default.mk

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

%:
	dh  $@ --with python3,sphinxdoc --buildsystem=pybuild

execute_before_dh_auto_build:
	# build the documentation in HTML format
	faketime '@$(SOURCE_DATE_EPOCH)' \
		sh -c '(cd doc/; export SPHINXOPTS="-j auto"; $(MAKE) html)'

DOCDIR = debian/python-sympy-doc/usr/share/doc/python-sympy-doc
execute_after_dh_auto_install:
	mv debian/python3-sympy/usr/bin/isympy debian/isympy-common/usr/bin/
	mv debian/python3-sympy/usr/share/man/man1/* \
		debian/isympy-common/usr/share/man/man1/
	rm -rf debian/python*-sympy/usr/bin/
	rm -rf debian/python*-sympy/usr/share/man/
	# Get rid of embedded mpmath.  Unfortunately, we
	# can't remove all files with quilt (empty files, for example).
	rm -rf debian/python*-sympy/usr/lib/python*/dist-packages/sympy/mpmath/
	# create the file version.json for the package python-sympy-doc
	install -d $(DOCDIR)
	v=$(DEB_VERSION_UPSTREAM_REVISION); \
	  echo "{\"latest\": \"$$v\", \"dev\": \"$$v\"}" > \
	    $(DOCDIR)/version.json

execute_after_dh_auto_clean:
	cd doc/; $(MAKE) clean;
