[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 ... ]'
|
---|
| 36 | echo ' [-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
|
---|
| 66 | if( "$1" == "-noext" ) then
|
---|
| 67 | set i = 0
|
---|
| 68 | while ( $i < $#EXTCURNAME )
|
---|
| 69 | @ i += 1
|
---|
| 70 | if( "$2" == "$EXTCURNAME[$i]" ) set SOPEXTOK[$i] = 0
|
---|
| 71 | end
|
---|
| 72 | shift
|
---|
| 73 | endif
|
---|
[2720] | 74 |
|
---|
| 75 | shift
|
---|
| 76 | end
|
---|
| 77 |
|
---|
[2724] | 78 |
|
---|
| 79 | #----------------------------------------------------------------------
|
---|
| 80 | #### Verification generale
|
---|
[2720] | 81 | if( ! $?SOPHYABASE ) then
|
---|
| 82 | echo ERROR: define SOPHYABASE or use script arguments
|
---|
| 83 | exit -2
|
---|
| 84 | endif
|
---|
| 85 | if( ! $?SOPHYACXX ) then
|
---|
| 86 | echo ERROR: define SOPHYACXX or use script arguments
|
---|
| 87 | echo " SOPHYACXX define the name of the C++ compiler (ex: g++ cxx ...)"
|
---|
| 88 | exit -2
|
---|
| 89 | endif
|
---|
| 90 | if( ! $?TMPDIR ) setenv TMPDIR /tmp
|
---|
| 91 | touch $TMPDIR/tmp_test
|
---|
| 92 | if( $status != 0 ) then
|
---|
| 93 | echo ERROR: no write acces in temporary directory: $TMPDIR
|
---|
| 94 | echo '----> define TMPDIR environment variable: "setenv TMPDIR ..."'
|
---|
| 95 | exit -2
|
---|
| 96 | endif
|
---|
[2724] | 97 | rm -f $TMPDIR/tmp_test
|
---|
[2720] | 98 | if( ! $?mincname ) then
|
---|
| 99 | set mincname = `uname`_${SOPHYACXX}_make.inc
|
---|
| 100 | endif
|
---|
| 101 | if( ! -e $mincname ) then
|
---|
| 102 | echo ERROR: file $mincname NOT found
|
---|
| 103 | exit -2
|
---|
| 104 | endif
|
---|
| 105 | if( ! -e ../BaseTools/machdefs_mkmf.h ) then
|
---|
| 106 | echo ERROR: file machdefs_mkmf.h NOT found in BaseTools
|
---|
| 107 | exit -2
|
---|
| 108 | endif
|
---|
[2724] | 109 | echo SOPEXTOK: $SOPEXTOK
|
---|
[2720] | 110 |
|
---|
[2724] | 111 | #----------------------------------------------------------------------
|
---|
| 112 | #### creation des variables chemins sophya core
|
---|
[2720] | 113 | echo " "
|
---|
| 114 | echo ">>>>>> 1/ Creating directory tree under $SOPHYABASE "
|
---|
| 115 | set sinc = $SOPHYABASE/include
|
---|
| 116 | set slib = $SOPHYABASE/lib
|
---|
| 117 | set sslb = $SOPHYABASE/slb
|
---|
| 118 | set sobj = $SOPHYABASE/obj
|
---|
| 119 | set sexe = $SOPHYABASE/exe
|
---|
| 120 | set sconf = $sinc/SophyaConfInfo
|
---|
| 121 | foreach d ( $sinc $slib $sslb $sobj $sexe $sconf )
|
---|
| 122 | if( ! -d $d ) then
|
---|
| 123 | mkdir $d
|
---|
| 124 | if( $status ) then
|
---|
| 125 | echo ERROR: creation of $d failed
|
---|
| 126 | exit -3
|
---|
| 127 | endif
|
---|
| 128 | echo Directory $d created
|
---|
| 129 | endif
|
---|
| 130 | touch $d/tmp_test
|
---|
| 131 | if( $status ) then
|
---|
| 132 | echo ERROR: no write acces to $d
|
---|
| 133 | exit -4
|
---|
| 134 | endif
|
---|
| 135 | rm -f $d/tmp_test
|
---|
| 136 | end
|
---|
| 137 |
|
---|
[2724] | 138 |
|
---|
| 139 | #----------------------------------------------------------------------
|
---|
| 140 | #### Fichier confinfo - log e configure
|
---|
[2720] | 141 | set conflog = $sconf/conf.log
|
---|
| 142 | rm -f $conflog ; touch $conflog
|
---|
| 143 | echo ' --- Log of SOPHYA configure script - Date= ' `date` >> $conflog
|
---|
| 144 | echo "$cmdline" >> $conflog
|
---|
| 145 | set inclistf = $sconf/include.list
|
---|
| 146 | rm -f $inclistf ; touch $inclistf
|
---|
| 147 |
|
---|
[2724] | 148 |
|
---|
| 149 | #----------------------------------------------------------------------
|
---|
| 150 | #### liens ou copie des *.h
|
---|
[2720] | 151 | echo " "
|
---|
| 152 | echo ">>>>>> 2/ Copying include files to $sinc "
|
---|
[2724] | 153 | cd ../ > /dev/null
|
---|
[2720] | 154 | set srcd = `pwd`
|
---|
[2724] | 155 | set cpln = "cp -p "
|
---|
| 156 | if( $?incln ) set cpln = "ln -s -f "
|
---|
[2720] | 157 | foreach d ( $SOPMOD $SOPEXT $SOPPI )
|
---|
[2724] | 158 | if ( -d $srcd/$d ) then
|
---|
[2720] | 159 | echo Copying include files for module $d
|
---|
[2724] | 160 | cd $srcd/$d;
|
---|
[2720] | 161 | set file = ( *.h )
|
---|
[2724] | 162 | cd $sinc; if( $status == 0 ) rm -f $file
|
---|
| 163 | # on vire le .h de $file si .h dans excludeinc du module
|
---|
| 164 | cd $srcd/$d
|
---|
| 165 | if( -e excludeinc ) then
|
---|
| 166 | if( `cat excludeinc | wc -l` > 0 ) then
|
---|
| 167 | set file
|
---|
| 168 | foreach f ( *.h )
|
---|
| 169 | grep "$f" excludeinc > /dev/null
|
---|
| 170 | if( $status != 0 ) set file = ( $file $f )
|
---|
| 171 | end
|
---|
| 172 | endif
|
---|
[2720] | 173 | endif
|
---|
[2724] | 174 | # on copie ou link dans $sinc
|
---|
| 175 | if( `echo $file | wc -w` > 0 ) then
|
---|
| 176 | foreach f ( $file )
|
---|
| 177 | $cpln $srcd/$d/$f $sinc/$f
|
---|
| 178 | end
|
---|
| 179 | endif
|
---|
[2720] | 180 | echo $file >> $inclistf
|
---|
| 181 | endif
|
---|
| 182 | end
|
---|
[2724] | 183 | cd $srcd/BuildMgr/.
|
---|
[2720] | 184 |
|
---|
| 185 |
|
---|
[2724] | 186 | #----------------------------------------------------------------------
|
---|
| 187 | #### lien des .h des librairies externes
|
---|
[2720] | 188 | echo " "
|
---|
| 189 | echo ">>>>>> 3/ Include files for external libraries "
|
---|
| 190 | set i = 0
|
---|
| 191 | while ( $i < $#SOPEXT )
|
---|
| 192 | @ i += 1
|
---|
| 193 | if( "$EXTINCNAME[$i]" == "PASDEINC" ) continue
|
---|
| 194 | if( $SOPEXTOK[$i] <= 0 ) continue
|
---|
| 195 | set nom = $EXTINCNAME[$i]:t
|
---|
| 196 | set rac = $EXTINCNAME[$i]:h
|
---|
| 197 | if( -d ../$SOPEXT[$i] ) then
|
---|
| 198 | echo "Searching include file for $SOPEXT[$i] ..."
|
---|
[2724] | 199 | foreach d ( $extpathinc $extpath $defextinc )
|
---|
[2720] | 200 | set duminc = `find $d -name $nom -print | head -1 `
|
---|
| 201 | set dumrep = $duminc:h
|
---|
| 202 | if ( "$dumrep" != "" ) then
|
---|
| 203 | rm -f $sinc/$rac
|
---|
| 204 | ln -f -s $dumrep $sinc/$rac
|
---|
| 205 | echo Includes for $SOPEXT[$i] found in $dumrep
|
---|
| 206 | break
|
---|
| 207 | endif
|
---|
| 208 | end
|
---|
| 209 | if ( "$dumrep" == "" ) then
|
---|
| 210 | echo WARNING: Includes for $SOPEXT[$i] NOT found
|
---|
| 211 | echo " Compilation of module $SOPEXT[$i] disabled"
|
---|
| 212 | set SOPEXTOK[$i] = 0
|
---|
| 213 | endif
|
---|
| 214 | endif
|
---|
| 215 | end
|
---|
| 216 |
|
---|
[2724] | 217 |
|
---|
| 218 | #----------------------------------------------------------------------
|
---|
| 219 | #### liens des librairies externes
|
---|
[2720] | 220 | echo " "
|
---|
| 221 | echo ">>>>>> 4/ External libraries "
|
---|
| 222 | set fpath = $TMPDIR/fpath
|
---|
| 223 | rm -f $fpath; touch $fpath
|
---|
| 224 | set extliblib
|
---|
| 225 | set i = 0
|
---|
| 226 | while ( $i < $#SOPEXT )
|
---|
| 227 | @ i += 1
|
---|
| 228 | if( "$EXTLIBNAME[$i]" == "PASDELIB" ) continue
|
---|
| 229 | if( $SOPEXTOK[$i] <= 0 ) continue
|
---|
| 230 | set nom = $EXTLIBNAME[$i]
|
---|
| 231 | if( -d ../$SOPEXT[$i] ) then
|
---|
| 232 | echo "Searching libraries path for $SOPEXT[$i] ..."
|
---|
[2724] | 233 | foreach d ( $extpathlib $extpath $defextlib )
|
---|
[2720] | 234 | set dumlib = `find $d -name $nom -print | head -1 `
|
---|
| 235 | if ( "$dumlib" != "" ) then
|
---|
| 236 | echo "-L$dumlib:h" >> $fpath
|
---|
| 237 | set extliblib = ( $extliblib $ALLEXTLIBS[$i] )
|
---|
| 238 | break
|
---|
| 239 | endif
|
---|
| 240 | end
|
---|
| 241 | if ( "$dumlib" == "" ) then
|
---|
| 242 | echo WARNING: Libraries for $SOPEXT[$i] NOT found
|
---|
| 243 | echo " Check the generated make.inc file"
|
---|
| 244 | endif
|
---|
| 245 | endif
|
---|
| 246 | end
|
---|
| 247 | set extlibpath = `cat $fpath | sort -u`
|
---|
| 248 | echo extlibpath= $extlibpath
|
---|
| 249 | echo extliblib= $extliblib
|
---|
[2724] | 250 | rm -f $fpath
|
---|
[2720] | 251 |
|
---|
[2724] | 252 |
|
---|
| 253 | #----------------------------------------------------------------------
|
---|
| 254 | #### Generation de sophyamake.inc
|
---|
| 255 | # On le cree dans le repertoire temporaire d'abord
|
---|
[2720] | 256 | set mfile = $sinc/sophyamake.inc
|
---|
[2724] | 257 | rm -f $mfile
|
---|
[2720] | 258 | echo " "
|
---|
[2724] | 259 | echo ">>>>>> 5/ Creating $mfile from $mincname "
|
---|
[2720] | 260 | echo "# -----------------------------------------------" > $mfile
|
---|
| 261 | echo "# File make.inc - generated by SOPHYA configure" >> $mfile
|
---|
| 262 | echo "# Date" `date` >> $mfile
|
---|
| 263 | echo "# Seed file : $mincname " >> $mfile
|
---|
| 264 | echo "# -----------------------------------------------" >> $mfile
|
---|
| 265 | echo " " >> $mfile
|
---|
| 266 | echo "# SOPHYA Base installation directory " >> $mfile
|
---|
| 267 | echo "SOPHYABASE = $SOPHYABASE" >> $mfile
|
---|
| 268 | echo " " >> $mfile
|
---|
| 269 | echo 'SOPHYAINCP = $(SOPHYABASE)/include/' >> $mfile
|
---|
| 270 | echo 'SOPHYAOBJP = $(SOPHYABASE)/obj/' >> $mfile
|
---|
| 271 | echo 'SOPHYALIBP = $(SOPHYABASE)/lib/' >> $mfile
|
---|
| 272 | echo 'SOPHYASLBP = $(SOPHYABASE)/slb/' >> $mfile
|
---|
| 273 | echo 'SOPHYAEXEP = $(SOPHYABASE)/exe/' >> $mfile
|
---|
| 274 |
|
---|
| 275 | echo " " >> $mfile
|
---|
| 276 | echo "# External libraries PATH " >> $mfile
|
---|
| 277 | echo "SOPEXTLIBP = $extlibpath" >> $mfile
|
---|
| 278 | echo "SOPEXTLIBLIST = $extliblib" >> $mfile
|
---|
| 279 |
|
---|
| 280 | echo " " >> $mfile
|
---|
| 281 | cat $mincname >> $mfile
|
---|
| 282 |
|
---|
[2724] | 283 | rm -f $mfile:t
|
---|
[2720] | 284 | ln -s $mfile $mfile:t
|
---|
| 285 |
|
---|
[2724] | 286 |
|
---|
| 287 | #----------------------------------------------------------------------
|
---|
| 288 | #### Copie de machdefs.h
|
---|
[2720] | 289 | set mdefname = $TMPDIR/machdefs.h
|
---|
| 290 | echo " "
|
---|
| 291 | echo ">>>>>> 6/ Creating machdefs.h from BaseTools/machdefs_mkmf.h"
|
---|
| 292 | rm -f $mdefname; touch $mdefname
|
---|
| 293 | echo "/*** machdefs.h generated by SOPHYA configure ***/" >> $mdefname
|
---|
| 294 | echo "#ifndef MACHDEFS_SEEN" >> $mdefname
|
---|
| 295 | echo "#define MACHDEFS_SEEN" >> $mdefname
|
---|
| 296 | echo "/*------ Code generation switch ---- */" >> $mdefname
|
---|
| 297 | echo "/* System selector (uname) */" >> $mdefname
|
---|
| 298 | set sname = `uname`
|
---|
| 299 | echo "#ifndef $sname" >> $mdefname
|
---|
| 300 | echo "#define $sname 1 " >> $mdefname
|
---|
| 301 | echo "#endif" >> $mdefname
|
---|
| 302 | echo "/* #define SO_BOUNDCHECKING 1 */" >> $mdefname
|
---|
[2724] | 303 |
|
---|
[2720] | 304 | echo " " >> $mdefname
|
---|
[2724] | 305 | echo "/*------ External libraries no-use flag ---- */" >> $mdefname
|
---|
| 306 | set i = 0
|
---|
| 307 | while ( $i < $#SOPEXTOK )
|
---|
| 308 | @ i += 1
|
---|
| 309 | if( $SOPEXTOK[$i] > 0 ) continue
|
---|
| 310 | echo "#define SOPHYA_NO_$SOPEXT[$i]" >> $mdefname
|
---|
| 311 | end
|
---|
[2720] | 312 |
|
---|
[2724] | 313 | echo " " >> $mdefname
|
---|
| 314 | grep -v -e '#ifndef *MACHDEFS_SEEN' -e '#define *MACHDEFS_SEEN' ../BaseTools/machdefs_mkmf.h >> $mdefname
|
---|
[2720] | 315 | # On ne copie que si machdefs.h est different
|
---|
| 316 | if (-e $sinc/machdefs.h ) then
|
---|
| 317 | diff $mdefname $sinc/machdefs.h >& /dev/null
|
---|
| 318 | if ($status != 0) then
|
---|
| 319 | cp -f -p $mdefname $sinc/machdefs.h
|
---|
| 320 | echo " file $sinc/machdefs.h changed -> replaced"
|
---|
| 321 | else
|
---|
| 322 | echo " file $sinc/machdefs.h has not changed -> kept"
|
---|
| 323 | endif
|
---|
| 324 | else
|
---|
| 325 | cp -f -p $mdefname $sinc/machdefs.h
|
---|
| 326 | echo " file $sinc/machdefs.h created"
|
---|
| 327 | endif
|
---|
[2724] | 328 | rm -f $mdefname
|
---|
[2720] | 329 |
|
---|
| 330 |
|
---|
[2724] | 331 | #----------------------------------------------------------------------
|
---|
| 332 | #### Creation des fichiers contenant les listes d'objets et d'includes
|
---|
[2720] | 333 | echo " "
|
---|
| 334 | echo ">>>>>> 7/ Creating object list files for shared library creation "
|
---|
| 335 | set objlistname = $sconf/libsophya.objlist
|
---|
| 336 | echo " 7.a/ Creating $objlistname "
|
---|
[2724] | 337 | rm -f $objlistname ; touch $objlistname
|
---|
[2720] | 338 | foreach d ( $SOPMOD )
|
---|
| 339 | if ( -d ../$d ) then
|
---|
| 340 | cat ../$d/objlist.list >> $objlistname
|
---|
| 341 | endif
|
---|
| 342 | end
|
---|
| 343 |
|
---|
| 344 | set objlistname = $sconf/libextsophya.objlist
|
---|
| 345 | echo " 7.b/ Creating $objlistname "
|
---|
[2724] | 346 | rm -f $objlistname ; touch $objlistname
|
---|
[2720] | 347 | foreach d ( $SOPEXT )
|
---|
| 348 | if ( -d ../$d ) then
|
---|
| 349 | cat ../$d/objlist.list >> $objlistname
|
---|
| 350 | endif
|
---|
| 351 | end
|
---|
| 352 |
|
---|
| 353 | set objlistname = $sconf/libPI.objlist
|
---|
| 354 | echo " 7.c/ Creating $objlistname "
|
---|
[2724] | 355 | rm -f $objlistname ; touch $objlistname
|
---|
[2720] | 356 | foreach d ($SOPPI )
|
---|
| 357 | if ( -d ../$d ) then
|
---|
| 358 | cat ../$d/objlist.list >> $objlistname
|
---|
| 359 | endif
|
---|
| 360 | end
|
---|
[2724] | 361 |
|
---|
| 362 |
|
---|
| 363 | #----------------------------------------------------------------------
|
---|
| 364 | exit 0
|
---|