#!/bin/sh
#
# xmm-config
#
# LinuX MultiMedia Project config tool 
# used for compiling software related to this project ( e.g. Plugins )
#
# last modified 22.10.2001, by Arthur Kleer
#

prefix=/usr
version=0.6.0

usage()
{
  cat <<EOF
Usage: xmm-config [OPTION]...

General options:
    --help			Print this message
    --version			Print the version of XMMP

Building options:
    --cflags			Print the compiler flags that are necessary
				to compile XMMP related software
    --libs			Print the linker flags that are necessary
				to link XMMP related software
    --mplayer-cflags		Print the compiler flags that are necessary
				to compile software using libmplayer
    --mplayer-libs		Print the compiler flags that are necessary
				to link software using libmplayer
    --prefix=PREFIX		Use PREFIX instead of the installation prefix


Installation directory options:
    --prefix --bindir --libdir --plugindir --datadir --themedir
EOF
}

if test $# -eq 0; then
    usage
    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
    --help)
      usage 0
      ;;
    --version)
      echo $version
      exit 0
      ;;
    --prefix=*)
      prefix=$optarg
      ;;
    --prefix)
      echo $prefix
      ;;
    --bindir)
      echo $prefix/bin
      ;;
    --libdir)
      echo $prefix/lib/xmmp
      ;;
    --plugindir)
      echo $prefix/lib/xmmp/Plugins
      ;;
    --themedir)
      echo $prefix/lib/xmmp/Themes
      ;;
    --datadir)
      echo $prefix/lib/xmmp/Data
      ;;
    --cflags)
      if test ${prefix}/include != /usr/include ; then
        incdir=-I${prefix}/include
      fi
      echo $incdir -I${prefix}/include
      ;;
    --libs)
      if test ${prefix}/lib != /usr/lib ; then
        libdir=-L${prefix}/lib
      fi
      echo $libdir -Wl,-rpath,${prefix}/lib -lxmm -ldl -lpthread
      ;;
    --mplayer-cflags)
      if test ${prefix}/include != /usr/include ; then
        mplayer_incdir=-I${prefix}/include
      fi
      echo $mplayer_incdir -I${prefix}/include/libxmm -I${prefix}/include/libmplayer `gtk-config --cflags`
      ;;
    --mplayer-libs)
      if test ${prefix}/lib != /usr/lib ; then
        mplayer_libdir=-L${prefix}/lib
      fi
      echo $mplayer_libdir -Wl,-rpath,${prefix}/lib -lxmm -ldl -lpthread -lmplayer `gtk-config --libs`
      ;;
    *)
      echo "${usage}" 1>&2
      exit 1
      ;;
  esac
  shift
done
