[135] | 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 'main : $(DYN) bibio phys $(OPTION_DEP) ' |
---|
| 110 | echo ' cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\' |
---|
| 111 | echo ' cd $(LOCAL_DIR); \' |
---|
[302] | 112 | echo ' $(COMPILE90) $(LIBF)/$(DIRMAIN)/$(SOURCE) -o $(PROG).o ; \' |
---|
[135] | 113 | if [ "$CRAY" = '0' ] ; then |
---|
| 114 | ##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 ' |
---|
| 115 | 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 ' |
---|
| 116 | else |
---|
| 117 | ##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 ' |
---|
| 118 | 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 ' |
---|
| 119 | fi |
---|
| 120 | echo |
---|
| 121 | echo 'dyn : $(LIBO)/libdyn$(DIM)d.a $(FILTRE)$(DIM)d' |
---|
| 122 | echo |
---|
| 123 | echo 'olddyn : $(LIBO)/libolddyn$(DIM)d.a $(FILTRE)$(DIM)d' |
---|
| 124 | echo |
---|
| 125 | echo 'phys : $(LIBPHY)' |
---|
| 126 | echo |
---|
| 127 | echo 'bibio : $(LIBO)/libbibio.a' |
---|
| 128 | echo |
---|
| 129 | ##echo 'aeronomars : $(LIBO)/libaeronomars.a' |
---|
| 130 | ##echo |
---|
| 131 | echo 'adjnt : $(LIBO)/libadjnt.a' |
---|
| 132 | echo |
---|
| 133 | echo '$(FILTRE)3d : $(LIBO)/lib$(FILTRE).a' |
---|
| 134 | echo |
---|
| 135 | echo '$(FILTRE)2d :' |
---|
| 136 | echo |
---|
| 137 | echo '$(FILTRE)1d :' |
---|
| 138 | echo |
---|
| 139 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 140 | echo "# Contenu des differentes bibliotheques" |
---|
| 141 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 142 | echo |
---|
| 143 | echo |
---|
| 144 | cd $libf >/dev/null 2>&1 |
---|
| 145 | for diri in ` ls ` |
---|
| 146 | do |
---|
| 147 | if [ -d $diri ] ; then |
---|
| 148 | if [ "`ls $diri/*.F`" != "" ] || [ "`ls $diri/*.F90`" != "" ] ; then |
---|
| 149 | cd $diri >/dev/null 2>&1 |
---|
| 150 | echo |
---|
| 151 | listlib="" |
---|
| 152 | for i in `ls *.F` |
---|
| 153 | do |
---|
| 154 | fili=`basename $i .F` |
---|
| 155 | test=` ( head $i | grep ' PROGRAM' ) ` |
---|
| 156 | if [ "$test" = "" ] ; then |
---|
| 157 | listlib=$listlib" "$fili |
---|
| 158 | fi |
---|
| 159 | done |
---|
| 160 | for i in `ls *.F90` |
---|
| 161 | do |
---|
| 162 | fili=`basename $i .F90` |
---|
| 163 | test=` ( head $i | grep ' PROGRAM' ) ` |
---|
| 164 | if [ "$test" = "" ] ; then |
---|
| 165 | listlib=$listlib" "$fili |
---|
| 166 | fi |
---|
| 167 | done |
---|
| 168 | # |
---|
| 169 | echo |
---|
| 170 | echo |
---|
| 171 | echo "#=======================================================================" |
---|
| 172 | echo "# Contenu de la bibliotheque correspondant au Directory "$diri |
---|
| 173 | echo "#=======================================================================" |
---|
| 174 | echo |
---|
| 175 | for fili in $listlib |
---|
| 176 | do |
---|
| 177 | echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)" |
---|
| 178 | echo |
---|
| 179 | done |
---|
| 180 | echo '.PRECIOUS : $(LIBO)/lib'$diri'.a' |
---|
| 181 | echo |
---|
| 182 | echo |
---|
| 183 | echo "# Compilation des membres de la bibliotheque lib"$diri".a" |
---|
| 184 | echo |
---|
| 185 | for fili in $listlib |
---|
| 186 | do |
---|
| 187 | if [ -f $fili.F90 ] ; then |
---|
| 188 | trufile=$fili.F90 |
---|
| 189 | else |
---|
| 190 | trufile=$fili.F |
---|
| 191 | fi |
---|
| 192 | F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1 |
---|
| 193 | egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1 |
---|
| 194 | egrep -i '#include*.inc ' $trufile > /dev/null 2>&1 && F90=1 |
---|
| 195 | str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$diri/$trufile |
---|
| 196 | [ "$fili" = "chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F |
---|
| 197 | for stri in ` ( sed -n "/\#include/s/\#include//p" $trufile | sed 's/\"//g' ; egrep -i '^ *use ' $trufile | sed -e 's/,/ /' | awk ' { print $2 } ' ) ` |
---|
| 198 | do |
---|
| 199 | stri=`echo $stri | tr [A-Z] [a-z]` |
---|
| 200 | if [ -f $stri ] ; then |
---|
| 201 | echo $str1 \\ |
---|
| 202 | str1='$(LIBF)/'$diri'/'$stri |
---|
| 203 | else |
---|
| 204 | if [ -f $stri.F ] || [ -f $stri.F90 ] ; then |
---|
| 205 | echo $str1 \\ |
---|
| 206 | str1='$(LIBO)/lib'$diri'.a('$stri'.o)' |
---|
| 207 | else |
---|
| 208 | # for dirinc in dyn3d grid bibio aeronomars phymars |
---|
| 209 | for dirinc in $* |
---|
| 210 | do |
---|
| 211 | if [ -f ../$dirinc/$stri ] ; then |
---|
| 212 | echo $str1 \\ |
---|
| 213 | str1='$(LIBF)/'`cd .. ; ls */$stri | head -1` |
---|
| 214 | fi |
---|
| 215 | if [ -f ../$dirinc/$stri.F90 ] ; then |
---|
| 216 | echo $str1 \\ |
---|
| 217 | str1='$(LIBO)/lib'$dirinc'.a('$stri'.o)' |
---|
| 218 | fi |
---|
| 219 | done |
---|
| 220 | fi |
---|
| 221 | fi |
---|
| 222 | done |
---|
| 223 | echo $str1 |
---|
| 224 | if [ "$F90" -eq '0' ] ; then |
---|
| 225 | echo ' cd $(LOCAL_DIR); \' |
---|
| 226 | echo ' $(COMPILE) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
| 227 | else |
---|
| 228 | echo ' cd $(LOCAL_DIR); \' |
---|
| 229 | if [ -f $fili.F90 ] ; then |
---|
| 230 | echo ' $(COMPTRU90) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
| 231 | else |
---|
| 232 | echo ' $(COMPILE90) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
| 233 | fi |
---|
| 234 | MODU=0; egrep -i '^ *module ' $trufile> /dev/null 2>&1 && MODU=1 |
---|
| 235 | if [ "$MODU" -eq '1' -a "$CRAY" != '1' ] ; then |
---|
| 236 | if [ "$os" = 'UNIX_System_V' ] ; then |
---|
| 237 | echo ' cp $(MOD_LOC_DIR)/*.$(MOD_SUFFIX) $(LIBO)/ ; \' |
---|
| 238 | else |
---|
| 239 | echo ' mv $(MOD_LOC_DIR)/'$fili'.$(MOD_SUFFIX) $(LIBO)/'$fili'.$(MOD_SUFFIX) ; \' |
---|
| 240 | # echo ' if [ "$(MOD_LOC_DIR)" ne "$(LIBO)" ] ; then mv $(MOD_LOC_DIR)/'*'.$(MOD_SUFFIX) $(LIBO) ; fi ; \' |
---|
| 241 | fi |
---|
| 242 | fi |
---|
| 243 | fi |
---|
| 244 | if ( [ "$XNEC" -eq '1' ] || [ "$X6NEC" = '1' ] || [ "$X8BRODIE" = '1' ] ) ; then |
---|
| 245 | echo ' sxar r $(LIBO)/libsx'$diri'.a '$fili'.o ; \' |
---|
| 246 | fi |
---|
| 247 | echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \' |
---|
| 248 | echo ' cd $(GCM)' |
---|
| 249 | echo |
---|
| 250 | done |
---|
| 251 | # |
---|
| 252 | echo |
---|
| 253 | cd $libf |
---|
| 254 | fi |
---|
| 255 | fi |
---|
| 256 | done |
---|