--- MITgcm/tools/genmake2 2004/01/15 19:19:59 1.62 +++ MITgcm/tools/genmake2 2004/02/23 21:51:32 1.66 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.62 2004/01/15 19:19:59 edhill Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.66 2004/02/23 21:51:32 edhill Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -458,7 +458,19 @@ if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then HAVE_NETCDF=t else - cat genmake_tnc.log >> genmake_warnings + # try again with "-lnetcdf" added to the libs + $CPP genmake_tnc.F > genmake_tnc.f \ + && $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \ + $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1 + RET_COMPILE=$? + test -x ./genmake_tnc && ./genmake_tnc >> genmake_tnc.log 2>&1 + RETVAL=$? + if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then + LIBS="$LIBS -lnetcdf" + HAVE_NETCDF=t + else + cat genmake_tnc.log >> genmake_warnings + fi fi rm -f genmake_tnc* } @@ -834,12 +846,21 @@ if test "x$LINK" = x ; then LINK=$FC fi -if test "x$CPP" = x ; then - CPP="cpp" -fi if test "x$MAKE" = x ; then MAKE="make" fi +if test "x$CPP" = x ; then + CPP=cpp +fi +#EH3 === UGLY === +# The following an ugly little hack to check for $CPP in /lib/ and it +# should eventually be replaced with a more general function that +# searches a combo of the user's path and a list of "usual suspects" +# to find the correct location for binaries such as $CPP. +for i in " " "/lib/" ; do + echo "#define A a" | $i$CPP > test_cpp 2>&1 && CPP=$i$CPP +done +#EH3 === UGLY === echo "#define A a" | $CPP > test_cpp 2>&1 RETVAL=$? if test "x$RETVAL" != x0 ; then @@ -973,7 +994,7 @@ TOOLSDIR="$ROOTDIR/tools" fi if test ! -d ${TOOLSDIR} ; then - echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!" + echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!" exit 1 fi if test "x$S64" = x ; then @@ -1209,7 +1230,7 @@ cat make_mnc.errors 1>&2 exit 1 fi - if test -a "x$HAVE_NETCDF" != xt ; then + if test "x$HAVE_NETCDF" != xt ; then cat <