[218] | 1 | #!/bin/csh
|
---|
[1834] | 2 | # $Id: mkmf,v 1.17 2001-12-19 18:34:11 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
|
---|
[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
|
---|
| 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++
|
---|
[1783] | 104 | if ( -d ../$f && ! -f ../$f/no_mkmf ) 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
|
---|
[1603] | 119 | set cmd = './mkmfPI PI BaseTools'
|
---|
[218] | 120 | echo "mkmf: Creation makefile lib PI"
|
---|
| 121 | echo " execution $cmd"
|
---|
[740] | 122 | $DODBG $cmd
|
---|
[218] | 123 | endif
|
---|
[1834] | 124 | if ( -d ../PIGcont ) then
|
---|
| 125 | set cmd = './mkmfPI PIGcont BaseTools'
|
---|
| 126 | echo "mkmf: Creation makefile lib PIGcont"
|
---|
| 127 | echo " execution $cmd"
|
---|
| 128 | $DODBG $cmd
|
---|
| 129 | endif
|
---|
[218] | 130 | if ( -d ../PIext ) then
|
---|
[740] | 131 | set cmd = "./mkmfPI PIext $libnames PI"
|
---|
[218] | 132 | echo "mkmf: Creation makefile lib PIext"
|
---|
| 133 | echo " execution $cmd"
|
---|
[740] | 134 | $DODBG $cmd
|
---|
[218] | 135 | endif
|
---|
| 136 | echo '.PHONY: PI' >> GNUmakefile
|
---|
| 137 | echo 'PI:' >> GNUmakefile
|
---|
| 138 | echo ' if [ -d PI ] ; then cd PI ; $(MAKE) ; fi' >> GNUmakefile
|
---|
[1834] | 139 | echo ' if [ -d PIGcont ] ; then cd PIGcont ; $(MAKE) ; fi' >> GNUmakefile
|
---|
[218] | 140 | echo ' if [ -d PIext ] ; then cd PIext ; $(MAKE) ; fi' >> GNUmakefile
|
---|
| 141 |
|
---|
| 142 |
|
---|
[751] | 143 | echo 'mkmf: Writing shared library building part of the makefile :'
|
---|
[1783] | 144 | if ( `uname` == "Darwin" ) then
|
---|
| 145 | set sosfx = "dylib"
|
---|
| 146 | else
|
---|
| 147 | set sosfx = "so"
|
---|
| 148 | endif
|
---|
[740] | 149 |
|
---|
| 150 | echo '# Shared library creation part of the Makefile' >> GNUmakefile
|
---|
| 151 | echo ' ' >> GNUmakefile
|
---|
| 152 | echo '# List of libraries (.a)' >> GNUmakefile
|
---|
| 153 | echo 'PSLB = ' $module_libnames >> GNUmakefile
|
---|
| 154 | echo 'EXTPSLB = ' $extmodule_libnames >> GNUmakefile
|
---|
| 155 | echo 'PIPSLB = $(LIB)libPI.a $(LIB)libPIext.a' >> GNUmakefile
|
---|
| 156 | echo '# List of external library references' >> GNUmakefile
|
---|
| 157 | echo 'EXTLIB = -L$(EXTLIBPATH)' $extlib_list >> GNUmakefile
|
---|
[751] | 158 | echo 'EXTSLB = -L$(EXTSLBPATH)' $extslb_list >> GNUmakefile
|
---|
[740] | 159 | echo 'XPILIBS = $(LIBXPIPATH) $(LIBXPILIST)' >> GNUmakefile
|
---|
[1783] | 160 | echo '' >> GNUmakefile
|
---|
| 161 | echo '# main dependence list' >> GNUmakefile
|
---|
| 162 | echo 'slball : slb slbext slbpi ' >> GNUmakefile
|
---|
| 163 | echo 'slb : $(SLB)libsophya.'$sosfx >> GNUmakefile
|
---|
| 164 | echo 'slbext : $(SLB)libextsophya.'$sosfx >> GNUmakefile
|
---|
| 165 | echo 'slbpi : $(SLB)libPI.'$sosfx >> GNUmakefile
|
---|
| 166 | echo ' ' >> GNUmakefile
|
---|
[740] | 167 |
|
---|
| 168 | echo '# List of .o files for each module' >> GNUmakefile
|
---|
| 169 | set objalls = ''
|
---|
| 170 | foreach f ($modules_pres)
|
---|
| 171 | echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)' >> GNUmakefile
|
---|
| 172 | set objalls = ( $objalls '$(OBJ'$f')' )
|
---|
| 173 | end
|
---|
| 174 | echo 'ALLOBJS =' $objalls >> GNUmakefile
|
---|
| 175 | echo ' ' >> GNUmakefile
|
---|
| 176 |
|
---|
| 177 | echo '# List of .o files modules with reference to external libraries' >> GNUmakefile
|
---|
| 178 | set objalls = ''
|
---|
| 179 | foreach f ($extmodules_pres)
|
---|
| 180 | echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)' >> GNUmakefile
|
---|
| 181 | set objalls = ( $objalls '$(OBJ'$f')' )
|
---|
| 182 | end
|
---|
| 183 | echo 'ALLEXTOBJS =' $objalls >> GNUmakefile
|
---|
| 184 | echo ' ' >> GNUmakefile
|
---|
| 185 |
|
---|
| 186 | echo '# List of .o files for PI modules ' >> GNUmakefile
|
---|
| 187 | set objalls = ''
|
---|
[1834] | 188 | foreach f (PI PIGcont PIext)
|
---|
[740] | 189 | echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)' >> GNUmakefile
|
---|
| 190 | set objalls = ( $objalls '$(OBJ'$f')' )
|
---|
| 191 | end
|
---|
| 192 | echo 'ALLPIOBJS =' $objalls >> GNUmakefile
|
---|
| 193 | echo ' ' >> GNUmakefile
|
---|
| 194 |
|
---|
| 195 | echo '# Building Sophya shared library' >> GNUmakefile
|
---|
[1783] | 196 | echo '$(SLB)libsophya.'$sosfx' : $(PSLB)' >> GNUmakefile
|
---|
[740] | 197 | echo ' $(CMDTILSHL) ' >> GNUmakefile
|
---|
| 198 | echo ' cd $(OBJ); \' >> GNUmakefile
|
---|
[1783] | 199 | echo ' $(CMDSHLCXX) -o $(SLB)libsophya.'$sosfx' \' >> GNUmakefile
|
---|
[740] | 200 | echo ' $(FGSHLACXX) $(ALLOBJS) $(FGSHLNCXX)\' >> GNUmakefile
|
---|
| 201 | echo ' -L$(SLB) $(LIBLSHL)' >> GNUmakefile
|
---|
| 202 | echo ' ' >> GNUmakefile
|
---|
| 203 |
|
---|
| 204 | echo '# Building ExtSophya shared library' >> GNUmakefile
|
---|
[1783] | 205 | echo '$(SLB)libextsophya.'$sosfx' : $(EXTPSLB)' >> GNUmakefile
|
---|
[740] | 206 | echo ' $(CMDTILSHL) ' >> GNUmakefile
|
---|
| 207 | echo ' cd $(OBJ); \' >> GNUmakefile
|
---|
[1783] | 208 | echo ' $(CMDSHLCXX) -o $(SLB)libextsophya.'$sosfx' \' >> GNUmakefile
|
---|
[740] | 209 | echo ' $(FGSHLACXX) $(ALLEXTOBJS) $(FGSHLNCXX)\' >> GNUmakefile
|
---|
[751] | 210 | echo ' -L$(SLB) -lsophya $(EXTLIB) $(LIBLSHL)' >> GNUmakefile
|
---|
[740] | 211 | echo ' ' >> GNUmakefile
|
---|
| 212 |
|
---|
| 213 | echo '# Building PI shared library' >> GNUmakefile
|
---|
[1783] | 214 | echo '$(SLB)libPI.'$sosfx' : $(PIPSLB)' >> GNUmakefile
|
---|
[740] | 215 | echo ' $(CMDTILSHL) ' >> GNUmakefile
|
---|
| 216 | echo ' cd $(OBJ); \' >> GNUmakefile
|
---|
[1783] | 217 | echo ' $(CMDSHLCXX) -o $(SLB)libPI.'$sosfx' \' >> GNUmakefile
|
---|
[751] | 218 | echo ' $(FGSHLACXX) $(ALLPIOBJS) $(FGSHLNCXX) \' >> GNUmakefile
|
---|
| 219 | echo ' -L$(SLB) -lsophya -lextsophya $(EXTLIB) $(XPILIBS) $(LIBLSHL)' >> GNUmakefile
|
---|
[740] | 220 | echo ' ' >> GNUmakefile
|
---|
| 221 |
|
---|
| 222 |
|
---|
[218] | 223 | cat >> GNUmakefile << __END__
|
---|
| 224 |
|
---|
| 225 | clean:
|
---|
| 226 | if [ -d \$(LIB) ] ; then cd \$(LIB)/. ; rm -f *.a ; fi
|
---|
[1783] | 227 | if [ -d \$(SLB) ] ; then cd \$(SLB)/. ; rm -f *.$sosfx ; fi
|
---|
[740] | 228 | if [ -d \$(OBJ) ] ; then cd \$(OBJ)/. ; rm -f *.o rm -rf cxxrep* ; fi
|
---|
| 229 | # if [ -d PI ] ; then cd PI/. ; \$(MAKE) clean ; fi
|
---|
[218] | 230 |
|
---|
| 231 | __END__
|
---|
| 232 |
|
---|
| 233 | mv GNUmakefile ../GNUmakefile
|
---|
| 234 |
|
---|
| 235 | echo '*** mkmf done ***'
|
---|
| 236 |
|
---|