#!/bin/sh
#=begin
#== NAME
#((* spmconfig *)) -- output environment variables 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
#:--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"
exec_prefix=/usr
libdir=/lib
includedir=/usr/include/spml2

fc="/usr/bin/mpif90"
fcflags="-I/usr/include/spml2 -I/usr/include/gtool5/openmpi -I/usr/include -I/usr/include -g -O2 -fstack-protector-strong -fstack-clash-protection -fcf-protection -fopenmp -fno-inline-functions-called-once -std=f2003 -I/usr/include -I/usr/include -g -O2  -fstack-protector-strong -fstack-clash-protection -fcf-protection"
ldflags="-Wl,-z,relro -Wl,-z,now -L/usr/lib/x86_64-linux-gnu -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu"
ldlibs="-lspml2-lapack-lapack -lgtool_mpi -L/usr/lib/x86_64-linux-gnu -lnetcdff -Wl,-z,relro -Wl,-z,now -lnetcdf -lnetcdf -lm  -lispack3 -llapack"
version="spml 2.0.0-rc1"

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
  --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 "  --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            ;;
    --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
