#!/usr/bin/make -f

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	SCONSOPTS += -j$(NUMJOBS)
endif

%:
		dh $@ --with python2

override_dh_auto_configure:
	mkdir build-python$*
	ln -s gnukfreebsd9-config.py build/gnukfreebsd10-config.py
	cp -r build engine ext utils SConstruct setup.py test_fife.py build-python$*
	find build-python$*/engine/core/ext/tinyxml -type f -a \! -name fife_tinyxml.h -delete
	touch $@

override_dh_auto_build:
	python$* $(shell which scons) -C build-python$* fife-python $(SCONSOPTS)

override_dh_auto_test:
	python$* $(shell which scons) -C build-python$* tests $(SCONSOPTS)


override_dh_auto_install:
	python$* $(shell which scons) -C build-python$* DESTDIR=$(CURDIR)/debian/python-fife install-python $(SCONSOPTS)
	find $(CURDIR)/debian/python-fife -name '*.so' -exec chrpath -d {} \;

override_dh_auto_clean:
	rm -fr build-python*
	rm -f debian/stamps/*
	rm -f build/gnukfreebsd10-config.py
	dh_auto_clean

