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

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

Corrections dans configure (gestion flag -arch64) + nettoyage IRIX64.inc , Reza 12/04/2007

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