#!/bin/sh

version=1.3.3
prefix=/usr
tremor=
curl=
pthread=1

usage()
{
  cat << "  EOF"
  alogg-config [--options]
    --help                 Prints this help
    --version              Prints installed alogg version
    --cflags               Prints compiler flags to compile with alogg
    --libs                 Prints linker options to link with alogg
    --libs-alogg-only      Prints linker options to link with alogg,
                            without its dependencies (Allegro, Ogg/Vorbis...)
  EOF
}

if [ $# == 0 ]
then
  usage
  exit 1
fi

while [ $# -gt 0 ]
do
  case $1 in
    --version)
      echo ${version}
    ;;
    --cflags)
      msg="-I${prefix}/include `allegro-config --cflags`"
      if [ ! -z ${tremor} ]; then msg="${msg} -DALOGG_USE_TREMOR"; fi
      if [ ! -z ${curl} ]; then msg="${msg} -DALOGG_USE_CURL"; fi
      if [ ! -z ${pthread} ]; then msg="${msg} -DALOGG_USE_PTHREAD"; fi
      echo ${msg}
    ;;
    --libs)
      msg="-L${prefix}/lib -lalogg `allegro-config --libs`"
      if [ -z ${tremor} ]
      then
        msg="${msg} -lvorbisfile -lvorbisenc -lvorbis -logg -lm"
      else
        msg="${msg} -lvorbisidec"
      fi
      if [ ! -z ${curl} ]; then msg="${msg} `curl-config --libs`"; fi
      if [ ! -z ${curl} ]; then msg="${msg} -lpthread"; fi
      echo ${msg}
    ;;
    --libs-alogg-only)
      echo -L${prefix}/lib -lalogg
    ;;
    --help)
      usage
    ;;
    *)
      usage
      exit 1
    ;;
  esac
  shift
done

exit 0
