source: Sophya/trunk/SophyaLib/Mgr/mkmf@ 765

Last change on this file since 765 was 751, checked in by ansari, 26 years ago

Correction bug ds mkmf , Reza 02/03/200

  • Property svn:executable set to *
File size: 7.8 KB
Line 
1#!/bin/csh
2# $Id: mkmf,v 1.10 2000-03-02 10:57:51 ansari Exp $
3
4# Pour debugger
5set DODBG = 'echo'
6set DODBG = ''
7
8# Librairies externe
9if( ! $?EXTLIBDIR ) then
10 echo 'mkmf- WARNING (External libraries) EXTLIBDIR variable not set'
11endif
12
13# creation de MakefileUser.h a partir de Makefile.h
14echo 'mkmf: Creating MakefileUser.h'
15cat Makefile.h | awk -f makefileuser.awk >! MakefileUser.h
16
17# creation des liens pour les includes
18echo '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
26set modules = `cat libdirs`
27set extmodules = `cat extlibdirs`
28set modules_pres = ''
29set extmodules_pres = ''
30
31set module_libnames = ''
32set extmodule_libnames = ''
33set extlib_list = ''
34set extslb_list = ''
35# Constitution de la liste de modules present
36foreach 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
41end
42foreach 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
51end
52
53echo 'mkmf: List of modules '
54echo ' ... modules= ' $modules_pres
55echo $module_libnames
56echo ' ... extmodules= ' $extmodules_pres
57echo $extmodule_libnames
58
59echo 'mkmf: Creating makefile global :'
60rm -f GNUmakefile
61
62echo '# include files defining compiler/linker options ' >> GNUmakefile
63echo 'MODULECXXREPNAME := PI' >> GNUmakefile
64echo 'include Mgr/Makefile.h' >> GNUmakefile
65echo 'include Mgr/Makefile.slb' >> GNUmakefile
66echo '' >> GNUmakefile
67
68echo 'LIBF = ' `sed -e 's/.*/$(LIB)lib&.a/' libdirs` >> GNUmakefile
69echo 'LIBS = -L$(LIB)' `sed -e 's/.*/-l&/' libdirs` '-lm' >> GNUmakefile
70echo 'LIBG = -L$(GLB) -lstdc++' >> GNUmakefile
71echo 'ifeq ($(HOSTTYPE), powerpc)' >> GNUmakefile
72echo ' LIBG = -L$(GLB)' >> GNUmakefile
73echo 'endif' >> GNUmakefile
74
75cat >> GNUmakefile <<EOF
76
77defaut: libs
78
79all: libs extlibs PI
80
81libs: cxxlibs
82
83extlibs: cxxextlibs
84
85EOF
86
87# Dans cet ordre pour les templates de cxx, a cause des dependances
88# pour instantiation automatique/manuels
89
90echo 'cxxlibs: ' $modules_pres >> GNUmakefile
91echo ' ' >> GNUmakefile
92echo 'cxxextlibs: ' $extmodules_pres >> GNUmakefile
93
94
95# Attention, ne pas changer l'ordre de libnames dependances cxx ?????
96set libnames = ($modules_pres $extmodules_pres)
97set i = 1
98set j = $#libnames ; @ j--
99while ($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++
113end
114
115
116if ( -d ../PI ) then
117 set cmd = './mkmfPI PI SysTools'
118 echo "mkmf: Creation makefile lib PI"
119 echo " execution $cmd"
120 $DODBG $cmd
121endif
122if ( -d ../PIext ) then
123 set cmd = "./mkmfPI PIext $libnames PI"
124 echo "mkmf: Creation makefile lib PIext"
125 echo " execution $cmd"
126 $DODBG $cmd
127endif
128echo '.PHONY: PI' >> GNUmakefile
129echo 'PI:' >> GNUmakefile
130echo ' if [ -d PI ] ; then cd PI ; $(MAKE) ; fi' >> GNUmakefile
131echo ' if [ -d PIext ] ; then cd PIext ; $(MAKE) ; fi' >> GNUmakefile
132
133
134echo 'mkmf: Writing shared library building part of the makefile :'
135
136echo '# Shared library creation part of the Makefile' >> GNUmakefile
137echo ' ' >> GNUmakefile
138echo '# List of libraries (.a)' >> GNUmakefile
139echo 'PSLB = ' $module_libnames >> GNUmakefile
140echo 'EXTPSLB = ' $extmodule_libnames >> GNUmakefile
141echo 'PIPSLB = $(LIB)libPI.a $(LIB)libPIext.a' >> GNUmakefile
142echo '# List of external library references' >> GNUmakefile
143echo 'EXTLIB = -L$(EXTLIBPATH)' $extlib_list >> GNUmakefile
144echo 'EXTSLB = -L$(EXTSLBPATH)' $extslb_list >> GNUmakefile
145echo 'XPILIBS = $(LIBXPIPATH) $(LIBXPILIST)' >> GNUmakefile
146echo '' >> GNUmakefile
147echo '# main dependence list' >> GNUmakefile
148echo 'slball : slb slbext slbpi ' >> GNUmakefile
149echo 'slb : $(SLB)libsophya.so ' >> GNUmakefile
150echo 'slbext : $(SLB)libextsophya.so ' >> GNUmakefile
151echo 'slbpi : $(SLB)libPI.so' >> GNUmakefile
152echo ' ' >> GNUmakefile
153
154echo '# List of .o files for each module' >> GNUmakefile
155set objalls = ''
156foreach f ($modules_pres)
157 echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)' >> GNUmakefile
158 set objalls = ( $objalls '$(OBJ'$f')' )
159end
160echo 'ALLOBJS =' $objalls >> GNUmakefile
161echo ' ' >> GNUmakefile
162
163echo '# List of .o files modules with reference to external libraries' >> GNUmakefile
164set objalls = ''
165foreach f ($extmodules_pres)
166 echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)' >> GNUmakefile
167 set objalls = ( $objalls '$(OBJ'$f')' )
168end
169echo 'ALLEXTOBJS =' $objalls >> GNUmakefile
170echo ' ' >> GNUmakefile
171
172echo '# List of .o files for PI modules ' >> GNUmakefile
173set objalls = ''
174foreach f (PI PIext)
175 echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)' >> GNUmakefile
176 set objalls = ( $objalls '$(OBJ'$f')' )
177end
178echo 'ALLPIOBJS =' $objalls >> GNUmakefile
179echo ' ' >> GNUmakefile
180
181echo '# Building Sophya shared library' >> GNUmakefile
182echo '$(SLB)libsophya.so : $(PSLB)' >> GNUmakefile
183echo ' $(CMDTILSHL) ' >> GNUmakefile
184echo ' cd $(OBJ); \' >> GNUmakefile
185echo ' $(CMDSHLCXX) -o $(SLB)libsophya.so \' >> GNUmakefile
186echo ' $(FGSHLACXX) $(ALLOBJS) $(FGSHLNCXX)\' >> GNUmakefile
187echo ' -L$(SLB) $(LIBLSHL)' >> GNUmakefile
188echo ' ' >> GNUmakefile
189
190echo '# Building ExtSophya shared library' >> GNUmakefile
191echo '$(SLB)libextsophya.so : $(EXTPSLB)' >> GNUmakefile
192echo ' $(CMDTILSHL) ' >> GNUmakefile
193echo ' cd $(OBJ); \' >> GNUmakefile
194echo ' $(CMDSHLCXX) -o $(SLB)libextsophya.so \' >> GNUmakefile
195echo ' $(FGSHLACXX) $(ALLEXTOBJS) $(FGSHLNCXX)\' >> GNUmakefile
196echo ' -L$(SLB) -lsophya $(EXTLIB) $(LIBLSHL)' >> GNUmakefile
197echo ' ' >> GNUmakefile
198
199echo '# Building PI shared library' >> GNUmakefile
200echo '$(SLB)libPI.so : $(PIPSLB)' >> GNUmakefile
201echo ' $(CMDTILSHL) ' >> GNUmakefile
202echo ' cd $(OBJ); \' >> GNUmakefile
203echo ' $(CMDSHLCXX) -o $(SLB)libPI.so \' >> GNUmakefile
204echo ' $(FGSHLACXX) $(ALLPIOBJS) $(FGSHLNCXX) \' >> GNUmakefile
205echo ' -L$(SLB) -lsophya -lextsophya $(EXTLIB) $(XPILIBS) $(LIBLSHL)' >> GNUmakefile
206echo ' ' >> GNUmakefile
207
208
209cat >> GNUmakefile << __END__
210
211clean:
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
219mv GNUmakefile ../GNUmakefile
220
221echo '*** mkmf done ***'
222
Note: See TracBrowser for help on using the repository browser.