/[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.4 by edhill, Tue Aug 26 16:22:15 2003 UTC revision 1.8 by edhill, Tue Sep 23 15:53:02 2003 UTC
# Line 80  EOF Line 80  EOF
80    
81  }  }
82    
 parse_options()  {  
   
     ac_prev=  
     for ac_option in "${OPTIONS[@]}" ; do  
   
         # 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  
 }  
   
83  #  Parse the package dependency information  #  Parse the package dependency information
84  get_pdepend_list()  {  get_pdepend_list()  {
85    
# Line 222  usage()  { Line 109  usage()  {
109      echo "      -pdepend=NAME | --pdepend=NAME"      echo "      -pdepend=NAME | --pdepend=NAME"
110      echo "    -pdefault NAME | --pdefault NAME"      echo "    -pdefault NAME | --pdefault NAME"
111      echo "      -pdefault=NAME | --pdefault=NAME"      echo "      -pdefault=NAME | --pdefault=NAME"
112      echo "    -makefile NAME | -ma NAME"      echo "    -make NAME | -m NAME"
113      echo "      --makefile=NAME | -ma=NAME"      echo "      --make=NAME | -m=NAME"
114        echo "    -makefile NAME | -mf NAME"
115        echo "      --makefile=NAME | -mf=NAME"
116      echo "    -platform NAME | --platform NAME | -pl NAME | --pl NAME"      echo "    -platform NAME | --platform NAME | -pl NAME | --pl NAME"
117      echo "      -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME"      echo "      -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME"
118      echo "    -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME"      echo "    -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME"
# Line 255  usage()  { Line 144  usage()  {
144      exit 1      exit 1
145  }  }
146    
 # 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  
 }  
   
   
