/[MITgcm]/MITgcm/tools/genmake2
ViewVC logotype

Diff of /MITgcm/tools/genmake2

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.60 by edhill, Wed Jan 14 03:44:48 2004 UTC revision 1.69 by edhill, Wed Feb 25 19:12:10 2004 UTC
# Line 100  find_possible_configs()  { Line 100  find_possible_configs()  {
100          CPP="cpp -traditional -P"          CPP="cpp -traditional -P"
101      fi      fi
102    
103      # makedepend is not always available      #  The "original" makedepend is part of the Imake system that is
104        #  most often distributed with XFree86 or with an XFree86 source
105        #  package.  As a result, many machines (eg. generic Linux) do not
106        #  have a system-default "makedepend" available.  For those
107        #  systems, we have two fall-back options:
108        #
109        #    1) a makedepend implementation shipped with the cyrus-imapd
110        #       package:  ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
111        #
112        #    2) a known-buggy xmakedpend shell script
113        #
114        #  So the choices are, in order:
115        #
116        #    1) use the user-specified program
117        #    2) use a system-wide default
118        #    3) locally build and use the cyrus implementation
119        #    4) fall back to the buggy local xmakedpend script
120        #
121      if test "x${MAKEDEPEND}" = x ; then      if test "x${MAKEDEPEND}" = x ; then
122        which makedepend >& /dev/null        which makedepend >& /dev/null
123        RETVAL=$?        RETVAL=$?
124        if test "x${RETVAL}" = x1 ; then        if test ! "x${RETVAL}" = x0 ; then
125           echo "    makedepend was not found. Using xmakedpend instead."           echo "    a system-default makedepend was not found."
126           MAKEDEPEND='$(TOOLSDIR)/xmakedepend'  
127             #  Try to build the cyrus impl
128             rm -f ./genmake_cy_md
129             (
130                 cd $ROOTDIR/tools/cyrus-imapd-makedepend  \
131                     &&  ./configure > /dev/null 2>&1  \
132                     &&  make > /dev/null 2>&1  \
133                     &&  ./makedepend ifparser.c > /dev/null 2>&1  \
134                     &&  echo "true"
135             ) > ./genmake_cy_md
136             grep true ./genmake_cy_md > /dev/null 2>&1
137             RETVAL=$?
138             if test "x$RETVAL" = x0 ; then
139                 MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
140             else
141                 MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
142             fi
143             rm -f ./genmake_cy_md
144        fi        fi
145      fi      fi
146    
# Line 145  EOF Line 179  EOF
179          echo "   "$p_FC          echo "   "$p_FC
180          if test "x$FC" = x ; then          if test "x$FC" = x ; then
181              FC=`echo $p_FC | $AWK '{print $1}'`              FC=`echo $p_FC | $AWK '{print $1}'`
182                echo "  Setting FORTRAN compiler to: "$FC
183          fi          fi
184      fi      fi
185    
186      for i in $p_FC ; do      if test "x$OPTFILE" = x ; then
187          p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i          OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
188          if test -r $p_OF ; then          if test ! -r $OPTFILE ; then
189              OPTFILE=$p_OF               echo "  I looked for the file "$OPTFILE" but did not find it"
190              echo "  The options file:  $p_OF"          fi
191              echo "    appears to match so we'll use it."      fi
192              break  #    echo "  The options file:  $p_OF"
193          fi  #    echo "    appears to match so we'll use it."
194      done  #   for i in $p_FC ; do
195    #p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
196    #if test -r $p_OF ; then
197    #    OPTFILE=$p_OF
198    #    echo "  The options file:  $p_OF"
199    #    echo "    appears to match so we'll use it."
200    #    break
201    #fi
202    #   done
203      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
204          cat 1>&2 <<EOF          cat 1>&2 <<EOF
205    
# Line 253  Usage: "$0" [OPTIONS] Line 296  Usage: "$0" [OPTIONS]
296        --makefile=NAME | -mf=NAME        --makefile=NAME | -mf=NAME
297            Call the makefile "NAME".  The default is "Makefile".            Call the makefile "NAME".  The default is "Makefile".
298    
299        -makedepend NAME | -md NAME
300          --makedepend=NAME | -md=NAME
301              Use "NAME" for the MAKEDEPEND program.
302    
303      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
304        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
305            Specify the location of the MITgcm ROOTDIR as "NAME".            Specify the location of the MITgcm ROOTDIR as "NAME".
# Line 294  Usage: "$0" [OPTIONS] Line 341  Usage: "$0" [OPTIONS]
341            *only* works if it is supported by the OPTFILE that            *only* works if it is supported by the OPTFILE that
342            is being used.            is being used.
343    
344        -mpi | --mpi
345              Include MPI header files and link to MPI libraries
346        -mpi=PATH | --mpi=PATH
347              Include MPI header files and link to MPI libraries using MPI_ROOT
348              set to PATH. i.e. Include files from $PATH/include, link to libraries
349              from $PATH/lib and use binaries from $PATH/bin.
350    
351    While it is most often a single word, the "NAME" variables specified    While it is most often a single word, the "NAME" variables specified
352    above can in many cases be a space-delimited string such as:    above can in many cases be a space-delimited string such as:
353    
# Line 458  EOF Line 512  EOF
512      if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then      if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
513          HAVE_NETCDF=t          HAVE_NETCDF=t
514      else      else
515          cat genmake_tnc.log >> genmake_warnings          # try again with "-lnetcdf" added to the libs
516            $CPP genmake_tnc.F > genmake_tnc.f  \
517                &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \
518                $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1
519            RET_COMPILE=$?
520            test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
521            RETVAL=$?
522            if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
523                LIBS="$LIBS -lnetcdf"
524                HAVE_NETCDF=t
525            else
526                cat genmake_tnc.log >> genmake_warnings
527            fi
528      fi      fi
529      rm -f genmake_tnc*      rm -f genmake_tnc*
530  }  }
531    
532    
533    
534    ###############################################################################
535    #   Sequential part of script starts here
536    ###############################################################################
537    
538  #  Set defaults here  #  Set defaults here
539  COMMANDL="$0 $@"  COMMANDL="$0 $@"
540    
# Line 474  KPP= Line 545  KPP=
545  FC=  FC=
546  CPP=  CPP=
547  LINK=  LINK=
 # DEFINES="-DWORDLENGTH=4"  
