]> SALOME platform Git repositories - tools/install.git/blob - config_files/common.sh
Salome HOME
Small Correction
[tools/install.git] / config_files / common.sh
1 #!/bin/sh
2
3 # This script installs a subset of products necessary for SALOME application
4 #
5 # Usage: install <target-directory> [all]
6 #        install <target-directory> <product> ... <product>
7 #
8 # Type 'install --help' to get more information
9 #
10 # Important note: 
11 #   <target-directory> must be an absolute path
12 #
13 # The script is the part of the SALOME PRO installation procedure.
14 #
15 # Copyright : 2003 CEA/DEN, EDF R&D
16 ####################################################################################
17
18 export DELIM="------"
19 export SHRC="salome.sh"
20 export CSHRC="salome.csh"
21
22 #this function takes several parameters
23 #first parameter contains descriptor of output file
24 #next parameters is command for execution
25 #in case of bad result of execution ask user about furher steps
26 #(user can cancel installation procedure)
27 check_job()
28 {
29   out=$1
30   shift
31   errfile=/tmp/errlog
32   if [ -n "$INSTALL_WORK" ] ; then errfile=$INSTALL_WORK/errlog; fi
33   cmd="`pwd` -> $*"
34   if [ "$out" != "1" ] ; then cmd="$cmd >> $out" ; fi
35   echo -e $cmd
36   if [ "$out" != "1" ] ; then
37       $* >> $out 2>$errfile
38   else
39       $*
40   fi
41   if [ "$?" -ne "0" ] ; then
42     if [ $out != "1" ] ; then
43       cat $out
44       cat $errfile >&2
45       cat $errfile >> $out
46     fi
47     # VSR : 10/11/05: disable answer mode ==>
48     #echo -n " " >&2
49     #echo -e "NOT DONE !!! => $*"
50     #echo -n "Would you like to continue to install this product: (Y,N) [Y] : "
51     #read rep;
52     #rep=`echo $rep  | tr "[A-Z]" "[a-z]"`
53     #if test -z $rep || [ $rep = "y" ] ; then
54     #  return 1
55     #fi
56     # VSR : 10/11/05: disable answer mode <==
57     exit 1
58   fi
59   return 0
60 }
61
62 #invoke check_job function
63 #all output will be put into terminal
64 check_jb()
65 {
66   check_job 1 $*
67   return
68 }
69
70 # make directory
71 makedir()
72 {
73   rm -rf "$1" > /dev/null
74   mkdir -p "$1"
75 }
76
77 #create environment for sh and csh
78 make_env()
79 {
80 install_root=$1;  shift
81 install_work=$1; 
82 for i in $SHRC $CSHRC ; do
83     if [ -e ${install_work}/$i ]; then
84         rm ${install_work}/$i
85     fi
86     touch ${install_work}/$i
87 done
88
89 if [ $# -eq 3 ] ; then
90     product_name=$3;
91     product_env=${install_work}/env_${product_name}.sh
92     (test -e ${product_env} && rm ${product_env} )
93 fi
94 ### !!! writing salome.sh file !!!  -> define INSTALL_ROOT
95 cat >> ${install_work}/$SHRC <<EOF
96 #${DELIM} Setting products installation directory ${DELIM}
97 export INSTALL_ROOT=${install_root}
98
99 #${DELIM} Environment switch: 0 for SALOME building, 1 for SALOME launching ${DELIM}
100 export ENV_FOR_LAUNCH=1
101
102 EOF
103 ### !!! The next is for RedHat 9 only !!! 
104 if [ -f /etc/redhat-release ] ; then
105   grep -e "Red Hat Linux release 9" /etc/redhat-release > /dev/null
106   if [ $? -eq 0 ] ; then
107     cat >> ${install_work}/$SHRC <<EOF
108 #${DELIM} Force RH9 to use old implementation of threads ${DELIM}
109 export LD_ASSUME_KERNEL=2.4.18
110
111 EOF
112   fi
113 fi
114 ### !!! writing salome.csh file !!! -> set inital variables
115 pre_vars="PATH LD_LIBRARY_PATH LD_RUN_PATH PYTHONPATH TCLLIBPATH"
116 for i in $pre_vars ; do
117 cat >> ${install_work}/$CSHRC <<EOF
118 #${DELIM} setting initial ${i} ${DELIM}
119 if (! (\$?${i}) ) then
120   setenv $i
121 endif
122
123 EOF
124 done
125
126 ### !!! writing salome.(c)sh files !!! -> dump products environment files, changing 'export' by 'setenv(a|p)' where necessary
127 ### Note, that for performance reasons temporary environment files used during installation procedure itself
128 ### are created without using setenv(a|p) aliases.
129
130 # 1. first dump all environment files into the $SHRC file
131 product_sequence="$2"
132 for i in $product_sequence ; do
133     env_file=${install_work}/env_${i}.sh
134     ( test -e $env_file && cat $env_file >> ${install_work}/$SHRC 2>/dev/null )
135 done
136
137 # 2. writing global functions to _salome.sh file
138 cat >> ${install_work}/_$SHRC <<EOF
139 ##########################################################################
140 # Functions exporta and exportp are used to append/prepend correspondingly 
141 # one directory or a set of directories separated by semicolon symbol (':')
142 # to the environment variables like PATH, LD_LIBRARY_PATH, PYTHONPATH,
143 # LD_RUN_PATH etc. 
144 # The main purpose is to replace default setenv command behavior:
145 # exporta, exportp also remove duplicated entries, shortening in that way
146 # the environment variables.
147 # If some directory being added is already included into the variable
148 # nothing is done for it.
149 # Note, that these functions work some slower that setenv command itself.
150 #
151 #### cleandup ###
152 # appends/prepends set of directories (second parameter) 
153 # to the another set of directories (first parameter) and
154 # removes duplicated entries;
155 # the third parameter defines the mode: 0 - append, 1 - prepend
156 cleandup() {
157 out_var=\`echo \$1 \$2 | awk -v dir=\$3 '{                   \\
158     na = split(\$2,a,":");                                \\
159     if ( \$1 == "<empty>") nb = split("",b,":");          \\
160     else nb = split(\$1,b,":");                           \\
161     s = "" ;                                             \\
162     for(i=1;i<=nb;i++) {                                 \\
163         if(!(b[i] in ccc)) {                             \\
164             if(length(s)!=0)                             \\
165                 s = sprintf("%s:",s);                    \\
166             s = sprintf("%s%s",s,b[i]);                  \\
167             ccc[b[i]];                                   \\
168         };                                               \\
169     };                                                   \\
170     s1 = "";                                             \\
171     for(i=1;i<=na;i++) {                                 \\
172         if(!(a[i] in ccc)) {                             \\
173             if(length(s1)!=0)                            \\
174                 s1 = sprintf("%s:",s1);                  \\
175             s1 = sprintf("%s%s",s1,a[i]);                \\
176             ccc[a[i]];                                   \\
177         };                                               \\
178     };                                                   \\
179     if(dir)                                              \\
180         s = length(s) == 0 ? s1 : sprintf("%s:%s",s1,s); \\
181     else                                                 \\
182         s = length(s1) == 0 ? s : sprintf("%s:%s",s,s1); \\
183     printf("%s\n",s);                                    \\
184     }'\`
185 echo \$out_var
186 }
187 ### exporta ###
188 # appends directory or set of directories, separated by ':' (second parameter)
189 # to the variable (first parameter)
190 exporta () { 
191 xenv=\`printenv \$1\`
192 if [ -z "\$xenv" ]; then xenv="<empty>"; fi
193 out_var=\`cleandup \$xenv \$2 0\`
194 export \$1=\$out_var
195 }
196 ### exportp ###
197 # prepends directory or set of directories, separated by ':' (second parameter)
198 # to the variable (first parameter)
199 exportp () { 
200 xenv=\`printenv \$1\`
201 if [ -z "\$xenv" ]; then xenv="<empty>"; fi
202 out_var=\`cleandup \$xenv \$2 1\`
203 export \$1=\$out_var
204 }
205 ###########################################################################
206
207 EOF
208
209 # 3. writing global functions to _salome.csh file
210 cat >> ${install_work}/_$CSHRC <<EOF
211 ###########################################################################
212 # Aliases setenva and setenvp are used to append/prepend correspondingly 
213 # one directory or a set of directories separated by semicolon symbol (':')
214 # to the environment variables like PATH, LD_LIBRARY_PATH, PYTHONPATH,
215 # LD_RUN_PATH etc. 
216 # The main purpose is to replace default setenv command behavior:
217 # setenva, setenvp also remove duplicated entries, shortening in that way
218 # the environment variables.
219 # If some directory being added is already included into the variable
220 # nothing is done for it.
221 # Note, that these aliases work some slower that setenv command itself.
222 #
223 #### cleandup ###
224 # appends/prepends set of directories (second parameter) 
225 # to the another set of directories (first parameter) and
226 # removes duplicated entries;
227 # the third parameter defines the mode: 0 - append, 1 - prepend
228 alias cleandup "echo \!:1 \!:2 | awk -v dir=\!:3         \\\\
229 '"'{ na = split(\$2,a,":");                               \\\\
230      nb = split(\$1,b,":");                               \\\\
231      s = "" ;                                            \\\\
232      for(i=1;i<=nb;i++) {                                \\\\
233         if(!(b[i] in ccc)) {                             \\\\
234             if(length(s)!=0)                             \\\\
235                 s = sprintf("%s:",s);                    \\\\
236             s = sprintf("%s%s",s,b[i]);                  \\\\
237             ccc[b[i]];                                   \\\\
238         };                                               \\\\
239     };                                                   \\\\
240     s1 = "";                                             \\\\
241     for(i=1;i<=na;i++) {                                 \\\\
242         if(!(a[i] in ccc)) {                             \\\\
243             if(length(s1)!=0)                            \\\\
244                 s1 = sprintf("%s:",s1);                  \\\\
245             s1 = sprintf("%s%s",s1,a[i]);                \\\\
246             ccc[a[i]];                                   \\\\
247         };                                               \\\\
248     };                                                   \\\\
249     if(dir)                                              \\\\
250         s = length(s) == 0 ? s1 : sprintf("%s:%s",s1,s); \\\\
251     else                                                 \\\\
252         s = length(s1) == 0 ? s : sprintf("%s:%s",s,s1); \\\\
253     printf("%s\n",s);                                    \\\\
254     }'"'"
255 ### setenva ###
256 # appends directory or set of directories, separated by ':' (second parameter)
257 # to the variable (first parameter)
258 alias setenva 'set a=\!:1 ; set b=\!:2 ;  \\
259                set c=\`printenv \$a\` ;      \\
260                set b=\`cleandup \$c \$b 0\` ; \\
261                setenv \$a \$b ;             \\
262                unset a, b, c'
263
264 ### setenvp ###
265 # prepends directory or set of directories, separated by ':' (second parameter)
266 # to the variable (first parameter)
267 alias setenvp 'set a=\!:1 ; set b=\!:2 ;  \\
268                set c=\`printenv \$a\` ;      \\
269                set b=\`cleandup \$c \$b 1\` ; \\
270                setenv \$a \$b ;             \\
271                unset a, b, c'
272 ###########################################################################
273
274 EOF
275 cat ${install_work}/$CSHRC >> ${install_work}/_$CSHRC
276
277 # 4. put the contents of salome.sh to _salome.sh replacing export by export(a|p) aliases where necessary
278 sed -e 's%export\([[:blank:]]*\)PATH=\$[{]\?PATH[}]\?:\(.*\)%exporta\1PATH \2%g' -e 's%export\([[:blank:]]*\)PATH=\(.*\):\$[{]\?PATH[}]\?%exportp\1PATH \2%g' ${install_work}/$SHRC > ${INSTALL_WORK}/_tmp1 2>/dev/null
279 sed -e 's%export\([[:blank:]]*\)LD_LIBRARY_PATH=\$[{]\?LD_LIBRARY_PATH[}]\?:\(.*\)%exporta\1LD_LIBRARY_PATH \2%g' -e 's%export\([[:blank:]]*\)LD_LIBRARY_PATH=\(.*\):\$[{]\?LD_LIBRARY_PATH[}]\?%exportp\1LD_LIBRARY_PATH \2%g' ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
280 sed -e 's%export\([[:blank:]]*\)PYTHONPATH=\$[{]\?PYTHONPATH[}]\?:\(.*\)%exporta\1PYTHONPATH \2%g' -e 's%export\([[:blank:]]*\)PYTHONPATH=\(.*\):\$[{]\?PYTHONPATH[}]\?%exportp\1PYTHONPATH \2%g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
281 sed -e 's%export\([[:blank:]]*\)LD_RUN_PATH=\$[{]\?LD_RUN_PATH[}]\?:\(.*\)%exporta\1LD_RUN_PATH \2%g' -e 's%export\([[:blank:]]*\)LD_RUN_PATH=\(.*\):\$[{]\?LD_RUN_PATH[}]\?%exportp\1LD_RUN_PATH \2%g' ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2
282 cat ${INSTALL_WORK}/_tmp2 >> ${install_work}/_$SHRC
283
284 # 5. Create a salome.csh file from salome.sh by replacing export by setenv, etc.
285 sed -e 's%export \([[:alnum:]_[:blank:]]*\)\=%setenv \1 %g' ${install_work}/$SHRC > ${INSTALL_WORK}/_tmp1 2>/dev/null
286 cat ${INSTALL_WORK}/_tmp1 >> ${install_work}/$CSHRC
287
288 # 6. Create a _salome.csh file from _salome.sh by replacing export by setenv, exporta by setenva, etc.
289 sed -e 's%export \([[:alnum:]_[:blank:]]*\)\=%setenv \1 %g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
290 sed -e 's%exporta \([[:alnum:]_[:blank:]]*\)%setenva \1%g'  ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
291 sed -e 's%exportp \([[:alnum:]_[:blank:]]*\)%setenvp \1%g'  ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
292 sed -e 's%if \[ -n "\${ENV_FOR_LAUNCH}" \] ; then%if ( ${?ENV_FOR_LAUNCH} ) then%g' ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
293 sed -e 's%if \[ "\${ENV_FOR_LAUNCH}" == "1" \] ; then%if ( "\${ENV_FOR_LAUNCH}" == "1" ) then%g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
294 sed -e 's%^\([[:blank:]]*\)fi\([[:blank:]]*\)$%\1endif\2%g' ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
295 cat ${INSTALL_WORK}/_tmp2 >> ${install_work}/_$CSHRC 2>/dev/null
296
297 rm -f ${INSTALL_WORK}/_tmp1 ${INSTALL_WORK}/_tmp2
298
299 if [ $# -eq 4 ] ; then
300     product_dir=$4
301     if [ -e ${product_dir} ] ; then
302         cp -f ${install_work}/_$SHRC  ${product_dir}/$SHRC
303         cp -f ${install_work}/_$CSHRC ${product_dir}/$CSHRC
304     fi
305 fi
306 sed -e 's%setenv ENV_FOR_LAUNCH 1%setenv ENV_FOR_LAUNCH 0%' ${install_work}/_$CSHRC > ${install_root}/env_build.csh
307 # Setting "/usr/X11R6/lib" path in LD_LIBRARY_PATH for the libGL.so.1 file
308 echo "setenv LD_LIBRARY_PATH /usr/X11R6/lib:${LD_LIBRARY_PATH}" >> ${install_root}/env_build.csh
309
310 sed -e 's%export ENV_FOR_LAUNCH=1%export ENV_FOR_LAUNCH=0%' ${install_work}/_$SHRC  > ${install_root}/env_build.sh
311 # Setting "/usr/X11R6/lib" path in LD_LIBRARY_PATH for the libGL.so.1 file
312 echo "export LD_LIBRARY_PATH=/usr/X11R6/lib:${LD_LIBRARY_PATH}" >> ${install_root}/env_build.sh
313
314 cp -f ${install_work}/_$CSHRC ${install_root}/env_products.csh
315 # Setting "/usr/X11R6/lib" path in LD_LIBRARY_PATH for the libGL.so.1 file
316 echo "setenv LD_LIBRARY_PATH /usr/X11R6/lib:${LD_LIBRARY_PATH}" >> ${install_root}/env_products.csh
317
318 cp -f ${install_work}/_$SHRC  ${install_root}/env_products.sh
319 # Setting "/usr/X11R6/lib" path in LD_LIBRARY_PATH for the libGL.so.1 file
320 echo "export LD_LIBRARY_PATH=/usr/X11R6/lib:${LD_LIBRARY_PATH}" >> ${install_root}/env_products.sh
321
322 rm -f ${install_work}/_$SHRC ${install_work}/_$CSHRC
323 ### !!! copying build.csh script
324 if [ -e ./build.csh ]; then
325     cp -f ./build.csh ${install_root}
326 fi
327 }
328
329 #try use already existing product
330 try_existing()
331 {
332 product_dir=$1;  install_root=$2;  install_work=$3;  product_sequence="$4";  product_type=$5
333 env_file=${product_dir}/env_${product_type}.sh
334 if [ -f ${env_file} ] ; then
335     cp -f ${env_file} ${install_work}
336     make_env ${install_root} ${install_work} "${product_sequence}"
337     source ${install_work}/$SHRC
338     check_version
339     if [ $? -eq 0 ] ; then
340         if [ -d ${product_dir} ] && [ -w ${product_dir} ] ; then
341             #makedir ${product_dir}
342             print_env
343             return 0    
344         fi
345     else
346         rm -f ${install_work}/env_${product_type}.sh
347         make_env ${install_root} ${install_work} "${product_sequence}"
348     fi
349 fi
350 return 1;
351 }
352
353 #check existance of lib passed as first parameter
354 #return 0 if lib exists
355 #if you pass second parameter search will be done in it 
356 #otherwise search will be done in $LD_LIBRARY_PATH
357 #you should use : as dilimeter if you are going to pass second parameter
358 check_lib_version(){
359 if [ -n "$2" ]; then
360    whereIs=$2
361 else
362    whereIs=$LD_LIBRARY_PATH
363 fi
364 for L in `echo ${whereIs} | sed -e"s%:% %g"` ;  do
365     ret=`find $L -name $1 2>/dev/null`
366     if [ -n "$ret" ] ; then
367         #echo "The $1 exists on yours system in a $L folder"
368         return 0
369     fi
370 done
371 return 1
372 }
373
374 find_in_path(){
375 file=$1;  shift; 
376 path=$*
377 for i in `echo ${path} | sed -e"s%:% %g"` ; do 
378     ret=`find $i -name $file -maxdepth 1 2>/dev/null`
379     if [ -n "$ret" ] ; then
380         ret=`echo $ret | sed -e"s%/\$file$%%g"`
381         echo $ret
382         return 0
383     fi
384 done
385 return 1
386 }
387
388 sort_path(){
389 arg1=$1;  val1=$2;  arg2=$3;  val2=$4
390 tmp="^$val1$|^$val1:|:$val1$|:$val1:"
391 #echo $val2 | grep -E "$tmp" >/dev/null 2>&1
392 #if [ $? -eq 0 ] ; then 
393 #    echo "$arg2"
394 #    return
395 #fi
396 to_tail=1
397 exclude_list="usr lib bin sbin etc"
398 for i in ${exclude_list} ; do
399     tmp="^/$i/|^/$i\$"
400     echo ${val1} | grep -E "$tmp" >/dev/null 2>&1
401     if [ $? == 0 ] ; then to_tail=0; break; fi
402 done
403 if [ $to_tail -eq 0 ] ; then
404     echo $arg2:$arg1
405 else
406     echo $arg1:$arg2
407 fi
408 return $to_tail
409 }
410
411 where_gcc(){
412 maj_ver=`echo $1 | awk -F. '{if(NF>0) print $1; else print 0}'`
413 min_ver=`echo $1 | awk -F. '{if(NF>1) print $2; else print 0}'`
414 rel_ver=`echo $1 | awk -F. '{if(NF>2) print $3; else print 0}'`
415 let ver=$maj_ver*10000+$min_ver*100+$rel_ver
416 newer=""
417 newerver=0
418 for i in `echo ${PATH}:/usr/bin:/usr/local/bin | sed -e"s%:% %g"` ; do 
419     ret=`find $i -name gcc -maxdepth 1 2>/dev/null`
420     if [ -n "$ret" ] ; then
421         maj_ver=`$ret -dumpversion | awk -F. '{if(NF>0) print $1; else print 0}'`
422         min_ver=`$ret -dumpversion | awk -F. '{if(NF>1) print $2; else print 0}'`
423         rel_ver=`$ret -dumpversion | awk -F. '{if(NF>2) print $3; else print 0}'`
424         let ver1=$maj_ver*10000+$min_ver*100+$rel_ver
425         if [ $ver1 -eq $ver ] ; then
426             ret=`echo $ret | sed -e"s%/gcc$%%g"`
427             echo $ret
428             return 0
429         fi
430         if [ $ver1 -gt $ver ] && [ $ver1 -gt $newerver ] ; then
431             let newerver=$ver1
432             newer=`echo $ret | sed -e"s%/gcc$%%g"`
433         fi
434     fi
435 done
436 if [ -n "$newer" ] ; then
437     echo $newer
438     return 0
439 fi
440 return 1
441 }
442
443 where_tcl(){
444 if test -z "${TCLHOME}"; then
445     TCLHOME=/usr
446 fi
447 tclcfg=`find ${TCLHOME}/lib -name "tclConfig.sh" 2> /dev/null`
448 file=""
449 maxver=0
450 for f in $tclcfg; do
451     ver=`cat $f | grep -e "TCL_VERSION=.*" | sed -e "s%TCL_VERSION=[\'|\"]\(.*\)[\'|\"]%\1%g" | awk -F. '{x=0;for(i=1;i<=3;i++){x=x*100;if(i<=NF)x+=$i;}print x;}'`
452     if [ $maxver -lt $ver ]; then
453         maxver=$ver
454         file=$f
455     fi
456 done
457 if test -n "$file"; then
458     echo `dirname $file`
459     return 0
460 else
461     echo ""
462     return 1
463 fi
464 }
465
466 where_tk(){
467 if test -z "${TCLHOME}"; then
468     TCLHOME=/usr
469 fi
470 tclcfg=`find ${TCLHOME}/lib -name "tkConfig.sh" 2> /dev/null`
471 file=""
472 maxver=0
473 for f in $tclcfg; do
474     ver=`cat $f | grep -e "TK_VERSION=.*" | sed -e "s%TK_VERSION=[\'|\"]\(.*\)[\'|\"]%\1%g" | awk -F. '{x=0;for(i=1;i<=3;i++){x=x*100;if(i<=NF)x+=$i;}print x;}'`
475     if [ $maxver -lt $ver ]; then
476         maxver=$ver
477         file=$f
478     fi
479 done
480 if test -n "$file"; then
481     echo `dirname $file`
482     return 0
483 else
484     echo ""
485     return 1
486 fi
487 }
488
489 where_dps(){
490 if test -f /usr/X11R6/include/DPS/dpsconfig.h ; then
491     echo "/usr/X11R6"
492     return 0
493 fi
494 if test -f /usr/include/DPS/dpsconfig.h ; then
495     echo "/usr"
496     return 0
497 fi
498 echo ""
499 return 1
500 }
501
502 modif_la_files(){
503 ldir=$1
504 if [ -z "$ldir" ] || [ ! -d "$ldir" ]; then return 1; fi
505
506 srcdir=`pwd`
507
508 SALOME_MODULES="`env | awk -F_ '/[[:alnum:]]*_ROOT_DIR/ { print $1 }'`"
509
510 cd $ldir
511 ldir=`pwd`
512 la_files=`find . -name "*.la"`
513
514 for l in X ${la_files}; do
515 if [ "$l" != "X" ] ; then
516     d=`dirname $l`
517     l=`basename $l`
518     cd $ldir; cd $d
519     # 1. process salome modules dependencies
520     for mod in $SALOME_MODULES; do
521         moddir=`printenv ${mod}_ROOT_DIR`
522         if [ -n "${moddir}" ] ; then
523             #echo $l $mod $moddir
524             sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*${mod}[^[:space:]/]*/lib% \1${moddir}/lib%g" $l > $l"_"
525             mv -f $l"_" $l
526         fi
527     done
528     # 2. process CAS.CADE dependencies
529     casdir=`printenv CASROOT`/lib
530     if [ ! -d ${casdir} ] ; then casdir=`printenv CASROOT`/Linux/lib ; fi
531     if [ ! -d ${casdir} ] ; then casdir=`printenv CASROOT`/lin/lib ; fi
532     if [ -n "${CASROOT}" ] && [ -d "${casdir}" ] ; then
533         # echo $l $CASROOT $casdir
534         sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*\(OCT\|CAS\)[^[:space:]/]*/Linux/lib% \1${casdir}%g" \
535             -e "s%[[:space:]]\(-L\)\?[^[:space:]]*\(OCT\|CAS\)[^[:space:]/]*/lin/lib% \1${casdir}%g"   \
536             -e "s%[[:space:]]\(-L\)\?[^[:space:]]*\(OCT\|CAS\)[^[:space:]/]*/lib% \1${casdir}%g" $l > $l"_"
537         mv -f $l"_" $l
538     fi
539     # 3. process omniORB dependencies
540     omnidir=`printenv OMNIORBDIR`/lib/i586_linux_2.0_glibc2.1
541     if [ ! -d ${omnidir} ] ; then omnidir=`printenv OMNIORBDIR`/lib ; fi
542     if [ -n "${OMNIORBDIR}" ] && [ -d "${omnidir}" ] ; then
543         # echo $l $OMNIORBDIR $omnidir
544         sed -e "s%-L[^[:space:]]*omni[^[:space:]]*%-L${omnidir}%g" $l > $l"_"
545         mv -f $l"_" $l
546     fi
547     # 4. process VTK dependencies
548     vtkdir=`printenv VTKHOME`/lib/vtk
549     if [ -n "${VTKHOME}" ] && [ -d "${vtkdir}" ] ; then
550         # echo $l $VTKHOME $vtkdir
551         sed -e "s%-L[^[:space:]]*VTK[^[:space:]]*/lib/vtk%-L${vtkdir}%g" $l > $l"_"
552         mv -f $l"_" $l
553     fi
554     # 5. process HDF dependencies
555     hdfdir=`printenv HDF5HOME`/lib
556     if [ -n "${HDF5HOME}" ] && [ -d "${hdfdir}" ] ; then
557         # echo $l $HDF5HOME $hdfdir
558         sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*hdf[^[:space:]/]*/lib% \1${hdfdir}%g" $l > $l"_"
559         mv -f $l"_" $l
560     fi
561     # 6. process MED dependencies
562     meddir=`printenv MED2HOME`/lib
563     if [ -n "${MED2HOME}" ] && [ -d "${meddir}" ] ; then
564         # echo $l $MED2HOME $meddir
565         sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*med[^[:space:]/]*/lib% \1${meddir}%g" $l > $l"_"
566         mv -f $l"_" $l
567     fi
568     # 7. process qwt dependencies
569     qwtdir=`find_in_path libqwt.so ${LD_LIBRARY_PATH}`
570     if [ -n "${qwtdir}" ] && [ -d "${qwtdir}" ] ; then
571         # echo $l $qwtdir
572         sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*qwt[^[:space:]/]*/lib% \1${qwtdir}%g" $l > $l"_"
573         mv -f $l"_" $l
574     fi
575     # 8. process qt dependencies
576     qtdir=`printenv QTDIR`/lib
577     if [ -n "${QTDIR}" ] && [ -d "${qtdir}" ] ; then
578         # echo $l $QTDIR $qtdir
579         sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*qt[^[:space:]/]*/lib% \1${qtdir}%g" $l > $l"_"
580         mv -f $l"_" $l
581     fi
582     # 9. process python dependencies
583     where_python=`which python`                 # e.g. /usr/bin/python
584     if [ -n "$where_python" ] ; then
585         where_python=`dirname $where_python`    # --> /usr/bin
586         where_python=`dirname $where_python`    # --> /usr
587         python_version=`python -c "import sys; print sys.version[:3]"`
588         # echo $l $where_python $python_version
589         sed -e "s%-L[^[:space:]]*python[0-9]\.[0-9]\([^[:space:]]*\)%-L${where_python}/lib/python${python_version}\1%g" $l > $l"_"
590         mv -f $l"_" $l
591     fi
592     # 10. process sip dependencies
593     sipdir=`find_in_path sip.so ${LD_LIBRARY_PATH}`
594     if [ -n "${sipdir}" ] && [ -d "${sipdir}" ] ; then
595         # echo $l $sipdir
596         sed -e "s%-L[^[:space:]]*sip[^[:space:]]*%-L${sipdir}%g" $l > $l"_"
597         mv -f $l"_" $l
598     fi
599     # 11. process PyQt dependencies
600     pyqtdir=`find_in_path qt.so ${LD_LIBRARY_PATH}`
601     if [ -n "${pyqtdir}" ] && [ -d "${pyqtdir}" ] ; then
602         # echo $l $pyqtdir
603         sed -e "s%-L[^[:space:]]*PyQt[^[:space:]]*%-L${pyqtdir}%g" $l > $l"_"
604         mv -f $l"_" $l
605     fi
606     # 12. process tcl/tk dependencies
607     tcldir=`printenv TCLHOME`/lib
608     if [ -n "${tcldir}" ] && [ -d "${tcldir}" ] ; then
609         # echo $l $TCLHOME $tcldir
610         sed -e "s%-L[^[:space:]]*tcltk[^[:space:]]*/lib%-L${tcldir}%g" $l > $l"_"
611         mv -f $l"_" $l
612     fi
613     # 13. process boost dependencies
614     boostdir=`printenv BOOSTDIR`/lib
615     if [ -n "${boostdir}" ] && [ -d "${boostdir}" ] ; then
616         # echo $l $BOOSTDIR $boostdir
617         sed -e "s%-L[^[:space:]]*boost[^[:space:]]*/lib%-L${boostdir}%g" $l > $l"_"
618         mv -f $l"_" $l
619     fi
620     # 14. modify libdir
621     #sed -e "s%^libdir='\(.*\)'%libdir='${PRODUCT_DIR}/lib/salome'%g" $l > $l"_"
622     mod=`basename $ldir | awk -F_ '{print $1}'`
623     moddir=`printenv ${mod}_ROOT_DIR`
624     sed -e "s%^libdir='[^[:space:]]*${mod}[^[:space:]]*/\(lib.*\)'%libdir='${moddir}/\1'%g" $l > $l"_"
625     mv -f $l"_" $l
626 fi
627 done
628
629 cd $srcdir
630 return 0
631 }