| [218] | 1 | #!/bin/csh 
 | 
|---|
| [968] | 2 | # $Id: mkmf,v 1.12 2000-04-21 16:32:48 ansari 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
 | 
|---|
| [740] | 20 | $DODBG ./mkmflien
 | 
|---|
| [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 :'
 | 
|---|
| [218] | 61 | rm -f GNUmakefile
 | 
|---|
 | 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
 | 
|---|
 | 93 | echo ' ' >> GNUmakefile 
 | 
|---|
 | 94 | echo 'cxxextlibs: ' $extmodules_pres >> GNUmakefile
 | 
|---|
| [218] | 95 | 
 | 
|---|
 | 96 | 
 | 
|---|
| [751] | 97 | #  Attention, ne pas changer l'ordre de libnames dependances cxx  ????? 
 | 
|---|
| [740] | 98 | set libnames = ($modules_pres $extmodules_pres)
 | 
|---|
| [218] | 99 | set i = 1
 | 
|---|
 | 100 | set j = $#libnames ; @ j--
 | 
|---|
 | 101 | while ($i <= $#libnames)
 | 
|---|
 | 102 |   set f = $libnames[$i]
 | 
|---|
 | 103 |   set k = $i ; @ k++
 | 
|---|
 | 104 |   if ( -d ../$f ) then 
 | 
|---|
| [751] | 105 |     set cmd = "./mkmflib $f "
 | 
|---|
| [218] | 106 |     echo "mkmf: Creation makefile lib $f"
 | 
|---|
 | 107 |     echo "   execution $cmd"
 | 
|---|
| [740] | 108 |     $DODBG $cmd
 | 
|---|
| [218] | 109 |   endif
 | 
|---|
 | 110 |   echo '.PHONY: ' $f >> GNUmakefile
 | 
|---|
 | 111 |   echo $f':' >> GNUmakefile
 | 
|---|
 | 112 |   echo '        if [ -d '$f' ] ; then cd ' $f '; $(MAKE) ; fi' >> GNUmakefile
 | 
|---|
 | 113 |   echo ' ' >> GNUmakefile
 | 
|---|
 | 114 |   @ i++
 | 
|---|
 | 115 | end
 | 
|---|
 | 116 | 
 | 
|---|
 | 117 | 
 | 
|---|
 | 118 | if ( -d ../PI ) then 
 | 
|---|
 | 119 |   set cmd = './mkmfPI PI SysTools'
 | 
|---|
 | 120 |   echo "mkmf: Creation makefile lib PI"
 | 
|---|
 | 121 |   echo "   execution $cmd"
 | 
|---|
| [740] | 122 |   $DODBG  $cmd
 | 
|---|
| [218] | 123 | endif
 | 
|---|
 | 124 | if ( -d ../PIext ) then 
 | 
|---|
| [740] | 125 |   set cmd = "./mkmfPI PIext $libnames PI"
 | 
|---|
| [218] | 126 |   echo "mkmf: Creation makefile lib PIext"
 | 
|---|
 | 127 |   echo "   execution $cmd"
 | 
|---|
| [740] | 128 |   $DODBG $cmd
 | 
|---|
| [218] | 129 | endif
 | 
|---|
 | 130 | echo '.PHONY: PI' >> GNUmakefile
 | 
|---|
 | 131 | echo 'PI:' >> GNUmakefile
 | 
|---|
 | 132 | echo '  if [ -d PI ] ; then cd PI ; $(MAKE) ; fi' >> GNUmakefile
 | 
|---|
 | 133 | echo '  if [ -d PIext ] ; then cd PIext ; $(MAKE) ; fi' >> GNUmakefile
 | 
|---|
 | 134 | 
 | 
|---|
 | 135 | 
 | 
|---|
| [751] | 136 | echo 'mkmf: Writing shared library building part of the makefile :'
 | 
|---|
| [740] | 137 | 
 | 
|---|
 | 138 | echo '#  Shared library creation part of the Makefile'       >> GNUmakefile
 | 
|---|
 | 139 | echo ' '                                 >> GNUmakefile
 | 
|---|
 | 140 | echo '#  List of libraries (.a)'         >> GNUmakefile
 | 
|---|
 | 141 | echo 'PSLB = ' $module_libnames          >> GNUmakefile
 | 
|---|
 | 142 | echo 'EXTPSLB = ' $extmodule_libnames    >> GNUmakefile
 | 
|---|
 | 143 | echo 'PIPSLB =  $(LIB)libPI.a  $(LIB)libPIext.a'   >> GNUmakefile
 | 
|---|
 | 144 | echo '#  List of external library references'       >> GNUmakefile
 | 
|---|
 | 145 | echo 'EXTLIB  = -L$(EXTLIBPATH)' $extlib_list       >> GNUmakefile
 | 
|---|
| [751] | 146 | echo 'EXTSLB  = -L$(EXTSLBPATH)' $extslb_list       >> GNUmakefile
 | 
|---|
| [740] | 147 | echo 'XPILIBS = $(LIBXPIPATH) $(LIBXPILIST)'        >> GNUmakefile
 | 
|---|
 | 148 | echo ''                                  >> GNUmakefile
 | 
|---|
 | 149 | echo '#  main dependence list'           >> GNUmakefile
 | 
|---|
 | 150 | echo 'slball : slb slbext slbpi '        >> GNUmakefile
 | 
|---|
 | 151 | echo 'slb : $(SLB)libsophya.so '         >> GNUmakefile
 | 
|---|
 | 152 | echo 'slbext : $(SLB)libextsophya.so   ' >> GNUmakefile
 | 
|---|
 | 153 | echo 'slbpi : $(SLB)libPI.so'            >> GNUmakefile
 | 
|---|
 | 154 | echo ' '                                 >> GNUmakefile
 | 
|---|
 | 155 | 
 | 
|---|
 | 156 | echo '# List of .o files for each module'  >> GNUmakefile
 | 
|---|
 | 157 | set objalls =  ''
 | 
|---|
 | 158 | foreach f ($modules_pres)
 | 
|---|
 | 159 |   echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)'  >> GNUmakefile
 | 
|---|
 | 160 |   set objalls = ( $objalls '$(OBJ'$f')' )
 | 
|---|
 | 161 | end
 | 
|---|
 | 162 | echo 'ALLOBJS =' $objalls                >> GNUmakefile
 | 
|---|
 | 163 | echo ' '                                 >> GNUmakefile
 | 
|---|
 | 164 | 
 | 
|---|
 | 165 | echo '# List of .o files modules with reference to external libraries'  >> GNUmakefile
 | 
|---|
 | 166 | set objalls =  ''
 | 
|---|
 | 167 | foreach f ($extmodules_pres)
 | 
|---|
 | 168 |   echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)'  >> GNUmakefile
 | 
