/[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.11.2.1 by adcroft, Wed Oct 1 18:44:48 2003 UTC revision 1.11.2.12 by edhill, Sat Oct 4 14:21:58 2003 UTC
# Line 11  Line 11 
11  # Search for particular CPP #cmds associated with packages  # Search for particular CPP #cmds associated with packages
12  # usage: test_for_package_in_cpp_options CPP_file package_name  # usage: test_for_package_in_cpp_options CPP_file package_name
13  test_for_package_in_cpp_options() {  test_for_package_in_cpp_options() {
14     cpp_options=$1      cpp_options=$1
15     pkg=$2      pkg=$2
16     grep -i "#define.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1      grep -i "#define.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1
17     RETVAL=$?      RETVAL=$?
18     if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
19        echo "Error: In $cpp_options there is an illegal line: #define ALLOW_$pkg"          echo "Error: In $cpp_options there is an illegal line: #define ALLOW_$pkg"
20        exit 99          exit 99
21     fi      fi
22     grep -i "#undef.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1      grep -i "#undef.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1
23     RETVAL=$?      RETVAL=$?
24     if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
25        echo "Error: In $cpp_options there is an illegal line: #undef ALLOW_$pkg"          echo "Error: In $cpp_options there is an illegal line: #undef ALLOW_$pkg"
26        exit 99          exit 99
27     fi      fi
28     grep -i "#define.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1      grep -i "#define.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1
29     RETVAL=$?      RETVAL=$?
30     if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
31        echo "Error: In $cpp_options there is an illegal line: #define DISABLE_$pkg"          echo "Error: In $cpp_options there is an illegal line: #define DISABLE_$pkg"
32        exit 99          exit 99
33     fi      fi
34     grep -i "#undef.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1      grep -i "#undef.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1
35     RETVAL=$?      RETVAL=$?
36     if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
37        echo "Error: In $cpp_options there is an illegal line: #undef DISABLE_$pkg"          echo "Error: In $cpp_options there is an illegal line: #undef DISABLE_$pkg"
38        exit 99          exit 99
39     fi     fi
40  }  }
41    
42    # Read the $ROOTDIR/pkg/pkg_groups file and expand any references to
43    # the package list.
44    expand_pkg_groups() {
45        new_packages=
46        PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups"
47        if test -r $PKG_GROUPS ; then
48            cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp
49            cat ./p1.tmp | awk '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp
50            matched=0
51            for i in $PACKAGES ; do
52                line=`grep $i ./p2.tmp`
53                RETVAL=$?
54                if test "x$RETVAL" = x0 ; then
55                    matched=1
56                    replace=`echo $line | awk '{ $1=""; $2=""; print $0 }'`
57                    echo "    replacing \"$i\" with: $replace"
58                    new_packages="$new_packages $replace"
59                else
60                    new_packages="$new_packages $i"
61                fi
62            done
63            PACKAGES=$new_packages
64            rm -f ./p[1,2].tmp
65        else
66            echo "Warning: can't read package groups definition file: $PKG_GROUPS"
67        fi
68    }
69    
70  # Guess possible config options for this host  # Guess possible config options for this host
71  find_possible_configs()  {  find_possible_configs()  {
72    
73      tmp1=`uname`"_"`uname -m`      tmp1=`uname`"_"`uname -m`
74      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
75      PLATFORM=`echo $tmp2 | sed -e 's/i[3-6]86/ia32/'`      PLATFORM=`echo $tmp2 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
76      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
77      echo "  The platform appears to be:  $PLATFORM"      echo "  The platform appears to be:  $PLATFORM"
78  #     if test "x$OFLIST" = x ; then  #     if test "x$OFLIST" = x ; then
# Line 212  usage()  { Line 239  usage()  {
239      echo "      -disable=NAME | --disable=NAME"      echo "      -disable=NAME | --disable=NAME"
240      echo "    -enable NAME | --enable NAME"      echo "    -enable NAME | --enable NAME"
241      echo "      -enable=NAME | --enable=NAME"      echo "      -enable=NAME | --enable=NAME"
242        echo "    -standarddirs NAME | --standarddirs NAME"
243        echo "      -standarddirs=NAME | --standarddirs=NAME"
244      echo "    -noopt NAME | --noopt NAME"      echo "    -noopt NAME | --noopt NAME"
245      echo "      -noopt=NAME | --noopt=NAME"      echo "      -noopt=NAME | --noopt=NAME"
246  #    echo "    -cpp NAME | --cpp NAME"  #    echo "    -cpp NAME | --cpp NAME"
# Line 286  MODS= Line 315  MODS=
315  TOOLSDIR=  TOOLSDIR=
316  SOURCEDIRS=  SOURCEDIRS=
317  INCLUDEDIRS=  INCLUDEDIRS=
318    STANDARDDIRS=
319    
320  PWD=`pwd`  PWD=`pwd`
321  MAKE=make  MAKE=make
# Line 296  MACHINE=`uname -a` Line 326  MACHINE=`uname -a`
326  EXECUTABLE=  EXECUTABLE=
327  EXEHOOK=  EXEHOOK=
328  EXEDIR=  EXEDIR=
329    PACKAGES_CONF=
330    IEEE=
331    if test "x$MITGCM_IEEE" != x ; then
332        IEEE=$MITGCM_IEEE
333    fi
334    
335  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
336  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"
337  gm_s2="FC IEEE MPI JAM DUMPSTATE"  gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS"
338    
339  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
340  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 "
341  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
342  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"
343  gm_s6="EXECUTABLE EXEHOOK EXEDIR"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
344    
345  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6"  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6"
346    
347    
348  echo  echo
349  echo "===  Processing options files and arguments  ==="  echo "===  Processing options files and arguments  ==="
350  gm_local="./gm_local"  gm_local="genmake_local"
351    for i in . $MODS ; do
352        if test -r $i/$gm_local ; then
353            source $i/$gm_local
354            break
355        fi
356    done
357  echo -n "  getting local config information:  "  echo -n "  getting local config information:  "
358  if test -e $gm_local ; then  if test -e $gm_local ; then
359      echo "using $gm_local"      echo "using $gm_local"
# Line 404  for ac_option ; do Line 445  for ac_option ; do
445          -enable=* | --enable=*)          -enable=* | --enable=*)
446              ENABLE=$ac_optarg ;;              ENABLE=$ac_optarg ;;
447                    
448            -standarddirs | --standarddirs)
449                ac_prev=STANDARDDIRS ;;
450            -standarddirs=* | --standarddirs=*)
451                STANDARDDIRS=$ac_optarg ;;
452    
453          -noopt | --noopt)          -noopt | --noopt)
454              ac_prev=NOOPT ;;              ac_prev=NOOPT ;;
455          -noopt=* | --noopt=*)          -noopt=* | --noopt=*)
# Line 420  for ac_option ; do Line 466  for ac_option ; do
466              FC=$ac_optarg ;;              FC=$ac_optarg ;;
467                    
468          -ieee | --ieee)          -ieee | --ieee)
469              IEEE=1 ;;              IEEE=true ;;
470          -noieee | --noieee)          -noieee | --noieee)
471              IEEE=0 ;;              IEEE= ;;
472                    
473          -mpi | --mpi)          -mpi | --mpi)
474              MPI=1 ;;              MPI=true ;;
475          -nompi | --nompi)          -nompi | --nompi)
476              MPI=0 ;;              MPI= ;;
477                    
478          -jam | --jam)          -jam | --jam)
479              JAM=1 ;;              JAM=1 ;;
# Line 497  if test "x$OPTFILE" != xNONE ; then Line 543  if test "x$OPTFILE" != xNONE ; then
543              exit 1              exit 1
544          fi          fi
545          if test "x$DUMPSTATE" != xf ; then          if test "x$DUMPSTATE" != xf ; then
546              cp -f $OPTFILE "gm_optfile"              cp -f $OPTFILE "genmake_optfile"
547          fi          fi
548      else      else
549          echo "Error: can't read OPTFILE=\"$OPTFILE\""          echo "Error: can't read OPTFILE=\"$OPTFILE\""
# Line 513  if test "x$FC" = x ; then Line 559  if test "x$FC" = x ; then
559  Error: no Fortran compiler: please specify using one of the following:  Error: no Fortran compiler: please specify using one of the following:
560    1) within the options file ("FC=...") as specified by "-of=OPTFILE"    1) within the options file ("FC=...") as specified by "-of=OPTFILE"
561    2) the "-fc=XXX" command-line option    2) the "-fc=XXX" command-line option
562    3) the "./gm_local" file    3) the "./genmake_local" file
563  EOF  EOF
564      exit 1      exit 1
565  fi  fi
# Line 531  if test "x$RETVAL" != x0 ; then Line 577  if test "x$RETVAL" != x0 ; then
577  Error: C pre-processor "$CPP" failed the test case: please specify using:  Error: C pre-processor "$CPP" failed the test case: please specify using:
578    
579    1) within the options file ("CPP=...") as specified by "-of=OPTFILE"    1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
580    2) the "./gm_local" file    2) the "./genmake_local" file
581    
582  EOF  EOF
583      exit 1      exit 1
# Line 634  fi Line 680  fi
680  source ./.pd_tmp  source ./.pd_tmp
681  rm -f ./.pd_tmp  rm -f ./.pd_tmp
682    
683    #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"
684    #  file should eventually be added so that, for convenience, one can
685    #  specify groups of packages using names like "ocean" and "atmosphere".
686  echo  -n "  checking default package list:  "  echo  -n "  checking default package list:  "
687  if test "x${PDEFAULT}" = x ; then  if test "x${PDEFAULT}" = x ; then
688        for i in "." $MODS ; do
689            if test -r $i"/packages.conf" ; then
690                    PDEFAULT=$i"/packages.conf"
691                    break
692            fi
693        done
694    fi
695    if test "x${PDEFAULT}" = x ; then
696      PDEFAULT="$ROOTDIR/pkg/pkg_default"      PDEFAULT="$ROOTDIR/pkg/pkg_default"
697  fi  fi
698  if test "x${PDEFAULT}" = xNONE ; then  if test "x${PDEFAULT}" = xNONE ; then
# Line 657  else Line 714  else
714          for i in $def ; do          for i in $def ; do
715              PACKAGES="$PACKAGES $i"              PACKAGES="$PACKAGES $i"
716          done          done
717          echo "    packages are:  $PACKAGES"          echo "    before group expansion packages are: $PACKAGES"
718            expand_pkg_groups
719            echo "    after group expansion packages are:  $PACKAGES"
720      fi      fi
721  fi  fi
722    
# Line 793  done Line 852  done
852  # echo  # echo
853    
854  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
855  PACKAGES_DOT_H=PACKAGES.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
856  if test -e $PACKAGES_DOT_H ; then  cat <<EOF >$PACKAGES_DOT_H".tmp"
     if test ! -e $PACKAGES_DOT_H.bak ; then  
         cp -f $PACKAGES_DOT_H $PACKAGES_DOT_H.bak  
     fi  
     cat $PACKAGES_DOT_H \  
         | awk 'BEGIN{p=1;} ($1=="C===" && $2=="GENMAKE"){p=0;} {if (p==1) print $0}' \  
         > $PACKAGES_DOT_H.tmp  
 fi  
 cat <<EOF >>$PACKAGES_DOT_H.tmp  
857  C=== GENMAKE v2 ===  C=== GENMAKE v2 ===
858  C  The following defines have been set by GENMAKE, so please do not  C  The following defines have been set by GENMAKE, so please do not
859  C  edit anything below these comments.  In general, you should  C  edit anything below these comments.  In general, you should
860  C  add or remove packages by re-running genmake with different  C  add or remove packages by re-running genmake with different
861  C  "-enable" and/or "-disable" options.  C  "-enable" and/or "-disable" options.
862    
863    #ifndef PACKAGES_H
864    #define PACKAGES_H
865    
866  C  Packages disabled by genmake:  C  Packages disabled by genmake:
867  EOF  EOF
868  #  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 828  for n in $names ; do Line 882  for n in $names ; do
882          done          done
883          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
884              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`
885              echo "#undef $undef" >> $PACKAGES_DOT_H.tmp              echo "#undef $undef" >> $PACKAGES_DOT_H".tmp"
886  #           DEFINES="$DEFINES -U$undef"  #           DEFINES="$DEFINES -U$undef"
887    
888  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
# Line 848  for n in $names ; do Line 902  for n in $names ; do
902          fi          fi
903      fi      fi
904  done  done
905  cat <<EOF >>$PACKAGES_DOT_H.tmp  cat <<EOF >>$PACKAGES_DOT_H".tmp"
906    
907  C  Packages enabled by genmake:  C  Packages enabled by genmake:
908  EOF  EOF
909  for i in $PACKAGES ; do  for i in $PACKAGES ; do
910      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`
911      echo "#define $def" >> $PACKAGES_DOT_H.tmp      echo "#define $def" >> $PACKAGES_DOT_H".tmp"
912      DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
913    
914  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
915      case $i in      case $i in
916          aim_v23)          aim_v23)
917              echo "#define   ALLOW_AIM" >> $PACKAGES_DOT_H.tmp              echo "#define   ALLOW_AIM" >> $PACKAGES_DOT_H".tmp"
918              DEFINES="$DEFINES -DALLOW_AIM"              DEFINES="$DEFINES -DALLOW_AIM"
919              echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)"              echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)"
920              ;;              ;;
921      esac      esac
922  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
923    
924  done  done
925  mv -f $PACKAGES_DOT_H.tmp $PACKAGES_DOT_H  cat <<EOF >>$PACKAGES_DOT_H".tmp"
926    
927    #endif /* PACKAGES_H */
928    EOF
929    
930    if test ! -f $PACKAGES_DOT_H ; then
931        mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
932    else
933        cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
934        RETVAL=$?
935        if test "x$RETVAL" = x0 ; then
936            rm -f $PACKAGES_DOT_H".tmp"
937        else
938            mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak"
939            mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
940        fi
941    fi
942    
943  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS"
944  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
945  STANDARDDIRS=${STANDARDDIRS:-"eesupp model"}  if test "x$STANDARDDIRS" = x ; then
946        STANDARDDIRS="eesupp model"
947    fi
948  for d in $STANDARDDIRS ; do  for d in $STANDARDDIRS ; do
949      adr="$ROOTDIR/$d/src"      adr="$ROOTDIR/$d/src"
950      if test ! -d $adr ; then      if test ! -d $adr ; then
# Line 892  for d in $STANDARDDIRS ; do Line 964  for d in $STANDARDDIRS ; do
964      fi      fi
965  done  done
966    
967  echo "  Searching for CPP_OPTIONS.h (macros and flags for configuring the model):"  echo " Searching for CPP_OPTIONS.h in order to warn about the presence"
968    echo " of \"#define ALLOW_PKGNAME\"-type statements:"
969  CPP_OPTIONS=  CPP_OPTIONS=
970  spaths=". $INCLUDEDIRS"  spaths=". $INCLUDEDIRS"
971  for i in $spaths ; do  for i in $spaths ; do
# Line 901  for i in $spaths ; do Line 974  for i in $spaths ; do
974      if test -f $try -a -r $try ; then      if test -f $try -a -r $try ; then
975          echo "    found CPP_OPTIONS=\"$try\""          echo "    found CPP_OPTIONS=\"$try\""
976          CPP_OPTIONS="$try"          CPP_OPTIONS="$try"
 #aja    if test "x$i" != "x." ; then  
 #aja        cp -f $CPP_OPTIONS .  
 #aja    fi  
977          break          break
978      fi      fi
979  done  done
# Line 983  echo "" >> csrclist.inc Line 1053  echo "" >> csrclist.inc
1053  echo "" >> f90srclist.inc  echo "" >> f90srclist.inc
1054  echo "" >> hlist.inc  echo "" >> hlist.inc
1055    
 echo $DEFINES  
   
1056  if test -e $MAKEFILE ; then  if test -e $MAKEFILE ; then
1057      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
1058  fi  fi
# Line 1106  clean: Line 1174  clean:
1174  Clean:  Clean:
1175          @make clean          @make clean
1176          @make cleanlinks          @make cleanlinks
1177          -rm -f Makefile.bak gm_state gm_optfile make.log PACKAGES.h*          -rm -f Makefile.bak genmake_state genmake_optfile make.log
1178  CLEAN:  CLEAN:
1179          @make Clean          @make Clean
1180          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
# Line 1176  printf "\n===  Done  ===\n" Line 1244  printf "\n===  Done  ===\n"
1244    
1245  #  Write the "state" for future records  #  Write the "state" for future records
1246  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" != xf ; then
1247      echo -n "" > gm_state      echo -n "" > genmake_state
1248      for i in $gm_state ; do      for i in $gm_state ; do
1249          t1="t2=\$$i"          t1="t2=\$$i"
1250          eval $t1          eval $t1
1251          echo "$i='$t2'" >> gm_state          echo "$i='$t2'" >> genmake_state
1252      done      done
1253  fi  fi

Legend:
Removed from v.1.11.2.1  
changed lines
  Added in v.1.11.2.12

  ViewVC Help
Powered by ViewVC 1.1.22