#! /usr/bin/env bash
## bin/yoda-config.  Generated from yoda-config.in by configure.

tmp=$(echo $* | grep -E -- '--\<help\>|-\<h\>')
if test $# -eq 0 || test -n "$tmp"; then
    echo "yoda-config: configuration tool for the YODA data analysis library"
    echo
    echo "Usage: $( basename $0 ) [--help|-h] | "
    echo "           [--{prefix,datadir,libdir,includedir}] | "
    echo "           [--{cxxflags,ldflags,libs}] | "
    echo "           [--version]"
    echo "Options:"
    echo "  --help | -h   : show this help message"
    echo
    echo "  --prefix      : show the installation prefix (cf. autoconf)"
    echo "  --includedir  : show the path to the directory containing the YODA headers"
    echo "  --libdir      : show the path to the directory containing the YODA libraries"
    echo "  --pythonpath  : show the path(s) to the directory containing YODA's Python package"
    echo
    echo "  --guess-prefix: try to use the runtime prefix, rather than that set at install-time"
    echo
    echo "  --cflags|--cppflags : returns a '-I' string for insertion into CPPFLAGS or CXXFLAGS"
    echo "  --ldflags|--libs    : returns a '-L/-l' string for insertion into LIBS or LIBADD"
    echo
    echo "  --version     : returns the YODA release version number"
    if [[ $# -eq 0 ]]; then exit 1; else exit 0; fi
fi


## These variables need to exist
## Note no use of $DESTDIR... we ignore it so that destdir can be used
## for temp installs later copied to /
tmp=$( echo "$*" | grep -E -- '--\<guess-prefix\>')
if [[ -n "$tmp" ]]; then
    bindir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
    prefix=$(dirname $bindir)
    exec_prefix=$prefix
else
    prefix=/Users/chrisg/software/yoda/local
    exec_prefix=${prefix}
fi
datarootdir=${prefix}/share


OUT=""

## "Atomic" build info
tmp=$( echo "$*" | grep -E -- '--\<prefix\>')
test -n "$tmp" && OUT="$OUT /Users/chrisg/software/yoda/local"

tmp=$( echo "$*" | grep -E -- '--\<includedir\>')
test -n "$tmp" && OUT="$OUT ${prefix}/include"

tmp=$( echo "$*" | grep -E -- '--\<libdir\>')
test -n "$tmp" && OUT="$OUT ${exec_prefix}/lib"

tmp=$( echo "$*" | grep -E -- '--\<pythonpath|pydir\>')
test -n "$tmp" && OUT="$OUT /Users/chrisg/software/yoda/local/lib/python3.12/site-packages"


## "Pre-rolled" build info
tmp=$( echo "$*" | grep -E -- '--\<cflags\>|--\<cppflags\>|--\<cxxflags\>')
test -n "$tmp" && OUT="$OUT -I${prefix}/include"

tmp=$( echo "$*" | grep -E -- '--\<ldflags\>|--\<libs\>|--\<ldadd\>')
test -n "$tmp" && OUT="$OUT -L${exec_prefix}/lib -lYODA"


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

echo $OUT
