1 | #! /bin/ksh |
---|
2 | ################################################################################ |
---|
3 | # |
---|
4 | # File : ~/util/compile/frames/Create_COMP_libs.frm |
---|
5 | # |
---|
6 | # Script to generate the library compile script |
---|
7 | # |
---|
8 | # Stephanie Legutke, MPI-HH, M&D Dec 14, 2004 |
---|
9 | # |
---|
10 | # This script is used to generate a compile script for the PRISM libraries. |
---|
11 | # The script is specifically created for the target platform. |
---|
12 | # Depending on the node name it selects site and OS specifics. |
---|
13 | # The node name is either detected with `uname -n` or, if the script is not |
---|
14 | # created on the target machine, it must be specifieid by the user. |
---|
15 | # The generated compile script is moved to ~/src/mod/'model name' |
---|
16 | # after successful generation. |
---|
17 | # The script uses m4 for preprocessing. It has been tested with |
---|
18 | # GNU m4 version 1.4. Other, older or non-GNU versions of m4 may fail! |
---|
19 | # |
---|
20 | # This script is called interactively only. |
---|
21 | # |
---|
22 | # 5 positional parameters are possible: |
---|
23 | # |
---|
24 | # Usage : COMP_libs [- [- [node [MPI1]]]] |
---|
25 | # |
---|
26 | # $1=""/"-": directing std output to a file / the screen |
---|
27 | # $2=""/"-"/"+": directing err output to a file / the screen / stdout |
---|
28 | # $3=""/"'node'": node name for header files with OS/site specs |
---|
29 | # $4=""/"MPI1": message passing |
---|
30 | # |
---|
31 | # If not called with all parameters, the defaults are: |
---|
32 | # $1 the gmake of the generated script directs stdout to a file |
---|
33 | # $2 the gmake of the generated script directs errout to a file |
---|
34 | # $3 node name of the machine where this scripts is run; |
---|
35 | # (if it is not the node name appearing in the header file |
---|
36 | # names with the site/OS specifications, it must be given) |
---|
37 | # $4 MPI2 |
---|
38 | # |
---|
39 | ################################################################################ |
---|
40 | # |
---|
41 | echo |
---|
42 | echo '-----------------------------------------------------------------' |
---|
43 | echo ' ' |
---|
44 | echo ' This script may fail if you do not use the right version of m4!' |
---|
45 | if [ "$3" = "rhodes" ] ; then |
---|
46 | echo ' The version you use is :' `/usr/freeware/bin/m4 --version` |
---|
47 | elif [ "$3" = "zahir" ] ; then |
---|
48 | echo ' The version you use is :' `/usr/local/bin/m4 --version` |
---|
49 | elif [ "$3" = "vargas" ] ; then |
---|
50 | echo ' The version you use is :' `/usr/local/pub/M4/m4-1.4.11/bin/m4 --version` |
---|
51 | else |
---|
52 | echo ' The version you use is :' `m4 --version` |
---|
53 | fi |
---|
54 | echo ' Make sure this is GNU m4 younger than version 1.4!' |
---|
55 | echo ' ' |
---|
56 | echo '-----------------------------------------------------------------' |
---|
57 | |
---|
58 | set +x |
---|
59 | |
---|
60 | if [ "$1" = "--" ] || [ "$1" = "help" ] || [ "$1" = "--help" ] ; then |
---|
61 | echo |
---|
62 | echo '----------- Usage --------------------------------------------------------' |
---|
63 | echo ' $1=""/"-": directing std output to a file / the screen' |
---|
64 | echo ' $2=""/"-"/"+": directing err output to a file / the screen / stdout' |
---|
65 | echo ' $3=""/"node": node name for header files with OS/site specs' |
---|
66 | echo ' $4=""/"MPI1": message passing' |
---|
67 | echo '--------------------------------------------------------------------------' |
---|
68 | echo ' ' |
---|
69 | exit |
---|
70 | fi |
---|
71 | echo |
---|
72 | |
---|
73 | # |
---|
74 | # Redirecting standard output and error output |
---|
75 | # |
---|
76 | |
---|
77 | outout='stdout=$SCRIPTDIR/COMP_libs.log' |
---|
78 | if [ "$1" != "" ]; then |
---|
79 | if [ "$1" = "-" ]; then |
---|
80 | outout='stdout=`tty`' |
---|
81 | echo '* (g)make standard output will directed to screen.' |
---|
82 | else |
---|
83 | echo 'This values is not allowed for parameter 1 (std out)' |
---|
84 | exit |
---|
85 | fi |
---|
86 | else |
---|
87 | echo '* (g)make standard output will be directed to a file.' |
---|
88 | fi |
---|
89 | |
---|
90 | errout='stderr=$SCRIPTDIR/COMP_libs.err' |
---|
91 | if [ "$2" != "" ]; then |
---|
92 | if [ "$2" = "-" ]; then |
---|
93 | echo '* (g)make standard error will directed to screen.' |
---|
94 | errout='stderr=`tty`' |
---|
95 | elif [ "$2" = "+" ]; then |
---|
96 | echo '* (g)make standard error will directed to stdout.' |
---|
97 | errout='stderr="$stdout"' |
---|
98 | else |
---|
99 | echo 'This values is not allowed for parameter 2 (std err)' |
---|
100 | exit |
---|
101 | fi |
---|
102 | else |
---|
103 | echo '* (g)make standard error will be directed to a file.' |
---|
104 | fi |
---|
105 | |
---|
106 | # |
---|
107 | # HOST, OS, node name for header file directory selection |
---|
108 | # |
---|
109 | |
---|
110 | node=`uname -n` |
---|
111 | node1_7=`echo ${node} | cut -c1-7` |
---|
112 | if [ ${node1_7} = platine ]; then node=${node1_7}; fi |
---|
113 | if [ ${node1_7} = mercure ]; then node=${node1_7}; fi |
---|
114 | node1_5=`echo ${node} | cut -c1-5` |
---|
115 | if [ ${node1_5} = zahir ]; then node=${node1_5}; fi |
---|
116 | if [ ${node1_5} = curie ]; then node=${node1_5}; fi |
---|
117 | node1_6=`echo ${node} | cut -c1-6` |
---|
118 | if [ ${node1_6} = vargas ] || [ ${node1_6} = titane ]; then node=${node1_6}; fi |
---|
119 | node1_3=`echo ${node} | cut -c1-3` |
---|
120 | if [ ${node1_3} = ada ]; then node=${node1_3}; fi |
---|
121 | build=`uname -s` |
---|
122 | if [ "$3" != "" ]; then |
---|
123 | if [ "$3" != $node ]; then |
---|
124 | echo ' ' |
---|
125 | echo 'Warning: the node name specified is not the node name of this machine' |
---|
126 | echo 'Ensure that the site/OS specific header files exist.' |
---|
127 | node=$3 |
---|
128 | fi |
---|
129 | fi |
---|
130 | |
---|
131 | echo ' ' |
---|
132 | echo '* Creating library compile script' |
---|
133 | echo ' on/for a '$build ' platform with node name ' $node'.' |
---|
134 | echo ' ' |
---|
135 | |
---|
136 | node1_4=`echo ${node} | cut -c1-4` |
---|
137 | if [ ${node1_4} = xbar ]; then node=${node1_4}; fi |
---|
138 | if [ ${node1_4} = hpca ]; then node=${node1_4}; fi |
---|
139 | |
---|
140 | node1_2=`echo ${node} | cut -c1-2` |
---|
141 | if [ ${node1_2} = ds ]; then node=${node1_2}; fi |
---|
142 | |
---|
143 | node1_6=`echo ${node} | cut -c1-6` |
---|
144 | if [ ${node1_6} = total1 ]; then node=${node1_6}; fi |
---|
145 | |
---|
146 | echo ' ' |
---|
147 | echo '* Abbreviated node name is ' $node'.' |
---|
148 | echo ' ' |
---|
149 | |
---|
150 | mespas=irgendwas |
---|
151 | messpass=MPI2 |
---|
152 | if [ "$4" != "" ]; then |
---|
153 | if [ "$4" = MPI1 ] || [ "$4" = NONE ] ; then |
---|
154 | messpass=$4 |
---|
155 | mespas=MPI2 |
---|
156 | else |
---|
157 | echo 'This may not be specified:'$4 |
---|
158 | exit 1 |
---|
159 | fi |
---|
160 | echo '* The message passing will be '$4'.' |
---|
161 | else |
---|
162 | echo '* The message passing will be MPI2.' |
---|
163 | fi |
---|
164 | |
---|
165 | # |
---|
166 | # Change to directory of script |
---|
167 | # |
---|
168 | |
---|
169 | scriptdir=`dirname $0` |
---|
170 | cd $scriptdir |
---|
171 | |
---|
172 | # /u/fj/mfuj/mfuj004/bin/m4" ; xbar |
---|
173 | |
---|
174 | cat > infile.m4 <<EOF |
---|
175 | #! /bin/ksh |
---|
176 | changequote([{,}])dnl |
---|
177 | changecom |
---|
178 | dnl |
---|
179 | dnl Embedding as batch (not needed on all nodes) |
---|
180 | dnl |
---|
181 | define(comp_Model,comp_libs)dnl |
---|
182 | sinclude(include/Qsub_start_${node}.h)dnl |
---|
183 | undefine([{comp_Model}])dnl |
---|
184 | |
---|
185 | dnl |
---|
186 | dnl Comments, usage, history |
---|
187 | dnl |
---|
188 | include(include/Comments_libs.h)dnl |
---|
189 | include(include/Comments_libs_frm.h)dnl |
---|
190 | |
---|
191 | dnl |
---|
192 | dnl GUI input for all compile scripts |
---|
193 | dnl |
---|
194 | define(${mespas},${messpass})dnl |
---|
195 | include(include/Guispecif_all.h)dnl |
---|
196 | undefine([{${mespas}}])dnl |
---|
197 | |
---|
198 | dnl |
---|
199 | dnl GUI input depending on model |
---|
200 | dnl |
---|
201 | include(include/Guispecif_libs.h)dnl |
---|
202 | |
---|
203 | dnl |
---|
204 | dnl Command parameter input (scripting only) |
---|
205 | dnl |
---|
206 | include(include/Command_par_libs_frm.h)dnl |
---|
207 | include(include/Input_check_all_frm.h)dnl |
---|
208 | include(include/Input_check_libs_frm.h)dnl |
---|
209 | |
---|
210 | dnl |
---|
211 | dnl Parameter renaming and printing |
---|
212 | dnl |
---|
213 | include(include/Print_par_all.h)dnl |
---|
214 | include(include/Print_par_libs.h)dnl |
---|
215 | |
---|
216 | scriptdir=\`dirname \$0\` |
---|
217 | cd \$scriptdir |
---|
218 | export SCRIPTDIR=\`pwd\` |
---|
219 | node=\`uname -n\` |
---|
220 | node1_7=\`echo \${node} | cut -c1-7\` |
---|
221 | if [ \${node1_7} = platine ]; then node=\${node1_7}; fi |
---|
222 | if [ \${node1_7} = mercure ]; then node=\${node1_7}; fi |
---|
223 | node1_5=\`echo \${node} | cut -c1-5\` |
---|
224 | if [ \${node1_5} = zahir ]; then node=\${node1_5}; fi |
---|
225 | if [ \${node1_5} = curie ]; then node=\${node1_5}; fi |
---|
226 | node1_6=\`echo \${node} | cut -c1-6\` |
---|
227 | if [ \${node1_6} = vargas ] || [ \${node1_6} = titane ]; then node=\${node1_6}; fi |
---|
228 | node1_3=\`echo \${node} | cut -c1-3\` |
---|
229 | if [ \${node1_3} = ada ]; then node=\${node1_3}; fi |
---|
230 | |
---|
231 | dnl |
---|
232 | dnl HOST, OS, node name |
---|
233 | dnl |
---|
234 | include(include/Prolog_all.h)dnl |
---|
235 | include(include/Prolog_libs.h)dnl |
---|
236 | export TARFILE=libs_\`date +%y%m%d\`.tar |
---|
237 | |
---|
238 | dnl |
---|
239 | dnl Site and OS specifics |
---|
240 | dnl |
---|
241 | include(include_${node}/Sitespecific_${node}.h)dnl |
---|
242 | include(include_${node}/Compile_mode_libs_${node}.h)dnl |
---|
243 | include(include_${node}/OSspecific_${node}.h)dnl |
---|
244 | |
---|
245 | dnl |
---|
246 | dnl Non Site and OS dependent cpp flags |
---|
247 | dnl |
---|
248 | include(include/Cppflags_libs.h)dnl |
---|
249 | include(include/Cppflags_edit.h)dnl |
---|
250 | |
---|
251 | dnl |
---|
252 | dnl Build the build |
---|
253 | dnl |
---|
254 | include(include/Build_dirs_libs.h)dnl |
---|
255 | |
---|
256 | dnl |
---|
257 | dnl Create top level Makefile |
---|
258 | dnl |
---|
259 | include(include/Top_makefile_all.h)dnl |
---|
260 | define(NodeName,$node)dnl |
---|
261 | include(include/Top_makefile_libs.h)dnl |
---|
262 | undefine(NodeName)dnl |
---|
263 | |
---|
264 | define(outdev,${outout})dnl |
---|
265 | outdev |
---|
266 | undefine([{outdev}])dnl |
---|
267 | define(errdev,${errout})dnl |
---|
268 | errdev |
---|
269 | undefine([{errdev}])dnl |
---|
270 | |
---|
271 | if [ -f \$BLDROOT/lib.status ]; then rm \$BLDROOT/lib.status; fi |
---|
272 | |
---|
273 | dnl |
---|
274 | dnl Make libaries |
---|
275 | dnl |
---|
276 | include(include/Make_libs.h)dnl |
---|
277 | |
---|
278 | dnl |
---|
279 | dnl Print update status : scripting only |
---|
280 | dnl |
---|
281 | include(include/Status_libs_frm.h)dnl |
---|
282 | |
---|
283 | dnl |
---|
284 | dnl Embedding as batch (not needed on all nodes) |
---|
285 | dnl |
---|
286 | sinclude(include/Qsub_end_${node}.h)dnl |
---|
287 | |
---|
288 | exit |
---|
289 | |
---|
290 | m4exit |
---|
291 | |
---|
292 | EOF |
---|
293 | # |
---|
294 | # Run preprocessor: note the blank behind -D / -U |
---|
295 | # |
---|
296 | if [ "$3" = "rhodes" ] ; then |
---|
297 | /usr/freeware/bin/m4 infile.m4 > COMP_libs |
---|
298 | elif [ "$3" = "zahir" ] ; then |
---|
299 | /usr/local/bin/m4 infile.m4 > COMP_libs |
---|
300 | elif [ "$3" = "vargas" ] ; then |
---|
301 | /usr/local/pub/M4/m4-1.4.11/bin/m4 infile.m4 > COMP_libs |
---|
302 | else |
---|
303 | m4 infile.m4 > COMP_libs |
---|
304 | fi |
---|
305 | |
---|
306 | status=$? |
---|
307 | if [ $status -eq 0 ]; then |
---|
308 | mv COMP_libs ../../COMP_libs.${node} |
---|
309 | chmod 755 ../../COMP_libs.${node} |
---|
310 | olddir=`pwd` |
---|
311 | cd ../.. |
---|
312 | moddir=`pwd` |
---|
313 | echo "* The compile script name is "$moddir/COMP_libs.${node} |
---|
314 | echo ' ' |
---|
315 | else |
---|
316 | echo "An error occurred! Status="$status |
---|
317 | echo ' ' |
---|
318 | fi |
---|
319 | |
---|
320 | cd $olddir |
---|
321 | rm infile.m4 |
---|
322 | exit |
---|