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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- --enable-atlas

override_dh_install:
	dh_install
	find $(CURDIR)/debian/tmp -name "*.pyc" -delete
	d-shlibmove --commit \
		    --multiarch \
		    --devunversioned \
		    --exclude-la \
		    --override s/libgsl23-dev/libgsl-dev/ \
		    --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
	find debian -name __pycache__ | xargs rm -rf
	find debian -name libghmm.la -delete

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
