#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk
# include /usr/share/cdbs/1/rules/patchsys-quilt.mk
include /usr/share/cdbs/1/class/autotools.mk


# Disable checks: known bad test case ignored this release
#DEB_MAKE_CHECK_TARGET := check
DEB_MAKE_CLEAN_TARGET := clean distclean maintainer-clean
DEB_CONFIGURE_EXTRA_FLAGS :=  --enable-shared --with-pic
DEB_AUTO_UPDATE_LIBTOOL := pre
DEB_CONFIGURE_SCRIPT_ENV += \
    CFLAGS="-D_HDFEOS5_THREADSAFE" \
    CPPFLAGS="-Df2cFortran -I/usr/include/hdf"

clean::
	[ ! -f Makefile ] || $(MAKE) distclean

makebuilddir/libhe5-hdfeos-dev::
	# Needed for the pthreads tests
	cp  samples/simple.txt testdrivers/threads
	# Need to prod quilt for some reason.
	# QUILT_PATCHES=debian/patches quilt push -a
	autoreconf -is

configure/libhe5-hdfeos-dev::
	# Delete the libtool crap and install debian libtool
	rm -f libtool
	ln -sf /usr/bin/libtool .

install/libhe5-hdfeos-dev::
	$(MAKE) -C samples clean
	cp -a samples/* debian/libhe5-hdfeos-dev/usr/share/doc/libhe5-hdfeos-dev/examples
	chmod -x debian/libhe5-hdfeos-dev/usr/share/doc/libhe5-hdfeos-dev/examples/*

install/libhe5-hdfeos0::
	mv debian/tmp/usr/lib/libhe5_hdfeos.so.0.0.0  debian/libhe5-hdfeos0/usr/lib/libhe5_hdfeos.so.0.0.0
	ln -sf libhe5_hdfeos.so.0.0.0 debian/libhe5-hdfeos0/usr/lib/libhe5_hdfeos.so.0
	

# Store build information
common-binary-post-install-arch common-binary-post-install-indep::
	dh_buildinfo
