#!/bin/sh
# Copyright (C) 2005  Network Applied Communication Laboratory Co., Ltd.

load_config()
{
  if test "x${prefix}" = "x"; then
    prefix="/usr"
  fi
  exec_prefix="/usr"
  bindir="/usr/bin"
  libdir="/usr/lib64"
  CC="x86_64-momonga-linux-gcc"
  CFLAGS="-pthread -O2 -mtune=generic -fPIC -fstack-protector   -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -I/usr/include/apr-1  -pthread"
  CPPFLAGS="-DLINUX=2 -D_REENTRANT -D_GNU_SOURCE "
  INCLUDES="-I/usr/include -I/usr/include/apr-1  "
  LDFLAGS="-L/usr/lib64 -L../src/.libs"
  LIBS_LD="-lrast -lapr-1  -lpthread -ldl -ldb "
  LIBS_LIBTOOL="/usr/lib64/librast.la -L/usr/lib64 -R/usr/lib64 -lapr-1  -lpthread -ldl -ldb "
  encodingdir="/usr/lib64/rast/encodings"
  version="0.3.1"
}

usage()
{
  echo "usage: $0 [options]"
  echo
  echo "options:"
  echo "  --prefix               print PREFIX to rast install"
  echo "  --prefix=XXX           set prefix to XXX for remainder of command"
  echo "  --exec-prefix          print prefix for executables"
  echo "  --bindir               print binary directory path"
  echo "  --libdir               print library directory path"
  echo "  --cc                   print C compiler used"
  echo "  --cflags               print C compiler flags"
  echo "  --cppflags             print C Preprocessor flags"
  echo "  --includes             print include directives"
  echo "  --ldflags              print linker flags"
  echo "  --libs-ld              print link switches for linking to Rast"
  echo "  --libs-libtool         print libtool inputs for linking to Rast"
  echo "  --version              print Rast version"
}

load_config

if [ $# -eq 0 ]; then
  usage
  exit 1
fi

while [ $# -gt 0 ];
do
  arg="$1"
  var=`echo $arg | sed -e 's/^[^=]*=//'`
  case "$arg" in
    # undocumented.
    --debug)
    set -x
    ;;

    --prefix)
    echo $prefix
    ;;

    --prefix=*)
    prefix=$var
    load_config
    ;;

    --exec-prefix)
    echo $exec_prefix
    ;;

    --bindir)
    echo $bindir
    ;;

    --libdir)
    echo $libdir
    ;;

    --cc)
    echo $CC
    ;;

    --cflags)
    echo $CFLAGS
    ;;

    --cppflags)
    echo $CPPFLAGS | sed -e 's/-I. //'
    ;;

    --includes)
    echo $INCLUDES
    ;;

    --ldflags)
    echo $LDFLAGS
    ;;

    --libs-ld)
    echo $LIBS_LD
    ;;

    --libs-libtool)
    echo $LIBS_LIBTOOL
    ;;

    --encodingdir)
    echo $encodingdir
    ;;

    --version)
    echo $version
    ;;

    --help)
    usage
    exit 0
    ;;

    --usage)
    usage
    exit 0
    ;;

    -?)
    usage
    exit 0
    ;;

    *)
    echo $0: ERROR Unknown Option $arg 1>&2
    exit 1;
    ;;
  esac
  shift
done
