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

VERSION=`dpkg-parsechangelog | awk '/^Version:/ {print $2}' | sed -e 's/^[0-9]*://' -e 's/-.*//' -e 's/[+~]dfsg$//'`

help2man --no-info --no-discard-stderr --help-option=" " \
         --name='ea-utils: Approximate line counts for each file.' \
            --version-string="$VERSION" alc > $MANDIR/alc.1

help2man --no-info --no-discard-stderr --help-option="-h" \
         --name='ea-utils: read sam, fastq or pileup and return the phred-scale' \
            --version-string="$VERSION" determine-phred > $MANDIR/determine-phred.1

help2man --no-info --no-discard-stderr --help-option="-h" \
         --name='ea-utils: removes one or more adapter sequences from the fastq file' \
            --version-string="$VERSION" fastq-clipper > $MANDIR/fastq-clipper.1

help2man --no-info --no-discard-stderr --help-option="-h" \
         --name='ea-utils: join two paired-end reads on the overlapping ends' \
            --version-string="$VERSION" fastq-join > $MANDIR/fastq-join.1

help2man --no-info --no-discard-stderr --help-option="-h" \
         --name='ea-utils: detect levels of adapter presence, compute likelihoods and locations of the adapters' \
            --version-string="$VERSION" fastq-mcf > $MANDIR/fastq-mcf.1

help2man --no-info --no-discard-stderr --help-option="-h" \
         --name='ea-utils: replace '%' with the barcode id in the barcodes file' \
            --version-string="$VERSION" fastq-multx > $MANDIR/fastq-multx.1

help2man --no-info --no-discard-stderr --help-option="-h" \
         --name='ea-utils: produce lots of easily digested statistics' \
            --version-string="$VERSION" fastq-stats > $MANDIR/fastq-stats.1

LC_ALL=C help2man --no-info --no-discard-stderr --help-option="-h" \
         --name='ea-utils: R script to process fastq-stats output' \
            --version-string="$VERSION" fastx-graph \
            | sed -e '/^Loading/d' -e '/Attaching package/d' -e '/^The following objects are masked from/d' -e '/^format.pval/d' > $MANDIR/fastx-graph.1

help2man --no-info --no-discard-stderr --help-option="-h" \
         --name='ea-utils: return random entries from the input fastq' \
            --version-string="$VERSION" randomFQ > $MANDIR/randomFQ.1

help2man --no-info --no-discard-stderr --help-option="-h" \
         --name='ea-utils: produce digested statistics' \
            --version-string="$VERSION" sam-stats > $MANDIR/sam-stats.1

help2man --no-info --no-discard-stderr --help-option="-h" \
         --name='ea-utils: output summry stats or perform variant calling' \
            --version-string="$VERSION" varcall > $MANDIR/varcall.1

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

