1 | #!/bin/csh
|
---|
2 | # $Id: mkmf,v 1.17 2001-12-19 18:34:11 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 | 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 |
|
---|
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 && ! -f ../$f/no_mkmf ) 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 BaseTools'
|
---|
120 | echo "mkmf: Creation makefile lib PI"
|
---|
121 | echo " execution $cmd"
|
---|
122 | $DODBG $cmd
|
---|
123 | endif
|
---|
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
|
---|
130 | if ( -d ../PIext ) then
|
---|
131 | set cmd = "./mkmfPI PIext $libnames PI"
|
---|
132 | echo "mkmf: Creation makefile lib PIext"
|
---|
133 | echo " execution $cmd"
|
---|
134 | $DODBG $cmd
|
---|
135 | endif
|
---|
136 | echo '.PHONY: PI' >> GNUmakefile
|
---|
137 | echo 'PI:' >> GNUmakefile
|
---|
138 | echo ' if [ -d PI ] ; then cd PI ; $(MAKE) ; fi' >> GNUmakefile
|
---|
139 | echo ' if [ -d PIGcont ] ; then cd PIGcont ; $(MAKE) ; fi' >> GNUmakefile
|
---|
140 | echo ' if [ -d PIext ] ; then cd PIext ; $(MAKE) ; fi' >> GNUmakefile
|
---|
141 |
|
---|
142 |
|
---|
143 | echo 'mkmf: Writing shared library building part of the makefile :'
|
---|
144 | if ( `uname` == "Darwin" ) then
|
---|
145 | set sosfx = "dylib"
|
---|
146 | else
|
---|
147 | set sosfx = "so"
|
---|
148 | endif
|
---|
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
|
---|
158 | echo 'EXTSLB = -L$(EXTSLBPATH)' $extslb_list >> GNUmakefile
|
---|
159 | echo 'XPILIBS = $(LIBXPIPATH) $(LIBXPILIST)' >> GNUmakefile
|
---|
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
|
---|
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 = ''
|
---|
188 | foreach f (PI PIGcont PIext)
|
---|
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
|
---|
196 | echo '$(SLB)libsophya.'$sosfx' : $(PSLB)' >> GNUmakefile
|
---|
197 | echo ' $(CMDTILSHL) ' >> GNUmakefile
|
---|
198 | echo ' cd $(OBJ); \' >> GNUmakefile
|
---|
199 | echo ' $(CMDSHLCXX) -o $(SLB)libsophya.'$sosfx' \' >> GNUmakefile
|
---|
200 | echo ' $(FGSHLACXX) $(ALLOBJS) $(FGSHLNCXX)\' >> GNUmakefile
|
---|
201 | echo ' -L$(SLB) $(LIBLSHL)' >> GNUmakefile
|
---|
202 | echo ' ' >> GNUmakefile
|
---|
203 |
|
---|
204 | echo '# Building ExtSophya shared library' >> GNUmakefile
|
---|
205 | echo '$(SLB)libextsophya.'$sosfx' : $(EXTPSLB)' >> GNUmakefile
|
---|
206 | echo ' $(CMDTILSHL) ' >> GNUmakefile
|
---|
207 | echo ' cd $(OBJ); \' >> GNUmakefile
|
---|
208 | echo ' $(CMDSHLCXX) -o $(SLB)libextsophya.'$sosfx' \' >> GNUmakefile
|
---|
209 | echo ' $(FGSHLACXX) $(ALLEXTOBJS) $(FGSHLNCXX)\' >> GNUmakefile
|
---|
210 | echo ' -L$(SLB) -lsophya $(EXTLIB) $(LIBLSHL)' >> GNUmakefile
|
---|
211 | echo ' ' >> GNUmakefile
|
---|
212 |
|
---|
213 | echo '# Building PI shared library' >> GNUmakefile
|
---|
214 | echo '$(SLB)libPI.'$sosfx' : $(PIPSLB)' >> GNUmakefile
|
---|
215 | echo ' $(CMDTILSHL) ' >> GNUmakefile
|
---|
216 | echo ' cd $(OBJ); \' >> GNUmakefile
|
---|
217 | echo ' $(CMDSHLCXX) -o $(SLB)libPI.'$sosfx' \' >> GNUmakefile
|
---|
218 | echo ' $(FGSHLACXX) $(ALLPIOBJS) $(FGSHLNCXX) \' >> GNUmakefile
|
---|
219 | echo ' -L$(SLB) -lsophya -lextsophya $(EXTLIB) $(XPILIBS) $(LIBLSHL)' >> GNUmakefile
|
---|
220 | echo ' ' >> GNUmakefile
|
---|
221 |
|
---|
222 |
|
---|
223 | cat >> GNUmakefile << __END__
|
---|
224 |
|
---|
225 | clean:
|
---|
226 | if [ -d \$(LIB) ] ; then cd \$(LIB)/. ; rm -f *.a ; fi
|
---|
227 | if [ -d \$(SLB) ] ; then cd \$(SLB)/. ; rm -f *.$sosfx ; fi
|
---|
228 | if [ -d \$(OBJ) ] ; then cd \$(OBJ)/. ; rm -f *.o rm -rf cxxrep* ; fi
|
---|
229 | # if [ -d PI ] ; then cd PI/. ; \$(MAKE) clean ; fi
|
---|
230 |
|
---|
231 | __END__
|
---|
232 |
|
---|
233 | mv GNUmakefile ../GNUmakefile
|
---|
234 |
|
---|
235 | echo '*** mkmf done ***'
|
---|
236 |
|
---|