147  #eh3 # This is the generic configuration.  #eh3 # This is the generic configuration.
148  #eh3 set LN         = ( 'ln -s' )  #eh3 set LN         = ( 'ln -s' )
149  #eh3 set CPP        = ( '/lib/cpp -P' )  #eh3 set CPP        = ( '/lib/cpp -P' )
# Line 288  dump_state()  { Line 164  dump_state()  {
164  #eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = (  )  #eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = (  )
165    
166  #  Set defaults here  #  Set defaults here
167    COMMANDL="$0 $@"
168    
169  PLATFORM=  PLATFORM=
170  LN=  LN=
171  S64=  S64=
# Line 300  DISABLE= Line 178  DISABLE=
178  MAKEFILE=  MAKEFILE=
179  MAKEDEPEND=  MAKEDEPEND=
180  PDEPEND=  PDEPEND=
181    DUMPSTATE=f
182  PDEFAULT=  PDEFAULT=
183  OPTFILE=  OPTFILE=
184  INCLUDES="-I."  INCLUDES="-I."
# Line 324  THISHOSTNAME=`hostname` Line 203  THISHOSTNAME=`hostname`
203  THISCWD=`pwd`  THISCWD=`pwd`
204  THISDATE=`date`  THISDATE=`date`
205  MACHINE=`uname -a`  MACHINE=`uname -a`
206    EXECUTABLE=
207    EXEHOOK=
208    EXEDIR=
209    
210    #  The following state can be set directly by command-line switches
211    gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"
212    gm_s2="FC IEEE MPI JAM DUMPSTATE"
213    
214    #  The following state is not directly set by command-line switches
215    gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "
216    gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
217    gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"
218    gm_s6="EXECUTABLE EXEHOOK EXEDIR"
219    
220    gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6"
221    
222    
223  echo  echo
224  echo "===  Processing options files and arguments  ==="  echo "===  Processing options files and arguments  ==="
# Line 384  for ac_option ; do Line 279  for ac_option ; do
279          -pdefault=* | --pdefault=*)          -pdefault=* | --pdefault=*)
280              PDEFAULT=$ac_optarg ;;              PDEFAULT=$ac_optarg ;;
281                    
282          -makefile | -ma)          -make | --make | -m | --m)
283                ac_prev=MAKE ;;
284            -make=* | --make=* | -m=* | --m=*)
285                MAKE=$ac_optarg ;;
286            
287            -makefile | --makefile | -ma | --ma)
288              ac_prev=MAKEFILE ;;              ac_prev=MAKEFILE ;;
289          --makefile=* | -ma=*)          -makefile=* | --makefile=* | -ma=* | --ma=*)
290              MAKEFILE=$ac_optarg ;;              MAKEFILE=$ac_optarg ;;
291                    
292          -platform | --platform | -pl | --pl)          -platform | --platform | -pl | --pl)
# Line 444  for ac_option ; do Line 344  for ac_option ; do
344          -nojam | --nojam)          -nojam | --nojam)
345              JAM=0 ;;              JAM=0 ;;
346                    
347            -ds | --ds)
348                DUMPSTATE=t ;;
349            
350          -*)          -*)
351              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
352              usage              usage
# Line 476  else Line 379  else
379                  echo "--please check that variable syntax is bash-compatible"                  echo "--please check that variable syntax is bash-compatible"
380                  exit 1                  exit 1
381              fi              fi
382                if test "x$DUMPSTATE" != xf ; then
383                    cp -f $OPTFILE "gm_optfile"
384                fi
385          else          else
386              echo "Error: can't read OPTFILE=\"$OPTFILE\""              echo "Error: can't read OPTFILE=\"$OPTFILE\""
387              exit 1              exit 1
# Line 483  else Line 389  else
389      fi      fi
390  fi  fi
391    
392    #  Check that FC, LINK, CPP, and S64 are defined.  If not, complain
393    #  and abort!
394    if test "x$FC" = x ; then
395        cat <<EOF 1>&2
396    
397    Error: no Fortran compiler: please specify using one of the following:
398      1) within the options file ("FC=...") as specified by "-of=OPTFILE"
399      2) the "-fc=XXX" command-line option
400      3) the "./gm_local" file
401    EOF
402        exit 1
403    fi
404    if test "x$LINK" = x ; then
405        LINK=$FC
406    fi
407    if test "x$CPP" = x ; then
408        cat <<EOF 1>&2
409    
410    Error: no C pre-processor: please specify using one of the following:
411      1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
412      2) the "./gm_local" file
413    EOF
414        exit 1
415    fi
416    if test "x$S64" = x ; then
417        cat <<EOF 1>&2
418    
419    Error: no C pre-processor: please specify using one of the following:
420      1) within the options file ("S64=...") as specified by "-of=OPTFILE"
421      2) the "./gm_local" file
422    EOF
423        exit 1
424    fi
425    
426    
427  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
428  echo -n "  Adding MODS directories:  "  echo -n "  Adding MODS directories:  "
429  for d in $MODS ; do  for d in $MODS ; do
# Line 1043  all: \$(EXECUTABLE) Line 984  all: \$(EXECUTABLE)
984  depend:  depend:
985          @make links          @make links
986          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
987          ../../../tools/f90mkdepend >> \$(MAKEFILE)          ${TOOLSDIR}/f90mkdepend >> \$(MAKEFILE)
988    
989  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES)  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES)
990    
# Line 1091  cleanlinks: Line 1032  cleanlinks:
1032    
1033  EOF  EOF
1034    
1035    if test "x$EXEHOOK" != x ; then
1036        printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE
1037    fi
1038    
1039  echo "  Making list of \"exceptions\" that need \".p\" files"  echo "  Making list of \"exceptions\" that need \".p\" files"
1040  for i in $KPPFILES ; do  for i in $KPPFILES ; do
1041      base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`      base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`
# Line 1120  echo "  Adding makedepend marker" Line 1065  echo "  Adding makedepend marker"
1065  printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE  printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE
1066    
1067  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
1068    
1069    
1070    #  Write the "state" for future records
1071    if test "x$DUMPSTATE" != xf ; then
1072        echo -n "" > gm_state
1073        for i in $gm_state ; do
1074            t1="t2=\$$i"
1075            eval $t1
1076            echo "$i='$t2'" >> gm_state
1077        done
1078    fi

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.22