/[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.1 by edhill, Sat Aug 16 14:01:08 2003 UTC revision 1.11.2.2 by edhill, Wed Oct 1 19:33:01 2003 UTC
# Line 8  Line 8 
8  #   modified by aja 01/00  #   modified by aja 01/00
9  #   rewritten in bash by eh3 08/03  #   rewritten in bash by eh3 08/03
10    
11    # Search for particular CPP #cmds associated with packages
12    # usage: test_for_package_in_cpp_options CPP_file package_name
13    test_for_package_in_cpp_options() {
14        cpp_options=$1
15        pkg=$2
16        grep -i "#define.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1
17        RETVAL=$?
18        if test "x${RETVAL}" = x0 ; then
19            echo "Error: In $cpp_options there is an illegal line: #define ALLOW_$pkg"
20            exit 99
21        fi
22        grep -i "#undef.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1
23        RETVAL=$?
24        if test "x${RETVAL}" = x0 ; then
25            echo "Error: In $cpp_options there is an illegal line: #undef ALLOW_$pkg"
26            exit 99
27        fi
28        grep -i "#define.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1
29        RETVAL=$?
30        if test "x${RETVAL}" = x0 ; then
31            echo "Error: In $cpp_options there is an illegal line: #define DISABLE_$pkg"
32            exit 99
33        fi
34        grep -i "#undef.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1
35        RETVAL=$?
36        if test "x${RETVAL}" = x0 ; then
37            echo "Error: In $cpp_options there is an illegal line: #undef DISABLE_$pkg"
38            exit 99
39       fi
40    }
41    
42    
43  # Guess possible config options for this host  # Guess possible config options for this host
44  find_possible_configs()  {  find_possible_configs()  {
45    
46      p_PLATFORM=`uname`"-"`uname -m`      tmp1=`uname`"_"`uname -m`
47      echo "The platform appears to be:"      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
48      echo "  "$p_PLATFORM      PLATFORM=`echo $tmp2 | sed -e 's/i[3-6]86/ia32/'`
49        OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
50      p_LN=      echo "  The platform appears to be:  $PLATFORM"
51    #     if test "x$OFLIST" = x ; then
52    #       echo "  No pre-defined options files were found matching this platform"
53    #       echo "  but examples for other platforms can be found in:"
54    #       echo "    $ROOTDIR/tools/build_options"
55    #     else
56    #       echo "  Options files (located in $ROOTDIR/tools/build_options) that"
57    #       echo "  may work with this machine are:"
58    #       for i in $OFLIST ; do
59    #           echo "    $i"
60    #       done
61    #     fi
62        
63      echo "test" > test      echo "test" > test
64      ln -s ./test link      ln -s ./test link
65      RETVAL=$?      RETVAL=$?
66      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
67          p_LN="ln -s"          LN="ln -s"
68        else
69            echo "Error: \"ln -s\" does not appear to work on this system!"
70            echo "  For help, please contact <MITgcm-support@mitgcm.org>."
71            exit 1
72      fi      fi
73      rm -f test link      rm -f test link
74    
75      p_CPP=`which cpp`      if test "x$CPP" = x ; then
76                CPP="cpp -traditional -P"
     RETVAL=$?  
     if test "x${RETVAL}" = x0 ; then  
         p_LN="ln -s"  
77      fi      fi
     rm -f test link  
78    
79      # look for possible fortran compilers      # look for possible fortran compilers
80        tmp="$MITGCM_FC $FC g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"
81      p_FC=      p_FC=
82      for c in f77 g77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 ; do      for c in $tmp ; do
83          which $c > /dev/null 2>&1          rm -f ./hello.f ./hello
84            cat >> hello.f <<EOF
85          program hello
86          do i=1,3
87            print *, 'hello world : ', i
88          enddo
89          end
90    EOF
91            $c -o hello hello.f > /dev/null 2>&1
92          RETVAL=$?          RETVAL=$?
93          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
94              p_FC="$p_FC $c"              p_FC="$p_FC $c"
95          fi          fi
96      done      done
     echo "Possible FORTRAN compilers appear to be:  "  
97      if test "x${p_FC}" = x ; then      if test "x${p_FC}" = x ; then
98          echo "  None found!!!"          cat 1>&2 <<EOF
99      else  
100          echo "  "$p_FC  Error: No Fortran compilers were found in your path.  Please specify one using:
101      fi  
102        1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
103        2) a command-line option (eg. "-fc NAME"), or
104        3) the MITGCM_FC environment variable.
105    
     # look for possible MPI libraries  
     mpi_libs=  
     mpi_fort=`which mpif77 2>/dev/null`  
     RETVAL=$?  
     if test "x${RETVAL}" = x0 ; then  
         cat >>test.f <<EOF  
       PROGRAM HELLO  
       DO 10, I=1,10  
       PRINT *,'Hello World'  
    10 CONTINUE  
       STOP  
       END  
106  EOF  EOF
107          eval "$mpi_fort -showme test.f > out"          exit 1
108          RETVAL=$?      else
109          if test "x${RETVAL}" = x0 ; then          echo "  The possible FORTRAN compilers found in your path are:"
110              a=`cat out`          echo "   "$p_FC
111              for i in $a ; do          if test "x$FC" = x ; then
112                  case $i in              FC=`echo $p_FC | awk '{print $1}'`
                     -*)  
                         mpi_libs="$mpi_libs $i" ;;  
                 esac  
             done  
             echo "The MPI libs appear to be:"  
             echo "  "$mpi_libs  
113          fi          fi
         rm -f test.f out  
