#! /bin/sh

prefix=@prefix@
exec_prefix=@exec_prefix@
includedir=@includedir@

usage()
{
    cat <<EOF
Usage: libglade-config [OPTION] [LIBRARIES]

Known values for OPTION are:

  --prefix=DIR		change libglade prefix [default $prefix]
  --libs		print library linking information
  --cflags		print pre-processor and compiler flags
  --check		just check for library.
  --help		display this help and exit
  --version		output version information

Possible widget libraries:
  gtk (included by default)
  gnome
  bonobo
  gnomedb
EOF

    exit $1
}

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

cflags=false
libs=false

lib_gtk=yes
lib_gnome=no
lib_bonobo=no
lib_gnomedb=no

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
	;;

    --version)
	echo @PACKAGE@ @VERSION@
	exit 0
	;;

    --help)
	usage 0
	;;

    --cflags)
	echo_cflags=yes
       	;;

    --libs)
	echo_libs=yes
       	;;

    --check)
	;;

    gtk)
	lib_gtk=yes
	;;
    gnome)
	lib_gnome=yes
	;;
    bonobo)
	lib_gnome=yes   # bonobo implies gnome
	lib_bonobo=yes
	;;
    gnomedb)            # gnomedb implies gnome
        lib_gnome=yes
        lib_gnomedb=yes
        ;;

    *)
	usage 1 1>&2
	exit 1
	;;
    esac
    shift
done

# This is uncommented when we have no GNOME support ...
@GNOME_SUPPORT_FALSE@if test "$lib_gnome" = "yes"; then
@GNOME_SUPPORT_FALSE@  echo "*** GNOME support was not compiled into libglade" 1>&2
@GNOME_SUPPORT_FALSE@  exit 1
@GNOME_SUPPORT_FALSE@fi

# This is uncommented when we have no BONOBO support ...
@BONOBO_SUPPORT_FALSE@if test "$lib_bonobo" = "yes"; then
@BONOBO_SUPPORT_FALSE@  echo "*** Bonobo support was not compiled into libglade" 1>&2
@BONOBO_SUPPORT_FALSE@  exit 1
@BONOBO_SUPPORT_FALSE@fi

# This is uncommented when we have no GNOME-DB support ...
@GNOMEDB_SUPPORT_FALSE@if test "$lib_gnomedb" = "yes"; then
@GNOMEDB_SUPPORT_FALSE@  echo "*** GNOME-DB support was not compiled into libglade" 1>&2
@GNOMEDB_SUPPORT_FALSE@  exit 1
@GNOMEDB_SUPPORT_FALSE@fi

if test "$echo_cflags" = "yes"; then
    cflags="@XML_CFLAGS@ -I@includedir@/libglade-1.0"
    if test "$lib_bonobo" = "yes"; then
	cflags="$cflags @BONOBO_CFLAGS@"
    elif test "$lib_gnomedb" = "yes"; then
        cflags="$cflags @GNOMEDB_CFLAGS@"
    elif test "$lib_gnome" = "yes"; then
	cflags="$cflags @GNOME_INCLUDEDIR@"
    else
	cflags="$cflags @GTK_CFLAGS@"
    fi
    echo $cflags
fi

if test "$echo_libs" = "yes"; then
    libs=""
    libsa=""
    if test "$lib_gtk" = "yes"; then
	libs="-lglade"
	libsa="@GTK_LIBS@"
    fi
    if test "$lib_gnome" = "yes"; then
	libs="-lglade-gnome $libs"
	libsa="@GNOME_LIBDIR@ @GNOMEUI_LIBS@"
    fi
    if test "$lib_bonobo" = "yes"; then
	libs="-lglade-bonobo $libs"
	libsa="@GNOME_LIBDIR@ @BONOBO_LIBS@"
    fi
    if test "$lib_gnomedb" = "yes"; then
	libs="-lglade-gnomedb $libs"
	libsa="@GNOME_LIBDIR@ @GNOMEDB_LIBS@"
    fi
    echo -L@libdir@ $libs @XML_LIBS@ $libsa
fi

exit 0
