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

Contents of /MITgcm/tools/genmake2

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


Revision 1.12 - (show annotations) (download)
Thu Oct 9 04:19:20 2003 UTC (20 years, 5 months ago) by edhill
Branch: MAIN
CVS Tags: checkpoint51i_post
Changes since 1.11: +180 -58 lines
 o first check-in for the "branch-genmake2" merge
 o verification suite as run on shelley (gcc 3.2.2):

Wed Oct  8 23:42:29 EDT 2003
                T           S           U           V
G D M    c        m  s        m  s        m  s        m  s
E p a R  g  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  .
N n k u  2  i  a  a  d  i  a  a  d  i  a  a  d  i  a  a  d
2 d e n  d  n  x  n  .  n  x  n  .  n  x  n  .  n  x  n  .

OPTFILE=NONE

Y Y Y Y 13 16 16 16  0 16 16 16 16 16 16 16 16 13 12  0  0 pass  adjustment.128x64x1
Y Y Y Y 16 16 16 16  0 16 16 16 16 16 16  0  0 16 16  0  0 pass  adjustment.cs-32x32x1
Y Y Y Y 16 16 16 16  0 16 16 16 16 16 16 22  0 16 16 22  0 pass  adjust_nlfs.cs-32x32x1
Y Y Y Y -- 13 13 16 16 13 13 13 13 16 16 16 16 16 16 16 16 N/O   advect_cs
Y Y Y Y -- 22 16 16 16 16 16 16 13 16 16 16 16 16 16 16 16 N/O   advect_xy
Y Y Y Y -- 13 16 13 16 16 16 16 16 16 16 22 16 16 16 16 16 N/O   advect_xz
Y Y Y Y 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 pass  aim.5l_cs
Y Y Y Y 14 16 16 16 16 16 16 16 16 13 16 16 16 16 16 13 16 pass  aim.5l_Equatorial_Channel
Y Y Y Y 16 16 16 16 16 16 16 16 16 16 16 13 16 16 13 13 16 pass  aim.5l_LatLon
Y Y Y Y 13 16 16 16 16 16 16 16 16 16 13 12 13 13 16 13 16 pass  exp0
Y Y Y Y 14 16 16 16 16 16 16 16 22 16 16 16 13 16 16 22 16 pass  exp1
Y Y Y Y 13 13 16 13 16 16 16 16 16 13 13 16 16 13 13 13 13 pass  exp2
Y Y Y Y 16 16 16 16 16 16 16 16 22 16 16 16 16 16 16 16 16 pass  exp4
Y Y Y Y 16 16 16 16 16 16 16 16 16 16 16 22 16 16 16 22 16 pass  exp5
Y Y Y Y 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 pass  front_relax
Y Y Y Y 14 16 16 13 13 16 16 13 13 16 13 13 16 12 13 13 16 pass  global_ocean.90x40x15
Y Y Y Y 10 16 16 13 13 16 13 16 16 13 13 13 13 16 16 13 16 FAIL  global_ocean.cs32x15
Y Y Y Y  6 11 12 13 13 12 13 16 13  9  9  9  9 10  9  9 11 FAIL  global_ocean_pressure
Y Y Y Y 14 16 16 13 16 16 16 13 13 13 13 13 16 12 16 13 16 pass  global_with_exf
Y Y Y Y 14 16 16 16 16 16 16 16 16 11 13 22 13 16 16  9 16 pass  hs94.128x64x5
Y Y Y Y 13 16 16 16 16 16 16 16 16 11 16 16 16 13 16 22 13 pass  hs94.1x64x5
Y Y Y Y 14 16 16 16 16 16 16 16 16 13 16 13 13 16 16 22 13 pass  hs94.cs-32x32x5
Y Y Y Y 10 10 16 13 13 16 16 16 22 16 13 13 13 13 13 22 13 FAIL  ideal_2D_oce
Y Y Y Y  8 16 16 16 16 16 16 16 16 13 13  8 16 16 16 16 16 FAIL  internal_wave
Y Y Y Y 14 16 16 16 16 16 16 16 16 13 13 22 13 13 13 22 16 pass  inverted_barometer
Y Y Y Y 12 16 16 16 16 16 16 16 16 16 13 12 13 13 13 13 13 FAIL  lab_sea
Y Y Y Y 11 16 16 16 16 16 16 16 13 13 13 12 13 16 13 12 13 FAIL  natl_box
Y Y Y Y 16 16 16 16 16 16 16 16 22 16 16 16 16 16 16 16 16 pass  plume_on_slope
Y Y Y Y 13 16 16 16 16 13 16 16 16 16 16 16 16 13 16 16 16 pass  solid-body.cs-32x32x1