|---|
 | 169 |   set objalls = ( $objalls '$(OBJ'$f')' )
 | 
|---|
 | 170 | end
 | 
|---|
 | 171 | echo 'ALLEXTOBJS =' $objalls             >> GNUmakefile
 | 
|---|
 | 172 | echo ' '                                 >> GNUmakefile
 | 
|---|
 | 173 | 
 | 
|---|
 | 174 | echo '# List of .o files for PI modules '  >> GNUmakefile
 | 
|---|
 | 175 | set objalls =  ''
 | 
|---|
 | 176 | foreach f (PI PIext)
 | 
|---|
 | 177 |   echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)'  >> GNUmakefile
 | 
|---|
 | 178 |   set objalls = ( $objalls '$(OBJ'$f')' )
 | 
|---|
 | 179 | end
 | 
|---|
 | 180 | echo 'ALLPIOBJS =' $objalls              >> GNUmakefile
 | 
|---|
 | 181 | echo ' '                                 >> GNUmakefile
 | 
|---|
 | 182 | 
 | 
|---|
 | 183 | echo '# Building Sophya shared library'  >> GNUmakefile
 | 
|---|
 | 184 | echo '$(SLB)libsophya.so : $(PSLB)'                             >> GNUmakefile
 | 
|---|
 | 185 | echo '  $(CMDTILSHL) '                                          >> GNUmakefile
 | 
