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

Last change on this file since 830 was 823, checked in by ansari, 25 years ago

MAJ Makefile mkmf, etc ... Reza 06/04/2000

  • Property svn:executable set to *
File size: 7.9 KB
Line 
1#!/bin/csh
2# $Id: mkmf,v 1.11 2000-04-06 09:50:06 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
69# echo 'LIBS = -L$(LIB)' `sed -e 's/.*/-l&/' libdirs` '-lm' >> GNUmakefile
70echo 'LIBS = -L$(LIB)' `sed -e 's/.*/-l&/' libdirs` >> GNUmakefile
71# echo 'LIBG = -L$(GLB) -lstdc++' >> GNUmakefile
72# echo 'ifeq ($(HOSTTYPE), powerpc)' >> GNUmakefile
73# echo ' LIBG = -L$(GLB)' >> GNUmakefile
74# echo 'endif' >> GNUmakefile
75
76cat >> GNUmakefile <<EOF
77
78defaut: libs
79
80all: libs extlibs PI
81
82libs: cxxlibs
83
84extlibs: cxxextlibs
85
86EOF
87
88# Dans cet ordre pour les templates de cxx, a cause des dependances
89# pour instantiation automatique/manuels
90
91echo 'cxxlibs: ' $modules_pres >> GNUmakefile
92echo ' ' >> GNUmakefile
93echo 'cxxextlibs: ' $extmodules_pres >> GNUmakefile
94
95
96# Attention, ne pas changer l'ordre de libnames dependances cxx ?????
97set libnames = ($modules_pres $extmodules_pres)
98set i = 1
99set j = $#libnames ; @ j--
100while ($i <= $#libnames)
101 set f = $libnames[$i]
102 set k = $i ; @ k++
103 if ( -d ../$f ) then
104 set cmd = "./mkmflib $f "
105 echo "mkmf: Creation makefile lib $f"
106 echo " execution $cmd"
107 $DODBG $cmd
108 endif
109 echo '.PHONY: ' $f >> GNUmakefile
110 echo $f':' >> GNUmakefile
111 echo ' if [ -d '$f' ] ; then cd ' $f '; $(MAKE) ; fi' >> GNUmakefile
112 echo ' ' >> GNUmakefile
113 @ i++
114end
115
116
117if ( -d ../PI ) then
118 set cmd = './mkmfPI PI SysTools'
119 echo "mkmf: Creation makefile lib PI"
120 echo " execution $cmd"
121 $DODBG $cmd
122endif
123if ( -d ../PIext ) then
124 set cmd = "./mkmfPI PIext $libnames PI"
125 echo "mkmf: Creation makefile lib PIext"
126 echo " execution $cmd"
127 $DODBG $cmd
128endif
129echo '.PHONY: PI' >> GNUmakefile
130echo 'PI:' >> GNUmakefile
131echo ' if [ -d PI ] ; then cd PI ; $(MAKE) ; fi' >> GNUmakefile
132echo ' if [ -d PIext ] ; then cd PIext ; $(MAKE) ; fi' >> GNUmakefile
133
134
135echo 'mkmf: Writing shared library building part of the makefile :'
136
137echo '# Shared library creation part of the Makefile' >> GNUmakefile
138echo ' ' >> GNUmakefile
139echo '# List of libraries (.a)' >> GNUmakefile
140echo 'PSLB = ' $module_libnames >> GNUmakefile
141echo 'EXTPSLB = ' $extmodule_libnames >> GNUmakefile
142echo 'PIPSLB = $(LIB)libPI.a $(LIB)libPIext.a' >> GNUmakefile
143echo '# List of external library references' >> GNUmakefile
144echo 'EXTLIB = -L$(EXTLIBPATH)' $extlib_list >> GNUmakefile
145echo 'EXTSLB = -L$(EXTSLBPATH)' $extslb_list >> GNUmakefile
146echo 'XPILIBS = $(LIBXPIPATH) $(LIBXPILIST)' >> GNUmakefile
147echo '' >> GNUmakefile
148echo '# main dependence list' >> GNUmakefile
149echo 'slball : slb slbext slbpi ' >> GNUmakefile
150echo 'slb : $(SLB)libsophya.so ' >> GNUmakefile
151echo 'slbext : $(SLB)libextsophya.so ' >> GNUmakefile
152echo 'slbpi : $(SLB)libPI.so' >> GNUmakefile
153echo ' ' >> GNUmakefile
154
155echo '# List of .o files for each module' >> GNUmakefile
156set objalls = ''
157foreach f ($modules_pres)
158 echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)' >> GNUmakefile
159 set objalls = ( $objalls '$(OBJ'$f')' )
160end
161echo 'ALLOBJS =' $objalls >> GNUmakefile
162echo ' ' >> GNUmakefile
163
164echo '# List of .o files modules with reference to external libraries' >> GNUmakefile
165set objalls = ''
166foreach f ($extmodules_pres)
167 echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)' >> GNUmakefile
168 set objalls = ( $objalls '$(OBJ'$f')' )
169end
170echo 'ALLEXTOBJS =' $objalls >> GNUmakefile
171echo ' ' >> GNUmakefile
172
173echo '# List of .o files for PI modules ' >> GNUmakefile
174set objalls = ''
175foreach f (PI PIext)
176 echo 'OBJ'$f '= $(shell echo' '`cat' "./$f/$f.o.list" '`)' >> GNUmakefile
177 set objalls = ( $objalls '$(OBJ'$f')' )
178end
179echo 'ALLPIOBJS =' $objalls >> GNUmakefile
180echo ' ' >> GNUmakefile
181
182echo '# Building Sophya shared library' >> GNUmakefile
183echo '$(SLB)libsophya.so : $(PSLB)' >> GNUmakefile
184echo ' $(CMDTILSHL) ' >> GNUmakefile
185echo ' cd $(OBJ); \' >> GNUmakefile
186echo ' $(CMDSHLCXX) -o $(SLB)libsophya.so \' >> GNUmakefile
187echo ' $(FGSHLACXX) $(ALLOBJS) $(FGSHLNCXX)\' >> GNUmakefile
188echo ' -L$(SLB) $(LIBLSHL)' >> GNUmakefile
189echo ' ' >> GNUmakefile
190
191echo '# Building ExtSophya shared library' >> GNUmakefile
192echo '$(SLB)libextsophya.so : $(EXTPSLB)' >> GNUmakefile
193echo ' $(CMDTILSHL) ' >> GNUmakefile
194echo ' cd $(OBJ); \' >> GNUmakefile
195echo ' $(CMDSHLCXX) -o $(SLB)libextsophya.so \' >> GNUmakefile
196echo ' $(FGSHLACXX) $(ALLEXTOBJS) $(FGSHLNCXX)\' >> GNUmakefile
197echo ' -L$(SLB) -lsophya $(EXTLIB) $(LIBLSHL)' >> GNUmakefile
198echo ' ' >> GNUmakefile
199
200echo '# Building PI shared library' >> GNUmakefile
201echo '$(SLB)libPI.so : $(PIPSLB)' >> GNUmakefile
202echo ' $(CMDTILSHL) ' >> GNUmakefile
203echo ' cd $(OBJ); \' >> GNUmakefile
204echo ' $(CMDSHLCXX) -o $(SLB)libPI.so \' >> GNUmakefile
205echo ' $(FGSHLACXX) $(ALLPIOBJS) $(FGSHLNCXX) \' >> GNUmakefile
206echo ' -L$(SLB) -lsophya -lextsophya $(EXTLIB) $(XPILIBS) $(LIBLSHL)' >> GNUmakefile
207echo ' ' >> GNUmakefile
208
209
210cat >> GNUmakefile << __END__
211
212clean:
213 if [ -d \$(LIB) ] ; then cd \$(LIB)/. ; rm -f *.a ; fi
214 if [ -d \$(SLB) ] ; then cd \$(SLB)/. ; rm -f *.so ; fi
215 if [ -d \$(OBJ) ] ; then cd \$(OBJ)/. ; rm -f *.o rm -rf cxxrep* ; fi
216# if [ -d PI ] ; then cd PI/. ; \$(MAKE) clean ; fi
217
218__END__
219
220mv GNUmakefile ../GNUmakefile
221
222echo '*** mkmf done ***'
223
Note: See TracBrowser for help on using the repository browser.