#!/usr/bin/make -f

%:
	dh $@ --with python3 -Scmake -Bbuild

override_dh_auto_build:
	dh_auto_build -Scmake -Bbuild
	cd build/tests && ctest .

# so that the python build can find it
	ln -s lib/$(DEB_HOST_MULTIARCH)/libolm.so build/
	cd python && make olm-python3
#       make doc # HTML rendering for olm/megolm docs doesn't work properly after conversion to md

override_dh_auto_install:
	dh_auto_install -Scmake -Bbuild
#	olm 3 doesn't change the C ABI from olm 2, so should still work as an olm 2
#       (the version bump was due to incompatibilities in bindings)
	ln -s libolm.so.3 debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libolm.so.2

	mkdir -p $(CURDIR)/debian/python3-olm
	cd python && make headers
	for v in `py3versions -vr`; do \
	  cd $(CURDIR)/python; \
	  python$$v setup.py install -O1 --root=$(CURDIR)/debian/python3-olm/ --install-layout=deb; \
	done
