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

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

INSTALLDIR = $(CURDIR)/debian/tmp

_prefix = /usr
_libdir = $(_prefix)/lib
_datadir = $(_prefix)/share

configure: configure-stamp

configure-stamp:
	dh_testdir

	mkdir -p src/autogen
	dh_autoreconf

	CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" FFLAGS="$(FFLAGS)" \
	CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS) -Wl,-z,defs" ./configure \
	   --prefix=$(_prefix) \
	   --libdir=$(_libdir)/voms \
	   --disable-static

	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) clean && $(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)

	rm $(INSTALLDIR)$(_libdir)/voms/libvomsmysql.la

binary: binary-arch

binary-arch: install
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installchangelogs
	dh_install --fail-missing
	dh_installman
	dh_lintian
	dh_link
	dh_strip --dbg-package=voms-mysql-plugin-dbg
	dh_compress
	dh_fixperms
	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
