/[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.10 by adcroft, Fri Sep 26 18:47:59 2003 UTC revision 1.11 by edhill, Mon Sep 29 16:15:23 2003 UTC
# Line 12  Line 12 
12  # Guess possible config options for this host  # Guess possible config options for this host
13  find_possible_configs()  {  find_possible_configs()  {
14    
15      p_PLATFORM=`uname`"-"`uname -m`      tmp1=`uname`"_"`uname -m`
16      echo "The platform appears to be:"      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
17      echo "  "$p_PLATFORM      PLATFORM=`echo $tmp2 | sed -e 's/i[3-6]86/ia32/'`
18        OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
19      p_LN=      echo "  The platform appears to be:  $PLATFORM"
20    #     if test "x$OFLIST" = x ; then
21    #       echo "  No pre-defined options files were found matching this platform"
22    #       echo "  but examples for other platforms can be found in:"
23    #       echo "    $ROOTDIR/tools/build_options"
24    #     else
25    #       echo "  Options files (located in $ROOTDIR/tools/build_options) that"
26    #       echo "  may work with this machine are:"
27    #       for i in $OFLIST ; do
28    #           echo "    $i"
29    #       done
30    #     fi
31        
32      echo "test" > test      echo "test" > test
33      ln -s ./test link      ln -s ./test link
34      RETVAL=$?      RETVAL=$?
35      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
36          p_LN="ln -s"          LN="ln -s"
37        else
38            echo "Error: \"ln -s\" does not appear to work on this system!"
39            echo "  For help, please contact <MITgcm-support@mitgcm.org>."
40            exit 1
41      fi      fi
42      rm -f test link      rm -f test link
43    
44      p_CPP=`which cpp`      if test "x$CPP" = x ; then
45                CPP="cpp -traditional -P"
     RETVAL=$?  
     if test "x${RETVAL}" = x0 ; then  
         p_LN="ln -s"  
46      fi      fi
     rm -f test link  
47    
48      # look for possible fortran compilers      # look for possible fortran compilers
49        tmp="$MITGCM_FC $FC g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"
50      p_FC=      p_FC=
51      for c in f77 g77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 ; do      for c in $tmp ; do
52          which $c > /dev/null 2>&1          rm -f ./hello.f ./hello
53            cat >> hello.f <<EOF
54          program hello
55          do i=1,3
56            print *, 'hello world : ', i
57          enddo
58          end
59    EOF
60            $c -o hello hello.f > /dev/null 2>&1
61          RETVAL=$?          RETVAL=$?
62          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
63              p_FC="$p_FC $c"              p_FC="$p_FC $c"
64          fi          fi
65      done      done
     echo "Possible FORTRAN compilers appear to be:  "  
66      if test "x${p_FC}" = x ; then      if test "x${p_FC}" = x ; then
67          echo "  None found!!!"          cat 1>&2 <<EOF
68    
69    Error: No Fortran compilers were found in your path.  Please specify one using:
70    
71        1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
72        2) a command-line option (eg. "-fc NAME"), or
73        3) the MITGCM_FC environment variable.
74    
75    EOF
76            exit 1
77      else      else
78          echo "  "$p_FC          echo "  The possible FORTRAN compilers found in your path are:"
79            echo "   "$p_FC
80            if test "x$FC" = x ; then
81                FC=`echo $p_FC | awk '{print $1}'`
82            fi
83      fi      fi
84    
85      # look for possible MPI libraries      for i in $p_FC ; do
86      mpi_libs=          p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
87      mpi_fort=`which mpif77 2>/dev/null`          if test -r $p_OF ; then
88      RETVAL=$?              OPTFILE=$p_OF
89      if test "x${RETVAL}" = x0 ; then              echo "  The options file:  $p_OF"
90          cat >>test.f <<EOF              echo "    appears to match so we'll use it."
91        PROGRAM HELLO              break
       DO 10, I=1,10  
       PRINT *,'Hello World'  
    10 CONTINUE  
       STOP  
       END  
 EOF  
         eval "$mpi_fort -showme test.f > out"  
         RETVAL=$?  
         if test "x${RETVAL}" = x0 ; then  
             a=`cat out`  
             for i in $a ; do  
                 case $i in  
                     -*)  
                         mpi_libs="$mpi_libs $i" ;;  
                 esac  
             done  
             echo "The MPI libs appear to be:"  
             echo "  "$mpi_libs  
