1 | #!/bin/sh |
---|
2 | # |
---|
3 | # $Id: create_make_gcm 1461 2010-12-03 11:12:25Z emillour $ |
---|
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 | echo 'DIRMAIN=dyn$(DIM)d$(FLAG_PARA)' |
---|
55 | echo 'RM=rm' |
---|
56 | echo |
---|
57 | echo "OPLINK = " |
---|
58 | echo |
---|
59 | echo '# Les differentes librairies pour l"edition des liens:' |
---|
60 | echo |
---|
61 | echo 'dyn3d = $(LIBO)/libdyn3d.a $(LIBO)/lib$(FILTRE).a' |
---|
62 | echo 'dyn3dpar = $(LIBO)/libdyn3dpar.a $(LIBO)/lib$(FILTRE).a' |
---|
63 | echo 'dyn2d = $(LIBO)/libdyn2d.a' |
---|
64 | echo 'dyn1d = $(LIBO)/libdyn1d.a' |
---|
65 | echo 'L_DYN = -ldyn$(DIM)d$(FLAG_PARA)' |
---|
66 | echo 'L_FILTRE = -l$(FILTRE)' |
---|
67 | echo 'L_PHY = -lphy$(PHYS) ' |
---|
68 | echo 'L_BIBIO = -lbibio' |
---|
69 | echo 'L_ADJNT =' |
---|
70 | echo 'L_COSP = -lcosp' |
---|
71 | |
---|
72 | echo |
---|
73 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
74 | echo "# Option de compilation FORTRAN" |
---|
75 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
76 | echo |
---|
77 | echo 'COMPILE = $(F77) $(OPTIM) $(INCLUDE) -c' |
---|
78 | echo 'COMPILE90 = $(F90) $(OPTIM90) $(INCLUDE) -c' |
---|
79 | echo 'COMPTRU90 = $(F90) $(OPTIMTRU90) $(INCLUDE) -c' |
---|
80 | echo "LINK = $LINK" |
---|
81 | echo "AR = $AR" |
---|
82 | echo |
---|
83 | echo |
---|
84 | echo '#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' |
---|
85 | echo '# Option de compilation C' |
---|
86 | echo '#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' |
---|
87 | echo |
---|
88 | echo 'COMPILEC = $(CCC) $(OPTIMC) $(INCLUDEC) -c' |
---|
89 | echo |
---|
90 | echo |
---|
91 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
92 | echo "# Creation des differents executables" |
---|
93 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
94 | echo |
---|
95 | echo "# Executables:" |
---|
96 | echo "# ------------" |
---|
97 | echo |
---|
98 | echo "PROG = code" |
---|
99 | echo |
---|
100 | #echo 'main : chimie $(DYN) bibio phys $(OPTION_DEP) ' |
---|
101 | echo 'main : $(DYN) bibio phys $(OPTION_DEP) ' |
---|
102 | echo ' cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\' |
---|
103 | echo ' cd $(LOCAL_DIR); \' |
---|
104 | echo ' $(COMPILE90) $(LIBF)/$(DIRMAIN)/$(SOURCE) -o $(PROG).o ; \' |
---|
105 | echo ' $(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_ADJNT) $(L_COSP) $(L_FILTRE) $(L_PHY) $(L_DYN) $(L_BIBIO) $(L_DYN) $(OPLINK) $(OPTION_LINK) -o $(LOCAL_DIR)/$(PROG).e ; $(RM) $(PROG).o ' |
---|
106 | echo |
---|
107 | echo 'dyn : $(LIBO)/libdyn$(DIM)d$(FLAG_PARA).a $(FILTRE)$(DIM)d' |
---|
108 | echo |
---|
109 | echo 'phys : $(LIBPHY)' |
---|
110 | echo |
---|
111 | #echo 'chimie : $(LIBO)/libchimie.a' |
---|
112 | echo |
---|
113 | echo 'bibio : $(LIBO)/libbibio.a' |
---|
114 | echo |
---|
115 | echo 'adjnt : $(LIBO)/libadjnt.a' |
---|
116 | echo |
---|
117 | echo 'cosp : $(LIBO)/libcosp.a' |
---|
118 | echo |
---|
119 | echo 'chimtitan : $(LIBO)/libchimtitan.a' |
---|
120 | echo |
---|
121 | echo '$(FILTRE)3d : $(LIBO)/lib$(FILTRE).a' |
---|
122 | echo |
---|
123 | echo '$(FILTRE)2d :' |
---|
124 | echo |
---|
125 | echo '$(FILTRE)1d :' |
---|
126 | echo |
---|
127 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
128 | echo "# Contenu des differentes bibliotheques" |
---|
129 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
130 | echo |
---|
131 | echo |
---|
132 | cd $libf >/dev/null 2>&1 |
---|
133 | for diri in ` ls ` |
---|
134 | do |
---|
135 | if [ -d $diri ] ; then |
---|
136 | if [ "`ls $diri/*.F`" != "" ] || [ "`ls $diri/*.F90`" != "" ] ; then |
---|
137 | cd $diri >/dev/null 2>&1 |
---|
138 | echo |
---|
139 | listlib="" |
---|
140 | for i in `ls *.F` |
---|
141 | do |
---|
142 | fili=`basename $i .F` |
---|
143 | test=` ( head $i | grep ' PROGRAM' ) ` |
---|
144 | if [ "$test" = "" ] ; then |
---|
145 | listlib=$listlib" "$fili |
---|
146 | fi |
---|
147 | done |
---|
148 | for i in `ls *.F90` |
---|
149 | do |
---|
150 | fili=`basename $i .F90` |
---|
151 | test=` ( head $i | grep ' PROGRAM' ) ` |
---|
152 | if [ "$test" = "" ] ; then |
---|
153 | listlib=$listlib" "$fili |
---|
154 | fi |
---|
155 | done |
---|
156 | # |
---|
157 | echo |
---|
158 | echo |
---|
159 | echo "#=======================================================================" |
---|
160 | echo "# Contenu de la bibliotheque correspondant au Directory "$diri |
---|
161 | echo "#=======================================================================" |
---|
162 | echo |
---|
163 | for fili in $listlib |
---|
164 | do |
---|
165 | echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)" |
---|
166 | echo |
---|
167 | done |
---|
168 | echo '.PRECIOUS : $(LIBO)/lib'$diri'.a' |
---|
169 | echo |
---|
170 | echo |
---|
171 | echo "# Compilation des membres de la bibliotheque lib"$diri".a" |
---|
172 | echo |
---|
173 | for fili in $listlib |
---|
174 | do |
---|
175 | if [ -f $fili.F90 ] ; then |
---|
176 | trufile=$fili.F90 |
---|
177 | else |
---|
178 | trufile=$fili.F |
---|
179 | fi |
---|
180 | F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1 |
---|
181 | egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1 |
---|
182 | egrep -i '#include*.inc ' $trufile > /dev/null 2>&1 && F90=1 |
---|
183 | str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$diri/$trufile |
---|
184 | [ "$fili" = "chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F |
---|
185 | for stri in ` ( sed -n "/\#include/s/\#include//p" $trufile | sed 's/\"//g' ; egrep -i '^ *use ' $trufile | sed -e 's/,/ /' | awk ' { print $2 } ' ) ` |
---|
186 | do |
---|
187 | |
---|
188 | |
---|
189 | # Differents cas de dependance correspondant a des include ou des |
---|
190 | # use module. |
---|
191 | # soit dans le repertoire local soit dans un autre. |
---|
192 | |
---|
193 | stri=`echo $stri | tr [A-Z] [a-z]` |
---|
194 | if [ -f $stri ] ; then |
---|
195 | echo $str1 \\ |
---|
196 | str1='$(LIBF)/'$diri'/'$stri |
---|
197 | else |
---|
198 | if [ -f $stri.F ] || [ -f $stri.F90 ] ; then |
---|
199 | echo $str1 \\ |
---|
200 | str1='$(LIBO)/lib'$diri'.a('$stri'.o)' |
---|
201 | else |
---|
202 | for dirinc in dyn3d grid bibio filtrez |
---|
203 | do |
---|
204 | if [ -f ../$dirinc/$stri ] ; then |
---|
205 | echo $str1 \\ |
---|
206 | str1='$(LIBF)/'`cd .. ; ls */$stri | head -1` |
---|
207 | fi |
---|
208 | if [ -f ../$dirinc/$stri.F90 ] ; then |
---|
209 | echo $str1 \\ |
---|
210 | str1='$(LIBO)/lib'$dirinc'.a('$stri'.o)' |
---|
211 | fi |
---|
212 | done |
---|
213 | fi |
---|
214 | fi |
---|
215 | done |
---|
216 | echo $str1 |
---|
217 | # Compile in LIBO directory; and before compiling, remove |
---|
218 | # object from library |
---|
219 | echo ' cd $(LIBO); \' |
---|
220 | echo ' $(AR) d $(LIBO)/lib'$diri'.a '$fili'.o ; \' |
---|
221 | if [ "$F90" -eq '0' ] ; then |
---|
222 | ## Fixed Form Fortran 77 |
---|
223 | echo ' $(COMPILE) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
224 | else |
---|
225 | ## Fortran 90 |
---|
226 | if [ -f $fili.F90 ] ; then |
---|
227 | ## Free Form |
---|
228 | echo ' $(COMPTRU90) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
229 | else |
---|
230 | echo ' $(COMPILE90) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
231 | fi |
---|
232 | fi |
---|
233 | # Put generated object in library |
---|
234 | echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \' |
---|
235 | echo ' cd $(GCM)' |
---|
236 | echo |
---|
237 | done |
---|
238 | # |
---|
239 | echo |
---|
240 | cd $libf |
---|
241 | ############################## |
---|
242 | ## CAS DES FICHIERS EN C |
---|
243 | ###### |
---|
244 | elif [ "`ls $diri/*.c`" != "" ] ; then |
---|
245 | cd $diri >/dev/null 2>&1 |
---|
246 | echo |
---|
247 | listlib="" |
---|
248 | for i in `ls *.c` |
---|
249 | do |
---|
250 | fili=`basename $i .c` |
---|
251 | test=` ( head $i | grep ' PROGRAM' ) ` |
---|
252 | if [ "$test" = "" ] ; then |
---|
253 | listlib=$listlib" "$fili |
---|
254 | fi |
---|
255 | done |
---|
256 | # |
---|
257 | echo |
---|
258 | echo |
---|
259 | echo '#=======================================================================' |
---|
260 | echo '# Contenu de la bibliotheque correspondant au Directory '$diri |
---|
261 | echo '#=======================================================================' |
---|
262 | echo |
---|
263 | for fili in $listlib |
---|
264 | do |
---|
265 | echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)" |
---|
266 | echo |
---|
267 | done |
---|
268 | echo '.PRECIOUS : $(LIBO)/lib'$diri'.a' |
---|
269 | echo |
---|
270 | echo |
---|
271 | echo '# Compilation des membres de la bibliotheque lib'$diri'.a' |
---|
272 | echo |
---|
273 | for fili in $listlib |
---|
274 | do |
---|
275 | str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$diri/$fili.c |
---|
276 | for stri in ` ( sed -n "/\#include/s/\#include//p" $fili.c | sed 's/\"//g' ) ` |
---|
277 | do |
---|
278 | if [ -f $stri ] ; then |
---|
279 | echo $str1 \\ |
---|
280 | str1='$(LIBF)/'$diri'/'$stri |
---|
281 | else |
---|
282 | for dirinc in dyn3d grid bibio |
---|
283 | do |
---|
284 | if [ -f ../$dirinc/$stri ] ; then |
---|
285 | echo $str1 \\ |
---|
286 | str1='$(LIBF)/'`cd .. ; ls */$stri | head -1` |
---|
287 | fi |
---|
288 | done |
---|
289 | fi |
---|
290 | done |
---|
291 | echo $str1 |
---|
292 | # Compile in LIBO directory; and before compiling, remove |
---|
293 | # object from library |
---|
294 | echo ' cd $(LIBO); \' |
---|
295 | echo ' $(AR) d $(LIBO)/lib'$diri'.a '$fili'.o ; \' |
---|
296 | ## C |
---|
297 | echo ' $(COMPILEC) $(LIBF)/'$diri'/'$fili'.c; \' |
---|
298 | # Put generated object in library |
---|
299 | echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \' |
---|
300 | echo ' cd $(GCM)' |
---|
301 | echo |
---|
302 | done |
---|
303 | # |
---|
304 | echo |
---|
305 | cd $libf |
---|
306 | ############################## |
---|
307 | fi |
---|
308 | fi |
---|
309 | done |
---|