/[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.9 by adcroft, Fri Sep 26 18:16:38 2003 UTC revision 1.13 by edhill, Fri Oct 10 18:38:57 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    # 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      p_PLATFORM=`uname`"-"`uname -m`      tmp1=`uname`"_"`uname -m`
74      echo "The platform appears to be:"      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
75      echo "  "$p_PLATFORM      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")`
77      p_LN=      echo "  The platform appears to be:  $PLATFORM"
78    #     if test "x$OFLIST" = x ; then
79    #       echo "  No pre-defined options files were found matching this platform"
80    #       echo "  but examples for other platforms can be found in:"
81    #       echo "    $ROOTDIR/tools/build_options"
82    #     else
83    #       echo "  Options files (located in $ROOTDIR/tools/build_options) that"
84    #       echo "  may work with this machine are:"
85    #       for i in $OFLIST ; do
86    #           echo "    $i"
87    #       done
88    #     fi
89        
90      echo "test" > test      echo "test" > test
91      ln -s ./test link      ln -s ./test link
92      RETVAL=$?      RETVAL=$?
93      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
94          p_LN="ln -s"          LN="ln -s"
95        else
96            echo "Error: \"ln -s\" does not appear to work on this system!"
97            echo "  For help, please contact <MITgcm-support@mitgcm.org>."
98            exit 1
99      fi      fi
100      rm -f test link      rm -f test link
101    
102      p_CPP=`which cpp`      if test "x$CPP" = x ; then
103                CPP="cpp -traditional -P"
     RETVAL=$?  
     if test "x${RETVAL}" = x0 ; then  
         p_LN="ln -s"  
104      fi      fi
     rm -f test link  
105    
106      # look for possible fortran compilers      # look for possible fortran compilers
107        tmp="$MITGCM_FC $FC g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"
108      p_FC=      p_FC=
109      for c in f77 g77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 ; do      for c in $tmp ; do
110          which $c > /dev/null 2>&1          rm -f ./hello.f ./hello
111            cat >> hello.f <<EOF
112          program hello
113          do i=1,3
114            print *, 'hello world : ', i
115          enddo
116          end
117    EOF
118            $c -o hello hello.f > /dev/null 2>&1
119          RETVAL=$?          RETVAL=$?
120          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
121              p_FC="$p_FC $c"              p_FC="$p_FC $c"
122          fi          fi
123      done      done
     echo "Possible FORTRAN compilers appear to be:  "  
124      if test "x${p_FC}" = x ; then      if test "x${p_FC}" = x ; then
125          echo "  None found!!!"          cat 1>&2 <<EOF
126    
127    Error: No Fortran compilers were found in your path.  Please specify one using:
128    
129        1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
130        2) a command-line option (eg. "-fc NAME"), or
131        3) the MITGCM_FC environment variable.
132    
133    EOF
134            exit 1
135      else      else
136          echo "  "$p_FC          echo "  The possible FORTRAN compilers found in your path are:"
137            echo "   "$p_FC
138            if test "x$FC" = x ; then
139                FC=`echo $p_FC | awk '{print $1}'`
140            fi
141      fi      fi
142    
143      # look for possible MPI libraries      for i in $p_FC ; do
144      mpi_libs=          p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
145      mpi_fort=`which mpif77 2>/dev/null`          if test -r $p_OF ; then
146      RETVAL=$?              OPTFILE=$p_OF
147      if test "x${RETVAL}" = x0 ; then              echo "  The options file:  $p_OF"
148          cat >>test.f <<EOF              echo "    appears to match so we'll use it."
149        PROGRAM HELLO              break
       DO 10, I=1,10  
       PRINT *,'Hello World'  
    10 CONTINUE  
       STOP  
       END  
 EOF  
         eval "$mpi_fort -showme test.f > out"  
         RETVAL=$?  
         if test "x${RETVAL}" = x0 ; then  
             a=`cat out`  
             for i in $a ; do  
                 case $i in  
                     -*)  
                         mpi_libs="$mpi_libs $i" ;;  
                 esac  
             done  
             echo "The MPI libs appear to be:"  
             echo "  "$mpi_libs  
