#!/usr/bin/make -f
# -*- makefile -*-
# debian/rules for macs

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

pkg := $(shell dpkg-parsechangelog | sed -n 's/^Source: //p')
version=$(shell dpkg-parsechangelog -ldebian/changelog | grep Version: | cut -f2 -d' ' | cut -f1 -d- )
mandir=$(CURDIR)/debian/$(pkg)/usr/share/man/man1/

%:
	dh $@ --with python2

override_dh_auto_clean:
	dh_auto_clean
	find -type f -name '*.c' -exec rm -f '{}' ';' 

override_dh_auto_install:
	dh_auto_install
	
	# try to create man pages whereever possible
	mkdir -p $(mandir)	
	export PYTHONPATH=$(CURDIR)/build/`ls build | grep ^lib\. | head -n 1` ; \
	export PATH=$(CURDIR)/build/`ls build | grep ^scripts- | head -n 1`:$${PATH} ; \
	help2man --no-info --name='Fine-tuning script to call broad peaks from a single bedGraph track for scores' \
	    --version-string="$(version)"  \
		 bdgbroadcall > $(mandir)/bdgbroadcall.1 ; \
	help2man --no-info --name='Calculate scores using certain method by comparing a bedGraph file from treatment and a file from control representing local bias' \
	    --version-string="$(version)"  \
		 bdgcmp > $(mandir)/bdgcmp.1 ; \
	help2man --no-info --name='Naive call differential peaks from 4 bedGraph tracks for scores' \
	    --version-string="$(version)" \
		 bdgdiff > $(mandir)/bdgdiff.1 ; \
	help2man --no-info --name='Naive call peaks from a single bedGraph track for scores' \
	    --version-string="$(version)" \
		 bdgpeakcall > $(mandir)/bdgpeakcall.1 ; \
	help2man --no-info --name='Filter duplicate reads depending on sequencing depth' \
	    --version-string="$(version)" \
		 filterdup > $(mandir)/filterdup.1 ; \
	help2man --no-info --name='Model-based Analysis for ChIP-Sequencing' \
	    --version-string="$(version)" \
		 macs2 > $(mandir)/macs2.1 ; \
	help2man --no-info --name='Differential Analysis for ChIP-Sequencing' \
	    --version-string="$(version)" \
		 macs2diff > $(mandir)/macs2diff.1 ; \
	help2man --no-info --name='Random sample certain number/percentage of tags' \
	    --version-string="$(version)" \
		 randsample > $(mandir)/randsample.1
