/[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.76 by edhill, Thu Apr 8 21:32:11 2004 UTC revision 1.84 by edhill, Mon Jul 12 15:49:08 2004 UTC
# Line 1  Line 1 
1  #! /usr/bin/env bash  #! /usr/bin/env sh
2  #  #
3  # $Header$  # $Header$
4  #  #
# Line 97  EOF Line 97  EOF
97      RETVAL=$?      RETVAL=$?
98      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
99          if test "x$FS" = x ; then          if test "x$FS" = x ; then
100              FS='fs'              FS='for'
101              FS90='fs90'              FS90='fr9'
102              check_for_broken_Ff              check_for_broken_Ff
103          else          else
104              cat <<EOF 2>&1              cat <<EOF 2>&1
# Line 124  EOF Line 124  EOF
124  EOF  EOF
125      test -e Makefile  &&  mv -f Makefile Makefile.bak      test -e Makefile  &&  mv -f Makefile Makefile.bak
126      cat <<EOF >> Makefile      cat <<EOF >> Makefile
127    %.$tfs : %.F
128  .SUFFIXES:  .SUFFIXES:
129  genmake_hello.$tfs: genmake_hello.F  genmake_hello.$tfs: genmake_hello.F
130          $LN genmake_hello.F genmake_hello.$tfs          $LN genmake_hello.F genmake_hello.$tfs
# Line 132  EOF Line 133  EOF
133      RETVAL=$?      RETVAL=$?
134      if test "x$RETVAL" != x0 -o ! -e "genmake_hello."$tfs ; then      if test "x$RETVAL" != x0 -o ! -e "genmake_hello."$tfs ; then
135          if test "x$FS" = x ; then          if test "x$FS" = x ; then
136              FS='fs'              FS='for'
137              FS90='fs9'              FS90='fr9'
138              check_for_broken_Ff              check_for_broken_Ff
139          else          else
140              cat <<EOF 2>&1              cat <<EOF 2>&1
# Line 157  EOF Line 158  EOF
158  }  }
159    
160    
161  # Guess possible config options for this host  look_for_makedepend()  {
 find_possible_configs()  {  
   
     tmp1=`uname`"_"`uname -m`  
     tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`  
     tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`  
     tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`  
     tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`  
     tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`  
     PLATFORM=$tmp3  
     OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`  
     echo "  The platform appears to be:  $PLATFORM"  
       
     echo "test" > test  
     ln -s ./test link  
     RETVAL=$?  
     if test "x${RETVAL}" = x0 ; then  
         LN="ln -s"  
     else  
         echo "Error: \"ln -s\" does not appear to work on this system!"  
         echo "  For help, please contact <MITgcm-support@mitgcm.org>."  
         exit 1  
     fi  
     rm -f test link  
   
     if test "x$CPP" = x ; then  
         CPP="cpp -traditional -P"  
     fi  
162    
163      #  The "original" makedepend is part of the Imake system that is      #  The "original" makedepend is part of the Imake system that is
164      #  most often distributed with XFree86 or with an XFree86 source      #  most often distributed with XFree86 or with an XFree86 source
# Line 206  find_possible_configs()  { Line 180  find_possible_configs()  {
180      #      #
181      if test "x${MAKEDEPEND}" = x ; then      if test "x${MAKEDEPEND}" = x ; then
182        which makedepend > /dev/null 2>&1        which makedepend > /dev/null 2>&1
183        RETVAL=$?        RV0=$?
184        if test ! "x${RETVAL}" = x0 ; then        cat <<EOF >> genmake_tc.f
185          program test
186          write(*,*) 'test'
187          stop
188          end
189    EOF
190          makedepend genmake_tc.f > /dev/null 2>&1
191          RV1=$?
192          if test ! "x${RV0}${RV1}" = x00 ; then
193           echo "    a system-default makedepend was not found."           echo "    a system-default makedepend was not found."
194    
195           #  Try to build the cyrus impl           #  Try to build the cyrus impl
# Line 215  find_possible_configs()  { Line 197  find_possible_configs()  {
197           (           (
198               cd $ROOTDIR/tools/cyrus-imapd-makedepend  \               cd $ROOTDIR/tools/cyrus-imapd-makedepend  \
199                   &&  ./configure > /dev/null 2>&1  \                   &&  ./configure > /dev/null 2>&1  \
200                   &&  make > /dev/null 2>&1  \                   &&  make > /dev/null 2>&1
201                   &&  ./makedepend ifparser.c > /dev/null 2>&1  \               if test -x ./makedepend.exe ; then
202                     $LN ./makedepend.exe ./makedepend
203                 fi
204                 ./makedepend ifparser.c > /dev/null 2>&1  \
205                   &&  echo "true"                   &&  echo "true"
206           ) > ./genmake_cy_md           ) > ./genmake_cy_md
207           grep true ./genmake_cy_md > /dev/null 2>&1           grep true ./genmake_cy_md > /dev/null 2>&1
# Line 229  find_possible_configs()  { Line 214  find_possible_configs()  {
214           rm -f ./genmake_cy_md           rm -f ./genmake_cy_md
215        fi        fi
216      fi      fi
217    }
218    
219    
220    # Guess possible config options for this host
221    find_possible_configs()  {
222    
223        tmp1=`uname`"_"`uname -m`
224        tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
225        tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
226        tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
227        tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
228        tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
229        PLATFORM=$tmp3
230        echo $PLATFORM | grep cygwin > /dev/null 2>&1  &&  PLATFORM=cygwin_ia32
231        OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
232        echo "  The platform appears to be:  $PLATFORM"
233        
234        echo "test" > test
235        ln -s ./test link
236        RETVAL=$?
237        if test "x${RETVAL}" = x0 ; then
238            LN="ln -s"
239        else
240            echo "Error: \"ln -s\" does not appear to work on this system!"
241            echo "  For help, please contact <MITgcm-support@mitgcm.org>."
242            exit 1
243        fi
244        rm -f test link
245    
246        if test "x$CPP" = x ; then
247            CPP="cpp -traditional -P"
248        fi
249    
250        look_for_makedepend
251    
252      # look for possible fortran compilers      # look for possible fortran compilers
253      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"
# Line 358  Usage: "$0" [OPTIONS] Line 377  Usage: "$0" [OPTIONS]
377      -help | --help | -h | --h      -help | --help | -h | --h
378            Print this help message and exit.            Print this help message and exit.
379    
380        -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME
381          -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME
382              Use "NAME" as the adoptfile.  By default, the file at
383              "tools/adjoint_options/adjoint_default" will be used.
384    
385      -nooptfile | --nooptfile      -nooptfile | --nooptfile
386        -optfile NAME | --optfile NAME | -of NAME | --of NAME        -optfile NAME | --optfile NAME | -of NAME | --of NAME
387        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
# Line 664  HAVE_FDATE= Line 688  HAVE_FDATE=
688  FC_NAMEMANGLE=  FC_NAMEMANGLE=
689  HAVE_CLOC=  HAVE_CLOC=
690  HAVE_NETCDF=  HAVE_NETCDF=
691    HAVE_ETIME=
692    
693  MODS=  MODS=
694  TOOLSDIR=  TOOLSDIR=
# Line 714  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPE Line 739  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPE
739  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
740  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"
741  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
742  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE"  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"
743    
744  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
745  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
# Line 987  if test "x$OPTFILE" != xNONE ; then Line 1012  if test "x$OPTFILE" != xNONE ; then
1012  fi  fi
1013    
1014  #  Check for broken systems that cannot correctly distinguish *.F and *.f files  #  Check for broken systems that cannot correctly distinguish *.F and *.f files
1015  check_for_broken_Ff  # check_for_broken_Ff
1016    
1017  echo "  getting AD_OPTFILE information:  "  echo "  getting AD_OPTFILE information:  "
1018  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
# Line 1066  EOF Line 1091  EOF
1091  else  else
1092      rm -f test_cpp      rm -f test_cpp
1093  fi  fi
1094  if test "x$MAKEDEPEND" = x ; then  look_for_makedepend
     MAKEDEPEND=makedepend  
 fi  
1095  if test "x$LN" = x ; then  if test "x$LN" = x ; then
1096      LN="ln -s"      LN="ln -s"
1097  fi  fi
# Line 1086  EOF Line 1109  EOF
1109  fi  fi
1110  rm -f genmake_test_ln genmake_tlink  rm -f genmake_test_ln genmake_tlink
1111    
1112    #  Check for broken *.F/*.f handling and fix if possible
1113    check_for_broken_Ff
1114    
1115  if test ! "x$MPI" = x ; then  if test ! "x$MPI" = x ; then
1116        echo "  Turning on MPI cpp macros"        echo "  Turning on MPI cpp macros"
1117        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
# Line 1131  else Line 1157  else
1157  fi  fi
1158  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1159    
1160    printf "  Do we have the etime() command using $FC...  "
1161    cat > genmake_tcomp.f <<EOF
1162          program hello
1163          REAL*4 ACTUAL, TARRAY(2)
1164          EXTERNAL ETIME
1165          REAL*4 ETIME
1166          actual = etime( tarray )
1167          print *, tarray
1168          end
1169    EOF
1170    $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1
1171    RETVAL=$?
1172    if test "x$RETVAL" = x0 ; then
1173        HAVE_ETIME=t
1174        DEFINES="$DEFINES -DHAVE_ETIME"
1175        echo "yes"
1176    else
1177        HAVE_ETIME=
1178        echo "no"
1179    fi
1180    rm -f genmake_tcomp*
1181    
1182  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
1183  check_HAVE_CLOC  check_HAVE_CLOC
1184  if test "x$HAVE_CLOC" != x ; then  if test "x$HAVE_CLOC" != x ; then
# Line 1753  echo 'F90FILES =  $(F90SRCFILES:.F=.'$FS Line 1801  echo 'F90FILES =  $(F90SRCFILES:.F=.'$FS
1801  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
1802  echo >> $MAKEFILE  echo >> $MAKEFILE
1803  echo '.SUFFIXES:' >> $MAKEFILE  echo '.SUFFIXES:' >> $MAKEFILE
1804  echo '.SUFFIXES: .o .F .p .'$FS' .c .F90 .'$FS90 >> $MAKEFILE  echo '.SUFFIXES: .o .'$FS' .p .F .c .'$FS90' .F90' >> $MAKEFILE
1805  rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc  rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc
1806  rm -f ad_flow_files.inc  rm -f ad_flow_files.inc
1807    
# Line 1789  CLEAN: Line 1837  CLEAN:
1837          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
1838          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
1839          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
1840          -rm -f \$(EXECUTABLE) output.txt          -rm -f \$(EXECUTABLE) output.txt STD*
1841    
1842  #eh3 Makefile: makefile  #eh3 Makefile: makefile
1843  makefile:  makefile:

Legend:
Removed from v.1.76  
changed lines
  Added in v.1.84

  ViewVC Help
Powered by ViewVC 1.1.22