#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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

%:
	dh $@ 

override_dh_auto_build:
	$(MAKE) DEBUG_OPTIONS=-g -C src all
	cd src && make install

override_dh_clean:
	dh_clean
	$(MAKE) -C src clobber

override_dh_strip:
	dh_strip --dbg-package=eigensoft-dbg

override_dh_install:
	dh_install
	# the file is empty
	rm -f debian/eigensoft/usr/share/eigen*/POPGEN/HGDP.X.perl

VERSION=4.2
get-orig-source:
	[ -r ../eig$(VERSION).tar.gz ] || wget http://www.hsph.harvard.edu/faculty/alkes-price/files/eig$(VERSION).tar.gz -O ../eig$(VERSION).tar.gz
	rm -rf ../EIG$(VERSION)
	cd .. && tar xzf eig$(VERSION).tar.gz
	cd .. && mv EIG$(VERSION) eigensoft-$(VERSION)
	find ../eigensoft-$(VERSION)/bin -type f | grep -v '.perl$$' | egrep -v '(fixgreen|ploteig)' | xargs -r rm
	find ../eigensoft-$(VERSION)/POPGEN -type f | grep -v '.perl$$' | xargs -r chmod -x
	find ../eigensoft-$(VERSION)/CONVERTF -type f | grep -v '.perl$$' | xargs -r chmod -x
	find ../eigensoft-$(VERSION)/EIGENSTRAT -type f | grep -v '.perl$$' | xargs -r chmod -x
	#find ../eigensoft-$(VERSION) -name "*.o" -delete
	make -C ../eigensoft-$(VERSION)/src clobber
	cd .. && tar cjf eigensoft_$(VERSION).orig.tar.bz2 eigensoft-$(VERSION)