150          fi          fi
151          rm -f test.f out      done
152        if test "x$OPTFILE" = x ; then
153            cat 1>&2 <<EOF
154    
155    Error: No options file was found in:  $ROOTDIR/tools/build_options/
156      that matches this platform ("$PLATFORM") and the compilers found in
157      your path.  Please specify an "optfile" using:
158    
159        1) the command line (eg. "-optfile=path/to/OPTFILE"), or
160        2) the MITGCM_OF environment variable.
161    
162      If you need help, please contact the developers at <MITgcm-support@mitgcm.org>.
163    
164    EOF
165            exit 1
166      fi      fi
167        
168    #     # look for possible MPI libraries
169    #     mpi_libs=
170    #     mpi_fort=`which mpif77 2>/dev/null`
171    #     RETVAL=$?
172    #     if test "x${RETVAL}" = x0 ; then
173    #       cat >>test.f <<EOF
174    #       PROGRAM HELLO
175    #       DO 10, I=1,10
176    #       PRINT *,'Hello World'
177    #    10 CONTINUE
178    #       STOP
179    #       END
180    # EOF
181    #       eval "$mpi_fort -showme test.f > out"
182    #       RETVAL=$?
183    #       if test "x${RETVAL}" = x0 ; then
184    #           a=`cat out`
185    #           for i in $a ; do
186    #               case $i in
187    #                   -*)
188    #                       mpi_libs="$mpi_libs $i" ;;
189    #               esac
190    #           done
191    #           echo "The MPI libs appear to be:"
192    #           echo "  "$mpi_libs
193    #       fi
194    #       rm -f test.f out
195    #     fi
196    
197  }  }
198    
# Line 123  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 172  S64= Line 290  S64=
290  KPP=  KPP=
291  FC=  FC=
292  LINK=  LINK=
293    DEFINES="-DWORDLENGTH=4"
294  PACKAGES=  PACKAGES=
295  ENABLE=  ENABLE=
296  DISABLE=  DISABLE=
297  MAKEFILE=  MAKEFILE=
298  MAKEDEPEND=  MAKEDEPEND=
299  PDEPEND=  PDEPEND=
300  DUMPSTATE=f  DUMPSTATE=t
301  PDEFAULT=  PDEFAULT=
302  OPTFILE=  OPTFILE=
303  INCLUDES="-I."  INCLUDES="-I."
# Line 196  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 206  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 314  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 330  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 361  for ac_option ; do Line 497  for ac_option ; do
497            
498  done  done
499    
500    if test -f ./.genmakerc ; then
501        echo
502        echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
503        echo "  file.  This file format is no longer supported.  Please see:"
504        echo
505        echo "    http://mitgcm.org/devel_HOWTO/"
506        echo
507        echo "  for directions on how to setup and use the new \"genmake2\" input"
508        echo "  files and send an email to MITgcm-support@mitgcm.org if you want help."
509        echo
510    fi
511    
512    if test "x${ROOTDIR}" = x ; then
513        if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
514            ROOTDIR=".."
515        else
516            for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
517                if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then
518                    ROOTDIR=$d
519                    echo -n "Warning:  ROOTDIR was not specified but there appears to be"
520                    echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."
521                    break
522                fi
523            done
524        fi
525    fi
526    if test "x${ROOTDIR}" = x ; then
527        echo "Error: Cannot determine ROOTDIR for MITgcm code."
528        echo "  Please specify a ROOTDIR using either an options "
529        echo "  file or a command-line option."
530        exit 1
531    fi
532    if test ! -d ${ROOTDIR} ; then
533        echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!"
534        exit 1
535    fi
536    
537  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
538  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
539      echo "Warning: no OPTFILE specified so we'll look for possible settings"      if test "x$MITGCM_OF" = x ; then
540      printf "\n===  Searching for possible settings for OPTFILE  ===\n"          echo "Warning: no OPTFILE specified so we'll look for possible settings"
541      find_possible_configs          printf "\n===  Searching for possible settings for OPTFILE  ===\n"
542  else          find_possible_configs
     if test "x$OPTFILE" = xNONE ; then  
         echo "    OPTFILE=NONE so we'll try to use default settings"  
543      else      else
544          if test -f "$OPTFILE" -a -r "$OPTFILE" ; then          OPTFILE=$MITGCM_OF
545              echo "    using OPTFILE=\"$OPTFILE\""      fi
546              source "$OPTFILE"  fi
547              RETVAL=$?  if test "x$OPTFILE" != xNONE ; then
548              if test "x$RETVAL" != x0 ; then      if test -f "$OPTFILE" -a -r "$OPTFILE" ; then
549                  echo -n "Error: failed to source OPTFILE \"$OPTFILE\""          echo "    using OPTFILE=\"$OPTFILE\""
550                  echo "--please check that variable syntax is bash-compatible"          source "$OPTFILE"
551                  exit 1          RETVAL=$?
552              fi          if test "x$RETVAL" != x0 ; then
553              if test "x$DUMPSTATE" != xf ; then              echo -n "Error: failed to source OPTFILE \"$OPTFILE\""
554                  cp -f $OPTFILE "gm_optfile"              echo "--please check that variable syntax is bash-compatible"
             fi  
         else  
             echo "Error: can't read OPTFILE=\"$OPTFILE\""  
