/[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.73 by edhill, Tue Mar 16 18:20:34 2004 UTC revision 1.76 by edhill, Thu Apr 8 21:32:11 2004 UTC
# 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 496  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 508  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 517  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 603  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 780  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)
# Line 889  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 942  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 1190  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 1212  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 1639  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          -rm -f makedepend.out
1771    
# Line 1671  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 1701  FC_NAMEMANGLE.h: Line 1808  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 1841  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 1851  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    

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

  ViewVC Help
Powered by ViewVC 1.1.22