#! /bin/csh

unset CC
unset FC
unset F77
unset F90
unset CXX
unset CFLAGS
unset CPPFLAGS
unset FFLAGS
unset F90FLAGS
unset CXXFLAGS
unset ARFLAGS
unset NMFLAGS
unset FPP
unset M4FLAGS
unset LIBS
unset FLIBS
unset FLDFLAGS

unsetenv CC
unsetenv FC
unsetenv F77
unsetenv F90
unsetenv CXX
unsetenv CFLAGS
unsetenv CPPFLAGS
unsetenv FFLAGS
unsetenv F90FLAGS
unsetenv CXXFLAGS
unsetenv ARFLAGS
unsetenv NMFLAGS
unsetenv FPP
unsetenv M4FLAGS
unsetenv LIBS
unsetenv FLIBS
unsetenv FLDFLAGS

setenv  CC gcc
setenv F77 gfortran
setenv CXX g++

#setenv CFLAGS -O
#setenv CPPFLAGS '-fPIC -DNDEBUG -DpgiFortran'
#setenv FFLAGS '-O -w'

setenv PREFIX /Users/thoar/GNU

make clean
make distclean

if ( -d ${PREFIX} ) then
   echo "Installing into ${PREFIX}"
else   
   mkdir ${PREFIX}
   echo "Installing into ${PREFIX}"
endif

rm -fv macros.make config.status config.log config.cache

# UDUNITS_PATH

./configure CC=${CC} CXX=${CXX} F77=${F77} \
   NETCDF_INC=/Users/thoar/GNU/include \
   NETCDF_LIB=/Users/thoar/GNU/lib \
   --disable-ncoxx --disable-dependency-tracking \
   --prefix=${PREFIX} || exit 1

make         || exit 2
make check   || exit 3
make test    || exit 3
make install || exit 4
