--- MITgcm/tools/genmake2 2005/11/17 20:06:08 1.135 +++ MITgcm/tools/genmake2 2005/12/03 08:30:32 1.137 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.135 2005/11/17 20:06:08 edhill Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.137 2005/12/03 08:30:32 edhill Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -353,10 +353,18 @@ else echo " The possible FORTRAN compilers found in your path are:" echo " "$p_FC - if test "x$FC" = x ; then - FC=`echo $p_FC | $AWK '{print $1}'` - echo " Setting FORTRAN compiler to: "$FC - fi + fi + + # Use the first of the compilers found in the current PATH + # that has a correctly-named optfile + if test "x$OPTFILE" = x -a "x$FC" = x ; then + for i in $p_FC ; do + OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i + if test -r $OPTFILE ; then + echo " Setting OPTFILE to: "$OPTFILE + break + fi + done fi if test "x$OPTFILE" = x ; then @@ -689,6 +697,63 @@ } +check_HAVE_SIGREG() { + get_fortran_c_namemangling + cat < genmake_tc_1.c +$FC_NAMEMANGLE +#include +#include +#include +#include +#include + +int * ip; + +static void killhandler( + unsigned int sn, siginfo_t si, struct ucontext *sc ) +{ + *ip = *ip + 1; + return; +} + +void FC_NAMEMANGLE(sigreg) (int * aip) +{ + ip = aip; + struct sigaction s; + s.sa_flags = SA_SIGINFO; + s.sa_sigaction = (void *)killhandler; + if(sigaction (SIGTERM,&s,(struct sigaction *)NULL)) { + printf("Sigaction returned error = %d\n", errno); + exit(0); + } + return; +} +EOF + make genmake_tc_1.o >> genmake_warnings 2>&1 + RET_C=$? + cat < genmake_tc_2.$FS + program hello + integer anint + common /iv/ anint + external sigreg + call sigreg(anint) + end +EOF + echo >> genmake_warnings + echo "running: check_HAVE_SIGREG()" >> genmake_warnings + cat genmake_tc_2.$FS >> genmake_warnings + COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o" + echo $COMM >> genmake_warnings + $COMM >> genmake_warnings 2>&1 + RETVAL=$? + if test "x$RETVAL" = x0 ; then + HAVE_SIGREG=t + DEFINES="$DEFINES -DHAVE_SIGREG" + fi + rm -f genmake_tc* +} + + check_HAVE_SETRLSTK() { get_fortran_c_namemangling cat < genmake_tc_1.c @@ -1447,6 +1512,15 @@ echo "yes" else echo "no" +fi +rm -f genmake_t* + +printf " Can we register a signal handler using $FC... " +check_HAVE_SIGREG +if test "x$HAVE_SIGREG" != x ; then + echo "yes" +else + echo "no" fi rm -f genmake_t*