| 1 | #!/bin/csh | 
|---|
| 2 | # $Id: mkmf,v 1.10 2000-03-02 10:57:51 ansari 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 | echo 'mkmf: Creating MakefileUser.h' | 
|---|
| 15 | cat Makefile.h | awk -f makefileuser.awk >! MakefileUser.h | 
|---|
| 16 |  | 
|---|
| 17 | # creation des liens pour les includes | 
|---|
| 18 | echo 'mkmf: Creating links for *.h (call mkmflien)' | 
|---|
| 19 | $DODBG ./mkmflien | 
|---|
| 20 |  | 
|---|
| 21 | # Liste des modules a construire | 
|---|
| 22 | # modules : Liste de module SOPHYA, sans dependance exterieure | 
|---|
| 23 | # extmodules : Liste de modules avec dependance exterieures | 
|---|
| 24 | #        _pres : Liste des modules presents | 
|---|
| 25 |  | 
|---|
| 26 | set modules = `cat libdirs` | 
|---|
| 27 | set extmodules = `cat extlibdirs` | 
|---|
| 28 | set modules_pres = '' | 
|---|
| 29 | set extmodules_pres = '' | 
|---|
| 30 |  | 
|---|
| 31 | set module_libnames = '' | 
|---|
| 32 | set extmodule_libnames = '' | 
|---|
| 33 | set extlib_list = '' | 
|---|
| 34 | set extslb_list = '' | 
|---|
| 35 | #  Constitution de la liste de modules present | 
|---|
| 36 | foreach f ($modules) | 
|---|
| 37 | if (-d ../$f ) then | 
|---|
| 38 | set modules_pres = ( $modules_pres $f ) | 
|---|
| 39 | set module_libnames = ( $module_libnames '$(LIB)lib'$f.a ) | 
|---|
| 40 | endif | 
|---|
| 41 | end | 
|---|
| 42 | foreach f ($extmodules) | 
|---|
| 43 | if (-d ../$f ) then | 
|---|
| 44 | set extmodules_pres = ( $extmodules_pres $f ) | 
|---|
| 45 | set extmodule_libnames = ( $extmodule_libnames '$(LIB)lib'$f.a ) | 
|---|
| 46 | set lil = "../$f/extlib_list" | 
|---|
| 47 | if (-f $lil ) set extlib_list = ($extlib_list `sed -e 's/.*/-l&/' $lil`) | 
|---|
| 48 | set lil = "../$f/extslb_list" | 
|---|
| 49 | if (-f $lil ) set extslb_list = ($extslb_list `sed -e 's/.*/-l&/' $lil`) | 
|---|
| 50 | endif | 
|---|
| 51 | end | 
|---|
| 52 |  | 
|---|
| 53 | echo 'mkmf: List of modules ' | 
|---|
| 54 | echo '  ... modules= ' $modules_pres | 
|---|
| 55 | echo $module_libnames | 
|---|
| 56 | echo '  ... extmodules= ' $extmodules_pres | 
|---|
| 57 | echo $extmodule_libnames | 
|---|
| 58 |  | 
|---|
| 59 | echo 'mkmf: Creating makefile global :' | 
|---|
| 60 | rm -f GNUmakefile | 
|---|
| 61 |  | 
|---|
| 62 | echo '# include files defining compiler/linker options '  >> GNUmakefile | 
|---|
| 63 | echo 'MODULECXXREPNAME := PI'  >> GNUmakefile | 
|---|
| 64 | echo 'include Mgr/Makefile.h' >> GNUmakefile | 
|---|
| 65 | echo 'include Mgr/Makefile.slb' >> GNUmakefile | 
|---|
| 66 | echo ''   >> GNUmakefile | 
|---|
| 67 |  | 
|---|
| 68 | echo 'LIBF = ' `sed -e 's/.*/$(LIB)lib&.a/' libdirs` >> GNUmakefile | 
|---|
| 69 | echo 'LIBS = -L$(LIB)' `sed -e 's/.*/-l&/' libdirs` '-lm' >> GNUmakefile | 
|---|
| 70 | echo 'LIBG = -L$(GLB) -lstdc++' >> GNUmakefile | 
|---|
| 71 | echo 'ifeq ($(HOSTTYPE), powerpc)' >> GNUmakefile | 
|---|
| 72 | echo '  LIBG = -L$(GLB)' >> GNUmakefile | 
|---|
| 73 | echo 'endif' >> GNUmakefile | 
|---|
| 74 |  | 
|---|
| 75 | cat >> GNUmakefile <<EOF | 
|---|
| 76 |  | 
|---|
| 77 | defaut: libs | 
|---|
| 78 |  | 
|---|
| 79 | all: libs extlibs PI | 
|---|
| 80 |  | 
|---|
| 81 | libs: cxxlibs | 
|---|
| 82 |  | 
|---|
| 83 | extlibs: cxxextlibs | 
|---|
| 84 |  | 
|---|
| 85 | EOF | 
|---|
| 86 |  | 
|---|
| 87 | # Dans cet ordre pour les templates de cxx, a cause des dependances | 
|---|
| 88 | # pour instantiation automatique/manuels | 
|---|
| 89 |  | 
|---|
| 90 | echo 'cxxlibs: ' $modules_pres >>    GNUmakefile | 
|---|
| 91 | echo ' ' >> GNUmakefile | 
|---|
| 92 | echo 'cxxextlibs: ' $extmodules_pres >> GNUmakefile | 
|---|
| 93 |  | 
|---|
| 94 |  | 
|---|
| 95 | #  Attention, ne pas changer l'ordre de libnames dependances cxx  ????? | 
|---|
| 96 | set libnames = ($modules_pres $extmodules_pres) | 
|---|
| 97 | set i = 1 | 
|---|
| 98 | set j = $#libnames ; @ j-- | 
|---|
| 99 | while ($i <= $#libnames) | 
|---|
| 100 | set f = $libnames[$i] | 
|---|
| 101 | set k = $i ; @ k++ | 
|---|
| 102 | if ( -d ../$f ) then | 
|---|
| 103 | set cmd = "./mkmflib $f " | 
|---|
| 104 | echo "mkmf: Creation makefile lib $f" | 
|---|
| 105 | echo "   execution $cmd" | 
|---|
| 106 | $DODBG $cmd | 
|---|
| 107 | endif | 
|---|
| 108 | echo '.PHONY: ' $f >> GNUmakefile | 
|---|
| 109 | echo $f':' >> GNUmakefile | 
|---|
| 110 | echo '        if [ -d '$f' ] ; then cd ' $f '; $(MAKE) ; fi' >> GNUmakefile | 
|---|
| 111 | echo ' ' >> GNUmakefile | 
|---|
| 112 | @ i++ | 
|---|
| 113 | end | 
|---|
| 114 |  | 
|---|
| 115 |  | 
|---|
| 116 | if ( -d ../PI ) then | 
|---|
| 117 | set cmd = './mkmfPI PI SysTools' | 
|---|
| 118 | echo "mkmf: Creation makefile lib PI" | 
|---|
| 119 | echo "   execution $cmd" | 
|---|
| 120 | $DODBG  $cmd | 
|---|
| 121 | endif | 
|---|
| 122 | if ( -d ../PIext ) then | 
|---|
| 123 | set cmd = "./mkmfPI PIext $libnames PI" | 
|---|
| 124 | echo "mkmf: Creation makefile lib PIext" | 
|---|
| 125 | echo "   execution $cmd" | 
|---|
| 126 | $DODBG $cmd | 
|---|
| 127 | endif | 
|---|
| 128 | echo '.PHONY: PI' >> GNUmakefile | 
|---|
| 129 | echo 'PI:' >> GNUmakefile | 
|---|
| 130 | echo '  if [ -d PI ] ; then cd PI ; $(MAKE) ; fi' >> GNUmakefile | 
|---|
| 131 | echo '  if [ -d PIext ] ; then cd PIext ; $(MAKE) ; fi' >> GNUmakefile | 
|---|
| 132 |  | 
|---|
| 133 |  | 
|---|
| 134 | echo 'mkmf: Writing shared library building part of the makefile :' | 
|---|
| 135 |  | 
|---|
| 136 | echo '#  Shared library creation part of the Makefile'       >> GNUmakefile | 
|---|
| 137 | echo ' '                                 >> GNUmakefile | 
|---|
| 138 | echo '#  List of libraries (.a)'         >> GNUmakefile | 
|---|
| 139 | echo 'PSLB = ' $module_libnames          >> GNUmakefile | 
|---|
| 140 | echo 'EXTPSLB = ' $extmodule_libnames    >> GNUmakefile | 
|---|
| 141 | echo 'PIPSLB =  $(LIB)libPI.a  $(LIB)libPIext.a'   >> GNUmakefile | 
|---|
| 142 | echo '#  List of external library references'       >> GNUmakefile | 
|---|
| 143 | echo 'EXTLIB  = -L$(EXTLIBPATH)' $extlib_list       >> GNUmakefile | 
|---|
| 144 | echo 'EXTSLB  = -L$(EXTSLBPATH)' $extslb_list       >> GNUmakefile | 
|---|
| 145 | echo 'XPILIBS = $(LIBXPIPATH) $(LIBXPILIST)'        >> GNUmakefile | 
|---|
| 146 | echo ''                                  >> GNUmakefile | 
|---|
| 147 | echo '#  main dependence list'           >> GNUmakefile | 
|---|
| 148 | echo 'slball : slb slbext slbpi '        >> GNUmakefile | 
|---|
| 149 | echo 'slb : $(SLB)libsophya.so '         >> GNUmakefile | 
|---|
| 150 | echo 'slbext : $(SLB)libextsophya.so   ' >> GNUmakefile | 
|---|
| 151 | echo 'slbpi : $(SLB)libPI.so'            >> GNUmakefile | 
|---|
| 152 | echo ' '                                 >> GNUmakefile | 
|---|
| 153 |  | 
|---|
| 154 | echo '# List of .o files for each module'  >> GNUmakefile | 
|---|
| 155 | set objalls =  '' | 
|---|
| 156 | foreach f ($modules_pres) | 
|---|
| 157 | echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)'  >> GNUmakefile | 
|---|
| 158 | set objalls = ( $objalls '$(OBJ'$f')' ) | 
|---|
| 159 | end | 
|---|
| 160 | echo 'ALLOBJS =' $objalls                >> GNUmakefile | 
|---|
| 161 | echo ' '                                 >> GNUmakefile | 
|---|
| 162 |  | 
|---|
| 163 | echo '# List of .o files modules with reference to external libraries'  >> GNUmakefile | 
|---|
| 164 | set objalls =  '' | 
|---|
| 165 | foreach f ($extmodules_pres) | 
|---|
| 166 | echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)'  >> GNUmakefile | 
|---|
| 167 | set objalls = ( $objalls '$(OBJ'$f')' ) | 
|---|
| 168 | end | 
|---|
| 169 | echo 'ALLEXTOBJS =' $objalls             >> GNUmakefile | 
|---|
| 170 | echo ' '                                 >> GNUmakefile | 
|---|
| 171 |  | 
|---|
| 172 | echo '# List of .o files for PI modules '  >> GNUmakefile | 
|---|
| 173 | set objalls =  '' | 
|---|
| 174 | foreach f (PI PIext) | 
|---|
| 175 | echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)'  >> GNUmakefile | 
|---|
| 176 | set objalls = ( $objalls '$(OBJ'$f')' ) | 
|---|
| 177 | end | 
|---|
| 178 | echo 'ALLPIOBJS =' $objalls              >> GNUmakefile | 
|---|
| 179 | echo ' '                                 >> GNUmakefile | 
|---|
| 180 |  | 
|---|
| 181 | echo '# Building Sophya shared library'  >> GNUmakefile | 
|---|
| 182 | echo '$(SLB)libsophya.so : $(PSLB)'                             >> GNUmakefile | 
|---|
| 183 | echo '  $(CMDTILSHL) '                                          >> GNUmakefile | 
|---|
| 184 | echo '  cd  $(OBJ); \'                                          >> GNUmakefile | 
|---|
| 185 | echo '  $(CMDSHLCXX) -o $(SLB)libsophya.so  \'                  >> GNUmakefile | 
|---|
| 186 | echo '  $(FGSHLACXX) $(ALLOBJS)  $(FGSHLNCXX)\'                 >> GNUmakefile | 
|---|
| 187 | echo '  -L$(SLB) $(LIBLSHL)'                                    >> GNUmakefile | 
|---|
| 188 | echo ' '                                                        >> GNUmakefile | 
|---|
| 189 |  | 
|---|
| 190 | echo '# Building ExtSophya shared library'  >> GNUmakefile | 
|---|
| 191 | echo '$(SLB)libextsophya.so : $(EXTPSLB)'                       >> GNUmakefile | 
|---|
| 192 | echo '  $(CMDTILSHL) '                                          >> GNUmakefile | 
|---|
| 193 | echo '  cd  $(OBJ); \'                                          >> GNUmakefile | 
|---|
| 194 | echo '  $(CMDSHLCXX) -o $(SLB)libextsophya.so  \'               >> GNUmakefile | 
|---|
| 195 | echo '  $(FGSHLACXX) $(ALLEXTOBJS)  $(FGSHLNCXX)\'              >> GNUmakefile | 
|---|
| 196 | echo '  -L$(SLB) -lsophya $(EXTLIB) $(LIBLSHL)'                 >> GNUmakefile | 
|---|
| 197 | echo ' '                                                        >> GNUmakefile | 
|---|
| 198 |  | 
|---|
| 199 | echo '# Building PI shared library'  >> GNUmakefile | 
|---|
| 200 | echo '$(SLB)libPI.so : $(PIPSLB)'                               >> GNUmakefile | 
|---|
| 201 | echo '  $(CMDTILSHL) '                                          >> GNUmakefile | 
|---|
| 202 | echo '  cd  $(OBJ); \'                                          >> GNUmakefile | 
|---|
| 203 | echo '  $(CMDSHLCXX) -o $(SLB)libPI.so  \'                      >> GNUmakefile | 
|---|
| 204 | echo '  $(FGSHLACXX) $(ALLPIOBJS) $(FGSHLNCXX) \'               >> GNUmakefile | 
|---|
| 205 | echo '  -L$(SLB) -lsophya -lextsophya $(EXTLIB) $(XPILIBS) $(LIBLSHL)'      >> GNUmakefile | 
|---|
| 206 | echo ' '                                                        >> GNUmakefile | 
|---|
| 207 |  | 
|---|
| 208 |  | 
|---|
| 209 | cat >> GNUmakefile << __END__ | 
|---|
| 210 |  | 
|---|
| 211 | clean: | 
|---|
| 212 | if [ -d \$(LIB) ] ; then cd \$(LIB)/. ; rm -f *.a  ; fi | 
|---|
| 213 | if [ -d \$(SLB) ] ; then cd \$(SLB)/. ; rm -f *.so ; fi | 
|---|
| 214 | if [ -d \$(OBJ) ] ; then cd \$(OBJ)/. ; rm -f *.o  rm -rf cxxrep* ; fi | 
|---|
| 215 | #       if [ -d PI ]     ; then cd PI/.     ; \$(MAKE) clean ; fi | 
|---|
| 216 |  | 
|---|
| 217 | __END__ | 
|---|
| 218 |  | 
|---|
| 219 | mv GNUmakefile ../GNUmakefile | 
|---|
| 220 |  | 
|---|
| 221 | echo '*** mkmf done ***' | 
|---|
| 222 |  | 
|---|