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