/[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.53 - (show annotations) (download)
Mon Sep 10 20:54:01 2001 UTC (22 years, 6 months ago) by cnh
Branch: MAIN
CVS Tags: checkpoint40pre9
Changes since 1.52: +2 -2 lines
Fix script to be compatible with tcsh on Digital UNIX

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

  ViewVC Help
Powered by ViewVC 1.1.22