[2720] | 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 |
|
---|
[2724] | 7 | #----------------------------------------------------------------------
|
---|
| 8 | #### liste des modules
|
---|
[2720] | 9 | set SOPMOD = ( BaseTools SysTools SUtils TArray NTools HiStats SkyMap Samba SkyT )
|
---|
| 10 | set SOPPI = ( PI PIext PIGcont )
|
---|
| 11 |
|
---|
[2724] | 12 | set SOPEXT = ( FitsIOServer IFFTW LinAlg XAstroPack MinuitAdapt )
|
---|
| 13 | set EXTCURNAME = ( fits fftw lapack astro minuit )
|
---|
| 14 | set SOPEXTOK = ( 1 1 1 1 1 )
|
---|
| 15 | set EXTINCNAME = ( FitsIO/fitsio.h FFTW/fftw.h PASDEINC XAstro/astro.h Cern/minuit.h )
|
---|
| 16 | set EXTLIBNAME = ( libcfitsio.a libfftw.a liblapack.a libxastro.a libminuit.a )
|
---|
| 17 | set ALLEXTLIBS = ( '-lcfitsio' '-lfftw -lrfftw' '-llapack -lblas' '-lxastro' '-lminuit' )
|
---|
[2720] | 18 |
|
---|
| 19 | set defextinc = ( ~ /usr/include /usr/local/include )
|
---|
| 20 | set defextlib = ( ~ /usr/lib /usr/local/lib )
|
---|
| 21 |
|
---|
[2724] | 22 |
|
---|
| 23 | #----------------------------------------------------------------------
|
---|
| 24 | #### Decodage arguments
|
---|
[2720] | 25 | set cmdline = "$0 $*"
|
---|
| 26 | set extpath
|
---|
[2724] | 27 | set extpathinc
|
---|
| 28 | set extpathlib
|
---|
[2720] | 29 | unset incln
|
---|
| 30 | unset mincname
|
---|
| 31 | while ( $#argv > 0 )
|
---|
| 32 |
|
---|
| 33 | if( "$1" == "-h" ) then
|
---|
[2724] | 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 ... ]'
|
---|
[2739] | 36 | echo ' [-noextlib -noext fits -noext fftw -noext lapack -noext astro -noext minuit]'
|
---|
[2720] | 37 | exit -1
|
---|
| 38 | endif
|
---|
| 39 | if( "$1" == "-sbase" ) then
|
---|
| 40 | setenv SOPHYABASE $2
|
---|
| 41 | shift
|
---|
| 42 | endif
|
---|
| 43 | if( "$1" == "-scxx" ) then
|
---|
| 44 | setenv SOPHYACXX $2
|
---|
| 45 | shift
|
---|
| 46 | endif
|
---|
| 47 | if( "$1" == "-incln" ) then
|
---|
| 48 | set incln
|
---|
| 49 | endif
|
---|
[2724] | 50 | if( "$1" == "-minc" ) then
|
---|
| 51 | set mincname = ( $2 )
|
---|
| 52 | shift
|
---|
| 53 | endif
|
---|
[2720] | 54 | if( "$1" == "-extp" ) then
|
---|
| 55 | set extpath = ( $extpath $2 )
|
---|
| 56 | shift
|
---|
| 57 | endif
|
---|
[2724] | 58 | if( "$1" == "-extip" ) then
|
---|
| 59 | set extpathinc = ( $extpathinc $2 )
|
---|
[2720] | 60 | shift
|
---|
| 61 | endif
|
---|
[2724] | 62 | if( "$1" == "-extlp" ) then
|
---|
| 63 | set extpathlib = ( $extpathlib $2 )
|
---|
| 64 | shift
|
---|
| 65 | endif
|
---|
[2739] | 66 | if( "$1" == "-noextlib" ) then
|
---|
| 67 | set i = 0
|
---|
| 68 | while ( $i < $#SOPEXTOK )
|
---|
| 69 | @ i += 1
|
---|
| 70 | set SOPEXTOK[$i] = 0
|
---|
| 71 | end
|
---|
| 72 | endif
|
---|
[2724] | 73 | if( "$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
|
---|
| 80 | endif
|
---|
[2720] | 81 |
|
---|
| 82 | shift
|
---|
| 83 | end
|
---|
| 84 |
|
---|
[2724] | 85 |
|
---|
| 86 | #----------------------------------------------------------------------
|
---|
| 87 | #### Verification generale
|
---|
[2720] | 88 | if( ! $?SOPHYABASE ) then
|
---|
| 89 | echo ERROR: define SOPHYABASE or use script arguments
|
---|
| 90 | exit -2
|
---|
| 91 | endif
|
---|
| 92 | if( ! $?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
|
---|
| 96 | endif
|
---|
| 97 | if( ! $?TMPDIR ) setenv TMPDIR /tmp
|
---|
| 98 | touch $TMPDIR/tmp_test
|
---|
| 99 | if( $status != 0 ) then
|
---|
| 100 | echo ERROR: no write acces in temporary directory: $TMPDIR
|
---|
| 101 | echo '----> define TMPDIR environment variable: "setenv TMPDIR ..."'
|
---|
| 102 | exit -2
|
---|
| 103 | endif
|
---|
[2724] | 104 | rm -f $TMPDIR/tmp_test
|
---|
[2720] | 105 | if( ! $?mincname ) then
|
---|
| 106 | set mincname = `uname`_${SOPHYACXX}_make.inc
|
---|
| 107 | endif
|
---|
| 108 | if( ! -e $mincname ) then
|
---|
| 109 | echo ERROR: file $mincname NOT found
|
---|
| 110 | exit -2
|
---|
| 111 | endif
|
---|
| 112 | if( ! -e ../BaseTools/machdefs_mkmf.h ) then
|
---|
| 113 | echo ERROR: file machdefs_mkmf.h NOT found in BaseTools
|
---|
| 114 | exit -2
|
---|
| 115 | endif
|
---|
[2724] | 116 | echo SOPEXTOK: $SOPEXTOK
|
---|
[2720] | 117 |
|
---|
[2724] | 118 | #----------------------------------------------------------------------
|
---|
| 119 | #### creation des variables chemins sophya core
|
---|
[2720] | 120 | echo " "
|
---|
| 121 | echo ">>>>>> 1/ Creating directory tree under $SOPHYABASE "
|
---|
| 122 | set sinc = $SOPHYABASE/include
|
---|
| 123 | set slib = $SOPHYABASE/lib
|
---|
| 124 | set sslb = $SOPHYABASE/slb
|
---|
| 125 | set sobj = $SOPHYABASE/obj
|
---|
| 126 | set sexe = $SOPHYABASE/exe
|
---|
| 127 | set sconf = $sinc/SophyaConfInfo
|
---|
| 128 | foreach 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
|
---|
| 143 | end
|
---|
| 144 |
|
---|
[2724] | 145 |
|
---|
| 146 | #----------------------------------------------------------------------
|
---|
| 147 | #### Fichier confinfo - log e configure
|
---|
[2720] | 148 | set conflog = $sconf/conf.log
|
---|
| 149 | rm -f $conflog ; touch $conflog
|
---|
| 150 | echo ' --- Log of SOPHYA configure script - Date= ' `date` >> $conflog
|
---|
| 151 | echo "$cmdline" >> $conflog
|
---|
| 152 | set inclistf = $sconf/include.list
|
---|
| 153 | rm -f $inclistf ; touch $inclistf
|
---|
| 154 |
|
---|
[2724] | 155 |
|
---|
| 156 | #----------------------------------------------------------------------
|
---|
| 157 | #### liens ou copie des *.h
|
---|
[2720] | 158 | echo " "
|
---|
| 159 | echo ">>>>>> 2/ Copying include files to $sinc "
|
---|
[2724] | 160 | cd ../ > /dev/null
|
---|
[2720] | 161 | set srcd = `pwd`
|
---|
[2724] | 162 | set cpln = "cp -p "
|
---|
| 163 | if( $?incln ) set cpln = "ln -s -f "
|
---|
[2720] | 164 | foreach d ( $SOPMOD $SOPEXT $SOPPI )
|
---|
[2724] | 165 | if ( -d $srcd/$d ) then
|
---|
[2726] | 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 |
|
---|
[2724] | 172 | cd $srcd/$d;
|
---|
[2720] | 173 | set file = ( *.h )
|
---|
[2724] | 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 )
|
---|
[2739] | 181 | grep -q "$f:r\.h" excludeinc
|
---|
[2724] | 182 | if( $status != 0 ) set file = ( $file $f )
|
---|
| 183 | end
|
---|
| 184 | endif
|
---|
[2720] | 185 | endif
|
---|
[2724] | 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
|
---|
[2720] | 192 | echo $file >> $inclistf
|
---|
| 193 | endif
|
---|
| 194 | end
|
---|
[2724] | 195 | cd $srcd/BuildMgr/.
|
---|
[2720] | 196 |
|
---|
| 197 |
|
---|
[2724] | 198 | #----------------------------------------------------------------------
|
---|
| 199 | #### lien des .h des librairies externes
|
---|
[2720] | 200 | echo " "
|
---|
| 201 | echo ">>>>>> 3/ Include files for external libraries "
|
---|
| 202 | set i = 0
|
---|
| 203 | while ( $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] ..."
|
---|
[2724] | 211 | foreach d ( $extpathinc $extpath $defextinc )
|
---|
[2720] | 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
|
---|
| 227 | end
|
---|
| 228 |
|
---|
[2724] | 229 |
|
---|
| 230 | #----------------------------------------------------------------------
|
---|
| 231 | #### liens des librairies externes
|
---|
[2720] | 232 | echo " "
|
---|
| 233 | echo ">>>>>> 4/ External libraries "
|
---|
| 234 | set fpath = $TMPDIR/fpath
|
---|
| 235 | rm -f $fpath; touch $fpath
|
---|
| 236 | set extliblib
|
---|
| 237 | set i = 0
|
---|
| 238 | while ( $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] ..."
|
---|
[2724] | 245 | foreach d ( $extpathlib $extpath $defextlib )
|
---|
[2720] | 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
|
---|
| 258 | end
|
---|
| 259 | set extlibpath = `cat $fpath | sort -u`
|
---|
| 260 | echo extlibpath= $extlibpath
|
---|
| 261 | echo extliblib= $extliblib
|
---|
[2724] | 262 | rm -f $fpath
|
---|
[2720] | 263 |
|
---|
[2724] | 264 |
|
---|
| 265 | #----------------------------------------------------------------------
|
---|
| 266 | #### Generation de sophyamake.inc
|
---|
| 267 | # On le cree dans le repertoire temporaire d'abord
|
---|
[2720] | 268 | set mfile = $sinc/sophyamake.inc
|
---|
[2724] | 269 | rm -f $mfile
|
---|
[2720] | 270 | echo " "
|
---|
[2724] | 271 | echo ">>>>>> 5/ Creating $mfile from $mincname "
|
---|
[2720] | 272 | echo "# -----------------------------------------------" > $mfile
|
---|
| 273 | echo "# File make.inc - generated by SOPHYA configure" >> $mfile
|
---|
| 274 | echo "# Date" `date` >> $mfile
|
---|
| 275 | echo "# Seed file : $mincname " >> $mfile
|
---|
| 276 | echo "# -----------------------------------------------" >> $mfile
|
---|
| 277 | echo " " >> $mfile
|
---|
| 278 | echo "# SOPHYA Base installation directory " >> $mfile
|
---|
| 279 | echo "SOPHYABASE = $SOPHYABASE" >> $mfile
|
---|
| 280 | echo " " >> $mfile
|
---|
| 281 | echo 'SOPHYAINCP = $(SOPHYABASE)/include/' >> $mfile
|
---|
| 282 | echo 'SOPHYAOBJP = $(SOPHYABASE)/obj/' >> $mfile
|
---|
| 283 | echo 'SOPHYALIBP = $(SOPHYABASE)/lib/' >> $mfile
|
---|
| 284 | echo 'SOPHYASLBP = $(SOPHYABASE)/slb/' >> $mfile
|
---|
| 285 | echo 'SOPHYAEXEP = $(SOPHYABASE)/exe/' >> $mfile
|
---|
| 286 |
|
---|
| 287 | echo " " >> $mfile
|
---|
| 288 | echo "# External libraries PATH " >> $mfile
|
---|
| 289 | echo "SOPEXTLIBP = $extlibpath" >> $mfile
|
---|
| 290 | echo "SOPEXTLIBLIST = $extliblib" >> $mfile
|
---|
| 291 |
|
---|
| 292 | echo " " >> $mfile
|
---|
| 293 | cat $mincname >> $mfile
|
---|
| 294 |
|
---|
[2724] | 295 | rm -f $mfile:t
|
---|
[2720] | 296 | ln -s $mfile $mfile:t
|
---|
| 297 |
|
---|
[2724] | 298 |
|
---|
| 299 | #----------------------------------------------------------------------
|
---|
| 300 | #### Copie de machdefs.h
|
---|
[2720] | 301 | set mdefname = $TMPDIR/machdefs.h
|
---|
| 302 | echo " "
|
---|
| 303 | echo ">>>>>> 6/ Creating machdefs.h from BaseTools/machdefs_mkmf.h"
|
---|
| 304 | rm -f $mdefname; touch $mdefname
|
---|
| 305 | echo "/*** machdefs.h generated by SOPHYA configure ***/" >> $mdefname
|
---|
| 306 | echo "#ifndef MACHDEFS_SEEN" >> $mdefname
|
---|
| 307 | echo "#define MACHDEFS_SEEN" >> $mdefname
|
---|
| 308 | echo "/*------ Code generation switch ---- */" >> $mdefname
|
---|
| 309 | echo "/* System selector (uname) */" >> $mdefname
|
---|
| 310 | set sname = `uname`
|
---|
| 311 | echo "#ifndef $sname" >> $mdefname
|
---|
| 312 | echo "#define $sname 1 " >> $mdefname
|
---|
| 313 | echo "#endif" >> $mdefname
|
---|
| 314 | echo "/* #define SO_BOUNDCHECKING 1 */" >> $mdefname
|
---|
[2724] | 315 |
|
---|
[2720] | 316 | echo " " >> $mdefname
|
---|
[2724] | 317 | echo "/*------ External libraries no-use flag ---- */" >> $mdefname
|
---|
| 318 | set i = 0
|
---|
| 319 | while ( $i < $#SOPEXTOK )
|
---|
| 320 | @ i += 1
|
---|
| 321 | if( $SOPEXTOK[$i] > 0 ) continue
|
---|
| 322 | echo "#define SOPHYA_NO_$SOPEXT[$i]" >> $mdefname
|
---|
| 323 | end
|
---|
[2720] | 324 |
|
---|
[2724] | 325 | echo " " >> $mdefname
|
---|
| 326 | grep -v -e '#ifndef *MACHDEFS_SEEN' -e '#define *MACHDEFS_SEEN' ../BaseTools/machdefs_mkmf.h >> $mdefname
|
---|
[2720] | 327 | # On ne copie que si machdefs.h est different
|
---|
| 328 | if (-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
|
---|
| 336 | else
|
---|
| 337 | cp -f -p $mdefname $sinc/machdefs.h
|
---|
| 338 | echo " file $sinc/machdefs.h created"
|
---|
| 339 | endif
|
---|
[2724] | 340 | rm -f $mdefname
|
---|
[2720] | 341 |
|
---|
| 342 |
|
---|
[2724] | 343 | #----------------------------------------------------------------------
|
---|
| 344 | #### Creation des fichiers contenant les listes d'objets et d'includes
|
---|
[2720] | 345 | echo " "
|
---|
| 346 | echo ">>>>>> 7/ Creating object list files for shared library creation "
|
---|
| 347 | set objlistname = $sconf/libsophya.objlist
|
---|
| 348 | echo " 7.a/ Creating $objlistname "
|
---|
[2724] | 349 | rm -f $objlistname ; touch $objlistname
|
---|
[2751] | 350 | foreach d ( $SOPMOD )
|
---|
| 351 | rm -f $sconf/$d.conf
|
---|
| 352 | if ( ! -d ../$d ) continue
|
---|
| 353 | cat ../$d/objlist.list >> $objlistname
|
---|
| 354 | touch $sconf/$d.conf
|
---|
[2720] | 355 | end
|
---|
| 356 |
|
---|
| 357 | set objlistname = $sconf/libextsophya.objlist
|
---|
| 358 | echo " 7.b/ Creating $objlistname "
|
---|
[2724] | 359 | rm -f $objlistname ; touch $objlistname
|
---|
[2739] | 360 | set i = 0
|
---|
| 361 | while ( $i < $#SOPEXT )
|
---|
| 362 | @ i += 1
|
---|
[2751] | 363 | set d = $SOPEXT[$i]
|
---|
| 364 | rm -f $sconf/$d.conf
|
---|
[2739] | 365 | if( $SOPEXTOK[$i] <= 0 ) continue
|
---|
| 366 | if ( ! -d ../$d ) continue
|
---|
| 367 | cat ../$d/objlist.list >> $objlistname
|
---|
[2751] | 368 | touch $sconf/$d.conf
|
---|
[2739] | 369 | end
|
---|
[2720] | 370 |
|
---|
| 371 | set objlistname = $sconf/libPI.objlist
|
---|
| 372 | echo " 7.c/ Creating $objlistname "
|
---|
[2724] | 373 | rm -f $objlistname ; touch $objlistname
|
---|
[2751] | 374 | foreach d ( $SOPPI )
|
---|
| 375 | rm -f $sconf/$d.conf
|
---|
| 376 | if ( ! -d ../$d ) continue
|
---|
| 377 | cat ../$d/objlist.list >> $objlistname
|
---|
| 378 | touch $sconf/$d.conf
|
---|
[2720] | 379 | end
|
---|
[2724] | 380 |
|
---|
| 381 |
|
---|
| 382 | #----------------------------------------------------------------------
|
---|
| 383 | exit 0
|
---|