#!/usr/bin/make -f

-include /usr/share/python/python.mk

PYVERS=$(shell pyversions -vs)

CMAKE_OPTIONS=-DPYTHON_BINDINGS=ON -DCMAKE_SKIP_RPATH=ON -DWITH_STATIC_INCHI=ON

%:
	dh $@ --builddirectory=$(CURDIR)/build --parallel --with=python2

override_dh_auto_configure:
	dh_auto_configure -- -DPYTHON_BINDINGS=ON -DPERL_BINDINGS=ON \
                             -DOBPERL_INSTALLDIRS=vendor \
                             -DCMAKE_SKIP_RPATH=ON -DBUILD_GUI=ON

override_dh_auto_build:
	dh_auto_build
	for pyversion in $(PYVERS); do \
	  cd $(CURDIR)/build/scripts && python$$pyversion \
	  $(CURDIR)/scripts/python/setup.py build \
	  --build-lib=$(CURDIR)/build/scripts/pybuild-$$pyversion; \
	done

override_dh_auto_install:
	dh_auto_install
	for pyversion in $(PYVERS); do \
	  cd $(CURDIR)/build/scripts && python$$pyversion \
	  $(CURDIR)/scripts/python/setup.py install \
	  --root $(CURDIR)/debian/python-openbabel \
	  --prefix=/usr --no-compile \
	  $(py_setup_install_args); \
	done

override_dh_install:
	dh_install -Xperllocal.pod --list-missing

override_dh_compress:
	dh_compress -Xusr/share/doc/libopenbabel-doc/html/

override_dh_auto_test:
	-BABEL_LIBDIR=$(CURDIR)/build/lib \
	LD_LIBRARY_PATH=$(CURDIR)/build/lib \
	dh_auto_test
