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

Last change on this file since 2724 was 2724, checked in by cmv, 20 years ago

configure suite cmv 18/05/05

  • Property svn:executable set to *
File size: 10.5 KB
Line 
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
9set SOPMOD = ( BaseTools SysTools SUtils TArray NTools HiStats SkyMap Samba SkyT )
10set SOPPI = ( PI PIext PIGcont )
11
12set SOPEXT = ( FitsIOServer IFFTW LinAlg XAstroPack MinuitAdapt )
13set EXTCURNAME = ( fits fftw lapack astro minuit )
14set SOPEXTOK = ( 1 1 1 1 1 )
15set EXTINCNAME = ( FitsIO/fitsio.h FFTW/fftw.h PASDEINC XAstro/astro.h Cern/minuit.h )
16set EXTLIBNAME = ( libcfitsio.a libfftw.a liblapack.a libxastro.a libminuit.a )
17set ALLEXTLIBS = ( '-lcfitsio' '-lfftw -lrfftw' '-llapack -lblas' '-lxastro' '-lminuit' )
18
19set defextinc = ( ~ /usr/include /usr/local/include )
20set defextlib = ( ~ /usr/lib /usr/local/lib )
21
22
23#----------------------------------------------------------------------
24#### Decodage arguments
25set cmdline = "$0 $*"
26set extpath
27set extpathinc
28set extpathlib
29unset incln
30unset mincname
31while ( $#argv > 0 )
32
33if( "$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 ' [-noext fits -noext fftw -noext lapack -noext astro -noext minuit]'
37 exit -1
38endif
39if( "$1" == "-sbase" ) then
40 setenv SOPHYABASE $2
41 shift
42endif
43if( "$1" == "-scxx" ) then
44 setenv SOPHYACXX $2
45 shift
46endif
47if( "$1" == "-incln" ) then
48 set incln
49endif
50if( "$1" == "-minc" ) then
51 set mincname = ( $2 )
52 shift
53endif
54if( "$1" == "-extp" ) then
55 set extpath = ( $extpath $2 )
56 shift
57endif
58if( "$1" == "-extip" ) then
59 set extpathinc = ( $extpathinc $2 )
60 shift
61endif
62if( "$1" == "-extlp" ) then
63 set extpathlib = ( $extpathlib $2 )
64 shift
65endif
66if( "$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
73endif
74
75shift
76end
77
78
79#----------------------------------------------------------------------
80#### Verification generale
81if( ! $?SOPHYABASE ) then
82 echo ERROR: define SOPHYABASE or use script arguments
83 exit -2
84endif
85if( ! $?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
89endif
90if( ! $?TMPDIR ) setenv TMPDIR /tmp
91touch $TMPDIR/tmp_test
92if( $status != 0 ) then
93 echo ERROR: no write acces in temporary directory: $TMPDIR
94 echo '----> define TMPDIR environment variable: "setenv TMPDIR ..."'
95 exit -2
96endif
97rm -f $TMPDIR/tmp_test
98if( ! $?mincname ) then
99 set mincname = `uname`_${SOPHYACXX}_make.inc
100endif
101if( ! -e $mincname ) then
102 echo ERROR: file $mincname NOT found
103 exit -2
104endif
105if( ! -e ../BaseTools/machdefs_mkmf.h ) then
106 echo ERROR: file machdefs_mkmf.h NOT found in BaseTools
107 exit -2
108endif
109echo SOPEXTOK: $SOPEXTOK
110
111#----------------------------------------------------------------------
112#### creation des variables chemins sophya core
113echo " "
114echo ">>>>>> 1/ Creating directory tree under $SOPHYABASE "
115set sinc = $SOPHYABASE/include
116set slib = $SOPHYABASE/lib
117set sslb = $SOPHYABASE/slb
118set sobj = $SOPHYABASE/obj
119set sexe = $SOPHYABASE/exe
120set sconf = $sinc/SophyaConfInfo
121foreach 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
136end
137
138
139#----------------------------------------------------------------------
140#### Fichier confinfo - log e configure
141set conflog = $sconf/conf.log
142rm -f $conflog ; touch $conflog
143echo ' --- Log of SOPHYA configure script - Date= ' `date` >> $conflog
144echo "$cmdline" >> $conflog
145set inclistf = $sconf/include.list
146rm -f $inclistf ; touch $inclistf
147
148
149#----------------------------------------------------------------------
150#### liens ou copie des *.h
151echo " "
152echo ">>>>>> 2/ Copying include files to $sinc "
153cd ../ > /dev/null
154set srcd = `pwd`
155set cpln = "cp -p "
156if( $?incln ) set cpln = "ln -s -f "
157foreach d ( $SOPMOD $SOPEXT $SOPPI )
158 if ( -d $srcd/$d ) then
159 echo Copying include files for module $d
160 cd $srcd/$d;
161 set file = ( *.h )
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
173 endif
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
180 echo $file >> $inclistf
181 endif
182end
183cd $srcd/BuildMgr/.
184
185
186#----------------------------------------------------------------------
187#### lien des .h des librairies externes
188echo " "
189echo ">>>>>> 3/ Include files for external libraries "
190set i = 0
191while ( $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] ..."
199 foreach d ( $extpathinc $extpath $defextinc )
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
215end
216
217
218#----------------------------------------------------------------------
219#### liens des librairies externes
220echo " "
221echo ">>>>>> 4/ External libraries "
222set fpath = $TMPDIR/fpath
223rm -f $fpath; touch $fpath
224set extliblib
225set i = 0
226while ( $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] ..."
233 foreach d ( $extpathlib $extpath $defextlib )
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
246end
247set extlibpath = `cat $fpath | sort -u`
248echo extlibpath= $extlibpath
249echo extliblib= $extliblib
250rm -f $fpath
251
252
253#----------------------------------------------------------------------
254#### Generation de sophyamake.inc
255# On le cree dans le repertoire temporaire d'abord
256set mfile = $sinc/sophyamake.inc
257rm -f $mfile
258echo " "
259echo ">>>>>> 5/ Creating $mfile from $mincname "
260echo "# -----------------------------------------------" > $mfile
261echo "# File make.inc - generated by SOPHYA configure" >> $mfile
262echo "# Date" `date` >> $mfile
263echo "# Seed file : $mincname " >> $mfile
264echo "# -----------------------------------------------" >> $mfile
265echo " " >> $mfile
266echo "# SOPHYA Base installation directory " >> $mfile
267echo "SOPHYABASE = $SOPHYABASE" >> $mfile
268echo " " >> $mfile
269echo 'SOPHYAINCP = $(SOPHYABASE)/include/' >> $mfile
270echo 'SOPHYAOBJP = $(SOPHYABASE)/obj/' >> $mfile
271echo 'SOPHYALIBP = $(SOPHYABASE)/lib/' >> $mfile
272echo 'SOPHYASLBP = $(SOPHYABASE)/slb/' >> $mfile
273echo 'SOPHYAEXEP = $(SOPHYABASE)/exe/' >> $mfile
274
275echo " " >> $mfile
276echo "# External libraries PATH " >> $mfile
277echo "SOPEXTLIBP = $extlibpath" >> $mfile
278echo "SOPEXTLIBLIST = $extliblib" >> $mfile
279
280echo " " >> $mfile
281cat $mincname >> $mfile
282
283rm -f $mfile:t
284ln -s $mfile $mfile:t
285
286
287#----------------------------------------------------------------------
288#### Copie de machdefs.h
289set mdefname = $TMPDIR/machdefs.h
290echo " "
291echo ">>>>>> 6/ Creating machdefs.h from BaseTools/machdefs_mkmf.h"
292rm -f $mdefname; touch $mdefname
293echo "/*** machdefs.h generated by SOPHYA configure ***/" >> $mdefname
294echo "#ifndef MACHDEFS_SEEN" >> $mdefname
295echo "#define MACHDEFS_SEEN" >> $mdefname
296echo "/*------ Code generation switch ---- */" >> $mdefname
297echo "/* System selector (uname) */" >> $mdefname
298set sname = `uname`
299echo "#ifndef $sname" >> $mdefname
300echo "#define $sname 1 " >> $mdefname
301echo "#endif" >> $mdefname
302echo "/* #define SO_BOUNDCHECKING 1 */" >> $mdefname
303
304echo " " >> $mdefname
305echo "/*------ External libraries no-use flag ---- */" >> $mdefname
306set i = 0
307while ( $i < $#SOPEXTOK )
308 @ i += 1
309 if( $SOPEXTOK[$i] > 0 ) continue
310 echo "#define SOPHYA_NO_$SOPEXT[$i]" >> $mdefname
311end
312
313echo " " >> $mdefname
314grep -v -e '#ifndef *MACHDEFS_SEEN' -e '#define *MACHDEFS_SEEN' ../BaseTools/machdefs_mkmf.h >> $mdefname
315# On ne copie que si machdefs.h est different
316if (-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
324else
325 cp -f -p $mdefname $sinc/machdefs.h
326 echo " file $sinc/machdefs.h created"
327endif
328rm -f $mdefname
329
330
331#----------------------------------------------------------------------
332#### Creation des fichiers contenant les listes d'objets et d'includes
333echo " "
334echo ">>>>>> 7/ Creating object list files for shared library creation "
335set objlistname = $sconf/libsophya.objlist
336echo " 7.a/ Creating $objlistname "
337rm -f $objlistname ; touch $objlistname
338foreach d ( $SOPMOD )
339 if ( -d ../$d ) then
340 cat ../$d/objlist.list >> $objlistname
341 endif
342end
343
344set objlistname = $sconf/libextsophya.objlist
345echo " 7.b/ Creating $objlistname "
346rm -f $objlistname ; touch $objlistname
347foreach d ( $SOPEXT )
348 if ( -d ../$d ) then
349 cat ../$d/objlist.list >> $objlistname
350 endif
351end
352
353set objlistname = $sconf/libPI.objlist
354echo " 7.c/ Creating $objlistname "
355rm -f $objlistname ; touch $objlistname
356foreach d ($SOPPI )
357 if ( -d ../$d ) then
358 cat ../$d/objlist.list >> $objlistname
359 endif
360end
361
362
363#----------------------------------------------------------------------
364exit 0
Note: See TracBrowser for help on using the repository browser.