/[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.87 by edhill, Sat Jul 17 03:29:08 2004 UTC revision 1.108 by edhill, Thu Oct 21 13:38:46 2004 UTC
# Line 122  EOF Line 122  EOF
122        stop        stop
123        end        end
124  EOF  EOF
125      test -e Makefile  &&  mv -f Makefile Makefile.bak      test -f Makefile  &&  mv -f Makefile Makefile.bak
126      cat <<EOF >> Makefile      cat <<EOF >> Makefile
 %.$tfs : %.F  
127  .SUFFIXES:  .SUFFIXES:
128  genmake_hello.$tfs: genmake_hello.F  .SUFFIXES: .$tfs .F
129          $LN genmake_hello.F genmake_hello.$tfs  .F.$tfs:
130            $LN \$< \$@
131  EOF  EOF
132      $MAKE "genmake_hello."$tfs > /dev/null 2>&1      $MAKE "genmake_hello."$tfs > /dev/null 2>&1
133      RETVAL=$?      RETVAL=$?
134      if test "x$RETVAL" != x0 -o ! -e "genmake_hello."$tfs ; then      if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then
135          if test "x$FS" = x ; then          if test "x$FS" = x ; then
136              FS='for'              FS='for'
137              FS90='fr9'              FS90='fr9'
# Line 149  EOF Line 149  EOF
149          fi          fi
150      fi      fi
151      rm -f genmake_hello.* Makefile      rm -f genmake_hello.* Makefile
152      test -e Makefile  &&  mv -f Makefile.bak Makefile      test -f Makefile  &&  mv -f Makefile.bak Makefile
153    
154      #  If we make it here, use the extensions      #  If we make it here, use the extensions
155      FS=$tfs      FS=$tfs
# Line 195  EOF Line 195  EOF
195              echo "    a system-default makedepend was not found."              echo "    a system-default makedepend was not found."
196                            
197              #  Try to build the cyrus implementation              #  Try to build the cyrus implementation
198              rm -f ./genmake_cy_md              build_cyrus_makedepend
             (  
                 cd $ROOTDIR/tools/cyrus-imapd-makedepend  \  
                     &&  ./configure > /dev/null 2>&1  \  
                     &&  make > /dev/null 2>&1  
                 if test -x ./makedepend.exe ; then  
                     $LN ./makedepend.exe ./makedepend  
                 fi  
                 ./makedepend ifparser.c > /dev/null 2>&1  \  
                     &&  echo "true"  
             ) > ./genmake_cy_md  
             grep true ./genmake_cy_md > /dev/null 2>&1  
199              RETVAL=$?              RETVAL=$?
200              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" != x0 ; then
                 MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'  
             else  
201                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
202              fi              fi
203              rm -f ./genmake_cy_md              rm -f ./genmake_cy_md
204          fi          fi
205        else
206            #  echo "MAKEDEPEND=${MAKEDEPEND}"
207            echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1
208            RETVAL=$?
209            if test x"$RETVAL" = x0 ; then
210                build_cyrus_makedepend
211            fi
212      fi      fi
213  }  }
214    
215    
216    build_cyrus_makedepend()  {
217        rm -f ./genmake_cy_md
218        (
219            cd $ROOTDIR/tools/cyrus-imapd-makedepend  \
220                &&  ./configure > /dev/null 2>&1  \
221                &&  make > /dev/null 2>&1
222            if test -x ./makedepend.exe ; then
223                $LN ./makedepend.exe ./makedepend
224            fi
225            ./makedepend ifparser.c > /dev/null 2>&1  \
226                &&  echo "true"
227        ) > ./genmake_cy_md
228        grep true ./genmake_cy_md > /dev/null 2>&1
229        RETVAL=$?
230        rm -f ./genmake_cy_md
231        if test "x$RETVAL" = x0 ; then
232            MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
233            return 0
234        else
235            echo "WARNING: unable to build cyrus-imapd-makedepend"
236            return 1
237        fi
238    }
239    
240  # Guess possible config options for this host  # Guess possible config options for this host
241  find_possible_configs()  {  find_possible_configs()  {
242    
# Line 251  find_possible_configs()  { Line 269  find_possible_configs()  {
269    
270      look_for_makedepend      look_for_makedepend
271    
272      # look for possible fortran compilers      #================================================================
273        #  look for possible C compilers
274        tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc"
275        p_CC=
276        for c in $tmp ; do
277            rm -f ./genmake_hello.c  ./genmake_hello
278            cat >> genmake_hello.c << EOF
279    #include <stdio.h>
280    int main(int argc, char **argv) {
281      printf("Hello!\n");
282      return 0;
283    }
284    EOF
285            $c -o genmake_hello genmake_hello.c > /dev/null 2>&1
286            RETVAL=$?
287            if test "x${RETVAL}" = x0 ; then
288                p_CC="$p_CC $c"
289            fi
290        done
291        rm -f ./genmake_hello.c ./genmake_hello
292        if test "x${p_CC}" = x ; then
293            cat 1>&2 <<EOF
294    
295    Error: No C compilers were found in your path.  Please specify one using:
296    
297        1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
298        2) the CC or MITGCM_CC environment variables.
299    
300    EOF
301            exit 1
302        else
303            echo "  The possible C compilers found in your path are:"
304            echo "   "$p_CC
305            if test "x$CC" = x ; then
306                CC=`echo $p_CC | $AWK '{print $1}'`
307                echo "  Setting C compiler to: "$CC
308            fi
309        fi
310    
311        #================================================================
312        #  look for possible FORTRAN compilers
313      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"
314      p_FC=      p_FC=
315      for c in $tmp ; do      for c in $tmp ; do
# Line 277  Error: No Fortran compilers were found i Line 335  Error: No Fortran compilers were found i
335    
336      1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),      1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
337      2) a command-line option (eg. "-fc NAME"), or      2) a command-line option (eg. "-fc NAME"), or
338      3) the MITGCM_FC environment variable.      3) the FC or MITGCM_FC environment variables.
339    
340  EOF  EOF
341          exit 1          exit 1
# Line 448  Usage: "$0" [OPTIONS] Line 506  Usage: "$0" [OPTIONS]
506            will search for a working compiler by trying a list of            will search for a working compiler by trying a list of
507            "usual suspects" such as g77, f77, etc.            "usual suspects" such as g77, f77, etc.
508    
509        -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
510              Use "NAME" as the C compiler.  By default, genmake
511              will search for a working compiler by trying a list of
512              "usual suspects" such as gcc, c89, cc, etc.
513    
514      -[no]ieee | --[no]ieee      -[no]ieee | --[no]ieee
515            Do or don't use IEEE numerics.  Note that this option            Do or don't use IEEE numerics.  Note that this option
516            *only* works if it is supported by the OPTFILE that            *only* works if it is supported by the OPTFILE that
# Line 457  Usage: "$0" [OPTIONS] Line 520  Usage: "$0" [OPTIONS]
520            Include MPI header files and link to MPI libraries            Include MPI header files and link to MPI libraries
521      -mpi=PATH | --mpi=PATH      -mpi=PATH | --mpi=PATH
522            Include MPI header files and link to MPI libraries using MPI_ROOT            Include MPI header files and link to MPI libraries using MPI_ROOT
523            set to PATH. i.e. Include files from $PATH/include, link to libraries            set to PATH. i.e. Include files from \$PATH/include, link to libraries
524            from $PATH/lib and use binaries from $PATH/bin.            from \$PATH/lib and use binaries from \$PATH/bin.
525    
526      -bash NAME      -bash NAME
527            Explicitly specify the Bourne or BASH shell to use            Explicitly specify the Bourne or BASH shell to use
# Line 483  EOF Line 546  EOF
546    
547  #  Build a CPP macro to automate calling C routines from FORTRAN  #  Build a CPP macro to automate calling C routines from FORTRAN
548  get_fortran_c_namemangling()  {  get_fortran_c_namemangling()  {
549    
550        #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
551        if test ! "x$FC_NAMEMANGLE" = x ; then
552            return 0
553        fi
554    
555      default_nm="#define FC_NAMEMANGLE(X) X ## _"      default_nm="#define FC_NAMEMANGLE(X) X ## _"
556            
557      cat > genmake_test.c <<EOF      cat > genmake_test.c <<EOF
# Line 500  WARNING: Please contact <MITgcm-support@ Line 569  WARNING: Please contact <MITgcm-support@
569  EOF  EOF
570          return 1          return 1
571      fi      fi
572      c_tcall=`nm genmake_test.o | grep 'T ' | grep tcall | cut -d ' ' -f 3`      c_tcall=`nm genmake_test.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
573      RETVAL=$?      RETVAL=$?
574      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
575          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 530  WARNING: Please contact <MITgcm-support@ Line 599  WARNING: Please contact <MITgcm-support@
599  EOF  EOF
600          return 1          return 1
601      fi      fi
602      f_tcall=`nm genmake_tcomp.o | grep 'T ' | grep tcall | cut -d ' ' -f 3`      f_tcall=`nm genmake_tcomp.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
603      RETVAL=$?      RETVAL=$?
604      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
605          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 606  EOF Line 675  EOF
675  }  }
676    
677    
678    check_HAVE_STAT()  {
679        get_fortran_c_namemangling
680        cat <<EOF > genmake_tc_1.c
681    $FC_NAMEMANGLE
682    #include <stdio.h>
683    #include <stdlib.h>
684    #include <unistd.h>
685    #include <sys/stat.h>
686    #include <sys/types.h>
687    void FC_NAMEMANGLE(tfsize) ( int *nbyte )
688    {
689        char name[512];
690        struct stat astat;
691    
692        name[0] = 'a'; name[1] = '\0';
693        if (! stat(name, &astat))
694            *nbyte = (int)(astat.st_size);
695        else
696            *nbyte = -1;
697    }
698    EOF
699        make genmake_tc_1.o >> genmake_tc.log 2>&1
700        RET_C=$?
701        cat <<EOF > genmake_tc_2.f
702          program hello
703          integer nbyte
704          call tfsize(nbyte)
705          print *," HELLO WORLD", nbyte
706          end program hello
707    EOF
708        $FC $FFLAGS -o genmake_tc genmake_tc_2.f genmake_tc_1.o >> genmake_tc.log 2>&1
709        RET_F=$?
710        test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1
711        RETVAL=$?
712        if test "x$RETVAL" = x0 ; then
713            HAVE_STAT=t
714            DEFINES="$DEFINES -DHAVE_STAT"
715        fi
716        rm -f genmake_tc*
717    }
718    
719    
720  check_netcdf_libs()  {  check_netcdf_libs()  {
721        echo "" > genmake_tnc.log
722      cat <<EOF > genmake_tnc.for      cat <<EOF > genmake_tnc.for
723        program fgennc        program fgennc
724  #include "netcdf.inc"  #include "netcdf.inc"
# Line 619  check_netcdf_libs()  { Line 731  check_netcdf_libs()  {
731        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
732        end        end
733  EOF  EOF
734      $CPP genmake_tnc.for > genmake_tnc.f  \      #echo "$CPP $DEFINES $INCLUDES genmake_tnc.for > genmake_tnc.f"
735          &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1      #echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.f"
736        #echo "$LINK -o genmake_tnc.o $LIBS"
737        $CPP $DEFINES $INCLUDES genmake_tnc.for > genmake_tnc.f 2>/dev/null  \
738            &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.f >> genmake_tnc.log 2>&1  \
739            &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
740      RET_COMPILE=$?      RET_COMPILE=$?
741      test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1  
742      RETVAL=$?      #EH3  Remove test program execution for machines that either disallow
743      if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then      #EH3  execution or cannot support it (eg. cross-compilers)
744        #EH3
745        #EH3 test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
746        #EH3 RETVAL=$?
747        #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
748    
749        if test "x$RET_COMPILE" = x0 ; then
750          HAVE_NETCDF=t          HAVE_NETCDF=t
751      else      else
752          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
753          $CPP genmake_tnc.for > genmake_tnc.f  \          $CPP $DEFINES $INCLUDES genmake_tnc.for > genmake_tnc.f 2>/dev/null  \
754              &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.f >> genmake_tnc.log 2>&1  \
755              $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1              &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
756          RET_COMPILE=$?          RET_COMPILE=$?
757          test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1          if test "x$RET_COMPILE" = x0 ; then
         RETVAL=$?  
         if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then  
758              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
759              HAVE_NETCDF=t              HAVE_NETCDF=t
760          else          else
# Line 658  LN= Line 778  LN=
778  S64=  S64=
779  KPP=  KPP=
780  FC=  FC=
781    #CC=gcc
782  CPP=  CPP=
783  LINK=  LINK=
784  DEFINES=  DEFINES=
# Line 665  PACKAGES= Line 786  PACKAGES=
786  ENABLE=  ENABLE=
787  DISABLE=  DISABLE=
788  MAKEFILE=  MAKEFILE=
789  MAKEDEPEND=  #MAKEDEPEND=
790  PDEPEND=  PDEPEND=
791  DUMPSTATE=t  DUMPSTATE=t
792  PDEFAULT=  PDEFAULT=
# Line 689  HAVE_SYSTEM= Line 810  HAVE_SYSTEM=
810  HAVE_FDATE=  HAVE_FDATE=
811  FC_NAMEMANGLE=  FC_NAMEMANGLE=
812  HAVE_CLOC=  HAVE_CLOC=
813    HAVE_STAT=
814  HAVE_NETCDF=  HAVE_NETCDF=
815  HAVE_ETIME=  HAVE_ETIME=
816    
# Line 703  BASH= Line 825  BASH=
825  PWD=`pwd`  PWD=`pwd`
826  MAKE=make  MAKE=make
827  AWK=awk  AWK=awk
828  THISHOSTNAME=`hostname`  THISHOST=`hostname`
829  THISCWD=`pwd`  THISCWD=`pwd`
830  THISDATE=`date`  THISDATE=`date`
831    THISUSER=`echo $USER`
832    THISVER=
833  MACHINE=`uname -a`  MACHINE=`uname -a`
834  EXECUTABLE=  EXECUTABLE=
835  EXEHOOK=  EXEHOOK=
# Line 739  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STA Line 863  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STA
863  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
864  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "
865  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
866  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"
867  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
868  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"
869    
# Line 771  for i in . $MODS ; do Line 895  for i in . $MODS ; do
895      fi      fi
896  done  done
897  printf "  getting local config information:  "  printf "  getting local config information:  "
898  if test -e $gm_local ; then  if test -f $gm_local ; then
899      echo "using $gm_local"      echo "using $gm_local"
900      . $gm_local      . $gm_local
901      # echo "DISABLE=$DISABLE"      # echo "DISABLE=$DISABLE"
# Line 780  else Line 904  else
904      echo "none found"      echo "none found"
905  fi  fi
906    
907  #  echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
908  #OPTIONS=  #OPTIONS=
909  #n=0  #n=0
910  #for i ; do  #for i ; do
# Line 792  fi Line 916  fi
916  #done  #done
917  #parse_options  #parse_options
918  ac_prev=  ac_prev=
919  for ac_option in $@ ; do  for ac_option in "$@" ; do
920    
921      G2ARGS="$G2ARGS \"$ac_option\""      G2ARGS="$G2ARGS \"$ac_option\""
922    
# Line 888  for ac_option in $@ ; do Line 1012  for ac_option in $@ ; do
1012  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1013  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1014  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1015                        
1016            -cc | --cc)
1017                ac_prev=CC ;;
1018            -cc=* | --cc=*)
1019                CC=$ac_optarg ;;
1020            
1021          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1022              ac_prev=FC ;;              ac_prev=FC ;;
1023          -fc=* | --fc=*)          -fc=* | --fc=*)
# Line 959  if test -f ./.genmakerc ; then Line 1088  if test -f ./.genmakerc ; then
1088      echo      echo
1089  fi  fi
1090    
1091    #  Find the MITgcm ${ROOTDIR}
1092  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
1093      tmp=`echo $PWD | sed -e 's/\// /g' | awk '{print $NR}'`      tmp=`echo $PWD | sed -e 's/\// /g' | awk '{print $NR}'`
1094      if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
# Line 985  if test ! -d ${ROOTDIR} ; then Line 1115  if test ! -d ${ROOTDIR} ; then
1115      exit 1      exit 1
1116  fi  fi
1117    
1118    #  Find the MITgcm ${THISVER}
1119    if test -f "${ROOTDIR}/doc/tag-index" ; then
1120        THISVER=`grep checkpoint ${ROOTDIR}/doc/tag-index | head -1`
1121    fi
1122    
1123  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
1124  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1125      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
# Line 1044  if test "x${AD_OPTFILE}" != xNONE ; then Line 1179  if test "x${AD_OPTFILE}" != xNONE ; then
1179      fi      fi
1180  fi  fi
1181    
1182  #  Check that FC, LINK, CPP, S64, LN, and MAKE are defined.  If not,  #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
1183  #  either set defaults or complain and abort!  #  either set defaults or complain and abort!
1184  if test ! "x$BASH" = x ; then  if test ! "x$BASH" = x ; then
1185      # add a trailing space so that it works within the Makefile syntax (see below)      # add a trailing space so that it works within the Makefile syntax (see below)
# Line 1060  Error: no Fortran compiler: please speci Line 1195  Error: no Fortran compiler: please speci
1195  EOF  EOF
1196      exit 1      exit 1
1197  fi  fi
1198    if test "x$CC" = x ; then
1199        CC=cc
1200    #     cat <<EOF 1>&2
1201    # Error: no C compiler: please specify using one of the following:
1202    #   1) within the options file ("CC=...") as specified by "-of=OPTFILE"
1203    #   2) the "-cc=XXX" command-line option
1204    #   3) the "./genmake_local" file
1205    # EOF
1206    #     exit 1
1207    fi
1208  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1209      LINK=$FC      LINK=$FC
1210  fi  fi
# Line 1191  else Line 1336  else
1336  fi  fi
1337  rm -f genmake_t*  rm -f genmake_t*
1338    
1339    printf "  Can we use stat() through C calls...  "
1340    check_HAVE_STAT
1341    if test "x$HAVE_STAT" != x ; then
1342        echo "yes"
1343    else
1344        echo "no"
1345    fi
1346    rm -f genmake_t*
1347    
1348  printf "  Can we create NetCDF-enabled binaries...  "  printf "  Can we create NetCDF-enabled binaries...  "
1349  check_netcdf_libs  check_netcdf_libs
1350  if test "x$HAVE_NETCDF" != x ; then  if test "x$HAVE_NETCDF" != x ; then
# Line 1243  if test ! -d ${TOOLSDIR} ; then Line 1397  if test ! -d ${TOOLSDIR} ; then
1397      exit 1      exit 1
1398  fi  fi
1399  if test "x$S64" = x ; then  if test "x$S64" = x ; then
1400      S64='$(TOOLSDIR)/set64bitConst.sh'      echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
1401        RETVAL=$?
1402        if test "x${RETVAL}" = x0 ; then
1403            S64='$(TOOLSDIR)/set64bitConst.sh'
1404        else
1405            echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
1406            RETVAL=$?
1407            if test "x${RETVAL}" = x0 ; then
1408                S64='$(TOOLSDIR)/set64bitConst.csh'
1409            else
1410                cat <<EOF
1411    
1412    ERROR: neither of the two default scripts:
1413    
1414        ${TOOLSDIR}/set64bitConst.sh
1415        ${TOOLSDIR}/set64bitConst.csh
1416    
1417      are working so please check paths or specify (with \$S64) a
1418      working version of this script.
1419    
1420    EOF
1421                exit 1
1422            fi
1423        fi
1424  fi  fi
1425  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1426    
# Line 1388  done Line 1565  done
1565  rm -f ./.tmp_pack  rm -f ./.tmp_pack
1566  echo "    packages are:  $PACKAGES"  echo "    packages are:  $PACKAGES"
1567    
1568    #  Check availability of NetCDF and then either build the MNC template
1569    #  files or delete mnc from the list of available packages.
1570    echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1571    RETVAL=$?
1572    if test "x$RETVAL" = x0 ; then
1573        if test "x$HAVE_NETCDF" != xt ; then
1574            cat <<EOF
1575    
1576    *********************************************************************
1577    WARNING: the "mnc" package was enabled but tests failed to compile
1578      NetCDF applications.  Please check that:
1579    
1580      1) NetCDF is correctly installed for this compiler and
1581      2) the LIBS variable (within the "optfile") specifies the correct
1582           NetCDF library to link against.
1583    
1584      Due to this failure, the "mnc" package is now DISABLED.
1585    *********************************************************************
1586    
1587    EOF
1588            PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
1589            DISABLE="$DISABLE mnc"
1590        else
1591            ( cd $ROOTDIR"/pkg/mnc" && $MAKE templates ) > make_mnc.errors 2>&1
1592            RETVAL=$?
1593            if test "x${RETVAL}" = x0 ; then
1594                rm -f make_mnc.errors
1595            else
1596                echo "Error: problem encountered while building source files in pkg/mnc:"
1597                cat make_mnc.errors 1>&2
1598                exit 1
1599            fi
1600        fi
1601    fi
1602    
1603  echo "  applying package dependency rules"  echo "  applying package dependency rules"
1604  ck=  ck=
1605  while test "x$ck" != xtt ; do  while test "x$ck" != xtt ; do
# Line 1472  for i in $PACKAGES ; do Line 1684  for i in $PACKAGES ; do
1684      fi      fi
1685  done  done
1686    
 #  Build MNC templates and check for ability to build and use NetCDF  
 echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1  
 RETVAL=$?  
 if test "x$RETVAL" = x0 ; then  
     ( cd $ROOTDIR"/pkg/mnc" && $MAKE templates ) > make_mnc.errors 2>&1  
     RETVAL=$?  
     if test "x${RETVAL}" = x0 ; then  
         rm -f make_mnc.errors  
     else  
         echo "Error: problem encountered while building source files in pkg/mnc:"  
         cat make_mnc.errors 1>&2  
         exit 1  
     fi  
     if test "x$HAVE_NETCDF" != xt ; then  
         cat <<EOF  
   
 WARNING: the "mnc" package has been enabled but tests failed to  
   compile and/or execute NetCDF applications.  Please check that:  
   
   1) NetCDF is installed for your compiler and  
   2) the LIBS variable (within the 'optfile") specifies the correct  
        NetCDF library to link against.  
     
 EOF  
     fi  
 fi  
   
1687  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
1688  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
1689  #  The following UGLY HACK sets multiple "#undef"s and it needs to go  #  The following UGLY HACK sets multiple "#undef"s and it needs to go
# Line 1645  for d in $alldirs ; do Line 1830  for d in $alldirs ; do
1830                          ;;                          ;;
1831                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
1832                          ;;                          ;;
1833                      ./BUILD_INFO.h)
1834                            ;;
1835                    *)                    *)
1836                          touch .links.tmp/$sf                          touch .links.tmp/$sf
1837                          deplist="$deplist $sf"                          deplist="$deplist $sf"
# Line 1690  echo "" >> f90srclist.inc Line 1877  echo "" >> f90srclist.inc
1877  echo "" >> hlist.inc  echo "" >> hlist.inc
1878  echo "" >> ad_flow_files.inc  echo "" >> ad_flow_files.inc
1879    
1880  if test -e $MAKEFILE ; then  if test -f $MAKEFILE ; then
1881      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
1882  fi  fi
1883  echo "  Writing makefile: $MAKEFILE"  echo "  Writing makefile: $MAKEFILE"
# Line 1701  echo "#    $THISDATE" >> $MAKEFILE Line 1888  echo "#    $THISDATE" >> $MAKEFILE
1888  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
1889  echo "#    $0 $G2ARGS" >> $MAKEFILE  echo "#    $0 $G2ARGS" >> $MAKEFILE
1890  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
1891  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
1892    
1893  EXE_AD=$EXECUTABLE"_ad"  EXE_AD=$EXECUTABLE"_ad"
1894  EXE_FTL=$EXECUTABLE"_ftl"  EXE_FTL=$EXECUTABLE"_ftl"
# Line 1747  ENABLED_PACKAGES = ${ENABLED_PACKAGES} Line 1934  ENABLED_PACKAGES = ${ENABLED_PACKAGES}
1934  DISABLED_PACKAGES = ${DISABLED_PACKAGES}  DISABLED_PACKAGES = ${DISABLED_PACKAGES}
1935    
1936  # These files are created by Makefile  # These files are created by Makefile
1937  SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h  SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h BUILD_INFO.h
1938    
1939  EOF  EOF
1940    
# Line 1766  KPP = ${KPP} Line 1953  KPP = ${KPP}
1953  FC = ${FC}  FC = ${FC}
1954  # Fortran compiler  # Fortran compiler
1955  F90C = ${F90C}  F90C = ${F90C}
1956    # C compiler
1957    CC = ${CC}
1958  # Link editor  # Link editor
1959  LINK = ${LINK} ${LDADD}  LINK = ${LINK} ${LDADD}
1960    
# Line 1788  CFLAGS = ${CFLAGS} Line 1977  CFLAGS = ${CFLAGS}
1977  NOOPTFILES = ${NOOPTFILES}  NOOPTFILES = ${NOOPTFILES}
1978  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
1979  # Flags and libraries needed for linking  # Flags and libraries needed for linking
1980  LIBS = ${LIBS} \$(XLIBS)  LIBS = ${LIBS}
1981  # Name of the Mekfile  # Name of the Mekfile
1982  MAKEFILE=${MAKEFILE}  MAKEFILE=${MAKEFILE}
1983    
# Line 1849  makefile: Line 2038  makefile:
2038  cleanlinks:  cleanlinks:
2039          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2040    
2041  # Special targets ($SPECIAL_FILES) which are create by make  # Special targets (SPECIAL_FILES) which are create by make
2042  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2043          @echo Creating \$@ ...          @echo Creating \$@ ...
2044          @$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) > \$@          @$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) > \$@
# Line 1860  FC_NAMEMANGLE.h: Line 2049  FC_NAMEMANGLE.h:
2049          @echo Creating \$@ ...          @echo Creating \$@ ...
2050          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
2051    
2052    BUILD_INFO.h:
2053            @echo Creating \$@ ...
2054    EOF
2055    
2056    test ! "x$THISVER" = x  && echo "       -echo \"#define THISVER '$THISVER'\" > \$@"   >> $MAKEFILE
2057    test ! "x$THISUSER" = x && echo "       -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
2058    test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2059    test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2060    
2061    cat >>$MAKEFILE <<EOF
2062    
2063  # The normal chain of rules is (  .F - .$FS - .o  )  # The normal chain of rules is (  .F - .$FS - .o  )
2064    
2065  %.o : %.F  ## This nullifies any default implicit rules concerning these two file types:
2066    ## %.o : %.F
2067    
2068  .F.$FS:  .F.$FS:
2069          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
# Line 1947  ad_tamc_output.f: ad_input_code.f Line 2148  ad_tamc_output.f: ad_input_code.f
2148  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
2149          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
2150    
2151    adonlyfwd:
2152            patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
2153    
2154    adtrick:
2155            patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
2156    
2157  # ... FTL ...  # ... FTL ...
2158  ftlall: ftl_taf  ftlall: ftl_taf

Legend:
Removed from v.1.87  
changed lines
  Added in v.1.108

  ViewVC Help
Powered by ViewVC 1.1.22