#!/bin/sh

dblib_libs="`root-config --libs` `gtk-config --libs` -lcurses -lpthread -lreadline -lz -lesd"
dblib_cflags="`root-config --cflags` `gtk-config --cflags` "
version=0.1.0

usage()
{
	cat <<EOF
Usage: db-config [OPTIONS]
Options:
	[--version]
	[--libs]
	[--cflags]
EOF
	exit $1
}

if test $# -eq 0; then
	usage 1 1>&2
fi

lib_db=yes

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

  case $1 in
    --version)
      echo $version
      ;;
    --cflags)
      echo_cflags=yes
      ;;
    --libs)
      echo_libs=yes
      ;;
    *)
      usage 1 1>&2
      ;;
  esac
  shift
done

if test "$echo_cflags" = "yes"; then
      echo -I${DAQBUILDER_ROOT}/Source/ $dblib_cflags  
fi

if test "$echo_libs" = "yes"; then
      my_dblib_libs=
      libdirs=-L/usr/lib
      for i in $dblib_libs ; do
        if test $i != -L/usr/lib ; then
          if test -z "$my_dblib_libs" ; then
            my_dblib_libs="$i"
          else
            my_dblib_libs="$my_dblib_libs $i"
          fi
        fi
      done

      echo -L${DAQBUILDER_ROOT}/Source/lib/ -lDAQBuilder $libdirs   -L/usr/X11R6/lib -lgtk -lgdk $my_dblib_libs  -lXi -lXext -lX11 -lXpm -lXm  -lm
fi      