1 #!/bin/bash
2 #
3 # $Header: /u/u3/gcmpack/MITgcm/tools/genmake2,v 1.11.2.13 2003/10/08 05:58:50 edhill Exp $
4 #
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 # 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
71 find_possible_configs() {
72
73 tmp1=`uname`"_"`uname -m`
74 tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
75 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 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
91 ln -s ./test link
92 RETVAL=$?
93 if test "x${RETVAL}" = x0 ; then
94 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
100 rm -f test link
101
102 if test "x$CPP" = x ; then
103 CPP="cpp -traditional -P"
104 fi
105
106 # look for possible fortran compilers
107 tmp="$MITGCM_FC $FC g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"
108 p_FC=
109 for c in $tmp ; do
110 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=$?
120 if test "x${RETVAL}" = x0 ; then
121 p_FC="$p_FC $c"
122 fi
123 done
124 if test "x${p_FC}" = x ; then
125 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
136 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
142
143 for i in $p_FC ; do
144 p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
145 if test -r $p_OF ; then
146 OPTFILE=$p_OF
147 echo " The options file: $p_OF"
148 echo " appears to match so we'll use it."
149 break
150 fi
151 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
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
199 # Parse the package dependency information
200 get_pdepend_list() {
201
202 # strip the comments and then convert the dependency file into
203 # two arrays: PNAME, DNAME
204 cat $1 | sed -e 's/#.*$//g' \
205 | awk 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \
206 > ./.pd_tmp
207 source ./.pd_tmp
208 rm -f ./.pd_tmp
209
210 echo -n "PNAME = "${}
211 }
212
213
214 # Explain usage
215 usage() {
216 echo
217 echo "Usage: "$0" [OPTIONS]"
218 echo " where [OPTIONS] can be:"
219 echo
220 echo " -help | --help | -h | --h"
221 echo " -nooptfile | --nooptfile"
222 echo " -optfile NAME | --optfile NAME | -of NAME | --of NAME"
223 echo " -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME"
224 echo " -pdepend NAME | --pdepend NAME"
225 echo " -pdepend=NAME | --pdepend=NAME"
226 echo " -pdefault NAME | --pdefault NAME"
227 echo " -pdefault=NAME | --pdefault=NAME"
228 echo " -make NAME | -m NAME"
229 echo " --make=NAME | -m=NAME"
230 echo " -makefile NAME | -mf NAME"
231 echo " --makefile=NAME | -mf=NAME"
232 echo " -platform NAME | --platform NAME | -pl NAME | --pl NAME"
233 echo " -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME"
234 echo " -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME"
235 echo " -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME"
236 echo " -mods NAME | --mods NAME | -mo NAME | --mo NAME"
237 echo " -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME"
238 echo " -disable NAME | --disable NAME"
239 echo " -disable=NAME | --disable=NAME"
240 echo " -enable NAME | --enable NAME"
241 echo " -enable=NAME | --enable=NAME"
242 echo " -standarddirs NAME | --standarddirs NAME"
243 echo " -standarddirs=NAME | --standarddirs=NAME"
244 echo " -noopt NAME | --noopt NAME"
245 echo " -noopt=NAME | --noopt=NAME"
246 # echo " -cpp NAME | --cpp NAME"
247 # echo " -cpp=NAME | --cpp=NAME"
248 echo " -fortran NAME | --fortran NAME | -fc NAME | --fc NAME"
249 echo " -fc=NAME | --fc=NAME"
250 echo " -[no]ieee | --[no]ieee"
251 echo " -[no]mpi | --[no]mpi"
252 echo " -[no]jam | --[no]jam"
253 echo
254 echo " and NAME is a string such as:"
255 echo
256 echo " --enable pkg1 --enable 'pkg1 pkg2' --enable 'pkg1 pkg2 pkg3'"
257 echo " -mods=dir1 -mods='dir1' -mods='dir1 dir2 dir3'"
258 echo " -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'"
259 echo
260 echo " which, depending upon your shell, may need to be single-quoted"
261 echo " if it contains spaces, dashes, or other special characters."
262 exit 1
263 }
264
265 #eh3 # This is the generic configuration.
266 #eh3 set LN = ( 'ln -s' )
267 #eh3 set CPP = ( '/lib/cpp -P' )
268 #eh3 set S64 = ( '$(TOOLSDIR)/set64bitConst.sh' )
269 #eh3 set KPP = ( )
270 #eh3 set FC = ( 'f77' )
271 #eh3 set LINK = $FC
272 #eh3 set MAKEDEPEND = ( 'makedepend' )
273 #eh3 set INCLUDES = ( -I. )
274 #eh3 set FFLAGS = ( )
275 #eh3 set FOPTIM = ( )
276 #eh3 set CFLAGS = ( )
277 #eh3 set KFLAGS1 = ( )
278 #eh3 set KFLAGS2 = ( )
279 #eh3 set LIBS = ( )
280 #eh3 set KPPFILES = ( )
281 #eh3 if (! $?NOOPTFILES ) set NOOPTFILES = ( )
282 #eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = ( )
283
284 # Set defaults here
285 COMMANDL="$0 $@"
286
287 PLATFORM=
288 LN=
289 S64=
290 KPP=
291 FC=
292 LINK=
293 DEFINES="-DWORDLENGTH=4"
294 PACKAGES=
295 ENABLE=
296 DISABLE=
297 MAKEFILE=
298 MAKEDEPEND=
299 PDEPEND=
300 DUMPSTATE=t
301 PDEFAULT=
302 OPTFILE=
303 INCLUDES="-I."
304 FFLAGS=
305 FOPTIM=
306 CFLAGS=
307 KFLAGS1=
308 KFLAGS2=
309 LIBS=
310 KPPFILES=
311 NOOPTFILES=
312 NOOPTFLAGS=
313
314 MODS=
315 TOOLSDIR=
316 SOURCEDIRS=
317 INCLUDEDIRS=
318 STANDARDDIRS=
319
320 PWD=`pwd`
321 MAKE=make
322 THISHOSTNAME=`hostname`
323 THISCWD=`pwd`
324 THISDATE=`date`
325 MACHINE=`uname -a`
326 EXECUTABLE=
327 EXEHOOK=
328 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
336 gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"
337 gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS"
338
339 # 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 "
341 gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
342 gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"
343 gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
344
345 gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6"
346
347
348 echo
349 echo "=== Processing options files and arguments ==="
350 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: "
358 if test -e $gm_local ; then
359 echo "using $gm_local"
360 source $gm_local
361 # echo "DISABLE=$DISABLE"
362 # echo "ENABLE=$ENABLE"
363 else
364 echo "none found"
365 fi
366
367 # echo "$0::$1:$2:$3:$4:$5:$6:$7:"
368 #OPTIONS=
369 #n=0
370 #for i ; do
371 # echo "$i $n"
372 # setvar="OPTIONS[$n]='$i'"
373 # # echo " $setvar"
374 # eval "$setvar"
375 # n=$(( $n + 1 ))
376 #done
377 #parse_options
378
379 ac_prev=
380 for ac_option ; do
381
382 # If the previous option needs an argument, assign it.
383 if test -n "$ac_prev"; then
384 eval "$ac_prev=\$ac_option"
385 ac_prev=
386 continue
387 fi
388
389 ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
390
391 case $ac_option in
392
393 -help | --help | -h | --h)
394 usage ;;
395
396 -nooptfile | --nooptfile)
397 OPTFILE="NONE" ;;
398 -optfile | --optfile | -of | --of)
399 ac_prev=OPTFILE ;;
400 -optfile=* | --optfile=* | -of=* | --of=*)
401 OPTFILE=$ac_optarg ;;
402
403 -pdepend | --pdepend)
404 ac_prev=PDEPEND ;;
405 -pdepend=* | --pdepend=*)
406 PDEPEND=$ac_optarg ;;
407
408 -pdefault | --pdefault)
409 ac_prev=PDEFAULT ;;
410 -pdefault=* | --pdefault=*)
411 PDEFAULT=$ac_optarg ;;
412
413 -make | --make | -m | --m)
414 ac_prev=MAKE ;;
415 -make=* | --make=* | -m=* | --m=*)
416 MAKE=$ac_optarg ;;
417
418 -makefile | --makefile | -ma | --ma)
419 ac_prev=MAKEFILE ;;
420 -makefile=* | --makefile=* | -ma=* | --ma=*)
421 MAKEFILE=$ac_optarg ;;
422
423 -platform | --platform | -pl | --pl)
424 ac_prev=PLATFORM ;;
425 -platform=* | --platform=* | -pl=* | --pl=*)
426 PLATFORM=$ac_optarg ;;
427
428 -rootdir | --rootdir | -rd | --rd)
429 ac_prev=ROOTDIR ;;
430 -rootdir=* | --rootdir=* | -rd=* | --rd=*)
431 ROOTDIR=$ac_optarg ;;
432
433 -mods | --mods | -mo | --mo)
434 ac_prev=MODS ;;
435 -mods=* | --mods=* | -mo=* | --mo=*)
436 MODS=$ac_optarg ;;
437
438 -disable | --disable)
439 ac_prev=DISABLE ;;
440 -disable=* | --disable=*)
441 DISABLE=$ac_optarg ;;
442
443 -enable | --enable)
444 ac_prev=ENABLE ;;
445 -enable=* | --enable=*)
446 ENABLE=$ac_optarg ;;
447
448 -standarddirs | --standarddirs)
449 ac_prev=STANDARDDIRS ;;
450 -standarddirs=* | --standarddirs=*)
451 STANDARDDIRS=$ac_optarg ;;
452
453 -noopt | --noopt)
454 ac_prev=NOOPT ;;
455 -noopt=* | --noopt=*)
456 NOOPT=$ac_optarg ;;
457
458 # -cpp | --cpp)
459 # ac_prev=cpp ;;
460 # -cpp=* | --cpp=*)
461 # CPP=$ac_optarg ;;
462
463 -fortran | --fortran | -fc | --fc)
464 ac_prev=FC ;;
465 -fc=* | --fc=*)
466 FC=$ac_optarg ;;
467
468 -ieee | --ieee)
469 IEEE=true ;;
470 -noieee | --noieee)
471 IEEE= ;;
472
473 -mpi | --mpi)
474 MPI=true ;;
475 -nompi | --nompi)
476 MPI= ;;
477
478 -jam | --jam)
479 JAM=1 ;;
480 -nojam | --nojam)
481 JAM=0 ;;
482
483 -ds | --ds)
484 DUMPSTATE=t ;;
485
486 -*)
487 echo "Error: unrecognized option: "$ac_option
488 usage
489 ;;
490
491 *)
492 echo "Error: unrecognized argument: "$ac_option
493 usage
494 ;;
495
496 esac
497
498 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: "
538 if test "x${OPTFILE}" = x ; then
539 if test "x$MITGCM_OF" = x ; then
540 echo "Warning: no OPTFILE specified so we'll look for possible settings"
541 printf "\n=== Searching for possible settings for OPTFILE ===\n"
542 find_possible_configs
543 else
544 OPTFILE=$MITGCM_OF
545 fi
546 fi
547 if test "x$OPTFILE" != xNONE ; then
548 if test -f "$OPTFILE" -a -r "$OPTFILE" ; then
549 echo " using OPTFILE=\"$OPTFILE\""
550 source "$OPTFILE"
551 RETVAL=$?
552 if test "x$RETVAL" != x0 ; then
553 echo -n "Error: failed to source OPTFILE \"$OPTFILE\""
554 echo "--please check that variable syntax is bash-compatible"
555 exit 1
556 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
564 fi
565
566 # Check that FC, LINK, CPP, and S64 are defined. If not, complain
567 # and abort!
568 if test "x$FC" = x ; then
569 cat <<EOF 1>&2
570
571 Error: no Fortran compiler: please specify using one of the following:
572 1) within the options file ("FC=...") as specified by "-of=OPTFILE"
573 2) the "-fc=XXX" command-line option
574 3) the "./genmake_local" file
575 EOF
576 exit 1
577 fi
578 if test "x$LINK" = x ; then
579 LINK=$FC
580 fi
581 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
588
589 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"
592 2) the "./genmake_local" file
593
594 EOF
595 exit 1
596 else
597 rm -f test_cpp
598 fi
599 if test "x$MAKEDEPEND" = x ; then
600 MAKEDEPEND=makedepend
601 fi
602
603 printf "\n=== Setting defaults ===\n"
604 echo -n " Adding MODS directories: "
605 for d in $MODS ; do
606 if test ! -d $d ; then
607 echo
608 echo "Error: MODS directory \"$d\" not found!"
609 exit 1
610 else
611 echo -n " $d"
612 SOURCEDIRS="$SOURCEDIRS $d"
613 INCLUDEDIRS="$INCLUDEDIRS $d"
614 fi
615 done
616 echo
617
618 if test "x$MAKEFILE" = x ; then
619 MAKEFILE="Makefile"
620 fi
621 if test "x${PLATFORM}" = x ; then
622 PLATFORM=$p_PLATFORM
623 fi
624
625 if test "x${EXEDIR}" = x ; then
626 if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then
627 EXEDIR=../exe
628 else
629 EXEDIR=.
630 fi
631 fi
632 if test ! -d ${EXEDIR} ; then
633 echo "Error: the specified EXEDIR (\"$EXEDIR\") does not exist!"
634 exit 1
635 fi
636
637 if test "x${TOOLSDIR}" = x ; then
638 TOOLSDIR="$ROOTDIR/tools"
639 fi
640 if test ! -d ${TOOLSDIR} ; then
641 echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"
642 exit 1
643 fi
644 if test "x$S64" = x ; then
645 S64='$(TOOLSDIR)/set64bitConst.sh'
646 fi
647
648 EXECUTABLE=${EXECUTABLE:-mitgcmuv}
649
650 # We have a special set of source files in eesupp/src which are
651 # generated from some template source files. We'll make them first so
652 # they appear as regular source code
653 if test -r $ROOTDIR"/eesupp/src/Makefile" ; then
654 echo " Making source files in eesupp from templates"
655 $MAKE -C $ROOTDIR"/eesupp/src/" > make_eesupp.errors 2>&1
656 RETVAL=$?
657 if test "x${RETVAL}" = x0 ; then
658 rm -f make_eesupp.errors
659 else
660 echo "Error: problem encountered while building source files in eesupp:"
661 cat make_eesupp.errors
662 exit 1
663 fi
664 fi
665
666 printf "\n=== Determining package settings ===\n"
667 if test "x${PDEPEND}" = x ; then
668 tmp=$ROOTDIR"/pkg/pkg_depend"
669 if test -r $tmp ; then
670 PDEPEND=$tmp
671 else
672 echo "Warning: No package dependency information was specified."
673 echo " Please check that ROOTDIR/pkg/pkg_depend exists."
674 fi
675 else
676 if test ! -r ${PDEPEND} ; then
677 echo "Error: can't read package dependency info from PDEPEND=\"$PDEPEND\""
678 exit 1
679 fi
680 fi
681 echo " getting package dependency info from $PDEPEND"
682 # Strip the comments and then convert the dependency file into
683 # two arrays: PNAME, DNAME
684 cat $PDEPEND | sed -e 's/#.*$//g' \
685 | awk 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \
686 > ./.pd_tmp
687 RETVAL=$?
688 if test ! "x${RETVAL}" = x0 ; then
689 echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""
690 exit 1
691 fi
692 source ./.pd_tmp
693 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: "
699 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"
709 fi
710 if test "x${PDEFAULT}" = xNONE ; then
711 echo "default packages file disabled"
712 else
713 if test ! -r $PDEFAULT ; then
714 echo ""
715 echo "Warning: can't read default packages from PDEFAULT=\"$PDEFAULT\""
716 else
717 echo " using PDEFAULT=\"$PDEFAULT\""
718 # Strip the comments and add all the names
719 def=`cat $PDEFAULT | sed -e 's/#.*$//g' | awk '(NF>0){print $0}'`
720 RETVAL=$?
721 if test "x${RETVAL}" != x0 ; then
722 echo -n "Error: can't parse default package list "
723 echo "-- please check PDEFAULT=\"$PDEFAULT\""
724 exit 1
725 fi
726 for i in $def ; do
727 PACKAGES="$PACKAGES $i"
728 done
729 echo " before group expansion packages are: $PACKAGES"
730 expand_pkg_groups
731 echo " after group expansion packages are: $PACKAGES"
732 fi
733 fi
734
735 echo " applying DISABLE settings"
736 pack=
737 for p in $PACKAGES ; do
738 addit="t"
739 for d in $DISABLE ; do
740 if test "x$p" = "x$d" ; then
741 addit="f"
742 fi
743 done
744 if test "x$addit" = xt ; then
745 pack="$pack $p"
746 fi
747 done
748 PACKAGES="$pack"
749 echo " applying ENABLE settings"
750 echo "" > ./.tmp_pack
751 PACKAGES="$PACKAGES $ENABLE"
752 for i in $PACKAGES ; do
753 if test ! -d "$ROOTDIR/pkg/$i" ; then
754 echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""
755 exit 1
756 fi
757 echo $i >> ./.tmp_pack
758 done
759 pack=`cat ./.tmp_pack | sort | uniq`
760 rm -f ./.tmp_pack
761 PACKAGES=
762 for i in $pack ; do
763 PACKAGES="$PACKAGES $i"
764 done
765 echo " packages are: $PACKAGES"
766
767 echo " applying package dependency rules"
768 ck=
769 while test "x$ck" != xtt ; do
770 i=0
771 # rtot=${#PNAME[@]}
772 rtot=$nname
773 while test $i -lt $rtot ; do
774
775 # Is $pname in the current $PACKAGES list?
776 # pname=${PNAME[$i]}
777 tmp="pname=\"\$PNAME_$i\""
778 eval $tmp
779 pin="f"
780 for p in $PACKAGES ; do
781 if test "x$p" = "x$pname" ; then
782 pin="t"
783 fi
784 done
785
786 # Is the DNAME entry a (+) or (-) rule ?
787 tmp="dname=\"\$DNAME_$i\""
788 eval $tmp
789 plus="-"
790 echo $dname | grep '^+' > /dev/null 2>&1
791 RETVAL=$?
792 if test "x$RETVAL" = x0 ; then
793 plus="+"
794 fi
795
796 # Is $dname in the current $PACKAGES list?
797 dname=`echo $dname | sed -e 's/^[+-]//'`
798 din="f"
799 for p in $PACKAGES ; do
800 if test "x$p" = "x$dname" ; then
801 din="t"
802 fi
803 done
804
805 # Do we need to add $dname according to the dependency rules?
806 if test "x$pin" = xt -a "x$plus" = "x+" -a "x$din" = xf ; then
807 in_dis="f"
808 for dis in $DISABLE ; do
809 if test "x$dis" = "x$dname" ; then
810 in_dis="t"
811 fi
812 done
813 if test "x$in_dis" = xt ; then
814 echo "Error: can't satisfy package dependencies:"
815 echo " \"$dname\" is required by the dependency rules"
816 echo " but is disallowed by the DISABLE settings"
817 exit 1
818 else
819 PACKAGES="$PACKAGES $dname"
820 ck=
821 fi
822 fi
823
824 # Do we need to get rid of $dname according to the dependency rules?
825 if test "x$pin" = xt -a "x$plus" = "x-" -a "x$din" = xt; then
826 echo "Error: can't satisfy package dependencies:"
827 echo " \"$pname\" was requested but is disallowed by"
828 echo " the dependency rules for \"$dname\""
829 exit 1
830 fi
831 i=$(( $i + 1 ))
832 done
833 ck=$ck"t"
834 done
835 echo " packages are: $PACKAGES"
836 for i in $PACKAGES ; do
837 adr="$ROOTDIR/pkg/$i"
838 if test -d $adr ; then
839 SOURCEDIRS="$SOURCEDIRS $adr"
840 INCLUDEDIRS="$INCLUDEDIRS $adr"
841 else
842 echo "Error: the directory \"$adr\" for package $i doesn't exist"
843 exit 1
844 fi
845 done
846
847 # This is compatible with the old genmake. The "DISABLE_*" flags
848 # need to be replaced by the "ALLOW_*" flags set below.
849 #
850 # echo -n " Setting package-specific CPP flags: "
851 # pkrm=( mom_fluxform mom_vecinv generic_advdiff )
852 # pkrmdef=( -DDISABLE_MOM_FLUXFORM -DDISABLE_MOM_VECINV -DDISABLE_GENERIC_ADVDIFF -DDISABLE_DEBUGMODE )
853 # echo -n " "
854 # i=0
855 # while test $i -lt "${#pkrm[@]}" ; do
856 # echo "$PACKAGES" | grep "${pk[$i]}" > /dev/null 2>&1
857 # RETVAL=$?
858 # if test "x$RETVAL" = x1 ; then
859 # DEFINES="$DEFINES ${pkdef[$i]}"
860 # echo -n " ${pkdef[$i]}"
861 # fi
862 # i=$(( $i + 1 ))
863 # done
864 # echo
865
866 # Create a list of #define and #undef to enable/disable packages
867 PACKAGES_DOT_H=PACKAGES_CONFIG.h
868 cat <<EOF >$PACKAGES_DOT_H".tmp"
869 C=== GENMAKE v2 ===
870 C The following defines have been set by GENMAKE, so please do not
871 C edit anything below these comments. In general, you should
872 C add or remove packages by re-running genmake with different
873 C "-enable" and/or "-disable" options.
874
875 #ifndef PACKAGES_H
876 #define PACKAGES_H
877
878 C Packages disabled by genmake:
879 EOF
880 # The following UGLY HACK sets multiple "#undef"s and it needs to go
881 # away. On 2003-08-12, CNH, JMC, and EH3 agreed that the CPP_OPTIONS.h
882 # file would eventually be split up so that all package-related #define
883 # statements could be separated and handled only by genmake.
884 names=`ls -1 "$ROOTDIR/pkg"`
885 all_pack=
886 for n in $names ; do
887 if test -d "$ROOTDIR/pkg/$n" -a "x$n" != xCVS ; then
888 has_pack="f"
889 for pack in $PACKAGES ; do
890 if test "x$pack" = "x$n" ; then
891 has_pack="t"
892 break
893 fi
894 done
895 if test "x$has_pack" = xf ; then
896 undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`
897 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!!!
901 case $n in
902 mom_fluxform)
903 DEFINES="$DEFINES -DDISABLE_MOM_FLUXFORM"
904 ;;
905 mom_vecinv)
906 DEFINES="$DEFINES -DDISABLE_MOM_VECINV"
907 ;;
908 debug)
909 DEFINES="$DEFINES -DDISABLE_DEBUGMODE"
910 ;;
911 esac
912 #EH3 WARNING : This is an UGLY HACK that needs to be removed!!!
913
914 fi
915 fi
916 done
917 cat <<EOF >>$PACKAGES_DOT_H".tmp"
918
919 C Packages enabled by genmake:
920 EOF
921 for i in $PACKAGES ; do
922 def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`
923 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!!!
927 case $i in
928 aim_v23)
929 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
934 #EH3 WARNING : This is an UGLY HACK that needs to be removed!!!
935
936 done
937 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"
956 BUILDDIR=${BUILDDIR:-.}
957 if test "x$STANDARDDIRS" = x ; then
958 STANDARDDIRS="eesupp model"
959 fi
960 for d in $STANDARDDIRS ; do
961 adr="$ROOTDIR/$d/src"
962 if test ! -d $adr ; then
963 echo "Error: directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
964 echo " is correct and that you correctly specified the STANDARDDIRS option"
965 exit 1
966 else
967 SOURCEDIRS="$SOURCEDIRS $adr"
968 fi
969 adr="$ROOTDIR/$d/inc"
970 if test ! -d $adr ; then
971 echo "Error: directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
972 echo " is correct and that you correctly specified the STANDARDDIRS option"
973 exit 1
974 else
975 INCLUDEDIRS="$INCLUDEDIRS $adr"
976 fi
977 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
1004 echo "=== Creating the Makefile ==="
1005 echo " setting INCLUDES"
1006 for i in $INCLUDEDIRS ; do
1007 if ! test -d $i ; then
1008 # INCLUDES="$INCLUDES -I$i"
1009 # else
1010 echo "Warning: can't find INCLUDEDIRS=\"$i\""
1011 fi
1012 done
1013
1014 echo " Determining the list of source and include files"
1015 rm -rf .links.tmp
1016 mkdir .links.tmp
1017 echo "# This section creates symbolic links" > srclinks.tmp
1018 echo "" >> srclinks.tmp
1019 echo -n 'SRCFILES = ' > srclist.inc
1020 echo -n 'CSRCFILES = ' > csrclist.inc
1021 echo -n 'F90SRCFILES = ' > f90srclist.inc
1022 echo -n 'HEADERFILES = ' > hlist.inc
1023 alldirs="$SOURCEDIRS $INCLUDEDIRS ."
1024 for d in $alldirs ; do
1025 deplist=
1026 sfiles=`( cd $d; echo *.[h,c,F] )`
1027 sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
1028 for sf in $sfiles ; do
1029 if test ! -r ".links.tmp/$sf" ; then
1030 if test -f "$d/$sf" ; then
1031 extn=`echo $sf | awk -F '.' '{print $NF}'`
1032 touch .links.tmp/$sf
1033 deplist="$deplist $sf"
1034 case $extn in
1035 F)
1036 echo " \\" >> srclist.inc
1037 echo -n " $sf" >> srclist.inc
1038 ;;
1039 F90)
1040 echo " \\" >> f90srclist.inc
1041 echo -n " $sf" >> f90srclist.inc
1042 ;;
1043 c)
1044 echo " \\" >> csrclist.inc
1045 echo -n " $sf" >> csrclist.inc
1046 ;;
1047 h)
1048 echo " \\" >> hlist.inc
1049 echo -n " $sf" >> hlist.inc
1050 ;;
1051 esac
1052 fi
1053 fi
1054 done
1055 if test "x$deplist" != x ; then
1056 echo "" >> srclinks.tmp
1057 echo "# These files are linked from $d" >> srclinks.tmp
1058 echo "$deplist :" >> srclinks.tmp
1059 printf "\t\$(LN) %s/\$@ \$@\n" $d >> srclinks.tmp
1060 fi
1061 done
1062 rm -rf .links.tmp
1063 echo "" >> srclist.inc
1064 echo "" >> csrclist.inc
1065 echo "" >> f90srclist.inc
1066 echo "" >> hlist.inc
1067
1068 if test -e $MAKEFILE ; then
1069 mv -f $MAKEFILE "$MAKEFILE.bak"
1070 fi
1071 echo " Writing makefile: $MAKEFILE"
1072 echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE
1073 echo "# $MACHINE" >> $MAKEFILE
1074 echo "# This makefile was generated automatically on" >> $MAKEFILE
1075 echo "# $THISDATE" >> $MAKEFILE
1076 echo "# by the command:" >> $MAKEFILE
1077 echo "# $0 $@" >> $MAKEFILE
1078 echo "# executed by:" >> $MAKEFILE
1079 echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE
1080 cat >>$MAKEFILE <<EOF
1081 #
1082 # BUILDDIR : Directory where object files are written
1083 # SOURCEDIRS : Directories containing the source (.F) files
1084 # INCLUDEDIRS : Directories containing the header-source (.h) files
1085 # EXEDIR : Directory where executable that is generated is written
1086 # EXECUTABLE : Full path of executable binary
1087 #
1088 # CPP : C-preprocessor command
1089 # INCLUDES : Directories searched for header files
1090 # DEFINES : Macro definitions for CPP
1091 # MAKEDEPEND : Dependency generator
1092 # KPP : Special preprocessor command (specific to platform)
1093 # KFLAGS : Flags for KPP
1094 # FC : Fortran compiler command
1095 # FFLAGS : Configuration/debugging options for FC
1096 # FOPTIM : Optimization options for FC
1097 # LINK : Command for link editor program
1098 # LIBS : Library flags /or/ additional optimization/debugging flags
1099
1100 ROOTDIR = ${ROOTDIR}
1101 BUILDDIR = ${BUILDDIR}
1102 SOURCEDIRS = ${SOURCEDIRS}
1103 INCLUDEDIRS = ${INCLUDEDIRS}
1104 EXEDIR = ${EXEDIR}
1105 EXECUTABLE = \$(EXEDIR)/${EXECUTABLE}
1106 TOOLSDIR = ${TOOLSDIR}
1107
1108 EOF
1109
1110 # Note: figure out some way to add Hyades JAM libraries here
1111
1112 cat >>$MAKEFILE <<EOF
1113 # Unix ln (link)
1114 LN = ${LN}
1115 # C preprocessor
1116 CPP = cat \$< | ${S64} | ${CPP}
1117 # Dependency generator
1118 MAKEDEPEND = ${MAKEDEPEND}
1119 # Special preprocessor (KAP on DECs, FPP on Crays)
1120 KPP = ${KPP}
1121 # Fortran compiler
1122 FC = ${FC}
1123 # Fortran compiler
1124 F90C = ${F90C}
1125 # Link editor
1126 LINK = ${LINK}
1127
1128 # Defines for CPP
1129 DEFINES = ${DEFINES}
1130 # Includes for CPP
1131 INCLUDES = ${INCLUDES}
1132 # Flags for KPP
1133 KFLAGS1 = ${KFLAGS1}
1134 KFLAGS2 = ${KFLAGS2}
1135 # Optim./debug for FC
1136 FFLAGS = ${FFLAGS}
1137 FOPTIM = ${FOPTIM}
1138 # Optim./debug for FC
1139 F90FLAGS = ${F90FLAGS}
1140 F90OPTIM = ${F90OPTIM}
1141 # Flags for CC
1142 CFLAGS = ${CFLAGS}
1143 # Files that should not be optimized
1144 NOOPTFILES = ${NOOPTFILES}
1145 NOOPTFLAGS = ${NOOPTFLAGS}
1146 # Flags and libraries needed for linking
1147 LIBS = ${LIBS} \$(XLIBS)
1148 # Name of the Mekfile
1149 MAKEFILE=${MAKEFILE}
1150
1151 EOF
1152
1153 cat srclist.inc >> $MAKEFILE
1154 cat csrclist.inc >> $MAKEFILE
1155 cat f90srclist.inc >> $MAKEFILE
1156 cat hlist.inc >> $MAKEFILE
1157 echo 'F77FILES = $(SRCFILES:.F=.f)' >> $MAKEFILE
1158 echo 'F90FILES = $(F90SRCFILES:.F90=.f90)' >> $MAKEFILE
1159 echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
1160
1161 rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc
1162
1163 cat >>$MAKEFILE <<EOF
1164
1165 .SUFFIXES:
1166 .SUFFIXES: .o .f .p .F .c .F90 .f90
1167
1168 all: \$(EXECUTABLE)
1169 \$(EXECUTABLE): \$(OBJFILES)
1170 \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
1171 depend:
1172 @make links
1173 \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
1174 ${TOOLSDIR}/f90mkdepend >> \$(MAKEFILE)
1175
1176 links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES)
1177
1178 small_f: \$(F77FILES) \$(F90FILES)
1179
1180 output.txt: \$(EXECUTABLE)
1181 @printf 'running ... '
1182 @\$(EXECUTABLE) > \$@
1183
1184 clean:
1185 -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl}
1186 Clean:
1187 @make clean
1188 @make cleanlinks
1189 -rm -f Makefile.bak genmake_state genmake_optfile make.log
1190 CLEAN:
1191 @make Clean
1192 -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
1193 -find \$(EXEDIR) -name "*.data" -exec rm {} \;
1194 -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
1195 -rm -f \$(EXECUTABLE) output.txt
1196
1197 makefile:
1198 ${0} $@
1199 cleanlinks:
1200 -find . -type l -exec rm {} \;
1201
1202 # The normal chain of rules is ( .F - .f - .o )
1203 .F.f:
1204 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1205 .f.o:
1206 \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
1207 .F90.f90:
1208 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1209 .f90.o:
1210 \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
1211 .c.o:
1212 \$(CC) \$(CFLAGS) -c \$<
1213
1214 # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain
1215 .F.p:
1216 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1217 .p.f:
1218 \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
1219
1220 EOF
1221
1222 if test "x$EXEHOOK" != x ; then
1223 printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE
1224 fi
1225
1226 echo " Making list of \"exceptions\" that need \".p\" files"
1227 for i in $KPPFILES ; do
1228 base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`
1229 RETVAL=$?
1230 if test "x$RETVAL" != x0 ; then
1231 echo "Error: unable to add file \"$i\" to the exceptions list"
1232 fi
1233 echo "$base.f: $base.p" >> $MAKEFILE
1234 done
1235
1236 echo " Making list of NOOPTFILES"
1237 for i in $NOOPTFILES ; do
1238 base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`
1239 RETVAL=$?
1240 if test "x$RETVAL" != x0 ; then
1241 echo "Error: unable to add file \"$i\" to the exceptions list"
1242 fi
1243 echo "$base.o: $base.f" >> $MAKEFILE
1244 printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE
1245 done
1246
1247 echo " Add rules for links"
1248 cat srclinks.tmp >> $MAKEFILE
1249 rm -f srclinks.tmp
1250
1251 echo " Adding makedepend marker"
1252 printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE
1253
1254 printf "\n=== Done ===\n"
1255
1256
1257 # Write the "state" for future records
1258 if test "x$DUMPSTATE" != xf ; then
1259 echo -n "" > genmake_state
1260 for i in $gm_state ; do
1261 t1="t2=\$$i"
1262 eval $t1
1263 echo "$i='$t2'" >> genmake_state
1264 done
1265 fi

  ViewVC Help
Powered by ViewVC 1.1.22