source: Sophya/trunk/SophyaLib/BuildMgr/configure@ 2751

Last change on this file since 2751 was 2751, checked in by cmv, 20 years ago

gestion CXXCOMPILE-LIB-PROG cmv 20/05/05

  • Property svn:executable set to *
File size: 10.9 KB
Line 
1#!/bin/csh
2# SOPHYA configuration managment script
3# C. Magneville / R. Ansari - Mai 2005
4# Exemple: ./configure -sbase /laltmp/ansari/sbase/ -scxx cxx -extp /exp/planck/ExtLibs/Include/ \
5# -extp /exp/planck/ExtLibs/OSF1-cxx/
6
7#----------------------------------------------------------------------
8#### liste des modules
9set SOPMOD = ( BaseTools SysTools SUtils TArray NTools HiStats SkyMap Samba SkyT )
10set SOPPI = ( PI PIext PIGcont )
11
12set SOPEXT = ( FitsIOServer IFFTW LinAlg XAstroPack MinuitAdapt )
13set EXTCURNAME = ( fits fftw lapack astro minuit )
14set SOPEXTOK = ( 1 1 1 1 1 )
15set EXTINCNAME = ( FitsIO/fitsio.h FFTW/fftw.h PASDEINC XAstro/astro.h Cern/minuit.h )
16set EXTLIBNAME = ( libcfitsio.a libfftw.a liblapack.a libxastro.a libminuit.a )
17set ALLEXTLIBS = ( '-lcfitsio' '-lfftw -lrfftw' '-llapack -lblas' '-lxastro' '-lminuit' )
18
19set defextinc = ( ~ /usr/include /usr/local/include )
20set defextlib = ( ~ /usr/lib /usr/local/lib )
21
22
23#----------------------------------------------------------------------
24#### Decodage arguments
25set cmdline = "$0 $*"
26set extpath
27set extpathinc
28set extpathlib
29unset incln
30unset mincname
31while ( $#argv > 0 )
32
33if( "$1" == "-h" ) then
34 echo 'configure [-sbase SOPHYABASE] [-scxx SOPHYACXX] [-incln] [-minc mymake.inc] '
35 echo ' [-extp dir1 -extp dir2 ...] [-extip dir1 -extip dir2 ... ] [-extlp dir1 -extlp dir2 ... ]'
36 echo ' [-noextlib -noext fits -noext fftw -noext lapack -noext astro -noext minuit]'
37 exit -1
38endif
39if( "$1" == "-sbase" ) then
40 setenv SOPHYABASE $2
41 shift
42endif
43if( "$1" == "-scxx" ) then
44 setenv SOPHYACXX $2
45 shift
46endif
47if( "$1" == "-incln" ) then
48 set incln
49endif
50if( "$1" == "-minc" ) then
51 set mincname = ( $2 )
52 shift
53endif
54if( "$1" == "-extp" ) then
55 set extpath = ( $extpath $2 )
56 shift
57endif
58if( "$1" == "-extip" ) then
59 set extpathinc = ( $extpathinc $2 )
60 shift
61endif
62if( "$1" == "-extlp" ) then
63 set extpathlib = ( $extpathlib $2 )
64 shift
65endif
66if( "$1" == "-noextlib" ) then
67 set i = 0
68 while ( $i < $#SOPEXTOK )
69 @ i += 1
70 set SOPEXTOK[$i] = 0
71 end
72endif
73if( "$1" == "-noext" ) then
74 set i = 0
75 while ( $i < $#EXTCURNAME )
76 @ i += 1
77 if( "$2" == "$EXTCURNAME[$i]" ) set SOPEXTOK[$i] = 0
78 end
79 shift
80endif
81
82shift
83end
84
85
86#----------------------------------------------------------------------
87#### Verification generale
88if( ! $?SOPHYABASE ) then
89 echo ERROR: define SOPHYABASE or use script arguments
90 exit -2
91endif
92if( ! $?SOPHYACXX ) then
93 echo ERROR: define SOPHYACXX or use script arguments
94 echo " SOPHYACXX define the name of the C++ compiler (ex: g++ cxx ...)"
95 exit -2
96endif
97if( ! $?TMPDIR ) setenv TMPDIR /tmp
98touch $TMPDIR/tmp_test
99if( $status != 0 ) then
100 echo ERROR: no write acces in temporary directory: $TMPDIR
101 echo '----> define TMPDIR environment variable: "setenv TMPDIR ..."'
102 exit -2
103endif
104rm -f $TMPDIR/tmp_test
105if( ! $?mincname ) then
106 set mincname = `uname`_${SOPHYACXX}_make.inc
107endif
108if( ! -e $mincname ) then
109 echo ERROR: file $mincname NOT found
110 exit -2
111endif
112if( ! -e ../BaseTools/machdefs_mkmf.h ) then
113 echo ERROR: file machdefs_mkmf.h NOT found in BaseTools
114 exit -2
115endif
116echo SOPEXTOK: $SOPEXTOK
117
118#----------------------------------------------------------------------
119#### creation des variables chemins sophya core
120echo " "
121echo ">>>>>> 1/ Creating directory tree under $SOPHYABASE "
122set sinc = $SOPHYABASE/include
123set slib = $SOPHYABASE/lib
124set sslb = $SOPHYABASE/slb
125set sobj = $SOPHYABASE/obj
126set sexe = $SOPHYABASE/exe
127set sconf = $sinc/SophyaConfInfo
128foreach d ( $sinc $slib $sslb $sobj $sexe $sconf )
129 if( ! -d $d ) then
130 mkdir $d
131 if( $status ) then
132 echo ERROR: creation of $d failed
133 exit -3
134 endif
135 echo Directory $d created
136 endif
137 touch $d/tmp_test
138 if( $status ) then
139 echo ERROR: no write acces to $d
140 exit -4
141 endif
142 rm -f $d/tmp_test
143end
144
145
146#----------------------------------------------------------------------
147#### Fichier confinfo - log e configure
148set conflog = $sconf/conf.log
149rm -f $conflog ; touch $conflog
150echo ' --- Log of SOPHYA configure script - Date= ' `date` >> $conflog
151echo "$cmdline" >> $conflog
152set inclistf = $sconf/include.list
153rm -f $inclistf ; touch $inclistf
154
155
156#----------------------------------------------------------------------
157#### liens ou copie des *.h
158echo " "
159echo ">>>>>> 2/ Copying include files to $sinc "
160cd ../ > /dev/null
161set srcd = `pwd`
162set cpln = "cp -p "
163if( $?incln ) set cpln = "ln -s -f "
164foreach d ( $SOPMOD $SOPEXT $SOPPI )
165 if ( -d $srcd/$d ) then
166 if ( $?incln ) then
167 echo Creating link to include files for module $d
168 else
169 echo Copying include files for module $d
170 endif
171
172 cd $srcd/$d;
173 set file = ( *.h )
174 cd $sinc; if( $status == 0 ) rm -f $file
175 # on vire le .h de $file si .h dans excludeinc du module
176 cd $srcd/$d
177 if( -e excludeinc ) then
178 if( `cat excludeinc | wc -l` > 0 ) then
179 set file
180 foreach f ( *.h )
181 grep -q "$f:r\.h" excludeinc
182 if( $status != 0 ) set file = ( $file $f )
183 end
184 endif
185 endif
186 # on copie ou link dans $sinc
187 if( `echo $file | wc -w` > 0 ) then
188 foreach f ( $file )
189 $cpln $srcd/$d/$f $sinc/$f
190 end
191 endif
192 echo $file >> $inclistf
193 endif
194end
195cd $srcd/BuildMgr/.
196
197
198#----------------------------------------------------------------------
199#### lien des .h des librairies externes
200echo " "
201echo ">>>>>> 3/ Include files for external libraries "
202set i = 0
203while ( $i < $#SOPEXT )
204 @ i += 1
205 if( "$EXTINCNAME[$i]" == "PASDEINC" ) continue
206 if( $SOPEXTOK[$i] <= 0 ) continue
207 set nom = $EXTINCNAME[$i]:t
208 set rac = $EXTINCNAME[$i]:h
209 if( -d ../$SOPEXT[$i] ) then
210 echo "Searching include file for $SOPEXT[$i] ..."
211 foreach d ( $extpathinc $extpath $defextinc )
212 set duminc = `find $d -name $nom -print | head -1 `
213 set dumrep = $duminc:h
214 if ( "$dumrep" != "" ) then
215 rm -f $sinc/$rac
216 ln -f -s $dumrep $sinc/$rac
217 echo Includes for $SOPEXT[$i] found in $dumrep
218 break
219 endif
220 end
221 if ( "$dumrep" == "" ) then
222 echo WARNING: Includes for $SOPEXT[$i] NOT found
223 echo " Compilation of module $SOPEXT[$i] disabled"
224 set SOPEXTOK[$i] = 0
225 endif
226 endif
227end
228
229
230#----------------------------------------------------------------------
231#### liens des librairies externes
232echo " "
233echo ">>>>>> 4/ External libraries "
234set fpath = $TMPDIR/fpath
235rm -f $fpath; touch $fpath
236set extliblib
237set i = 0
238while ( $i < $#SOPEXT )
239 @ i += 1
240 if( "$EXTLIBNAME[$i]" == "PASDELIB" ) continue
241 if( $SOPEXTOK[$i] <= 0 ) continue
242 set nom = $EXTLIBNAME[$i]
243 if( -d ../$SOPEXT[$i] ) then
244 echo "Searching libraries path for $SOPEXT[$i] ..."
245 foreach d ( $extpathlib $extpath $defextlib )
246 set dumlib = `find $d -name $nom -print | head -1 `
247 if ( "$dumlib" != "" ) then
248 echo "-L$dumlib:h" >> $fpath
249 set extliblib = ( $extliblib $ALLEXTLIBS[$i] )
250 break
251 endif
252 end
253 if ( "$dumlib" == "" ) then
254 echo WARNING: Libraries for $SOPEXT[$i] NOT found
255 echo " Check the generated make.inc file"
256 endif
257 endif
258end
259set extlibpath = `cat $fpath | sort -u`
260echo extlibpath= $extlibpath
261echo extliblib= $extliblib
262rm -f $fpath
263
264
265#----------------------------------------------------------------------
266#### Generation de sophyamake.inc
267# On le cree dans le repertoire temporaire d'abord
268set mfile = $sinc/sophyamake.inc
269rm -f $mfile
270echo " "
271echo ">>>>>> 5/ Creating $mfile from $mincname "
272echo "# -----------------------------------------------" > $mfile
273echo "# File make.inc - generated by SOPHYA configure" >> $mfile
274echo "# Date" `date` >> $mfile
275echo "# Seed file : $mincname " >> $mfile
276echo "# -----------------------------------------------" >> $mfile
277echo " " >> $mfile
278echo "# SOPHYA Base installation directory " >> $mfile
279echo "SOPHYABASE = $SOPHYABASE" >> $mfile
280echo " " >> $mfile
281echo 'SOPHYAINCP = $(SOPHYABASE)/include/' >> $mfile
282echo 'SOPHYAOBJP = $(SOPHYABASE)/obj/' >> $mfile
283echo 'SOPHYALIBP = $(SOPHYABASE)/lib/' >> $mfile
284echo 'SOPHYASLBP = $(SOPHYABASE)/slb/' >> $mfile
285echo 'SOPHYAEXEP = $(SOPHYABASE)/exe/' >> $mfile
286
287echo " " >> $mfile
288echo "# External libraries PATH " >> $mfile
289echo "SOPEXTLIBP = $extlibpath" >> $mfile
290echo "SOPEXTLIBLIST = $extliblib" >> $mfile
291
292echo " " >> $mfile
293cat $mincname >> $mfile
294
295rm -f $mfile:t
296ln -s $mfile $mfile:t
297
298
299#----------------------------------------------------------------------
300#### Copie de machdefs.h
301set mdefname = $TMPDIR/machdefs.h
302echo " "
303echo ">>>>>> 6/ Creating machdefs.h from BaseTools/machdefs_mkmf.h"
304rm -f $mdefname; touch $mdefname
305echo "/*** machdefs.h generated by SOPHYA configure ***/" >> $mdefname
306echo "#ifndef MACHDEFS_SEEN" >> $mdefname
307echo "#define MACHDEFS_SEEN" >> $mdefname
308echo "/*------ Code generation switch ---- */" >> $mdefname
309echo "/* System selector (uname) */" >> $mdefname
310set sname = `uname`
311echo "#ifndef $sname" >> $mdefname
312echo "#define $sname 1 " >> $mdefname
313echo "#endif" >> $mdefname
314echo "/* #define SO_BOUNDCHECKING 1 */" >> $mdefname
315
316echo " " >> $mdefname
317echo "/*------ External libraries no-use flag ---- */" >> $mdefname
318set i = 0
319while ( $i < $#SOPEXTOK )
320 @ i += 1
321 if( $SOPEXTOK[$i] > 0 ) continue
322 echo "#define SOPHYA_NO_$SOPEXT[$i]" >> $mdefname
323end
324
325echo " " >> $mdefname
326grep -v -e '#ifndef *MACHDEFS_SEEN' -e '#define *MACHDEFS_SEEN' ../BaseTools/machdefs_mkmf.h >> $mdefname
327# On ne copie que si machdefs.h est different
328if (-e $sinc/machdefs.h ) then
329 diff $mdefname $sinc/machdefs.h >& /dev/null
330 if ($status != 0) then
331 cp -f -p $mdefname $sinc/machdefs.h
332 echo " file $sinc/machdefs.h changed -> replaced"
333 else
334 echo " file $sinc/machdefs.h has not changed -> kept"
335 endif
336else
337 cp -f -p $mdefname $sinc/machdefs.h
338 echo " file $sinc/machdefs.h created"
339endif
340rm -f $mdefname
341
342
343#----------------------------------------------------------------------
344#### Creation des fichiers contenant les listes d'objets et d'includes
345echo " "
346echo ">>>>>> 7/ Creating object list files for shared library creation "
347set objlistname = $sconf/libsophya.objlist
348echo " 7.a/ Creating $objlistname "
349rm -f $objlistname ; touch $objlistname
350foreach d ( $SOPMOD )
351 rm -f $sconf/$d.conf
352 if ( ! -d ../$d ) continue
353 cat ../$d/objlist.list >> $objlistname
354 touch $sconf/$d.conf
355end
356
357set objlistname = $sconf/libextsophya.objlist
358echo " 7.b/ Creating $objlistname "
359rm -f $objlistname ; touch $objlistname
360set i = 0
361while ( $i < $#SOPEXT )
362 @ i += 1
363 set d = $SOPEXT[$i]
364 rm -f $sconf/$d.conf
365 if( $SOPEXTOK[$i] <= 0 ) continue
366 if ( ! -d ../$d ) continue
367 cat ../$d/objlist.list >> $objlistname
368 touch $sconf/$d.conf
369end
370
371set objlistname = $sconf/libPI.objlist
372echo " 7.c/ Creating $objlistname "
373rm -f $objlistname ; touch $objlistname
374foreach d ( $SOPPI )
375 rm -f $sconf/$d.conf
376 if ( ! -d ../$d ) continue
377 cat ../$d/objlist.list >> $objlistname
378 touch $sconf/$d.conf
379end
380
381
382#----------------------------------------------------------------------
383exit 0
Note: See TracBrowser for help on using the repository browser.