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

export CXXFLAGS += -Wall
export LDFLAGS += -Wl,--no-undefined -Wl,-rpath=/usr/lib/voxbo/lib

# one ring to rule them all ...
%:
	dh $@

override_dh_auto_configure:
	./configure.py -s -p neurodebian

override_dh_auto_build:
	$(MAKE) QTDIR=/usr \
			QTBASEINCDIR=/usr/include/qt4 \
			MOC=/usr/bin/moc-qt4 \
			VB_SHARED=1

override_dh_auto_install:
	$(MAKE) install VB_PREFIX=$(CURDIR)/debian/voxbo/usr/lib/voxbo
	install -d $(CURDIR)/debian/voxbo/usr/lib/voxbo/lib
	install -t $(CURDIR)/debian/voxbo/usr/lib/voxbo/lib $(shell find . -name '*.so')
	# cleanup
	-rm $(CURDIR)/debian/voxbo/usr/lib/voxbo/bin/vbinstall
	# no Matlab stuff
	-rm $(CURDIR)/debian/voxbo/usr/lib/voxbo/bin/spm8*

override_dh_clean:
	$(MAKE) distclean
	dh_clean

override_dh_shlibdeps:
	dh_shlibdeps -l $(CURDIR)/debian/voxbo/usr/lib/voxbo/lib

override_dh_install:
	dh_install
	# remove obsolete license file (voxbo doesn't ship this template) but it
	# comes from the mni-colin27-nifti package
	-rm debian/voxbo/usr/lib/voxbo/elements/templates/ch2_license.txt
