/[MITgcm]/MITgcm/tools/genmake
ViewVC logotype

Contents of /MITgcm/tools/genmake

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


Revision 1.35 - (show annotations) (download)
Tue May 29 14:01:40 2001 UTC (22 years, 10 months ago) by adcroft
Branch: MAIN
Changes since 1.34: +57 -11 lines
Merge from branch pre38:
 o essential mods for cubed sphere
 o debugged atmosphere, dynamcis + physics (aim)
 o new packages (mom_vecinv, mom_fluxform, ...)

1 #!/bin/csh -f
2 #
3 # $Header: /u/gcmpack/models/MITgcmUV/tools/genmake,v 1.33.2.9 2001/05/09 14:13:03 adcroft Exp $
4 # $Name: $
5 #
6 # Makefile generator for MITgcm UV codes
7 # created by cnh 03/98
8 # adapted by aja 06/98
9 # modified by aja 01/00
10
11 # Default lists
12 set DISABLE = ( aim autodiff cal cost ctrl ecco exf )
13 set ENABLE = ( )
14 set MODS = ( )
15
16 # Grab variables/lists from .genmakerc
17 if (-r .genmakerc) source .genmakerc
18
19 # Process command-line arguments
20 set allargs=( $argv )
21 while ($#allargs)
22 set arg = $allargs[1]
23 switch ($arg)
24 case -makefile:
25 set mfile = ( Makefile )
26 breaksw
27 case -makefile=*:
28 set mfile = ( `echo $arg | sed 's/-makefile=//' `)
29 breaksw
30 case -platform:
31 case -platform=:
32 echo "To change platform you must specify one with -platform="
33 echo "eg. -platform=sparc or -platform=mips"
34 exit
35 breaksw
36 case -platform*:
37 if ($?platform) then
38 echo Option -platform=dir can only be specified once.; exit 1
39 endif
40 set platform = ( `echo $arg | sed 's/-platform=//' `)
41 breaksw
42 case -rootdir:
43 case -rootdir=:
44 echo "To specify root directory you must specify one with -rootdir=dir"
45 echo "with NO space eg. -rootdir=../../.. or -rootdir=/usr/people/joe/src"
46 exit
47 breaksw
48 case -rootdir=*:
49 if ($?ROOTDIR) then
50 echo "***" Warning: variable \$ROOTDIR is already set to $ROOTDIR
51 echo "***" Command line \"$arg\" will override this.
52 endif
53 set ROOTDIR = ( `echo $arg | sed 's/-rootdir=//' `)
54 breaksw
55 case -mods:
56 case -mods=:
57 echo "To specify an additional source directory you must specify one with -mods=dir"
58 echo "with NO space eg. -mods=../code or -mods=/usr/people/joe/src"
59 exit
60 breaksw
61 case -mods=*:
62 set MODS = ( $MODS `echo $arg | sed 's/-mods=//' | sed 's/,/ /g' `)
63 breaksw
64 case -disable:
65 case -disable=:
66 echo "To disable packages from compilation use -disable=pkg1,pkg2"
67 echo "with NO spaces eg. -disable=kpp,gmredi or -disable=all (to enable all packages)"
68 exit
69 breaksw
70 case -disable=*:
71 set DISABLE = ( $DISABLE `echo $arg | sed 's/-disable=//' | sed 's/,/ /g' `)
72 breaksw
73 case -enable:
74 case -enable=:
75 echo "To enable packages from compilation use -enable=pkg1,pkg2"
76 echo "with NO spaces eg. -enable=aim or -enable=all (to enable all packages)"
77 echo "-enable overrides -disable, ie. a package listed in both is enabled"
78 exit
79 breaksw
80 case -enable=*:
81 set ENABLE = ( $ENABLE `echo $arg | sed 's/-enable=//' | sed 's/,/ /g' `)
82 breaksw
83 case -mpi:
84 echo "Enabling MPI options"
85 set USEMPI
86 breaksw
87 case -jam:
88 set include_jam_libs
89 echo "Including paths to JAM libraries"
90 breaksw
91 case -help:
92 echo "usage: $0 [-help] [-makefile[=...]] [-platform=...] [-mpi] [-jam] [-disable=pkg1[,pkg2,...]] [-enable=pkg1[,pkg2,...]] [-mods=dir1[,dir2,...]] [-rootdir=dir]"
93 cat << EOF
94
95 $0 is used to generate the Makefile in the current directory.
96
97 Typical invocations are:
98 o from "bin": ../tools/genmake
99 o from "verification/expt/code": ../../../tools/genmake
100 o from "verification/expt/input": ../../../tools/genmake -mods=../code
101 o from a scratch directory: ~/mitgcm/tools/genmake -rootdir=~/mitgcm
102 or ~/mitgcm/tools/genmake -rootdir=~/mitgcm -mods=~/mymods
103
104 Packages (collected modules of code) can be disabled to avoid unnecessary
105 compilation of unused code. For instance if you know you will not
106 use GM/Redi, KPP and OBCS and they are appropriate turned-off in the
107 configuration:
108 .../tools/genmake -disable=gmredi,kpp,obcs
109
110 If you add some source files you can re-call the previous instance of
111 genmake with "make makefile".
112
113 genmake also reads the file .genmakerc which can be used to configure
114 options (primarily the command-line options above) for particular experiments.
115 EOF
116 exit
117 breaksw
118 default:
119 echo "Unknown command-line option: " $arg
120 echo $0 "-help to show usage"
121 exit
122 breaksw
123 endsw
124 shift allargs
125 end
126
127 # Default actions/options
128
129 # If platform wasn't specified then determine platform type of the host
130 if (! $?platform) then
131 set platform = (`uname`)
132 endif
133 # If name of makefile wasn't specified then use default "Makefile"
134 if (! $?mfile) set mfile = ( Makefile )
135
136 set mach = ( `uname -a` )
137 echo Operating system: $mach
138
139 # Directories for source, includes, binaries and executables
140 #
141 # If -rootdir wasn't specified then assume script is being run from bin
142 # but if it was supplied then we should place the executable in the build dir
143 if (! $?ROOTDIR) then
144 set pwd=`pwd`
145 if ($pwd:t == bin & -d ../model & -d ../eesupp & -d ../pkg) then
146 set ROOTDIR = ( .. )
147 endif
148 endif
149 # Scan for logical ROOTDIR
150 if (! $?ROOTDIR) then
151 foreach dr (. .. ../.. ../../.. ../../../.. ../../../../..)
152 if (-d $dr/model & -d $dr/eesupp & -d $dr/pkg) then
153 set ROOTDIR = $dr
154 echo ROOTDIR was not specified. Setting ROOTDIR = \"$ROOTDIR\"
155 break
156 endif
157 end
158 endif
159 if (! $?ROOTDIR) then
160 echo Root directory was not specified and could not be determined.
161 echo Specify the root location of the model source with -rootdir=dir
162 exit 1
163 endif
164 if (! -d $ROOTDIR) then
165 echo Root directory $ROOTDIR not found.;exit 1
166 endif
167 # If -mods wasn't specified then we will assume that we can find all the
168 # source code in the standard directories
169 if (! $?MODS) then
170 set SOURCEDIRS = ( )
171 set INCLUDEDIRS = ( . )
172 else
173 set SOURCEDIRS = ( $MODS )
174 set INCLUDEDIRS = ( . $MODS )
175 endif
176 if (! $?BUILDDIR) set BUILDDIR = ( . )
177 if (! -d $BUILDDIR) then
178 echo Build directory $BUILDDIR not found.;exit 1
179 endif
180 if (! $?EXEDIR) then
181 set pwd=`pwd`
182 if ($pwd:t == bin & -d ../exe & $ROOTDIR == ..) then
183 set EXEDIR = ( ../exe )
184 else
185 set EXEDIR = ( . )
186 endif
187 endif
188 if (! -d $EXEDIR) then
189 echo Executable directory $EXEDIR not found.;exit 1
190 endif
191 if (! $?TOOLSDIR) set TOOLSDIR = ( $ROOTDIR/tools )
192 if (! -d $TOOLSDIR) then
193 echo Tools directory $TOOLSDIR not found.;exit 1
194 endif
195 if (! $?EXECUTABLE) set EXECUTABLE = ( mitgcmuv )
196
197 # We have a special set of source files in eesupp/src which
198 # are generated from some template source files. We'll make them
199 # first so the appear as regular source code
200 if (-r $ROOTDIR/eesupp/src/Makefile) then
201 echo Making source files in eesupp from templates...
202 (cd $ROOTDIR/eesupp/src/; make) >& make_eesupp.errs
203 if ($status == 0) then
204 rm -f make_eesupp.errs
205 else
206 cat make_eesupp.errs
207 exit 2
208 endif
209 endif
210
211 # Now scan the standard source code tree
212 foreach dr ($SOURCEDIRS)
213 set adr=$dr
214 if (! -d $adr) then
215 echo mods directory $adr not found.; exit 1
216 endif
217 echo Adding mods dir: $adr
218 end
219 if (! $?PACKAGES) then
220 set PACKAGES=()
221 foreach pkg (`cd $ROOTDIR/pkg; find . -type d | grep -v CVS | sed 's:\./::' | grep -v "\." | sort`)
222 if (-d $ROOTDIR/pkg/$pkg) set PACKAGES=($PACKAGES $pkg)
223 end
224 endif
225 foreach dr ($PACKAGES)
226 set enable
227 foreach p ($DISABLE)
228 if ($p != 'all' & ! -d $ROOTDIR/pkg/$p) then
229 echo Specified package \"$p\" does not exist.
230 exit 1
231 endif
232 if ($dr == $p) unset enable
233 if ($p == 'all') unset enable
234 # The following allows entire trees to be disabled
235 if ($dr:h == $p) unset enable
236 if ($dr:h:h == $p) unset enable
237 if ($dr:h:h:h == $p) unset enable
238 if ($dr:h:h:h:h == $p) unset enable
239 end
240 foreach p ($ENABLE)
241 if ($dr == $p) set enable
242 end
243 if ($?enable) then
244 set adr=$ROOTDIR/pkg/$dr
245 if (! -d $adr) then
246 echo Source directory $adr not found.; exit 1
247 endif
248 echo Adding pkg dir: $adr
249 set SOURCEDIRS = ($SOURCEDIRS $adr)
250 set INCLUDEDIRS = ($INCLUDEDIRS $adr)
251 else
252 echo " *" Package \"$dr\" NOT enabled.
253 endif
254 end
255 if (! $?STANDARDDIRS) set STANDARDDIRS=(eesupp model)
256 foreach dr ($STANDARDDIRS)
257 set adr=$ROOTDIR/$dr/src
258 if (! -d $adr) then
259 echo Source directory $adr not found.; exit 1
260 endif
261 echo Adding src dir: $adr
262 set SOURCEDIRS = ($SOURCEDIRS $adr)
263 set idr = `echo $adr | sed 's/src/inc/'`
264 set INCLUDEDIRS = ($INCLUDEDIRS $idr)
265 end
266
267 # This is the generic configuration.
268 # Platform specific options are chosen below
269 set LN = ( 'ln -s' )
270 set CPP = ( '/lib/cpp -P' )
271 set KPP = ( )
272 set FC = ( 'f77' )
273 set LINK = ( 'f77' )
274 set DEFINES = ( )
275 set INCLUDES = ( )
276 set FFLAGS = ( )
277 set FOPTIM = ( )
278 set KFLAGS1 = ( )
279 set KFLAGS2 = ( )
280 set LIBS = ( )
281 set KPPFILES = ( )
282 set NOOPTFILES = ( )
283 set NOOPTFLAGS = ( )
284 set RMFILES = ( )
285
286 # We often want to use different compile/link options is using MPI
287 if ($?USEMPI) then
288 set USEMPI = ( '+mpi' )
289 set DEFINES = ( ${DEFINES} '-DALLOW_USE_MPI -DALWAYS_USE_MPI' )
290 else
291 set USEMPI
292 # set DEFINES = ( ${DEFINES} '-UALLOW_USE_MPI -UALWAYS_USE_MPI' )
293 endif
294
295 # Platform specific options
296 switch ($platform$USEMPI)
297 case OSF1:
298 case OSF1+mpi:
299 echo "Configuring for DEC Alpha"
300 set CPP = ( '/usr/bin/cpp -P' )
301 set DEFINES = ( ${DEFINES} '-DTARGET_DEC -DWORDLENGTH=1' )
302 set KPP = ( 'kapf' )
303 set KPPFILES = ( 'main.F' )
304 set KFLAGS1 = ( '-scan=132 -noconc -cmp=' )
305 set FC = ( 'f77' )
306 set FFLAGS = ( '-convert big_endian -r8 -extend_source -automatic -call_shared -notransform_loops -align dcommons' )
307 set FOPTIM = ( '-O5 -fast -tune host -inline all' )
308 set NOOPTFLAGS = ( '-O0' )
309 set LIBS = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' )
310 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F')
311 set RMFILES = ( '*.p.out' )
312 breaksw
313 case IRIX64+mpi:
314 echo "Configuring for SGI Mips with MPI"
315 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
316 set INCLUDES = ( '-I/usr/local/mpi/include' )
317 set FC = ( 'mpif77' )
318 set LINK = ( 'mpif77' )
319 set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' )
320 set FOPTIM = ( '-O3' )
321 set RMFILES = ( 'rii_files' )
322 breaksw
323 case IRIX64:
324 echo "Configuring for SGI Mips"
325 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
326 set INCLUDES = ( '-I/usr/local/mpi/include' )
327 set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4 -r8 -static' )
328 set FOPTIM = ( '-O3' )
329 # set NOOPTFLAGS = ( '-O0' )
330 # set NOOPTFILES = ( 'barrier.F different_multiple.F ' \
331 # 'external_fields_load.F' )
332 set RMFILES = ( 'rii_files' )
333 breaksw
334 case o2:
335 case IRIX:
336 echo "Configuring for SGI O2 running IRIX 6.5"
337 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
338 set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' )
339 set FOPTIM = ( '-O2' )
340 set NOOPTFLAGS = ( '-O0' )
341 breaksw
342 case o2+mpi:
343 case IRIX+mpi:
344 echo "Configuring for SGI O2 running IRIX 6.5 with MPI"
345 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
346 set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' )
347 set FOPTIM = ( '-O2' )
348 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F' )
349 set NOOPTFLAGS = ( '-O0' )
350 set LIBS = ( '-lmpi' )
351 breaksw
352 case o2k+mpi:
353 echo "Configuring for SGI Origin2000 running IRIX 6.5"
354 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
355 set INCLUDES = ( '-I/usr/include' )
356 set FFLAGS = ( '-n32 -extend_source -bytereclen' )
357 set FOPTIM = ( '-O2' )
358 set NOOPTFILES = ( 'calc_mom_rhs.F' )
359 set NOOPTFLAGS = ( '-O1' )
360 set LIBS = ( '-lmpi -lscs' )
361 breaksw
362 case onyx:
363 case onyx+mpi:
364 echo "Configuring for SGI ONYX running IRIX64"
365 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
366 set FFLAGS = ( '-extend_source -bytereclen -r10000 -64' )
367 set FOPTIM = ( '-O2' )
368 set NOOPTFLAGS = ( '-O0' )
369 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F' )
370 set LIBS = ( '-lmpi' )
371 breaksw
372 case SunOS:
373 set LN = ( '/usr/bin/ln -s' )
374 set CPP = ( '/usr/ccs/lib/cpp -P' )
375 set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4' )
376 set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar')
377 set FOPTIM = ( '-fast -O3' )
378 set NOOPTFLAGS = ( '-O0' )
379 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F ini_vertical_grid.F')
380 breaksw
381 case SunOS+mpi:
382 set LN = ( '/usr/bin/ln -s' )
383 set CPP = ( '/usr/ccs/lib/cpp -P' )
384 set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4' )
385 set INCLUDES = ( '-I/usr/local/mpi/include' )
386 set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar')
387 set FOPTIM = ( '-fast -O3' )
388 set NOOPTFLAGS = ( '-O0' )
389 set LIBS = ( '-L/usr/local/mpi/lib/solaris/ch_shmem -lmpi -lthread' \
390 '-lsocket -lnsl' )
391 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F ini_vertical_grid.F')
392 breaksw
393 case IRIX32:
394 echo "Configuring for SGI ONYX running IRIX64"
395 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
396 set INCLUDES = ( '-I/usr/include' )
397 set FFLAGS = ( '-extend_source -bytereclen -r10000 -64' )
398 set FOPTIM = ( '-O2' )
399 set NOOPTFLAGS = ( '-O0' )
400 set NOOPTFILES = ( 'barrier.F different_multiple.F ' \
401 'external_fields_load.F' )
402 set LIBS = ( '-lmpi' )
403 breaksw
404 case HP-UX+mpi:
405 set FC = ( 'mpif77' )
406 set LINK = ( 'mpif77' )
407 set INCLUDES = ( '-I/opt/mpi/include' )
408 case HP-UX:
409 echo "Configuring for HP Exemplar"
410 set CPP = ( '/usr/ccs/lbin/cpp -P' )
411 set DEFINES = ( ${DEFINES} '-DTARGET_HP -DWORDLENGTH=4' )
412 set FFLAGS = ( '+es +U77 +Onoautopar +Oexemplar_model' \
413 '+Okernel_threads' )
414 set FOPTIM = ( '+O2' )
415 set NOOPTFLAGS = ( '+O0' )
416 set NOOPTFILES = ( 'barrier.F different_multiple.F' \
417 'external_fields_load.F' )
418 breaksw
419 case Linux+mpi:
420 set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' )
421 set INCLUDES = ( '-I/usr/local/include' )
422 case Linux:
423 set LN = ( '/bin/ln -s' )
424 set CPP = ( '/lib/cpp -traditional -P' )
425 set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' )
426 set FC = ( 'g77' )
427 set FFLAGS = ( '-Wimplicit -Wunused -Wuninitialized' )
428 set FOPTIM = ( '-O3 -malign-double -funroll-loops ' )
429 set LINK = ( 'g77' )
430 breaksw
431 case Linux+pgi+mpi:
432 if ($?include_jam_libs) then
433 set INCLUDES = ( '-I/usr/local/mpich-1.2.1/pgi_fortran_binding/include' )
434 set LIBS = ( '-L/usr/local/mpich-1.2.1/pgi_fortran_binding/lib/ -lfmpich -lmpich' )
435 else
436 set INCLUDES = ( '-I/usr/local/include' )
437 set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' )
438 endif
439 case Linux+pgi:
440 set LN = ( '/bin/ln -s' )
441 set CPP = ( '/lib/cpp -traditional -P' )
442 set DEFINES = ( ${DEFINES} '-DWORDLENGTH=4' )
443 set FC = ( 'pgf77' )
444 set FFLAGS = ( '-byteswapio -r8 -Mnodclchk -Mextend' )
445 set FOPTIM = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )
446 set LINK = ( 'pgf77' )
447 breaksw
448 case T3E:
449 case sn6312:
450 set CPP = ( '/opt/ctl/bin/cpp -P')
451 set DEFINES = ( ${DEFINES} '-DTARGET_T3E -DWORDLENGTH=4' )
452 set FC = ( 'f90' )
453 set LINK = ( 'f90' )
454 set FFLAGS = ( '-O 2,fusion' )
455 breaksw
456 case T90:
457 case sn7113:
458 set FC = ( 'f90' )
459 set LINK = ( 'f90' )
460 set LN = ( '/bin/ln -s' )
461 set CPP = ( '/opt/ctl/bin/cpp -N -P' )
462 set DEFINES = ( ${DEFINES} '-DTARGET_CRAY_VECTOR -DWORDLENGTH=4' )
463 set FFLAGS = ( '-m3 -Rabc -N 132')
464 set FOPTIM = ( '-O0' )
465 set NOOPTFLAGS = ( '-O0' )
466 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F')
467 breaksw
468 case SV1:
469 case sn3002:
470 set FC = ( 'f90' )
471 set LINK = ( 'f90' )
472 set LN = ( '/bin/ln -s' )
473 set CPP = ( '/opt/ctl/bin/cpp -N -P' )
474 set DEFINES = ( ${DEFINES} '-DTARGET_CRAY_VECTOR -DWORDLENGTH=4' )
475 set FFLAGS = ( '-m3 -Rabc -ei -eI -s cf77types -N 132')
476 set FOPTIM = ( '-O0' )
477 set NOOPTFLAGS = ( '-O0' )
478 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F')
479 breaksw
480 default:
481 echo "Error: platform not recognized: uname -p = " $platform$USEMPI
482 exit
483 breaksw
484 endsw
485
486 ###############################################################################
487 ## ##
488 ## Everything below here should not need to be changed. Platform specific ##
489 ## changes and code specific changes should be configured above this line. ##
490 ## ##
491 ###############################################################################
492
493 # Convert lists of directories into command-line options
494 foreach inc ($INCLUDEDIRS)
495 set INCLUDES = ($INCLUDES -I$inc)
496 end
497
498 # Search for source code
499 rm -rf .links.tmp;mkdir .links.tmp
500 echo "# This section creates symbolic links" > srclinks.tmp
501 echo "" >> srclinks.tmp
502 echo -n 'SRCFILES = ' > srclist.inc
503 echo -n 'CSRCFILES = ' > csrclist.inc
504 #echo -n 'HEADERFILES = ' > hlist.inc
505 foreach dr ($SOURCEDIRS)
506 set deplist=( )
507 foreach srcfile (`cd $dr; ls *.[hcF]`)
508 if (! -r .links.tmp/$srcfile) then
509 if (-f $dr/$srcfile) then
510 switch ($srcfile:e)
511 case F:
512 touch .links.tmp/$srcfile
513 set deplist=($deplist $srcfile)
514 echo ' \' >> srclist.inc
515 echo -n " " $srcfile >> srclist.inc
516 breaksw
517 case c:
518 touch .links.tmp/$srcfile
519 set deplist=($deplist $srcfile)
520 echo ' \' >> csrclist.inc
521 echo -n " " $srcfile >> csrclist.inc
522 breaksw
523 case h:
524 # touch .links.tmp/$srcfile
525 # set deplist=($deplist $srcfile)
526 # echo ' \' >> hlist.inc
527 # echo -n " " $srcfile >> hlist.inc
528 breaksw
529 endsw
530 endif
531 endif
532 end
533 if ($#deplist != 0) then
534 echo "# These files are linked from $dr" >> srclinks.tmp
535 echo $deplist':' >> srclinks.tmp
536 echo ' $(LN) '$dr'/$@ $@' >> srclinks.tmp
537 endif
538 end
539 rm -rf .links.tmp
540 echo "" >> srclist.inc
541 echo "" >> csrclist.inc
542 #echo "" >> hlist.inc
543
544 set THISHOSTNAME = ( `hostname` )
545 set THISCWD = ( `pwd` )
546 set THISDATE = ( `date` )
547
548 if (-r $mfile) mv -f $mfile $mfile.bak
549 ###########################################
550 ## This is the template for the makefile ##
551 ###########################################
552 echo Creating makefile: $mfile
553 echo "# Multithreaded + multi-processing makefile for $mach" > ${mfile}
554 echo "# This makefile was generated automatically on" >> ${mfile}
555 echo "# $THISDATE" >> ${mfile}
556 echo "# by the command:" >> ${mfile}
557 echo "# ${0} $argv" >> ${mfile}
558 echo "# executed by:" >> ${mfile}
559 echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> ${mfile}
560 cat >> ${mfile} <<EOF
561 #
562 # BUILDDIR : Directory where object files are written
563 # SOURCEDIRS : Directories containing the source (.F) files
564 # INCLUDEDIRS : Directories containing the header-source (.h) files
565 # EXEDIR : Directory where executable that is generated is written
566 # EXECUTABLE : Full path of executable binary
567 #
568 # CPP : C-preprocessor command
569 # INCLUDES : Directories searched for header files
570 # DEFINES : Macro definitions for CPP
571 # KPP : Special preprocessor command (specific to platform)
572 # KFLAGS : Flags for KPP
573 # FC : Fortran compiler command
574 # FFLAGS : Configuration/debugging options for FC
575 # FOPTIM : Optimization options for FC
576 # LINK : Command for link editor program
577 # LIBS : Library flags /or/ additional optimization/debugging flags
578
579 ROOTDIR = ${ROOTDIR}
580 BUILDDIR = ${BUILDDIR}
581 SOURCEDIRS = ${SOURCEDIRS}
582 INCLUDEDIRS = ${INCLUDEDIRS}
583 EXEDIR = ${EXEDIR}
584 EXECUTABLE = \$(EXEDIR)/${EXECUTABLE}
585 TOOLSDIR = ${TOOLSDIR}
586
587 EOF
588
589
590 # JAM libraries on Hyades
591 if ($?include_jam_libs) then
592 cat >> ${mfile} <<EOF
593 # extra stuff for Hyades ............................................
594 HYADES_DIR = /u/u0/cnh/jam-lib/software
595 HYADES_DIR = /u/u0/cnh/jam-lib-twoproc
596 HYADES_DIR = /usr/local/jamlib/current/dual_proc
597 WORK_DIR = \$(HYADES_DIR)
598 DEPOSIT_DIR = linux_bin
599
600 STARTXOBJDIR = startx_util/\$(DEPOSIT_DIR)
601 STARTXOBJ = \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/startx_timer.o \
602 \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/startx_util.o \
603 \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/client.o \
604 \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/csutil.o
605
606 JAMOBJDIR = jam/\$(DEPOSIT_DIR)
607 JAMOBJ = \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_init.o \
608 \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_kernel.o \
609 \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_malloc.o \
610 \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_vmalloc.o \
611 \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_mutex.o
612
613 JAMCOBJDIR = jam_collective/\$(DEPOSIT_DIR)
614 JAMCOBJ = \$(WORK_DIR)/jam_collective/\$(DEPOSIT_DIR)/jam_collective.o
615
616 XLIBS = \$(STARTXOBJ) \$(JAMOBJ) \$(JAMCOBJ)
617
618 # ..................................................................
619
620 EOF
621 endif
622
623
624 cat >> ${mfile} <<EOF
625 # Unix ln (link)
626 LN = ${LN}
627 # C preprocessor
628 CPP = cat \$< | \$(TOOLSDIR)/set64bitConst.sh | ${CPP}
629 # Special preprocessor (KAP on DECs, FPP on Crays)
630 KPP = ${KPP}
631 # Fortran compiler
632 FC = ${FC}
633 # Link editor
634 LINK = ${LINK}
635
636 # Defines for CPP
637 DEFINES = ${DEFINES}
638 # Includes for CPP
639 INCLUDES = ${INCLUDES}
640 # Flags for KPP
641 KFLAGS1 = ${KFLAGS1}
642 KFLAGS2 = ${KFLAGS2}
643 # Optim./debug for FC
644 FFLAGS = ${FFLAGS}
645 FOPTIM = ${FOPTIM}
646 # Files that should not be optimized
647 NOOPTFILES = ${NOOPTFILES}
648 NOOPTFLAGS = ${NOOPTFLAGS}
649 # Flags and libraries needed for linking
650 LIBS = ${LIBS} \$(XLIBS)
651
652 EOF
653
654 cat srclist.inc >> ${mfile}
655 cat csrclist.inc >> ${mfile}
656 echo 'F77FILES = $(SRCFILES:.F=.f)' >> ${mfile}
657 echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o)' >> ${mfile}
658
659 rm -f srclist.inc csrclist.inc flist.tmp clist.tmp
660
661 cat >> ${mfile} <<EOF
662
663 .SUFFIXES:
664 .SUFFIXES: .o .f .p .F .c
665
666 all: \$(EXECUTABLE)
667 \$(EXECUTABLE): \$(OBJFILES)
668 \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
669 depend:
670 @make links
671 makedepend -o .f \$(INCLUDES) \$(SRCFILES)
672
673 links: \$(SRCFILES)
674
675 small_f: \$(F77FILES)
676
677 clean:
678 -rm -rf *.o *.f *.p ${RMFILES}
679 Clean:
680 @make clean
681 @make cleanlinks
682 -rm -f Makefile.bak
683 CLEAN:
684 @make Clean
685 -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
686 -find \$(EXEDIR) -name "*.data" -exec rm {} \;
687 -rm -f \$(EXECUTABLE)
688
689 makefile:
690 ${0} $argv
691 cleanlinks:
692 -find . -type l -exec rm {} \;
693
694 # The normal chain of rules is ( .F - .f - .o )
695 .F.f:
696 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
697 .f.o:
698 \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
699
700 # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain
701 .F.p:
702 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
703 .p.f:
704 \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
705 EOF
706
707 # Make list of "exceptions" that need ".p" files
708 foreach sf ($KPPFILES)
709 set fname=( ${sf:t} )
710 echo "${fname:r}.f: ${fname:r}.p" >> ${mfile}
711 end
712 foreach sf ($NOOPTFILES)
713 set fname=( ${sf:t} )
714 echo "${fname:r}.o: ${fname:r}.f" >> ${mfile}
715 echo ' $(FC) $(FFLAGS) $(NOOPTFLAGS) -c $<' >> ${mfile}
716 end
717 echo "" >> ${mfile}
718
719 # Add rules for links
720 cat srclinks.tmp >> ${mfile}
721 rm -f srclinks.tmp
722
723 echo "" >> ${mfile}
724 echo "# DO NOT DELETE" >> ${mfile}
725
726 exit

  ViewVC Help
Powered by ViewVC 1.1.22