/[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.33.2.4 - (show annotations) (download)
Thu Mar 22 16:05:52 2001 UTC (23 years, 1 month ago) by adcroft
Branch: pre38
Changes since 1.33.2.3: +25 -2 lines
Brought -help up to date.

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

  ViewVC Help
Powered by ViewVC 1.1.22