#!/bin/bash
# copied in part from fastjet-config
# Licensed under the GPL v2.

installationdir=/tmp/tmp0458_550/wheel/platlib
installationlibdir=lib64
moddir=/tmp/tmp0458_550/wheel/platlib/include/hoppet
version=2.1.1
pythonpath=lib/python3.14/site-packages

# print a usage message and exit
# exit code passed as argument:
#   0 if it is a normal call
#   1 if it is due to a misusage.
usage()
{
  cat 1>&2 <<EOF
This is the tool for determining compiler flags for use with hoppet 2.1.1.
Usage:
  --prefix     returns the prefix indicating where the code is installed
  --cxxflags   returns the compilation flags to be used with C++ programs
  --fflags     returns the compilation flags to be used with a fortran(90) compiler
  --libs       returns the flags to pass to the linker
  --version    returns the version number
  --pythonpath returns path for hoppet Python module (add to PYTHONPATH)

NOTE: --libs does not currently provide access to the system f90 libraries, 
      which may be needed if you link a program with a c++ compiler
EOF
exit $1
}

# wite error messages and exit
write_error()
{
    echo "Error: $1"
    echo "Use $0 --help for more information"
    exit 1
}

# first deal with the case where no argument is passed
[ $# -gt 0 ] || usage 1

# browse arguments
for arg do
    case "$arg" in
	--help|-h)
	    usage 0
	    ;;
	--prefix)
	  echo $installationdir
	  ;;
	--cxxflags)
	  echo -I$installationdir/include
	  ;;
	--fflags)
	  echo -I$moddir
	  ;;
	--libs|--ldflags)
	  echo -Wl,-rpath,$installationdir/$installationlibdir -L$installationdir/$installationlibdir -lhoppet
	  ;;
	--pythonpath)
	  echo $installationdir/$pythonpath
	  ;;
	--version)
	  echo $version
	  ;;
	*)
	    write_error "$arg is not a valid argument"
	    ;;
    esac
done
