1 | #!/bin/sh |
---|
2 | # |
---|
3 | # $Header: /home/cvsroot/LMDZ4/create_make_gcm,v 1.8 2008-01-23 15:44:26 fairhead Exp $ |
---|
4 | # |
---|
5 | #set -xv |
---|
6 | machine=`hostname` |
---|
7 | os=`uname` |
---|
8 | gcm=`pwd` |
---|
9 | libf=$gcm/libf |
---|
10 | libo=$gcm/libo |
---|
11 | CRAY=0 |
---|
12 | if [ "$machine" = "atlas" -o "$machine" = "etoile" -o "$machine" = "axis" ] ; then |
---|
13 | CRAY=1 |
---|
14 | fi |
---|
15 | XNEC=0 |
---|
16 | if [ "$machine" = "rhodes" ] ; then |
---|
17 | XNEC=1 |
---|
18 | fi |
---|
19 | X6NEC=0 |
---|
20 | if [ "$machine" = "mercure" ] ; then |
---|
21 | X6NEC=1 |
---|
22 | fi |
---|
23 | X8BRODIE=0 |
---|
24 | if [ "$machine" = "brodie" ] ; then |
---|
25 | X8BRODIE=1 |
---|
26 | fi |
---|
27 | VPP=0 |
---|
28 | if [ "$machine" = "nymphea0" ] ; then |
---|
29 | VPP=1 |
---|
30 | fi |
---|
31 | # |
---|
32 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
33 | echo "# Definitions de Macros pour Make" |
---|
34 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
35 | echo |
---|
36 | echo "# Repertoires :" |
---|
37 | echo |
---|
38 | echo "GCM = "$gcm |
---|
39 | echo 'LIBF = $(GCM)/libf' |
---|
40 | if [ "$CRAY" = '0' ] ; then |
---|
41 | # echo 'LIBO = $(GCM)/libo/$(MACHINE)' |
---|
42 | echo 'LIBO = $(LIBOGCM)/$(MACHINE)' |
---|
43 | else |
---|
44 | echo 'LIBO = $(GCM)/libo' |
---|
45 | fi |
---|
46 | #echo 'LOCAL_DIR=$(GCM)' |
---|
47 | #echo $localdir |
---|
48 | echo "LOCAL_DIR=`echo $localdir`" |
---|
49 | echo 'BIBIO = $(LIBF)/bibio' |
---|
50 | echo "FILTRE = filtre" |
---|
51 | echo "PHYS = " |
---|
52 | echo "DYN = dyn " |
---|
53 | echo 'LIBPHY = $(LIBO)/libphy$(PHYS).a' |
---|
54 | if [ "$1" = 'titan' ] ; then |
---|
55 | echo 'LIBCHIM = $(LIBO)/libchim$(CHIM).a' |
---|
56 | fi |
---|
57 | echo 'DIRMAIN=dyn$(DIM)d$(FLAG_PARA)' |
---|
58 | echo 'RM=rm' |
---|
59 | echo |
---|
60 | echo "OPLINK = " |
---|
61 | echo |
---|
62 | echo '# Les differentes librairies pour l"edition des liens:' |
---|
63 | echo |
---|
64 | if ( [ "$XNEC" = '1' ] || [ "$X6NEC" = '1' ] || [ "$X8BRODIE" = '1' ] ) ; then |
---|
65 | echo 'dyn3d = $(LIBO)/libsxdyn3d.a $(LIBO)/libsx$(FILTRE).a' |
---|
66 | echo 'dyn3dpar = $(LIBO)/libsxdyn3dpar.a $(LIBO)/libsx$(FILTRE).a' |
---|
67 | echo 'dyn2d = $(LIBO)/libsxdyn2d.a' |
---|
68 | echo 'dyn1d = $(LIBO)/libsxdyn1d.a' |
---|
69 | echo 'L_DYN = -lsxdyn$(DIM)d$(FLAG_PARA)' |
---|
70 | echo 'L_FILTRE = -lsx$(FILTRE)' |
---|
71 | echo 'L_PHY = -lsxphy$(PHYS) ' |
---|
72 | if [ "$1" = 'titan' ] ; then |
---|
73 | echo 'L_CHIM = -lsxchim$(CHIM) ' |
---|
74 | fi |
---|
75 | echo 'L_BIBIO = -lsxbibio' |
---|
76 | echo 'L_ADJNT =' |
---|
77 | else |
---|
78 | echo 'dyn3d = $(LIBO)/libdyn3d.a $(LIBO)/lib$(FILTRE).a' |
---|
79 | echo 'dyn3dpar = $(LIBO)/libdyn3dpar.a $(LIBO)/lib$(FILTRE).a' |
---|
80 | echo 'dyn2d = $(LIBO)/libdyn2d.a' |
---|
81 | echo 'dyn1d = $(LIBO)/libdyn1d.a' |
---|
82 | echo 'L_DYN = -ldyn$(DIM)d$(FLAG_PARA)' |
---|
83 | echo 'L_FILTRE = -l$(FILTRE)' |
---|
84 | echo 'L_PHY = -lphy$(PHYS) ' |
---|
85 | if [ "$1" = 'titan' ] ; then |
---|
86 | echo 'L_CHIM = -lchim$(CHIM) ' |
---|
87 | fi |
---|
88 | echo 'L_BIBIO = -lbibio' |
---|
89 | echo 'L_ADJNT =' |
---|
90 | fi |
---|
91 | |
---|
92 | echo |
---|
93 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
94 | echo "# Option de compilation FORTRAN" |
---|
95 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
96 | echo |
---|
97 | echo 'COMPILE = $(F77) $(OPTIM) $(INCLUDE) -c' |
---|
98 | echo 'COMPILE90 = $(F90) $(OPTIM90) $(INCLUDE) -c' |
---|
99 | echo 'COMPTRU90 = $(F90) $(OPTIMTRU90) $(INCLUDE) -c' |
---|
100 | echo "LINK = $LINK" |
---|
101 | echo "AR = $AR" |
---|
102 | echo |
---|
103 | echo |
---|
104 | echo '#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' |
---|
105 | echo '# Option de compilation C' |
---|
106 | echo '#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' |
---|
107 | echo |
---|
108 | echo 'COMPILEC = $(CCC) $(OPTIMC) $(INCLUDEC) -c' |
---|
109 | echo 'AR = ar' |
---|
110 | echo |
---|
111 | echo |
---|
112 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
113 | echo "# Creation des differents executables" |
---|
114 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
115 | echo |
---|
116 | echo "# Executables:" |
---|
117 | echo "# ------------" |
---|
118 | echo |
---|
119 | echo "PROG = code" |
---|
120 | echo |
---|
121 | if [ "$1" = 'titan' ] ; then |
---|
122 | echo 'main : chim $(DYN) bibio phys $(OPTION_DEP) ' |
---|
123 | else |
---|
124 | echo 'main : $(DYN) bibio phys $(OPTION_DEP) ' |
---|
125 | fi |
---|
126 | echo ' cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\' |
---|
127 | echo ' cd $(LOCAL_DIR); \' |
---|
128 | echo ' $(COMPILE90) $(LIBF)/$(DIRMAIN)/$(PROG).F -o $(PROG).o ; \' |
---|
129 | echo ' $(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_ADJNT) $(L_FILTRE) $(L_PHY) $(L_CHIM) $(L_BIBIO) $(L_DYN) $(OPLINK) $(OPTION_LINK) -o $(LOCAL_DIR)/$(PROG).e ; $(RM) $(PROG).o ' |
---|
130 | echo |
---|
131 | echo 'dyn : $(LIBO)/libdyn$(DIM)d$(FLAG_PARA).a $(FILTRE)$(DIM)d' |
---|
132 | echo |
---|
133 | echo 'phys : $(LIBPHY)' |
---|
134 | echo |
---|
135 | if [ "$1" = 'titan' ] ; then |
---|
136 | echo 'chim : $(LIBCHIM)' |
---|
137 | echo |
---|
138 | fi |
---|
139 | echo 'bibio : $(LIBO)/libbibio.a' |
---|
140 | echo |
---|
141 | echo 'adjnt : $(LIBO)/libadjnt.a' |
---|
142 | echo |
---|
143 | echo '$(FILTRE)3d : $(LIBO)/lib$(FILTRE).a' |
---|
144 | echo |
---|
145 | echo '$(FILTRE)2d :' |
---|
146 | echo |
---|
147 | echo '$(FILTRE)1d :' |
---|
148 | echo |
---|
149 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
150 | echo "# Contenu des differentes bibliotheques" |
---|
151 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
152 | echo |
---|
153 | echo |
---|
154 | cd $libf >/dev/null 2>&1 |
---|
155 | for diri in ` ls ` |
---|
156 | do |
---|
157 | if [ -d $diri ] ; then |
---|
158 | if [ "`ls $diri/*.F`" != "" ] || [ "`ls $diri/*.F90`" != "" ] ; then |
---|
159 | cd $diri >/dev/null 2>&1 |
---|
160 | echo |
---|
161 | listlib="" |
---|
162 | for i in `ls *.F` |
---|
163 | do |
---|
164 | fili=`basename $i .F` |
---|
165 | test=` ( head $i | grep ' PROGRAM' ) ` |
---|
166 | if [ "$test" = "" ] ; then |
---|
167 | listlib=$listlib" "$fili |
---|
168 | fi |
---|
169 | done |
---|
170 | for i in `ls *.F90` |
---|
171 | do |
---|
172 | fili=`basename $i .F90` |
---|
173 | test=` ( head $i | grep ' PROGRAM' ) ` |
---|
174 | if [ "$test" = "" ] ; then |
---|
175 | listlib=$listlib" "$fili |
---|
176 | fi |
---|
177 | done |
---|
178 | # |
---|
179 | echo |
---|
180 | echo |
---|
181 | echo "#=======================================================================" |
---|
182 | echo "# Contenu de la bibliotheque correspondant au Directory "$diri |
---|
183 | echo "#=======================================================================" |
---|
184 | echo |
---|
185 | for fili in $listlib |
---|
186 | do |
---|
187 | echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)" |
---|
188 | echo |
---|
189 | done |
---|
190 | echo '.PRECIOUS : $(LIBO)/lib'$diri'.a' |
---|
191 | echo |
---|
192 | echo |
---|
193 | echo "# Compilation des membres de la bibliotheque lib"$diri".a" |
---|
194 | echo |
---|
195 | for fili in $listlib |
---|
196 | do |
---|
197 | if [ -f $fili.F90 ] ; then |
---|
198 | trufile=$fili.F90 |
---|
199 | else |
---|
200 | trufile=$fili.F |
---|
201 | fi |
---|
202 | F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1 |
---|
203 | egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1 |
---|
204 | egrep -i '#include*.inc ' $trufile > /dev/null 2>&1 && F90=1 |
---|
205 | str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$diri/$trufile |
---|
206 | [ "$fili" = "chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F |
---|
207 | for stri in ` ( sed -n "/\#include/s/\#include//p" $trufile | sed 's/\"//g' ; egrep -i '^ *use ' $trufile | sed -e 's/,/ /' | awk ' { print $2 } ' ) ` |
---|
208 | do |
---|
209 | stri=`echo $stri | tr [A-Z] [a-z]` |
---|
210 | if [ -f $stri ] ; then |
---|
211 | echo $str1 \\ |
---|
212 | str1='$(LIBF)/'$diri'/'$stri |
---|
213 | else |
---|
214 | if [ -f $stri.F ] || [ -f $stri.F90 ] ; then |
---|
215 | echo $str1 \\ |
---|
216 | str1='$(LIBO)/lib'$diri'.a('$stri'.o)' |
---|
217 | else |
---|
218 | for dirinc in dyn3d grid bibio |
---|
219 | do |
---|
220 | if [ -f ../$dirinc/$stri ] ; then |
---|
221 | echo $str1 \\ |
---|
222 | str1='$(LIBF)/'`cd .. ; ls */$stri | head -1` |
---|
223 | fi |
---|
224 | done |
---|
225 | fi |
---|
226 | fi |
---|
227 | done |
---|
228 | echo $str1 |
---|
229 | if [ "$F90" -eq '0' ] ; then |
---|
230 | echo ' cd $(LOCAL_DIR); \' |
---|
231 | echo ' $(COMPILE) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
232 | else |
---|
233 | echo ' cd $(LOCAL_DIR); \' |
---|
234 | if [ -f $fili.F90 ] ; then |
---|
235 | echo ' $(COMPTRU90) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
236 | else |
---|
237 | echo ' $(COMPILE90) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
238 | fi |
---|
239 | MODU=0; egrep -i '^ *module ' $trufile> /dev/null 2>&1 && MODU=1 |
---|
240 | if [ "$MODU" -eq '1' -a "$CRAY" != '1' ] ; then |
---|
241 | if [ "$os" = 'UNIX_System_V' ] ; then |
---|
242 | echo ' cp $(MOD_LOC_DIR)/*.$(MOD_SUFFIX) $(LIBO)/ ; \' |
---|
243 | else |
---|
244 | echo ' mv $(MOD_LOC_DIR)/'$fili'.$(MOD_SUFFIX) $(LIBO)/'$fili'.$(MOD_SUFFIX) ; \' |
---|
245 | # echo ' if [ "$(MOD_LOC_DIR)" ne "$(LIBO)" ] ; then mv $(MOD_LOC_DIR)/'*'.$(MOD_SUFFIX) $(LIBO) ; fi ; \' |
---|
246 | fi |
---|
247 | fi |
---|
248 | fi |
---|
249 | if ( [ "$XNEC" -eq '1' ] || [ "$X6NEC" = '1' ] || [ "$X8BRODIE" = '1' ] ) ; then |
---|
250 | echo ' sxar r $(LIBO)/libsx'$diri'.a '$fili'.o ; \' |
---|
251 | fi |
---|
252 | echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \' |
---|
253 | echo ' cd $(GCM)' |
---|
254 | echo |
---|
255 | done |
---|
256 | # |
---|
257 | echo |
---|
258 | cd $libf |
---|
259 | elif [ "`ls $diri/*.c`" != "" ] ; then |
---|
260 | cd $diri >/dev/null 2>&1 |
---|
261 | echo |
---|
262 | listlib="" |
---|
263 | for i in `ls *.c` |
---|
264 | do |
---|
265 | fili=`basename $i .c` |
---|
266 | test=` ( head $i | grep ' PROGRAM' ) ` |
---|
267 | if [ "$test" = "" ] ; then |
---|
268 | listlib=$listlib" "$fili |
---|
269 | fi |
---|
270 | done |
---|
271 | # |
---|
272 | echo |
---|
273 | echo |
---|
274 | echo '#=======================================================================' |
---|
275 | echo '# Contenu de la bibliotheque correspondant au Directory '$diri |
---|
276 | echo '#=======================================================================' |
---|
277 | echo |
---|
278 | for fili in $listlib |
---|
279 | do |
---|
280 | echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)" |
---|
281 | echo |
---|
282 | done |
---|
283 | echo '.PRECIOUS : $(LIBO)/lib'$diri'.a' |
---|
284 | echo |
---|
285 | echo |
---|
286 | echo '# Compilation des membres de la bibliotheque lib'$diri'.a' |
---|
287 | echo |
---|
288 | for fili in $listlib |
---|
289 | do |
---|
290 | str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$diri/$fili.c |
---|
291 | for stri in ` ( sed -n "/\#include/s/\#include//p" $fili.c | sed 's/\"//g' ) ` |
---|
292 | do |
---|
293 | if [ -f $stri ] ; then |
---|
294 | echo $str1 \\ |
---|
295 | str1='$(LIBF)/'$diri'/'$stri |
---|
296 | else |
---|
297 | for dirinc in dyn3d grid bibio |
---|
298 | do |
---|
299 | if [ -f ../$dirinc/$stri ] ; then |
---|
300 | echo $str1 \\ |
---|
301 | str1='$(LIBF)/'`cd .. ; ls */$stri | head -1` |
---|
302 | fi |
---|
303 | done |
---|
304 | fi |
---|
305 | done |
---|
306 | echo $str1 |
---|
307 | echo ' $(COMPILEC) $(LIBF)/'$diri'/'$fili'.c; \' |
---|
308 | if ( [ "$XNEC" -eq '1' ] || [ "$X6NEC" = '1' ] || [ "$X8BRODIE" = '1' ] ) ; then |
---|
309 | echo ' sxar r $(LIBO)/libsx'$diri'.a '$fili'.o ; \' |
---|
310 | fi |
---|
311 | echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; /bin/rm '$fili'.o ; \' |
---|
312 | echo ' cd $(GCM)' |
---|
313 | echo |
---|
314 | done |
---|
315 | # |
---|
316 | echo |
---|
317 | cd $libf |
---|
318 | fi |
---|
319 | fi |
---|
320 | done |
---|