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

-include /usr/share/dpkg/buildflags.mk

name = globus-gridmap-eppn-callout
_name = globus_gridmap_eppn_callout

INSTALLDIR = $(CURDIR)/debian/tmp

_prefix = /usr
_bindir = $(_prefix)/bin
_sbindir = $(_prefix)/sbin
_includedir = $(_prefix)/include
_libdir = $(_prefix)/lib
_datadir = $(_prefix)/share
_mandir = $(_datadir)/man
_docdir = $(_datadir)/doc/lib$(name)-dev

configure: configure-stamp

configure-stamp:
	dh_testdir

	dh_autoreconf

	CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" \
	FFLAGS="$(FFLAGS)" CPPFLAGS="$(CPPFLAGS)" \
	LDFLAGS="$(LDFLAGS) -Wl,--as-needed -Wl,-z,defs" \
	dh_auto_configure -- \
	   --disable-static \
	   --includedir=$(_includedir)/globus \
	   --libexecdir=$(_datadir)/globus \
	   --docdir=$(_docdir)

	# Reduce overlinking
	sed 's!CC \(.*-shared\) !CC \\\$${wl}--as-needed \1 !' -i libtool

	touch $@

build: build-arch build-indep

build-arch: build-stamp

build-indep:

build-stamp: configure-stamp
	dh_testdir

	$(MAKE)

	touch $@

clean:
	dh_testdir
	dh_testroot

	if [ -r Makefile ] ; then $(MAKE) distclean ; fi

	dh_autoreconf_clean

	rm -f build-stamp configure-stamp

	dh_clean

install: build-stamp
	dh_testdir
	dh_testroot
	dh_prep

	$(MAKE) install DESTDIR=$(INSTALLDIR)

	# Remove libtool archives (.la files)
	rm $(INSTALLDIR)$(_libdir)/*/*.la

	# Remove installed license file
	rm $(INSTALLDIR)$(_docdir)/GLOBUS_LICENSE

binary: binary-arch binary-indep

binary-arch: install
	dh_testdir
	dh_testroot
	dh_installdocs debian/README
	dh_installchangelogs
	dh_install
	dh_missing --fail-missing
	dh_installman
	dh_lintian
	dh_link
	dh_strip --dbgsym-migration='lib$(name)-dbg (<< 1.13-2~)'
	dh_compress
	dh_fixperms
	dh_perl
	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary-indep:

.PHONY: binary binary-arch binary-indep build build-arch build-indep clean configure install