548  DEFINES=  DEFINES=
549  PACKAGES=  PACKAGES=
550  ENABLE=  ENABLE=
# Line 495  LIBS= Line 565  LIBS=
565  KPPFILES=  KPPFILES=
566  NOOPTFILES=  NOOPTFILES=
567  NOOPTFLAGS=  NOOPTFLAGS=
568    MPI=
569    MPIPATH=
570    
571  # DEFINES checked by test compilation  # DEFINES checked by test compilation
572  HAVE_SYSTEM=  HAVE_SYSTEM=
# Line 642  for ac_option ; do Line 714  for ac_option ; do
714          -make=* | --make=* | -m=* | --m=*)          -make=* | --make=* | -m=* | --m=*)
715              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
716                    
717            -makedepend | --makedepend | -md | --md)
718                ac_prev=MAKEDEPEND ;;
719            -makedepend=* | --makedepend=* | -md=* | --md=*)
720                MAKEDEPEND=$ac_optarg ;;
721            
722          -makefile | --makefile | -ma | --ma)          -makefile | --makefile | -ma | --ma)
723              ac_prev=MAKEFILE ;;              ac_prev=MAKEFILE ;;
724          -makefile=* | --makefile=* | -ma=* | --ma=*)          -makefile=* | --makefile=* | -ma=* | --ma=*)
# Line 693  for ac_option ; do Line 770  for ac_option ; do
770              IEEE=true ;;              IEEE=true ;;
771          -noieee | --noieee)          -noieee | --noieee)
772              IEEE= ;;              IEEE= ;;
773    
774            -mpi | --mpi)
775                MPI=true ;;
776            -mpi=* | --mpi=*)
777                MPIPATH=$ac_optarg
778                MPI=true ;;
779                    
780  #       -jam | --jam)  #       -jam | --jam)
781  #           JAM=1 ;;  #           JAM=1 ;;
# Line 834  fi Line 917  fi
917  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
918      LINK=$FC      LINK=$FC
919  fi  fi
 if test "x$CPP" = x ; then  
     CPP="cpp"  
 fi  