114      fi      fi
115    
116  }      for i in $p_FC ; do
117            p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
118            if test -r $p_OF ; then
119                OPTFILE=$p_OF
120                echo "  The options file:  $p_OF"
121                echo "    appears to match so we'll use it."
122                break
123            fi
124        done
125        if test "x$OPTFILE" = x ; then
126            cat 1>&2 <<EOF
127    
128  parse_options()  {  Error: No options file was found in:  $ROOTDIR/tools/build_options/
129      that matches this platform ("$PLATFORM") and the compilers found in
130      your path.  Please specify an "optfile" using:
131    
132      ac_prev=      1) the command line (eg. "-optfile=path/to/OPTFILE"), or
133      for ac_option in "${OPTIONS[@]}" ; do      2) the MITGCM_OF environment variable.
134    
135      If you need help, please contact the developers at <MITgcm-support@mitgcm.org>.
136    
137    EOF
138            exit 1
139        fi
140        
141    #     # look for possible MPI libraries
142    #     mpi_libs=
143    #     mpi_fort=`which mpif77 2>/dev/null`
144    #     RETVAL=$?
145    #     if test "x${RETVAL}" = x0 ; then
146    #       cat >>test.f <<EOF
147    #       PROGRAM HELLO
148    #       DO 10, I=1,10
149    #       PRINT *,'Hello World'
150    #    10 CONTINUE
151    #       STOP
152    #       END
153    # EOF
154    #       eval "$mpi_fort -showme test.f > out"
155    #       RETVAL=$?
156    #       if test "x${RETVAL}" = x0 ; then
157    #           a=`cat out`
158    #           for i in $a ; do
159    #               case $i in
160    #                   -*)
161    #                       mpi_libs="$mpi_libs $i" ;;
162    #               esac
163    #           done
164    #           echo "The MPI libs appear to be:"
165    #           echo "  "$mpi_libs
166    #       fi
167    #       rm -f test.f out
168    #     fi
169    
         # echo "ac_option = :$ac_option:"  
           
         # If the previous option needs an argument, assign it.  
         if test -n "$ac_prev"; then  
             eval "$ac_prev=\$ac_option"  
             ac_prev=  
             continue  
         fi  
           
         ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`  
           
         case $ac_option in  
               
             -help | --help | -h | --h)  
                 usage ;;  
               
             -nooptfile | --nooptfile)  
                 OPTFILE="NONE" ;;  
             -optfile | --optfile | -of | --of)  
                 ac_prev=optfile ;;  
             -optfile=* | --optfile=* | -of=* | --of=*)  
                 OPTFILE=$ac_optarg ;;  
               
             -pdepend | --pdepend)  
                 ac_prev=pdepend ;;  
             -pdepend=* | --pdepend=*)  
                 PDEPEND=$ac_optarg ;;  
               
             -pdefault | --pdefault)  
                 ac_prev=pdefault ;;  
             -pdefault=* | --pdefault=*)  
                 PDEFAULT=$ac_optarg ;;  
               
             -makefile | -ma)  
                 ac_prev=makefile ;;  
             --makefile=* | -ma=*)  
                 MAKEFILE=$ac_optarg ;;  
               
             -platform | --platform | -pl | --pl)  
                 ac_prev=platform ;;  
             -platform=* | --platform=* | -pl=* | --pl=*)  
                 PLATFORM=$ac_optarg ;;  
   
             -rootdir | --rootdir | -rd | --rd)  
                 ac_prev=rootdir ;;  
             -rootdir=* | --rootdir=* | -rd=* | --rd=*)  
                 ROOTDIR=$ac_optarg ;;  
               
             -mods | --mods | -mo | --mo)  
                 ac_prev=mods ;;  
             -mods=* | --mods=* | -mo=* | --mo=*)  
                 MODS=$ac_optarg ;;  
               
             -disable | --disable)  
                 ac_prev=disable ;;  
             -disable=* | --disable=*)  
                 DISABLE=$ac_optarg ;;  
               
             -enable | --enable)  
                 ac_prev=enable ;;  
             -enable=* | --enable=*)  
                 ENABLE=$ac_optarg ;;  
               
             -noopt | --noopt)  
                 ac_prev=noopt ;;  
             -noopt=* | --noopt=*)  
                 NOOPT=$ac_optarg ;;  
               
 #           -cpp | --cpp)  
 #               ac_prev=cpp ;;  
 #           -cpp=* | --cpp=*)  
 #               CPP=$ac_optarg ;;  
               
             -fortran | --fortran | -fc | --fc)  
                 ac_prev=fc ;;  
             -fc=* | --fc=*)  
                 FC=$ac_optarg ;;  
               
             -ieee | --ieee)  
                 IEEE=1 ;;  
             -noieee | --noieee)  
                 IEEE=0 ;;  
               
             -mpi | --mpi)  
                 MPI=1 ;;  
             -nompi | --nompi)  
                 MPI=0 ;;  
               
             -jam | --jam)  
                 JAM=1 ;;  
             -nojam | --nojam)  
                 JAM=0 ;;  
               
             -*)  
                 echo "Error: unrecognized option: "$ac_option  
                 usage  
                 ;;  
               
             *)  
                 echo "Error: unrecognized argument: "$ac_option  
                 usage  
                 ;;  
               
         esac  
           
     done  
170  }  }
171    
172  #  Parse the package dependency information  #  Parse the package dependency information
# Line 210  get_pdepend_list()  { Line 186  get_pdepend_list()  {
186    
187  #  Explain usage  #  Explain usage
188  usage()  {  usage()  {
189      echo ""      echo
190      echo "Usage: "$0" [OPTIONS]"      echo "Usage: "$0" [OPTIONS]"
191      echo "  where [OPTIONS] can be:"$'\n'      echo "  where [OPTIONS] can be:"
192        echo
193      echo "    -help | --help | -h | --h"      echo "    -help | --help | -h | --h"
194      echo "    -nooptfile | --nooptfile"      echo "    -nooptfile | --nooptfile"
195      echo "      -optfile NAME | --optfile NAME | -of NAME | --of NAME"      echo "      -optfile NAME | --optfile NAME | -of NAME | --of NAME"
# Line 221  usage()  { Line 198  usage()  {
198      echo "      -pdepend=NAME | --pdepend=NAME"      echo "      -pdepend=NAME | --pdepend=NAME"
199      echo "    -pdefault NAME | --pdefault NAME"      echo "    -pdefault NAME | --pdefault NAME"
200      echo "      -pdefault=NAME | --pdefault=NAME"      echo "      -pdefault=NAME | --pdefault=NAME"
201      echo "    -makefile NAME | -ma NAME"      echo "    -make NAME | -m NAME"
202      echo "      --makefile=NAME | -ma=NAME"      echo "      --make=NAME | -m=NAME"
203        echo "    -makefile NAME | -mf NAME"
204        echo "      --makefile=NAME | -mf=NAME"
205      echo "    -platform NAME | --platform NAME | -pl NAME | --pl NAME"      echo "    -platform NAME | --platform NAME | -pl NAME | --pl NAME"
206      echo "      -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME"      echo "      -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME"
207      echo "    -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME"      echo "    -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME"
# Line 241  usage()  { Line 220  usage()  {
220      echo "      -fc=NAME | --fc=NAME"      echo "      -fc=NAME | --fc=NAME"
221      echo "    -[no]ieee | --[no]ieee"      echo "    -[no]ieee | --[no]ieee"
222      echo "    -[no]mpi | --[no]mpi"      echo "    -[no]mpi | --[no]mpi"
223      echo "    -[no]jam | --[no]jam"$'\n'      echo "    -[no]jam | --[no]jam"
224      echo "  and NAME is a string such as:"$'\n'      echo
225        echo "  and NAME is a string such as:"
226        echo
227      echo "    --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'"      echo "    --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'"
228      echo "    -mods=dir1   -mods='dir1'   -mods='dir1 dir2 dir3'"      echo "    -mods=dir1   -mods='dir1'   -mods='dir1 dir2 dir3'"
229      echo "    -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'"$'\n'      echo "    -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'"
230        echo
231      echo "  which, depending upon your shell, may need to be single-quoted"      echo "  which, depending upon your shell, may need to be single-quoted"
232      echo "  if it contains spaces, dashes, or other special characters."      echo "  if it contains spaces, dashes, or other special characters."
233      exit 1      exit 1
234  }  }
235    
 # Dump all important state  
 dump_state()  {  
     fname=$1  
     echo " " > $fname  
     RETVAL=$?  
     if test "x${RETVAL}" = x ; then  
         echo "Error: cannot write to $fname"  
         exit 1  
     fi  
     echo "makefile "$makefile > $fname  
 }  
   
   
236  #eh3 # This is the generic configuration.  #eh3 # This is the generic configuration.
237  #eh3 set LN         = ( 'ln -s' )  #eh3 set LN         = ( 'ln -s' )
238  #eh3 set CPP        = ( '/lib/cpp -P' )  #eh3 set CPP        = ( '/lib/cpp -P' )
# Line 284  dump_state()  { Line 253  dump_state()  {
253  #eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = (  )  #eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = (  )
254    
255  #  Set defaults here  #  Set defaults here
256    COMMANDL="$0 $@"
257    
258  PLATFORM=  PLATFORM=
259  LN=  LN=
260  S64=  S64=
261  KPP=  KPP=
262  FC=  FC=
263  LINK=  LINK=
264    DEFINES="-DWORDLENGTH=4"
265  PACKAGES=  PACKAGES=
266  ENABLE=  ENABLE=
267  DISABLE=  DISABLE=
268  MAKEFILE=  MAKEFILE=
269  MAKEDEPEND=  MAKEDEPEND=
270  PDEPEND=  PDEPEND=
271    DUMPSTATE=t
272  PDEFAULT=  PDEFAULT=
273  OPTFILE=  OPTFILE=
274  INCLUDES=-I.  INCLUDES="-I."
275  FFLAGS=  FFLAGS=
276  FOPTIM=  FOPTIM=
277  CFLAGS=  CFLAGS=
# Line 320  THISHOSTNAME=`hostname` Line 293  THISHOSTNAME=`hostname`
293  THISCWD=`pwd`  THISCWD=`pwd`
294  THISDATE=`date`  THISDATE=`date`
295  MACHINE=`uname -a`  MACHINE=`uname -a`
296    EXECUTABLE=
297    EXEHOOK=
298    EXEDIR=
299    
300    #  The following state can be set directly by command-line switches
301    gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"
302    gm_s2="FC IEEE MPI JAM DUMPSTATE"
303    
304    #  The following state is not directly set by command-line switches
305    gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "
306    gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
307    gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"
308    gm_s6="EXECUTABLE EXEHOOK EXEDIR"
309    
310    gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6"
311    
312  echo $'\n'"===  Processing options files and arguments  ==="  
313    echo
314    echo "===  Processing options files and arguments  ==="
315  gm_local="./gm_local"  gm_local="./gm_local"
316  echo -n "  getting local config information:  "  echo -n "  getting local config information:  "
317  if test -e $gm_local ; then  if test -e $gm_local ; then
318      echo "using $gm_local"      echo "using $gm_local"
319      source $gm_local      source $gm_local
320      echo "DISABLE=$DISABLE"$'\n'"ENABLE=$ENABLE"      # echo "DISABLE=$DISABLE"
321        # echo "ENABLE=$ENABLE"
322  else  else
323      echo "none found"      echo "none found"
324  fi  fi
325    
326  #  echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #  echo "$0::$1:$2:$3:$4:$5:$6:$7:"
327  OPTIONS=()  #OPTIONS=
328  n=0  #n=0
329  for i ; do  #for i ; do
330     setvar="OPTIONS[$n]='$i'"  #   echo "$i  $n"
331     #  echo "  $setvar"  #   setvar="OPTIONS[$n]='$i'"
332     eval "$setvar"  #   #  echo "  $setvar"
333     n=$(( $n + 1 ))  #   eval "$setvar"
334    #   n=$(( $n + 1 ))
335    #done
336    #parse_options
337    
338    ac_prev=
339    for ac_option ; do
340    
341        # If the previous option needs an argument, assign it.
342        if test -n "$ac_prev"; then
343            eval "$ac_prev=\$ac_option"
344            ac_prev=
345            continue
346        fi
347        
348        ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
349        
350        case $ac_option in
351            
352            -help | --help | -h | --h)
353                usage ;;
354            
355            -nooptfile | --nooptfile)
356                OPTFILE="NONE" ;;
357            -optfile | --optfile | -of | --of)
358                ac_prev=OPTFILE ;;
359            -optfile=* | --optfile=* | -of=* | --of=*)
360                OPTFILE=$ac_optarg ;;
361            
362            -pdepend | --pdepend)
363                ac_prev=PDEPEND ;;
364            -pdepend=* | --pdepend=*)
365                PDEPEND=$ac_optarg ;;
366            
367            -pdefault | --pdefault)
368                ac_prev=PDEFAULT ;;
369            -pdefault=* | --pdefault=*)
370                PDEFAULT=$ac_optarg ;;
371            
372            -make | --make | -m | --m)
373                ac_prev=MAKE ;;
374            -make=* | --make=* | -m=* | --m=*)
375                MAKE=$ac_optarg ;;
376            
377            -makefile | --makefile | -ma | --ma)
378                ac_prev=MAKEFILE ;;
379            -makefile=* | --makefile=* | -ma=* | --ma=*)
380                MAKEFILE=$ac_optarg ;;
381            
382            -platform | --platform | -pl | --pl)
383                ac_prev=PLATFORM ;;
384            -platform=* | --platform=* | -pl=* | --pl=*)
385                PLATFORM=$ac_optarg ;;
386            
387            -rootdir | --rootdir | -rd | --rd)
388                ac_prev=ROOTDIR ;;
389            -rootdir=* | --rootdir=* | -rd=* | --rd=*)
390                ROOTDIR=$ac_optarg ;;
391            
392            -mods | --mods | -mo | --mo)
393                ac_prev=MODS ;;
394            -mods=* | --mods=* | -mo=* | --mo=*)
395                MODS=$ac_optarg ;;
396            
397            -disable | --disable)
398                ac_prev=DISABLE ;;
399            -disable=* | --disable=*)
400                DISABLE=$ac_optarg ;;
401            
402            -enable | --enable)
403                ac_prev=ENABLE ;;
404            -enable=* | --enable=*)
405                ENABLE=$ac_optarg ;;
406            
407            -noopt | --noopt)
408                ac_prev=NOOPT ;;
409            -noopt=* | --noopt=*)
410                NOOPT=$ac_optarg ;;
411            
412    #           -cpp | --cpp)
413    #               ac_prev=cpp ;;
414    #           -cpp=* | --cpp=*)
415    #               CPP=$ac_optarg ;;
416                
417            -fortran | --fortran | -fc | --fc)
418                ac_prev=FC ;;
419            -fc=* | --fc=*)
420                FC=$ac_optarg ;;
421            
422            -ieee | --ieee)
423                IEEE=1 ;;
424            -noieee | --noieee)
425                IEEE=0 ;;
426            
427            -mpi | --mpi)
428                MPI=1 ;;
429            -nompi | --nompi)
430                MPI=0 ;;
431            
432            -jam | --jam)
433                JAM=1 ;;
434            -nojam | --nojam)
435                JAM=0 ;;
436            
437            -ds | --ds)
438                DUMPSTATE=t ;;
439            
440            -*)
441                echo "Error: unrecognized option: "$ac_option
442                usage
443                ;;
444            
445            *)
446                echo "Error: unrecognized argument: "$ac_option
447                usage
448                ;;
449            
450        esac
451        
452  done  done
453  parse_options  
454    if test "x${ROOTDIR}" = x ; then
455        if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
456            ROOTDIR=".."
457        else
458            for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
459                if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then
460                    ROOTDIR=$d
461                    echo -n "Warning:  ROOTDIR was not specified but there appears to be"
462                    echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."
463                    break
464                fi
465            done
466        fi
467    fi
468    if test "x${ROOTDIR}" = x ; then
469        echo "Error: Cannot determine ROOTDIR for MITgcm code."
470        echo "  Please specify a ROOTDIR using either an options "
471        echo "  file or a command-line option."
472        exit 1
473    fi
474    if test ! -d ${ROOTDIR} ; then
475        echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!"
476        exit 1
477    fi
478    
479  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
480  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
481      echo "Warning: no OPTFILE specified so we'll look for possible settings"      if test "x$MITGCM_OF" = x ; then
482      echo $'\n'"===  Searching for possible settings for OPTFILE  ==="          echo "Warning: no OPTFILE specified so we'll look for possible settings"
483      find_possible_configs          printf "\n===  Searching for possible settings for OPTFILE  ===\n"
484  else          find_possible_configs
     if test "x$OPTFILE" = xNONE ; then  
         echo "    OPTFILE=NONE so we'll try to use default settings"  
485      else      else
486          if test -f "$OPTFILE" -a -r "$OPTFILE" ; then          OPTFILE=$MITGCM_OF
487              echo "    using OPTFILE=\"$OPTFILE\""      fi
488              source "$OPTFILE"  fi
489              RETVAL=$?  if test "x$OPTFILE" != xNONE ; then
490              if test "x$RETVAL" != x0 ; then      if test -f "$OPTFILE" -a -r "$OPTFILE" ; then
491                  echo -n "Error: failed to source OPTFILE \"$OPTFILE\""          echo "    using OPTFILE=\"$OPTFILE\""
492                  echo "--please check that variable syntax is bash-compatible"          source "$OPTFILE"
493                  exit 1          RETVAL=$?
494              fi          if test "x$RETVAL" != x0 ; then
495          else              echo -n "Error: failed to source OPTFILE \"$OPTFILE\""
496              echo "Error: can't read OPTFILE=\"$OPTFILE\""              echo "--please check that variable syntax is bash-compatible"
497              exit 1              exit 1
498          fi          fi
499            if test "x$DUMPSTATE" != xf ; then
500                cp -f $OPTFILE "gm_optfile"
501            fi
502        else
503            echo "Error: can't read OPTFILE=\"$OPTFILE\""
504            exit 1
505      fi      fi
506  fi  fi
507    
508  echo $'\n'"===  Setting defaults  ==="  #  Check that FC, LINK, CPP, and S64 are defined.  If not, complain
509    #  and abort!
510    if test "x$FC" = x ; then
511        cat <<EOF 1>&2
512    
513    Error: no Fortran compiler: please specify using one of the following:
514      1) within the options file ("FC=...") as specified by "-of=OPTFILE"
515      2) the "-fc=XXX" command-line option
516      3) the "./gm_local" file
517    EOF
518        exit 1
519    fi
520    if test "x$LINK" = x ; then
521        LINK=$FC
522    fi
523    if test "x$CPP" = x ; then
524        CPP="cpp"
525    fi
526    echo "#define A a" | cpp > test_cpp 2>&1
527    RETVAL=$?
528    if test "x$RETVAL" != x0 ; then
529        cat <<EOF 1>&2
530    
531    Error: C pre-processor "$CPP" failed the test case: please specify using:
532    
533      1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
534      2) the "./gm_local" file
535    
536    EOF
537        exit 1
538    else
539        rm -f test_cpp
540    fi
541    if test "x$MAKEDEPEND" = x ; then
542        MAKEDEPEND=makedepend
543    fi
544    
545    printf "\n===  Setting defaults  ===\n"
546  echo -n "  Adding MODS directories:  "  echo -n "  Adding MODS directories:  "
547  for d in $MODS ; do  for d in $MODS ; do
548      if test ! -d $d ; then      if test ! -d $d ; then
549          echo $'\n\n'"Error: MODS directory \"$d\" not found!"          echo
550            echo "Error: MODS directory \"$d\" not found!"
551          exit 1          exit 1
552      else      else
553          echo -n " $d"          echo -n " $d"
# Line 389  if test "x${PLATFORM}" = x ; then Line 564  if test "x${PLATFORM}" = x ; then
564      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
565  fi  fi
566    
 if test "x${ROOTDIR}" = x ; then  
     if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then  
         ROOTDIR=".."  
     else  
         for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do  
             if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then  
                 ROOTDIR=$d  
                 echo -n "Warning:  ROOTDIR was not specified but there appears to be"  
                 echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."  
                 break  
             fi  
         done  
     fi  
 fi  
 if test "x${ROOTDIR}" = x ; then  
     echo "Error: Cannot determine ROOTDIR for MITgcm code."  
     echo "  Please specify a ROOTDIR using either an options "  
     echo "  file or a command-line option."  
     exit 1  
 fi  
 if test ! -d ${ROOTDIR} ; then  
     echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!"  
     exit 1  
 fi  
   
567  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
568      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then
569          EXEDIR=../exe          EXEDIR=../exe
# Line 433  if test ! -d ${TOOLSDIR} ; then Line 583  if test ! -d ${TOOLSDIR} ; then
583      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"
584      exit 1      exit 1
585  fi  fi
586    if test "x$S64" = x ; then
587        S64='$(TOOLSDIR)/set64bitConst.sh'
588    fi
589    
590  EXECUTABLE=${EXECUTABLE:-mitgcmuv}  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
591    
# Line 443  if test -r $ROOTDIR"/eesupp/src/Makefile Line 596  if test -r $ROOTDIR"/eesupp/src/Makefile
596      echo "  Making source files in eesupp from templates"      echo "  Making source files in eesupp from templates"
597      $MAKE -C $ROOTDIR"/eesupp/src/" > make_eesupp.errors 2>&1      $MAKE -C $ROOTDIR"/eesupp/src/" > make_eesupp.errors 2>&1
598      RETVAL=$?      RETVAL=$?
599      if test "x${RETVAL}" == "x0" ; then      if test "x${RETVAL}" = x0 ; then
600          rm -f make_eesupp.errors          rm -f make_eesupp.errors
601      else      else
602          echo "Error: problem encountered while building source files in eesupp:"          echo "Error: problem encountered while building source files in eesupp:"
# Line 452  if test -r $ROOTDIR"/eesupp/src/Makefile Line 605  if test -r $ROOTDIR"/eesupp/src/Makefile
605      fi      fi
606  fi  fi
607    
608  echo $'\n'"===  Determining package settings  ==="  printf "\n===  Determining package settings  ===\n"
609  if  test "x${PDEPEND}" = x ; then  if  test "x${PDEPEND}" = x ; then
610      tmp=$ROOTDIR"/pkg/pkg_depend"      tmp=$ROOTDIR"/pkg/pkg_depend"
611      if test -r $tmp ; then      if test -r $tmp ; then
# Line 471  echo "  getting package dependency info Line 624  echo "  getting package dependency info
624  #  Strip the comments and then convert the dependency file into  #  Strip the comments and then convert the dependency file into
625  #  two arrays: PNAME, DNAME  #  two arrays: PNAME, DNAME
626  cat $PDEPEND | sed -e 's/#.*$//g' \  cat $PDEPEND | sed -e 's/#.*$//g' \
627      | awk 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \      | awk 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \
628      > ./.pd_tmp      > ./.pd_tmp
629  RETVAL=$?  RETVAL=$?
630  if test ! "x${RETVAL}" = x0 ; then  if test ! "x${RETVAL}" = x0 ; then
# Line 523  for p in $PACKAGES ; do Line 676  for p in $PACKAGES ; do
676  done  done
677  PACKAGES="$pack"  PACKAGES="$pack"
678  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
679  rm -f ./.tmp_pack  echo "" > ./.tmp_pack
680  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
681  for i in $PACKAGES ; do  for i in $PACKAGES ; do
682      if test ! -d "$ROOTDIR/pkg/$i" ; then      if test ! -d "$ROOTDIR/pkg/$i" ; then
# Line 544  echo "  applying package dependency rule Line 697  echo "  applying package dependency rule
697  ck=  ck=
698  while test "x$ck" != xtt ; do  while test "x$ck" != xtt ; do
699      i=0      i=0
700      rtot=${#PNAME[@]}      # rtot=${#PNAME[@]}
701        rtot=$nname
702      while test $i -lt $rtot ; do      while test $i -lt $rtot ; do
703    
704          #  Is $pname in the current $PACKAGES list?          #  Is $pname in the current $PACKAGES list?
705          pname=${PNAME[$i]}          #  pname=${PNAME[$i]}
706            tmp="pname=\"\$PNAME_$i\""
707            eval $tmp
708          pin="f"          pin="f"
709          for p in $PACKAGES ; do          for p in $PACKAGES ; do
710              if test "x$p" = "x$pname" ; then              if test "x$p" = "x$pname" ; then
# Line 557  while test "x$ck" != xtt ; do Line 713  while test "x$ck" != xtt ; do
713          done          done
714    
715          #  Is the DNAME entry a (+) or (-) rule ?          #  Is the DNAME entry a (+) or (-) rule ?
716            tmp="dname=\"\$DNAME_$i\""
717            eval $tmp
718          plus="-"          plus="-"
719          echo "${DNAME[$i]}" | grep '^+' > /dev/null 2>&1          echo $dname | grep '^+' > /dev/null 2>&1
720          RETVAL=$?          RETVAL=$?
721          if test "x$RETVAL" = x0 ; then          if test "x$RETVAL" = x0 ; then
722              plus="+"              plus="+"
723          fi          fi
724    
725          #  Is $dname in the current $PACKAGES list?          #  Is $dname in the current $PACKAGES list?
726          dname=`echo ${DNAME[$i]} | sed -e 's/^[+-]//'`          dname=`echo $dname | sed -e 's/^[+-]//'`
727          din="f"          din="f"
728          for p in $PACKAGES ; do          for p in $PACKAGES ; do
729              if test "x$p" = "x$dname" ; then              if test "x$p" = "x$dname" ; then
# Line 634  done Line 792  done
792  # done  # done
793  # echo  # echo
794    
795  echo "  Setting package-specific CPP flags in CPP_OPTIONS.h:"  # Create a list of #define and #undef to enable/disable packages
796  CPP_OPTIONS=  PACKAGES_DOT_H=PACKAGES.h
797  spaths=". $SOURCEDIRS"  if test -e $PACKAGES_DOT_H ; then
798  for i in $spaths ; do      cat $PACKAGES_DOT_H \
     try="$i/CPP_OPTIONS.h"  
     #  echo -n "    trying $try : "  
     if test -f $try -a -r $try ; then  
         echo "    found CPP_OPTIONS=\"$try\""  
         CPP_OPTIONS="$try"  
         if test "x$i" != "x." ; then  
             cp -f $CPP_OPTIONS .  
         fi  
         break  
     fi  
 done  
 if test "x$CPP_OPTIONS" = x ; then  
     echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"  
     exit 1  
 fi  
 if test -e CPP_OPTIONS.h ; then  
     if test ! -e CPP_OPTIONS.h.bak ; then  
         cp -f CPP_OPTIONS.h CPP_OPTIONS.h.bak  
     fi  
     cat CPP_OPTIONS.h \  
799          | awk 'BEGIN{p=1;} ($1=="C===" && $2=="GENMAKE"){p=0;} {if (p==1) print $0}' \          | awk 'BEGIN{p=1;} ($1=="C===" && $2=="GENMAKE"){p=0;} {if (p==1) print $0}' \
800          > CPP_OPTIONS.h.tmp          > $PACKAGES_DOT_H".tmp"
801  fi  fi
802  cat <<EOF >>CPP_OPTIONS.h.tmp  cat <<EOF >>$PACKAGES_DOT_H".tmp"
803  C=== GENMAKE v2 ===  C=== GENMAKE v2 ===
804  C  The following defines have been set by GENMAKE, so please edit  C  The following defines have been set by GENMAKE, so please do not
805  C  them only if you know what you're doing.  In general, you should  C  edit anything below these comments.  In general, you should
806  C  add or remove packages by re-running genmake with different  C  add or remove packages by re-running genmake with different
807  C  "-enable" and/or "-disable" options.  C  "-enable" and/or "-disable" options.
808    
# Line 687  for n in $names ; do Line 825  for n in $names ; do
825          done          done
826          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
827              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`
828              echo "#undef $undef" >> CPP_OPTIONS.h.tmp              echo "#undef $undef" >> $PACKAGES_DOT_H".tmp"
829    #           DEFINES="$DEFINES -U$undef"
830    
831  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
832              case $n in              case $n in
# Line 697  for n in $names ; do Line 836  for n in $names ; do
836                  mom_vecinv)                  mom_vecinv)
837                      DEFINES="$DEFINES -DDISABLE_MOM_VECINV"                      DEFINES="$DEFINES -DDISABLE_MOM_VECINV"
838                      ;;                      ;;
                 generic_advdiff)  
                     DEFINES="$DEFINES -DDISABLE_GENERIC_ADVDIFF"  
                     ;;  
