| 1 | #!/bin/csh 
 | 
|---|
| 2 | # $Id: mkmf,v 1.18 2003-08-28 14:26:09 cmv Exp $
 | 
|---|
| 3 | 
 | 
|---|
| 4 | #  Pour debugger 
 | 
|---|
| 5 | set DODBG = 'echo'
 | 
|---|
| 6 | set DODBG = ''
 | 
|---|
| 7 | 
 | 
|---|
| 8 | # Librairies externe
 | 
|---|
| 9 | if( ! $?EXTLIBDIR ) then
 | 
|---|
| 10 |   echo 'mkmf- WARNING (External libraries) EXTLIBDIR variable not set'
 | 
|---|
| 11 | endif
 | 
|---|
| 12 | 
 | 
|---|
| 13 | # creation de MakefileUser.h a partir de Makefile.h
 | 
|---|
| 14 | chmod +x ./makefileuser.csh
 | 
|---|
| 15 | $DODBG ./makefileuser.csh
 | 
|---|
| 16 | 
 | 
|---|
| 17 | # creation des liens pour les includes
 | 
|---|
| 18 | echo 'mkmf: Creating links for *.h (call mkmflien)'
 | 
|---|
| 19 | chmod +x ./mkmflien
 | 
|---|
| 20 | $DODBG ./mkmflien -clean
 | 
|---|
| 21 | 
 | 
|---|
| 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 | 
 | 
|---|
| 60 | echo 'mkmf: Creating makefile global :'
 | 
|---|
| 61 | rm -f GNUmakefile; touch GNUmakefile
 | 
|---|
| 62 | 
 | 
|---|
| 63 | echo '# include files defining compiler/linker options '  >> GNUmakefile
 | 
|---|
| 64 | echo 'MODULECXXREPNAME := PI'  >> GNUmakefile
 | 
|---|
| 65 | echo 'include Mgr/Makefile.h' >> GNUmakefile
 | 
|---|
| 66 | echo 'include Mgr/Makefile.slb' >> GNUmakefile
 | 
|---|
| 67 | echo ''   >> GNUmakefile
 | 
|---|
| 68 | 
 | 
|---|
| 69 | echo 'LIBF = ' `sed -e 's/.*/$(LIB)lib&.a/' libdirs` >> GNUmakefile
 | 
|---|
| 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
 | 
|---|
| 76 | 
 | 
|---|
| 77 | cat >> GNUmakefile <<EOF
 | 
|---|
| 78 | 
 | 
|---|
| 79 | defaut: libs
 | 
|---|
| 80 | 
 | 
|---|
| 81 | all: libs extlibs PI
 | 
|---|
| 82 | 
 | 
|---|
| 83 | libs: cxxlibs
 | 
|---|
| 84 | 
 | 
|---|
| 85 | extlibs: cxxextlibs
 | 
|---|
| 86 | 
 | 
|---|
| 87 | EOF
 | 
|---|
| 88 | 
 | 
|---|
| 89 | # Dans cet ordre pour les templates de cxx, a cause des dependances
 | 
|---|
| 90 | # pour instantiation automatique/manuels
 | 
|---|
| 91 | 
 | 
|---|
| 92 | echo 'cxxlibs: ' $modules_pres >>    GNUmakefile
 | 
|---|
| 93 | echo '' >> GNUmakefile 
 | 
|---|
| 94 | echo 'cxxextlibs: ' $extmodules_pres >> GNUmakefile
 | 
|---|
| 95 | 
 | 
|---|
| 96 | # pour creer les repertoires et les liens
 | 
|---|
| 97 | 
 | 
|---|
| 98 | echo '#--- Create directory and copy includes for install' >> GNUmakefile
 | 
|---|
| 99 | echo 'depend:' >> GNUmakefile
 | 
|---|
| 100 | echo 'ifdef DPCDEVREP' >> GNUmakefile
 | 
|---|
| 101 | echo 'ifdef EROSCXX' >> GNUmakefile
 | 
|---|
| 102 | echo '  @echo "Sophya will be installed under:"' >> GNUmakefile
 | 
|---|
| 103 | echo '  @echo "  $(DPCDEVREP)/Include" ' >> GNUmakefile
 | 
|---|
| 104 | echo '  @echo "  $(DPCDEVREP)/`uname`-$(EROSCXX)" ' >> GNUmakefile
 | 
|---|
| 105 | echo '  if [ -d Mgr ] ; then cd Mgr; \' >> GNUmakefile
 | 
|---|
| 106 | echo '  ./crerep_sophya $(DPCDEVREP) `uname`-$(EROSCXX); \' >> GNUmakefile
 | 
