#!/bin/sh
## Jabber config program, graciously based on etherx-config
## Released under the GPL, refer to the file COPYING
##

prefix="/usr"
exec_prefix="${prefix}"

etherx_prefix="$prefix"
etherx_exec_prefix="$exec_prefix"
etherx_bindir="${exec_prefix}/bin"
etherx_libdir="${exec_prefix}/lib"
etherx_includedir="${prefix}/include"
etherx_mandir="${prefix}/man"
etherx_datadir="${prefix}/share"
etherx_acdir="${prefix}/share/aclocal"
etherx_cflags="-g -O2"
etherx_ldflags=""
etherx_libs="-ladns -lpth -lnsl -ldl "
etherx_version="1.0"

help=no
version=no

usage="etherx-config"
usage="$usage [--help] [--version] [--all]"
usage="$usage [--prefix] [--exec-prefix] [--bindir] [--libdir] [--includedir] [--mandir] [--datadir] [--acdir]"
usage="$usage [--cflags] [--ldflags] [--libs]"
if [ $# -eq 0 ]; then
    echo "etherx-config:Error: Invalid option" 1>&2
    echo "etherx-config:Usage: $usage" 1>&2
    exit 1
fi
output=''
output_extra=''
all=no
prev=''
OIFS="$IFS" IFS="$DIFS"
for option
do
    if [ ".$prev" != . ]; then
        eval "$prev=\$option"
        prev=''
        continue
    fi
    case "$option" in
        -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
           *) optarg='' ;;
    esac
    case "$option" in
        --help|-h)
            echo "Usage: $usage"
            echo "Report bugs to http://bugs.jabber.org"
            exit 0
            ;;
        --version|-v)
            echo "Etherx $etherx_version"
            exit 0
            ;;
        --all)
            all=yes
            ;;
        --prefix)
            output="$output $etherx_prefix"
            ;;
        --exec-prefix)
            output="$output $etherx_exec_prefix"
            ;;
        --bindir)
            output="$output $etherx_bindir"
            ;;
        --libdir)
            output="$output $etherx_libdir"
            ;;
        --includedir)
            output="$output $etherx_includedir"
            ;;
        --mandir)
            output="$output $etherx_mandir"
            ;;
        --datadir)
            output="$output $etherx_datadir"
            ;;
        --acdir)
            output="$output $etherx_acdir"
            ;;
        --cflags)
            output="$output -I$etherx_includedir"
            output_extra="$output_extra $etherx_cflags"
            ;;
        --ldflags)
            output="$output -L$etherx_libdir"
            output_extra="$output_extra $etherx_ldflags"
            ;;
        --libs)
            output="$output -letherx"
            output_extra="$output_extra $etherx_libs"
            ;;
        * )
            echo "etherx-config:Error: Invalid option" 1>&2
            echo "etherx-config:Usage: $usage" 1>&2
            exit 1;
            ;;
    esac
done
IFS="$OIFS"
if [ ".$prev" != . ]; then
    echo "etherx-config:Error: missing argument to --`echo $prev | sed 's/_/-/g'`" 1>&2
    exit 1
fi
if [ ".$output" != . ]; then
    if [ ".$all" = .yes ]; then
        output="$output $output_extra"
    fi
    echo $output
fi

