#!/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=${PROGNAME}
help2man --no-info --no-discard-stderr  \
         --name="Mapping PacBio sequences to references" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=createChemistryHeader
help2man --no-info --no-discard-stderr \
         --name="Create a SAM header with PacBio sequencing chemistry information" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=extractUnmappedSubreads
help2man --no-info --no-discard-stderr \
         --name="Extract unmapped subreads from a fasta file" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=loadChemistry
help2man --no-info --no-discard-stderr \
         --name="Load PacBio sequencing chemistry information" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

progname=maskAlignedReads
help2man --no-info --no-discard-stderr \
         --name="Mask aligned reads in regions file" \
            --version-string="$VERSION" ${progname} > $MANDIR/${progname}.1
echo $AUTHOR >> $MANDIR/${progname}.1

rm -f $MANDIR/*.py.1
for man in $MANDIR/*.1 ; do
    ln -s `basename $man` $MANDIR/`basename $man .1`.py.1
done

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
