#!/usr/bin/make -f

include debian/cdbs/1/class/scons.mk
include /usr/share/cdbs/1/rules/debhelper.mk

DEB_COMPRESS_EXCLUDE := .pdf
DEB_INSTALL_DOCS_ALL += README AUTHORS TODO
DEB_SCONS_OPTIONS = prefix=/usr
DEB_DH_INSTALL_SOURCEDIR = debian/tmp
DEB_SCONS_INSTALL_OPTIONS = DESTDIR=$(CURDIR)/debian/tmp
USCAN_DESTDIR := $(CURDIR)
SCONS = `which scons`
PYVERSIONS = $(shell pyversions --requested debian/control)

clean::
	rm -f config.log
	rm -f options.cache
	rm -f src/ufc/_ufc.so
	rm -f src/ufc/ufc.py
	rm -f src/ufc/ufc_wrap.cc
	rm -f src/ufc/ufc_wrap.cxx
	rm -f src/ufc/ufc_wrap.os
	rm -f swig_config.pyc
	rm -f ufc-1.pc
	-rm -rf $(addprefix build-, $(PYVERSIONS))
	-rm -rf $(addprefix build-stamp-, $(PYVERSIONS))
	-rm -rf $(addprefix install-stamp-, $(PYVERSIONS))

common-build-arch:: $(addprefix build-stamp-, $(PYVERSIONS))
build-stamp-%:
	mkdir build-$*
	cp -r `ls | grep -vE '(build-|stamp|debian)'` build-$*
	cd build-$* && `which $*` $(SCONS) prefix=/usr
	touch $@

common-install-arch:: $(addprefix install-stamp-, $(PYVERSIONS))
install-stamp-%:
	cd build-$* && `which $*` $(SCONS) install DESTDIR=$(CURDIR)/debian/tmp
	touch $@

binary-install/python-ufc::
	dh_pycentral -p$(cdbs_curpkg)

get-orig-source:
	uscan --force-download --verbose --destdir $(USCAN_DESTDIR)
