| 1 | #!/bin/csh | 
|---|
| 2 | # $Id: mkmf,v 1.13 2001-05-11 08:32:00 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 | 
|---|
| 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 |  | 
|---|
| 97 | #  Attention, ne pas changer l'ordre de libnames dependances cxx  ????? | 
|---|
| 98 | set libnames = ($modules_pres $extmodules_pres) | 
|---|
| 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 | 
|---|
| 105 | set cmd = "./mkmflib $f " | 
|---|
| 106 | echo "mkmf: Creation makefile lib $f" | 
|---|
| 107 | echo "   execution $cmd" | 
|---|
| 108 | $DODBG $cmd | 
|---|
| 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" | 
|---|
| 122 | $DODBG  $cmd | 
|---|
| 123 | endif | 
|---|
| 124 | if ( -d ../PIext ) then | 
|---|
| 125 | set cmd = "./mkmfPI PIext $libnames PI" | 
|---|
| 126 | echo "mkmf: Creation makefile lib PIext" | 
|---|
| 127 | echo "   execution $cmd" | 
|---|
| 128 | $DODBG $cmd | 
|---|
| 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 |  | 
|---|
| 136 | echo 'mkmf: Writing shared library building part of the makefile :' | 
|---|
| 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 | 
|---|
| 146 | echo 'EXTSLB  = -L$(EXTSLBPATH)' $extslb_list       >> GNUmakefile | 
|---|
| 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 | 
|---|
| 198 | echo '  -L$(SLB) -lsophya $(EXTLIB) $(LIBLSHL)'                 >> GNUmakefile | 
|---|
| 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 | 
|---|
| 206 | echo '  $(FGSHLACXX) $(ALLPIOBJS) $(FGSHLNCXX) \'               >> GNUmakefile | 
|---|
| 207 | echo '  -L$(SLB) -lsophya -lextsophya $(EXTLIB) $(XPILIBS) $(LIBLSHL)'      >> GNUmakefile | 
|---|
| 208 | echo ' '                                                        >> GNUmakefile | 
|---|
| 209 |  | 
|---|
| 210 |  | 
|---|
| 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 | 
|---|
| 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 |  | 
|---|
| 219 | __END__ | 
|---|
| 220 |  | 
|---|
| 221 | mv GNUmakefile ../GNUmakefile | 
|---|
| 222 |  | 
|---|
| 223 | echo '*** mkmf done ***' | 
|---|
| 224 |  | 
|---|