#!/usr/bin/make -f
# -*- makefile -*-
# debian/rules of libhmsbeagle

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

pkg := $(shell dpkg-parsechangelog | sed -n 's/^Source: //p')
lib := $(pkg)1
use_sse := $(shell if [ `dpkg-architecture -qDEB_BUILD_ARCH` = amd64 ] ; then echo yes ; else echo no ; fi)

%:
	dh $@ --with autoreconf --with javahelper

override_dh_auto_configure:
	./autogen.sh
	dh_auto_configure -- --enable-doxygen-man --enable-march-native=no --enable-sse=$(use_sse)

override_dh_auto_build:
	$(MAKE)
	$(MAKE) doxygen-doc
	ant

override_dh_install:
	dh_install
	jniso=`find debian/$(lib) -name $(pkg)-jni.so` ; \
	mkdir -p `dirname $$jniso`/jni ; \
	mv $$jniso `dirname $$jniso`/jni

override_dh_auto_clean:
	$(MAKE) -f Makefile distclean || true
	rm -rf doc .config configure
	rm -rf lib build

# Does not help to fix the lintian issue ... hmmm
#override_dh_shlibdeps:
#	# somehow shlibdeps is not called for jni subdir
#	dh_shlibdeps -- debian/$(pkg)1/usr/lib/jni/* debian/$(pkg)1/usr/lib/lib*

override_dh_installdocs:
	dh_installdocs
	find debian/$(pkg)-dev -name jquery.js -delete

get-orig-source:
	. debian/get-orig-source
