1 | #!/bin/sh |
---|
2 | #set -xv |
---|
3 | # |
---|
4 | # Ehouarn: added the following feature: |
---|
5 | # create_make_gcm must be called with list of directories |
---|
6 | # which contain header (or modules) which should be scanned |
---|
7 | # by create_make_gcm when checking dependencies. |
---|
8 | # Example: |
---|
9 | # create_make_gcm dyn3d grid |
---|
10 | # means that header/modules will be looked for in directories |
---|
11 | # ., dyn3d and grid |
---|
12 | # |
---|
13 | machine=`hostname` |
---|
14 | os=`uname` |
---|
15 | gcm=`pwd` |
---|
16 | libf=$gcm/libf |
---|
17 | libo=$gcm/libo |
---|
18 | CRAY=0 |
---|
19 | if [ "$machine" = "atlas" -o "$machine" = "etoile" -o "$machine" = "axis" ] ; then |
---|
20 | CRAY=1 |
---|
21 | fi |
---|
22 | XNEC=0 |
---|
23 | if [ "$machine" = "rhodes" ] ; then |
---|
24 | XNEC=1 |
---|
25 | fi |
---|
26 | VPP=0 |
---|
27 | if [ "$machine" = "nymphea0" ] ; then |
---|
28 | VPP=1 |
---|
29 | fi |
---|
30 | # |
---|
31 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
32 | echo "# Definitions de Macros pour Make" |
---|
33 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
34 | echo |
---|
35 | echo "# create_make_gcm arguments: $*" |
---|
36 | echo |
---|
37 | echo "# Repertoires :" |
---|
38 | echo |
---|
39 | echo "GCM = "$gcm |
---|
40 | if [ "$CRAY" = '0' ] ; then |
---|
41 | echo "MACHINE = sun4" |
---|
42 | fi |
---|
43 | echo 'LIBF = $(GCM)/libf' |
---|
44 | if [ "$CRAY" = '0' ] ; then |
---|
45 | # echo 'LIBO = $(GCM)/libo/$(MACHINE)' |
---|
46 | echo 'LIBO = $(LIBOGCM)/$(MACHINE)' |
---|
47 | else |
---|
48 | echo 'LIBO = $(GCM)/libo' |
---|
49 | fi |
---|
50 | #echo 'LOCAL_DIR=$(GCM)' |
---|
51 | #echo $localdir |
---|
52 | echo "LOCAL_DIR=`echo $localdir`" |
---|
53 | echo 'BIBIO = $(LIBF)/bibio' |
---|
54 | echo 'AERONOMARS = $(LIBF)/aeronomars' |
---|
55 | echo "FILTRE = filtre" |
---|
56 | echo "PHYS = " |
---|
57 | echo 'DYN = $(DYNTYPE)' |
---|
58 | echo 'LIBPHY = $(LIBO)/libphy$(PHYS).a' |
---|
59 | echo 'DIRMAIN= $(DYN)$(DIM)d' |
---|
60 | echo 'RM=rm' |
---|
61 | echo |
---|
62 | echo "OPLINK = " |
---|
63 | echo |
---|
64 | echo '# Les differentes librairies pour l"edition des liens:' |
---|
65 | echo |
---|
66 | if [ "$XNEC" = '1' ] ; then |
---|
67 | echo 'dyn3d = $(LIBO)/libsxdyn3d.a $(LIBO)/libsx$(FILTRE).a' |
---|
68 | echo 'dyn2d = $(LIBO)/libsxdyn2d.a' |
---|
69 | echo 'dyn1d = $(LIBO)/libsxdyn1d.a' |
---|
70 | echo 'L_DYN = -lsxdyn$(DIM)d' |
---|
71 | echo 'L_FILTRE = -lsx$(FILTRE)' |
---|
72 | echo 'L_PHY = -lsxphy$(PHYS) ' |
---|
73 | echo 'L_BIBIO = -lsxbibio' |
---|
74 | echo 'L_AERONOMARS = -lsxaeronomars' |
---|
75 | echo 'L_ADJNT =' |
---|
76 | else |
---|
77 | echo 'dyn3d = $(LIBO)/libdyn3d.a $(LIBO)/lib$(FILTRE).a' |
---|
78 | echo 'dyn2d = $(LIBO)/libdyn2d.a' |
---|
79 | echo 'dyn1d = $(LIBO)/libdyn1d.a' |
---|
80 | echo 'L_DYN = -l$(DYN)$(DIM)d' |
---|
81 | echo 'L_FILTRE = -l$(FILTRE)' |
---|
82 | echo 'L_PHY = -lphy$(PHYS) ' |
---|
83 | echo 'L_BIBIO = -lbibio' |
---|
84 | echo 'L_AERONOMARS = -laeronomars' |
---|
85 | echo 'L_ADJNT =' |
---|
86 | fi |
---|
87 | echo |
---|
88 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
89 | echo "# Option de compilation FORTRAN" |
---|
90 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
91 | echo |
---|
92 | echo 'COMPILE = $(F77) $(OPTIM) $(INCLUDE) -c' |
---|
93 | echo 'COMPILE90 = $(F90) $(OPTIM90) $(INCLUDE) -c' |
---|
94 | echo 'COMPTRU90 = $(F90) $(OPTIMTRU90) $(INCLUDE) -c' |
---|
95 | echo "LINK = $LINK" |
---|
96 | echo "AR = $AR" |
---|
97 | echo |
---|
98 | echo |
---|
99 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
100 | echo "# Creation des differents executables" |
---|
101 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
102 | echo |
---|
103 | echo "# Executables:" |
---|
104 | echo "# ------------" |
---|
105 | echo |
---|
106 | echo "PROG = code" |
---|
107 | echo |
---|
108 | echo 'main : $(DYN) bibio phys aeronomars $(OPTION_DEP) ' |
---|
109 | echo ' cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\' |
---|
110 | echo ' cd $(LOCAL_DIR); \' |
---|
111 | echo ' $(COMPILE90) $(LIBF)/$(DIRMAIN)/$(SOURCE) -o $(PROG).o ; \' |
---|
112 | if [ "$CRAY" = '0' ] ; then |
---|
113 | echo ' $(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_ADJNT) $(L_FILTRE) $(L_AERONOMARS) $(L_PHY) $(L_BIBIO) $(L_DYN) $(L_AERONOMARS) $(OPLINK) $(OPTION_LINK) -o $(LOCAL_DIR)/$(PROG).e ; $(RM) $(PROG).o ' |
---|
114 | else |
---|
115 | echo ' $(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_ADJNT) $(L_FILTRE) $(L_AERONOMARS) $(L_PHY) $(L_BIBIO) $(L_DYN) $(L_AERONOMARS) $(OPLINK) $(OPTION_LINK) -o $(LOCAL_DIR)/$(PROG).e ; $(RM) $(PROG).o ' |
---|
116 | fi |
---|
117 | echo |
---|
118 | echo 'dyn : $(LIBO)/libdyn$(DIM)d.a $(FILTRE)$(DIM)d' |
---|
119 | echo |
---|
120 | echo 'olddyn : $(LIBO)/libolddyn$(DIM)d.a $(FILTRE)$(DIM)d' |
---|
121 | echo |
---|
122 | echo 'phys : $(LIBPHY)' |
---|
123 | echo |
---|
124 | echo 'bibio : $(LIBO)/libbibio.a' |
---|
125 | echo |
---|
126 | echo 'aeronomars : $(LIBO)/libaeronomars.a' |
---|
127 | echo |
---|
128 | echo 'adjnt : $(LIBO)/libadjnt.a' |
---|
129 | echo |
---|
130 | echo '$(FILTRE)3d : $(LIBO)/lib$(FILTRE).a' |
---|
131 | echo |
---|
132 | echo '$(FILTRE)2d :' |
---|
133 | echo |
---|
134 | echo '$(FILTRE)1d :' |
---|
135 | echo |
---|
136 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
137 | echo "# Contenu des differentes bibliotheques" |
---|
138 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
139 | echo |
---|
140 | echo |
---|
141 | cd $libf >/dev/null 2>&1 |
---|
142 | for diri in ` ls ` |
---|
143 | do |
---|
144 | if [ -d $diri ] ; then |
---|
145 | if [ "`ls $diri/*.F`" != "" ] || [ "`ls $diri/*.F90`" != "" ] ; then |
---|
146 | cd $diri >/dev/null 2>&1 |
---|
147 | echo |
---|
148 | listlib="" |
---|
149 | for i in `ls *.F` |
---|
150 | do |
---|
151 | fili=`basename $i .F` |
---|
152 | test=` ( head $i | grep ' PROGRAM' ) ` |
---|
153 | if [ "$test" = "" ] ; then |
---|
154 | listlib=$listlib" "$fili |
---|
155 | fi |
---|
156 | done |
---|
157 | for i in `ls *.F90` |
---|
158 | do |
---|
159 | fili=`basename $i .F90` |
---|
160 | test=` ( head $i | grep ' PROGRAM' ) ` |
---|
161 | if [ "$test" = "" ] ; then |
---|
162 | listlib=$listlib" "$fili |
---|
163 | fi |
---|
164 | done |
---|
165 | # |
---|
166 | echo |
---|
167 | echo |
---|
168 | echo "#=======================================================================" |
---|
169 | echo "# Contenu de la bibliotheque correspondant au Directory "$diri |
---|
170 | echo "#=======================================================================" |
---|
171 | echo |
---|
172 | for fili in $listlib |
---|
173 | do |
---|
174 | echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)" |
---|
175 | echo |
---|
176 | done |
---|
177 | echo '.PRECIOUS : $(LIBO)/lib'$diri'.a' |
---|
178 | echo |
---|
179 | echo |
---|
180 | echo "# Compilation des membres de la bibliotheque lib"$diri".a" |
---|
181 | echo |
---|
182 | for fili in $listlib |
---|
183 | do |
---|
184 | if [ -f $fili.F90 ] ; then |
---|
185 | trufile=$fili.F90 |
---|
186 | else |
---|
187 | trufile=$fili.F |
---|
188 | fi |
---|
189 | F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1 |
---|
190 | egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1 |
---|
191 | egrep -i '#include*.inc ' $trufile > /dev/null 2>&1 && F90=1 |
---|
192 | str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$diri/$trufile |
---|
193 | [ "$fili" = "chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F |
---|
194 | for stri in ` ( sed -n "/\#include/s/\#include//p" $trufile | sed 's/\"//g' ; egrep -i '^ *use ' $trufile | sed -e 's/,/ /' | awk ' { print $2 } ' ) ` |
---|
195 | do |
---|
196 | stri=`echo $stri | tr [A-Z] [a-z]` |
---|
197 | if [ -f $stri ] ; then |
---|
198 | echo $str1 \\ |
---|
199 | str1='$(LIBF)/'$diri'/'$stri |
---|
200 | else |
---|
201 | if [ -f $stri.F ] || [ -f $stri.F90 ] ; then |
---|
202 | echo $str1 \\ |
---|
203 | str1='$(LIBO)/lib'$diri'.a('$stri'.o)' |
---|
204 | else |
---|
205 | # for dirinc in dyn3d grid bibio aeronomars phymars |
---|
206 | for dirinc in $* |
---|
207 | do |
---|
208 | if [ -f ../$dirinc/$stri ] ; then |
---|
209 | echo $str1 \\ |
---|
210 | str1='$(LIBF)/'`cd .. ; ls */$stri | head -1` |
---|
211 | fi |
---|
212 | if [ -f ../$dirinc/$stri.F90 ] ; then |
---|
213 | echo $str1 \\ |
---|
214 | str1='$(LIBO)/lib'$dirinc'.a('$stri'.o)' |
---|
215 | fi |
---|
216 | done |
---|
217 | fi |
---|
218 | fi |
---|
219 | done |
---|
220 | echo $str1 |
---|
221 | # Compile in LOCAL_DIR directory, and before compiling, |
---|
222 | # remove the object from the library |
---|
223 | echo ' cd $(LOCAL_DIR); \' |
---|
224 | echo ' $(AR) d $(LIBO)/lib'$diri'.a '$fili'.o ; \' |
---|
225 | if [ "$F90" -eq '0' ] ; then |
---|
226 | ## Fixed Form Fortran 77 |
---|
227 | echo ' $(COMPILE) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
228 | else |
---|
229 | ## Fortran 90 |
---|
230 | echo ' cd $(LOCAL_DIR); \' |
---|
231 | if [ -f $fili.F90 ] ; then |
---|
232 | ## Free Form Fortran 90 |
---|
233 | echo ' $(COMPTRU90) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
234 | else |
---|
235 | ## Fixed Form Fortran 90 |
---|
236 | echo ' $(COMPILE90) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
237 | fi |
---|
238 | ## If a module, handle created module descriptor file |
---|
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 | # Put generated object in library |
---|
253 | echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \' |
---|
254 | echo ' cd $(GCM)' |
---|
255 | echo |
---|
256 | done |
---|
257 | # |
---|
258 | echo |
---|
259 | cd $libf |
---|
260 | fi |
---|
261 | fi |
---|
262 | done |
---|