--- MITgcm/tools/genmake2 2004/07/27 20:59:19 1.90 +++ MITgcm/tools/genmake2 2004/07/30 14:31:40 1.91 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.90 2004/07/27 20:59:19 edhill Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.91 2004/07/30 14:31:40 edhill Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -269,7 +269,47 @@ look_for_makedepend - # look for possible fortran compilers + #================================================================ + # look for possible C compilers + tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc" + p_CC= + for c in $tmp ; do + rm -f ./genmake_hello.c ./genmake_hello + cat >> genmake_hello.c << EOF +#include +int main(int argc, char **argv) { + printf("Hello!\n"); + return 0; +} +EOF + $c -o genmake_hello genmake_hello.c > /dev/null 2>&1 + RETVAL=$? + if test "x${RETVAL}" = x0 ; then + p_CC="$p_CC $c" + fi + done + rm -f ./genmake_hello.c ./genmake_hello + if test "x${p_CC}" = x ; then + cat 1>&2 </dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3` RETVAL=$? if test "x$RETVAL" != x0 ; then FC_NAMEMANGLE=$default_nm @@ -554,7 +599,7 @@ EOF return 1 fi - f_tcall=`nm genmake_tcomp.o | grep 'T ' | grep tcall | cut -d ' ' -f 3` + f_tcall=`nm genmake_tcomp.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3` RETVAL=$? if test "x$RETVAL" != x0 ; then FC_NAMEMANGLE=$default_nm @@ -631,6 +676,7 @@ check_netcdf_libs() { + echo "" > genmake_tnc.log cat < genmake_tnc.for program fgennc #include "netcdf.inc" @@ -644,7 +690,7 @@ end EOF #echo "$CPP $DEFINES $INCLUDES" - $CPP $DEFINES $INCLUDES genmake_tnc.for > genmake_tnc.f \ + $CPP $DEFINES $INCLUDES genmake_tnc.for > genmake_tnc.f 2>/dev/null \ && $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1 RET_COMPILE=$? test -x ./genmake_tnc && ./genmake_tnc >> genmake_tnc.log 2>&1 @@ -653,7 +699,7 @@ HAVE_NETCDF=t else # try again with "-lnetcdf" added to the libs - $CPP $DEFINES $INCLUDES genmake_tnc.for > genmake_tnc.f \ + $CPP $DEFINES $INCLUDES genmake_tnc.for > genmake_tnc.f 2>/dev/null \ && $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \ $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1 RET_COMPILE=$? @@ -683,6 +729,7 @@ S64= KPP= FC= +CC= CPP= LINK= DEFINES= @@ -913,7 +960,12 @@ # ac_prev=cpp ;; # -cpp=* | --cpp=*) # CPP=$ac_optarg ;; - + + -cc | --cc) + ac_prev=CC ;; + -cc=* | --cc=*) + CC=$ac_optarg ;; + -fortran | --fortran | -fc | --fc) ac_prev=FC ;; -fc=* | --fc=*) @@ -1069,7 +1121,7 @@ fi fi -# Check that FC, LINK, CPP, S64, LN, and MAKE are defined. If not, +# Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined. If not, # either set defaults or complain and abort! if test ! "x$BASH" = x ; then # add a trailing space so that it works within the Makefile syntax (see below) @@ -1084,6 +1136,16 @@ 3) the "./genmake_local" file EOF exit 1 +fi +if test "x$CC" = x ; then + cat <&2 + +Error: no C compiler: please specify using one of the following: + 1) within the options file ("CC=...") as specified by "-of=OPTFILE" + 2) the "-cc=XXX" command-line option + 3) the "./genmake_local" file +EOF + exit 1 fi if test "x$LINK" = x ; then LINK=$FC