839                  debug)                  debug)
840                      DEFINES="$DEFINES -DDISABLE_DEBUGMODE"                      DEFINES="$DEFINES -DDISABLE_DEBUGMODE"
841                      ;;                      ;;
# Line 709  for n in $names ; do Line 845  for n in $names ; do
845          fi          fi
846      fi      fi
847  done  done
848  cat <<EOF >>CPP_OPTIONS.h.tmp  cat <<EOF >>$PACKAGES_DOT_H".tmp"
849    
850  C  Packages enabled by genmake:  C  Packages enabled by genmake:
851  EOF  EOF
852  for i in $PACKAGES ; do  for i in $PACKAGES ; do
853      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`
854      echo "#define $def" >> CPP_OPTIONS.h.tmp      echo "#define $def" >> $PACKAGES_DOT_H".tmp"
855    #eh3 DEFINES="$DEFINES -D$def"
856    
857  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
858      case $i in      case $i in
859          aim_v23)          aim_v23)
860              echo "#define   ALLOW_AIM" >> CPP_OPTIONS.h.tmp              echo "#define   ALLOW_AIM" >> $PACKAGES_DOT_H".tmp"
861                DEFINES="$DEFINES -DALLOW_AIM"
862                echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)"
863              ;;              ;;
864      esac      esac
865  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
866    
867  done  done
868  mv -f CPP_OPTIONS.h.tmp CPP_OPTIONS.h  cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
869    RETVAL=$?
870    if test "x$RETVAL" = x0 ; then
871        mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H".bak"
872        mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
873    fi
874    
875  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS"
876  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
# Line 750  for d in $STANDARDDIRS ; do Line 894  for d in $STANDARDDIRS ; do
894      fi      fi
895  done  done
896    
897    echo " Searching for CPP_OPTIONS.h in order to warn about the presence"
898    echo " of \"#define ALLOW_PKGNAME\"-type statements:"
899    CPP_OPTIONS=
900    spaths=". $INCLUDEDIRS"
901    for i in $spaths ; do
902        try="$i/CPP_OPTIONS.h"
903        #  echo -n "    trying $try : "
904        if test -f $try -a -r $try ; then
905            echo "    found CPP_OPTIONS=\"$try\""
906            CPP_OPTIONS="$try"
907            break
908        fi
909    done
910    if test "x$CPP_OPTIONS" = x ; then
911        echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"
912        exit 1
913    fi
914    # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
915    names=`ls -1 "$ROOTDIR/pkg"`
916    for n in $names ; do
917        test_for_package_in_cpp_options $CPP_OPTIONS $n
918    done
919    
920  echo $'\n'"===  Creating the Makefile  ==="  
921    echo
922    echo "===  Creating the Makefile  ==="
923  echo "  setting INCLUDES"  echo "  setting INCLUDES"
924  for i in $INCLUDEDIRS ; do  for i in $INCLUDEDIRS ; do
925      if test -d $i ; then      if ! test -d $i ; then
926          INCLUDES="$INCLUDES -I$i"  #       INCLUDES="$INCLUDES -I$i"
927      else  #   else
928          echo "Warning: can't find INCLUDEDIRS=\"$i\""          echo "Warning: can't find INCLUDEDIRS=\"$i\""
929      fi      fi
930  done  done
# Line 766  rm -rf .links.tmp Line 934  rm -rf .links.tmp
934  mkdir .links.tmp  mkdir .links.tmp
935  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > srclinks.tmp
936  echo "" >> srclinks.tmp  echo "" >> srclinks.tmp
937  echo -n 'SRCFILES = ' > srclist.inc  echo -n 'SRCFILES = '    > srclist.inc
938  echo -n 'CSRCFILES = ' > csrclist.inc  echo -n 'CSRCFILES = '   > csrclist.inc
939    echo -n 'F90SRCFILES = ' > f90srclist.inc
940  echo -n 'HEADERFILES = ' > hlist.inc  echo -n 'HEADERFILES = ' > hlist.inc
941  alldirs=". $SOURCEDIRS $INCLUDEDIRS"  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
942  for d in $alldirs ; do  for d in $alldirs ; do
943      deplist=      deplist=
944      sfiles=`( cd $d; echo *.[h,c,F] )`      sfiles=`( cd $d; echo *.[h,c,F] )`
945        sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
946      for sf in $sfiles ; do      for sf in $sfiles ; do
947          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
948              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
# Line 784  for d in $alldirs ; do Line 954  for d in $alldirs ; do
954                          echo    " \\"  >> srclist.inc                          echo    " \\"  >> srclist.inc
955                          echo -n " $sf" >> srclist.inc                          echo -n " $sf" >> srclist.inc
956                          ;;                          ;;
957                        F90)
958                            echo    " \\"  >> f90srclist.inc
959                            echo -n " $sf" >> f90srclist.inc
960                            ;;
961                      c)                      c)
962                          echo    " \\"  >> csrclist.inc                          echo    " \\"  >> csrclist.inc
963                          echo -n " $sf" >> csrclist.inc                          echo -n " $sf" >> csrclist.inc
# Line 797  for d in $alldirs ; do Line 971  for d in $alldirs ; do
971          fi          fi
972      done      done
973      if test "x$deplist" != x ; then      if test "x$deplist" != x ; then
974          echo $'\n'"#  These files are linked from $d" >> srclinks.tmp          echo "" >> srclinks.tmp
975            echo "#  These files are linked from $d" >> srclinks.tmp
976          echo "$deplist :" >> srclinks.tmp          echo "$deplist :" >> srclinks.tmp
977          echo $'\t$(LN) '$d'/$@ $@' >> srclinks.tmp          printf "\t\$(LN) %s/\$@ \$@\n" $d >> srclinks.tmp
978      fi      fi
979  done  done
980  rm -rf .links.tmp  rm -rf .links.tmp
981  echo "" >> srclist.inc  echo "" >> srclist.inc
982  echo "" >> csrclist.inc  echo "" >> csrclist.inc
983    echo "" >> f90srclist.inc
984  echo "" >> hlist.inc  echo "" >> hlist.inc
985    
986  if test -e $MAKEFILE ; then  if test -e $MAKEFILE ; then
# Line 862  MAKEDEPEND = ${MAKEDEPEND} Line 1038  MAKEDEPEND = ${MAKEDEPEND}
1038  KPP = ${KPP}  KPP = ${KPP}
1039  # Fortran compiler  # Fortran compiler
1040  FC = ${FC}  FC = ${FC}
1041    # Fortran compiler
1042    F90C = ${F90C}
1043  # Link editor  # Link editor
1044  LINK = ${LINK}  LINK = ${LINK}
1045    
# Line 875  KFLAGS2 = ${KFLAGS2} Line 1053  KFLAGS2 = ${KFLAGS2}
1053  # Optim./debug for FC  # Optim./debug for FC
1054  FFLAGS = ${FFLAGS}  FFLAGS = ${FFLAGS}
1055  FOPTIM = ${FOPTIM}  FOPTIM = ${FOPTIM}
1056    # Optim./debug for FC
1057    F90FLAGS = ${F90FLAGS}
1058    F90OPTIM = ${F90OPTIM}
1059  # Flags for CC  # Flags for CC
1060  CFLAGS = ${CFLAGS}  CFLAGS = ${CFLAGS}
1061  # Files that should not be optimized  # Files that should not be optimized
# Line 882  NOOPTFILES = ${NOOPTFILES} Line 1063  NOOPTFILES = ${NOOPTFILES}
1063  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
1064  # Flags and libraries needed for linking  # Flags and libraries needed for linking
1065  LIBS = ${LIBS} \$(XLIBS)  LIBS = ${LIBS} \$(XLIBS)
1066    # Name of the Mekfile
1067    MAKEFILE=${MAKEFILE}
1068    
1069  EOF  EOF
1070    
1071  cat srclist.inc  >> $MAKEFILE  cat srclist.inc    >> $MAKEFILE
1072  cat csrclist.inc >> $MAKEFILE  cat csrclist.inc   >> $MAKEFILE
1073  cat hlist.inc >> $MAKEFILE  cat f90srclist.inc >> $MAKEFILE
1074  echo 'F77FILES =  $(SRCFILES:.F=.f)'                    >> $MAKEFILE  cat hlist.inc      >> $MAKEFILE
1075  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o)' >> $MAKEFILE  echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE
1076    echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE
1077    echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
1078    
1079  rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp  rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc
1080    
1081  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1082    
1083  .SUFFIXES:  .SUFFIXES:
1084  .SUFFIXES: .o .f .p .F .c  .SUFFIXES: .o .f .p .F .c .F90 .f90
1085    
1086  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
1087  \$(EXECUTABLE): \$(OBJFILES)  \$(EXECUTABLE): \$(OBJFILES)
# Line 904  all: \$(EXECUTABLE) Line 1089  all: \$(EXECUTABLE)
1089  depend:  depend:
1090          @make links          @make links
1091          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
1092            ${TOOLSDIR}/f90mkdepend >> \$(MAKEFILE)
1093    
1094  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES)  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES)
1095    
1096  small_f: \$(F77FILES)  small_f: \$(F77FILES) \$(F90FILES)
1097    
1098  output.txt: \$(EXECUTABLE)  output.txt: \$(EXECUTABLE)
1099          @printf 'running ... '          @printf 'running ... '
1100          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
1101    
1102  clean:  clean:
1103          -rm -rf *.o *.f *.p ${RMFILES} work.{pc,pcl}          -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl}
1104  Clean:  Clean:
1105          @make clean          @make clean
1106          @make cleanlinks          @make cleanlinks
1107          -rm -f Makefile.bak          -rm -f Makefile.bak gm_state gm_optfile make.log PACKAGES.h*
1108  CLEAN:  CLEAN:
1109          @make Clean          @make Clean
1110          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
1111          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
1112          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
1113          -rm -f \$(EXECUTABLE)          -rm -f \$(EXECUTABLE) output.txt
1114    
1115  makefile:  makefile:
1116          ${0} $@          ${0} $@
# Line 936  cleanlinks: Line 1122  cleanlinks:
1122          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1123  .f.o:  .f.o:
1124          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
1125    .F90.f90:
1126            \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1127    .f90.o:
1128            \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
1129  .c.o:  .c.o:
1130          \$(CC) \$(CFLAGS) -c \$<          \$(CC) \$(CFLAGS) -c \$<
1131    
# Line 947  cleanlinks: Line 1137  cleanlinks:
1137    
1138  EOF  EOF
1139    
1140    if test "x$EXEHOOK" != x ; then
1141        printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE
1142    fi
1143    
1144  echo "  Making list of \"exceptions\" that need \".p\" files"  echo "  Making list of \"exceptions\" that need \".p\" files"
1145  for i in $KPPFILES ; do  for i in $KPPFILES ; do
1146      base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`      base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`
# Line 965  for i in $NOOPTFILES ; do Line 1159  for i in $NOOPTFILES ; do
1159          echo "Error: unable to add file \"$i\" to the exceptions list"          echo "Error: unable to add file \"$i\" to the exceptions list"
1160      fi      fi
1161      echo "$base.o: $base.f" >> $MAKEFILE      echo "$base.o: $base.f" >> $MAKEFILE
1162      echo $'\t$(FC) $(FFLAGS) $(NOOPTFLAGS) -c $<' >> $MAKEFILE      printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE
1163  done  done
1164    
1165  echo "  Add rules for links"  echo "  Add rules for links"
# Line 973  cat srclinks.tmp >> $MAKEFILE Line 1167  cat srclinks.tmp >> $MAKEFILE
1167  rm -f srclinks.tmp  rm -f srclinks.tmp
1168    
1169  echo "  Adding makedepend marker"  echo "  Adding makedepend marker"
1170  echo $'\n\n'"# DO NOT DELETE" >> $MAKEFILE  printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE
1171    
1172    printf "\n===  Done  ===\n"
1173    
1174  echo $'\n'"===  Done  ==="  
1175    #  Write the "state" for future records
1176    if test "x$DUMPSTATE" != xf ; then
1177        echo -n "" > gm_state
1178        for i in $gm_state ; do
1179            t1="t2=\$$i"
1180            eval $t1
1181            echo "$i='$t2'" >> gm_state
1182        done
1183    fi

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.11.2.2

  ViewVC Help
Powered by ViewVC 1.1.22