#! /bin/bash

# These variables need to exist
prefix=/usr
exec_prefix=/usr

if [[ $# -eq 0 || -n $( echo $* | egrep -- "--help|-h" ) ]]; then
    echo
    echo "qcdloop-config: configuration tool for qcdloop"
    echo
    echo "Usage: qcdloop-config [[--help|-h] | [--prefix] | [--ldflags]]"
    echo "Options:"
    echo "  --help | -h    : show this help message"
    echo "  --prefix       : show the installation prefix (cf. autoconf)"
    echo "  --incdir       : show the path to the qcdloop header directory (for C++ interface)"
    echo "  --libdir       : show the path to the qcdloop library directory"
    echo "  --cppflags     : get compiler flags for use with the C preprocessor stage of C++ compilation"
    echo "  --ldflags      : get compiler flags for use with the linker stage of any compilation"
    echo "  --version      : returns qcdloop release version number"
fi

OUT=""

tmp=$( echo "$*" | egrep -- '--\<prefix\>')
test -n "$tmp" && OUT="$OUT /usr"

tmp=$( echo "$*" | egrep -- '--\<incdir\>')
test -n "$tmp" && OUT="$OUT /usr/include"

tmp=$( echo "$*" | egrep -- '--\<cppflags\>')
test -n "$tmp" && OUT="$OUT -I/usr/include -std=c++11"

tmp=$( echo "$*" | egrep -- '--\<libdir\>')
test -n "$tmp" && OUT="$OUT /usr/lib64"

tmp=$( echo "$*" | egrep -- '--\<ldflags\>')
test -n "$tmp" && OUT="$OUT -L/usr/lib64 -lqcdloop -lquadmath"

## Version
tmp=$( echo "$*" | egrep -- '--\<version\>')
test -n "$tmp" && OUT="$OUT "2.0.9""

echo $OUT