555              exit 1              exit 1
556          fi          fi
557            if test "x$DUMPSTATE" != xf ; then
558                cp -f $OPTFILE "genmake_optfile"
559            fi
560        else
561            echo "Error: can't read OPTFILE=\"$OPTFILE\""
562            exit 1
563      fi      fi
564  fi  fi
565    
# Line 397  if test "x$FC" = x ; then Line 571  if test "x$FC" = x ; then
571  Error: no Fortran compiler: please specify using one of the following:  Error: no Fortran compiler: please specify using one of the following:
572    1) within the options file ("FC=...") as specified by "-of=OPTFILE"    1) within the options file ("FC=...") as specified by "-of=OPTFILE"
573    2) the "-fc=XXX" command-line option    2) the "-fc=XXX" command-line option
574    3) the "./gm_local" file    3) the "./genmake_local" file
575  EOF  EOF
576      exit 1      exit 1
577  fi  fi
# Line 405  if test "x$LINK" = x ; then Line 579  if test "x$LINK" = x ; then
579      LINK=$FC      LINK=$FC
580  fi  fi
581  if test "x$CPP" = x ; then  if test "x$CPP" = x ; then
582        CPP="cpp"
583    fi
584    echo "#define A a" | $CPP > test_cpp 2>&1
585    RETVAL=$?
586    if test "x$RETVAL" != x0 ; then
587      cat <<EOF 1>&2      cat <<EOF 1>&2
588    
589  Error: no C pre-processor: please specify using one of the following:  Error: C pre-processor "$CPP" failed the test case: please specify using:
590    
591    1) within the options file ("CPP=...") as specified by "-of=OPTFILE"    1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
592    2) the "./gm_local" file    2) the "./genmake_local" file
 EOF  
     exit 1  
 fi  
 if test "x$S64" = x ; then  
     cat <<EOF 1>&2  
593    
 Error: no C pre-processor: please specify using one of the following:  
   1) within the options file ("S64=...") as specified by "-of=OPTFILE"  
   2) the "./gm_local" file  
594  EOF  EOF
595      exit 1      exit 1
596    else
597        rm -f test_cpp
598    fi
599    if test "x$MAKEDEPEND" = x ; then
600        MAKEDEPEND=makedepend
601  fi  fi
   
602    
603  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
604  echo -n "  Adding MODS directories:  "  echo -n "  Adding MODS directories:  "
# Line 446  if test "x${PLATFORM}" = x ; then Line 622  if test "x${PLATFORM}" = x ; then
622      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
623  fi  fi
624    
 if test "x${ROOTDIR}" = x ; then  
     if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then  
         ROOTDIR=".."  
     else  
         for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do  
             if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then  
                 ROOTDIR=$d  
                 echo -n "Warning:  ROOTDIR was not specified but there appears to be"  
                 echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."  
                 break  
             fi  
         done  
     fi  
 fi  
 if test "x${ROOTDIR}" = x ; then  
     echo "Error: Cannot determine ROOTDIR for MITgcm code."  
     echo "  Please specify a ROOTDIR using either an options "  
     echo "  file or a command-line option."  
     exit 1  
 fi  
 if test ! -d ${ROOTDIR} ; then  
     echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!"  
     exit 1  
 fi  
   
