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

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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

pkg := bowtie

%:
	dh $@

override_dh_auto_build:
	$(MAKE) allall

override_dh_auto_install-arch:
	# remove strange byte-compyled Python code bowtie-buildc (no idea how and why it was created)
	find . -name bowtie-buildc -delete
	find . -name .cvsignore -delete

override_dh_install:
	dh_install
	if [ -d debian/tmp/usr/local/bin ] ; then \
	    dh_install -a usr/local/bin	usr ; \
	fi

override_dh_installman-arch:
	help2man --name="ultrafast memory-efficient short read aligner" --no-info \
             $(CURDIR)/bowtie > $(CURDIR)/debian/$(pkg)/usr/share/man/man1/bowtie.1
	help2man --name="building a colorspace index for bowtie" --no-info \
             $(CURDIR)/bowtie-build > $(CURDIR)/debian/$(pkg)/usr/share/man/man1/bowtie-build.1
	help2man --name="extracts information from a bowtie index" --no-info \
             $(CURDIR)/bowtie-inspect > $(CURDIR)/debian/$(pkg)/usr/share/man/man1/bowtie-inspect.1

override_dh_compress:
	dh_compress -X.ebwt

# Fix bowtie-examples access mode for files in examples/
override_dh_fixperms-indep:
	dh_fixperms
	chmod 644 debian/bowtie-examples/usr/share/doc/bowtie/examples/indexes/*
#	Following line is not needed because gzipped genome/ (by dh_compress) is always 644.
#	chmod 644 debian/bowtie-examples/usr/share/doc/bowtie/examples/genomes/*

override_dh_missing-indep:
	dh_missing -i --list-missing

override_dh_auto_clean:
	rm -f .bowtie*
	dh_auto_clean

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	unset LD_PRELOAD && make simple-test
	ln -s debian/tests
	unset LD_PRELOAD && sh debian/tests/run-unit-test test_at_build_time
	rm -f tests examples[0-9].out
endif