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 'COMPILE90 = $(F90) $(OPTIM90) $(INCLUDE) -c' |
---|
93 | echo "LINK = $LINK" |
---|
94 | echo "AR = $AR" |
---|
95 | echo |
---|
96 | echo |
---|
97 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
98 | echo "# Creation des differents executables" |
---|
99 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
100 | echo |
---|
101 | echo "# Executables:" |
---|
102 | echo "# ------------" |
---|
103 | echo |
---|
104 | echo "PROG = code" |
---|
105 | echo |
---|
106 | echo 'main : $(DYN) bibio phys aeronomars $(OPTION_DEP) ' |
---|
107 | echo ' cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\' |
---|
108 | echo ' cd $(LOCAL_DIR); \' |
---|
109 | echo ' $(COMPILE90) $(LIBF)/$(DIRMAIN)/$(PROG).F -o $(PROG).o ; \' |
---|
110 | if [ "$CRAY" = '0' ] ; then |
---|
111 | 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 ' |
---|
112 | else |
---|
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 | fi |
---|
115 | echo |
---|
116 | echo 'dyn : $(LIBO)/libdyn$(DIM)d.a $(FILTRE)$(DIM)d' |
---|
117 | echo |
---|
118 | echo 'olddyn : $(LIBO)/libolddyn$(DIM)d.a $(FILTRE)$(DIM)d' |
---|
119 | echo |
---|
120 | echo 'phys : $(LIBPHY)' |
---|
121 | echo |
---|
122 | echo 'bibio : $(LIBO)/libbibio.a' |
---|
123 | echo |
---|
124 | echo 'aeronomars : $(LIBO)/libaeronomars.a' |
---|
125 | echo |
---|
126 | echo 'adjnt : $(LIBO)/libadjnt.a' |
---|
127 | echo |
---|
128 | echo '$(FILTRE)3d : $(LIBO)/lib$(FILTRE).a' |
---|
129 | echo |
---|
130 | echo '$(FILTRE)2d :' |
---|
131 | echo |
---|
132 | echo '$(FILTRE)1d :' |
---|
133 | echo |
---|
134 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
135 | echo "# Contenu des differentes bibliotheques" |
---|
136 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
137 | echo |
---|
138 | echo |
---|
139 | cd $libf >/dev/null 2>&1 |
---|
140 | for diri in ` ls ` |
---|
141 | do |
---|
142 | if [ -d $diri ] ; then |
---|
143 | if [ "`ls $diri/*.F`" != "" ] || [ "`ls $diri/*.F90`" != "" ] ; then |
---|
144 | cd $diri >/dev/null 2>&1 |
---|
145 | echo |
---|
146 | listlib="" |
---|
147 | for i in `ls *.F` |
---|
148 | do |
---|
149 | fili=`basename $i .F` |
---|
150 | test=` ( head $i | grep ' PROGRAM' ) ` |
---|
151 | if [ "$test" = "" ] ; then |
---|
152 | listlib=$listlib" "$fili |
---|
153 | fi |
---|
154 | done |
---|
155 | for i in `ls *.F90` |
---|
156 | do |
---|
157 | fili=`basename $i .F90` |
---|
158 | test=` ( head $i | grep ' PROGRAM' ) ` |
---|
159 | if [ "$test" = "" ] ; then |
---|
160 | listlib=$listlib" "$fili |
---|
161 | fi |
---|
162 | done |
---|
163 | # |
---|
164 | echo |
---|
165 | echo |
---|
166 | echo "#=======================================================================" |
---|
167 | echo "# Contenu de la bibliotheque correspondant au Directory "$diri |
---|
168 | echo "#=======================================================================" |
---|
169 | echo |
---|
170 | for fili in $listlib |
---|
171 | do |
---|
172 | echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)" |
---|
173 | echo |
---|
174 | done |
---|
175 | echo '.PRECIOUS : $(LIBO)/lib'$diri'.a' |
---|
176 | echo |
---|
177 | echo |
---|
178 | echo "# Compilation des membres de la bibliotheque lib"$diri".a" |
---|
179 | echo |
---|
180 | for fili in $listlib |
---|
181 | do |
---|
182 | if [ -f $fili.F90 ] ; then |
---|
183 | trufile=$fili.F90 |
---|
184 | else |
---|
185 | trufile=$fili.F |
---|
186 | fi |
---|
187 | F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1 |
---|
188 | egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1 |
---|
189 | str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$diri/$trufile |
---|
190 | [ "$fili" = "chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F |
---|
191 | for stri in ` ( sed -n "/\#include/s/\#include//p" $trufile | sed 's/\"//g' ; egrep -i '^ *use ' $trufile | awk ' { print $2 } ' ) ` |
---|
192 | do |
---|
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 | str1='$(LIBO)/lib'$diri'.a('$stri'.o)' |
---|
200 | else |
---|
201 | # for dirinc in dyn3d grid bibio aeronomars phymars |
---|
202 | for dirinc in $* |
---|
203 | do |
---|
204 | if [ -f ../$dirinc/$stri ] ; then |
---|
205 | echo $str1 \\ |
---|
206 | str1='$(LIBF)/'`cd .. ; ls */$stri | head -1` |
---|
207 | fi |
---|
208 | done |
---|
209 | fi |
---|
210 | fi |
---|
211 | done |
---|
212 | echo $str1 |
---|
213 | echo ' cd $(LOCAL_DIR); \' |
---|
214 | echo ' $(COMPILE90) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
215 | MODU=0; egrep -i ' *module ' $trufile> /dev/null 2>&1 && MODU=1 |
---|
216 | if [ "$MODU" -eq '1' -a "$CRAY" != '1' ] ; then |
---|
217 | if [ "$os" = 'UNIX_System_V' ] ; then |
---|
218 | echo ' cp $(MOD_LOC_DIR)/*.$(MOD_SUFFIX) $(LIBO)/ ; \' |
---|
219 | else |
---|
220 | echo ' mv $(MOD_LOC_DIR)/'$fili'.$(MOD_SUFFIX) $(LIBO)/'$fili'.$(MOD_SUFFIX) ; \' |
---|
221 | fi |
---|
222 | fi |
---|
223 | if [ "$XNEC" -eq '1' ] ; then |
---|
224 | echo ' sxar r $(LIBO)/libsx'$diri'.a '$fili'.o ; \' |
---|
225 | fi |
---|
226 | echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \' |
---|
227 | echo ' cd $(GCM)' |
---|
228 | echo |
---|
229 | done |
---|
230 | # |
---|
231 | echo |
---|
232 | cd $libf |
---|
233 | fi |
---|
234 | fi |
---|
235 | done |
---|