92          fi          fi
93          rm -f test.f out      done
94        if test "x$OPTFILE" = x ; then
95            cat 1>&2 <<EOF
96    
97    Error: No options file was found in:  $ROOTDIR/tools/build_options/
98      that matches this platform ("$PLATFORM") and the compilers found in
99      your path.  Please specify an "optfile" using:
100    
101        1) the command line (eg. "-optfile=path/to/OPTFILE"), or
102        2) the MITGCM_OF environment variable.
103    
104      If you need help, please contact the developers at <MITgcm-support@mitgcm.org>.
105    
106    EOF
107            exit 1
108      fi      fi
109        
110    #     # look for possible MPI libraries
111    #     mpi_libs=
112    #     mpi_fort=`which mpif77 2>/dev/null`
113    #     RETVAL=$?
114    #     if test "x${RETVAL}" = x0 ; then
115    #       cat >>test.f <<EOF
116    #       PROGRAM HELLO
117    #       DO 10, I=1,10
118    #       PRINT *,'Hello World'
119    #    10 CONTINUE
120    #       STOP
121    #       END
122    # EOF
123    #       eval "$mpi_fort -showme test.f > out"
124    #       RETVAL=$?
125    #       if test "x${RETVAL}" = x0 ; then
126    #           a=`cat out`
127    #           for i in $a ; do
128    #               case $i in
129    #                   -*)
130    #                       mpi_libs="$mpi_libs $i" ;;
131    #               esac
132    #           done
133    #           echo "The MPI libs appear to be:"
134    #           echo "  "$mpi_libs
135    #       fi
136    #       rm -f test.f out
137    #     fi
138    
139  }  }
140    
# Line 172  S64= Line 230  S64=
230  KPP=  KPP=
231  FC=  FC=
232  LINK=  LINK=
233    DEFINES="-DWORDLENGTH=4"
234  PACKAGES=  PACKAGES=
235  ENABLE=  ENABLE=
236  DISABLE=  DISABLE=
237  MAKEFILE=  MAKEFILE=
238  MAKEDEPEND=  MAKEDEPEND=
239  PDEPEND=  PDEPEND=
240  DUMPSTATE=f  DUMPSTATE=t
241  PDEFAULT=  PDEFAULT=
242  OPTFILE=  OPTFILE=
243  INCLUDES="-I."  INCLUDES="-I."
# Line 361  for ac_option ; do Line 420  for ac_option ; do
420            
421  done  done
422    
423    if test "x${ROOTDIR}" = x ; then
424        if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
425            ROOTDIR=".."
426        else
427            for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
428                if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then
429                    ROOTDIR=$d
430                    echo -n "Warning:  ROOTDIR was not specified but there appears to be"
431                    echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."
432                    break
433                fi
434            done
435        fi
436    fi
437    if test "x${ROOTDIR}" = x ; then
438        echo "Error: Cannot determine ROOTDIR for MITgcm code."
439        echo "  Please specify a ROOTDIR using either an options "
440        echo "  file or a command-line option."
441        exit 1
442    fi
443    if test ! -d ${ROOTDIR} ; then
444        echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!"
445        exit 1
446    fi
447    
448  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
449  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
450      echo "Warning: no OPTFILE specified so we'll look for possible settings"      if test "x$MITGCM_OF" = x ; then
451      printf "\n===  Searching for possible settings for OPTFILE  ===\n"          echo "Warning: no OPTFILE specified so we'll look for possible settings"
452      find_possible_configs          printf "\n===  Searching for possible settings for OPTFILE  ===\n"
453  else          find_possible_configs
     if test "x$OPTFILE" = xNONE ; then  
         echo "    OPTFILE=NONE so we'll try to use default settings"  
