#! /bin/sh
# 
# flek-config
#
# by James Dean Palmer
#
# "$Id: flek-config.in,v 1.15 2000/09/29 21:49:34 clip Exp $"
#

MAJOR_VERSION=0
MINOR_VERSION=0
PATCH_VERSION=0
VERSION="$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION"

### BEGIN flek-config

# Calculate the prefix from the location of *this* file
prefix=`echo "$0" | sed 's/\/bin\/flek-config//
s/\/flek-config//'`

#prefix=/usr/X11R6
exec_prefix=/usr/X11R6
exec_prefix_set=no
bindir=/usr/X11R6/bin
includedir=/usr/X11R6/include
libdir=/usr/X11R6/lib
srcdir=.
fltk2=no

# compiler names
CXX="g++"
CC="alpha-pld-linux-gcc"

# flags for C++ compiler:
CFLAGS="-O2 -fPIC -fomit-frame-pointer -Wall -O2 -mieee  -I/usr/X11R6/include"
CXXFLAGS="-O2 -fPIC -fno-exceptions -fomit-frame-pointer -Wall -Wno-return-type -O2 -mieee  -I/usr/X11R6/include"

# flags for the linker
LDFLAGS="-s"

# program to make the archive:
# LIBNAME="@LIBNAME@"
LIBCOMMAND="@LIBCOMMAND@"
RANLIB="ranlib"
EXPORTCOMMAND="@EXPORTCOMMAND@"

FLTK_DIR="/usr/X11R6"
FLTK_LIB="-L/usr/X11R6/lib -lfltk"
FLTK_INC="-I/usr/X11R6/include"

usage ()
{
    echo "Usage: flek-config [OPTIONS]
Options:
	[--prefix[=DIR]]  return/set where FLEK is installed
	[--exec-prefix[=DIR]]
	[--version]

options telling what we are doing :
	[--use-core]      use core library (default)  (libflek_core)
	[--use-ui]        use user interface library  (libflek_ui)
	[--use-gl]        use OpenGL library          (libflek_gl)
	[--use-xml]       use Flek's xml wrapper      (libflek_xml)
	[--use-jpeg]      use jpeg routines           (libflek_jpeg)

options telling what information we request
	[--cflags]        return flags to compile C using Flek
	[--cxxflags]      return flags to compile C++ using Flek
	[--ldflags]       return flags to link against Flek
	[--ldstaticflags] return flags to link against static Flek library
                            even if there are DSOs installed
	[--libs]          return Flek libraries full path for dependencies
"
    exit $1
}

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

no_plugins=no

# Parse command line options
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
      if test $exec_prefix_set = no ; then
        exec_prefix=$optarg
      fi
      ;;
    --prefix)
      echo_prefix=yes
      ;;
    --exec-prefix=*)
      exec_prefix=$optarg
      exec_prefix_set=yes
      ;;
    --exec-prefix)
      echo_exec_prefix=yes
      ;;
    --version)
      echo $VERSION
      ;;
    --use-gl)
      use_gl=yes
      use_ui=yes
      ;;
    --use-core)
      use_core=yes
      ;;
    --use-xml)
      use_xml=yes
      ;;
    --use-jpeg)
      use_jpeg=yes
      ;;
    --use-ui)
      use_ui=yes
      ;;
    --cflags)
      echo_cflags=yes
      ;;
    --cxxflags)
      echo_cxxflags=yes
      ;;
    --ldflags)
      echo_ldflags=yes
      ;;
    --ldstaticflags)
      echo_ldstaticflags=yes
      ;;
    --libs)
      echo_libs=yes
      ;;
    *)
      echo_help=yes
      ;;
  esac
  shift
done

# Calculate needed libraries
LDLIBS=""
LDSTATIC=""
LIBS=""
if test "$use_jpeg" = "yes"; then
    LDLIBS="$LDLIBS -lflek_jpeg -ljpeg"
    LDSTATIC="$LDSTATIC $prefix/lib/libflek_jpeg.a -ljpeg"
    LIBS="$LIBS $prefix/lib/libflek_jpeg.a"
fi
if test "$use_xml" = "yes"; then
    LDLIBS="$LDLIBS -lflek_xml  -lz"
    LDSTATIC="$LDSTATIC $prefix/lib/libflek_xml.a "
    LIBS="$LIBS $prefix/lib/libflek_xml.a"
fi
if test "$use_gl" = "yes"; then
    LDLIBS="$LDLIBS -lflek_gl $FLTK_LIB -lGLU -lGL"
    LDSTATIC="$LDSTATIC $prefix/lib/libflek_gl.a $FLTK_LIB -lGLU -lGL"
    LIBS="$LIBS $prefix/lib/libflek_gl.a"
    if test "$fltk2" = "yes"; then
      LDLIBS="$LDLIBS -lfltk_gl"
      LDSTATIC="$LDSTATIC -lfltk_gl"
    fi
fi
if test "$use_ui" = "yes"; then
    LDLIBS="$LDLIBS -s -lflek_ui $FLTK_LIB  -L/usr/X11R6/lib -lX11 -lXext "
    LDSTATIC="$LDSTATIC -s $prefix/lib/libflek_ui.a $FLTK_LIB  -L/usr/X11R6/lib -lX11 -lXext "
    LIBS="$LIBS $prefix/lib/libflek_ui.a"
fi
LDLIBS="$LDLIBS -lflek_core -lm"
LDSTATIC="$LDSTATIC $prefix/lib/libflek_core.a -lm"
LIBS="$LIBS $prefix/lib/libflek_core.a"

# Answer to user requests
if test -n "$echo_help"; then usage 1
fi

if test "$echo_prefix" = "yes"; then
        echo $prefix
fi

if test "$echo_exec_prefix" = "yes"; then
        echo $exec_prefix
fi

if test "$echo_cflags" = "yes"; then
      includes=-I`echo "$0" | sed 's/\/bin\/flek-config/\/include/
s/\/flek-config//'`
      echo $includes $FLTK_INC $CFLAGS
fi

if test "$echo_cxxflags" = "yes"; then
      includes=-I`echo "$0" | sed 's/\/bin\/flek-config/\/include/
s/\/flek-config//'`
      echo $includes $FLTK_INC   $CXXFLAGS
fi

if test "$echo_ldflags" = "yes"; then
      my_libs=
      libdirs=-L${exec_prefix}/lib
      for i in $LDLIBS ; do
        if test $i != -L${exec_prefix}/lib ; then
          if test -z "$my_libs" ; then
            my_libs="$i"
          else
            my_libs="$my_libs $i"
          fi
        fi
      done
      echo $libdirs $my_libs
fi

if test "$echo_ldstaticflags" = "yes"; then
      echo $LDSTATIC
fi

if test "$echo_libs" = "yes"; then
      echo $LIBS
fi

# END of flek-config
