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

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

Mise en place nouveau schema de creation des Makefile et shared-libs , Reza 25/02/2000

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