|---|
| 107 | echo '  ./makefileuser.csh; \' >> GNUmakefile
 | 
|---|
| 108 | echo '  ./mkmflien -copy ; \' >> GNUmakefile
 | 
|---|
| 109 | echo '  fi' >> GNUmakefile
 | 
|---|
| 110 | echo 'else' >> GNUmakefile
 | 
|---|
| 111 | echo '  @echo "Variable EROSCXX must be define with setenv"' >> GNUmakefile
 | 
|---|
| 112 | echo 'endif' >> GNUmakefile
 | 
|---|
| 113 | echo 'else' >> GNUmakefile
 | 
|---|
| 114 | echo '  @echo "Variable DPCDEVREP must be define with setenv"' >> GNUmakefile
 | 
|---|
| 115 | echo 'endif' >> GNUmakefile
 | 
|---|
| 116 | echo '#--------------------------------------------------------------------' >> GNUmakefile
 | 
|---|
| 117 | echo '' >> GNUmakefile
 | 
|---|
| 118 | 
 | 
|---|
| 119 | #  Attention, ne pas changer l'ordre de libnames dependances cxx  ????? 
 | 
|---|
| 120 | set libnames = ($modules_pres $extmodules_pres)
 | 
|---|
| 121 | set i = 1
 | 
|---|
| 122 | set j = $#libnames ; @ j--
 | 
