1 | #!/bin/csh
|
---|
2 | # $Id: mkmf,v 1.23 2005-04-25 08:23:13 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; 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 | # pour creer les repertoires et les liens
|
---|
97 |
|
---|
98 | echo '#--- Create directory and copy includes for install' >> GNUmakefile
|
---|
99 | echo 'depend:' >> GNUmakefile
|
---|
100 | echo 'ifdef SOPHYADEVREP' >> GNUmakefile
|
---|
101 | echo 'ifdef SOPHYACXX' >> GNUmakefile
|
---|
102 | echo ' @echo "Sophya will be installed under:"' >> GNUmakefile
|
---|
103 | echo ' @echo " $(SOPHYADEVREP)/Include" ' >> GNUmakefile
|
---|
104 | echo ' @echo " $(SOPHYADEVREP)/`uname`-$(SOPHYACXX)" ' >> GNUmakefile
|
---|
105 | echo ' if [ -d Mgr ] ; then cd Mgr; \' >> GNUmakefile
|
---|
106 | echo ' ./crerep_sophya $(SOPHYADEVREP) `uname`-$(SOPHYACXX); \' >> GNUmakefile
|
---|
107 | echo ' ./makefileuser.csh; \' >> GNUmakefile
|
---|
108 | echo ' ./mkmflien -copy ; \' >> GNUmakefile
|
---|
109 | echo ' fi' >> GNUmakefile
|
---|
110 | echo 'else' >> GNUmakefile
|
---|
111 | echo ' @echo "Variable SOPHYACXX must be define with setenv"' >> GNUmakefile
|
---|
112 | echo 'endif' >> GNUmakefile
|
---|
113 | echo 'else' >> GNUmakefile
|
---|
114 | echo ' @echo "Variable SOPHYADEVREP must be define with setenv"' >> GNUmakefile
|
---|
115 | echo 'endif' >> GNUmakefile
|
---|
116 | echo '#--------------------------------------------------------------------' >> GNUmakefile
|
---|
117 | echo '' >> GNUmakefile
|
---|
118 |
|
---|
119 | # Attention, ne pas changer l'ordre de libnames dependances cxx ?????
|
---|
120 | set libnames = ($modules_pres $extmodules_pres)
|
---|
121 | set i = 1
|
---|
122 | set j = $#libnames ; @ j--
|
---|
123 | while ($i <= $#libnames)
|
---|
124 | set f = $libnames[$i]
|
---|
125 | set k = $i ; @ k++
|
---|
126 | if ( -d ../$f && ! -f ../$f/no_mkmf ) then
|
---|
127 | set cmd = "./mkmflib $f "
|
---|
128 | echo "mkmf: Creation makefile lib $f"
|
---|
129 | echo " execution $cmd"
|
---|
130 | $DODBG $cmd
|
---|
131 | endif
|
---|
132 | echo '.PHONY: ' $f >> GNUmakefile
|
---|
133 | echo $f':' >> GNUmakefile
|
---|
134 | echo ' if [ -d '$f' ] ; then cd ' $f '; $(MAKE) ; fi' >> GNUmakefile
|
---|
135 | echo '' >> GNUmakefile
|
---|
136 | @ i++
|
---|
137 | end
|
---|
138 |
|
---|
139 |
|
---|
140 | if ( -d ../PI ) then
|
---|
141 | set cmd = './mkmfPI PI BaseTools'
|
---|
142 | echo "mkmf: Creation makefile lib PI"
|
---|
143 | echo " execution $cmd"
|
---|
144 | $DODBG $cmd
|
---|
145 | endif
|
---|
146 | if ( -d ../PIGcont ) then
|
---|
147 | set cmd = './mkmfPI PIGcont BaseTools'
|
---|
148 | echo "mkmf: Creation makefile lib PIGcont"
|
---|
149 | echo " execution $cmd"
|
---|
150 | $DODBG $cmd
|
---|
151 | endif
|
---|
152 | if ( -d ../PIext ) then
|
---|
153 | set cmd = "./mkmfPI PIext $libnames PI"
|
---|
154 | echo "mkmf: Creation makefile lib PIext"
|
---|
155 | echo " execution $cmd"
|
---|
156 | $DODBG $cmd
|
---|
157 | endif
|
---|
158 | echo '.PHONY: PI' >> GNUmakefile
|
---|
159 | echo 'PI:' >> GNUmakefile
|
---|
160 | echo ' if [ -d PI ] ; then cd PI ; $(MAKE) ; fi' >> GNUmakefile
|
---|
161 | echo ' if [ -d PIGcont ] ; then cd PIGcont ; $(MAKE) ; fi' >> GNUmakefile
|
---|
162 | echo ' if [ -d PIext ] ; then cd PIext ; $(MAKE) ; fi' >> GNUmakefile
|
---|
163 |
|
---|
164 |
|
---|
165 | echo 'mkmf: Writing shared library building part of the makefile :'
|
---|
166 | if ( `uname` == "Darwin" ) then
|
---|
167 | set sosfx = "dylib"
|
---|
168 | else
|
---|
169 | set sosfx = "so"
|
---|
170 | endif
|
---|
171 |
|
---|
172 | echo '# Shared library creation part of the Makefile' >> GNUmakefile
|
---|
173 | echo '' >> GNUmakefile
|
---|
174 | echo '# List of libraries (.a)' >> GNUmakefile
|
---|
175 | echo 'PSLB = ' $module_libnames >> GNUmakefile
|
---|
176 | echo 'EXTPSLB = ' $extmodule_libnames >> GNUmakefile
|
---|
177 | echo 'PIPSLB = $(LIB)libPI.a $(LIB)libPIGcont.a $(LIB)libPIext.a' >> GNUmakefile
|
---|
178 | echo '# List of external library references' >> GNUmakefile
|
---|
179 | echo 'EXTLIBL = -L$(EXTLIBPATH)' $extlib_list >> GNUmakefile
|
---|
180 | echo 'EXTSLBL = -L$(EXTSLBPATH)' $extslb_list >> GNUmakefile
|
---|
181 | echo '' >> GNUmakefile
|
---|
182 | echo '# defining the other external libraries needed on different systems' >> GNUmakefile
|
---|
183 | echo '' >> GNUmakefile
|
---|
184 | echo '# On Linux lapack and blas and f2c/g2c are needed' >> GNUmakefile
|
---|
185 | echo 'ifeq ($(MACHEROS),Linux)' >> GNUmakefile
|
---|
186 | echo '#EXTLIB = $(EXTLIBL) -llapack -lblas -lf2c' >> GNUmakefile
|
---|
187 | echo '#EXTSLB = $(EXTSLBL) -llapack -lblas -lf2c' >> GNUmakefile
|
---|
188 | echo 'EXTLIB = $(EXTLIBL) -llapack -lblas -lg2c' >> GNUmakefile
|
---|
189 | echo 'EXTSLB = $(EXTSLBL) -llapack -lblas -lg2c' >> GNUmakefile
|
---|
190 | echo 'endif' >> GNUmakefile
|
---|
191 | echo '# On OSF1 libdxml contains part of Lapack, and the fortran support library is needed' >> GNUmakefile
|
---|
192 | echo '# (we still need to add liblapack.a to supply missing lapack routines in dxml)' >> GNUmakefile
|
---|
193 | echo '# (some OSF dxml versions are not OK, please use -lblas instead of -ldxml)' >> GNUmakefile
|
---|
194 | echo 'ifeq ($(MACHEROS),OSF1)' >> GNUmakefile
|
---|
195 | echo 'EXTLIB = $(EXTLIBL) -llapack -ldxml -lfor' >> GNUmakefile
|
---|
196 | echo '###EXTLIB = $(EXTLIBL) -llapack -lblas -lfor' >> GNUmakefile
|
---|
197 | echo 'EXTSLB = $(EXTSLBL) -llapack -ldxml -lfor' >> GNUmakefile
|
---|
198 | echo '###EXTSLB = $(EXTSLBL) -llapack -lblas -lfor' >> GNUmakefile
|
---|
199 | echo 'endif' >> GNUmakefile
|
---|
200 | echo '' >> GNUmakefile
|
---|
201 | echo '# On IRIX , complib.sgimath contains Lapack' >> GNUmakefile
|
---|
202 | echo 'ifeq ($(MACHEROS),IRIX64)' >> GNUmakefile
|
---|
203 | echo 'EXTLIB = $(EXTLIBL) -lcomplib.sgimath ' >> GNUmakefile
|
---|
204 | echo 'EXTSLB = $(EXTSLBL) -lcomplib.sgimath ' >> GNUmakefile
|
---|
205 | echo 'endif' >> GNUmakefile
|
---|
206 | echo '' >> GNUmakefile
|
---|
207 | echo 'XPILIBS = $(LIBXPIPATH) $(LIBXPILIST)' >> GNUmakefile
|
---|
208 | echo '' >> GNUmakefile
|
---|
209 | echo '# main dependence list' >> GNUmakefile
|
---|
210 | echo 'slball : slb slbext slbpi ' >> GNUmakefile
|
---|
211 | echo 'slb : $(SLB)libsophya.'$sosfx >> GNUmakefile
|
---|
212 | echo 'slbext : $(SLB)libextsophya.'$sosfx >> GNUmakefile
|
---|
213 | echo 'slbpi : $(SLB)libPI.'$sosfx >> GNUmakefile
|
---|
214 | echo '' >> GNUmakefile
|
---|
215 |
|
---|
216 | echo '# List of .o files for each module' >> GNUmakefile
|
---|
217 | set objalls = ''
|
---|
218 | foreach f ($modules_pres)
|
---|
219 | echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)' >> GNUmakefile
|
---|
220 | set objalls = ( $objalls '$(OBJ'$f')' )
|
---|
221 | end
|
---|
222 | echo 'ALLOBJS =' $objalls >> GNUmakefile
|
---|
223 | echo '' >> GNUmakefile
|
---|
224 |
|
---|
225 | echo '# List of .o files modules with reference to external libraries' >> GNUmakefile
|
---|
226 | set objalls = ''
|
---|
227 | foreach f ($extmodules_pres)
|
---|
228 | echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)' >> GNUmakefile
|
---|
229 | set objalls = ( $objalls '$(OBJ'$f')' )
|
---|
230 | end
|
---|
231 | echo 'ALLEXTOBJS =' $objalls >> GNUmakefile
|
---|
232 | echo '' >> GNUmakefile
|
---|
233 |
|
---|
234 | echo '# List of .o files for PI modules ' >> GNUmakefile
|
---|
235 | set objalls = ''
|
---|
236 | foreach f (PI PIGcont PIext)
|
---|
237 | echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)' >> GNUmakefile
|
---|
238 | set objalls = ( $objalls '$(OBJ'$f')' )
|
---|
239 | end
|
---|
240 | echo 'ALLPIOBJS =' $objalls >> GNUmakefile
|
---|
241 | echo '' >> GNUmakefile
|
---|
242 |
|
---|
243 | echo '# Building Sophya shared library' >> GNUmakefile
|
---|
244 | echo '$(SLB)libsophya.'$sosfx' : $(PSLB)' >> GNUmakefile
|
---|
245 | echo ' $(CMDTILSHL) ' >> GNUmakefile
|
---|
246 | echo ' cd $(OBJ); \' >> GNUmakefile
|
---|
247 | echo ' $(CMDSHLCXX) -o $(SLB)libsophya.'$sosfx' \' >> GNUmakefile
|
---|
248 | echo ' $(FGSHLACXX) $(ALLOBJS) $(FGSHLNCXX)\' >> GNUmakefile
|
---|
249 | echo ' -L$(SLB) $(LIBLSHL)' >> GNUmakefile
|
---|
250 | echo '' >> GNUmakefile
|
---|
251 |
|
---|
252 | echo '# Building ExtSophya shared library' >> GNUmakefile
|
---|
253 | echo '$(SLB)libextsophya.'$sosfx' : $(EXTPSLB)' >> GNUmakefile
|
---|
254 | echo ' $(CMDTILSHL) ' >> GNUmakefile
|
---|
255 | echo ' cd $(OBJ); \' >> GNUmakefile
|
---|
256 | echo ' $(CMDSHLCXX) -o $(SLB)libextsophya.'$sosfx' \' >> GNUmakefile
|
---|
257 | echo ' $(FGSHLACXX) $(ALLEXTOBJS) $(FGSHLNCXX)\' >> GNUmakefile
|
---|
258 | echo ' -L$(SLB) -lsophya $(EXTLIB) $(LIBLSHL)' >> GNUmakefile
|
---|
259 | echo '' >> GNUmakefile
|
---|
260 |
|
---|
261 | echo '# Building PI shared library' >> GNUmakefile
|
---|
262 | echo '$(SLB)libPI.'$sosfx' : $(PIPSLB)' >> GNUmakefile
|
---|
263 | echo ' $(CMDTILSHL) ' >> GNUmakefile
|
---|
264 | echo ' cd $(OBJ); \' >> GNUmakefile
|
---|
265 | echo ' $(CMDSHLCXX) -o $(SLB)libPI.'$sosfx' \' >> GNUmakefile
|
---|
266 | echo ' $(FGSHLACXX) $(ALLPIOBJS) $(FGSHLNCXX) \' >> GNUmakefile
|
---|
267 | echo ' -L$(SLB) -lsophya -lextsophya $(EXTLIB) $(XPILIBS) $(LIBLSHL)' >> GNUmakefile
|
---|
268 | echo '' >> GNUmakefile
|
---|
269 |
|
---|
270 |
|
---|
271 | cat >> GNUmakefile << __END__
|
---|
272 |
|
---|
273 | clean:
|
---|
274 | if [ -d \$(LIB) ] ; then cd \$(LIB)/. ; rm -f *.a ; fi
|
---|
275 | if [ -d \$(SLB) ] ; then cd \$(SLB)/. ; rm -f *.$sosfx ; fi
|
---|
276 | if [ -d \$(OBJ) ] ; then cd \$(OBJ)/. ; rm -f *.o rm -rf cxxrep* ; fi
|
---|
277 | # if [ -d PI ] ; then cd PI/. ; \$(MAKE) clean ; fi
|
---|
278 |
|
---|
279 | __END__
|
---|
280 |
|
---|
281 | mv GNUmakefile ../GNUmakefile
|
---|
282 |
|
---|
283 | echo '*** mkmf done ***'
|
---|
284 |
|
---|