#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
# export DH_VERBOSE=1

pkg:= $(shell dpkg-parsechangelog | awk '/^Source:/ {print $$2}')

# allow bashism's in commandlines
SHELL = /bin/bash

# variables to be used in configure invocation. see
# autotools-dev/README.Debian.gz
export DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

# use autoconf 2.52 or newer
ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
  confflags += --build $(DEB_HOST_GNU_TYPE)
else
  confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
endif

## Build BLAST parsing script mcxdeblast and the pipeline script mclblastline
## (sources in src/alien/oxygen).  It encapsulates all the stages of parsing,
## matrix creation, running mcl, and formatting the result
## into a single application.
confflags += --enable-blast

## add --enable-tribe to confflags to add the upstreams supplied tribe tools
## (protein clustering stuff).  This builds and installs the tools
##
##  tribe-families  tribe-matrix  tribemcl  tribe-parse
##
## We're not doing it since tribe-matrix segfaults, and the tools lackproper
## manpages.  Furthermore, the BLAST parsing scripts can be used in place of
## the tribe module.

# confflags += --enable-tribe

## If you really want to suppress the citation reference printed by MCL (the
## one which looks like
##
##  Please cite:
##    Stijn van Dongen, Graph Clustering by Flow Simulation.  PhD thesis,
##    University of Utrecht, May 2000.
##       (  http://www.library.uu.nl/digiarchief/dip/diss/1895620/full.pdf
##       or  http://micans.org/mcl/lit/svdthesis.pdf.gz)
##  OR
##    Stijn van Dongen, A cluster algorithm for graphs. Technical
##    Report INS-R0010, National Research Institute for Mathematics
##    and Computer Science in the Netherlands, Amsterdam, May 2000.
##       (  http://www.cwi.nl/ftp/CWIreports/INS/INS-R0010.ps.Z
##       or  http://micans.org/mcl/lit/INS-R0010.ps.Z)
##
## ), then this is the place to do it.  Of course we honor the choice of
## upstream here, and build as suggested by upsteam.

# confflags += --disable-helpful-reminder

docbackupdir:=$(CURDIR)/debian/doc.bak

%:
	dh $@ --with autotools_dev

override_dh_auto_clean:
	dh_auto_clean
	if [ -d $(docbackupdir) ] ; then \
	    rm -rf doc ; \
	    mv $(docbackupdir) doc ; \
	fi

override_dh_auto_configure:
	cp -a doc $(docbackupdir)
	./configure \
           $(confflags) \
           --prefix=/usr \
           --mandir=\$${prefix}/share/man \
           --infodir=\$${prefix}/share/info
