/[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.42 - (show annotations) (download)
Tue Aug 14 14:27:10 2001 UTC (22 years, 7 months ago) by adcroft
Branch: MAIN
Changes since 1.41: +5 -5 lines
Fixed problem which infinite links; header files ended up linked to
themselves because the ./ directory was the first in the INCLUDEDIRS
list. Now INCLUDES has -I. in it and ./ is at end of search path.

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

  ViewVC Help
Powered by ViewVC 1.1.22