/[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.2 by edhill, Wed Oct 1 19:33:01 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 645  for p in $PACKAGES ; do Line 676  for p in $PACKAGES ; do
676  done  done
677  PACKAGES="$pack"  PACKAGES="$pack"
678  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
679  rm -f ./.tmp_pack  echo "" > ./.tmp_pack
680  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
681  for i in $PACKAGES ; do  for i in $PACKAGES ; do
682      if test ! -d "$ROOTDIR/pkg/$i" ; then      if test ! -d "$ROOTDIR/pkg/$i" ; then
# Line 761  done Line 792  done
792  # done  # done
793  # echo  # echo
794    
795  echo "  Searching for CPP_OPTIONS.h (macros and flags for configuring the model):"  # Create a list of #define and #undef to enable/disable packages
796  CPP_OPTIONS=  PACKAGES_DOT_H=PACKAGES.h
797  spaths=". $SOURCEDIRS"  if test -e $PACKAGES_DOT_H ; then
798  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 \  
799          | 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}' \
800          > CPP_OPTIONS.h.tmp          > $PACKAGES_DOT_H".tmp"
801  fi  fi
802  cat <<EOF >>CPP_OPTIONS.h.tmp  cat <<EOF >>$PACKAGES_DOT_H".tmp"
803  C=== GENMAKE v2 ===  C=== GENMAKE v2 ===
804  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
805  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 825  for n in $names ; do
825          done          done
826          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
827              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`
828              echo "#undef $undef" >> CPP_OPTIONS.h.tmp              echo "#undef $undef" >> $PACKAGES_DOT_H".tmp"
829    #           DEFINES="$DEFINES -U$undef"
830    
831  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
832              case $n in              case $n in
# Line 824  for n in $names ; do Line 836  for n in $names ; do
836                  mom_vecinv)                  mom_vecinv)
837                      DEFINES="$DEFINES -DDISABLE_MOM_VECINV"                      DEFINES="$DEFINES -DDISABLE_MOM_VECINV"
838                      ;;                      ;;
                 generic_advdiff)  
                     DEFINES="$DEFINES -DDISABLE_GENERIC_ADVDIFF"  
                     ;;  
839                  debug)                  debug)
840                      DEFINES="$DEFINES -DDISABLE_DEBUGMODE"                      DEFINES="$DEFINES -DDISABLE_DEBUGMODE"
841                      ;;                      ;;
# Line 836  for n in $names ; do Line 845  for n in $names ; do
845          fi          fi
846      fi      fi
847  done  done
848  cat <<EOF >>CPP_OPTIONS.h.tmp  cat <<EOF >>$PACKAGES_DOT_H".tmp"
849    
850  C  Packages enabled by genmake:  C  Packages enabled by genmake:
851  EOF  EOF
852  for i in $PACKAGES ; do  for i in $PACKAGES ; do
853      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`
854      echo "#define $def" >> CPP_OPTIONS.h.tmp      echo "#define $def" >> $PACKAGES_DOT_H".tmp"
855    #eh3 DEFINES="$DEFINES -D$def"
856    
857  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
858      case $i in      case $i in
859          aim_v23)          aim_v23)
860              echo "#define   ALLOW_AIM" >> CPP_OPTIONS.h.tmp              echo "#define   ALLOW_AIM" >> $PACKAGES_DOT_H".tmp"
861                DEFINES="$DEFINES -DALLOW_AIM"
862                echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)"
863              ;;              ;;
864      esac      esac
865  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
866    
867  done  done
868  mv -f CPP_OPTIONS.h.tmp CPP_OPTIONS.h  cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
869    RETVAL=$?
870    if test "x$RETVAL" = x0 ; then
871        mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H".bak"
872        mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
873    fi
874    
875  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS"
876  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
# Line 877  for d in $STANDARDDIRS ; do Line 894  for d in $STANDARDDIRS ; do
894      fi      fi
895  done  done
896    
897    echo " Searching for CPP_OPTIONS.h in order to warn about the presence"
898    echo " of \"#define ALLOW_PKGNAME\"-type statements:"
899    CPP_OPTIONS=
900    spaths=". $INCLUDEDIRS"
901    for i in $spaths ; do
902        try="$i/CPP_OPTIONS.h"
903        #  echo -n "    trying $try : "
904        if test -f $try -a -r $try ; then
905            echo "    found CPP_OPTIONS=\"$try\""
906            CPP_OPTIONS="$try"
907            break
908        fi
909    done
910    if test "x$CPP_OPTIONS" = x ; then
911        echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"
912        exit 1
913    fi
914    # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
915    names=`ls -1 "$ROOTDIR/pkg"`
916    for n in $names ; do
917        test_for_package_in_cpp_options $CPP_OPTIONS $n
918    done
919    
920    
921  echo  echo
922  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
923  echo "  setting INCLUDES"  echo "  setting INCLUDES"
924  for i in $INCLUDEDIRS ; do  for i in $INCLUDEDIRS ; do
925      if test -d $i ; then      if ! test -d $i ; then
926          INCLUDES="$INCLUDES -I$i"  #       INCLUDES="$INCLUDES -I$i"
927      else  #   else
928          echo "Warning: can't find INCLUDEDIRS=\"$i\""          echo "Warning: can't find INCLUDEDIRS=\"$i\""
929      fi      fi
930  done  done
# Line 1064  clean: Line 1104  clean:
1104  Clean:  Clean:
1105          @make clean          @make clean
1106          @make cleanlinks          @make cleanlinks
1107          -rm -f Makefile.bak          -rm -f Makefile.bak gm_state gm_optfile make.log PACKAGES.h*
1108  CLEAN:  CLEAN:
1109          @make Clean          @make Clean
1110          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
1111          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
1112          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
1113          -rm -f \$(EXECUTABLE)          -rm -f \$(EXECUTABLE) output.txt
1114    
1115  makefile:  makefile:
1116          ${0} $@          ${0} $@

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

  ViewVC Help
Powered by ViewVC 1.1.22