#!/bin/sh -f

if test "$ELMER_LIB" = ""; then
  if  test "$ELMER_HOME" = ""; then
     LIBDIR=/opt/elmerfem-9.0/share/elmersolver/../../lib/elmersolver
     INCLUDE=/opt/elmerfem-9.0/share/elmersolver/include
  else
     LIBDIR=$ELMER_HOME/lib/elmersolver
     INCLUDE=$ELMER_HOME/share/elmersolver/include
  fi
else
  LIBDIR=$ELMER_LIB
  INCLUDE=$ELMER_LIB/../include
fi

if test "$ELMER_Fortran_COMPILER" = ""; then
  FC=/usr/bin/gfortran
else
  FC=$ELMER_Fortran_COMPILER
fi


if test FALSE = "TRUE"; then
    ELMERICE_LIB=$LIBDIR/../../share/elmersolver/lib
    LIBELMERICE="$ELMERICE_LIB/ElmerIceSolvers.so $ELMERICE_LIB/ElmerIceUSF.so"
    printf "with elmerice\n"
else
    LIBELMERICE=""
    printf "no elmerice\n"
fi

cmd="$FC $* -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -DNDEBUG  -DCONTIG= -DHAVE_EXECUTECOMMANDLINE -DUSE_ISO_C_BINDINGS -DUSE_ARPACK -O2 -g -DNDEBUG -fPIC -shared -I$INCLUDE -L$LIBDIR $LIBELMERICE -shared -lelmersolver "
printf "%s " $cmd
printf "\n"
$FC $* -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -DNDEBUG  -DCONTIG= -DHAVE_EXECUTECOMMANDLINE -DUSE_ISO_C_BINDINGS -DUSE_ARPACK -O2 -g -DNDEBUG -fPIC -shared -I$INCLUDE -L$LIBDIR $LIBELMERICE -shared -lelmersolver 
    
# $FC -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -DNDEBUG  $*
#$FC   $INCLUDE    $*
#$FC  $INCLUDE    $* -L$LIBDIR -lelmersolver
