#!/usr/bin/make -f
# debian/rules for blitz++
# 2011         Andreas Tille <tille@debian.org> 

version=0.9
libname=libblitz
pkgname=$(libname)0ldbl
docname=$(libname)-doc

PREFIX = /usr

%:
	dh $@ -with autotools-dev
	# dh --with autotools-dev --with autoreconf $@ # Needs Build-Depends: dh-autoreconf

override_dh_auto_configure:
	mv doc/blitz.info doc/blitz.info.save
	# dh_autotools-dev_updateconfig
	F77=gfortran ./configure --prefix=$(PREFIX) --with-cxx=gcc --with-blas --enable-debug --enable-static --enable-64bit --enable-shared --enable-doxygen CFLAGS="-g -O2 -DBZHAVE_STD" CXXFLAGS="-g -O2 -DBZ_HAVE_STD"

override_dh_auto_build:
	mv doc/blitz.info.save doc/blitz.info
	dh_auto_build
	cd doc && $(MAKE) all


override_dh_compress:
	dh_compress --exclude=examples --exclude=testsuite --exclude=.pdf

override_dh_install:
	dh_install
	mkdir -p `pwd`/debian/tmp/$(PREFIX)/share/doc/libblitz-doc/html
	for ext in html gif jpg ; do \
	    mv `pwd`/debian/tmp/$(PREFIX)/share/doc/blitz-0.9/*.$${ext} `pwd`/debian/tmp/$(PREFIX)/share/doc/libblitz-doc/html ; \
	done
	d-shlibmove --ldbl --commit \
	            --movedev "debian/tmp/usr/lib/pkgconfig/*" usr/lib/pkgconfig \
	            lib/.libs/libblitz.so

	#######    --movedev "debian/tmp/usr/lib/*.la" usr/lib \
	# Make sure there will be no *.la file created automagically by d-shlibmove
	find debian -name "*.la" -delete

	# Delete copy of jquery.js and replace it by a link (in dh_links) to libjs-jquery version
	rm -f debian/$(docname)/usr/share/doc/$(docname)/html/doxygen/jquery.js
