#!/bin/sh
#=begin
#== NAME
#((* gt5config *)) -- output environment variables for using gtool5 library.
#
#get environment variables using gtool5
#
#== SYNTAX
#
# % gt5config  [OPTIONS]
#
#== DESCRIPTION
#
#((* gt5config *)) is simple shell script.
#This script output environment variables for using gtool5 library.
#
#== OPTION
#
#:--help
#  display this help message and exit
#:--all
#  display all options
#:--fc
#  output fortran compiler name using gtool5 libarary
#:--mpifc
#  output MPI fortran compiler name using gtool5 libarary
#:--fcflags
#  output fortran FCFLAGS using gtool5 libarary
#:--ldflags
#  output fortran LDFLAGS using gtool5 libarary
#:--ldlibs
#  output fortran LDLIBS using gtool5 libarary
#:--prefix
#  output install prefix of gtool5
#:--includedir
#  output include (module file) directory of gtool5 library
#== BUGS
#
#If you find a bug, please report it at SPMODEL Development Group
#<dcstaff_(at)_gfd-dennou.org>
#
#=end

prefix="/usr/local/gtool"
exec_prefix=/usr/local/gtool
libdir=/lib
includedir=/usr/local/gtool/include

fc="gfortran"
mpifc=""
fcflags="-I/usr/local/gtool/include -I/usr/include -g -O2"
ldflags=" -L/usr/local/gtool/lib"
ldlibs="-lgtool -L/usr/lib -lnetcdff -Wl,-z,relro -Wl,-z,now -lnetcdf -lnetcdf "
version="gtool5 1.0.0"

usage() {
	cat <<EOF
Usage: gt5config [OPTION]

Available values for OPTION include:

  --help        display this help message and exit
  --all         display all options
  --fc          output fortran compiler name using gtool5 libarary
  --mpifc       output MPI fortran compiler name using gtool5 libarary
  --fcflags     output fortran FCFLAGS using gtool5 libarary
  --ldflags     output fortran LDFLAGS using gtool5 library
  --ldlibs      output fortran LDLIBS using gtool5 library
  --prefix      output install prefix of gtool5
  --includedir  output include(module file) directory of gtool5 library
  --version     output version

EOF

	exit $1

}

all()
{
        echo
        echo "This $version has been built with the following features: "
        echo
        echo "  --fc         -> $fc"
        echo "  --mpifc      -> $mpifc"
        echo "  --fcflags    -> $fcflags"
        echo "  --ldflags    -> $ldflags"
        echo "  --ldlibs     -> $ldlibs"
        echo
        echo "  --prefix     -> $prefix"
        echo "  --includedir -> $includedir"
        echo "  --version    -> $version"
        echo
}

if test $# -eq 0; then
	usage
fi

while test $# -gt 0; do
    case "$1" in
        -*=*) value=./../bin/gt5config ;;
        *) value= ;;
    esac

    case "$1" in
    --help)       usage 0              ;;
    --all)        all                  ;;
	--fc)		  echo $fc            ;;
	--mpifc)	  echo $mpifc         ;;
	--fcflags)	  echo $fcflags       ;;
	--ldflags)	  echo $ldflags       ;;
	--ldlibs)	  echo $ldlibs        ;;
    --prefix)     echo $prefix        ;;
    --includedir) echo $includedir    ;;
    --version)    echo $version       ;;
	*)
    echo "unknown option: $1" usage 1 ;;
    esac
    shift
done
exit 0
