#!/bin/sh

install_prefix=/usr

usage()
{
    cat <<EOF

Usage: roy-config --install-prefix
       roy-config --version
       roy-config [--libs [module names]] [--cflags]

Module Names:
    roynode
    therml
    tom

EOF
}

if test $# -eq 0; then
      echo "${usage}" 1>&2
      exit 1
fi

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

  case $1 in
    --install-prefix)
      echo $install_prefix
      ;;
    --version)
      echo 1.0.2
      ;;
    --cflags)
      echo -I$install_prefix/include
      ;;
    --libs)
      echo_libs=yes
      ;;
    roynode)
      lib_roynode=yes
      ;;
    therml)
      lib_therml=yes
      ;;
    tom)
      lib_tom=yes
      ;;
    *)
      usage 1>&2
      exit 1
      ;;
  esac
  shift
done

if test "$echo_libs" = "yes"; then
  libs="-L$install_prefix/lib "

  if test "$lib_roynode" = "yes"; then
    libs=$libs" -lroynode"
  fi

  if test "$lib_therml" = "yes"; then
    libs=$libs" -ltherml"
  fi
  
  if test "$lib_tom" = "yes"; then
    libs=$libs" -ltom  -lnsl"
  fi

  libs=$libs" -lroy"

  echo $libs
fi


