/[MITgcm]/MITgcm/tools/genmake2
ViewVC logotype

Annotation of /MITgcm/tools/genmake2

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.11.2.2 - (hide annotations) (download)
Wed Oct 1 19:33:01 2003 UTC (20 years, 6 months ago) by edhill
Branch: branch-genmake2
Changes since 1.11.2.1: +42 -44 lines
 o quote names and consistent indentation
 o create new $PACKAGES_DOT_H and backup file only if needed

1 edhill 1.1 #!/bin/bash
2     #
3 edhill 1.11.2.2 # $Header: /u/u3/gcmpack/MITgcm/tools/genmake2,v 1.11.2.1 2003/10/01 18:44:48 adcroft Exp $
4 edhill 1.1 #
5     # Makefile generator for MITgcm UV codes
6     # created by cnh 03/98
7     # adapted by aja 06/98
8     # modified by aja 01/00
9     # rewritten in bash by eh3 08/03
10    
11 adcroft 1.11.2.1 # 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 edhill 1.11.2.2 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 adcroft 1.11.2.1 fi
40     }
41    
42 edhill 1.1
43     # Guess possible config options for this host
44     find_possible_configs() {
45    
46 edhill 1.11 tmp1=`uname`"_"`uname -m`
47     tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
48     PLATFORM=`echo $tmp2 | sed -e 's/i[3-6]86/ia32/'`
49     OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
50     echo " The platform appears to be: $PLATFORM"
51     # if test "x$OFLIST" = x ; then
52     # echo " No pre-defined options files were found matching this platform"
53     # echo " but examples for other platforms can be found in:"
54     # echo " $ROOTDIR/tools/build_options"
55     # else
56     # echo " Options files (located in $ROOTDIR/tools/build_options) that"
57     # echo " may work with this machine are:"
58     # for i in $OFLIST ; do
59     # echo " $i"
60     # done
61     # fi
62    
63 edhill 1.1 echo "test" > test
64     ln -s ./test link
65     RETVAL=$?
66     if test "x${RETVAL}" = x0 ; then
67 edhill 1.11 LN="ln -s"
68     else
69     echo "Error: \"ln -s\" does not appear to work on this system!"
70     echo " For help, please contact <MITgcm-support@mitgcm.org>."
71     exit 1
72 edhill 1.1 fi
73     rm -f test link
74    
75 edhill 1.11 if test "x$CPP" = x ; then
76     CPP="cpp -traditional -P"
77 edhill 1.1 fi
78    
79     # look for possible fortran compilers
80 edhill 1.11 tmp="$MITGCM_FC $FC g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"
81 edhill 1.1 p_FC=
82 edhill 1.11 for c in $tmp ; do
83     rm -f ./hello.f ./hello
84     cat >> hello.f <<EOF
85     program hello
86     do i=1,3
87     print *, 'hello world : ', i
88     enddo
89     end
90     EOF
91     $c -o hello hello.f > /dev/null 2>&1
92 edhill 1.1 RETVAL=$?
93     if test "x${RETVAL}" = x0 ; then
94     p_FC="$p_FC $c"
95     fi
96     done
97     if test "x${p_FC}" = x ; then
98 edhill 1.11 cat 1>&2 <<EOF
99    
100     Error: No Fortran compilers were found in your path. Please specify one using:
101    
102     1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
103     2) a command-line option (eg. "-fc NAME"), or
104     3) the MITGCM_FC environment variable.
105    
106     EOF
107     exit 1
108 edhill 1.1 else
109 edhill 1.11 echo " The possible FORTRAN compilers found in your path are:"
110     echo " "$p_FC
111     if test "x$FC" = x ; then
112     FC=`echo $p_FC | awk '{print $1}'`
113     fi
114 edhill 1.1 fi
115    
116 edhill 1.11 for i in $p_FC ; do
117     p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
118     if test -r $p_OF ; then
119     OPTFILE=$p_OF
120     echo " The options file: $p_OF"
121     echo " appears to match so we'll use it."
122     break
123     fi
124     done
125     if test "x$OPTFILE" = x ; then
126     cat 1>&2 <<EOF
127    
128     Error: No options file was found in: $ROOTDIR/tools/build_options/
129     that matches this platform ("$PLATFORM") and the compilers found in
130     your path. Please specify an "optfile" using:
131    
132     1) the command line (eg. "-optfile=path/to/OPTFILE"), or
133     2) the MITGCM_OF environment variable.
134    
135     If you need help, please contact the developers at <MITgcm-support@mitgcm.org>.
136    
137 edhill 1.1 EOF
138 edhill 1.11 exit 1
139 edhill 1.1 fi
140 edhill 1.11
141     # # look for possible MPI libraries
142     # mpi_libs=
143     # mpi_fort=`which mpif77 2>/dev/null`
144     # RETVAL=$?
145     # if test "x${RETVAL}" = x0 ; then
146     # cat >>test.f <<EOF
147     # PROGRAM HELLO
148     # DO 10, I=1,10
149     # PRINT *,'Hello World'
150     # 10 CONTINUE
151     # STOP
152     # END
153     # EOF
154     # eval "$mpi_fort -showme test.f > out"
155     # RETVAL=$?
156     # if test "x${RETVAL}" = x0 ; then
157     # a=`cat out`
158     # for i in $a ; do
159     # case $i in
160     # -*)
161     # mpi_libs="$mpi_libs $i" ;;
162     # esac
163     # done
164     # echo "The MPI libs appear to be:"
165     # echo " "$mpi_libs
166     # fi
167     # rm -f test.f out
168     # fi
169 edhill 1.1
170     }
171    
172     # Parse the package dependency information
173     get_pdepend_list() {
174    
175     # strip the comments and then convert the dependency file into
176     # two arrays: PNAME, DNAME
177     cat $1 | sed -e 's/#.*$//g' \
178     | awk 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \
179     > ./.pd_tmp
180     source ./.pd_tmp
181     rm -f ./.pd_tmp
182    
183     echo -n "PNAME = "${}
184     }
185    
186    
187     # Explain usage
188     usage() {
189 edhill 1.2 echo
190 edhill 1.1 echo "Usage: "$0" [OPTIONS]"
191 edhill 1.2 echo " where [OPTIONS] can be:"
192     echo
193 edhill 1.1 echo " -help | --help | -h | --h"
194     echo " -nooptfile | --nooptfile"
195     echo " -optfile NAME | --optfile NAME | -of NAME | --of NAME"
196     echo " -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME"
197     echo " -pdepend NAME | --pdepend NAME"
198     echo " -pdepend=NAME | --pdepend=NAME"
199     echo " -pdefault NAME | --pdefault NAME"
200     echo " -pdefault=NAME | --pdefault=NAME"
201 edhill 1.6 echo " -make NAME | -m NAME"
202     echo " --make=NAME | -m=NAME"
203     echo " -makefile NAME | -mf NAME"
204     echo " --makefile=NAME | -mf=NAME"
205 edhill 1.1 echo " -platform NAME | --platform NAME | -pl NAME | --pl NAME"
206     echo " -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME"
207     echo " -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME"
208     echo " -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME"
209     echo " -mods NAME | --mods NAME | -mo NAME | --mo NAME"
210     echo " -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME"
211     echo " -disable NAME | --disable NAME"
212     echo " -disable=NAME | --disable=NAME"
213     echo " -enable NAME | --enable NAME"
214     echo " -enable=NAME | --enable=NAME"
215     echo " -noopt NAME | --noopt NAME"
216     echo " -noopt=NAME | --noopt=NAME"
217     # echo " -cpp NAME | --cpp NAME"
218     # echo " -cpp=NAME | --cpp=NAME"
219     echo " -fortran NAME | --fortran NAME | -fc NAME | --fc NAME"
220     echo " -fc=NAME | --fc=NAME"
221     echo " -[no]ieee | --[no]ieee"
222     echo " -[no]mpi | --[no]mpi"
223 edhill 1.2 echo " -[no]jam | --[no]jam"
224     echo
225     echo " and NAME is a string such as:"
226     echo
227 edhill 1.1 echo " --enable pkg1 --enable 'pkg1 pkg2' --enable 'pkg1 pkg2 pkg3'"
228     echo " -mods=dir1 -mods='dir1' -mods='dir1 dir2 dir3'"
229 edhill 1.2 echo " -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'"
230     echo
231 edhill 1.1 echo " which, depending upon your shell, may need to be single-quoted"
232     echo " if it contains spaces, dashes, or other special characters."
233     exit 1
234     }
235    
236     #eh3 # This is the generic configuration.
237     #eh3 set LN = ( 'ln -s' )
238     #eh3 set CPP = ( '/lib/cpp -P' )
239     #eh3 set S64 = ( '$(TOOLSDIR)/set64bitConst.sh' )
240     #eh3 set KPP = ( )
241     #eh3 set FC = ( 'f77' )
242     #eh3 set LINK = $FC
243     #eh3 set MAKEDEPEND = ( 'makedepend' )
244     #eh3 set INCLUDES = ( -I. )
245     #eh3 set FFLAGS = ( )
246     #eh3 set FOPTIM = ( )
247     #eh3 set CFLAGS = ( )
248     #eh3 set KFLAGS1 = ( )
249     #eh3 set KFLAGS2 = ( )
250     #eh3 set LIBS = ( )
251     #eh3 set KPPFILES = ( )
252     #eh3 if (! $?NOOPTFILES ) set NOOPTFILES = ( )
253     #eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = ( )
254    
255     # Set defaults here
256 edhill 1.5 COMMANDL="$0 $@"
257    
258 edhill 1.1 PLATFORM=
259     LN=
260     S64=
261     KPP=
262     FC=
263     LINK=
264 edhill 1.11 DEFINES="-DWORDLENGTH=4"
265 edhill 1.1 PACKAGES=
266     ENABLE=
267     DISABLE=
268     MAKEFILE=
269     MAKEDEPEND=
270     PDEPEND=
271 edhill 1.11 DUMPSTATE=t
272 edhill 1.1 PDEFAULT=
273     OPTFILE=
274 edhill 1.2 INCLUDES="-I."
275 edhill 1.1 FFLAGS=
276     FOPTIM=
277     CFLAGS=
278     KFLAGS1=
279     KFLAGS2=
280     LIBS=
281     KPPFILES=
282     NOOPTFILES=
283     NOOPTFLAGS=
284    
285     MODS=
286     TOOLSDIR=
287     SOURCEDIRS=
288     INCLUDEDIRS=
289    
290     PWD=`pwd`
291     MAKE=make
292     THISHOSTNAME=`hostname`
293     THISCWD=`pwd`
294     THISDATE=`date`
295     MACHINE=`uname -a`
296 edhill 1.7 EXECUTABLE=
297     EXEHOOK=
298     EXEDIR=
299 edhill 1.1
300 edhill 1.5 # The following state can be set directly by command-line switches
301     gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"
302     gm_s2="FC IEEE MPI JAM DUMPSTATE"
303    
304     # The following state is not directly set by command-line switches
305     gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "
306     gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
307     gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"
308 edhill 1.7 gm_s6="EXECUTABLE EXEHOOK EXEDIR"
309 edhill 1.5
310 edhill 1.7 gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6"
311 edhill 1.5
312    
313 edhill 1.2 echo
314     echo "=== Processing options files and arguments ==="
315 edhill 1.1 gm_local="./gm_local"
316     echo -n " getting local config information: "
317     if test -e $gm_local ; then
318     echo "using $gm_local"
319     source $gm_local
320 edhill 1.2 # echo "DISABLE=$DISABLE"
321     # echo "ENABLE=$ENABLE"
322 edhill 1.1 else
323     echo "none found"
324     fi
325    
326     # echo "$0::$1:$2:$3:$4:$5:$6:$7:"
327 edhill 1.2 #OPTIONS=
328     #n=0
329     #for i ; do
330     # echo "$i $n"
331     # setvar="OPTIONS[$n]='$i'"
332     # # echo " $setvar"
333     # eval "$setvar"
334     # n=$(( $n + 1 ))
335     #done
336     #parse_options
337    
338     ac_prev=
339     for ac_option ; do
340    
341     # If the previous option needs an argument, assign it.
342     if test -n "$ac_prev"; then
343     eval "$ac_prev=\$ac_option"
344     ac_prev=
345     continue
346     fi
347    
348     ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
349    
350     case $ac_option in
351    
352     -help | --help | -h | --h)
353     usage ;;
354    
355     -nooptfile | --nooptfile)
356     OPTFILE="NONE" ;;
357     -optfile | --optfile | -of | --of)
358 edhill 1.4 ac_prev=OPTFILE ;;
359 edhill 1.2 -optfile=* | --optfile=* | -of=* | --of=*)
360     OPTFILE=$ac_optarg ;;
361    
362     -pdepend | --pdepend)
363 edhill 1.4 ac_prev=PDEPEND ;;
364 edhill 1.2 -pdepend=* | --pdepend=*)
365     PDEPEND=$ac_optarg ;;
366    
367     -pdefault | --pdefault)
368 edhill 1.4 ac_prev=PDEFAULT ;;
369 edhill 1.2 -pdefault=* | --pdefault=*)
370     PDEFAULT=$ac_optarg ;;
371    
372 edhill 1.6 -make | --make | -m | --m)
373     ac_prev=MAKE ;;
374     -make=* | --make=* | -m=* | --m=*)
375     MAKE=$ac_optarg ;;
376    
377     -makefile | --makefile | -ma | --ma)
378 edhill 1.4 ac_prev=MAKEFILE ;;
379 edhill 1.6 -makefile=* | --makefile=* | -ma=* | --ma=*)
380 edhill 1.2 MAKEFILE=$ac_optarg ;;
381    
382     -platform | --platform | -pl | --pl)
383 edhill 1.4 ac_prev=PLATFORM ;;
384 edhill 1.2 -platform=* | --platform=* | -pl=* | --pl=*)
385     PLATFORM=$ac_optarg ;;
386    
387     -rootdir | --rootdir | -rd | --rd)
388 edhill 1.4 ac_prev=ROOTDIR ;;
389 edhill 1.2 -rootdir=* | --rootdir=* | -rd=* | --rd=*)
390     ROOTDIR=$ac_optarg ;;
391    
392     -mods | --mods | -mo | --mo)
393 edhill 1.4 ac_prev=MODS ;;
394 edhill 1.2 -mods=* | --mods=* | -mo=* | --mo=*)
395     MODS=$ac_optarg ;;
396    
397     -disable | --disable)
398 edhill 1.4 ac_prev=DISABLE ;;
399 edhill 1.2 -disable=* | --disable=*)
400     DISABLE=$ac_optarg ;;
401    
402     -enable | --enable)
403 edhill 1.4 ac_prev=ENABLE ;;
404 edhill 1.2 -enable=* | --enable=*)
405     ENABLE=$ac_optarg ;;
406    
407     -noopt | --noopt)
408 edhill 1.4 ac_prev=NOOPT ;;
409 edhill 1.2 -noopt=* | --noopt=*)
410     NOOPT=$ac_optarg ;;
411    
412     # -cpp | --cpp)
413     # ac_prev=cpp ;;
414     # -cpp=* | --cpp=*)
415     # CPP=$ac_optarg ;;
416    
417     -fortran | --fortran | -fc | --fc)
418 edhill 1.4 ac_prev=FC ;;
419 edhill 1.2 -fc=* | --fc=*)
420     FC=$ac_optarg ;;
421    
422     -ieee | --ieee)
423     IEEE=1 ;;
424     -noieee | --noieee)
425     IEEE=0 ;;
426    
427     -mpi | --mpi)
428     MPI=1 ;;
429     -nompi | --nompi)
430     MPI=0 ;;
431    
432     -jam | --jam)
433     JAM=1 ;;
434     -nojam | --nojam)
435     JAM=0 ;;
436    
437 edhill 1.5 -ds | --ds)
438     DUMPSTATE=t ;;
439    
440 edhill 1.2 -*)
441     echo "Error: unrecognized option: "$ac_option
442     usage
443     ;;
444    
445     *)
446     echo "Error: unrecognized argument: "$ac_option
447     usage
448     ;;
449    
450     esac
451    
452 edhill 1.1 done
453    
454 edhill 1.11 if test "x${ROOTDIR}" = x ; then
455     if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
456     ROOTDIR=".."
457     else
458     for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
459     if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then
460     ROOTDIR=$d
461     echo -n "Warning: ROOTDIR was not specified but there appears to be"
462     echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."
463     break
464     fi
465     done
466     fi
467     fi
468     if test "x${ROOTDIR}" = x ; then
469     echo "Error: Cannot determine ROOTDIR for MITgcm code."
470     echo " Please specify a ROOTDIR using either an options "
471     echo " file or a command-line option."
472     exit 1
473     fi
474     if test ! -d ${ROOTDIR} ; then
475     echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!"
476     exit 1
477     fi
478    
479 edhill 1.1 echo " getting OPTFILE information: "
480     if test "x${OPTFILE}" = x ; then
481 edhill 1.11 if test "x$MITGCM_OF" = x ; then
482     echo "Warning: no OPTFILE specified so we'll look for possible settings"
483     printf "\n=== Searching for possible settings for OPTFILE ===\n"
484     find_possible_configs
485 edhill 1.1 else
486 edhill 1.11 OPTFILE=$MITGCM_OF
487     fi
488     fi
489     if test "x$OPTFILE" != xNONE ; then
490     if test -f "$OPTFILE" -a -r "$OPTFILE" ; then
491     echo " using OPTFILE=\"$OPTFILE\""
492     source "$OPTFILE"
493     RETVAL=$?
494     if test "x$RETVAL" != x0 ; then
495     echo -n "Error: failed to source OPTFILE \"$OPTFILE\""
496     echo "--please check that variable syntax is bash-compatible"
497 edhill 1.1 exit 1
498     fi
499 edhill 1.11 if test "x$DUMPSTATE" != xf ; then
500     cp -f $OPTFILE "gm_optfile"
501     fi
502     else
503     echo "Error: can't read OPTFILE=\"$OPTFILE\""
504     exit 1
505 edhill 1.1 fi
506     fi
507 edhill 1.8
508     # Check that FC, LINK, CPP, and S64 are defined. If not, complain
509     # and abort!
510     if test "x$FC" = x ; then
511     cat <<EOF 1>&2
512    
513     Error: no Fortran compiler: please specify using one of the following:
514     1) within the options file ("FC=...") as specified by "-of=OPTFILE"
515     2) the "-fc=XXX" command-line option
516     3) the "./gm_local" file
517     EOF
518     exit 1
519     fi
520     if test "x$LINK" = x ; then
521     LINK=$FC
522     fi
523     if test "x$CPP" = x ; then
524 edhill 1.11 CPP="cpp"
525     fi
526     echo "#define A a" | cpp > test_cpp 2>&1
527     RETVAL=$?
528     if test "x$RETVAL" != x0 ; then
529 edhill 1.8 cat <<EOF 1>&2
530    
531 edhill 1.11 Error: C pre-processor "$CPP" failed the test case: please specify using:
532    
533 edhill 1.8 1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
534     2) the "./gm_local" file
535 edhill 1.11
536 edhill 1.8 EOF
537     exit 1
538 edhill 1.11 else
539     rm -f test_cpp
540 edhill 1.8 fi
541 edhill 1.11 if test "x$MAKEDEPEND" = x ; then
542     MAKEDEPEND=makedepend
543 edhill 1.8 fi
544    
545 edhill 1.2 printf "\n=== Setting defaults ===\n"
546 edhill 1.1 echo -n " Adding MODS directories: "
547     for d in $MODS ; do
548     if test ! -d $d ; then
549 edhill 1.2 echo
550     echo "Error: MODS directory \"$d\" not found!"
551 edhill 1.1 exit 1
552     else
553     echo -n " $d"
554     SOURCEDIRS="$SOURCEDIRS $d"
555     INCLUDEDIRS="$INCLUDEDIRS $d"
556     fi
557     done
558     echo
559    
560     if test "x$MAKEFILE" = x ; then
561     MAKEFILE="Makefile"
562     fi
563     if test "x${PLATFORM}" = x ; then
564     PLATFORM=$p_PLATFORM
565     fi
566    
567     if test "x${EXEDIR}" = x ; then
568     if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then
569     EXEDIR=../exe
570     else
571     EXEDIR=.
572     fi
573     fi
574     if test ! -d ${EXEDIR} ; then
575     echo "Error: the specified EXEDIR (\"$EXEDIR\") does not exist!"
576     exit 1
577     fi
578    
579     if test "x${TOOLSDIR}" = x ; then
580     TOOLSDIR="$ROOTDIR/tools"
581     fi
582     if test ! -d ${TOOLSDIR} ; then
583     echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"
584     exit 1
585     fi
586 edhill 1.11 if test "x$S64" = x ; then
587     S64='$(TOOLSDIR)/set64bitConst.sh'
588     fi
589 edhill 1.1
590     EXECUTABLE=${EXECUTABLE:-mitgcmuv}
591    
592     # We have a special set of source files in eesupp/src which are
593     # generated from some template source files. We'll make them first so
594     # they appear as regular source code
595     if test -r $ROOTDIR"/eesupp/src/Makefile" ; then
596     echo " Making source files in eesupp from templates"
597     $MAKE -C $ROOTDIR"/eesupp/src/" > make_eesupp.errors 2>&1
598     RETVAL=$?
599 edhill 1.2 if test "x${RETVAL}" = x0 ; then
600 edhill 1.1 rm -f make_eesupp.errors
601     else
602     echo "Error: problem encountered while building source files in eesupp:"
603     cat make_eesupp.errors
604     exit 1
605     fi
606     fi
607    
608 edhill 1.2 printf "\n=== Determining package settings ===\n"
609 edhill 1.1 if test "x${PDEPEND}" = x ; then
610     tmp=$ROOTDIR"/pkg/pkg_depend"
611     if test -r $tmp ; then
612     PDEPEND=$tmp
613     else
614     echo "Warning: No package dependency information was specified."
615     echo " Please check that ROOTDIR/pkg/pkg_depend exists."
616     fi
617     else
618     if test ! -r ${PDEPEND} ; then
619     echo "Error: can't read package dependency info from PDEPEND=\"$PDEPEND\""
620     exit 1
621     fi
622     fi
623     echo " getting package dependency info from $PDEPEND"
624     # Strip the comments and then convert the dependency file into
625     # two arrays: PNAME, DNAME
626     cat $PDEPEND | sed -e 's/#.*$//g' \
627 edhill 1.2 | awk 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \
628 edhill 1.1 > ./.pd_tmp
629     RETVAL=$?
630     if test ! "x${RETVAL}" = x0 ; then
631     echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""
632     exit 1
633     fi
634     source ./.pd_tmp
635     rm -f ./.pd_tmp
636    
637     echo -n " checking default package list: "
638     if test "x${PDEFAULT}" = x ; then
639     PDEFAULT="$ROOTDIR/pkg/pkg_default"
640     fi
641     if test "x${PDEFAULT}" = xNONE ; then
642     echo "default packages file disabled"
643     else
644     if test ! -r $PDEFAULT ; then
645     echo ""
646     echo "Warning: can't read default packages from PDEFAULT=\"$PDEFAULT\""
647     else
648     echo " using PDEFAULT=\"$PDEFAULT\""
649     # Strip the comments and add all the names
650     def=`cat $PDEFAULT | sed -e 's/#.*$//g' | awk '(NF>0){print $0}'`
651     RETVAL=$?
652     if test "x${RETVAL}" != x0 ; then
653     echo -n "Error: can't parse default package list "
654     echo "-- please check PDEFAULT=\"$PDEFAULT\""
655     exit 1
656     fi
657     for i in $def ; do
658     PACKAGES="$PACKAGES $i"
659     done
660     echo " packages are: $PACKAGES"
661     fi
662     fi
663    
664     echo " applying DISABLE settings"
665     pack=
666     for p in $PACKAGES ; do
667     addit="t"
668     for d in $DISABLE ; do
669     if test "x$p" = "x$d" ; then
670     addit="f"
671     fi
672     done
673     if test "x$addit" = xt ; then
674     pack="$pack $p"
675     fi
676     done
677     PACKAGES="$pack"
678     echo " applying ENABLE settings"
679 adcroft 1.11.2.1 echo "" > ./.tmp_pack
680 edhill 1.1 PACKAGES="$PACKAGES $ENABLE"
681     for i in $PACKAGES ; do
682     if test ! -d "$ROOTDIR/pkg/$i" ; then
683     echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""
684     exit 1
685     fi
686     echo $i >> ./.tmp_pack
687     done
688     pack=`cat ./.tmp_pack | sort | uniq`
689     rm -f ./.tmp_pack
690     PACKAGES=
691     for i in $pack ; do
692     PACKAGES="$PACKAGES $i"
693     done
694     echo " packages are: $PACKAGES"
695    
696     echo " applying package dependency rules"
697     ck=
698     while test "x$ck" != xtt ; do
699     i=0
700 edhill 1.2 # rtot=${#PNAME[@]}
701     rtot=$nname
702 edhill 1.1 while test $i -lt $rtot ; do
703    
704     # Is $pname in the current $PACKAGES list?
705 edhill 1.2 # pname=${PNAME[$i]}
706     tmp="pname=\"\$PNAME_$i\""
707     eval $tmp
708 edhill 1.1 pin="f"
709     for p in $PACKAGES ; do
710     if test "x$p" = "x$pname" ; then
711     pin="t"
712     fi
713     done
714    
715     # Is the DNAME entry a (+) or (-) rule ?
716 edhill 1.2 tmp="dname=\"\$DNAME_$i\""
717     eval $tmp
718 edhill 1.1 plus="-"
719 edhill 1.2 echo $dname | grep '^+' > /dev/null 2>&1
720 edhill 1.1 RETVAL=$?
721     if test "x$RETVAL" = x0 ; then
722     plus="+"
723     fi
724    
725     # Is $dname in the current $PACKAGES list?
726 edhill 1.2 dname=`echo $dname | sed -e 's/^[+-]//'`
727 edhill 1.1 din="f"
728     for p in $PACKAGES ; do
729     if test "x$p" = "x$dname" ; then
730     din="t"
731     fi
732     done
733    
734     # Do we need to add $dname according to the dependency rules?
735     if test "x$pin" = xt -a "x$plus" = "x+" -a "x$din" = xf ; then
736     in_dis="f"
737     for dis in $DISABLE ; do
738     if test "x$dis" = "x$dname" ; then
739     in_dis="t"
740     fi
741     done
742     if test "x$in_dis" = xt ; then
743     echo "Error: can't satisfy package dependencies:"
744     echo " \"$dname\" is required by the dependency rules"
745     echo " but is disallowed by the DISABLE settings"
746     exit 1
747     else
748     PACKAGES="$PACKAGES $dname"
749     ck=
750     fi
751     fi
752    
753     # Do we need to get rid of $dname according to the dependency rules?
754     if test "x$pin" = xt -a "x$plus" = "x-" -a "x$din" = xt; then
755     echo "Error: can't satisfy package dependencies:"
756     echo " \"$pname\" was requested but is disallowed by"
757     echo " the dependency rules for \"$dname\""
758     exit 1
759     fi
760     i=$(( $i + 1 ))
761     done
762     ck=$ck"t"
763     done
764     echo " packages are: $PACKAGES"
765     for i in $PACKAGES ; do
766     adr="$ROOTDIR/pkg/$i"
767     if test -d $adr ; then
768     SOURCEDIRS="$SOURCEDIRS $adr"
769     INCLUDEDIRS="$INCLUDEDIRS $adr"
770     else
771     echo "Error: the directory \"$adr\" for package $i doesn't exist"
772     exit 1
773     fi
774     done
775    
776     # This is compatible with the old genmake. The "DISABLE_*" flags
777     # need to be replaced by the "ALLOW_*" flags set below.
778     #
779     # echo -n " Setting package-specific CPP flags: "
780     # pkrm=( mom_fluxform mom_vecinv generic_advdiff )
781     # pkrmdef=( -DDISABLE_MOM_FLUXFORM -DDISABLE_MOM_VECINV -DDISABLE_GENERIC_ADVDIFF -DDISABLE_DEBUGMODE )
782     # echo -n " "
783     # i=0
784     # while test $i -lt "${#pkrm[@]}" ; do
785     # echo "$PACKAGES" | grep "${pk[$i]}" > /dev/null 2>&1
786     # RETVAL=$?
787     # if test "x$RETVAL" = x1 ; then
788     # DEFINES="$DEFINES ${pkdef[$i]}"
789     # echo -n " ${pkdef[$i]}"
790     # fi
791     # i=$(( $i + 1 ))
792     # done
793     # echo
794    
795 adcroft 1.11.2.1 # Create a list of #define and #undef to enable/disable packages
796     PACKAGES_DOT_H=PACKAGES.h
797     if test -e $PACKAGES_DOT_H ; then
798     cat $PACKAGES_DOT_H \
799 edhill 1.1 | awk 'BEGIN{p=1;} ($1=="C===" && $2=="GENMAKE"){p=0;} {if (p==1) print $0}' \
800 edhill 1.11.2.2 > $PACKAGES_DOT_H".tmp"
801 edhill 1.1 fi
802 edhill 1.11.2.2 cat <<EOF >>$PACKAGES_DOT_H".tmp"
803 edhill 1.1 C=== GENMAKE v2 ===
804 edhill 1.11 C The following defines have been set by GENMAKE, so please do not
805     C edit anything below these comments. In general, you should
806 edhill 1.1 C add or remove packages by re-running genmake with different
807     C "-enable" and/or "-disable" options.
808    
809     C Packages disabled by genmake:
810     EOF
811     # The following UGLY HACK sets multiple "#undef"s and it needs to go
812     # away. On 2003-08-12, CNH, JMC, and EH3 agreed that the CPP_OPTIONS.h
813     # file would eventually be split up so that all package-related #define
814     # statements could be separated and handled only by genmake.
815     names=`ls -1 "$ROOTDIR/pkg"`
816     all_pack=
817     for n in $names ; do
818     if test -d "$ROOTDIR/pkg/$n" -a "x$n" != xCVS ; then
819     has_pack="f"
820     for pack in $PACKAGES ; do
821     if test "x$pack" = "x$n" ; then
822     has_pack="t"
823     break
824     fi
825     done
826     if test "x$has_pack" = xf ; then
827     undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`
828 edhill 1.11.2.2 echo "#undef $undef" >> $PACKAGES_DOT_H".tmp"
829 adcroft 1.11.2.1 # DEFINES="$DEFINES -U$undef"
830 edhill 1.1
831     #EH3 WARNING : This is an UGLY HACK that needs to be removed!!!
832     case $n in
833     mom_fluxform)
834     DEFINES="$DEFINES -DDISABLE_MOM_FLUXFORM"
835     ;;
836     mom_vecinv)
837     DEFINES="$DEFINES -DDISABLE_MOM_VECINV"
838     ;;
839     debug)
840     DEFINES="$DEFINES -DDISABLE_DEBUGMODE"
841     ;;
842     esac
843     #EH3 WARNING : This is an UGLY HACK that needs to be removed!!!
844    
845     fi
846     fi
847     done
848 edhill 1.11.2.2 cat <<EOF >>$PACKAGES_DOT_H".tmp"
849 edhill 1.1
850     C Packages enabled by genmake:
851     EOF
852     for i in $PACKAGES ; do
853     def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`
854 edhill 1.11.2.2 echo "#define $def" >> $PACKAGES_DOT_H".tmp"
855     #eh3 DEFINES="$DEFINES -D$def"
856 edhill 1.1
857     #EH3 WARNING : This is an UGLY HACK that needs to be removed!!!
858     case $i in
859     aim_v23)
860 edhill 1.11.2.2 echo "#define ALLOW_AIM" >> $PACKAGES_DOT_H".tmp"
861     DEFINES="$DEFINES -DALLOW_AIM"
862 adcroft 1.11.2.1 echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)"
863 edhill 1.1 ;;
864     esac
865     #EH3 WARNING : This is an UGLY HACK that needs to be removed!!!
866    
867     done
868 edhill 1.11.2.2 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 edhill 1.1
875     echo " Adding STANDARDDIRS"
876     BUILDDIR=${BUILDDIR:-.}
877     STANDARDDIRS=${STANDARDDIRS:-"eesupp model"}
878     for d in $STANDARDDIRS ; do
879     adr="$ROOTDIR/$d/src"
880     if test ! -d $adr ; then
881     echo "Error: directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
882     echo " is correct and that you correctly specified the STANDARDDIRS option"
883     exit 1
884     else
885     SOURCEDIRS="$SOURCEDIRS $adr"
886     fi
887     adr="$ROOTDIR/$d/inc"
888     if test ! -d $adr ; then
889     echo "Error: directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
890     echo " is correct and that you correctly specified the STANDARDDIRS option"
891     exit 1
892     else
893     INCLUDEDIRS="$INCLUDEDIRS $adr"
894     fi
895     done
896    
897 edhill 1.11.2.2 echo " Searching for CPP_OPTIONS.h in order to warn about the presence"
898     echo " of \"#define ALLOW_PKGNAME\"-type statements:"
899 adcroft 1.11.2.1 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 edhill 1.1
921 edhill 1.2 echo
922     echo "=== Creating the Makefile ==="
923 edhill 1.1 echo " setting INCLUDES"
924     for i in $INCLUDEDIRS ; do
925 adcroft 1.11.2.1 if ! test -d $i ; then
926     # INCLUDES="$INCLUDES -I$i"
927     # else
928 edhill 1.1 echo "Warning: can't find INCLUDEDIRS=\"$i\""
929     fi
930     done
931    
932     echo " Determining the list of source and include files"
933     rm -rf .links.tmp
934     mkdir .links.tmp
935     echo "# This section creates symbolic links" > srclinks.tmp
936     echo "" >> srclinks.tmp
937 cnh 1.3 echo -n 'SRCFILES = ' > srclist.inc
938     echo -n 'CSRCFILES = ' > csrclist.inc
939     echo -n 'F90SRCFILES = ' > f90srclist.inc
940 edhill 1.1 echo -n 'HEADERFILES = ' > hlist.inc
941 adcroft 1.9 alldirs="$SOURCEDIRS $INCLUDEDIRS ."
942 edhill 1.1 for d in $alldirs ; do
943     deplist=
944     sfiles=`( cd $d; echo *.[h,c,F] )`
945 cnh 1.3 sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
946 edhill 1.1 for sf in $sfiles ; do
947     if test ! -r ".links.tmp/$sf" ; then
948     if test -f "$d/$sf" ; then
949     extn=`echo $sf | awk -F '.' '{print $NF}'`
950     touch .links.tmp/$sf
951     deplist="$deplist $sf"
952     case $extn in
953     F)
954     echo " \\" >> srclist.inc
955     echo -n " $sf" >> srclist.inc
956     ;;
957 cnh 1.3 F90)
958     echo " \\" >> f90srclist.inc
959     echo -n " $sf" >> f90srclist.inc
960     ;;
961 edhill 1.1 c)
962     echo " \\" >> csrclist.inc
963     echo -n " $sf" >> csrclist.inc
964     ;;
965     h)
966     echo " \\" >> hlist.inc
967     echo -n " $sf" >> hlist.inc
968     ;;
969     esac
970     fi
971     fi
972     done
973     if test "x$deplist" != x ; then
974 edhill 1.2 echo "" >> srclinks.tmp
975     echo "# These files are linked from $d" >> srclinks.tmp
976 edhill 1.1 echo "$deplist :" >> srclinks.tmp
977 edhill 1.2 printf "\t\$(LN) %s/\$@ \$@\n" $d >> srclinks.tmp
978 edhill 1.1 fi
979     done
980     rm -rf .links.tmp
981     echo "" >> srclist.inc
982     echo "" >> csrclist.inc
983 cnh 1.3 echo "" >> f90srclist.inc
984 edhill 1.1 echo "" >> hlist.inc
985 adcroft 1.11.2.1
986 edhill 1.1 if test -e $MAKEFILE ; then
987     mv -f $MAKEFILE "$MAKEFILE.bak"
988     fi
989     echo " Writing makefile: $MAKEFILE"
990     echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE
991     echo "# $MACHINE" >> $MAKEFILE
992     echo "# This makefile was generated automatically on" >> $MAKEFILE
993     echo "# $THISDATE" >> $MAKEFILE
994     echo "# by the command:" >> $MAKEFILE
995     echo "# $0 $@" >> $MAKEFILE
996     echo "# executed by:" >> $MAKEFILE
997     echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE
998     cat >>$MAKEFILE <<EOF
999     #
1000     # BUILDDIR : Directory where object files are written
1001     # SOURCEDIRS : Directories containing the source (.F) files
1002     # INCLUDEDIRS : Directories containing the header-source (.h) files
1003     # EXEDIR : Directory where executable that is generated is written
1004     # EXECUTABLE : Full path of executable binary
1005     #
1006     # CPP : C-preprocessor command
1007     # INCLUDES : Directories searched for header files
1008     # DEFINES : Macro definitions for CPP
1009     # MAKEDEPEND : Dependency generator
1010     # KPP : Special preprocessor command (specific to platform)
1011     # KFLAGS : Flags for KPP
1012     # FC : Fortran compiler command
1013     # FFLAGS : Configuration/debugging options for FC
1014     # FOPTIM : Optimization options for FC
1015     # LINK : Command for link editor program
1016     # LIBS : Library flags /or/ additional optimization/debugging flags
1017    
1018     ROOTDIR = ${ROOTDIR}
1019     BUILDDIR = ${BUILDDIR}
1020     SOURCEDIRS = ${SOURCEDIRS}
1021     INCLUDEDIRS = ${INCLUDEDIRS}
1022     EXEDIR = ${EXEDIR}
1023     EXECUTABLE = \$(EXEDIR)/${EXECUTABLE}
1024     TOOLSDIR = ${TOOLSDIR}
1025    
1026     EOF
1027    
1028     # Note: figure out some way to add Hyades JAM libraries here
1029    
1030     cat >>$MAKEFILE <<EOF
1031     # Unix ln (link)
1032     LN = ${LN}
1033     # C preprocessor
1034     CPP = cat \$< | ${S64} | ${CPP}
1035     # Dependency generator
1036     MAKEDEPEND = ${MAKEDEPEND}
1037     # Special preprocessor (KAP on DECs, FPP on Crays)
1038     KPP = ${KPP}
1039     # Fortran compiler
1040     FC = ${FC}
1041 cnh 1.3 # Fortran compiler
1042     F90C = ${F90C}
1043 edhill 1.1 # Link editor
1044     LINK = ${LINK}
1045    
1046     # Defines for CPP
1047     DEFINES = ${DEFINES}
1048     # Includes for CPP
1049     INCLUDES = ${INCLUDES}
1050     # Flags for KPP
1051     KFLAGS1 = ${KFLAGS1}
1052     KFLAGS2 = ${KFLAGS2}
1053     # Optim./debug for FC
1054     FFLAGS = ${FFLAGS}
1055     FOPTIM = ${FOPTIM}
1056 cnh 1.3 # Optim./debug for FC
1057     F90FLAGS = ${F90FLAGS}
1058     F90OPTIM = ${F90OPTIM}
1059 edhill 1.1 # Flags for CC
1060     CFLAGS = ${CFLAGS}
1061     # Files that should not be optimized
1062     NOOPTFILES = ${NOOPTFILES}
1063     NOOPTFLAGS = ${NOOPTFLAGS}
1064     # Flags and libraries needed for linking
1065     LIBS = ${LIBS} \$(XLIBS)
1066 cnh 1.3 # Name of the Mekfile
1067     MAKEFILE=${MAKEFILE}
1068 edhill 1.1
1069     EOF
1070    
1071 cnh 1.3 cat srclist.inc >> $MAKEFILE
1072     cat csrclist.inc >> $MAKEFILE
1073     cat f90srclist.inc >> $MAKEFILE
1074     cat hlist.inc >> $MAKEFILE
1075     echo 'F77FILES = $(SRCFILES:.F=.f)' >> $MAKEFILE
1076     echo 'F90FILES = $(F90SRCFILES:.F90=.f90)' >> $MAKEFILE
1077     echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
1078 edhill 1.1
1079 cnh 1.3 rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc
1080 edhill 1.1
1081     cat >>$MAKEFILE <<EOF
1082    
1083     .SUFFIXES:
1084 cnh 1.3 .SUFFIXES: .o .f .p .F .c .F90 .f90
1085 edhill 1.1
1086     all: \$(EXECUTABLE)
1087     \$(EXECUTABLE): \$(OBJFILES)
1088     \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
1089     depend:
1090     @make links
1091     \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
1092 edhill 1.7 ${TOOLSDIR}/f90mkdepend >> \$(MAKEFILE)
1093 edhill 1.1
1094 cnh 1.3 links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES)
1095 edhill 1.1
1096 cnh 1.3 small_f: \$(F77FILES) \$(F90FILES)
1097 edhill 1.1
1098     output.txt: \$(EXECUTABLE)
1099     @printf 'running ... '
1100     @\$(EXECUTABLE) > \$@
1101    
1102     clean:
1103 cnh 1.3 -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl}
1104 edhill 1.1 Clean:
1105     @make clean
1106     @make cleanlinks
1107 adcroft 1.11.2.1 -rm -f Makefile.bak gm_state gm_optfile make.log PACKAGES.h*
1108 edhill 1.1 CLEAN:
1109     @make Clean
1110     -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
1111     -find \$(EXEDIR) -name "*.data" -exec rm {} \;
1112     -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
1113 adcroft 1.11.2.1 -rm -f \$(EXECUTABLE) output.txt
1114 edhill 1.1
1115     makefile:
1116     ${0} $@
1117     cleanlinks:
1118     -find . -type l -exec rm {} \;
1119    
1120     # The normal chain of rules is ( .F - .f - .o )
1121     .F.f:
1122     \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1123     .f.o:
1124     \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
1125 cnh 1.3 .F90.f90:
1126     \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1127     .f90.o:
1128     \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
1129 edhill 1.1 .c.o:
1130     \$(CC) \$(CFLAGS) -c \$<
1131    
1132     # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain
1133     .F.p:
1134     \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1135     .p.f:
1136     \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
1137    
1138     EOF
1139 edhill 1.7
1140     if test "x$EXEHOOK" != x ; then
1141     printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE
1142     fi
1143 edhill 1.1
1144     echo " Making list of \"exceptions\" that need \".p\" files"
1145     for i in $KPPFILES ; do
1146     base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`
1147     RETVAL=$?
1148     if test "x$RETVAL" != x0 ; then
1149     echo "Error: unable to add file \"$i\" to the exceptions list"
1150     fi
1151     echo "$base.f: $base.p" >> $MAKEFILE
1152     done
1153    
1154     echo " Making list of NOOPTFILES"
1155     for i in $NOOPTFILES ; do
1156     base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`
1157     RETVAL=$?
1158     if test "x$RETVAL" != x0 ; then
1159     echo "Error: unable to add file \"$i\" to the exceptions list"
1160     fi
1161     echo "$base.o: $base.f" >> $MAKEFILE
1162 edhill 1.2 printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE
1163 edhill 1.1 done
1164    
1165     echo " Add rules for links"
1166     cat srclinks.tmp >> $MAKEFILE
1167     rm -f srclinks.tmp
1168    
1169     echo " Adding makedepend marker"
1170 edhill 1.2 printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE
1171 edhill 1.1
1172 edhill 1.2 printf "\n=== Done ===\n"
1173 edhill 1.5
1174    
1175     # Write the "state" for future records
1176     if test "x$DUMPSTATE" != xf ; then
1177     echo -n "" > gm_state
1178     for i in $gm_state ; do
1179     t1="t2=\$$i"
1180     eval $t1
1181     echo "$i='$t2'" >> gm_state
1182     done
1183     fi

  ViewVC Help
Powered by ViewVC 1.1.22