/[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.55 by jmc, Sat Dec 6 00:34:29 2003 UTC revision 1.70 by edhill, Sat Feb 28 05:01:12 2004 UTC
# Line 78  find_possible_configs()  { Line 78  find_possible_configs()  {
78      tmp1=`uname`"_"`uname -m`      tmp1=`uname`"_"`uname -m`
79      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
80      tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`      tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
81      PLATFORM=`echo $tmp3 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`      tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
82        tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
83        PLATFORM=$tmp2
84      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
85      echo "  The platform appears to be:  $PLATFORM"      echo "  The platform appears to be:  $PLATFORM"
86            
# Line 98  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 143  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 251  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 292  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 435  EOF Line 491  EOF
491  }  }
492    
493    
494    check_netcdf_libs()  {
495        cat <<EOF > genmake_tnc.F
496          program fgennc
497    #include "netcdf.inc"
498          integer iret, ncid, xid
499          iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
500          IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
501          iret = nf_def_dim(ncid, 'X', 11, xid)
502          IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
503          iret = nf_close(ncid)
504          IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
505          end
506    EOF
507        $CPP genmake_tnc.F > genmake_tnc.f  \
508            &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1
509        RET_COMPILE=$?
510        test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
511        RETVAL=$?
512        if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
513            HAVE_NETCDF=t
514        else
515            # 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
529        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 443  LN= Line 543  LN=
543  S64=  S64=
544  KPP=  KPP=
545  FC=  FC=
546    CPP=
547  LINK=  LINK=
 # DEFINES="-DWORDLENGTH=4"  
548  DEFINES=  DEFINES=
549  PACKAGES=  PACKAGES=
550  ENABLE=  ENABLE=
# Line 461  FOPTIM= Line 561  FOPTIM=
561  CFLAGS=  CFLAGS=
562  KFLAGS1=  KFLAGS1=
563  KFLAGS2=  KFLAGS2=
564    #LDADD=
565  LIBS=  LIBS=
566  KPPFILES=  KPPFILES=
567  NOOPTFILES=  NOOPTFILES=
568  NOOPTFLAGS=  NOOPTFLAGS=
569    MPI=
570    MPIPATH=
571    
572  # DEFINES checked by test compilation  # DEFINES checked by test compilation
573  HAVE_SYSTEM=  HAVE_SYSTEM=
574  HAVE_FDATE=  HAVE_FDATE=
575  FC_NAMEMANGLE=  FC_NAMEMANGLE=
576  HAVE_CLOC=  HAVE_CLOC=
577    HAVE_NETCDF=
578    
579  MODS=  MODS=
580  TOOLSDIR=  TOOLSDIR=
581  SOURCEDIRS=  SOURCEDIRS=
582  INCLUDEDIRS=  INCLUDEDIRS=
583  STANDARDDIRS=  STANDARDDIRS="USE_THE_DEFAULT"
584    
585  PWD=`pwd`  PWD=`pwd`
586  MAKE=make  MAKE=make
# Line 510  TAMC_EXTRA= Line 614  TAMC_EXTRA=
614    
615  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
616  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
617  gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STANDARDDIRS"
618    
619  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
620  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "
# Line 611  for ac_option ; do Line 715  for ac_option ; do
715          -make=* | --make=* | -m=* | --m=*)          -make=* | --make=* | -m=* | --m=*)
716              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
717                    
718            -makedepend | --makedepend | -md | --md)
719                ac_prev=MAKEDEPEND ;;
720            -makedepend=* | --makedepend=* | -md=* | --md=*)
721                MAKEDEPEND=$ac_optarg ;;
722            
723          -makefile | --makefile | -ma | --ma)          -makefile | --makefile | -ma | --ma)
724              ac_prev=MAKEFILE ;;              ac_prev=MAKEFILE ;;
725          -makefile=* | --makefile=* | -ma=* | --ma=*)          -makefile=* | --makefile=* | -ma=* | --ma=*)
# Line 662  for ac_option ; do Line 771  for ac_option ; do
771              IEEE=true ;;              IEEE=true ;;
772          -noieee | --noieee)          -noieee | --noieee)
773              IEEE= ;;              IEEE= ;;
774    
775            -mpi | --mpi)
776                MPI=true ;;
777            -mpi=* | --mpi=*)
778                MPIPATH=$ac_optarg
779                MPI=true ;;
780                    
781  #       -jam | --jam)  #       -jam | --jam)
782  #           JAM=1 ;;  #           JAM=1 ;;
# Line 803  fi Line 918  fi
918  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
919      LINK=$FC      LINK=$FC
920  fi  fi
 if test "x$CPP" = x ; then  
     CPP="cpp"  
 fi  
921  if test "x$MAKE" = x ; then  if test "x$MAKE" = x ; then
922      MAKE="make"      MAKE="make"
923  fi  fi
924    if test "x$CPP" = x ; then
925        CPP=cpp
926    fi
927    #EH3 === UGLY ===
928    #  The following an ugly little hack to check for $CPP in /lib/ and it
929    #  should eventually be replaced with a more general function that
930    #  searches a combo of the user's path and a list of "usual suspects"
931    #  to find the correct location for binaries such as $CPP.
932    for i in " " "/lib/" ; do
933        echo "#define A a" | $i$CPP > test_cpp 2>&1 && CPP=$i$CPP
934    done
935    #EH3 === UGLY ===
936  echo "#define A a" | $CPP > test_cpp 2>&1  echo "#define A a" | $CPP > test_cpp 2>&1
937  RETVAL=$?  RETVAL=$?
938  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
# Line 845  EOF Line 969  EOF
969  fi  fi
970  rm -f genmake_test_ln genmake_tlink  rm -f genmake_test_ln genmake_tlink
971    
972    if test ! "x$MPI" = x ; then
973          echo "  Turning on MPI cpp macros"
974          DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
975    fi
976    
977  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
978  echo -n "  Do we have the system() command using $FC...  "  echo -n "  Do we have the system() command using $FC...  "
# Line 895  else Line 1023  else
1023  fi  fi
1024  rm -f genmake_t*  rm -f genmake_t*
1025    
1026    echo -n "  Can we create NetCDF-enabled binaries...  "
1027    check_netcdf_libs
1028    if test "x$HAVE_NETCDF" != x ; then
1029        echo "yes"
1030    else
1031        echo "no"
1032    fi
1033    
1034    
1035  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1036  echo -n "  Adding MODS directories:  "  echo -n "  Adding MODS directories:  "
# Line 934  if test "x${TOOLSDIR}" = x ; then Line 1070  if test "x${TOOLSDIR}" = x ; then
1070      TOOLSDIR="$ROOTDIR/tools"      TOOLSDIR="$ROOTDIR/tools"
1071  fi  fi
1072  if test ! -d ${TOOLSDIR} ; then  if test ! -d ${TOOLSDIR} ; then
1073      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"      echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!"
1074      exit 1      exit 1
1075  fi  fi
1076  if test "x$S64" = x ; then  if test "x$S64" = x ; then
# Line 955  if test -r $ROOTDIR"/eesupp/src/Makefile Line 1091  if test -r $ROOTDIR"/eesupp/src/Makefile
1091          rm -f make_eesupp.errors          rm -f make_eesupp.errors
1092      else      else
1093          echo "Error: problem encountered while building source files in eesupp:"          echo "Error: problem encountered while building source files in eesupp:"
1094          cat make_eesupp.errors          cat make_eesupp.errors 1>&2
1095          exit 1          exit 1
1096      fi      fi
1097  fi  fi
1098    
1099    #same for exch2
1100    if test -r $ROOTDIR"/pkg/exch2/Makefile" ; then
1101        echo "  Making source files in exch2 from  templates"
1102        ( cd $ROOTDIR"/pkg/exch2/" && $MAKE ) > make_exch2.errors 2>&1
1103        RETVAL=$?
1104        if test "x${RETVAL}" = x0 ; then
1105            rm -f make_exch2.errors
1106        else
1107            echo "Error: problem encountered while building source files in exch2:"
1108            cat make_exch2.errors 1>&2
1109            exit 1
1110        fi
1111    fi
1112    
1113  printf "\n===  Determining package settings  ===\n"  printf "\n===  Determining package settings  ===\n"
1114  if  test "x${PDEPEND}" = x ; then  if  test "x${PDEPEND}" = x ; then
1115      tmp=$ROOTDIR"/pkg/pkg_depend"      tmp=$ROOTDIR"/pkg/pkg_depend"
# Line 1143  for i in $PACKAGES ; do Line 1293  for i in $PACKAGES ; do
1293      fi      fi
1294  done  done
1295    
1296    #  Build MNC templates and check for ability to build and use NetCDF
1297    echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1298    RETVAL=$?
1299    if test "x$RETVAL" = x0 ; then
1300        ( cd $ROOTDIR"/pkg/mnc" && $MAKE templates ) > make_mnc.errors 2>&1
1301        RETVAL=$?
1302        if test "x${RETVAL}" = x0 ; then
1303            rm -f make_mnc.errors
1304        else
1305            echo "Error: problem encountered while building source files in pkg/mnc:"
1306            cat make_mnc.errors 1>&2
1307            exit 1
1308        fi
1309        if test "x$HAVE_NETCDF" != xt ; then
1310            cat <<EOF
1311    
1312    WARNING: the "mnc" package has been enabled but tests failed to
1313      compile and/or execute NetCDF applications.  Please check that:
1314    
1315      1) NetCDF is installed for your compiler and
1316      2) the LIBS variable (within the 'optfile") specifies the correct
1317           NetCDF library to link against.
1318      
1319    EOF
1320        fi
1321    fi
1322    
1323  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
1324  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
# Line 1187  done Line 1363  done
1363    
1364  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS"
1365  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
1366  if test "x$STANDARDDIRS" = x ; then  if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then
1367      STANDARDDIRS="eesupp model"      STANDARDDIRS="eesupp model"
1368  fi  fi
1369  for d in $STANDARDDIRS ; do  if test "x$STANDARDDIRS" != x ; then
1370      adr="$ROOTDIR/$d/src"      for d in $STANDARDDIRS ; do
1371      if test ! -d $adr ; then          adr="$ROOTDIR/$d/src"
1372          echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""          if test ! -d $adr ; then
1373          echo "  is correct and that you correctly specified the STANDARDDIRS option"              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
1374          exit 1              echo "  is correct and that you correctly specified the STANDARDDIRS option"
1375      else              exit 1
1376          SOURCEDIRS="$SOURCEDIRS $adr"          else
1377      fi              SOURCEDIRS="$SOURCEDIRS $adr"
1378      adr="$ROOTDIR/$d/inc"          fi
1379      if test ! -d $adr ; then          adr="$ROOTDIR/$d/inc"
1380          echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""          if test ! -d $adr ; then
1381          echo "  is correct and that you correctly specified the STANDARDDIRS option"              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
1382          exit 1              echo "  is correct and that you correctly specified the STANDARDDIRS option"
1383      else              exit 1
1384          INCLUDEDIRS="$INCLUDEDIRS $adr"          else
1385      fi              INCLUDEDIRS="$INCLUDEDIRS $adr"
1386  done          fi
1387        done
1388    fi
1389    
1390  echo "  Searching for *OPTIONS.h files in order to warn about the presence"  echo "  Searching for *OPTIONS.h files in order to warn about the presence"
1391  echo "    of \"#define \"-type statements that are no longer allowed:"  echo "    of \"#define \"-type statements that are no longer allowed:"
# Line 1253  for i in $SOURCEDIRS ; do Line 1431  for i in $SOURCEDIRS ; do
1431      done      done
1432  done  done
1433    
1434    
1435  echo  echo
1436  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
1437  echo "  setting INCLUDES"  echo "  setting INCLUDES"
# Line 1411  FC = ${FC} Line 1590  FC = ${FC}
1590  # Fortran compiler  # Fortran compiler
1591  F90C = ${F90C}  F90C = ${F90C}
1592  # Link editor  # Link editor
1593  LINK = ${LINK}  LINK = ${LINK} ${LDADD}
1594    
1595  # Defines for CPP  # Defines for CPP
1596  DEFINES = ${DEFINES}  DEFINES = ${DEFINES}
# Line 1672  $TOOLSDIR/convert_cpp_cmd2defines "Warni Line 1851  $TOOLSDIR/convert_cpp_cmd2defines "Warni
1851  if test ! -f $PACKAGES_DOT_H ; then  if test ! -f $PACKAGES_DOT_H ; then
1852      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
1853  else  else
1854      cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H > /dev/null 2>&1
1855      RETVAL=$?      RETVAL=$?
1856      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
1857          rm -f $PACKAGES_DOT_H".tmp"          rm -f $PACKAGES_DOT_H".tmp"

Legend:
Removed from v.1.55  
changed lines
  Added in v.1.70

  ViewVC Help
Powered by ViewVC 1.1.22