#!/bin/sh

PCFILE=libmariadb

command -v pkg-config > /dev/null 2>&1
ret="$?"
if [ "$ret" -ne 0 ]; then
        echo pkg-config not found >&2
        exit 1
fi

pkg-config $PCFILE > /dev/null 2>&1
ret="$?"
if [ "$ret" -ne 0 ]; then
        echo $PCFILE pkg-config file missing >&2
        exit 1
fi

cflags=$(pkg-config $PCFILE --cflags)
include=$(pkg-config $PCFILE --cflags)
libs=$(pkg-config $PCFILE --libs)
plugindir=PLUGIN_DIR
socket=SOCKET
port=PORT
version=VERSION

usage () {
        cat <<EOF
Usage: $0 [OPTIONS]
Options:
        --cflags         [$cflags]
        --include        [$include]
        --libs           [$libs]
        --libs_r         [$libs]
        --plugindir      [$plugindir]
        --socket         [$socket]
        --port           [$port]
        --version        [$version]
EOF
  exit "$1"
}

if test $# -le 0; then usage 0 ; fi

while test $# -gt 0; do
        case $1 in
        --cflags)  echo "$cflags" ;;
        --include) echo "$include" ;;
        --libs)    echo "$libs" ;;
        --libs_r)  echo "$libs" ;;
        --plugindir) echo "$plugindir" ;;
        --socket)  echo "$socket" ;;
        --port)    echo "$port" ;;
        --version) echo "$version" ;;
        *) usage 1 >&2 ;;
        esac

        shift
done

exit 0
