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
|
---|
9 | set SOPMOD = ( BaseTools SysTools SUtils TArray NTools HiStats SkyMap Samba SkyT )
|
---|
10 | set SOPPI = ( PI PIext PIGcont )
|
---|
11 |
|
---|
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' )
|
---|
18 |
|
---|
19 | set defextinc = ( ~ /usr/include /usr/local/include )
|
---|
20 | set defextlib = ( ~ /usr/lib /usr/local/lib )
|
---|
21 |
|
---|
22 |
|
---|
23 | #----------------------------------------------------------------------
|
---|
24 | #### Decodage arguments
|
---|
25 | set cmdline = "$0 $*"
|
---|
26 | set extpath
|
---|
27 | set extpathinc
|
---|
28 | set extpathlib
|
---|
29 | unset incln
|
---|
30 | unset mincname
|
---|
31 | while ( $#argv > 0 )
|
---|
32 |
|
---|
33 | if( "$1" == "-h" ) then
|
---|
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 ' [-noextlib -noext fits -noext fftw -noext lapack -noext astro -noext minuit]'
|
---|
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
|
---|
50 | if( "$1" == "-minc" ) then
|
---|
51 | set mincname = ( $2 )
|
---|
52 | shift
|
---|
53 | endif
|
---|
54 | if( "$1" == "-extp" ) then
|
---|
55 | set extpath = ( $extpath $2 )
|
---|
56 | shift
|
---|
57 | endif
|
---|
58 | if( "$1" == "-extip" ) then
|
---|
59 | set extpathinc = ( $extpathinc $2 )
|
---|
60 | shift
|
---|
61 | endif
|
---|
62 | if( "$1" == "-extlp" ) then
|
---|
63 | set extpathlib = ( $extpathlib $2 )
|
---|
64 | shift
|
---|
65 | endif
|
---|
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
|
---|
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
|
---|
81 |
|
---|
82 | shift
|
---|
83 | end
|
---|
84 |
|
---|
85 |
|
---|
86 | #----------------------------------------------------------------------
|
---|
87 | #### Verification generale
|
---|
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
|
---|
104 | rm -f $TMPDIR/tmp_test
|
---|
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
|
---|
116 | echo SOPEXTOK: $SOPEXTOK
|
---|
117 |
|
---|
118 | #----------------------------------------------------------------------
|
---|
119 | #### creation des variables chemins sophya core
|
---|
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 |
|
---|
145 |
|
---|
146 | #----------------------------------------------------------------------
|
---|
147 | #### Fichier confinfo - log e configure
|
---|
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 |
|
---|
155 |
|
---|
156 | #----------------------------------------------------------------------
|
---|
157 | #### liens ou copie des *.h
|
---|
158 | echo " "
|
---|
159 | echo ">>>>>> 2/ Copying include files to $sinc "
|
---|
160 | cd ../ > /dev/null
|
---|
161 | set srcd = `pwd`
|
---|
162 | set cpln = "cp -p "
|
---|
163 | if( $?incln ) set cpln = "ln -s -f "
|
---|
164 | foreach d ( $SOPMOD $SOPEXT $SOPPI )
|
---|
165 | if ( -d $srcd/$d ) then
|
---|
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 |
|
---|
172 | cd $srcd/$d;
|
---|
173 | set file = ( *.h )
|
---|
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 )
|
---|
181 | grep -q "$f:r\.h" excludeinc
|
---|
182 | if( $status != 0 ) set file = ( $file $f )
|
---|
183 | end
|
---|
184 | endif
|
---|
185 | endif
|
---|
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
|
---|
192 | echo $file >> $inclistf
|
---|
193 | endif
|
---|
194 | end
|
---|
195 | cd $srcd/BuildMgr/.
|
---|
196 |
|
---|
197 |
|
---|
198 | #----------------------------------------------------------------------
|
---|
199 | #### lien des .h des librairies externes
|
---|
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] ..."
|
---|
211 | foreach d ( $extpathinc $extpath $defextinc )
|
---|
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 |
|
---|
229 |
|
---|
230 | #----------------------------------------------------------------------
|
---|
231 | #### liens des librairies externes
|
---|
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] ..."
|
---|
245 | foreach d ( $extpathlib $extpath $defextlib )
|
---|
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
|
---|
262 | rm -f $fpath
|
---|
263 |
|
---|
264 |
|
---|
265 | #----------------------------------------------------------------------
|
---|
266 | #### Generation de sophyamake.inc
|
---|
267 | # On le cree dans le repertoire temporaire d'abord
|
---|
268 | set mfile = $sinc/sophyamake.inc
|
---|
269 | rm -f $mfile
|
---|
270 | echo " "
|
---|
271 | echo ">>>>>> 5/ Creating $mfile from $mincname "
|
---|
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 |
|
---|
295 | rm -f $mfile:t
|
---|
296 | ln -s $mfile $mfile:t
|
---|
297 |
|
---|
298 |
|
---|
299 | #----------------------------------------------------------------------
|
---|
300 | #### Copie de machdefs.h
|
---|
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
|
---|
315 |
|
---|
316 | echo " " >> $mdefname
|
---|
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
|
---|
324 |
|
---|
325 | echo " " >> $mdefname
|
---|
326 | grep -v -e '#ifndef *MACHDEFS_SEEN' -e '#define *MACHDEFS_SEEN' ../BaseTools/machdefs_mkmf.h >> $mdefname
|
---|
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
|
---|
340 | rm -f $mdefname
|
---|
341 |
|
---|
342 |
|
---|
343 | #----------------------------------------------------------------------
|
---|
344 | #### Creation des fichiers contenant les listes d'objets et d'includes
|
---|
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 "
|
---|
349 | rm -f $objlistname ; touch $objlistname
|
---|
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
|
---|
355 | end
|
---|
356 |
|
---|
357 | set objlistname = $sconf/libextsophya.objlist
|
---|
358 | echo " 7.b/ Creating $objlistname "
|
---|
359 | rm -f $objlistname ; touch $objlistname
|
---|
360 | set i = 0
|
---|
361 | while ( $i < $#SOPEXT )
|
---|
362 | @ i += 1
|
---|
363 | set d = $SOPEXT[$i]
|
---|
364 | rm -f $sconf/$d.conf
|
---|
365 | if( $SOPEXTOK[$i] <= 0 ) continue
|
---|
366 | if ( ! -d ../$d ) continue
|
---|
367 | cat ../$d/objlist.list >> $objlistname
|
---|
368 | touch $sconf/$d.conf
|
---|
369 | end
|
---|
370 |
|
---|
371 | set objlistname = $sconf/libPI.objlist
|
---|
372 | echo " 7.c/ Creating $objlistname "
|
---|
373 | rm -f $objlistname ; touch $objlistname
|
---|
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
|
---|
379 | end
|
---|
380 |
|
---|
381 |
|
---|
382 | #----------------------------------------------------------------------
|
---|
383 | exit 0
|
---|