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

prefix="/usr/lib/x86_64-linux-gnu/spml-mpi"
exec_prefix=/usr/lib/x86_64-linux-gnu/spml-mpi
libdir=/lib
includedir=/usr/lib/x86_64-linux-gnu/spml-mpi/include

fc="mpif90"
mpifc="mpif90"
fcflags="-I/usr/lib/x86_64-linux-gnu/spml-mpi/include -I/usr/lib/x86_64-linux-gnu/gtool5-mpi/include -g -O2 -ffile-prefix-map=/build/spml-0.8.0=. -fstack-protector-strong -fstack-clash-protection -fcf-protection -fPIC -fopenmp"
ldflags="-L/usr/lib/x86_64-linux-gnu/gtool5-mpi/lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -lgtool5 -lnetcdf -lnetcdff -lispack-mpi  -llapack"
ldlibs="-L/usr/lib/x86_64-linux-gnu/spml-mpi/lib -lspml-lapack-lapack"
version="spml 0.8.0"

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

Available values for OPTION include:

  --help        display this help message and exit
  --all         display all options
  --fc          output fortran compiler name using spml libarary
  --mpifc       output MPI fortran compiler name using spml libarary
  --fcflags     output fortran FCFLAGS using spml libarary
  --ldflags     output fortran LDFLAGS using spml library
  --ldlibs      output fortran LDLIBS using spml library
  --prefix      output install prefix of spml
  --includedir  output include(module file) directory of spml 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/spmconfig ;;
        *) 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
