| [218] | 1 | #!/bin/csh | 
|---|
| [2685] | 2 | # $Id: mkmf,v 1.23 2005-04-25 08:23:13 cmv Exp $ | 
|---|
| [218] | 3 |  | 
|---|
| [740] | 4 | #  Pour debugger | 
|---|
|  | 5 | set DODBG = 'echo' | 
|---|
| [742] | 6 | set DODBG = '' | 
|---|
| [740] | 7 |  | 
|---|
|  | 8 | # Librairies externe | 
|---|
| [737] | 9 | if( ! $?EXTLIBDIR ) then | 
|---|
| [740] | 10 | echo 'mkmf- WARNING (External libraries) EXTLIBDIR variable not set' | 
|---|
| [554] | 11 | endif | 
|---|
|  | 12 |  | 
|---|
| [218] | 13 | # creation de MakefileUser.h a partir de Makefile.h | 
|---|
| [968] | 14 | chmod +x ./makefileuser.csh | 
|---|
|  | 15 | $DODBG ./makefileuser.csh | 
|---|
| [218] | 16 |  | 
|---|
|  | 17 | # creation des liens pour les includes | 
|---|
| [554] | 18 | echo 'mkmf: Creating links for *.h (call mkmflien)' | 
|---|
| [968] | 19 | chmod +x ./mkmflien | 
|---|
| [1493] | 20 | $DODBG ./mkmflien -clean | 
|---|
| [218] | 21 |  | 
|---|
| [740] | 22 | # Liste des modules a construire | 
|---|
|  | 23 | # modules : Liste de module SOPHYA, sans dependance exterieure | 
|---|
|  | 24 | # extmodules : Liste de modules avec dependance exterieures | 
|---|
|  | 25 | #        _pres : Liste des modules presents | 
|---|
|  | 26 |  | 
|---|
|  | 27 | set modules = `cat libdirs` | 
|---|
|  | 28 | set extmodules = `cat extlibdirs` | 
|---|
|  | 29 | set modules_pres = '' | 
|---|
|  | 30 | set extmodules_pres = '' | 
|---|
|  | 31 |  | 
|---|
|  | 32 | set module_libnames = '' | 
|---|
|  | 33 | set extmodule_libnames = '' | 
|---|
|  | 34 | set extlib_list = '' | 
|---|
|  | 35 | set extslb_list = '' | 
|---|
|  | 36 | #  Constitution de la liste de modules present | 
|---|
|  | 37 | foreach f ($modules) | 
|---|
|  | 38 | if (-d ../$f ) then | 
|---|
|  | 39 | set modules_pres = ( $modules_pres $f ) | 
|---|
|  | 40 | set module_libnames = ( $module_libnames '$(LIB)lib'$f.a ) | 
|---|
|  | 41 | endif | 
|---|
|  | 42 | end | 
|---|
|  | 43 | foreach f ($extmodules) | 
|---|
|  | 44 | if (-d ../$f ) then | 
|---|
|  | 45 | set extmodules_pres = ( $extmodules_pres $f ) | 
|---|
|  | 46 | set extmodule_libnames = ( $extmodule_libnames '$(LIB)lib'$f.a ) | 
|---|
|  | 47 | set lil = "../$f/extlib_list" | 
|---|
|  | 48 | if (-f $lil ) set extlib_list = ($extlib_list `sed -e 's/.*/-l&/' $lil`) | 
|---|
|  | 49 | set lil = "../$f/extslb_list" | 
|---|
|  | 50 | if (-f $lil ) set extslb_list = ($extslb_list `sed -e 's/.*/-l&/' $lil`) | 
|---|
|  | 51 | endif | 
|---|
|  | 52 | end | 
|---|
|  | 53 |  | 
|---|
|  | 54 | echo 'mkmf: List of modules ' | 
|---|
|  | 55 | echo '  ... modules= ' $modules_pres | 
|---|
|  | 56 | echo $module_libnames | 
|---|
|  | 57 | echo '  ... extmodules= ' $extmodules_pres | 
|---|
|  | 58 | echo $extmodule_libnames | 
|---|
|  | 59 |  | 
|---|
| [554] | 60 | echo 'mkmf: Creating makefile global :' | 
|---|
| [1821] | 61 | rm -f GNUmakefile; touch GNUmakefile | 
|---|
| [218] | 62 |  | 
|---|
| [740] | 63 | echo '# include files defining compiler/linker options '  >> GNUmakefile | 
|---|
|  | 64 | echo 'MODULECXXREPNAME := PI'  >> GNUmakefile | 
|---|
| [218] | 65 | echo 'include Mgr/Makefile.h' >> GNUmakefile | 
|---|
| [740] | 66 | echo 'include Mgr/Makefile.slb' >> GNUmakefile | 
|---|
|  | 67 | echo ''   >> GNUmakefile | 
|---|
| [218] | 68 |  | 
|---|
|  | 69 | echo 'LIBF = ' `sed -e 's/.*/$(LIB)lib&.a/' libdirs` >> GNUmakefile | 
|---|
| [823] | 70 | # echo 'LIBS = -L$(LIB)' `sed -e 's/.*/-l&/' libdirs` '-lm' >> GNUmakefile | 
|---|
|  | 71 | echo 'LIBS = -L$(LIB)' `sed -e 's/.*/-l&/' libdirs`  >> GNUmakefile | 
|---|
|  | 72 | # echo 'LIBG = -L$(GLB) -lstdc++' >> GNUmakefile | 
|---|
|  | 73 | # echo 'ifeq ($(HOSTTYPE), powerpc)' >> GNUmakefile | 
|---|
|  | 74 | # echo '  LIBG = -L$(GLB)' >> GNUmakefile | 
|---|
|  | 75 | # echo 'endif' >> GNUmakefile | 
|---|
| [218] | 76 |  | 
|---|
|  | 77 | cat >> GNUmakefile <<EOF | 
|---|
|  | 78 |  | 
|---|
|  | 79 | defaut: libs | 
|---|
|  | 80 |  | 
|---|
| [740] | 81 | all: libs extlibs PI | 
|---|
| [218] | 82 |  | 
|---|
| [740] | 83 | libs: cxxlibs | 
|---|
| [218] | 84 |  | 
|---|
| [740] | 85 | extlibs: cxxextlibs | 
|---|
|  | 86 |  | 
|---|
|  | 87 | EOF | 
|---|
|  | 88 |  | 
|---|
| [218] | 89 | # Dans cet ordre pour les templates de cxx, a cause des dependances | 
|---|
|  | 90 | # pour instantiation automatique/manuels | 
|---|
|  | 91 |  | 
|---|
| [740] | 92 | echo 'cxxlibs: ' $modules_pres >>    GNUmakefile | 
|---|
| [2424] | 93 | echo '' >> GNUmakefile | 
|---|
| [740] | 94 | echo 'cxxextlibs: ' $extmodules_pres >> GNUmakefile | 
|---|
| [218] | 95 |  | 
|---|
| [2424] | 96 | # pour creer les repertoires et les liens | 
|---|
| [218] | 97 |  | 
|---|
| [2424] | 98 | echo '#--- Create directory and copy includes for install' >> GNUmakefile | 
|---|
|  | 99 | echo 'depend:' >> GNUmakefile | 
|---|
| [2437] | 100 | echo 'ifdef SOPHYADEVREP' >> GNUmakefile | 
|---|
|  | 101 | echo 'ifdef SOPHYACXX' >> GNUmakefile | 
|---|
| [2424] | 102 | echo '  @echo "Sophya will be installed under:"' >> GNUmakefile | 
|---|
| [2437] | 103 | echo '  @echo "  $(SOPHYADEVREP)/Include" ' >> GNUmakefile | 
|---|
|  | 104 | echo '  @echo "  $(SOPHYADEVREP)/`uname`-$(SOPHYACXX)" ' >> GNUmakefile | 
|---|
| [2424] | 105 | echo '  if [ -d Mgr ] ; then cd Mgr; \' >> GNUmakefile | 
|---|
| [2437] | 106 | echo '  ./crerep_sophya $(SOPHYADEVREP) `uname`-$(SOPHYACXX); \' >> GNUmakefile | 
|---|
| [2424] | 107 | echo '  ./makefileuser.csh; \' >> GNUmakefile | 
|---|
|  | 108 | echo '  ./mkmflien -copy ; \' >> GNUmakefile | 
|---|
|  | 109 | echo '  fi' >> GNUmakefile | 
|---|
|  | 110 | echo 'else' >> GNUmakefile | 
|---|
| [2437] | 111 | echo '  @echo "Variable SOPHYACXX must be define with setenv"' >> GNUmakefile | 
|---|
| [2424] | 112 | echo 'endif' >> GNUmakefile | 
|---|
|  | 113 | echo 'else' >> GNUmakefile | 
|---|
| [2437] | 114 | echo '  @echo "Variable SOPHYADEVREP must be define with setenv"' >> GNUmakefile | 
|---|
| [2424] | 115 | echo 'endif' >> GNUmakefile | 
|---|
|  | 116 | echo '#--------------------------------------------------------------------' >> GNUmakefile | 
|---|
|  | 117 | echo '' >> GNUmakefile | 
|---|
|  | 118 |  | 
|---|
| [751] | 119 | #  Attention, ne pas changer l'ordre de libnames dependances cxx  ????? | 
|---|
| [740] | 120 | set libnames = ($modules_pres $extmodules_pres) | 
|---|
| [218] | 121 | set i = 1 | 
|---|
|  | 122 | set j = $#libnames ; @ j-- | 
|---|
|  | 123 | while ($i <= $#libnames) | 
|---|
|  | 124 | set f = $libnames[$i] | 
|---|
|  | 125 | set k = $i ; @ k++ | 
|---|
| [1783] | 126 | if ( -d ../$f && ! -f ../$f/no_mkmf ) then | 
|---|
| [751] | 127 | set cmd = "./mkmflib $f " | 
|---|
| [218] | 128 | echo "mkmf: Creation makefile lib $f" | 
|---|
|  | 129 | echo "   execution $cmd" | 
|---|
| [740] | 130 | $DODBG $cmd | 
|---|
| [218] | 131 | endif | 
|---|
|  | 132 | echo '.PHONY: ' $f >> GNUmakefile | 
|---|
|  | 133 | echo $f':' >> GNUmakefile | 
|---|
|  | 134 | echo '        if [ -d '$f' ] ; then cd ' $f '; $(MAKE) ; fi' >> GNUmakefile | 
|---|
| [2424] | 135 | echo '' >> GNUmakefile | 
|---|
| [218] | 136 | @ i++ | 
|---|
|  | 137 | end | 
|---|
|  | 138 |  | 
|---|
|  | 139 |  | 
|---|
|  | 140 | if ( -d ../PI ) then | 
|---|
| [1603] | 141 | set cmd = './mkmfPI PI BaseTools' | 
|---|
| [218] | 142 | echo "mkmf: Creation makefile lib PI" | 
|---|
|  | 143 | echo "   execution $cmd" | 
|---|
| [740] | 144 | $DODBG  $cmd | 
|---|
| [218] | 145 | endif | 
|---|
| [1834] | 146 | if ( -d ../PIGcont ) then | 
|---|
|  | 147 | set cmd = './mkmfPI PIGcont BaseTools' | 
|---|
|  | 148 | echo "mkmf: Creation makefile lib PIGcont" | 
|---|
|  | 149 | echo "   execution $cmd" | 
|---|
|  | 150 | $DODBG  $cmd | 
|---|
|  | 151 | endif | 
|---|
| [218] | 152 | if ( -d ../PIext ) then | 
|---|
| [740] | 153 | set cmd = "./mkmfPI PIext $libnames PI" | 
|---|
| [218] | 154 | echo "mkmf: Creation makefile lib PIext" | 
|---|
|  | 155 | echo "   execution $cmd" | 
|---|
| [740] | 156 | $DODBG $cmd | 
|---|
| [218] | 157 | endif | 
|---|
|  | 158 | echo '.PHONY: PI' >> GNUmakefile | 
|---|
|  | 159 | echo 'PI:' >> GNUmakefile | 
|---|
|  | 160 | echo '  if [ -d PI ] ; then cd PI ; $(MAKE) ; fi' >> GNUmakefile | 
|---|
| [1834] | 161 | echo '  if [ -d PIGcont ] ; then cd PIGcont ; $(MAKE) ; fi' >> GNUmakefile | 
|---|
| [218] | 162 | echo '  if [ -d PIext ] ; then cd PIext ; $(MAKE) ; fi' >> GNUmakefile | 
|---|
|  | 163 |  | 
|---|
|  | 164 |  | 
|---|
| [751] | 165 | echo 'mkmf: Writing shared library building part of the makefile :' | 
|---|
| [1783] | 166 | if ( `uname` == "Darwin" ) then | 
|---|
|  | 167 | set sosfx = "dylib" | 
|---|
|  | 168 | else | 
|---|
|  | 169 | set sosfx = "so" | 
|---|
|  | 170 | endif | 
|---|
| [740] | 171 |  | 
|---|
|  | 172 | echo '#  Shared library creation part of the Makefile'       >> GNUmakefile | 
|---|
| [2424] | 173 | echo ''                                 >> GNUmakefile | 
|---|
| [740] | 174 | echo '#  List of libraries (.a)'         >> GNUmakefile | 
|---|
|  | 175 | echo 'PSLB = ' $module_libnames          >> GNUmakefile | 
|---|
|  | 176 | echo 'EXTPSLB = ' $extmodule_libnames    >> GNUmakefile | 
|---|
| [2424] | 177 | echo 'PIPSLB =  $(LIB)libPI.a $(LIB)libPIGcont.a $(LIB)libPIext.a'   >> GNUmakefile | 
|---|
| [740] | 178 | echo '#  List of external library references'       >> GNUmakefile | 
|---|
| [2424] | 179 | echo 'EXTLIBL  = -L$(EXTLIBPATH)' $extlib_list       >> GNUmakefile | 
|---|
|  | 180 | echo 'EXTSLBL  = -L$(EXTSLBPATH)' $extslb_list       >> GNUmakefile | 
|---|
|  | 181 | echo ''                                   >> GNUmakefile | 
|---|
|  | 182 | echo '# defining the other external libraries needed on different systems'   >> GNUmakefile | 
|---|
|  | 183 | echo ''                                   >> GNUmakefile | 
|---|
| [2560] | 184 | echo '# On Linux   lapack and blas and f2c/g2c are needed'   >> GNUmakefile | 
|---|
| [2424] | 185 | echo 'ifeq ($(MACHEROS),Linux)'   >> GNUmakefile | 
|---|
|  | 186 | echo '#EXTLIB = $(EXTLIBL) -llapack -lblas -lf2c'   >> GNUmakefile | 
|---|
|  | 187 | echo '#EXTSLB = $(EXTSLBL) -llapack -lblas -lf2c'   >> GNUmakefile | 
|---|
|  | 188 | echo 'EXTLIB = $(EXTLIBL) -llapack -lblas -lg2c'   >> GNUmakefile | 
|---|
|  | 189 | echo 'EXTSLB = $(EXTSLBL) -llapack -lblas -lg2c'   >> GNUmakefile | 
|---|
|  | 190 | echo 'endif'   >> GNUmakefile | 
|---|
| [2560] | 191 | echo '# On OSF1 libdxml contains part of Lapack, and the fortran support library is needed'   >> GNUmakefile | 
|---|
|  | 192 | echo '#  (we still need to add liblapack.a to supply missing lapack routines in dxml)'   >> GNUmakefile | 
|---|
| [2685] | 193 | echo '#  (some OSF dxml versions are not OK, please use  -lblas instead of  -ldxml)'   >> GNUmakefile | 
|---|
| [2424] | 194 | echo 'ifeq ($(MACHEROS),OSF1)'   >> GNUmakefile | 
|---|
| [2579] | 195 | echo 'EXTLIB = $(EXTLIBL) -llapack -ldxml -lfor'   >> GNUmakefile | 
|---|
| [2573] | 196 | echo '###EXTLIB = $(EXTLIBL) -llapack -lblas -lfor'   >> GNUmakefile | 
|---|
| [2579] | 197 | echo 'EXTSLB = $(EXTSLBL) -llapack -ldxml -lfor'   >> GNUmakefile | 
|---|
| [2573] | 198 | echo '###EXTSLB = $(EXTSLBL) -llapack -lblas -lfor'   >> GNUmakefile | 
|---|
| [2424] | 199 | echo 'endif'   >> GNUmakefile | 
|---|
|  | 200 | echo ''                                   >> GNUmakefile | 
|---|
|  | 201 | echo '# On IRIX , complib.sgimath contains Lapack'   >> GNUmakefile | 
|---|
|  | 202 | echo 'ifeq ($(MACHEROS),IRIX64)'   >> GNUmakefile | 
|---|
|  | 203 | echo 'EXTLIB = $(EXTLIBL) -lcomplib.sgimath '   >> GNUmakefile | 
|---|
|  | 204 | echo 'EXTSLB = $(EXTSLBL) -lcomplib.sgimath '   >> GNUmakefile | 
|---|
|  | 205 | echo 'endif'   >> GNUmakefile | 
|---|
|  | 206 | echo ''                                   >> GNUmakefile | 
|---|
| [740] | 207 | echo 'XPILIBS = $(LIBXPIPATH) $(LIBXPILIST)'        >> GNUmakefile | 
|---|
| [1783] | 208 | echo ''                                   >> GNUmakefile | 
|---|
|  | 209 | echo '#  main dependence list'            >> GNUmakefile | 
|---|
|  | 210 | echo 'slball : slb slbext slbpi '         >> GNUmakefile | 
|---|
|  | 211 | echo 'slb : $(SLB)libsophya.'$sosfx       >> GNUmakefile | 
|---|
|  | 212 | echo 'slbext : $(SLB)libextsophya.'$sosfx >> GNUmakefile | 
|---|
|  | 213 | echo 'slbpi : $(SLB)libPI.'$sosfx         >> GNUmakefile | 
|---|
| [2424] | 214 | echo ''                                  >> GNUmakefile | 
|---|
| [740] | 215 |  | 
|---|
|  | 216 | echo '# List of .o files for each module'  >> GNUmakefile | 
|---|
|  | 217 | set objalls =  '' | 
|---|
|  | 218 | foreach f ($modules_pres) | 
|---|
|  | 219 | echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)'  >> GNUmakefile | 
|---|
|  | 220 | set objalls = ( $objalls '$(OBJ'$f')' ) | 
|---|
|  | 221 | end | 
|---|
|  | 222 | echo 'ALLOBJS =' $objalls                >> GNUmakefile | 
|---|
| [2424] | 223 | echo ''                                 >> GNUmakefile | 
|---|
| [740] | 224 |  | 
|---|
|  | 225 | echo '# List of .o files modules with reference to external libraries'  >> GNUmakefile | 
|---|
|  | 226 | set objalls =  '' | 
|---|
|  | 227 | foreach f ($extmodules_pres) | 
|---|
|  | 228 | echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)'  >> GNUmakefile | 
|---|
|  | 229 | set objalls = ( $objalls '$(OBJ'$f')' ) | 
|---|
|  | 230 | end | 
|---|
|  | 231 | echo 'ALLEXTOBJS =' $objalls             >> GNUmakefile | 
|---|
| [2424] | 232 | echo ''                                 >> GNUmakefile | 
|---|
| [740] | 233 |  | 
|---|
|  | 234 | echo '# List of .o files for PI modules '  >> GNUmakefile | 
|---|
|  | 235 | set objalls =  '' | 
|---|
| [1834] | 236 | foreach f (PI PIGcont PIext) | 
|---|
| [740] | 237 | echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)'  >> GNUmakefile | 
|---|
|  | 238 | set objalls = ( $objalls '$(OBJ'$f')' ) | 
|---|
|  | 239 | end | 
|---|
|  | 240 | echo 'ALLPIOBJS =' $objalls              >> GNUmakefile | 
|---|
| [2424] | 241 | echo ''                                 >> GNUmakefile | 
|---|
| [740] | 242 |  | 
|---|
|  | 243 | echo '# Building Sophya shared library'  >> GNUmakefile | 
|---|
| [1783] | 244 | echo '$(SLB)libsophya.'$sosfx' : $(PSLB)'                       >> GNUmakefile | 
|---|
| [740] | 245 | echo '  $(CMDTILSHL) '                                          >> GNUmakefile | 
|---|
|  | 246 | echo '  cd  $(OBJ); \'                                          >> GNUmakefile | 
|---|
| [1783] | 247 | echo '  $(CMDSHLCXX) -o $(SLB)libsophya.'$sosfx'  \'            >> GNUmakefile | 
|---|
| [740] | 248 | echo '  $(FGSHLACXX) $(ALLOBJS)  $(FGSHLNCXX)\'                 >> GNUmakefile | 
|---|
|  | 249 | echo '  -L$(SLB) $(LIBLSHL)'                                    >> GNUmakefile | 
|---|
| [2424] | 250 | echo ''                                                        >> GNUmakefile | 
|---|
| [740] | 251 |  | 
|---|
|  | 252 | echo '# Building ExtSophya shared library'  >> GNUmakefile | 
|---|
| [1783] | 253 | echo '$(SLB)libextsophya.'$sosfx' : $(EXTPSLB)'                 >> GNUmakefile | 
|---|
| [740] | 254 | echo '  $(CMDTILSHL) '                                          >> GNUmakefile | 
|---|
|  | 255 | echo '  cd  $(OBJ); \'                                          >> GNUmakefile | 
|---|
| [1783] | 256 | echo '  $(CMDSHLCXX) -o $(SLB)libextsophya.'$sosfx'  \'         >> GNUmakefile | 
|---|
| [740] | 257 | echo '  $(FGSHLACXX) $(ALLEXTOBJS)  $(FGSHLNCXX)\'              >> GNUmakefile | 
|---|
| [751] | 258 | echo '  -L$(SLB) -lsophya $(EXTLIB) $(LIBLSHL)'                 >> GNUmakefile | 
|---|
| [2424] | 259 | echo ''                                                        >> GNUmakefile | 
|---|
| [740] | 260 |  | 
|---|
|  | 261 | echo '# Building PI shared library'  >> GNUmakefile | 
|---|
| [1783] | 262 | echo '$(SLB)libPI.'$sosfx' : $(PIPSLB)'                         >> GNUmakefile | 
|---|
| [740] | 263 | echo '  $(CMDTILSHL) '                                          >> GNUmakefile | 
|---|
|  | 264 | echo '  cd  $(OBJ); \'                                          >> GNUmakefile | 
|---|
| [1783] | 265 | echo '  $(CMDSHLCXX) -o $(SLB)libPI.'$sosfx'  \'                >> GNUmakefile | 
|---|
| [751] | 266 | echo '  $(FGSHLACXX) $(ALLPIOBJS) $(FGSHLNCXX) \'               >> GNUmakefile | 
|---|
|  | 267 | echo '  -L$(SLB) -lsophya -lextsophya $(EXTLIB) $(XPILIBS) $(LIBLSHL)'      >> GNUmakefile | 
|---|
| [2424] | 268 | echo ''                                                        >> GNUmakefile | 
|---|
| [740] | 269 |  | 
|---|
|  | 270 |  | 
|---|
| [218] | 271 | cat >> GNUmakefile << __END__ | 
|---|
|  | 272 |  | 
|---|
|  | 273 | clean: | 
|---|
|  | 274 | if [ -d \$(LIB) ] ; then cd \$(LIB)/. ; rm -f *.a  ; fi | 
|---|
| [1783] | 275 | if [ -d \$(SLB) ] ; then cd \$(SLB)/. ; rm -f *.$sosfx ; fi | 
|---|
| [740] | 276 | if [ -d \$(OBJ) ] ; then cd \$(OBJ)/. ; rm -f *.o  rm -rf cxxrep* ; fi | 
|---|
|  | 277 | #       if [ -d PI ]     ; then cd PI/.     ; \$(MAKE) clean ; fi | 
|---|
| [218] | 278 |  | 
|---|
|  | 279 | __END__ | 
|---|
|  | 280 |  | 
|---|
|  | 281 | mv GNUmakefile ../GNUmakefile | 
|---|
|  | 282 |  | 
|---|
|  | 283 | echo '*** mkmf done ***' | 
|---|
|  | 284 |  | 
|---|