#!/bin/sh
prefix="/opt/local"
exec_prefix="${prefix}"
libdir="${exec_prefix}/lib"
includedir="${prefix}/include"
echo_cflags=no
echo_libs=no
echo_help=no
echo_tabs=no
echo_source=no
echo_lalibs=no

libs=" -L/opt/local/libexec/boost/1.87/lib -lboost_system-mt -lboost_regex-mt -lboost_thread-mt -L/opt/local/lib -lyazpp -L/opt/local/lib -lyaz -L/opt/local/lib -lxslt -lxml2 -L/opt/local/lib -liconv -lpthread -lm -ldl  -lpthread"
lalibs="-L/opt/local/lib -lyazpp -L/opt/local/lib -lyaz -L/opt/local/lib -lxslt -lxml2 -L/opt/local/lib -liconv -lpthread -lm -ldl  -lpthread"
VERSION=1.22.3

usage()
{
	cat <<EOF
Usage: metaproxy-config [OPTIONS] [LIBRARIES]
Options:
	[--prefix[=DIR]]
	[--version]
	[--libs]
	[--lalibs]
	[--cflags]
EOF
	exit $1
}

if test $# -eq 0; then
	echo_help=yes
fi

while test $# -gt 0; do
  case "$1" in
  -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  *) optarg= ;;
  esac

  case $1 in
    --prefix=*)
      prefix=$optarg
      ;;
    --prefix)
      echo $prefix
      exit 0
      ;;
    --version)
      echo $VERSION
      exit 0
      ;;
    --cflags)
      echo_cflags=yes
      ;;
    --libs)
      echo_libs=yes
      ;;
    --tabs)
      echo_tabs=yes
      ;;
    --lalibs)
      echo_lalibs=yes
      ;;
    -*)
      echo_help=yes
      ;;
  esac
  shift
done

INC="-I/opt/local/include -DYAZ_POSIX_THREADS=1 -DYAZ_HAVE_XML2=1 -DYAZ_HAVE_XSLT=1 -I/opt/local/include/libxml2 -I/opt/local/include -I/opt/local/include -I/opt/local/libexec/boost/1.87/include"

if test "$echo_source" = "yes"; then
    
    
    LIB="-L${build_root}/src/.libs -lmetaproxy $libs"
    LALIB="${build_root}/src/libmetaproxy.la $lalibs"
    INC="-I${src_root}/include $INC"
else
    LIB="-lmetaproxy $libs"
    if test "$prefix" != "/usr"; then
	LIB="-L${libdir} $LIB"
    fi
    LALIB="$LIB"
    if test "$prefix" != "/usr"; then
	INC="-I${includedir} $INC"
    fi
fi

if test "$echo_help" = "yes"; then
	usage 1 1>&2
fi
if test "$echo_cflags" = "yes"; then
    echo $INC
fi
if test "$echo_libs" = "yes"; then
    echo $LIB
fi
if test "$echo_lalibs" = "yes"; then
    echo $LALIB
fi