625  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
626      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then
627          EXEDIR=../exe          EXEDIR=../exe
# Line 490  if test ! -d ${TOOLSDIR} ; then Line 641  if test ! -d ${TOOLSDIR} ; then
641      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"
642      exit 1      exit 1
643  fi  fi
644    if test "x$S64" = x ; then
645        S64='$(TOOLSDIR)/set64bitConst.sh'
646    fi
647    
648  EXECUTABLE=${EXECUTABLE:-mitgcmuv}  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
649    
# Line 538  fi Line 692  fi
692  source ./.pd_tmp  source ./.pd_tmp
693  rm -f ./.pd_tmp  rm -f ./.pd_tmp
694    
695    #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"
696    #  file should eventually be added so that, for convenience, one can
697    #  specify groups of packages using names like "ocean" and "atmosphere".
698  echo  -n "  checking default package list:  "  echo  -n "  checking default package list:  "
699  if test "x${PDEFAULT}" = x ; then  if test "x${PDEFAULT}" = x ; then
700        for i in "." $MODS ; do
701            if test -r $i"/packages.conf" ; then
702                    PDEFAULT=$i"/packages.conf"
703                    break
704            fi
705        done
706    fi
707    if test "x${PDEFAULT}" = x ; then
708      PDEFAULT="$ROOTDIR/pkg/pkg_default"      PDEFAULT="$ROOTDIR/pkg/pkg_default"
709  fi  fi
710  if test "x${PDEFAULT}" = xNONE ; then  if test "x${PDEFAULT}" = xNONE ; then
# Line 561  else Line 726  else
726          for i in $def ; do          for i in $def ; do
727              PACKAGES="$PACKAGES $i"              PACKAGES="$PACKAGES $i"
728          done          done
729          echo "    packages are:  $PACKAGES"          echo "    before group expansion packages are: $PACKAGES"
730            expand_pkg_groups
731            echo "    after group expansion packages are:  $PACKAGES"
732      fi      fi
733  fi  fi
734    
# Line 580  for p in $PACKAGES ; do Line 747  for p in $PACKAGES ; do
747  done  done
748  PACKAGES="$pack"  PACKAGES="$pack"
749  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
750  rm -f ./.tmp_pack  echo "" > ./.tmp_pack
751  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
752  for i in $PACKAGES ; do  for i in $PACKAGES ; do
753      if test ! -d "$ROOTDIR/pkg/$i" ; then      if test ! -d "$ROOTDIR/pkg/$i" ; then
# Line 696  done Line 863  done
863  # done  # done
864  # echo  # echo
865    
866  echo "  Setting package-specific CPP flags in CPP_OPTIONS.h:"  # Create a list of #define and #undef to enable/disable packages
867  CPP_OPTIONS=  PACKAGES_DOT_H=PACKAGES_CONFIG.h
868  spaths="$SOURCEDIRS"  cat <<EOF >$PACKAGES_DOT_H".tmp"
 for i in $spaths ; do  
     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 \  
         | awk 'BEGIN{p=1;} ($1=="C===" && $2=="GENMAKE"){p=0;} {if (p==1) print $0}' \  
         > CPP_OPTIONS.h.tmp  
 fi  
 cat <<EOF >>CPP_OPTIONS.h.tmp  
