#!/usr/bin/make -f
#export DH_VERBOSE=1

PYTHONS:=$(shell pyversions --installed; py3versions --installed)

%:
	dh $@  --with autoreconf,python2,python3,sphinxdoc

override_dh_auto_configure:
	dh_auto_configure -- --enable-cuckoo --enable-magic

override_dh_auto_build:
	dh_auto_build
	set -e; for python in $(PYTHONS); do \
		( cd yara-python && $$python setup.py build ); \
	done
	$(MAKE) -C docs html

override_dh_auto_install:
	dh_auto_install
	set -e; for python in $(PYTHONS); do \
		( cd yara-python && $$python setup.py install --skip-build --root ../debian/tmp --install-layout=deb ); \
	done

override_dh_auto_clean:
	rm -rf yara-python/build docs/_build
	dh_auto_clean
	dh_auto_clean --sourcedirectory=yara-python

override_dh_autoreconf:
	mkdir -p m4 libyara/m4
	dh_autoreconf

override_dh_strip:
	dh_strip --dbg-package=yara-dbg

override_dh_install:
	dh_install --fail-missing -X.la

override_dh_installchangelogs:
	dh_installchangelogs
	dh_installchangelogs -p libyara-dev -p libyara3 -p python-yara -p python3-yara -p yara debian/changelog.upstream
