/[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.66 by edhill, Mon Feb 23 21:51:32 2004 UTC revision 1.76 by edhill, Thu Apr 8 21:32:11 2004 UTC
# Line 37  test_for_string_in_file() { Line 37  test_for_string_in_file() {
37      grep -i "$strng" $file > /dev/null 2>&1      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 -n "Error: In $file there is an illegal line: "          printf "Error: In $file there is an illegal line: "
41          grep -i "$strng" $file          grep -i "$strng" $file
42          return 1          return 1
43      fi      fi
# Line 67  expand_pkg_groups() { Line 67  expand_pkg_groups() {
67          done          done
68          PACKAGES=$new_packages          PACKAGES=$new_packages
69          rm -f ./p[1,2].tmp          rm -f ./p[1,2].tmp
70            return $matched
71      else      else
72          echo "Warning: can't read package groups definition file: $PKG_GROUPS"          echo "Warning: can't read package groups definition file: $PKG_GROUPS"
73      fi      fi
74  }  }
75    
76    #  Check for broken environments (eg. cygwin, MacOSX w/HFS+) that
77    #  cannot distinguish [*.F/*.F90] from [*.f/*.f90] files.
78    check_for_broken_Ff()  {
79        #  Do we have defaults for $FS and/or $FS90 ?
80        tfs=f
81        tfs9=f90
82        if test "x$FS" != x ; then
83            tfs="$FS"
84        fi
85        if test "x$FS90" != x ; then
86            tfs9="$FS90"
87        fi
88    
89        #  First check the ability to create a *.F/.f pair.
90        cat <<EOF >> genmake_hello.F
91          program hello
92          write(*,*) 'hi'
93          stop
94          end
95    EOF
96        cp genmake_hello.F "genmake_hello."$tfs > /dev/null 2>&1
97        RETVAL=$?
98        if test "x$RETVAL" != x0 ; then
99            if test "x$FS" = x ; then
100                FS='fs'
101                FS90='fs90'
102                check_for_broken_Ff
103            else
104                cat <<EOF 2>&1
105    ERROR: Your file system cannot distinguish between *.F and *.f files
106      (fails the "cp" test) and this program cannot find a suitable
107      replacement extension.  Please try a different build environment or
108      contact the <MITgcm-support@mitgcm.org> list for help.
109    
110    EOF
111                exit -1
112            fi
113            return
114        fi
115        rm -f genmake_hello.*
116    
117        #  Check the ability of ${MAKE} and ${LN} to use the current set
118        #  of extensions.
119        cat <<EOF >> genmake_hello.F
120          program hello
121          write(*,*) 'hi'
122          stop
123          end
124    EOF
125        test -e Makefile  &&  mv -f Makefile Makefile.bak
126        cat <<EOF >> Makefile
127    .SUFFIXES:
128    genmake_hello.$tfs: genmake_hello.F
129            $LN genmake_hello.F genmake_hello.$tfs
130    EOF
131        $MAKE "genmake_hello."$tfs > /dev/null 2>&1
132        RETVAL=$?
133        if test "x$RETVAL" != x0 -o ! -e "genmake_hello."$tfs ; then
134            if test "x$FS" = x ; then
135                FS='fs'
136                FS90='fs9'
137                check_for_broken_Ff
138            else
139                cat <<EOF 2>&1
140    ERROR: Your file system cannot distinguish between *.F and *.f files
141      (fails the "make/ln" test) and this program cannot find a suitable
142      replacement extension.  Please try a different build environment or
143      contact the <MITgcm-support@mitgcm.org> list for help.
144    
145    EOF
146                exit -1
147                return
148            fi
149        fi
150        rm -f genmake_hello.* Makefile
151        test -e Makefile  &&  mv -f Makefile.bak Makefile
152    
153        #  If we make it here, use the extensions
154        FS=$tfs
155        FS90=$tfs9
156        return
157    }
158    
159    
160  # Guess possible config options for this host  # Guess possible config options for this host
161  find_possible_configs()  {  find_possible_configs()  {
162    
# Line 80  find_possible_configs()  { Line 165  find_possible_configs()  {
165      tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`      tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
166      tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`      tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
167      tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`      tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
168      PLATFORM=$tmp2      tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
169        PLATFORM=$tmp3
170      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
171      echo "  The platform appears to be:  $PLATFORM"      echo "  The platform appears to be:  $PLATFORM"
172            
# Line 100  find_possible_configs()  { Line 186  find_possible_configs()  {
186          CPP="cpp -traditional -P"          CPP="cpp -traditional -P"
187      fi      fi
188    
189      # makedepend is not always available      #  The "original" makedepend is part of the Imake system that is
190        #  most often distributed with XFree86 or with an XFree86 source
191        #  package.  As a result, many machines (eg. generic Linux) do not
192        #  have a system-default "makedepend" available.  For those
193        #  systems, we have two fall-back options:
194        #
195        #    1) a makedepend implementation shipped with the cyrus-imapd
196        #       package:  ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
197        #
198        #    2) a known-buggy xmakedpend shell script
199        #
200        #  So the choices are, in order:
201        #
202        #    1) use the user-specified program
203        #    2) use a system-wide default
204        #    3) locally build and use the cyrus implementation
205        #    4) fall back to the buggy local xmakedpend script
206        #
207      if test "x${MAKEDEPEND}" = x ; then      if test "x${MAKEDEPEND}" = x ; then
208        which makedepend >& /dev/null        which makedepend > /dev/null 2>&1
209        RETVAL=$?        RETVAL=$?
210        if test "x${RETVAL}" = x1 ; then        if test ! "x${RETVAL}" = x0 ; then
211           echo "    makedepend was not found. Using xmakedpend instead."           echo "    a system-default makedepend was not found."
212           MAKEDEPEND='$(TOOLSDIR)/xmakedepend'  
213             #  Try to build the cyrus impl
214             rm -f ./genmake_cy_md
215             (
216                 cd $ROOTDIR/tools/cyrus-imapd-makedepend  \
217                     &&  ./configure > /dev/null 2>&1  \
218                     &&  make > /dev/null 2>&1  \
219                     &&  ./makedepend ifparser.c > /dev/null 2>&1  \
220                     &&  echo "true"
221             ) > ./genmake_cy_md
222             grep true ./genmake_cy_md > /dev/null 2>&1
223             RETVAL=$?
224             if test "x$RETVAL" = x0 ; then
225                 MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
226             else
227                 MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
228             fi
229             rm -f ./genmake_cy_md
230        fi        fi
231      fi      fi
232    
# Line 145  EOF Line 265  EOF
265          echo "   "$p_FC          echo "   "$p_FC
266          if test "x$FC" = x ; then          if test "x$FC" = x ; then
267              FC=`echo $p_FC | $AWK '{print $1}'`              FC=`echo $p_FC | $AWK '{print $1}'`
268                echo "  Setting FORTRAN compiler to: "$FC
269          fi          fi
270      fi      fi
271    
272      for i in $p_FC ; do      if test "x$OPTFILE" = x ; then
273          p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i          OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
274          if test -r $p_OF ; then          if test ! -r $OPTFILE ; then
275              OPTFILE=$p_OF               echo "  I looked for the file "$OPTFILE" but did not find it"
276              echo "  The options file:  $p_OF"          fi
277              echo "    appears to match so we'll use it."      fi
278              break  #    echo "  The options file:  $p_OF"
279          fi  #    echo "    appears to match so we'll use it."
280      done  #   for i in $p_FC ; do
281    #p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
282    #if test -r $p_OF ; then
283    #    OPTFILE=$p_OF
284    #    echo "  The options file:  $p_OF"
285    #    echo "    appears to match so we'll use it."
286    #    break
287    #fi
288    #   done
289      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
290          cat 1>&2 <<EOF          cat 1>&2 <<EOF
291    
# Line 215  get_pdepend_list()  { Line 344  get_pdepend_list()  {
344      . ./.pd_tmp      . ./.pd_tmp
345      rm -f ./.pd_tmp      rm -f ./.pd_tmp
346    
347      echo -n "PNAME = "${}      printf "PNAME = "${}
348  }  }
349    
350    
# Line 253  Usage: "$0" [OPTIONS] Line 382  Usage: "$0" [OPTIONS]
382        --makefile=NAME | -mf=NAME        --makefile=NAME | -mf=NAME
383            Call the makefile "NAME".  The default is "Makefile".            Call the makefile "NAME".  The default is "Makefile".
384    
385        -makedepend NAME | -md NAME
386          --makedepend=NAME | -md=NAME
387              Use "NAME" for the MAKEDEPEND program.
388    
389      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
390        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
391            Specify the location of the MITgcm ROOTDIR as "NAME".            Specify the location of the MITgcm ROOTDIR as "NAME".
# Line 294  Usage: "$0" [OPTIONS] Line 427  Usage: "$0" [OPTIONS]
427            *only* works if it is supported by the OPTFILE that            *only* works if it is supported by the OPTFILE that
428            is being used.            is being used.
429    
430        -mpi | --mpi
431              Include MPI header files and link to MPI libraries
432        -mpi=PATH | --mpi=PATH
433              Include MPI header files and link to MPI libraries using MPI_ROOT
434              set to PATH. i.e. Include files from $PATH/include, link to libraries
435              from $PATH/lib and use binaries from $PATH/bin.
436    
437        -bash NAME
438              Explicitly specify the Bourne or BASH shell to use
439    
440    While it is most often a single word, the "NAME" variables specified    While it is most often a single word, the "NAME" variables specified
441    above can in many cases be a space-delimited string such as:    above can in many cases be a space-delimited string such as:
442    
# Line 438  EOF Line 581  EOF
581    
582    
583  check_netcdf_libs()  {  check_netcdf_libs()  {
584      cat <<EOF > genmake_tnc.F      cat <<EOF > genmake_tnc.for
585        program fgennc        program fgennc
586  #include "netcdf.inc"  #include "netcdf.inc"
587        integer iret, ncid, xid        integer iret, ncid, xid
# Line 450  check_netcdf_libs()  { Line 593  check_netcdf_libs()  {
593        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
594        end        end
595  EOF  EOF
596      $CPP genmake_tnc.F > genmake_tnc.f  \      $CPP genmake_tnc.for > genmake_tnc.f  \
597          &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1          &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1
598      RET_COMPILE=$?      RET_COMPILE=$?
599      test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1      test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
# Line 459  EOF Line 602  EOF
602          HAVE_NETCDF=t          HAVE_NETCDF=t
603      else      else
604          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
605          $CPP genmake_tnc.F > genmake_tnc.f  \          $CPP genmake_tnc.for > genmake_tnc.f  \
606              &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \              &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \
607              $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1              $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1
608          RET_COMPILE=$?          RET_COMPILE=$?
# Line 476  EOF Line 619  EOF
619  }  }
620    
621    
622    
623    ###############################################################################
624    #   Sequential part of script starts here
625    ###############################################################################
626    
627  #  Set defaults here  #  Set defaults here
628  COMMANDL="$0 $@"  COMMANDL="$0 $@"
629    
# Line 486  KPP= Line 634  KPP=
634  FC=  FC=
635  CPP=  CPP=
636  LINK=  LINK=
 # DEFINES="-DWORDLENGTH=4"  
637  DEFINES=  DEFINES=
638  PACKAGES=  PACKAGES=
639  ENABLE=  ENABLE=
# Line 503  FOPTIM= Line 650  FOPTIM=
650  CFLAGS=  CFLAGS=
651  KFLAGS1=  KFLAGS1=
652  KFLAGS2=  KFLAGS2=
653    #LDADD=
654  LIBS=  LIBS=
655  KPPFILES=  KPPFILES=
656  NOOPTFILES=  NOOPTFILES=
657  NOOPTFLAGS=  NOOPTFLAGS=
658    MPI=
659    MPIPATH=
660    
661  # DEFINES checked by test compilation  # DEFINES checked by test compilation
662  HAVE_SYSTEM=  HAVE_SYSTEM=
# Line 521  SOURCEDIRS= Line 671  SOURCEDIRS=
671  INCLUDEDIRS=  INCLUDEDIRS=
672  STANDARDDIRS="USE_THE_DEFAULT"  STANDARDDIRS="USE_THE_DEFAULT"
673    
674    G2ARGS=
675    BASH=
676  PWD=`pwd`  PWD=`pwd`
677  MAKE=make  MAKE=make
678  AWK=awk  AWK=awk
# Line 536  IEEE= Line 688  IEEE=
688  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
689      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
690  fi  fi
691    FS=
692    FS90=
693    
694  AUTODIFF_PKG_USED=f  AUTODIFF_PKG_USED=f
695  AD_OPTFILE=  AD_OPTFILE=
# Line 589  for i in . $MODS ; do Line 743  for i in . $MODS ; do
743          break          break
744      fi      fi
745  done  done
746  echo -n "  getting local config information:  "  printf "  getting local config information:  "
747  if test -e $gm_local ; then  if test -e $gm_local ; then
748      echo "using $gm_local"      echo "using $gm_local"
749      . $gm_local      . $gm_local
# Line 613  fi Line 767  fi
767  ac_prev=  ac_prev=
768  for ac_option ; do  for ac_option ; do
769    
770        G2ARGS="$G2ARGS \"$ac_option\""
771    
772      # If the previous option needs an argument, assign it.      # If the previous option needs an argument, assign it.
773      if test -n "$ac_prev"; then      if test -n "$ac_prev"; then
774          eval "$ac_prev=\$ac_option"          eval "$ac_prev=\$ac_option"
# Line 654  for ac_option ; do Line 810  for ac_option ; do
810          -make=* | --make=* | -m=* | --m=*)          -make=* | --make=* | -m=* | --m=*)
811              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
812                    
813            -bash | --bash)
814                ac_prev=BASH ;;
815            -bash=* | --bash=*)
816                BASH=$ac_optarg ;;
817            
818            -makedepend | --makedepend | -md | --md)
819                ac_prev=MAKEDEPEND ;;
820            -makedepend=* | --makedepend=* | -md=* | --md=*)
821                MAKEDEPEND=$ac_optarg ;;
822            
823          -makefile | --makefile | -ma | --ma)          -makefile | --makefile | -ma | --ma)
824              ac_prev=MAKEFILE ;;              ac_prev=MAKEFILE ;;
825          -makefile=* | --makefile=* | -ma=* | --ma=*)          -makefile=* | --makefile=* | -ma=* | --ma=*)
# Line 701  for ac_option ; do Line 867  for ac_option ; do
867          -fc=* | --fc=*)          -fc=* | --fc=*)
868              FC=$ac_optarg ;;              FC=$ac_optarg ;;
869                    
870            -fs | --fs)
871                ac_prev=FS ;;
872            -fs=* | --fs=*)
873                FS=$ac_optarg ;;
874            
875            -fs90 | --fs90)
876                ac_prev=FS90 ;;
877            -fs90=* | --fs90=*)
878                FS90=$ac_optarg ;;
879            
880          -ieee | --ieee)          -ieee | --ieee)
881              IEEE=true ;;              IEEE=true ;;
882          -noieee | --noieee)          -noieee | --noieee)
883              IEEE= ;;              IEEE= ;;
884    
885            -mpi | --mpi)
886                MPI=true ;;
887            -mpi=* | --mpi=*)
888                MPIPATH=$ac_optarg
889                MPI=true ;;
890                    
891  #       -jam | --jam)  #       -jam | --jam)
892  #           JAM=1 ;;  #           JAM=1 ;;
# Line 757  if test "x${ROOTDIR}" = x ; then Line 939  if test "x${ROOTDIR}" = x ; then
939          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
940              if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then              if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then
941                  ROOTDIR=$d                  ROOTDIR=$d
942                  echo -n "Warning:  ROOTDIR was not specified but there appears to be"                  printf "Warning:  ROOTDIR was not specified but there appears to be"
943                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."
944                  break                  break
945              fi              fi
# Line 791  if test "x$OPTFILE" != xNONE ; then Line 973  if test "x$OPTFILE" != xNONE ; then
973          . "$OPTFILE"          . "$OPTFILE"
974          RETVAL=$?          RETVAL=$?
975          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
976              echo -n "Error: failed to source OPTFILE \"$OPTFILE\""              printf "Error: failed to source OPTFILE \"$OPTFILE\""
977              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
978              exit 1              exit 1
979          fi          fi
# Line 804  if test "x$OPTFILE" != xNONE ; then Line 986  if test "x$OPTFILE" != xNONE ; then
986      fi      fi
987  fi  fi
988    
989    #  Check for broken systems that cannot correctly distinguish *.F and *.f files
990    check_for_broken_Ff
991    
992  echo "  getting AD_OPTFILE information:  "  echo "  getting AD_OPTFILE information:  "
993  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
994      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" = x ; then
# Line 818  if test "x${AD_OPTFILE}" != xNONE ; then Line 1003  if test "x${AD_OPTFILE}" != xNONE ; then
1003          . "$AD_OPTFILE"          . "$AD_OPTFILE"
1004          RETVAL=$?          RETVAL=$?
1005          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
1006              echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""              printf "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""
1007              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1008              exit 1              exit 1
1009          fi          fi
# Line 833  fi Line 1018  fi
1018    
1019  #  Check that FC, LINK, CPP, S64, LN, and MAKE are defined.  If not,  #  Check that FC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
1020  #  either set defaults or complain and abort!  #  either set defaults or complain and abort!
1021    if test ! "x$BASH" = x ; then
1022        # add a trailing space so that it works within the Makefile syntax (see below)
1023        BASH="$BASH "
1024    fi
1025  if test "x$FC" = x ; then  if test "x$FC" = x ; then
1026      cat <<EOF 1>&2      cat <<EOF 1>&2
1027    
# Line 853  if test "x$CPP" = x ; then Line 1042  if test "x$CPP" = x ; then
1042      CPP=cpp      CPP=cpp
1043  fi  fi
1044  #EH3 === UGLY ===  #EH3 === UGLY ===
1045  #  The following an ugly little hack to check for $CPP in /lib/ and it  #  The following is an ugly little hack to check for $CPP in /lib/ and
1046  #  should eventually be replaced with a more general function that  #  it should eventually be replaced with a more general function that
1047  #  searches a combo of the user's path and a list of "usual suspects"  #  searches a combo of the user's path and a list of "usual suspects"
1048  #  to find the correct location for binaries such as $CPP.  #  to find the correct location for binaries such as $CPP.
1049  for i in " " "/lib/" ; do  for i in " " "/lib/" ; do
# Line 897  EOF Line 1086  EOF
1086  fi  fi
1087  rm -f genmake_test_ln genmake_tlink  rm -f genmake_test_ln genmake_tlink
1088    
1089    if test ! "x$MPI" = x ; then
1090          echo "  Turning on MPI cpp macros"
1091          DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1092    fi
1093    
1094  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1095  echo -n "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
1096  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.f <<EOF
1097        program hello        program hello
1098        call system('echo hi')        call system('echo hi')
# Line 917  else Line 1110  else
1110  fi  fi
1111  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1112    
1113  echo -n "  Do we have the fdate() command using $FC...  "  printf "  Do we have the fdate() command using $FC...  "
1114  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.f <<EOF
1115        program hello        program hello
1116        CHARACTER(128) string        CHARACTER(128) string
# Line 938  else Line 1131  else
1131  fi  fi
1132  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1133    
1134  echo -n "  Can we call simple C routines (here, \"cloc()\") using $FC...  "  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
1135  check_HAVE_CLOC  check_HAVE_CLOC
1136  if test "x$HAVE_CLOC" != x ; then  if test "x$HAVE_CLOC" != x ; then
1137      echo "yes"      echo "yes"
# Line 947  else Line 1140  else
1140  fi  fi
1141  rm -f genmake_t*  rm -f genmake_t*
1142    
1143  echo -n "  Can we create NetCDF-enabled binaries...  "  printf "  Can we create NetCDF-enabled binaries...  "
1144  check_netcdf_libs  check_netcdf_libs
1145  if test "x$HAVE_NETCDF" != x ; then  if test "x$HAVE_NETCDF" != x ; then
1146      echo "yes"      echo "yes"
# Line 957  fi Line 1150  fi
1150    
1151    
1152  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1153  echo -n "  Adding MODS directories:  "  printf "  Adding MODS directories:  "
1154  for d in $MODS ; do  for d in $MODS ; do
1155      if test ! -d $d ; then      if test ! -d $d ; then
1156          echo          echo
1157          echo "Error: MODS directory \"$d\" not found!"          echo "Error: MODS directory \"$d\" not found!"
1158          exit 1          exit 1
1159      else      else
1160          echo -n " $d"          printf " $d"
1161          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
1162          INCLUDEDIRS="$INCLUDEDIRS $d"          INCLUDEDIRS="$INCLUDEDIRS $d"
1163      fi      fi
# Line 1089  else Line 1282  else
1282          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
1283          RETVAL=$?          RETVAL=$?
1284          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
1285              echo -n "Error: can't parse default package list "              printf "Error: can't parse default package list "
1286              echo "-- please check PDEFAULT=\"$PDEFAULT\""              echo "-- please check PDEFAULT=\"$PDEFAULT\""
1287              exit 1              exit 1
1288          fi          fi
# Line 1097  else Line 1290  else
1290              PACKAGES="$PACKAGES $i"              PACKAGES="$PACKAGES $i"
1291          done          done
1292          echo "    before group expansion packages are: $PACKAGES"          echo "    before group expansion packages are: $PACKAGES"
1293          expand_pkg_groups          while ! expand_pkg_groups; do echo > /dev/null; done
1294          echo "    after group expansion packages are:  $PACKAGES"          echo "    after group expansion packages are:  $PACKAGES"
1295      fi      fi
1296  fi  fi
1297    
1298  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
1299    for i in $PACKAGES ; do
1300        echo $i >> ./.tmp_pack
1301    done
1302    for i in `grep  "-" ./.tmp_pack` ; do
1303        j=`echo $i | sed 's/[-]//'`
1304        DISABLE="$DISABLE $j"
1305    done
1306  pack=  pack=
1307  for p in $PACKAGES ; do  for p in $PACKAGES ; do
1308      addit="t"      addit="t"
# Line 1119  PACKAGES="$pack" Line 1319  PACKAGES="$pack"
1319  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
1320  echo "" > ./.tmp_pack  echo "" > ./.tmp_pack
1321  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
1322    # Test if each explicitly referenced package exists
1323  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1324      if test ! -d "$ROOTDIR/pkg/$i" ; then      j=`echo $i | sed 's/[-+]//'`
1325        if test ! -d "$ROOTDIR/pkg/$j" ; then
1326          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""
1327          exit 1          exit 1
1328      fi      fi
1329      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
1330  done  done
 pack=`cat ./.tmp_pack | sort | uniq`  
 rm -f ./.tmp_pack  
1331  PACKAGES=  PACKAGES=
1332  for i in $pack ; do  for i in `grep -v "-" ./.tmp_pack | sort | uniq` ; do
1333      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
1334  done  done
1335    rm -f ./.tmp_pack
1336  echo "    packages are:  $PACKAGES"  echo "    packages are:  $PACKAGES"
1337    
1338  echo "  applying package dependency rules"  echo "  applying package dependency rules"
# Line 1372  rm -rf .links.tmp Line 1573  rm -rf .links.tmp
1573  mkdir .links.tmp  mkdir .links.tmp
1574  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > srclinks.tmp
1575  echo "" >> srclinks.tmp  echo "" >> srclinks.tmp
1576  echo -n 'SRCFILES = '    > srclist.inc  printf 'SRCFILES = '    > srclist.inc
1577  echo -n 'CSRCFILES = '   > csrclist.inc  printf 'CSRCFILES = '   > csrclist.inc
1578  echo -n 'F90SRCFILES = ' > f90srclist.inc  printf 'F90SRCFILES = ' > f90srclist.inc
1579  echo -n 'HEADERFILES = ' > hlist.inc  printf 'HEADERFILES = ' > hlist.inc
1580  echo -n 'AD_FLOW_FILES = ' > ad_flow_files.inc  printf 'AD_FLOW_FILES = ' > ad_flow_files.inc
1581  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
1582  for d in $alldirs ; do  for d in $alldirs ; do
1583      deplist=      deplist=
# Line 1401  for d in $alldirs ; do Line 1602  for d in $alldirs ; do
1602                  case $extn in                  case $extn in
1603                      F)                      F)
1604                          echo    " \\"  >> srclist.inc                          echo    " \\"  >> srclist.inc
1605                          echo -n " $sf" >> srclist.inc                          printf " $sf" >> srclist.inc
1606                          ;;                          ;;
1607                      F90)                      F90)
1608                          echo    " \\"  >> f90srclist.inc                          echo    " \\"  >> f90srclist.inc
1609                          echo -n " $sf" >> f90srclist.inc                          printf " $sf" >> f90srclist.inc
1610                          ;;                          ;;
1611                      c)                      c)
1612                          echo    " \\"  >> csrclist.inc                          echo    " \\"  >> csrclist.inc
1613                          echo -n " $sf" >> csrclist.inc                          printf " $sf" >> csrclist.inc
1614                          ;;                          ;;
1615                      h)                      h)
1616                          echo    " \\"  >> hlist.inc                          echo    " \\"  >> hlist.inc
1617                          echo -n " $sf" >> hlist.inc                          printf " $sf" >> hlist.inc
1618                          ;;                          ;;
1619                      flow)                      flow)
1620                          echo    " \\"  >> ad_flow_files.inc                          echo    " \\"  >> ad_flow_files.inc
1621                          echo -n " $sf" >> ad_flow_files.inc                          printf " $sf" >> ad_flow_files.inc
1622                          ;;                          ;;
1623                  esac                  esac
1624              fi              fi
# Line 1446  echo "#    $MACHINE" >> $MAKEFILE Line 1647  echo "#    $MACHINE" >> $MAKEFILE
1647  echo "# This makefile was generated automatically on" >> $MAKEFILE  echo "# This makefile was generated automatically on" >> $MAKEFILE
1648  echo "#    $THISDATE" >> $MAKEFILE  echo "#    $THISDATE" >> $MAKEFILE
1649  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
1650  echo "#    $0 $@" >> $MAKEFILE  echo "#    $0 $G2ARGS" >> $MAKEFILE
1651  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
1652  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE
1653    
# Line 1514  FC = ${FC} Line 1715  FC = ${FC}
1715  # Fortran compiler  # Fortran compiler
1716  F90C = ${F90C}  F90C = ${F90C}
1717  # Link editor  # Link editor
1718  LINK = ${LINK}  LINK = ${LINK} ${LDADD}
1719    
1720  # Defines for CPP  # Defines for CPP
1721  DEFINES = ${DEFINES}  DEFINES = ${DEFINES}
# Line 1546  cat csrclist.inc      >> $MAKEFILE Line 1747  cat csrclist.inc      >> $MAKEFILE
1747  cat f90srclist.inc    >> $MAKEFILE  cat f90srclist.inc    >> $MAKEFILE
1748  cat hlist.inc         >> $MAKEFILE  cat hlist.inc         >> $MAKEFILE
1749  cat ad_flow_files.inc >> $MAKEFILE  cat ad_flow_files.inc >> $MAKEFILE
1750  echo               >> $MAKEFILE  echo >> $MAKEFILE
1751  echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE
1752  echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE  echo 'F90FILES =  $(F90SRCFILES:.F=.'$FS90')' >> $MAKEFILE
1753  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
1754    echo >> $MAKEFILE
1755    echo '.SUFFIXES:' >> $MAKEFILE
1756    echo '.SUFFIXES: .o .F .p .'$FS' .c .F90 .'$FS90 >> $MAKEFILE
1757  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
1758  rm -f ad_flow_files.inc  rm -f ad_flow_files.inc
1759    
1760  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1761    
 .SUFFIXES:  
 .SUFFIXES: .o .f .p .F .c .F90 .f90  
   
1762  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
1763  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)
1764          @echo Creating \$@ ...          @echo Creating \$@ ...
1765          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
1766  depend:  depend:
1767          @make links          @make links
1768          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
1769          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
1770            -rm -f makedepend.out
1771    
1772  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)
1773    
# Line 1577  output.txt: \$(EXECUTABLE) Line 1778  output.txt: \$(EXECUTABLE)
1778          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
1779    
1780  clean:  clean:
1781          -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
1782  Clean:  Clean:
1783          @make clean          @make clean
1784          @make cleanlinks          @make cleanlinks
# Line 1592  CLEAN: Line 1793  CLEAN:
1793    
1794  #eh3 Makefile: makefile  #eh3 Makefile: makefile
1795  makefile:  makefile:
1796          $THIS_SCRIPT $@          $THIS_SCRIPT $G2ARGS
1797  cleanlinks:  cleanlinks:
1798          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
1799    
1800  # Special targets ($SPECIAL_FILES) which are create by make  # Special targets ($SPECIAL_FILES) which are create by make
1801  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
1802          @echo Creating \$@ ...          @echo Creating \$@ ...
1803          @\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@
1804  AD_CONFIG.h:  AD_CONFIG.h:
1805          @echo Creating \$@ ...          @echo Creating \$@ ...
1806          @\$(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 > \$@          @$BASH\$(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 > \$@
1807  FC_NAMEMANGLE.h:  FC_NAMEMANGLE.h:
1808          @echo Creating \$@ ...          @echo Creating \$@ ...
1809          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
1810    
1811  # The normal chain of rules is (  .F - .f - .o  )  # The normal chain of rules is (  .F - .$FS - .o  )
1812  .F.f:  
1813    %.o : %.F
1814    
1815    .F.$FS:
1816          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1817  .f.o:  .$FS.o:
1818          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
1819  .F90.f90:  .F90.$FS90:
1820          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1821  .f90.o:  .$FS90.o:
1822          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
1823  .c.o:  .c.o:
1824          \$(CC) \$(CFLAGS) -c \$<          \$(CC) \$(CFLAGS) -c \$<
1825    
1826  # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
1827  .F.p:  .F.p:
1828          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1829  .p.f:  .p.$FS:
1830          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
1831    
1832  #=========================================  #=========================================
# Line 1649  done Line 1853  done
1853    
1854  echo "  Add the source list for AD code generation"  echo "  Add the source list for AD code generation"
1855  echo >> $MAKEFILE  echo >> $MAKEFILE
1856  echo -n "AD_FILES = " >> $MAKEFILE  printf "AD_FILES = " >> $MAKEFILE
1857  AD_FILES=`cat ad_files`  AD_FILES=`cat ad_files`
1858  for i in $AD_FILES ; do  for i in $AD_FILES ; do
1859      echo    " \\" >> $MAKEFILE      echo    " \\" >> $MAKEFILE
1860      echo -n " $i" >> $MAKEFILE      printf " $i" >> $MAKEFILE
1861  done  done
1862  echo >> $MAKEFILE  echo >> $MAKEFILE
1863  rm -f ad_files  rm -f ad_files
# Line 1666  adtaf: ad_taf_output.f Line 1870  adtaf: ad_taf_output.f
1870  adtamc: ad_tamc_output.f  adtamc: ad_tamc_output.f
1871    
1872  ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)
1873          @\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template
1874          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
1875          -rm -f ad_config.template          -rm -f ad_config.template
1876          @make \$(F77FILES)          @make \$(F77FILES)
# Line 1698  ftltaf: ftl_taf_output.f Line 1902  ftltaf: ftl_taf_output.f
1902  ftltamc: ftl_tamc_output.f  ftltamc: ftl_tamc_output.f
1903    
1904  ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)
1905          @\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template
1906          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
1907          -rm -f ftl_config.template          -rm -f ftl_config.template
1908          @make \$(F77FILES)          @make \$(F77FILES)
# Line 1747  for i in $KPPFILES ; do Line 1951  for i in $KPPFILES ; do
1951      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
1952          echo "Error: unable to add file \"$i\" to the exceptions list"          echo "Error: unable to add file \"$i\" to the exceptions list"
1953      fi      fi
1954      echo "$base.f: $base.p" >> $MAKEFILE      echo "$base.$FS: $base.p" >> $MAKEFILE
1955  done  done
1956    
1957  echo "  Making list of NOOPTFILES"  echo "  Making list of NOOPTFILES"
# Line 1757  for i in $NOOPTFILES ; do Line 1961  for i in $NOOPTFILES ; do
1961      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
1962          echo "Error: unable to add file \"$i\" to the exceptions list"          echo "Error: unable to add file \"$i\" to the exceptions list"
1963      fi      fi
1964      echo "$base.o: $base.f" >> $MAKEFILE      echo "$base.o: $base.$FS" >> $MAKEFILE
1965      printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE      printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE
1966  done  done
1967    
# Line 1771  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 1975  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
1975  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
1976    
1977  # Create special header files  # Create special header files
1978  $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" $DISABLED_PACKAGES " " "Enabled packages:" $ENABLED_PACKAGES > $PACKAGES_DOT_H".tmp"  $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" $DISABLED_PACKAGES " " "Enabled packages:" $ENABLED_PACKAGES > $PACKAGES_DOT_H".tmp"
1979  if test ! -f $PACKAGES_DOT_H ; then  if test ! -f $PACKAGES_DOT_H ; then
1980      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
1981  else  else
# Line 1785  else Line 1989  else
1989      fi      fi
1990  fi  fi
1991  if test ! -f AD_CONFIG.h ; then  if test ! -f AD_CONFIG.h ; then
1992      $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > AD_CONFIG.h      $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > AD_CONFIG.h
1993  fi  fi
1994    
1995    
1996  #  Write the "state" for future records  #  Write the "state" for future records
1997  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" != xf ; then
1998      echo -n "" > genmake_state      printf "" > genmake_state
1999      for i in $gm_state ; do      for i in $gm_state ; do
2000          t1="t2=\$$i"          t1="t2=\$$i"
2001          eval $t1          eval $t1

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

  ViewVC Help
Powered by ViewVC 1.1.22