#! /bin/bash

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

if [[ $# -eq 0 || -n $( echo $* | grep -E -- "--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 "$*" | grep -E -- '--\<prefix\>')
test -n "$tmp" && OUT="$OUT /usr"

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

tmp=$( echo "$*" | grep -E -- '--\<cppflags\>')
test -n "$tmp" && OUT="$OUT -Iinclude -std=c++11"

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

tmp=$( echo "$*" | grep -E -- '--\<ldflags\>')
test -n "$tmp" && OUT="$OUT -Llib64 -lqcdloop -lquadmath"

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

echo $OUT
