#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export CFLAGS=$(shell dpkg-buildflags --get CFLAGS)
export CPPFLAGS=$(shell dpkg-buildflags --get CPPFLAGS)
export CXXFLAGS=$(shell dpkg-buildflags --get CFXXLAGS)
export LDFLAGS=$(shell dpkg-buildflags --get LDFLAGS)

export DEB_BUILD_HARDENING=1

WAF_OPTIONS = --verbose --prefix=/usr --destdir=debian/tmp --enable-fftw3f
WAF_CMD = ./waf --nocache

SETUPTOOLS_OPTIONS = --prefix=../debian/tmp/usr --install-layout=deb

%:
	dh $@ --with python2

override_dh_auto_clean:
	#$(WAF_CMD) distclean
	find waflib/ -name *.pyc -delete
	rm -rf build/ .lock-waf*
	rm -rf python/build/ python/gen/ python/lib/*.pyc
	rm -rf debian/tmp
	rm -rf doc/web/
	rm -rf manpages.refs manpages.links

override_dh_auto_configure:
	$(WAF_CMD) configure $(WAF_OPTIONS)

override_dh_auto_build-arch:
	$(WAF_CMD) build $(WAF_OPTIONS)
	cd python; python setup.py --verbose build; cd ..

override_dh_auto_build-indep:
	ln -sf /usr/share/javascript/jquery/jquery.js doc/web/html/jquery.js

override_dh_auto_install:
	$(WAF_CMD) install $(WAF_OPTIONS)
	cd python; python setup.py --verbose install $(SETUPTOOLS_OPTIONS); cd ..
	# call dh_numpy to add dependency on numpy abi
	if [ -x /usr/bin/dh_numpy ]; then dh_numpy; fi