869  C=== GENMAKE v2 ===  C=== GENMAKE v2 ===
870  C  The following defines have been set by GENMAKE, so please edit  C  The following defines have been set by GENMAKE, so please do not
871  C  them only if you know what you're doing.  In general, you should  C  edit anything below these comments.  In general, you should
872  C  add or remove packages by re-running genmake with different  C  add or remove packages by re-running genmake with different
873  C  "-enable" and/or "-disable" options.  C  "-enable" and/or "-disable" options.
874    
875    #ifndef PACKAGES_H
876    #define PACKAGES_H
877    
878  C  Packages disabled by genmake:  C  Packages disabled by genmake:
879  EOF  EOF
880  #  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 749  for n in $names ; do Line 894  for n in $names ; do
894          done          done
895          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
896              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`
897              echo "#undef $undef" >> CPP_OPTIONS.h.tmp              echo "#undef $undef" >> $PACKAGES_DOT_H".tmp"
898    #           DEFINES="$DEFINES -U$undef"
899    
900  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
901              case $n in              case $n in
# Line 759  for n in $names ; do Line 905  for n in $names ; do
905                  mom_vecinv)                  mom_vecinv)
906                      DEFINES="$DEFINES -DDISABLE_MOM_VECINV"                      DEFINES="$DEFINES -DDISABLE_MOM_VECINV"
907                      ;;                      ;;
                 generic_advdiff)  
                     DEFINES="$DEFINES -DDISABLE_GENERIC_ADVDIFF"  
                     ;;  
908                  debug)                  debug)
909                      DEFINES="$DEFINES -DDISABLE_DEBUGMODE"                      DEFINES="$DEFINES -DDISABLE_DEBUGMODE"
910                      ;;                      ;;
# Line 771  for n in $names ; do Line 914  for n in $names ; do
914          fi          fi
915      fi      fi
916  done  done
917  cat <<EOF >>CPP_OPTIONS.h.tmp  cat <<EOF >>$PACKAGES_DOT_H".tmp"
918    
919  C  Packages enabled by genmake:  C  Packages enabled by genmake:
920  EOF  EOF
921  for i in $PACKAGES ; do  for i in $PACKAGES ; do
922      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`
923      echo "#define $def" >> CPP_OPTIONS.h.tmp      echo "#define $def" >> $PACKAGES_DOT_H".tmp"
924    #eh3 DEFINES="$DEFINES -D$def"
925    
926  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
927      case $i in      case $i in
928          aim_v23)          aim_v23)
929              echo "#define   ALLOW_AIM" >> CPP_OPTIONS.h.tmp              echo "#define   ALLOW_AIM" >> $PACKAGES_DOT_H".tmp"
930                DEFINES="$DEFINES -DALLOW_AIM"
931                echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)"
932              ;;              ;;
933      esac      esac
934  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
935    
936  done  done
937  mv -f CPP_OPTIONS.h.tmp CPP_OPTIONS.h  cat <<EOF >>$PACKAGES_DOT_H".tmp"
938    
939    #endif /* PACKAGES_H */
940    EOF
941    
942    if test ! -f $PACKAGES_DOT_H ; then
943        mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
944    else
945        cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
946        RETVAL=$?
947        if test "x$RETVAL" = x0 ; then
948            rm -f $PACKAGES_DOT_H".tmp"
949        else
950            mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak"
951            mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
952        fi
953    fi
954    
955  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS"
956  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
957  STANDARDDIRS=${STANDARDDIRS:-"eesupp model"}  if test "x$STANDARDDIRS" = x ; then
958        STANDARDDIRS="eesupp model"
959    fi
960  for d in $STANDARDDIRS ; do  for d in $STANDARDDIRS ; do
961      adr="$ROOTDIR/$d/src"      adr="$ROOTDIR/$d/src"
962      if test ! -d $adr ; then      if test ! -d $adr ; then
# Line 812  for d in $STANDARDDIRS ; do Line 976  for d in $STANDARDDIRS ; do
976      fi      fi
977  done  done
978    
979    echo " Searching for CPP_OPTIONS.h in order to warn about the presence"
980    echo " of \"#define ALLOW_PKGNAME\"-type statements:"
981    CPP_OPTIONS=
982    spaths=". $INCLUDEDIRS"
983    for i in $spaths ; do
984        try="$i/CPP_OPTIONS.h"
985        #  echo -n "    trying $try : "
986        if test -f $try -a -r $try ; then
987            echo "    found CPP_OPTIONS=\"$try\""
988            CPP_OPTIONS="$try"
989            break
990        fi
991    done
992    if test "x$CPP_OPTIONS" = x ; then
993        echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"
994        exit 1
995    fi
996    # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
997    names=`ls -1 "$ROOTDIR/pkg"`
998    for n in $names ; do
999        test_for_package_in_cpp_options $CPP_OPTIONS $n
1000    done
1001    
1002    
1003  echo  echo
1004  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
1005  echo "  setting INCLUDES"  echo "  setting INCLUDES"
1006  for i in $INCLUDEDIRS ; do  for i in $INCLUDEDIRS ; do
1007      if test -d $i ; then      if ! test -d $i ; then
1008          INCLUDES="$INCLUDES -I$i"  #       INCLUDES="$INCLUDES -I$i"
1009      else  #   else
1010          echo "Warning: can't find INCLUDEDIRS=\"$i\""          echo "Warning: can't find INCLUDEDIRS=\"$i\""
1011      fi      fi
1012  done  done
# Line 999  clean: Line 1186  clean:
1186  Clean:  Clean:
1187          @make clean          @make clean
1188          @make cleanlinks          @make cleanlinks
1189          -rm -f Makefile.bak          -rm -f Makefile.bak genmake_state genmake_optfile make.log
1190  CLEAN:  CLEAN:
1191          @make Clean          @make Clean
1192          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
1193          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
1194          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
1195          -rm -f \$(EXECUTABLE)          -rm -f \$(EXECUTABLE) output.txt
1196    
1197  makefile:  makefile:
1198          ${0} $@          ${0} $@
# Line 1069  printf "\n===  Done  ===\n" Line 1256  printf "\n===  Done  ===\n"
1256    
1257  #  Write the "state" for future records  #  Write the "state" for future records
1258  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" != xf ; then
1259      echo -n "" > gm_state      echo -n "" > genmake_state
1260      for i in $gm_state ; do      for i in $gm_state ; do
1261          t1="t2=\$$i"          t1="t2=\$$i"
1262          eval $t1          eval $t1
1263          echo "$i='$t2'" >> gm_state          echo "$i='$t2'" >> genmake_state
1264      done      done
1265  fi  fi

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.22