#!/bin/sh

# This file is part of Quipper. Copyright (C) 2011-2013. Please see the
# file COPYRIGHT for a list of authors, copyright holders, licensing,
# and other details. All rights reserved.
# 
# ======================================================================


# Check if we are on Windows

if test "$OS" = "Windows_NT"
then
 SCRIPT_EXT=".bat"
else
 SCRIPT_EXT=".sh"
fi

# Get working directory

SCRIPT_DIR="$(dirname "$0")"
MYNAME="$(basename "$0")"

# Usage message

usage() {
    echo "$MYNAME: the Quipper documentation builder"
    echo ""
    echo "Usage: $MYNAME --help|-h"
    echo "       $MYNAME [anything-other-than-the-above]"
    echo ""
    echo "Options: "
    echo "   --help, -h               : print this message"
    echo "   any-other-than-the-above : passed on to haddock"
    echo ""
    echo "This program is a wrapper around haddock."
    echo "Its usage is therefore exactly the same as that of haddock."
    echo "Try \`haddock --help' for more information."
}

# Test whether we need to print usage

if test "$*" = "--help" -o "$*" = "-h"
then
    usage
    exit 0
fi

# If not, run Haddock with Quipper preprocessor

haddock --optghc=-F                                          \
        --optghc=-pgmF                                       \
        --optghc="$SCRIPT_DIR/convert_template${SCRIPT_EXT}" \
        "$@"