|---|
| 123 | while ($i <= $#libnames)
 | 
|---|
| 124 |   set f = $libnames[$i]
 | 
|---|
| 125 |   set k = $i ; @ k++
 | 
|---|
| 126 |   if ( -d ../$f && ! -f ../$f/no_mkmf ) then 
 | 
|---|
| 127 |     set cmd = "./mkmflib $f "
 | 
|---|
| 128 |     echo "mkmf: Creation makefile lib $f"
 | 
|---|
| 129 |     echo "   execution $cmd"
 | 
|---|
| 130 |     $DODBG $cmd
 | 
|---|
| 131 |   endif
 | 
|---|
| 132 |   echo '.PHONY: ' $f >> GNUmakefile
 | 
|---|
| 133 |   echo $f':' >> GNUmakefile
 | 
|---|
| 134 |   echo '        if [ -d '$f' ] ; then cd ' $f '; $(MAKE) ; fi' >> GNUmakefile
 | 
|---|
| 135 |   echo '' >> GNUmakefile
 | 
|---|
| 136 |   @ i++
 | 
|---|
| 137 | end
 | 
|---|
| 138 | 
 | 
|---|
| 139 | 
 | 
|---|
| 140 | if ( -d ../PI ) then 
 | 
|---|
| 141 |   set cmd = './mkmfPI PI BaseTools'
 | 
|---|
| 142 |   echo "mkmf: Creation makefile lib PI"
 | 
|---|
| 143 |   echo "   execution $cmd"
 | 
|---|
| 144 |   $DODBG  $cmd
 | 
|---|
| 145 | endif
 | 
|---|
| 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
 | 
|---|
| 152 | if ( -d ../PIext ) then 
 | 
|---|
| 153 |   set cmd = "./mkmfPI PIext $libnames PI"
 | 
|---|
| 154 |   echo "mkmf: Creation makefile lib PIext"
 | 
|---|
| 155 |   echo "   execution $cmd"
 | 
|---|
| 156 |   $DODBG $cmd
 | 
|---|
| 157 | endif
 | 
|---|
| 158 | echo '.PHONY: PI' >> GNUmakefile
 | 
|---|
| 159 | echo 'PI:' >> GNUmakefile
 | 
|---|
| 160 | echo '  if [ -d PI ] ; then cd PI ; $(MAKE) ; fi' >> GNUmakefile
 | 
|---|
| 161 | echo '  if [ -d PIGcont ] ; then cd PIGcont ; $(MAKE) ; fi' >> GNUmakefile
 | 
|---|
| 162 | echo '  if [ -d PIext ] ; then cd PIext ; $(MAKE) ; fi' >> GNUmakefile
 | 
|---|
| 163 | 
 | 
|---|
| 164 | 
 | 
|---|
| 165 | echo 'mkmf: Writing shared library building part of the makefile :'
 | 
|---|
| 166 | if ( `uname` == "Darwin" ) then
 | 
|---|
| 167 |   set sosfx = "dylib"
 | 
|---|
| 168 | else
 | 
|---|
| 169 |   set sosfx = "so"
 | 
|---|
| 170 | endif
 | 
|---|
| 171 | 
 | 
|---|
| 172 | echo '#  Shared library creation part of the Makefile'       >> GNUmakefile
 | 
|---|
| 173 | echo ''                                 >> GNUmakefile
 | 
|---|
| 174 | echo '#  List of libraries (.a)'         >> GNUmakefile
 | 
|---|
| 175 | echo 'PSLB = ' $module_libnames          >> GNUmakefile
 | 
|---|
| 176 | echo 'EXTPSLB = ' $extmodule_libnames    >> GNUmakefile
 | 
|---|
| 177 | echo 'PIPSLB =  $(LIB)libPI.a $(LIB)libPIGcont.a $(LIB)libPIext.a'   >> GNUmakefile
 | 
|---|
| 178 | echo '#  List of external library references'       >> GNUmakefile
 | 
|---|
| 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
 | 
|---|
| 184 | echo '# On Linux   lapack and blas and f2c/g2c ere needed'   >> GNUmakefile
 | 
|---|
| 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
 | 
|---|
| 191 | echo '# On OSF1 libdxml contains Lapack, but the fortran support library is needed'   >> GNUmakefile
 | 
|---|
| 192 | echo 'ifeq ($(MACHEROS),OSF1)'   >> GNUmakefile
 | 
|---|
| 193 | echo 'EXTLIB = $(EXTLIBL) -ldxml -lfor'   >> GNUmakefile
 | 
|---|
| 194 | echo 'EXTSLB = $(EXTSLBL) -ldxml -lfor'   >> GNUmakefile
 | 
|---|
| 195 | echo 'endif'   >> GNUmakefile
 | 
|---|
| 196 | echo ''                                   >> GNUmakefile
 | 
|---|
| 197 | echo '# On IRIX , complib.sgimath contains Lapack'   >> GNUmakefile
 | 
|---|
| 198 | echo 'ifeq ($(MACHEROS),IRIX64)'   >> GNUmakefile
 | 
|---|
| 199 | echo 'EXTLIB = $(EXTLIBL) -lcomplib.sgimath '   >> GNUmakefile
 | 
|---|
| 200 | echo 'EXTSLB = $(EXTSLBL) -lcomplib.sgimath '   >> GNUmakefile
 | 
|---|
| 201 | echo 'endif'   >> GNUmakefile
 | 
|---|
| 202 | echo ''                                   >> GNUmakefile
 | 
|---|
| 203 | echo 'XPILIBS = $(LIBXPIPATH) $(LIBXPILIST)'        >> GNUmakefile
 | 
|---|
| 204 | echo ''                                   >> GNUmakefile
 | 
|---|
| 205 | echo '#  main dependence list'            >> GNUmakefile
 | 
|---|
| 206 | echo 'slball : slb slbext slbpi '         >> GNUmakefile
 | 
|---|
| 207 | echo 'slb : $(SLB)libsophya.'$sosfx       >> GNUmakefile
 | 
|---|
| 208 | echo 'slbext : $(SLB)libextsophya.'$sosfx >> GNUmakefile
 | 
|---|
| 209 | echo 'slbpi : $(SLB)libPI.'$sosfx         >> GNUmakefile
 | 
|---|
| 210 | echo ''                                  >> GNUmakefile
 | 
|---|
| 211 | 
 | 
|---|
| 212 | echo '# List of .o files for each module'  >> GNUmakefile
 | 
|---|
| 213 | set objalls =  ''
 | 
|---|
| 214 | foreach f ($modules_pres)
 | 
|---|
| 215 |   echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)'  >> GNUmakefile
 | 
|---|
| 216 |   set objalls = ( $objalls '$(OBJ'$f')' )
 | 
|---|
| 217 | end
 | 
|---|
| 218 | echo 'ALLOBJS =' $objalls                >> GNUmakefile
 | 
|---|
| 219 | echo ''                                 >> GNUmakefile
 | 
|---|
| 220 | 
 | 
|---|
| 221 | echo '# List of .o files modules with reference to external libraries'  >> GNUmakefile
 | 
|---|
| 222 | set objalls =  ''
 | 
|---|
| 223 | foreach f ($extmodules_pres)
 | 
|---|
| 224 |   echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)'  >> GNUmakefile
 | 
|---|
| 225 |   set objalls = ( $objalls '$(OBJ'$f')' )
 | 
|---|
| 226 | end
 | 
|---|
| 227 | echo 'ALLEXTOBJS =' $objalls             >> GNUmakefile
 | 
|---|
| 228 | echo ''                                 >> GNUmakefile
 | 
|---|
| 229 | 
 | 
|---|
| 230 | echo '# List of .o files for PI modules '  >> GNUmakefile
 | 
|---|
| 231 | set objalls =  ''
 | 
|---|
| 232 | foreach f (PI PIGcont PIext)
 | 
|---|
| 233 |   echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)'  >> GNUmakefile
 | 
