/[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.48 by heimbach, Tue Nov 25 16:03:38 2003 UTC revision 1.70 by edhill, Sat Feb 28 05:01:12 2004 UTC
# Line 1  Line 1 
1  #!/bin/sh  #! /usr/bin/env bash
2  #  #
3  # $Header$  # $Header$
4  #  #
# Line 13  Line 13 
13  test_for_package_in_cpp_options() {  test_for_package_in_cpp_options() {
14      cpp_options=$1      cpp_options=$1
15      pkg=$2      pkg=$2
16      grep -i "#define.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg" || exit 99
17      RETVAL=$?      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg" || exit 99
18      if test "x${RETVAL}" = x0 ; then      test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg" || exit 99
19          echo "Error: In $cpp_options there is an illegal line: #define ALLOW_$pkg"      test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg" || exit 99
20          exit 99  }
21      fi  
22      grep -i "#undef.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1  # Search for particular CPP #cmds associated with MPI
23      RETVAL=$?  # usage: test_for_mpi_in_cpp_eeoptions CPP_file
24      if test "x${RETVAL}" = x0 ; then  test_for_mpi_in_cpp_eeoptions() {
25          echo "Error: In $cpp_options there is an illegal line: #undef ALLOW_$pkg"      cpp_options=$1
26          exit 99      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI" || exit 99
27      fi      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI" || exit 99
28      grep -i "#define.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1      test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI" || exit 99
29        test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI" || exit 99
30    }
31    
32    # Search for particular string in a file. Return 1 if detected, 0 if not
33    # usage: test_for_string_in_file file string
34    test_for_string_in_file() {
35        file=$1
36        strng=$2
37        grep -i "$strng" $file > /dev/null 2>&1
38      RETVAL=$?      RETVAL=$?
39      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
40          echo "Error: In $cpp_options there is an illegal line: #define DISABLE_$pkg"          echo -n "Error: In $file there is an illegal line: "
41          exit 99          grep -i "$strng" $file
42            return 1
43      fi      fi
44      grep -i "#undef.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1      return 0
     RETVAL=$?  
     if test "x${RETVAL}" = x0 ; then  
         echo "Error: In $cpp_options there is an illegal line: #undef DISABLE_$pkg"  
         exit 99  
    fi  
45  }  }
46    
47  # Read the $ROOTDIR/pkg/pkg_groups file and expand any references to  # Read the $ROOTDIR/pkg/pkg_groups file and expand any references to
# Line 73  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 93  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 138  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 246  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 287  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 430  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 438  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 456  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 505  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 586  for ac_option ; do Line 695  for ac_option ; do
695          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
696              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
697                    
698          -adoptfile | --adoptfile | -ad | --ad)          -adoptfile | --adoptfile | -adof | --adof)
699              ac_prev=AD_OPTFILE ;;              ac_prev=AD_OPTFILE ;;
700          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
701              AD_OPTFILE=$ac_optarg ;;              AD_OPTFILE=$ac_optarg ;;
# Line 606  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 657  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 798  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 840  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 888  if test "x$HAVE_CLOC" != x ; then Line 1021  if test "x$HAVE_CLOC" != x ; then
1021  else  else
1022      echo "no"      echo "no"
1023  fi  fi
 echo "$FC_NAMEMANGLE" > FC_NAMEMANGLE.h.template  
 cmp FC_NAMEMANGLE.h FC_NAMEMANGLE.h.template > /dev/null 2>&1  
 RETVAL=$?  
 if test "x$RETVAL" != x0 ; then  
     mv -f FC_NAMEMANGLE.h.template FC_NAMEMANGLE.h  
 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 935  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 956  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 1144  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 1178  for i in $PACKAGES ; do Line 1353  for i in $PACKAGES ; do
1353  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
1354      case $i in      case $i in
1355          aim_v23)          aim_v23)
             DEFINES="$DEFINES -DALLOW_AIM"  
1356              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
1357              echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)"              echo "Warning: ALLOW_AIM is set to enable aim_v23."
1358              ;;              ;;
1359      esac      esac
1360  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
# Line 1189  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 CPP_OPTIONS.h in order to warn about the presence"  echo "  Searching for *OPTIONS.h files in order to warn about the presence"
1391  echo "    of \"#define ALLOW_PKGNAME\"-type statements:"  echo "    of \"#define \"-type statements that are no longer allowed:"
1392  CPP_OPTIONS=  CPP_OPTIONS=
1393    CPP_EEOPTIONS=
1394  spaths=". $INCLUDEDIRS"  spaths=". $INCLUDEDIRS"
1395    names=`ls -1 "$ROOTDIR/pkg"`
1396  for i in $spaths ; do  for i in $spaths ; do
1397      try="$i/CPP_OPTIONS.h"      try="$i/CPP_OPTIONS.h"
1398      #  echo -n "    trying $try : "      if test -f $try -a -r $try -a "x$CPP_OPTIONS" = x ; then
     if test -f $try -a -r $try ; then  