454      else      else
455          if test -f "$OPTFILE" -a -r "$OPTFILE" ; then          OPTFILE=$MITGCM_OF
456              echo "    using OPTFILE=\"$OPTFILE\""      fi
457              source "$OPTFILE"  fi
458              RETVAL=$?  if test "x$OPTFILE" != xNONE ; then
459              if test "x$RETVAL" != x0 ; then      if test -f "$OPTFILE" -a -r "$OPTFILE" ; then
460                  echo -n "Error: failed to source OPTFILE \"$OPTFILE\""          echo "    using OPTFILE=\"$OPTFILE\""
461                  echo "--please check that variable syntax is bash-compatible"          source "$OPTFILE"
462                  exit 1          RETVAL=$?
463              fi          if test "x$RETVAL" != x0 ; then
464              if test "x$DUMPSTATE" != xf ; then              echo -n "Error: failed to source OPTFILE \"$OPTFILE\""
465                  cp -f $OPTFILE "gm_optfile"              echo "--please check that variable syntax is bash-compatible"
             fi  
         else  
             echo "Error: can't read OPTFILE=\"$OPTFILE\""  
466              exit 1              exit 1
467          fi          fi
468            if test "x$DUMPSTATE" != xf ; then
469                cp -f $OPTFILE "gm_optfile"
470            fi
471        else
472            echo "Error: can't read OPTFILE=\"$OPTFILE\""
473            exit 1
474      fi      fi
475  fi  fi
476    
# Line 405  if test "x$LINK" = x ; then Line 490  if test "x$LINK" = x ; then
490      LINK=$FC      LINK=$FC
491  fi  fi
492  if test "x$CPP" = x ; then  if test "x$CPP" = x ; then
493        CPP="cpp"
494    fi
495    echo "#define A a" | cpp > test_cpp 2>&1
496    RETVAL=$?
497    if test "x$RETVAL" != x0 ; then
498      cat <<EOF 1>&2      cat <<EOF 1>&2
499    
500  Error: no C pre-processor: please specify using one of the following:  Error: C pre-processor "$CPP" failed the test case: please specify using:
501    
502    1) within the options file ("CPP=...") as specified by "-of=OPTFILE"    1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
503    2) the "./gm_local" file    2) the "./gm_local" file
 EOF  
     exit 1  
 fi  
 if test "x$S64" = x ; then  
     cat <<EOF 1>&2  
504    
 Error: no C pre-processor: please specify using one of the following:  
   1) within the options file ("S64=...") as specified by "-of=OPTFILE"  
   2) the "./gm_local" file  
505  EOF  EOF
506      exit 1      exit 1
507    else
508        rm -f test_cpp
509    fi
510    if test "x$MAKEDEPEND" = x ; then
511        MAKEDEPEND=makedepend
512  fi  fi
   
513    
514  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
515  echo -n "  Adding MODS directories:  "  echo -n "  Adding MODS directories:  "
# Line 446  if test "x${PLATFORM}" = x ; then Line 533  if test "x${PLATFORM}" = x ; then
533      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
534  fi  fi
535    
 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  
   
536  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
537      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then
538          EXEDIR=../exe          EXEDIR=../exe
# Line 490  if test ! -d ${TOOLSDIR} ; then Line 552  if test ! -d ${TOOLSDIR} ; then
552      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"
553      exit 1      exit 1
554  fi  fi
555    if test "x$S64" = x ; then
556        S64='$(TOOLSDIR)/set64bitConst.sh'
557    fi
558    
559  EXECUTABLE=${EXECUTABLE:-mitgcmuv}  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
560    
# Line 698  done Line 763  done
763    
764  echo "  Searching for CPP_OPTIONS.h (macros and flags for configuring the model):"  echo "  Searching for CPP_OPTIONS.h (macros and flags for configuring the model):"
765  CPP_OPTIONS=  CPP_OPTIONS=
766  spaths="$MODS ./ $SOURCEDIRS"  spaths=". $SOURCEDIRS"
767  for i in $spaths ; do  for i in $spaths ; do
768      try="$i/CPP_OPTIONS.h"      try="$i/CPP_OPTIONS.h"
769      #  echo -n "    trying $try : "      #  echo -n "    trying $try : "
# Line 725  if test -e CPP_OPTIONS.h ; then Line 790  if test -e CPP_OPTIONS.h ; then
790  fi  fi
791  cat <<EOF >>CPP_OPTIONS.h.tmp  cat <<EOF >>CPP_OPTIONS.h.tmp
792  C=== GENMAKE v2 ===  C=== GENMAKE v2 ===
793  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
794  C  them only if you know what you're doing.  In general, you should  C  edit anything below these comments.  In general, you should
795  C  add or remove packages by re-running genmake with different  C  add or remove packages by re-running genmake with different
796  C  "-enable" and/or "-disable" options.  C  "-enable" and/or "-disable" options.
797    

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.22