#!/usr/bin/make -f

export PYBUILD_NAME=xgboost
export DH_VERBOSE=1

%:
	+dh $@ --with python2,python3 --buildsystem=pybuild \
	       --sourcedirectory=xgboost-python

override_dh_auto_clean:
# ROODIR [sic] is undefined, but the Makefile attempts to 'cd' to it,
# which will fail if $HOME is nonexistent
	$(MAKE) clean_all ROODIR=/
	rm -rf xgboost-python
	rm -rf .pybuild

override_dh_auto_configure:
	$(MAKE) pippack ROODIR=/
	$(MAKE) -C xgboost-python/xgboost lib/libxgboost.so
	dh_auto_configure

override_dh_auto_install:
	dh_auto_install
	find debian/python*-xgboost -name .gitignore -delete
	find debian/python*-xgboost -name LICENSE -delete
	find debian/python*-xgboost -name '*.sln' -delete
# omit code examples which are not valid python 3
	rm debian/python3-xgboost/usr/lib/python3*/dist-packages/xgboost/rabit/guide/basic.py
	rm debian/python3-xgboost/usr/lib/python3*/dist-packages/xgboost/rabit/guide/broadcast.py
	rm debian/python3-xgboost/usr/lib/python3*/dist-packages/xgboost/rabit/test/local_recover.py

override_dh_python2:
	dh_python2 --no-ext-rename

override_dh_python3:
	dh_python3 --no-ext-rename