920  if test "x$MAKE" = x ; then  if test "x$MAKE" = x ; then
921      MAKE="make"      MAKE="make"
922  fi  fi
923    if test "x$CPP" = x ; then
924        CPP=cpp
925    fi
926    #EH3 === UGLY ===
927    #  The following an ugly little hack to check for $CPP in /lib/ and it
928    #  should eventually be replaced with a more general function that
929    #  searches a combo of the user's path and a list of "usual suspects"
930    #  to find the correct location for binaries such as $CPP.
931    for i in " " "/lib/" ; do
932        echo "#define A a" | $i$CPP > test_cpp 2>&1 && CPP=$i$CPP
933    done
934    #EH3 === UGLY ===
935  echo "#define A a" | $CPP > test_cpp 2>&1  echo "#define A a" | $CPP > test_cpp 2>&1
936  RETVAL=$?  RETVAL=$?
937  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
# Line 876  EOF Line 968  EOF
968  fi  fi
969  rm -f genmake_test_ln genmake_tlink  rm -f genmake_test_ln genmake_tlink
970    
971    if test ! "x$MPI" = x ; then
972          echo "  Turning on MPI cpp macros"
973          DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
974    fi
975    
976  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
977  echo -n "  Do we have the system() command using $FC...  "  echo -n "  Do we have the system() command using $FC...  "
# Line 973  if test "x${TOOLSDIR}" = x ; then Line 1069  if test "x${TOOLSDIR}" = x ; then
1069      TOOLSDIR="$ROOTDIR/tools"      TOOLSDIR="$ROOTDIR/tools"
1070  fi  fi
1071  if test ! -d ${TOOLSDIR} ; then  if test ! -d ${TOOLSDIR} ; then
1072      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"      echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!"
1073      exit 1      exit 1
1074  fi  fi
1075  if test "x$S64" = x ; then  if test "x$S64" = x ; then
# Line 994  if test -r $ROOTDIR"/eesupp/src/Makefile Line 1090  if test -r $ROOTDIR"/eesupp/src/Makefile
1090          rm -f make_eesupp.errors          rm -f make_eesupp.errors
1091      else      else
1092          echo "Error: problem encountered while building source files in eesupp:"          echo "Error: problem encountered while building source files in eesupp:"
1093          cat make_eesupp.errors          cat make_eesupp.errors 1>&2
1094          exit 1          exit 1
1095      fi      fi
1096  fi  fi
# Line 1008  if test -r $ROOTDIR"/pkg/exch2/Makefile" Line 1104  if test -r $ROOTDIR"/pkg/exch2/Makefile"
1104          rm -f make_exch2.errors          rm -f make_exch2.errors
1105      else      else
1106          echo "Error: problem encountered while building source files in exch2:"          echo "Error: problem encountered while building source files in exch2:"
1107          cat make_exch2.errors          cat make_exch2.errors 1>&2
1108          exit 1          exit 1
1109      fi      fi
1110  fi  fi
# Line 1196  for i in $PACKAGES ; do Line 1292  for i in $PACKAGES ; do
1292      fi      fi
1293  done  done
1294    
1295  #  Check for ability to build and use NetCDF  #  Build MNC templates and check for ability to build and use NetCDF
1296  echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1  echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1297  RETVAL=$?  RETVAL=$?
1298  if test "x$RETVAL" = x0 -a "x$HAVE_NETCDF" != xt ; then  if test "x$RETVAL" = x0 ; then
1299      cat <<EOF      ( cd $ROOTDIR"/pkg/mnc" && $MAKE templates ) > make_mnc.errors 2>&1
1300        RETVAL=$?
1301        if test "x${RETVAL}" = x0 ; then
1302            rm -f make_mnc.errors
1303        else
1304            echo "Error: problem encountered while building source files in pkg/mnc:"
1305            cat make_mnc.errors 1>&2
1306            exit 1
1307        fi
1308        if test "x$HAVE_NETCDF" != xt ; then
1309            cat <<EOF
1310    
1311  WARNING: the "mnc" package has been enabled but tests failed to  WARNING: the "mnc" package has been enabled but tests failed to
1312    compile and/or execute NetCDF applications.  Please check that:    compile and/or execute NetCDF applications.  Please check that:
# Line 1210  WARNING: the "mnc" package has been enab Line 1316  WARNING: the "mnc" package has been enab
1316         NetCDF library to link against.         NetCDF library to link against.
1317        
1318  EOF  EOF
1319        fi
1320  fi  fi
1321    
1322  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
# Line 1743  $TOOLSDIR/convert_cpp_cmd2defines "Warni Line 1850  $TOOLSDIR/convert_cpp_cmd2defines "Warni
1850  if test ! -f $PACKAGES_DOT_H ; then  if test ! -f $PACKAGES_DOT_H ; then
1851      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
1852  else  else
1853      cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H > /dev/null 2>&1
1854      RETVAL=$?      RETVAL=$?
1855      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
1856          rm -f $PACKAGES_DOT_H".tmp"          rm -f $PACKAGES_DOT_H".tmp"

Legend:
Removed from v.1.60  
changed lines
  Added in v.1.69

  ViewVC Help
Powered by ViewVC 1.1.22