#!/bin/sh
# $Id: yaz++-config.in,v 1.3 2001/03/26 14:43:49 adam Exp $
yazppprefix=/usr/local
yaz_echo_cflags=no
yaz_echo_libs=no
yaz_echo_help=no
yaz_echo_tabs=no
yaz_echo_source=no
yaz_echo_lalibs=no
yazpp_src_root=/usr/ports/net/yaz++/work/yaz++-0.5
yazpp_build_root=/usr/ports/net/yaz++/work/yaz++-0.5

yazlibs="-L/usr/local/lib -lyazthread -lyaz -lpthread "
YAZPPVERSION=0.5

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

#if test $# -eq 0; then
#	yaz_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=*)
      yazppprefix=$optarg
      ;;
    --prefix)
      echo $yazppprefix
      exit 0
      ;;
    --version)
      echo $YAZPPVERSION
      exit 0
      ;;
    --cflags)
      yaz_echo_cflags=yes
      ;;
    --libs)
      yaz_echo_libs=yes
      ;;
    --tabs)
      yaz_echo_tabs=yes
      ;;
    --lalibs)
      yaz_echo_lalibs=yes
      ;;
    -*)
      yaz_echo_help=yes
      ;;
  esac
  shift
done

if test "$yaz_echo_source" = "yes"; then
    YAZPPLIB="-L${yazpp_build_root}/src/.libs -lyaz++ $yazlibs"
    YAZPPLALIB="${yazpp_build_root}/src/libyaz++.la $yazlibs"
    YAZPPINC="-I/usr/local/include -DYAZ_POSIX_THREADS=1 -D_REENTRANT -I${yazpp_src_root}/include"
else

    if test "$yazppprefix" = "/usr"; then
	YAZPPLIB="-lyaz++ $yazlibs"
    else
	YAZPPLIB="-L${yazppprefix}/lib -lyaz++ $yazlibs"
    fi
    YAZPPLALIB=$YAZPPLIB
    if test "$yazppprefix" = "/usr"; then
	YAZPPINC=
    else
	YAZPPINC="-I/usr/local/include -DYAZ_POSIX_THREADS=1 -D_REENTRANT -I${yazppprefix}/include"
    fi
fi

if test "$yaz_echo_help" = "yes"; then
	usage 1 1>&2
fi
if test "$yaz_echo_cflags" = "yes"; then
	echo $YAZPPINC
fi
if test "$yaz_echo_libs" = "yes"; then
	echo $YAZPPLIB
fi
if test "$yaz_echo_lalibs" = "yes"; then
	echo $YAZPPLALIB
fi
