#!/bin/sh

usage()
{
	cat <<EOF
Usage: mariadb-config [OPTIONS]
Options
	[--cflags]
	[--libs]
EOF
	exit $1
}

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

true_val=1
false_val=0

prefix=""
postfix=""
result=""

pkg_config="mariadb_config"
pkg_config_options=""

needs_cflags=$false_val
needs_libs=$false_val

#Check if ISE_LIBRARY is defined, if not we use ISE_EIFFEL.
if [ -z "$ISE_LIBRARY" ]; then
	ISE_LIBRARY=$ISE_EIFFEL
fi

while test $# -gt 0; do
	case $1 in
		--libs)
		if [ $needs_libs = $false_val ]; then
			needs_libs=$true_val
			postfix=" $postfix_path $ISE_LIBRARY/library/store/spec/$ISE_PLATFORM/lib/mariadb_store.lib"
			result=" $result "`$pkg_config --libs`"
		fi
		;;
		--cflags)
		if [ $needs_cflags = $false_val ]; then
			needs_cflags=$true_val
			result=" $result "`$pkg_config --cflags`"
		fi
		;;
		*)
		usage 1 1>&2
		;;
 	esac
	shift
done

echo $prefix $result $postfix

