1 |
#!/bin/csh -f |
2 |
# |
3 |
# $Header: /u/gcmpack/models/MITgcmUV/tools/genmake.sgi,v 1.3 1998/04/24 19:32:20 adcroft Exp $ |
4 |
# |
5 |
# Makefile generator for MITgcm UV codes |
6 |
# |
7 |
|
8 |
# Generate make files for SGI IRIX system |
9 |
set mfile = ( Makefile.sgi ) |
10 |
set mach = ( 'SGI IRIX/mips4' ) |
11 |
|
12 |
# Directories for source, includes, binaries and executables |
13 |
# Note |
14 |
# o If you prefer/need everything under a single directory |
15 |
# copy everything in ../psupp/src, ../model/src, |
16 |
# ../psupp/inc and ../model/inc into a directory and then |
17 |
# edit the paths below to read |
18 |
# set PSUPP_SDIR = ( ) |
19 |
# set MODEL_SDIR = ( ) |
20 |
# set PSUPP_IDIR = ( ) |
21 |
# set MODEL_IDIR = ( ) |
22 |
# set TDIR = ( ) |
23 |
# set BDIR = ( ) |
24 |
# set EDIR = ( ) |
25 |
set PSUPP_SDIR = ( ../eesupp/src/ ) |
26 |
set MODEL_SDIR = ( ../model/src/ ) |
27 |
set PSUPP_IDIR = ( ../eesupp/inc/ ) |
28 |
set MODEL_IDIR = ( ../model/inc/ ) |
29 |
set TDIR = ( ../tools/ ) |
30 |
set BDIR = ( ../bin/ ) |
31 |
set EDIR = ( ../exe/ ) |
32 |
set EXE = ( mitgcmuv ) |
33 |
|
34 |
set CPP = ( '/lib/cpp -P $(INCLUDES) -DUSE_IRIX' ) |
35 |
set FCOMP = ( 'f77 -extend_source -mp -mpio -bytereclen -O3 -r10000 -c' ) |
36 |
set LINK = ( 'f77 -mp -mpio -bytereclen -O3 -r10000 ' ) |
37 |
set INCLUDES = ( '-I. -I$(PSUPP_IDIR) -I$(MODEL_IDIR) ' \ |
38 |
'-I/usr/local/mpi/include' ) |
39 |
|
40 |
echo "Creating make file ${mfile} " |
41 |
echo "#" > ${mfile} |
42 |
echo "# Multithreaded + multi-processing makefile for $mach " >> ${mfile} |
43 |
echo "# This make file was generated automatically by the command" >> ${mfile} |
44 |
echo "# " \"${0}\" >> ${mfile} |
45 |
echo "# on `hostname`:`pwd` " >> ${mfile} |
46 |
echo "# " `date` >> ${mfile} |
47 |
echo "# by $user" >> ${mfile} |
48 |
echo "# " >> ${mfile} |
49 |
|
50 |
cat >> ${mfile} <<EOF |
51 |
|
52 |
# PSUPP_SDIR: Directory holding parallel support routines |
53 |
# MODEL_SDIR: Directory model code |
54 |
# PSUPP_IDIR: Directory holding parallel support header files |
55 |
# MODEL_IDIR: Directory model header files |
56 |
# TDIR : Directory where build tools are stored |
57 |
# BDIR : Directory where object files are written |
58 |
# EDIR : Directory where executable that is generated is written |
59 |
# INCLUDES : Directories searched for header files |
60 |
# CPP : C-preprocessor command |
61 |
# FCOMP : Fortran compiler command |
62 |
# LINK : Command for link editor program |
63 |
# Note |
64 |
# ==== |
65 |
# o PSUPP_SDIR ... EDIR can all be set to the current directory if |
66 |
# you want to organise things that way. Alternatively they can be |
67 |
# set to different directories so that code can be kept on a backed |
68 |
# up disk while object files and executables are created on scratch |
69 |
# disks. I prefer this latter setup! |
70 |
# o Under Solaris if the disk on which the compiler is generating |
71 |
# object files and executables is mounted via NFS rather than being |
72 |
# a local SCSI disk compilation times can increase by a factor of |
73 |
# ten! |
74 |
PSUPP_SDIR = ${PSUPP_SDIR} |
75 |
MODEL_SDIR = ${MODEL_SDIR} |
76 |
PSUPP_IDIR = ${PSUPP_IDIR} |
77 |
MODEL_IDIR = ${MODEL_IDIR} |
78 |
TDIR = ${TDIR} |
79 |
BDIR = ${BDIR} |
80 |
EDIR = ${EDIR} |
81 |
INCLUDES = ${INCLUDES} |
82 |
EXE = \$(EDIR)${EXE} |
83 |
EOF |
84 |
|
85 |
echo "# C preprocessor " >> ${mfile} |
86 |
echo 'CPP =' ${CPP} >> ${mfile} |
87 |
echo "# Fortran compiler " >> ${mfile} |
88 |
echo 'FCOMP = '${FCOMP} >> ${mfile} |
89 |
echo "# Link editor " >> ${mfile} |
90 |
echo 'LINK = '${LINK} >> ${mfile} |
91 |
echo " " >> ${mfile} |
92 |
|
93 |
|
94 |
set psupp_slist = ( ) |
95 |
set psupp_olist = ( ) |
96 |
if ( ${PSUPP_SDIR} != ${MODEL_SDIR} ) then |
97 |
set flist = `ls -1 ${PSUPP_SDIR} | grep '.*\.F'` |
98 |
if ( "${flist}" != "" ) then |
99 |
foreach f ( $flist ) |
100 |
set fname = ( ${f:t} ) |
101 |
set pf = ( ${fname:r}.f ) |
102 |
set of = ( ${fname:r}.o ) |
103 |
echo ${pf}: '$(PSUPP_SDIR)'${fname} >> ${mfile}.$$ |
104 |
echo ' @echo Preprocessing $(PSUPP_SDIR)'${fname} >> ${mfile}.$$ |
105 |
echo ' @ $(CPP) $(PSUPP_SDIR)'${fname}' > '$pf >> ${mfile}.$$ |
106 |
echo ${of}: ${pf} >> ${mfile}.$$ |
107 |
echo ' @echo Compiling '${pf} >> ${mfile}.$$ |
108 |
echo ' @ $(FCOMP) '$pf >> ${mfile}.$$ |
109 |
set psupp_slist = ( ${psupp_slist} ${f} ) |
110 |
set psupp_olist = ( ${psupp_olist} ${of} ) |
111 |
end |
112 |
endif |
113 |
endif |
114 |
|
115 |
set model_slist = ( ) |
116 |
set model_olist = ( ) |
117 |
set flist = `ls -1 ${MODEL_SDIR} | grep '.*\.F'` |
118 |
if ( "${flist}" != "" ) then |
119 |
foreach f ( ${flist} ) |
120 |
set fname = ( ${f:t} ) |
121 |
set pf = ( ${fname:r}.f ) |
122 |
set of = ( ${fname:r}.o ) |
123 |
echo ${pf}: '$(MODEL_SDIR)'${fname} >> ${mfile}.$$ |
124 |
echo ' @echo Preprocessing $(MODEL_SDIR)'${fname} >> ${mfile}.$$ |
125 |
echo ' @ $(CPP) $(MODEL_SDIR)'${fname}' > '$pf >> ${mfile}.$$ |
126 |
echo ${of}: ${pf} >> ${mfile}.$$ |
127 |
echo ' @echo Compiling '${pf} >> ${mfile}.$$ |
128 |
echo ' @ $(FCOMP) '$pf >> ${mfile}.$$ |
129 |
set model_slist = ( ${model_slist} ${f} ) |
130 |
set model_olist = ( ${model_olist} ${of} ) |
131 |
end |
132 |
endif |
133 |
|
134 |
echo " " >> ${mfile} |
135 |
echo "# =========== " >> ${mfile} |
136 |
echo "# File lists " >> ${mfile} |
137 |
echo "# =========== " >> ${mfile} |
138 |
if ( $#psupp_olist == 0 ) then |
139 |
echo 'psupp_objs = ' >> ${mfile} |
140 |
else if ( $#psupp_olist == 1 ) then |
141 |
echo 'psupp_objs = '${psupp_olist} >> ${mfile} |
142 |
else |
143 |
echo 'psupp_objs = '$psupp_olist[1] '\' >> ${mfile} |
144 |
set psupp_count = 2 |
145 |
while ( $psupp_count < $#psupp_olist ) |
146 |
echo ' '$psupp_olist[$psupp_count] '\' >> ${mfile} |
147 |
@ psupp_count = $psupp_count + 1 |
148 |
end |
149 |
echo ' '$psupp_olist[$#psupp_olist] >> ${mfile} |
150 |
endif |
151 |
echo " " >> ${mfile} |
152 |
if ( $#psupp_slist == 0 ) then |
153 |
echo 'psupp_srcs = ' >> ${mfile} |
154 |
else if ( $#psupp_slist == 1 ) then |
155 |
echo 'psupp_srcs = $(PSUPP_SDIR)'${psupp_slist} >> ${mfile} |
156 |
else |
157 |
echo 'psupp_srcs = $(PSUPP_SDIR)'$psupp_slist[1] '\' >> ${mfile} |
158 |
set psupp_count = 2 |
159 |
while ( $psupp_count < $#psupp_slist ) |
160 |
echo ' $(PSUPP_SDIR)'$psupp_slist[$psupp_count] '\' >> ${mfile} |
161 |
@ psupp_count = $psupp_count + 1 |
162 |
end |
163 |
echo ' $(PSUPP_SDIR)'$psupp_slist[$#psupp_slist] >> ${mfile} |
164 |
endif |
165 |
echo " " >> ${mfile} |
166 |
if ( $#model_olist == 0 ) then |
167 |
echo 'model_objs = ' >> ${mfile} |
168 |
else if ( $#model_olist == 1 ) then |
169 |
echo 'model_objs = '${model_olist} >> ${mfile} |
170 |
else |
171 |
echo 'model_objs = '$model_olist[1] '\' >> ${mfile} |
172 |
set model_count = 2 |
173 |
while ( $model_count < $#model_olist ) |
174 |
echo ' '$model_olist[$model_count] '\' >> ${mfile} |
175 |
@ model_count = $model_count + 1 |
176 |
end |
177 |
echo ' '$model_olist[$#model_olist] >> ${mfile} |
178 |
endif |
179 |
echo " " >> ${mfile} |
180 |
if ( $#model_slist == 0 ) then |
181 |
echo 'model_srcs = ' >> ${mfile} |
182 |
else if ( $#model_slist == 1 ) then |
183 |
echo 'model_srcs = $(MODEL_SDIR)'${model_slist} >> ${mfile} |
184 |
else |
185 |
echo 'model_srcs = $(MODEL_SDIR)'$model_slist[1] '\' >> ${mfile} |
186 |
set model_count = 2 |
187 |
while ( $model_count < $#model_slist ) |
188 |
echo ' $(MODEL_SDIR)'$model_slist[$model_count] '\' >> ${mfile} |
189 |
@ model_count = $model_count + 1 |
190 |
end |
191 |
echo ' $(MODEL_SDIR)'$model_slist[$#model_slist] >> ${mfile} |
192 |
endif |
193 |
echo " " >> ${mfile} |
194 |
echo 'objs = $(psupp_objs) $(model_objs)' >> ${mfile} |
195 |
echo 'srcs = $(psupp_srcs) $(model_srcs)' >> ${mfile} |
196 |
echo " " >> ${mfile} |
197 |
echo "# =========== " >> ${mfile} |
198 |
echo "# Begin rules " >> ${mfile} |
199 |
echo "# =========== " >> ${mfile} |
200 |
echo " " >> ${mfile} |
201 |
echo '$(EXE): $(objs) ' >> ${mfile} |
202 |
echo ' $(LINK) -o $(EXE) $(objs)' >> ${mfile} |
203 |
echo " " >> ${mfile} |
204 |
echo 'clean: ' >> ${mfile} |
205 |
echo ' rm *.o *.f ' >> ${mfile} |
206 |
echo " " >> ${mfile} |
207 |
echo 'depend: ' >> ${mfile} |
208 |
echo ' makedepend -f $(TDIR)'${mfile}' $(INCLUDES) $(srcs) ' >> ${mfile} |
209 |
echo " " >> ${mfile} |
210 |
cat ${mfile}.$$ >> ${mfile} |
211 |
\rm ${mfile}.$$ |
212 |
|
213 |
# $ Id: $ |