1 | #!/bin/sh |
---|
2 | #set -xv |
---|
3 | machine=`hostname` |
---|
4 | os=`uname` |
---|
5 | gcm=`pwd` |
---|
6 | libf=$gcm/libf |
---|
7 | libo=$gcm/libo |
---|
8 | CRAY=0 |
---|
9 | if [ "$machine" = "atlas" -o "$machine" = "etoile" -o "$machine" = "axis" ] ; then |
---|
10 | CRAY=1 |
---|
11 | fi |
---|
12 | # |
---|
13 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
14 | echo "# Definitions de Macros pour Make" |
---|
15 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
16 | echo |
---|
17 | echo "# Repertoires :" |
---|
18 | echo |
---|
19 | echo "GCM = "$gcm |
---|
20 | if [ "$CRAY" = '0' ] ; then |
---|
21 | echo "MACHINE = sun4" |
---|
22 | fi |
---|
23 | echo 'LIBF = $(GCM)/libf' |
---|
24 | if [ "$CRAY" = '0' ] ; then |
---|
25 | # echo 'LIBO = $(GCM)/libo/$(MACHINE)' |
---|
26 | echo 'LIBO = $(LIBOGCM)/$(MACHINE)' |
---|
27 | else |
---|
28 | echo 'LIBO = $(GCM)/libo' |
---|
29 | fi |
---|
30 | #echo 'LOCAL_DIR=$(GCM)' |
---|
31 | #echo $localdir |
---|
32 | echo "LOCAL_DIR=`echo $localdir`" |
---|
33 | echo 'BIBIO = $(LIBF)/bibio' |
---|
34 | echo "FILTRE = filtre" |
---|
35 | echo "PHYS = " |
---|
36 | echo "DYN = dyn " |
---|
37 | echo 'LIBPHY = $(LIBO)/libphy$(PHYS).a' |
---|
38 | echo 'DIRMAIN=dyn$(DIM)d' |
---|
39 | echo 'RM=rm' |
---|
40 | echo |
---|
41 | echo "OPLINK = " |
---|
42 | echo |
---|
43 | echo '# Les differentes librairies pour l"edition des liens:' |
---|
44 | echo |
---|
45 | echo 'dyn3d = $(LIBO)/libdyn3d.a $(LIBO)/lib$(FILTRE).a' |
---|
46 | echo 'dyn2d = $(LIBO)/libdyn2d.a' |
---|
47 | echo 'dyn1d = $(LIBO)/libdyn1d.a' |
---|
48 | echo 'L_DYN = -ldyn$(DIM)d' |
---|
49 | echo 'L_FILTRE = -l$(FILTRE)' |
---|
50 | echo 'L_PHY = -lphy$(PHYS) ' |
---|
51 | echo 'L_BIBIO = -lbibio' |
---|
52 | echo 'L_ADJNT =' |
---|
53 | echo |
---|
54 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
55 | echo "# Option de compilation FORTRAN" |
---|
56 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
57 | echo |
---|
58 | echo 'COMPILE = $(F77) $(OPTIM) $(INCLUDE) -c' |
---|
59 | echo 'COMPILE90 = $(F90) $(OPTIM90) $(INCLUDE) -c' |
---|
60 | echo 'COMPTRU90 = $(F90) $(OPTIMTRU90) $(INCLUDE) -c' |
---|
61 | echo "LINK = $LINK" |
---|
62 | echo "AR = $AR" |
---|
63 | echo |
---|
64 | echo |
---|
65 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
66 | echo "# Creation des differents executables" |
---|
67 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
68 | echo |
---|
69 | echo "# Executables:" |
---|
70 | echo "# ------------" |
---|
71 | echo |
---|
72 | echo "PROG = code" |
---|
73 | echo |
---|
74 | echo 'main : $(DYN) bibio phys $(OPTION_DEP) ' |
---|
75 | echo ' cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\' |
---|
76 | if [ "$CRAY" = '0' ] ; then |
---|
77 | echo ' cd $(LOCAL_DIR); \' |
---|
78 | #echo ' $(COMPILE90) $(LIBF)/$(DIRMAIN)/$(PROG).F -o $(PROG).o ; \' |
---|
79 | echo ' $(COMPILE) $(LIBF)/$(DIRMAIN)/$(PROG).F -o $(PROG).o ; \' |
---|
80 | else |
---|
81 | echo ' $(COMPILE90) $(LIBF)/$(DIRMAIN)/$(PROG).F ; \' |
---|
82 | fi |
---|
83 | if [ "$CRAY" = '0' ] ; then |
---|
84 | echo ' $(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_ADJNT) $(L_FILTRE) $(L_PHY) $(L_BIBIO) $(L_DYN) $(OPLINK) $(OPTION_LINK) -o $(LOCAL_DIR)/$(PROG).e ; $(RM) $(PROG).o ' |
---|
85 | else |
---|
86 | echo ' $(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_ADJNT) $(L_FILTRE) $(L_PHY) $(L_BIBIO) $(OPLINK) $(OPTION_LINK) -o $(LOCAL_DIR)/$(PROG).e ; $(RM) $(PROG).o ' |
---|
87 | fi |
---|
88 | echo |
---|
89 | echo 'dyn : $(LIBO)/libdyn$(DIM)d.a $(FILTRE)$(DIM)d' |
---|
90 | echo |
---|
91 | echo 'phys : $(LIBPHY)' |
---|
92 | echo |
---|
93 | echo 'bibio : $(LIBO)/libbibio.a' |
---|
94 | echo |
---|
95 | echo 'adjnt : $(LIBO)/libadjnt.a' |
---|
96 | echo |
---|
97 | echo '$(FILTRE)3d : $(LIBO)/lib$(FILTRE).a' |
---|
98 | echo |
---|
99 | echo '$(FILTRE)2d :' |
---|
100 | echo |
---|
101 | echo '$(FILTRE)1d :' |
---|
102 | echo |
---|
103 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
104 | echo "# Contenu des differentes bibliotheques" |
---|
105 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
106 | echo |
---|
107 | echo |
---|
108 | cd $libf >/dev/null 2>&1 |
---|
109 | for diri in ` ls ` |
---|
110 | do |
---|
111 | if [ -d $diri ] ; then |
---|
112 | if [ "`ls $diri/*.F`" != "" ] || [ "`ls $diri/*.F90`" != "" ] ; then |
---|
113 | cd $diri >/dev/null 2>&1 |
---|
114 | echo |
---|
115 | listlib="" |
---|
116 | for i in `ls *.F` |
---|
117 | do |
---|
118 | fili=`basename $i .F` |
---|
119 | test=` ( head $i | grep ' PROGRAM' ) ` |
---|
120 | if [ "$test" = "" ] ; then |
---|
121 | listlib=$listlib" "$fili |
---|
122 | fi |
---|
123 | done |
---|
124 | for i in `ls *.F90` |
---|
125 | do |
---|
126 | fili=`basename $i .F90` |
---|
127 | test=` ( head $i | grep ' PROGRAM' ) ` |
---|
128 | if [ "$test" = "" ] ; then |
---|
129 | listlib=$listlib" "$fili |
---|
130 | fi |
---|
131 | done |
---|
132 | # |
---|
133 | echo |
---|
134 | echo |
---|
135 | echo "#=======================================================================" |
---|
136 | echo "# Contenu de la bibliotheque correspondant au Directory "$diri |
---|
137 | echo "#=======================================================================" |
---|
138 | echo |
---|
139 | for fili in $listlib |
---|
140 | do |
---|
141 | echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)" |
---|
142 | echo |
---|
143 | done |
---|
144 | echo '.PRECIOUS : $(LIBO)/lib'$diri'.a' |
---|
145 | echo |
---|
146 | echo |
---|
147 | echo "# Compilation des membres de la bibliotheque lib"$diri".a" |
---|
148 | echo |
---|
149 | for fili in $listlib |
---|
150 | do |
---|
151 | if [ -f $fili.F90 ] ; then |
---|
152 | trufile=$fili.F90 |
---|
153 | else |
---|
154 | trufile=$fili.F |
---|
155 | fi |
---|
156 | F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1 |
---|
157 | egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1 |
---|
158 | str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$diri/$trufile |
---|
159 | [ "$fili" = "chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F |
---|
160 | for stri in ` ( sed -n "/\#include/s/\#include//p" $trufile | sed 's/\"//g' ; egrep -i '^ *use ' $trufile | awk ' { print $2 } ' ) ` |
---|
161 | do |
---|
162 | stri=`echo $stri | tr [A-Z] [a-z]` |
---|
163 | if [ -f $stri ] ; then |
---|
164 | echo $str1 \\ |
---|
165 | str1='$(LIBF)/'$diri'/'$stri |
---|
166 | else |
---|
167 | if [ -f $stri.F ] || [ -f $stri.F90 ] ; then |
---|
168 | str1='$(LIBO)/lib'$diri'.a('$stri'.o)' |
---|
169 | else |
---|
170 | for dirinc in dyn3d grid bibio |
---|
171 | do |
---|
172 | if [ -f ../$dirinc/$stri ] ; then |
---|
173 | echo $str1 \\ |
---|
174 | str1='$(LIBF)/'`cd .. ; ls */$stri | head -1` |
---|
175 | fi |
---|
176 | done |
---|
177 | fi |
---|
178 | fi |
---|
179 | done |
---|
180 | echo $str1 |
---|
181 | if [ "$F90" -eq '0' ] ; then |
---|
182 | echo ' cd $(LOCAL_DIR); \' |
---|
183 | echo ' $(COMPILE) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
184 | else |
---|
185 | echo ' cd $(LOCAL_DIR); \' |
---|
186 | if [ -f $fili.F90 ] ; then |
---|
187 | echo ' $(COMPTRU90) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
188 | else |
---|
189 | echo ' $(COMPILE90) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
190 | fi |
---|
191 | MODU=0; egrep -i ' *module ' $trufile> /dev/null 2>&1 && MODU=1 |
---|
192 | if [ "$MODU" -eq '1' -a "$CRAY" != '1' ] ; then |
---|
193 | if [ "$os" = 'UNIX_System_V' ] ; then |
---|
194 | echo ' cp $(MOD_LOC_DIR)/*.$(MOD_SUFFIX) $(LIBO)/ ; \' |
---|
195 | else |
---|
196 | echo ' mv $(MOD_LOC_DIR)/'$fili'.$(MOD_SUFFIX) $(LIBO)/'$fili'.$(MOD_SUFFIX) ; \' |
---|
197 | fi |
---|
198 | fi |
---|
199 | fi |
---|
200 | echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \' |
---|
201 | echo ' cd $(GCM)' |
---|
202 | echo |
---|
203 | done |
---|
204 | # |
---|
205 | echo |
---|
206 | cd $libf |
---|
207 | fi |
---|
208 | fi |
---|
209 | done |
---|