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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

%:
	dh $@ --with python2 --enable-gsl --enable-atlas

override_dh_auto_configure:
	dh_auto_configure -- --with-python=python2

override_dh_install:
	dh_install
	find $(CURDIR)/debian/tmp -name "*.pyc" -delete
	d-shlibmove --commit \
		    --multiarch \
		    --devunversioned \
		    --exclude-la \
		    --movedev debian/tmp/usr/include usr \
		    debian/tmp/usr/lib/*/*.so
	cd $(CURDIR)/debian/ghmm/usr/bin/ && mv cluster ghmm-cluster
	sed -i -e 's@ [^ ]*-f\(file\|debug\)-prefix-map=[^ ]*@@g' \
		$(CURDIR)/debian/ghmm/usr/bin/ghmm-config
	#echo "FIXME: The following files are not installed"
	#ls -l $(find . -name site-packages)
	# cd $(CURDIR)/debian/tmp/usr/lib/python2.7/ && mv site-packages dist-packages

override_dh_auto_clean:
	if [ -r Makefile ]; then $(MAKE) clean; fi
	find . -name Makefile -delete
	find . \( -name "*.o" -o -name "*.lo" \) -delete
	rm -f ghmmwrapper/ghmmwrapper.py ghmmwrapper/ghmmwrapper_wrap.c
	rm -rf HMMEd/build/ ghmmwrapper/build/
	rm -f config.h config.log config.status
	rm -f libtool stamp-h1 tests/chmm_test.2JNcXz
	rm -f tools/ghmm-config
	rm -rf ghmm/.deps/ tests/.deps/ tools/.deps/

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	$(MAKE) --directory=tests
endif