|---|
 | 186 | echo '  cd  $(OBJ); \'                                          >> GNUmakefile
 | 
|---|
 | 187 | echo '  $(CMDSHLCXX) -o $(SLB)libsophya.so  \'                  >> GNUmakefile
 | 
|---|
 | 188 | echo '  $(FGSHLACXX) $(ALLOBJS)  $(FGSHLNCXX)\'                 >> GNUmakefile
 | 
|---|
 | 189 | echo '  -L$(SLB) $(LIBLSHL)'                                    >> GNUmakefile
 | 
|---|
 | 190 | echo ' '                                                        >> GNUmakefile
 | 
|---|
 | 191 | 
 | 
|---|
 | 192 | echo '# Building ExtSophya shared library'  >> GNUmakefile
 | 
|---|
 | 193 | echo '$(SLB)libextsophya.so : $(EXTPSLB)'                       >> GNUmakefile
 | 
|---|
 | 194 | echo '  $(CMDTILSHL) '                                          >> GNUmakefile
 | 
|---|
 | 195 | echo '  cd  $(OBJ); \'                                          >> GNUmakefile
 | 
|---|
 | 196 | echo '  $(CMDSHLCXX) -o $(SLB)libextsophya.so  \'               >> GNUmakefile
 | 
|---|
 | 197 | echo '  $(FGSHLACXX) $(ALLEXTOBJS)  $(FGSHLNCXX)\'              >> GNUmakefile
 | 
|---|
| [751] | 198 | echo '  -L$(SLB) -lsophya $(EXTLIB) $(LIBLSHL)'                 >> GNUmakefile
 | 
|---|
| [740] | 199 | echo ' '                                                        >> GNUmakefile
 | 
|---|
 | 200 | 
 | 
|---|
 | 201 | echo '# Building PI shared library'  >> GNUmakefile
 | 
|---|
 | 202 | echo '$(SLB)libPI.so : $(PIPSLB)'                               >> GNUmakefile
 | 
|---|
 | 203 | echo '  $(CMDTILSHL) '                                          >> GNUmakefile
 | 
|---|
 | 204 | echo '  cd  $(OBJ); \'                                          >> GNUmakefile
 | 
|---|
 | 205 | echo '  $(CMDSHLCXX) -o $(SLB)libPI.so  \'                      >> GNUmakefile
 | 
|---|
| [751] | 206 | echo '  $(FGSHLACXX) $(ALLPIOBJS) $(FGSHLNCXX) \'               >> GNUmakefile
 | 
|---|
 | 207 | echo '  -L$(SLB) -lsophya -lextsophya $(EXTLIB) $(XPILIBS) $(LIBLSHL)'      >> GNUmakefile
 | 
|---|
| [740] | 208 | echo ' '                                                        >> GNUmakefile
 | 
|---|
 | 209 | 
 | 
|---|
 | 210 | 
 | 
|---|
| [218] | 211 | cat >> GNUmakefile << __END__
 | 
|---|
 | 212 | 
 | 
|---|
 | 213 | clean:
 | 
|---|
 | 214 |         if [ -d \$(LIB) ] ; then cd \$(LIB)/. ; rm -f *.a  ; fi
 | 
|---|
 | 215 |         if [ -d \$(SLB) ] ; then cd \$(SLB)/. ; rm -f *.so ; fi
 | 
|---|
| [740] | 216 |         if [ -d \$(OBJ) ] ; then cd \$(OBJ)/. ; rm -f *.o  rm -rf cxxrep* ; fi
 | 
|---|
 | 217 | #       if [ -d PI ]     ; then cd PI/.     ; \$(MAKE) clean ; fi
 | 
|---|
| [218] | 218 | 
 | 
|---|
 | 219 | __END__
 | 
|---|
 | 220 | 
 | 
|---|
 | 221 | mv GNUmakefile ../GNUmakefile
 | 
|---|
 | 222 | 
 | 
|---|
 | 223 | echo '*** mkmf done ***'
 | 
|---|
 | 224 | 
 | 
|---|