#!/bin/sh

## variables

CONFIG_PREFIX="$( cd "$( dirname $( dirname "$0" ))" && pwd )"

CONFIG_MAPNIK_VERSION_STRING='2.2.0'
CONFIG_MAPNIK_VERSION='200200'
CONFIG_GIT_REVISION='923120557365ce217b7e7008b0eaf2adec4b33e3
'
CONFIG_GIT_DESCRIBE='v2.2.0
'
CONFIG_FONTS="/usr/X11R6/lib/X11/fonts/TTF"
CONFIG_INPUT_PLUGINS="/usr/local/lib/mapnik/input"
CONFIG_MAPNIK_DEFINES=' -DHAVE_JPEG -DMAPNIK_USE_PROJ4 -DHAVE_PNG -DHAVE_TIFF -DBIGINT -DOPENBSD -DMAPNIK_THREADSAFE -DNDEBUG -DHAVE_CAIRO -DHAVE_LIBXML2'
CONFIG_MAPNIK_LIBNAME='mapnik'
CONFIG_MAPNIK_LIBPATH="${CONFIG_PREFIX}/lib"
CONFIG_DEP_LIBS='  -lfreetype -lz -licuuc -lboost_filesystem-mt -lboost_system-mt -lboost_regex-mt -lproj -lpng -ljpeg -ltiff -lxml2 -lboost_thread-mt -lcairo -lgobject-2.0 -lglib-2.0 -lintl -lpcre -lpixman-1 -lfontconfig -lxcb-shm -lxcb-render -lXrender -lXext -lX11 -lxcb -lpthread-stubs -lXau -lXdmcp'
CONFIG_MAPNIK_LDFLAGS='-L/usr/local/lib -L/usr/lib -L/usr/X11R6/lib -lstdc++'
CONFIG_MAPNIK_INCLUDE="${CONFIG_PREFIX}/include -I${CONFIG_PREFIX}/include/mapnik/agg"
CONFIG_DEP_INCLUDES=' -I/usr/local/include/postgresql -I/usr/local/include -I/usr/local/include/libxml2 -I/usr/include -I/usr/X11R6/include/freetype2  -I/usr/local/include/cairo -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/X11R6/include/pixman-1 -I/usr/X11R6/include -I/usr/local/include/libpng16'
CONFIG_CXXFLAGS='-pthread -ansi -Wall -pthread -ftemplate-depth-300 -O2 -fno-strict-aliasing -finline-functions -Wno-inline -Wno-parentheses -Wno-char-subscripts'
CONFIG_CXX='c++'


## program below

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

Known values for OPTION are:

  -h --help         display this help and exit
  -v --version      version information (MAPNIK_VERSION_STRING)
  --version-number  version number (MAPNIK_VERSION) (new in 2.2.0)
  --git-revision    git hash from "git rev-list --max-count=1 HEAD"
  --git-describe    git decribe output (new in 2.2.0)
  --fonts           default fonts directory
  --input-plugins   default input plugins directory
  --defines         pre-processor defines for Mapnik build (new in 2.2.0)
  --prefix          Mapnik prefix [default $CONFIG_PREFIX]
  --lib-name        Mapnik library name
  --libs            library linking information
  --dep-libs        library linking information for Mapnik dependencies
  --ldflags         library paths (-L) information
  --includes        include paths (-I) for Mapnik headers (new in 2.2.0)
  --dep-includes    include paths (-I) for Mapnik dependencies (new in 2.2.0)
  --cxxflags        c++ compiler flags and pre-processor defines (new in 2.2.0)
  --cflags          all include paths, compiler flags, and pre-processor defines (for back-compatibility)
  --cxx             c++ compiler used to build mapnik (new in 2.2.0)
  --all-flags       all compile and link flags (new in 2.2.0)
EOF

    exit $1
}

echoerr() { echo "$@" 1>&2; }

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

while test $# -gt 0; do
    case "$1" in
    esac

    case "$1" in

    --help)
      usage 0
      ;;

    -h)
      usage 0
      ;;

    -v)
      echo ${CONFIG_MAPNIK_VERSION_STRING}
      ;;

    --version)
      echo ${CONFIG_MAPNIK_VERSION_STRING}
      ;;

    --version-number)
      echo ${CONFIG_MAPNIK_VERSION}
      ;;

    --git-revision)
      echo ${CONFIG_GIT_REVISION}
      ;;

    --git-describe)
      echo ${CONFIG_GIT_DESCRIBE}
      ;;

    --fonts)
      echo ${CONFIG_FONTS}
      ;;

    --input-plugins)
      echo ${CONFIG_INPUT_PLUGINS}
      ;;

    --defines)
      echo ${CONFIG_MAPNIK_DEFINES}
      ;;

    --prefix)
      echo ${CONFIG_PREFIX}
      ;;

    --lib-name)
      echo ${CONFIG_MAPNIK_LIBNAME}
      ;;

    --libs)
      echo -L${CONFIG_MAPNIK_LIBPATH} -l${CONFIG_MAPNIK_LIBNAME}
      ;;

    --dep-libs)
      echo ${CONFIG_DEP_LIBS}
      ;;

    --ldflags)
      echo ${CONFIG_MAPNIK_LDFLAGS}
      ;;

    --includes)
      echo -I${CONFIG_MAPNIK_INCLUDE}
      ;;

    --dep-includes)
      echo ${CONFIG_DEP_INCLUDES}
      ;;

    --cxxflags)
      echo ${CONFIG_CXXFLAGS}
      ;;

    --cflags)
      echo -I${CONFIG_MAPNIK_INCLUDE} ${CONFIG_DEP_INCLUDES} ${CONFIG_MAPNIK_DEFINES} ${CONFIG_CXXFLAGS}
      ;;

    --cxx)
      echo ${CONFIG_CXX}
      ;;

    --all-flags)
      echo -I${CONFIG_MAPNIK_INCLUDE} ${CONFIG_DEP_INCLUDES} ${CONFIG_MAPNIK_DEFINES} ${CONFIG_CXXFLAGS} -L${CONFIG_MAPNIK_LIBPATH} -l${CONFIG_MAPNIK_LIBNAME} ${CONFIG_MAPNIK_LDFLAGS} ${CONFIG_DEP_LIBS}
      ;;

    *)
  # push to stderr any invalid options
  echo "unknown option $1" 1>&2;
  ;;
    esac
    shift
done

exit 0
