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

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

Petite modif configure pour gestion -arch64 sur AIX (ar -X 64) , Reza 14/04/2007

  • Property svn:executable set to *
File size: 16.5 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" ) then
424 if ( ("$SOPHYACXX" == "xlC" ) || ("$SOPHYACXX" == "xlc" ) ) set a64cf = '-q64'
425 echo "/ARFLAGS/s/-rcs/-rcs -X 64/" >> $sprgfile
426 endif
427 set scmd = "/FLAGS/s/CNFPHFLF/$a64cf $compopt/g"
428endif
429echo $scmd > $sprgfile
430if ( $?nofpic ) echo "s/-fPIC/ /g" >> $sprgfile
431if( $?slballinone ) then
432 echo "/SOPHYAALLSLBLIST/s/-lPI -lextsophya -lsophya/-lAsophyaextPI/" >> $sprgfile
433 echo "/SOPHYAEXTSLBLIST/s/-lextsophya -lsophya/-lAsophyaextPI/" >> $sprgfile
434endif
435set scmd = "sed -f $sprgfile"
436set mftmp = $TMPDIR/sopmake.inc
437cp $mfile $mftmp
438sed -f $sprgfile $mftmp > $mfile
439rm -f $sprgfile $mftmp
440# --- FIN de gestion des flags modifiants les options de compilation (par sed)
441
442rm -f $mfile:t
443ln -s $mfile $mfile:t
444
445
446#----------------------------------------------------------------------
447#### Copie de machdefs.h
448set mdefname = $TMPDIR/machdefs.h
449echo " "
450echo ">>>>>> 6.a/ Creating machdefs.h from BaseTools/machdefs_mkmf.h"
451rm -f $mdefname; touch $mdefname
452echo "/*** machdefs.h generated by SOPHYA configure ***/" >> $mdefname
453echo "#ifndef MACHDEFS_SEEN" >> $mdefname
454echo "#define MACHDEFS_SEEN" >> $mdefname
455echo "/*------ Code generation switch ---- */" >> $mdefname
456echo "/* System selector (uname) */" >> $mdefname
457# Fait avant - set sname = `uname`
458echo "#ifndef $sname" >> $mdefname
459echo "#define $sname 1 " >> $mdefname
460echo "#endif" >> $mdefname
461
462## Definition de flags de compilation en fonction des options de configure
463if ( $?arch64 ) echo "#define SO_ARCH64 1" >> $mdefname
464if ( $?sasz64 ) echo "#define SO_SASIZET64 1" >> $mdefname
465if ( $?nofpic ) echo "#define SO_NOFPIC 1" >> $mdefname
466if ( $?nothsafe ) echo "#define SO_NOTHSAFE 1" >> $mdefname
467if ( $?boundcheck ) echo "#define SO_BOUNDCHECKING 1" >> $mdefname
468if ( $?sodebug ) echo "#define SOPHYA_DEBUG 1" >> $mdefname
469
470if ( "$sname" == "IRIX64" ) then
471 if ( "$SOPHYACXX" == "CC" ) then
472# __SGICC__ : flag indiquant que c'est le compilo CC de SGI
473 echo "#define __SGICC__ 1" >> $mdefname
474 endif
475endif
476
477
478echo " " >> $mdefname
479grep -v -e '#ifndef *MACHDEFS_SEEN' -e '#define *MACHDEFS_SEEN' ../BaseTools/machdefs_mkmf.h >> $mdefname
480# On ne copie que si machdefs.h est different
481if (-e $sinc/machdefs.h ) then
482 diff $mdefname $sinc/machdefs.h >& /dev/null
483 if ($status != 0) then
484 cp -f -p $mdefname $sinc/machdefs.h
485 echo " file $sinc/machdefs.h changed -> replaced"
486 else
487 echo " file $sinc/machdefs.h has not changed -> kept"
488 endif
489else
490 cp -f -p $mdefname $sinc/machdefs.h
491 echo " file $sinc/machdefs.h created"
492endif
493rm -f $mdefname
494
495
496#### Creation de sspvflags.h
497echo " "
498echo ">>>>>> 6.b/ Creating $sinc/sspvflags.h "
499rm -f $sinc/sspvflags.h; touch $sinc/sspvflags.h
500
501echo "#ifndef SSPVFLAGS_SEEN" >> $sinc/sspvflags.h
502echo "#define SSPVFLAGS_SEEN" >> $sinc/sspvflags.h
503echo " " >> $sinc/sspvflags.h
504echo "/*------ External libraries no-use flag ---- */" >> $sinc/sspvflags.h
505set i = 0
506while ( $i < $#SOPEXTOK )
507 @ i += 1
508 if( $SOPEXTOK[$i] > 0 ) continue
509 echo "#define SOPHYA_NO_$SOPEXT[$i]" >> $sinc/sspvflags.h
510end
511
512echo " " >> $sinc/sspvflags.h
513echo "/*------ Version selection flags ---- */" >> $sinc/sspvflags.h
514if( $?usefftw2 ) then
515 echo "#define FFTW_V2_EXTSOP" >> $sinc/sspvflags.h
516endif
517if( $?uselapack2 ) then
518 echo "#define LAPACK_V2_EXTSOP" >> $sinc/sspvflags.h
519endif
520echo " " >> $sinc/sspvflags.h
521echo "/*------ Use of single shared lib for SOPHYA+extlibs+PI ---- */" >> $sinc/sspvflags.h
522if( $?slballinone ) then
523 echo "#define SO_SLBALLINONE " >> $sinc/sspvflags.h
524endif
525echo " " >> $sinc/sspvflags.h
526echo "#endif " >> $sinc/sspvflags.h
527
528
529#----------------------------------------------------------------------
530#### Creation des fichiers contenant les listes d'objets et d'includes
531echo " "
532echo ">>>>>> 7/ Creating object list files for shared library creation "
533set objlistname = $sconf/libsophya.objlist
534echo " 7.a/ Creating $objlistname "
535rm -f $objlistname ; touch $objlistname
536foreach d ( $SOPMOD )
537 rm -f $sconf/$d.conf
538 if ( ! -d ../$d ) continue
539 cat ../$d/objlist.list >> $objlistname
540 touch $sconf/$d.conf
541end
542
543set objlistname = $sconf/libextsophya.objlist
544echo " 7.b/ Creating $objlistname "
545rm -f $objlistname ; touch $objlistname
546set i = 0
547while ( $i < $#SOPEXT )
548 @ i += 1
549 set d = $SOPEXT[$i]
550 rm -f $sconf/$d.conf
551 if( $SOPEXTOK[$i] <= 0 ) continue
552 if ( ! -d ../$d ) continue
553 cat ../$d/objlist.list >> $objlistname
554 touch $sconf/$d.conf
555end
556
557set objlistname = $sconf/libPI.objlist
558echo " 7.c/ Creating $objlistname "
559rm -f $objlistname ; touch $objlistname
560set i = 0
561while ( $i < $#SOPPI )
562 @ i += 1
563 set d = $SOPPI[$i]
564 rm -f $sconf/$d.conf
565 if( $SOPPIOK[$i] <= 0 ) continue
566 if ( ! -d ../$d ) continue
567 cat ../$d/objlist.list >> $objlistname
568 touch $sconf/$d.conf
569end
570
571
572#----------------------------------------------------------------------
573exit 0
Note: See TracBrowser for help on using the repository browser.