1399          echo "    found CPP_OPTIONS=\"$try\""          echo "    found CPP_OPTIONS=\"$try\""
1400          CPP_OPTIONS="$try"          CPP_OPTIONS="$try"
1401          break          # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
1402            for n in $names ; do
1403                test_for_package_in_cpp_options $CPP_OPTIONS $n
1404            done
1405        fi
1406        try="$i/CPP_EEOPTIONS.h"
1407        if test -f $try -a -r $try -a "x$CPP_EEOPTIONS" = x ; then
1408            echo "    found CPP_EEOPTIONS=\"$try\""
1409            # New safety test: make sure MPI is not determined by CPP_EEOPTIONS.h
1410    #**** not yet enabled ****
1411    #        test_for_mpi_in_cpp_eeoptions $try
1412    #**** not yet enabled ****
1413            CPP_EEOPTIONS="$try"
1414      fi      fi
1415  done  done
1416  if test "x$CPP_OPTIONS" = x ; then  if test "x$CPP_OPTIONS" = x ; then
1417      echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"      echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"
1418      exit 1      exit 1
1419  fi  fi
 # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h  
 names=`ls -1 "$ROOTDIR/pkg"`  
 for n in $names ; do  
     test_for_package_in_cpp_options $CPP_OPTIONS $n  
 done  
   
1420    
1421  #  Here, we build the list of files to be "run through" the adjoint  #  Here, we build the list of files to be "run through" the adjoint
1422  #  compiler.  #  compiler.
# Line 1248  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 1347  EXE_FTL=$EXECUTABLE"_ftl" Line 1531  EXE_FTL=$EXECUTABLE"_ftl"
1531  EXE_SVD=$EXECUTABLE"_svd"  EXE_SVD=$EXECUTABLE"_svd"
1532    
1533  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1534    #
1535    # OPTFILE="$OPTFILE"
1536  #  #
1537  # BUILDDIR     : Directory where object files are written  # BUILDDIR     : Directory where object files are written
1538  # SOURCEDIRS   : Directories containing the source (.F) files  # SOURCEDIRS   : Directories containing the source (.F) files
# Line 1383  EXE_SVD     = ${EXE_SVD} Line 1569  EXE_SVD     = ${EXE_SVD}
1569  ENABLED_PACKAGES = ${ENABLED_PACKAGES}  ENABLED_PACKAGES = ${ENABLED_PACKAGES}
1570  DISABLED_PACKAGES = ${DISABLED_PACKAGES}  DISABLED_PACKAGES = ${DISABLED_PACKAGES}
1571    
1572    # These files are created by Makefile
1573    SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h
1574    
1575  EOF  EOF
1576    
1577  #  Note: figure out some way to add Hyades JAM libraries here  #  Note: figure out some way to add Hyades JAM libraries here
# Line 1401  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 1447  cat >>$MAKEFILE <<EOF Line 1636  cat >>$MAKEFILE <<EOF
1636  .SUFFIXES: .o .f .p .F .c .F90 .f90  .SUFFIXES: .o .f .p .F .c .F90 .f90
1637    
1638  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
1639  \$(EXECUTABLE): links \$(OBJFILES)  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)
1640          @echo Creating \$@ ...          @echo Creating \$@ ...
1641          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
1642  depend:  depend:
# Line 1455  depend: Line 1644  depend:
1644          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
1645          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
1646    
1647  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) ${PACKAGES_DOT_H} AD_CONFIG.h  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)
1648    
1649  small_f: \$(F77FILES) \$(F90FILES)  small_f: \$(F77FILES) \$(F90FILES)
1650    
# Line 1468  clean: Line 1657  clean:
1657  Clean:  Clean:
1658          @make clean          @make clean
1659          @make cleanlinks          @make cleanlinks
1660          -rm -f ${PACKAGES_DOT_H} AD_CONFIG.h          -rm -f \$(SPECIAL_FILES)
1661          -rm -f Makefile.bak genmake_state genmake_*optfile genmake_warnings make.log          -rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log *.bak
1662  CLEAN:  CLEAN:
1663          @make Clean          @make Clean
1664          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
# Line 1483  makefile: Line 1672  makefile:
1672  cleanlinks:  cleanlinks:
1673          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
1674    
1675  # Special targets  # Special targets ($SPECIAL_FILES) which are create by make
1676  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
1677          @echo Creating \$@ ...          @echo Creating \$@ ...
1678          @\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@          @\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@
1679  AD_CONFIG.h:  AD_CONFIG.h:
1680          @echo Creating \$@ ...          @echo Creating \$@ ...
1681          @\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > \$@          @\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > \$@
1682    FC_NAMEMANGLE.h:
1683            @echo Creating \$@ ...
1684            echo "$FC_NAMEMANGLE" > \$@
1685    
1686  # The normal chain of rules is (  .F - .f - .o  )  # The normal chain of rules is (  .F - .f - .o  )
1687  .F.f:  .F.f:
# Line 1659  $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.48  
changed lines
  Added in v.1.70

  ViewVC Help
Powered by ViewVC 1.1.22