/[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.1 by adcroft, Wed Oct 1 18:44:48 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      if test ! -e $PACKAGES_DOT_H.bak ; then
799      try="$i/CPP_OPTIONS.h"          cp -f $PACKAGES_DOT_H $PACKAGES_DOT_H.bak
     #  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  
800      fi      fi
801      cat CPP_OPTIONS.h \      cat $PACKAGES_DOT_H \
802          | 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}' \
803          > CPP_OPTIONS.h.tmp          > $PACKAGES_DOT_H.tmp
804  fi  fi
805  cat <<EOF >>CPP_OPTIONS.h.tmp  cat <<EOF >>$PACKAGES_DOT_H.tmp
806  C=== GENMAKE v2 ===  C=== GENMAKE v2 ===
807  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
808  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 828  for n in $names ; do
828          done          done
829          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
830              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`
831              echo "#undef $undef" >> CPP_OPTIONS.h.tmp              echo "#undef $undef" >> $PACKAGES_DOT_H.tmp
832    #           DEFINES="$DEFINES -U$undef"
833    
834  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
835              case $n in              case $n in
# Line 824  for n in $names ; do Line 839  for n in $names ; do
839                  mom_vecinv)                  mom_vecinv)
840                      DEFINES="$DEFINES -DDISABLE_MOM_VECINV"                      DEFINES="$DEFINES -DDISABLE_MOM_VECINV"
841                      ;;                      ;;
                 generic_advdiff)  
                     DEFINES="$DEFINES -DDISABLE_GENERIC_ADVDIFF"  
                     ;;  
842                  debug)                  debug)
843                      DEFINES="$DEFINES -DDISABLE_DEBUGMODE"                      DEFINES="$DEFINES -DDISABLE_DEBUGMODE"
844                      ;;                      ;;
# Line 836  for n in $names ; do Line 848  for n in $names ; do
848          fi          fi
849      fi      fi
850  done  done
851  cat <<EOF >>CPP_OPTIONS.h.tmp  cat <<EOF >>$PACKAGES_DOT_H.tmp
852    
853  C  Packages enabled by genmake:  C  Packages enabled by genmake:
854  EOF  EOF
855  for i in $PACKAGES ; do  for i in $PACKAGES ; do
856      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`
857      echo "#define $def" >> CPP_OPTIONS.h.tmp      echo "#define $def" >> $PACKAGES_DOT_H.tmp
858        DEFINES="$DEFINES -D$def"
859    
860  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
861      case $i in      case $i in
862          aim_v23)          aim_v23)
863              echo "#define   ALLOW_AIM" >> CPP_OPTIONS.h.tmp              echo "#define   ALLOW_AIM" >> $PACKAGES_DOT_H.tmp
864                DEFINES="$DEFINES -DALLOW_AIM"
865                echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)"
866              ;;              ;;
867      esac      esac
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    
870  done  done
871  mv -f CPP_OPTIONS.h.tmp CPP_OPTIONS.h  mv -f $PACKAGES_DOT_H.tmp $PACKAGES_DOT_H
872    
873  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS"
874  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
# Line 877  for d in $STANDARDDIRS ; do Line 892  for d in $STANDARDDIRS ; do
892      fi      fi
893  done  done
894    
895    echo "  Searching for CPP_OPTIONS.h (macros and flags for configuring the model):"
896    CPP_OPTIONS=
897    spaths=". $INCLUDEDIRS"
898    for i in $spaths ; do
899        try="$i/CPP_OPTIONS.h"
900        #  echo -n "    trying $try : "
901        if test -f $try -a -r $try ; then
902            echo "    found CPP_OPTIONS=\"$try\""
903            CPP_OPTIONS="$try"
904    #aja    if test "x$i" != "x." ; then
905    #aja        cp -f $CPP_OPTIONS .
906    #aja    fi
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 943  echo "" >> csrclist.inc Line 983  echo "" >> csrclist.inc
983  echo "" >> f90srclist.inc  echo "" >> f90srclist.inc
984  echo "" >> hlist.inc  echo "" >> hlist.inc
985    
986    echo $DEFINES
987    
988  if test -e $MAKEFILE ; then  if test -e $MAKEFILE ; then
989      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
990  fi  fi
# Line 1064  clean: Line 1106  clean:
1106  Clean:  Clean:
1107          @make clean          @make clean
1108          @make cleanlinks          @make cleanlinks
1109          -rm -f Makefile.bak          -rm -f Makefile.bak gm_state gm_optfile make.log PACKAGES.h*
1110  CLEAN:  CLEAN:
1111          @make Clean          @make Clean
1112          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
1113          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
1114          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
1115          -rm -f \$(EXECUTABLE)          -rm -f \$(EXECUTABLE) output.txt
1116    
1117  makefile:  makefile:
1118          ${0} $@          ${0} $@

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

  ViewVC Help
Powered by ViewVC 1.1.22