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

Last change on this file since 2726 was 2726, checked in by ansari, 20 years ago

Amelioration impression ds configure (copy/link des .h)
Correction pour XAstroPack ds Makefile et extension .dylib pour Darwin_g++_make.inc

Reza 18 Mai 2005

  • Property svn:executable set to *
File size: 10.6 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 if ( $?incln ) then
160 echo Creating link to include files for module $d
161 else
162 echo Copying include files for module $d
163 endif
164
165 cd $srcd/$d;
166 set file = ( *.h )
167 cd $sinc; if( $status == 0 ) rm -f $file
168 # on vire le .h de $file si .h dans excludeinc du module
169 cd $srcd/$d
170 if( -e excludeinc ) then
171 if( `cat excludeinc | wc -l` > 0 ) then
172 set file
173 foreach f ( *.h )
174 grep "$f" excludeinc > /dev/null
175 if( $status != 0 ) set file = ( $file $f )
176 end
177 endif
178 endif
179 # on copie ou link dans $sinc
180 if( `echo $file | wc -w` > 0 ) then
181 foreach f ( $file )
182 $cpln $srcd/$d/$f $sinc/$f
183 end
184 endif
185 echo $file >> $inclistf
186 endif
187end
188cd $srcd/BuildMgr/.
189
190
191#----------------------------------------------------------------------
192#### lien des .h des librairies externes
193echo " "
194echo ">>>>>> 3/ Include files for external libraries "
195set i = 0
196while ( $i < $#SOPEXT )
197 @ i += 1
198 if( "$EXTINCNAME[$i]" == "PASDEINC" ) continue
199 if( $SOPEXTOK[$i] <= 0 ) continue
200 set nom = $EXTINCNAME[$i]:t
201 set rac = $EXTINCNAME[$i]:h
202 if( -d ../$SOPEXT[$i] ) then
203 echo "Searching include file for $SOPEXT[$i] ..."
204 foreach d ( $extpathinc $extpath $defextinc )
205 set duminc = `find $d -name $nom -print | head -1 `
206 set dumrep = $duminc:h
207 if ( "$dumrep" != "" ) then
208 rm -f $sinc/$rac
209 ln -f -s $dumrep $sinc/$rac
210 echo Includes for $SOPEXT[$i] found in $dumrep
211 break
212 endif
213 end
214 if ( "$dumrep" == "" ) then
215 echo WARNING: Includes for $SOPEXT[$i] NOT found
216 echo " Compilation of module $SOPEXT[$i] disabled"
217 set SOPEXTOK[$i] = 0
218 endif
219 endif
220end
221
222
223#----------------------------------------------------------------------
224#### liens des librairies externes
225echo " "
226echo ">>>>>> 4/ External libraries "
227set fpath = $TMPDIR/fpath
228rm -f $fpath; touch $fpath
229set extliblib
230set i = 0
231while ( $i < $#SOPEXT )
232 @ i += 1
233 if( "$EXTLIBNAME[$i]" == "PASDELIB" ) continue
234 if( $SOPEXTOK[$i] <= 0 ) continue
235 set nom = $EXTLIBNAME[$i]
236 if( -d ../$SOPEXT[$i] ) then
237 echo "Searching libraries path for $SOPEXT[$i] ..."
238 foreach d ( $extpathlib $extpath $defextlib )
239 set dumlib = `find $d -name $nom -print | head -1 `
240 if ( "$dumlib" != "" ) then
241 echo "-L$dumlib:h" >> $fpath
242 set extliblib = ( $extliblib $ALLEXTLIBS[$i] )
243 break
244 endif
245 end
246 if ( "$dumlib" == "" ) then
247 echo WARNING: Libraries for $SOPEXT[$i] NOT found
248 echo " Check the generated make.inc file"
249 endif
250 endif
251end
252set extlibpath = `cat $fpath | sort -u`
253echo extlibpath= $extlibpath
254echo extliblib= $extliblib
255rm -f $fpath
256
257
258#----------------------------------------------------------------------
259#### Generation de sophyamake.inc
260# On le cree dans le repertoire temporaire d'abord
261set mfile = $sinc/sophyamake.inc
262rm -f $mfile
263echo " "
264echo ">>>>>> 5/ Creating $mfile from $mincname "
265echo "# -----------------------------------------------" > $mfile
266echo "# File make.inc - generated by SOPHYA configure" >> $mfile
267echo "# Date" `date` >> $mfile
268echo "# Seed file : $mincname " >> $mfile
269echo "# -----------------------------------------------" >> $mfile
270echo " " >> $mfile
271echo "# SOPHYA Base installation directory " >> $mfile
272echo "SOPHYABASE = $SOPHYABASE" >> $mfile
273echo " " >> $mfile
274echo 'SOPHYAINCP = $(SOPHYABASE)/include/' >> $mfile
275echo 'SOPHYAOBJP = $(SOPHYABASE)/obj/' >> $mfile
276echo 'SOPHYALIBP = $(SOPHYABASE)/lib/' >> $mfile
277echo 'SOPHYASLBP = $(SOPHYABASE)/slb/' >> $mfile
278echo 'SOPHYAEXEP = $(SOPHYABASE)/exe/' >> $mfile
279
280echo " " >> $mfile
281echo "# External libraries PATH " >> $mfile
282echo "SOPEXTLIBP = $extlibpath" >> $mfile
283echo "SOPEXTLIBLIST = $extliblib" >> $mfile
284
285echo " " >> $mfile
286cat $mincname >> $mfile
287
288rm -f $mfile:t
289ln -s $mfile $mfile:t
290
291
292#----------------------------------------------------------------------
293#### Copie de machdefs.h
294set mdefname = $TMPDIR/machdefs.h
295echo " "
296echo ">>>>>> 6/ Creating machdefs.h from BaseTools/machdefs_mkmf.h"
297rm -f $mdefname; touch $mdefname
298echo "/*** machdefs.h generated by SOPHYA configure ***/" >> $mdefname
299echo "#ifndef MACHDEFS_SEEN" >> $mdefname
300echo "#define MACHDEFS_SEEN" >> $mdefname
301echo "/*------ Code generation switch ---- */" >> $mdefname
302echo "/* System selector (uname) */" >> $mdefname
303set sname = `uname`
304echo "#ifndef $sname" >> $mdefname
305echo "#define $sname 1 " >> $mdefname
306echo "#endif" >> $mdefname
307echo "/* #define SO_BOUNDCHECKING 1 */" >> $mdefname
308
309echo " " >> $mdefname
310echo "/*------ External libraries no-use flag ---- */" >> $mdefname
311set i = 0
312while ( $i < $#SOPEXTOK )
313 @ i += 1
314 if( $SOPEXTOK[$i] > 0 ) continue
315 echo "#define SOPHYA_NO_$SOPEXT[$i]" >> $mdefname
316end
317
318echo " " >> $mdefname
319grep -v -e '#ifndef *MACHDEFS_SEEN' -e '#define *MACHDEFS_SEEN' ../BaseTools/machdefs_mkmf.h >> $mdefname
320# On ne copie que si machdefs.h est different
321if (-e $sinc/machdefs.h ) then
322 diff $mdefname $sinc/machdefs.h >& /dev/null
323 if ($status != 0) then
324 cp -f -p $mdefname $sinc/machdefs.h
325 echo " file $sinc/machdefs.h changed -> replaced"
326 else
327 echo " file $sinc/machdefs.h has not changed -> kept"
328 endif
329else
330 cp -f -p $mdefname $sinc/machdefs.h
331 echo " file $sinc/machdefs.h created"
332endif
333rm -f $mdefname
334
335
336#----------------------------------------------------------------------
337#### Creation des fichiers contenant les listes d'objets et d'includes
338echo " "
339echo ">>>>>> 7/ Creating object list files for shared library creation "
340set objlistname = $sconf/libsophya.objlist
341echo " 7.a/ Creating $objlistname "
342rm -f $objlistname ; touch $objlistname
343foreach d ( $SOPMOD )
344 if ( -d ../$d ) then
345 cat ../$d/objlist.list >> $objlistname
346 endif
347end
348
349set objlistname = $sconf/libextsophya.objlist
350echo " 7.b/ Creating $objlistname "
351rm -f $objlistname ; touch $objlistname
352foreach d ( $SOPEXT )
353 if ( -d ../$d ) then
354 cat ../$d/objlist.list >> $objlistname
355 endif
356end
357
358set objlistname = $sconf/libPI.objlist
359echo " 7.c/ Creating $objlistname "
360rm -f $objlistname ; touch $objlistname
361foreach d ($SOPPI )
362 if ( -d ../$d ) then
363 cat ../$d/objlist.list >> $objlistname
364 endif
365end
366
367
368#----------------------------------------------------------------------
369exit 0
Note: See TracBrowser for help on using the repository browser.