|---|
| 234 |   set objalls = ( $objalls '$(OBJ'$f')' )
 | 
|---|
| 235 | end
 | 
|---|
| 236 | echo 'ALLPIOBJS =' $objalls              >> GNUmakefile
 | 
|---|
| 237 | echo ''                                 >> GNUmakefile
 | 
|---|
| 238 | 
 | 
|---|
| 239 | echo '# Building Sophya shared library'  >> GNUmakefile
 | 
|---|
| 240 | echo '$(SLB)libsophya.'$sosfx' : $(PSLB)'                       >> GNUmakefile
 | 
|---|
| 241 | echo '  $(CMDTILSHL) '                                          >> GNUmakefile
 | 
|---|
| 242 | echo '  cd  $(OBJ); \'                                          >> GNUmakefile
 | 
|---|
| 243 | echo '  $(CMDSHLCXX) -o $(SLB)libsophya.'$sosfx'  \'            >> GNUmakefile
 | 
|---|
| 244 | echo '  $(FGSHLACXX) $(ALLOBJS)  $(FGSHLNCXX)\'                 >> GNUmakefile
 | 
|---|
| 245 | echo '  -L$(SLB) $(LIBLSHL)'                                    >> GNUmakefile
 | 
|---|
| 246 | echo ''                                                        >> GNUmakefile
 | 
|---|
| 247 | 
 | 
|---|
| 248 | echo '# Building ExtSophya shared library'  >> GNUmakefile
 | 
|---|
| 249 | echo '$(SLB)libextsophya.'$sosfx' : $(EXTPSLB)'                 >> GNUmakefile
 | 
|---|
| 250 | echo '  $(CMDTILSHL) '                                          >> GNUmakefile
 | 
|---|
| 251 | echo '  cd  $(OBJ); \'                                          >> GNUmakefile
 | 
|---|
| 252 | echo '  $(CMDSHLCXX) -o $(SLB)libextsophya.'$sosfx'  \'         >> GNUmakefile
 | 
|---|
| 253 | echo '  $(FGSHLACXX) $(ALLEXTOBJS)  $(FGSHLNCXX)\'              >> GNUmakefile
 | 
|---|
| 254 | echo '  -L$(SLB) -lsophya $(EXTLIB) $(LIBLSHL)'                 >> GNUmakefile
 | 
|---|
| 255 | echo ''                                                        >> GNUmakefile
 | 
|---|
| 256 | 
 | 
|---|
| 257 | echo '# Building PI shared library'  >> GNUmakefile
 | 
|---|
| 258 | echo '$(SLB)libPI.'$sosfx' : $(PIPSLB)'                         >> GNUmakefile
 | 
|---|
| 259 | echo '  $(CMDTILSHL) '                                          >> GNUmakefile
 | 
|---|
| 260 | echo '  cd  $(OBJ); \'                                          >> GNUmakefile
 | 
|---|
| 261 | echo '  $(CMDSHLCXX) -o $(SLB)libPI.'$sosfx'  \'                >> GNUmakefile
 | 
|---|
| 262 | echo '  $(FGSHLACXX) $(ALLPIOBJS) $(FGSHLNCXX) \'               >> GNUmakefile
 | 
|---|
| 263 | echo '  -L$(SLB) -lsophya -lextsophya $(EXTLIB) $(XPILIBS) $(LIBLSHL)'      >> GNUmakefile
 | 
|---|
| 264 | echo ''                                                        >> GNUmakefile
 | 
|---|
| 265 | 
 | 
|---|
| 266 | 
 | 
|---|
| 267 | cat >> GNUmakefile << __END__
 | 
|---|
| 268 | 
 | 
|---|
| 269 | clean:
 | 
|---|
| 270 |         if [ -d \$(LIB) ] ; then cd \$(LIB)/. ; rm -f *.a  ; fi
 | 
|---|
| 271 |         if [ -d \$(SLB) ] ; then cd \$(SLB)/. ; rm -f *.$sosfx ; fi
 | 
|---|
| 272 |         if [ -d \$(OBJ) ] ; then cd \$(OBJ)/. ; rm -f *.o  rm -rf cxxrep* ; fi
 | 
|---|
| 273 | #       if [ -d PI ]     ; then cd PI/.     ; \$(MAKE) clean ; fi
 | 
|---|
| 274 | 
 | 
|---|
| 275 | __END__
 | 
|---|
| 276 | 
 | 
|---|
| 277 | mv GNUmakefile ../GNUmakefile
 | 
|---|
| 278 | 
 | 
|---|
| 279 | echo '*** mkmf done ***'
 | 
|---|
| 280 | 
 | 
|---|