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

Last change on this file since 3202 was 3202, checked in by ansari, 18 years ago

Ajout decodage arguments -arch64/-sasz64/-nofpic/-boundcheck/-sodebug pour flags de machdefs.h, Reza 10/04/2007

  • Property svn:executable set to *
File size: 14.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 SOPMODOK = ( 1 1 1 1 1 1 1 1 1 )
10set SOPMOD = ( BaseTools SysTools SUtils TArray NTools HiStats SkyMap Samba SkyT )
11set ALLSOPLIBS = ( '-lBaseTools' '-lSysTools' '-lSUtils' '-lTArray' '-lNTools' '-lHiStats' '-lSkyMap' '-lSamba' '-lSkyT' )
12
13set SOPPIOK = ( 1 1 1 )
14set SOPPI = ( PI PIext PIGcont )
15set ALLPILIBS = ( '-lPI' '-lPIext' '-lPIGcont' )
16
17set SOPEXT = ( FitsIOServer IFFTW LinAlg XAstroPack )
18set EXTCURNAME = ( fits fftw lapack astro )
19set SOPEXTOK = ( 1 1 1 1 )
20set EXTINCNAME = ( FitsIO/fitsio.h FFTW/fftw3.h PASDEINC XAstro/astro.h )
21set EXTLIBNAME = ( libcfitsio.a libfftw3.a liblapack.a libxastro.a )
22set ALLEXTLIBS = ( '-lcfitsio' '-lfftw3' '-llapack -lblas' '-lxastro' )
23
24#FFTW2: set EXTINCNAME = ( FitsIO/fitsio.h FFTW/fftw.h PASDEINC XAstro/astro.h )
25#FFTW2: set EXTLIBNAME = ( libcfitsio.a libfftw.a liblapack.a libxastro.a )
26#FFTW2: set ALLEXTLIBS = ( '-lcfitsio' '-lfftw -lrfftw' '-llapack -lblas' '-lxastro' )
27
28set defextinc = ( /usr/include /usr/local/include )
29set defextlib = ( /usr/lib /usr/local/lib )
30
31
32#----------------------------------------------------------------------
33#### Decodage arguments
34set cmdline = "$0 $*"
35set extpath
36set extpathinc
37set extpathlib
38unset incln
39unset mincname
40unset arch64
41unset sasz64
42unset nofpic
43unset boundcheck
44unset sodebug
45unset usefftw2
46unset uselapack2
47unset singleslb
48while ( $#argv > 0 )
49
50if( "$1" == "-h" ) then
51 echo 'configure [-sbase SOPHYABASE] [-scxx SOPHYACXX] [-incln] [-minc mymake.inc] '
52 echo ' [-arch64] [-sasz64] [-nofpic] [-boundcheck] [-sodebug]'
53 echo ' [-extp dir1 -extp dir2 ...] [-extip dir1 -extip dir2 ... ] [-extlp dir1 -extlp dir2 ... ]'
54 echo ' [-noextlib -noext fits -noext fftw -noext lapack -noext astro]'
55 echo ' [-usefftw2 -uselapack2] [-singleslb]'
56 exit -1
57endif
58if( "$1" == "-sbase" ) then
59 setenv SOPHYABASE $2
60 shift
61endif
62if( "$1" == "-scxx" ) then
63 setenv SOPHYACXX $2
64 shift
65endif
66if( "$1" == "-incln" ) then
67 set incln
68endif
69if( "$1" == "-minc" ) then
70 set mincname = ( $2 )
71 shift
72endif
73if( "$1" == "-extp" ) then
74 set extpath = ( $extpath $2 )
75 shift
76endif
77if( "$1" == "-extip" ) then
78 set extpathinc = ( $extpathinc $2 )
79 shift
80endif
81if( "$1" == "-extlp" ) then
82 set extpathlib = ( $extpathlib $2 )
83 shift
84endif
85if( "$1" == "-noextlib" ) then
86 set i = 0
87 while ( $i < $#SOPEXTOK )
88 @ i += 1
89 set SOPEXTOK[$i] = 0
90 end
91endif
92if( "$1" == "-noext" ) then
93 set i = 0
94 while ( $i < $#EXTCURNAME )
95 @ i += 1
96 if( "$2" == "$EXTCURNAME[$i]" ) set SOPEXTOK[$i] = 0
97 end
98 shift
99endif
100if( "$1" == "-usefftw2" ) then
101# version FFTW 2 au lieu de V3
102 set usefftw2
103 set i = 0
104 while ( $i < $#EXTCURNAME )
105 @ i += 1
106 if( "fftw" == "$EXTCURNAME[$i]" ) then
107 set EXTINCNAME[$i] = 'FFTW/fftw.h'
108 set EXTLIBNAME[$i] = 'libfftw.a'
109 set ALLEXTLIBS[$i] = '-lfftw -lrfftw'
110 endif
111 end
112endif
113if( "$1" == "-uselapack2" ) then
114# version LAPACK 2 au lieu de V3
115 set uselapack2
116endif
117if( "$1" == "-singleslb" ) then
118# Pour utiliser une seule librairie libsophyaPIext.so au lieu
119# des 3 libsophya.so libextsophya.so libPI.so
120 set singleslb
121endif
122# Decodage options pour flags de machdefs.h
123# Liste de flags : SO_ARCH64 SO_NOFPIC SO_SASIZET64 SO_BOUNDCHECKING SOPHYA_DEBUG
124if( "$1" == "-arch64" ) then
125 set arch64
126endif
127if( "$1" == "-sasz64" ) then
128 set sasz64
129endif
130if( "$1" == "-nofpic" ) then
131 set nofpic
132endif
133if( "$1" == "-boundcheck" ) then
134 set boundcheck
135endif
136if( "$1" == "-sodebug" ) then
137 set sodebug
138endif
139
140
141shift
142end
143
144
145#----------------------------------------------------------------------
146#### Verification generale
147if( ! $?SOPHYABASE ) then
148 echo ERROR: define SOPHYABASE or use script arguments
149 exit -2
150endif
151if( ! $?SOPHYACXX ) then
152 echo ERROR: define SOPHYACXX or use script arguments
153 echo " SOPHYACXX define the name of the C++ compiler (ex: g++ cxx ...)"
154 exit -2
155endif
156if( ! $?TMPDIR ) setenv TMPDIR /tmp
157touch $TMPDIR/tmp_test
158if( $status != 0 ) then
159 echo ERROR: no write acces in temporary directory: $TMPDIR
160 echo '----> define TMPDIR environment variable: "setenv TMPDIR ..."'
161 exit -2
162endif
163rm -f $TMPDIR/tmp_test
164if( ! $?mincname ) then
165 set mincname = `uname`_${SOPHYACXX}_make.inc
166endif
167if( ! -e $mincname ) then
168 echo ERROR: file $mincname NOT found
169 exit -2
170endif
171if( ! -e ../BaseTools/machdefs_mkmf.h ) then
172 echo ERROR: file machdefs_mkmf.h NOT found in BaseTools
173 exit -2
174endif
175echo SOPEXTOK: $SOPEXTOK
176
177#----------------------------------------------------------------------
178#### creation des variables chemins sophya core
179echo " "
180echo ">>>>>> 1/ Creating directory tree under $SOPHYABASE "
181set sinc = $SOPHYABASE/include
182set slib = $SOPHYABASE/lib
183set sslb = $SOPHYABASE/slb
184set sobj = $SOPHYABASE/obj
185set sexe = $SOPHYABASE/exe
186set sconf = $sinc/SophyaConfInfo
187foreach d ( $sinc $slib $sslb $sobj $sexe $sconf )
188 if( ! -d $d ) then
189 mkdir $d
190 if( $status ) then
191 echo ERROR: creation of $d failed
192 exit -3
193 endif
194 echo Directory $d created
195 endif
196 touch $d/tmp_test
197 if( $status ) then
198 echo ERROR: no write acces to $d
199 exit -4
200 endif
201 rm -f $d/tmp_test
202end
203
204
205#----------------------------------------------------------------------
206#### Fichier confinfo - log e configure
207set conflog = $sconf/conf.log
208rm -f $conflog ; touch $conflog
209echo ' --- Log of SOPHYA configure script - Date= ' `date` >> $conflog
210echo "$cmdline" >> $conflog
211set inclistf = $sconf/include.list
212rm -f $inclistf ; touch $inclistf
213
214
215#----------------------------------------------------------------------
216#### liens ou copie des *.h
217echo " "
218if( $?incln ) then
219 echo ">>>>>> 2/ Creating symbolic link for include files in $sinc "
220else
221 echo ">>>>>> 2/ Copying include files to $sinc "
222endif
223
224cd ../ > /dev/null
225set srcd = `pwd`
226set cpln = "cp -p "
227if( $?incln ) set cpln = "ln -s -f "
228foreach d ( $SOPMOD $SOPEXT $SOPPI )
229 if ( -d $srcd/$d ) then
230 if ( $?incln ) then
231 echo Creating link to include files for module $d
232 else
233 echo Copying include files for module $d
234 endif
235
236 cd $srcd/$d;
237 set file = ( *.h )
238 cd $sinc; if( $status == 0 ) rm -f $file
239 # on vire le .h de $file si .h dans excludeinc du module
240 cd $srcd/$d
241 if( -e excludeinc ) then
242 if( `cat excludeinc | wc -l` > 0 ) then
243 set file
244 foreach f ( *.h )
245 grep -q "$f:r\.h" excludeinc
246 if( $status != 0 ) set file = ( $file $f )
247 end
248 endif
249 endif
250 # on copie ou link dans $sinc
251 if( `echo $file | wc -w` > 0 ) then
252 foreach f ( $file )
253 $cpln $srcd/$d/$f $sinc/$f
254 end
255 endif
256 echo $file >> $inclistf
257 endif
258end
259rm -f $sinc/machdefs_ac.h $sinc/machdefs_mkmf.h
260cd $srcd/BuildMgr/.
261
262
263#----------------------------------------------------------------------
264#### lien des .h des librairies externes
265echo " "
266echo ">>>>>> 3/ Include files for external libraries "
267set i = 0
268while ( $i < $#SOPEXT )
269 @ i += 1
270 if( "$EXTINCNAME[$i]" == "PASDEINC" ) continue
271 if( $SOPEXTOK[$i] <= 0 ) continue
272 set nom = $EXTINCNAME[$i]:t
273 set rac = $EXTINCNAME[$i]:h
274 if( -d ../$SOPEXT[$i] ) then
275 echo "Searching include file for $SOPEXT[$i] ..."
276 foreach d ( $extpathinc $extpath $defextinc )
277 set duminc = `find $d -name $nom -print -follow | head -1 `
278 set dumrep = $duminc:h
279 if ( "$dumrep" != "" ) then
280 rm -f $sinc/$rac
281 ln -f -s $dumrep $sinc/$rac
282 echo Includes for $SOPEXT[$i] found in $dumrep
283 break
284 endif
285 end
286 if ( "$dumrep" == "" ) then
287 echo WARNING: Includes for $SOPEXT[$i] NOT found
288 echo " Compilation of module $SOPEXT[$i] disabled"
289 set SOPEXTOK[$i] = 0
290 endif
291 endif
292end
293
294
295#----------------------------------------------------------------------
296#### liens des librairies externes
297echo " "
298echo ">>>>>> 4.1/ External libraries "
299set fpath = $TMPDIR/fpath
300rm -f $fpath; touch $fpath
301set extliblib
302set i = 0
303while ( $i < $#SOPEXT )
304 @ i += 1
305 if( "$EXTLIBNAME[$i]" == "PASDELIB" ) continue
306 if( $SOPEXTOK[$i] <= 0 ) continue
307 set nom = $EXTLIBNAME[$i]
308 if( -d ../$SOPEXT[$i] ) then
309 echo "Searching libraries path for $SOPEXT[$i] ..."
310 foreach d ( $extpathlib $extpath $defextlib )
311 set dumlib = `find $d -name $nom -print -follow | head -1 `
312 if ( "$dumlib" != "" ) then
313 echo "-L$dumlib:h" >> $fpath
314 set extliblib = ( $extliblib $ALLEXTLIBS[$i] )
315 break
316 endif
317 end
318 if ( "$dumlib" == "" ) then
319 echo WARNING: Libraries for $SOPEXT[$i] NOT found
320 echo " Check the generated make.inc file"
321 endif
322 endif
323end
324set extlibpath = `cat $fpath | sort -u`
325echo extlibpath= $extlibpath
326echo extliblib= $extliblib
327rm -f $fpath
328
329
330#----------------------------------------------------------------------
331#### Identification des librairies archives Sophya
332echo " "
333echo ">>>>>> 4.2/ Sophya libraries archives "
334set sopmodlib
335set i = 0
336while ( $i < $#SOPMOD )
337 @ i += 1
338 if( $SOPMODOK[$i] <= 0 ) continue
339 if( -d ../$SOPMOD[$i] ) then
340 set sopmodlib = ( $sopmodlib $ALLSOPLIBS[$i] )
341 else
342 echo "WARNING: module "$SOPMOD[$i]" not found"
343 endif
344end
345echo sopmodlib= $sopmodlib
346
347echo " "
348echo ">>>>>> 4.3/ PI-Sophya libraries archives "
349set soppilib
350set i = 0
351while ( $i < $#SOPPI )
352 @ i += 1
353 if( $SOPPIOK[$i] <= 0 ) continue
354 if( -d ../$SOPPI[$i] ) then
355 set soppilib = ( $soppilib $ALLPILIBS[$i] )
356 else
357 echo "WARNING: module "$SOPPI[$i]" not found"
358 endif
359end
360echo soppilib= $soppilib
361
362#----------------------------------------------------------------------
363#### Generation de sophyamake.inc
364# On le cree dans le repertoire temporaire d'abord
365set mfile = $sinc/sophyamake.inc
366rm -f $mfile
367echo " "
368echo ">>>>>> 5/ Creating $mfile from $mincname "
369echo "# -----------------------------------------------" > $mfile
370echo "# File make.inc - generated by SOPHYA configure" >> $mfile
371echo "# Date" `date` >> $mfile
372echo "# Seed file : $mincname " >> $mfile
373echo "# -----------------------------------------------" >> $mfile
374echo " " >> $mfile
375echo "# SOPHYA Base installation directory " >> $mfile
376echo "SOPHYABASE = $SOPHYABASE" >> $mfile
377echo " " >> $mfile
378echo 'SOPHYAINCP = $(SOPHYABASE)/include/' >> $mfile
379echo 'SOPHYAOBJP = $(SOPHYABASE)/obj/' >> $mfile
380echo 'SOPHYALIBP = $(SOPHYABASE)/lib/' >> $mfile
381echo 'SOPHYASLBP = $(SOPHYABASE)/slb/' >> $mfile
382echo 'SOPHYAEXEP = $(SOPHYABASE)/exe/' >> $mfile
383
384echo " " >> $mfile
385echo "# module libraries " >> $mfile
386echo "SOPMODLIBLIST = $sopmodlib" >> $mfile
387
388echo " " >> $mfile
389echo "# External libraries PATH " >> $mfile
390echo "SOPEXTLIBP = $extlibpath" >> $mfile
391echo "SOPEXTLIBLIST = $extliblib" >> $mfile
392
393echo " " >> $mfile
394echo "# PI libraries " >> $mfile
395echo "SOPPILIBLIST = $soppilib" >> $mfile
396
397echo " " >> $mfile
398cat $mincname >> $mfile
399
400rm -f $mfile:t
401ln -s $mfile $mfile:t
402
403
404#----------------------------------------------------------------------
405#### Copie de machdefs.h
406set mdefname = $TMPDIR/machdefs.h
407echo " "
408echo ">>>>>> 6.a/ Creating machdefs.h from BaseTools/machdefs_mkmf.h"
409rm -f $mdefname; touch $mdefname
410echo "/*** machdefs.h generated by SOPHYA configure ***/" >> $mdefname
411echo "#ifndef MACHDEFS_SEEN" >> $mdefname
412echo "#define MACHDEFS_SEEN" >> $mdefname
413echo "/*------ Code generation switch ---- */" >> $mdefname
414echo "/* System selector (uname) */" >> $mdefname
415set sname = `uname`
416echo "#ifndef $sname" >> $mdefname
417echo "#define $sname 1 " >> $mdefname
418echo "#endif" >> $mdefname
419
420if ( $?arch64 ) echo "#define SO_ARCH64 1" >> $mdefname
421if ( $?nofpic ) echo "#define SO_NOFPIC 1" >> $mdefname
422if ( $?sasz64 ) echo "#define SO_SASIZET64 1" >> $mdefname
423if ( $?boundcheck ) echo "#define SO_BOUNDCHECKING 1" >> $mdefname
424if ( $?sodebug ) echo "#define SOPHYA_DEBUG 1" >> $mdefname
425
426if ( "$sname" == "IRIX64" ) then
427# SGI_ARCH64 : compile avec -64 (en 64 bits)
428 echo "#define SGI_ARCH64 1 /* Compile avec -64 */" >> $mdefname
429 if ( "$SOPHYACXX" == "CC" ) then
430# __SGICC__ : flag indiquant que c'est le compilo CC de SGI
431 echo "#define __SGICC__ 1" >> $mdefname
432 endif
433endif
434
435
436echo " " >> $mdefname
437grep -v -e '#ifndef *MACHDEFS_SEEN' -e '#define *MACHDEFS_SEEN' ../BaseTools/machdefs_mkmf.h >> $mdefname
438# On ne copie que si machdefs.h est different
439if (-e $sinc/machdefs.h ) then
440 diff $mdefname $sinc/machdefs.h >& /dev/null
441 if ($status != 0) then
442 cp -f -p $mdefname $sinc/machdefs.h
443 echo " file $sinc/machdefs.h changed -> replaced"
444 else
445 echo " file $sinc/machdefs.h has not changed -> kept"
446 endif
447else
448 cp -f -p $mdefname $sinc/machdefs.h
449 echo " file $sinc/machdefs.h created"
450endif
451rm -f $mdefname
452
453
454#### Creation de sspvflags.h
455echo " "
456echo ">>>>>> 6.b/ Creating $sinc/sspvflags.h "
457rm -f $sinc/sspvflags.h; touch $sinc/sspvflags.h
458
459echo "#ifndef SSPVFLAGS_SEEN" >> $sinc/sspvflags.h
460echo "#define SSPVFLAGS_SEEN" >> $sinc/sspvflags.h
461echo " " >> $sinc/sspvflags.h
462echo "/*------ External libraries no-use flag ---- */" >> $sinc/sspvflags.h
463set i = 0
464while ( $i < $#SOPEXTOK )
465 @ i += 1
466 if( $SOPEXTOK[$i] > 0 ) continue
467 echo "#define SOPHYA_NO_$SOPEXT[$i]" >> $sinc/sspvflags.h
468end
469
470echo " " >> $sinc/sspvflags.h
471echo "/*------ Version selection flags ---- */" >> $sinc/sspvflags.h
472if( $?usefftw2 ) then
473 echo "#define FFTW_V2_EXTSOP" >> $sinc/sspvflags.h
474endif
475if( $?uselapack2 ) then
476 echo "#define LAPACK_V2_EXTSOP" >> $sinc/sspvflags.h
477endif
478echo " " >> $sinc/sspvflags.h
479echo "/*------ Use of single shared lib for SOPHYA+extlibs+PI ---- */" >> $sinc/sspvflags.h
480if( $?singleslb ) then
481 echo "#define SINGLESLB_SOPHYA_PI_EXT" >> $sinc/sspvflags.h
482endif
483echo " " >> $sinc/sspvflags.h
484echo "#endif " >> $sinc/sspvflags.h
485
486
487#----------------------------------------------------------------------
488#### Creation des fichiers contenant les listes d'objets et d'includes
489echo " "
490echo ">>>>>> 7/ Creating object list files for shared library creation "
491set objlistname = $sconf/libsophya.objlist
492echo " 7.a/ Creating $objlistname "
493rm -f $objlistname ; touch $objlistname
494foreach d ( $SOPMOD )
495 rm -f $sconf/$d.conf
496 if ( ! -d ../$d ) continue
497 cat ../$d/objlist.list >> $objlistname
498 touch $sconf/$d.conf
499end
500
501set objlistname = $sconf/libextsophya.objlist
502echo " 7.b/ Creating $objlistname "
503rm -f $objlistname ; touch $objlistname
504set i = 0
505while ( $i < $#SOPEXT )
506 @ i += 1
507 set d = $SOPEXT[$i]
508 rm -f $sconf/$d.conf
509 if( $SOPEXTOK[$i] <= 0 ) continue
510 if ( ! -d ../$d ) continue
511 cat ../$d/objlist.list >> $objlistname
512 touch $sconf/$d.conf
513end
514
515set objlistname = $sconf/libPI.objlist
516echo " 7.c/ Creating $objlistname "
517rm -f $objlistname ; touch $objlistname
518foreach d ( $SOPPI )
519 rm -f $sconf/$d.conf
520 if ( ! -d ../$d ) continue
521 cat ../$d/objlist.list >> $objlistname
522 touch $sconf/$d.conf
523end
524
525
526#----------------------------------------------------------------------
527exit 0
Note: See TracBrowser for help on using the repository browser.