#!/bin/sh
MANDIR=debian/mans
mkdir -p $MANDIR

VERSION=`dpkg-parsechangelog | awk '/^Version:/ {print $2}' | sed -e 's/^[0-9]*://' -e 's/-.*//' -e 's/[+~]dfsg$//'`
NAME=`grep "^Description:" debian/control | sed 's/^Description: *//' | head -n1`
PROGNAME=`grep "^Package:" debian/control | sed 's/^Package: *//' | head -n1`

AUTHOR=".SH AUTHOR\nThis manpage was written by $DEBFULLNAME for the Debian distribution and
can be used for any other usage of the program.
"

# If program name is different from package name or title should be
# different from package short description change this here
progname=kissnp2
help2man --no-info --no-discard-stderr --help-option=" -help" \
         --name="detects SNPs and indels from read sets" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=kissreads2
help2man --no-info --no-discard-stderr --help-option=" -help" \
         --name="enhances the kissnp2 results by computing per read set" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=run_discoSnp++.sh
help2man --no-info --no-discard-stderr --help-option=" -h" \
         --name="pipelining kissnp2 and kissreads for calling SNPs and small indels from NGS reads without the need of a reference genome" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=run_discoSnpRad.sh
help2man --no-info --no-discard-stderr --help-option=" -h" \
         --name="pipelining kissnp2 and kissreads and clustering per locus for calling SNPs and small indels from RAD-seq data without the need of a reference genome" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

echo "$MANDIR/*.1" > debian/manpages

cat <<EOT
Please enhance the help2man output.
The following web page might be helpful in doing so:
    http://liw.fi/manpages/
EOT
