#!/usr/bin/make -f
# -*- makefile -*-
#
#  FIXME - don't edit this file any more.  Pull Steffen's version and work from there.
#  Except that won't work with Ubuntu 10.04 so we're stuffed.

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

export DEB_PYTHON_SYSTEM=pycentral
export DEB_COMPRESS_EXCLUDE=.js .sff .qual .fna .fna.txt

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/python-distutils.mk

export ROOTDIR=debian/`dh_listpackages`

# Apparently the override_dh_* mechanism doesn't work with the above includes??
# Yes, see http://lists.debian.org/debian-med/2011/03/msg00211.html
# TODO - redo this file as Andreas suggested.
clean::
	rm -rf doc/_build/*
	( cd qiime/support_files/denoiser/FlowgramAlignment && make clean ) || true
	rm -f qiime/support_files/denoiser/bin/*

#Lots of shuffling to be done...
# Python scripts go into /usr/lib/qiime/bin (not /usr/bin)
# Helper script goes into /usr/bin
# Setup scripts go into /usr/lib/qiime/shell
# Default configuration goes into /etc/qiime/default_qiime_config
# ...or maybe it should be copied to $HOME/.qiime_config on 1st run?
# Since 3.0, denoiser is aliased to Qiime
common-binary-fixup-arch::
	install -m 755 -d $(ROOTDIR)/usr/lib/qiime/bin
	install -m 755 -d $(ROOTDIR)/etc/qiime
	mv $(ROOTDIR)/usr/bin/*.py  $(ROOTDIR)/usr/lib/qiime/bin
	install -m 755 debian/scripts/qiime $(ROOTDIR)/usr/bin
	ln -sf qiime $(ROOTDIR)/usr/bin/denoiser
	install -m 755 debian/scripts/uclust $(ROOTDIR)/usr/lib/qiime/bin
	cp -R --no-preserve=all debian/scripts/shell $(ROOTDIR)/usr/lib/qiime
	rm -rf $(ROOTDIR)/usr/lib/qiime/shell/.svn
	chmod -R a+rX $(ROOTDIR)/usr/lib/qiime/shell
	chmod -R go-w $(ROOTDIR)/usr/lib/qiime/shell
	rm -rf $(ROOTDIR)/etc/qiime/qiime_config
	install -m 644 debian/scripts/qiime_config $(ROOTDIR)/etc/qiime/qiime_config
	# Lintian complains about case of ChangeLog.gz
	( cd $(ROOTDIR)/usr/share/doc/`dh_listpackages` ; mv ChangeLog.gz changelog.gz || true )
	# And about the existence of /usr/qiime
	mv $(ROOTDIR)/usr/qiime/support_files $(ROOTDIR)/usr/lib/qiime && rmdir $(ROOTDIR)/usr/qiime
