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

CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)
CFLAGS:=$(shell dpkg-buildflags --get CFLAGS)
CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS)
LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS)

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

PREFIX = /usr

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

override_dh_auto_configure:
	# dh_autotools-dev_updateconfig
	
	libtoolize --automake
	aclocal -Im4
	autoreconf -i
	automake
	
	F77=gfortran ./configure --prefix=$(PREFIX) --with-cxx=gcc --with-blas --enable-debug --enable-static --enable-64bit --enable-shared --enable-doxygen CFLAGS="${CFLAGS} -DBZHAVE_STD" CXXFLAGS="${CXXFLAGS} -DBZ_HAVE_STD"

override_dh_auto_build:
	#dh_auto_build
	#cd doc && $(MAKE) all
	
	# update doxigen conf file
	cd doc/doxygen && doxygen -u
	 
	$(MAKE) lib
	$(MAKE) info              #Build Blitz++ texinfo documentation
	
	mkdir -p doc/doxygen/html
	$(MAKE) pdf              #Build Blitz++ pdf documentation
	$(MAKE) html             #Build Blitz++ html documentation

override_dh_auto_test:
	#
	# TODO find . -name \*.htmlneed to be patched to compile properly
	#$(MAKE) check-testsuite  #Build and check the testsuite
	
	$(MAKE) check-examples   #Build and check the examples
	
	#$(MAKE) check-benchmarks #Build and check the benchmarks (long)

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/blitz.pc" 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


override_dh_clean:
	dh_clean
