#!/usr/bin/make -f
# Sample debian/rules for mothur
# Andreas Tille <tille@debian.org>

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

ARCHBITS ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH_BITS)
THREADS ?= -j3

%:
	dh $@

override_dh_auto_build:
	if [ $(ARCHBITS) -eq 64 ] ; then \
	    dh_auto_build -- $(THREADS) 64BIT_VERSION=yes USEMPI=yes && \
	    mv mothur mothur-mpi && make clean && \
	    dh_auto_build -- $(THREADS) 64BIT_VERSION=yes USEMPI=no ; \
	else \
	    dh_auto_build -- $(THREADS) 64BIT_VERSION=no USEMPI=yes && \
	    mv mothur mothur-mpi && make clean && \
	    dh_auto_build -- $(THREADS) 64BIT_VERSION=no USEMPI=no ; \
	fi

override_dh_auto_install:
	true

#Cleaning needs help right now
override_dh_auto_clean:
	rm -f mothur mothur-mpi *.o mothur.*.logfile
	make clean
	( cd uchime_src && rm -f *.o mk.stdout mk.stderr tmp.stderr )

# Remark: The following uscan command requires devscripts > 2.12.4 which is not
#         yet released at the time of this package release.  The code can be obtained
#         via
#   git clone git://tille@git.debian.org/git/users/tille/devscripts.git
#         and then use scripts/uscan.pl
#         Alternatively you can use
#	    . debian/get-orig-source
get-orig-source:
	uscan --verbose --force-download --repack --repack-compression xz
