#!/bin/sh
# -*- sh-indentation: 3 -*-
#
# genie-config a la ROOT's root-config
#

### Source GENIE config options::
source $GENIE/src/make/Make.config

### GENIE libraries path:
libdir=$GENIE/lib

### GENIE src top level directory:
srcdir=$GENIE/src

### GENIE Libraries;
libs="-L$libdir -lGAlgorithm -lGBaryonResonance -lGBase -lGBodekYang -lGCharm \
 -lGCrossSections -lGDecay -lGElas -lGHEP -lGEVGCore -lGEVGModules -lGEVGDrivers \
 -lGHadronTransp -lGFragmentation -lGInteraction -lGLlewellynSmith -lGMEC \
 -lGMessenger -lGNuGamma -lGNuE -lGNtuple -lGNuclear -lGNumerical -lGPartonModel -lGPDG -lGPDF\
 -lGRegistry -lGReinSeghal -lGReWeight -lGUtils"

if test "$GOPT_ENABLE_GEOM_DRIVERS" = "YES"; then
  libs="$libs -lGGeo"
fi
if test "$GOPT_ENABLE_FLUX_DRIVERS" = "YES"; then
  libs="$libs -lGFluxDrivers"
fi
if test "$GOPT_ENABLE_VIEWER" = "YES"; then
  libs="$libs -lGViewer"
fi
if test "$GOPT_ENABLE_MUELOSS" = "YES"; then
  libs="$libs -lGMuELoss"
fi

### GENIE validation tools;
vldlibs=""
if test "$GOPT_ENABLE_VALIDATION_TOOLS" = "YES"; then
vldlibs="$vldlibs -L$libdir -lGNuVld"
fi

### dependencies for depreciated version of nuvalidator package
nvldlibs="-L$libdir -lGNuVldXML -lGNuVldDBU -lGNuVldGUI -lGNuVldNeugen"

### Usage
usage="\
Usage: genie-config [--libs] [-vldlibs] [--libdir] [--topsrcdir]" 

if test $# -eq 0; then
   echo "${usage}" 1>&2
   exit 1
fi

out=""

while test $# -gt 0; do
  case "$1" in
  -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  *)    optarg= ;;
  esac

  case $1 in
    --libs)
      ### GENIE libraries
      out="$out $libs"
      ;;
    --vldlibs)
      ### GENIE validation tool libraries
      out="$out $vldlibs"
      ;;
    --nuvldlibs)
      ### GENIE nuvalidator libraries (depreciated version)
      out="$out $nuvldlibs"
      ;;
    --libdir)
      ### Output GENIE libdir
      out="$out $libdir"
      ;;
    --topsrcdir)
      ### Output GENIE top level src directory
      out="$out $srcdir"
      ;;
  esac
  shift
done

echo $out
