/[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 by edhill, Mon Sep 29 16:15:23 2003 UTC revision 1.11.2.3 by edhill, Wed Oct 1 20:47:26 2003 UTC
# Line 8  Line 8 
8  #   modified by aja 01/00  #   modified by aja 01/00
9  #   rewritten in bash by eh3 08/03  #   rewritten in bash by eh3 08/03
10    
11    # Search for particular CPP #cmds associated with packages
12    # usage: test_for_package_in_cpp_options CPP_file package_name
13    test_for_package_in_cpp_options() {
14        cpp_options=$1
15        pkg=$2
16        grep -i "#define.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1
17        RETVAL=$?
18        if test "x${RETVAL}" = x0 ; then
19            echo "Error: In $cpp_options there is an illegal line: #define ALLOW_$pkg"
20            exit 99
21        fi
22        grep -i "#undef.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1
23        RETVAL=$?
24        if test "x${RETVAL}" = x0 ; then
25            echo "Error: In $cpp_options there is an illegal line: #undef ALLOW_$pkg"
26            exit 99
27        fi
28        grep -i "#define.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1
29        RETVAL=$?
30        if test "x${RETVAL}" = x0 ; then
31            echo "Error: In $cpp_options there is an illegal line: #define DISABLE_$pkg"
32            exit 99
33        fi
34        grep -i "#undef.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1
35        RETVAL=$?
36        if test "x${RETVAL}" = x0 ; then
37            echo "Error: In $cpp_options there is an illegal line: #undef DISABLE_$pkg"
38            exit 99
39       fi
40    }
41    
42    
43  # Guess possible config options for this host  # Guess possible config options for this host
44  find_possible_configs()  {  find_possible_configs()  {
# Line 603  fi Line 634  fi
634  source ./.pd_tmp  source ./.pd_tmp
635  rm -f ./.pd_tmp  rm -f ./.pd_tmp
636    
637    #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"
638    #  file should eventually be added so that, for convenience, one can
639    #  specify groups of packages using names like "ocean" and "atmosphere".
640  echo  -n "  checking default package list:  "  echo  -n "  checking default package list:  "
641  if test "x${PDEFAULT}" = x ; then  if test "x${PDEFAULT}" = x ; then
642        for i in "." $MODS ; do
643            if test -r $i"/packages.conf" ; then
644                    PDEFAULT=$i"/packages.conf"
645                    break
646            fi
647        done
648    fi
649    if test "x${PDEFAULT}" = x ; then
650      PDEFAULT="$ROOTDIR/pkg/pkg_default"      PDEFAULT="$ROOTDIR/pkg/pkg_default"
651  fi  fi
652  if test "x${PDEFAULT}" = xNONE ; then  if test "x${PDEFAULT}" = xNONE ; then
# Line 645  for p in $PACKAGES ; do Line 687  for p in $PACKAGES ; do
687  done  done
688  PACKAGES="$pack"  PACKAGES="$pack"
689  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
690  rm -f ./.tmp_pack  echo "" > ./.tmp_pack
691  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
692  for i in $PACKAGES ; do  for i in $PACKAGES ; do
693      if test ! -d "$ROOTDIR/pkg/$i" ; then      if test ! -d "$ROOTDIR/pkg/$i" ; then
# Line 761  done Line 803  done
803  # done  # done
804  # echo  # echo
805    
806  echo "  Searching for CPP_OPTIONS.h (macros and flags for configuring the model):"  # Create a list of #define and #undef to enable/disable packages
807  CPP_OPTIONS=  PACKAGES_DOT_H=PACKAGES.h
808  spaths=". $SOURCEDIRS"  if test -e $PACKAGES_DOT_H ; then
809  for i in $spaths ; do      cat $PACKAGES_DOT_H \
     try="$i/CPP_OPTIONS.h"  
     #  echo -n "    trying $try : "  
     if test -f $try -a -r $try ; then  
         echo "    found CPP_OPTIONS=\"$try\""  
         CPP_OPTIONS="$try"  
         if test "x$i" != "x." ; then  
             cp -f $CPP_OPTIONS .  
         fi  
         break  
     fi  
 done  
 if test "x$CPP_OPTIONS" = x ; then  
     echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"  
     exit 1  
 fi  
 if test -e CPP_OPTIONS.h ; then  
     if test ! -e CPP_OPTIONS.h.bak ; then  
         cp -f CPP_OPTIONS.h CPP_OPTIONS.h.bak  
     fi  
     cat CPP_OPTIONS.h \  
810          | awk 'BEGIN{p=1;} ($1=="C===" && $2=="GENMAKE"){p=0;} {if (p==1) print $0}' \          | awk 'BEGIN{p=1;} ($1=="C===" && $2=="GENMAKE"){p=0;} {if (p==1) print $0}' \
811          > CPP_OPTIONS.h.tmp          > $PACKAGES_DOT_H".tmp"
812  fi  fi
813  cat <<EOF >>CPP_OPTIONS.h.tmp  cat <<EOF >>$PACKAGES_DOT_H".tmp"
814  C=== GENMAKE v2 ===  C=== GENMAKE v2 ===
815  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
816  C  edit anything below these comments.  In general, you should  C  edit anything below these comments.  In general, you should
# Line 814  for n in $names ; do Line 836  for n in $names ; do
836          done          done
837          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
838              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`
839              echo "#undef $undef" >> CPP_OPTIONS.h.tmp              echo "#undef $undef" >> $PACKAGES_DOT_H".tmp"
840    #           DEFINES="$DEFINES -U$undef"
841    
842  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
843              case $n in              case $n in
# Line 824  for n in $names ; do Line 847  for n in $names ; do
847                  mom_vecinv)                  mom_vecinv)
848                      DEFINES="$DEFINES -DDISABLE_MOM_VECINV"                      DEFINES="$DEFINES -DDISABLE_MOM_VECINV"
849                      ;;                      ;;
                 generic_advdiff)  
                     DEFINES="$DEFINES -DDISABLE_GENERIC_ADVDIFF"  
                     ;;  
850                  debug)                  debug)
851                      DEFINES="$DEFINES -DDISABLE_DEBUGMODE"                      DEFINES="$DEFINES -DDISABLE_DEBUGMODE"
852                      ;;                      ;;
# Line 836  for n in $names ; do Line 856  for n in $names ; do
856          fi          fi
857      fi      fi
858  done  done
859  cat <<EOF >>CPP_OPTIONS.h.tmp  cat <<EOF >>$PACKAGES_DOT_H".tmp"
860    
861  C  Packages enabled by genmake:  C  Packages enabled by genmake:
862  EOF  EOF
863  for i in $PACKAGES ; do  for i in $PACKAGES ; do
864      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`
865      echo "#define $def" >> CPP_OPTIONS.h.tmp      echo "#define $def" >> $PACKAGES_DOT_H".tmp"
866    #eh3 DEFINES="$DEFINES -D$def"
867    
868  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
869      case $i in      case $i in
870          aim_v23)          aim_v23)
871              echo "#define   ALLOW_AIM" >> CPP_OPTIONS.h.tmp              echo "#define   ALLOW_AIM" >> $PACKAGES_DOT_H".tmp"
872                DEFINES="$DEFINES -DALLOW_AIM"
873                echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)"
874              ;;              ;;
875      esac      esac
876  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
877    
878  done  done
879  mv -f CPP_OPTIONS.h.tmp CPP_OPTIONS.h  cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
880    RETVAL=$?
881    if test "x$RETVAL" = x0 ; then
882        mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H".bak"
883        mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
884    fi
885    
886  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS"
887  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
# Line 877  for d in $STANDARDDIRS ; do Line 905  for d in $STANDARDDIRS ; do
905      fi      fi
906  done  done
907    
908    echo " Searching for CPP_OPTIONS.h in order to warn about the presence"
909    echo " of \"#define ALLOW_PKGNAME\"-type statements:"
910    CPP_OPTIONS=
911    spaths=". $INCLUDEDIRS"
912    for i in $spaths ; do
913        try="$i/CPP_OPTIONS.h"
914        #  echo -n "    trying $try : "
915        if test -f $try -a -r $try ; then
916            echo "    found CPP_OPTIONS=\"$try\""
917            CPP_OPTIONS="$try"
918            break
919        fi
920    done
921    if test "x$CPP_OPTIONS" = x ; then
922        echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"
923        exit 1
924    fi
925    # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
926    names=`ls -1 "$ROOTDIR/pkg"`
927    for n in $names ; do
928        test_for_package_in_cpp_options $CPP_OPTIONS $n
929    done
930    
931    
932  echo  echo
933  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
934  echo "  setting INCLUDES"  echo "  setting INCLUDES"
935  for i in $INCLUDEDIRS ; do  for i in $INCLUDEDIRS ; do
936      if test -d $i ; then      if ! test -d $i ; then
937          INCLUDES="$INCLUDES -I$i"  #       INCLUDES="$INCLUDES -I$i"
938      else  #   else
939          echo "Warning: can't find INCLUDEDIRS=\"$i\""          echo "Warning: can't find INCLUDEDIRS=\"$i\""
940      fi      fi
941  done  done
# Line 1064  clean: Line 1115  clean:
1115  Clean:  Clean:
1116          @make clean          @make clean
1117          @make cleanlinks          @make cleanlinks
1118          -rm -f Makefile.bak          -rm -f Makefile.bak gm_state gm_optfile make.log PACKAGES.h*
1119  CLEAN:  CLEAN:
1120          @make Clean          @make Clean
1121          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
1122          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
1123          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
1124          -rm -f \$(EXECUTABLE)          -rm -f \$(EXECUTABLE) output.txt
1125    
1126  makefile:  makefile:
1127          ${0} $@          ${0} $@

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.11.2.3

  ViewVC Help
Powered by ViewVC 1.1.22