#! /bin/sh

comp=

need_cxx=
need_client=
need_server=
need_abyss=

while test $# -gt 0; do
    case $1 in
      (c++)          		comp="$comp xmlrpc_cpp";;
      (cgi-server)   		comp="$comp xmlrpc_server_cgi";;
      (server-util)  		need_server=1;;
      (c++2)         		need_cxx=1;;
      (abyss-server) 		need_abyss=1;;
      (client|libwww-client)	need_client=1;;
      (--) shift; break;;
      (--*) break;;
      (*)
      echo "Unrecognized token '$1'"
      exit 1
      ;;
    esac
    shift
done

if test -z "$need_cxx"; then
    test -z "$need_client" || comp="$comp xmlrpc_client"
    test -z "$need_abyss"  || comp="$comp xmlrpc_server_abyss"
    test -z "$need_server" || comp="$comp xmlrpc_server"
else
    test -z "$need_client" || comp="$comp xmlrpc_client++"
    test -z "$need_abyss"  || comp="$comp xmlrpc_server_abyss++"
    test -z "$need_server" || comp="$comp xmlrpc_server++"
fi

dummy_comp=xmlrpc_client

case $1 in
  (--features|--modules)
  echo "c++ abyss-server curl-client"
  exit 0
  ;;
  (--version)
  set -- --modversion
  ;;
  (--exec-prefix)
  set -- --variable=prefix
  ;;
  (--*dir|--prefix)
  set -- --variable=${1##--}
  ;;
  (--ldflags)
  set -- --libs-only-L
  ;;
  (--ldadd)
  set -- --libs-only-l
  ;;
  (*)
  dummy_comp=
  ;;
esac

test x"$comp" != x || comp=$dummy_comp

exec pkg-config "$@" $comp
