]> SALOME platform Git repositories - tools/install.git/blob - config_files/common.sh
Salome HOME
Update patch for ParaView 4.1: add fix for issue 0022593: [CEA 1175] PARAVIS segmenta...
[tools/install.git] / config_files / common.sh
1 #!/bin/bash -noprofile
2
3 ####################################################################################
4 #  File      : common.sh
5 #  Created   : Thu Dec 18 12:01:00 2002
6 #  Author    : Vadim SANDLER, Open CASCADE SAS (vadim.sandler@opencascade.com)
7 #  Project   : SALOME
8 #  Module    : Installation Wizard
9 #  Copyright : 2002-2014 CEA
10 #
11 #  This script is the part of the SALOME installation procedure.
12 #
13 ####################################################################################
14
15 export DELIM="------"
16 export SHRC="salome.sh"
17 export CSHRC="salome.csh"
18
19 #####################################################
20 # !WARNING! This is current SALOME version number
21 ####################################################
22 export SALOME_VERSION="7.4.0"
23 export YACSGEN_VERSION=${SALOME_VERSION}
24
25 # Name of the single directory for SALOME modules
26 export SDIR_NAME="SALOME_${SALOME_VERSION}"
27
28 #this function takes one parameter - path to module source folder
29 check_salome_src_version(){
30 root_dir=${!1}
31
32 if [ -n "${root_dir}" ]; then
33     cfg_file=configure.ac
34     if [ ! -f ${root_dir}/${cfg_file} ] ; then
35         cfg_file=configure.in.base
36         else
37             cfg_file=CMakeLists.txt
38         fi
39     if [ -f ${root_dir}/${cfg_file} ] ; then
40         if [ "${cfg_file}" = "CMakeLists.txt" ] ; then
41             ver_maj=`cat ${root_dir}/${cfg_file} | grep SET\(VERSION_MAJOR | sed -e "s%[A-Z_() ]%%g"`
42             ver_min=`cat ${root_dir}/${cfg_file} | grep SET\(VERSION_MINOR | sed -e "s%[A-Z_() ]%%g"`
43             ver_maintenance=`cat ${root_dir}/${cfg_file} | grep SET\(VERSION_MAINTENANCE | sed -e "s%[A-Z_() ]%%g"`
44             ver="${ver_maj}.${ver_min}.${ver_maintenance}"
45         else
46             ver=`grep -e "^AC_INIT" ${root_dir}/${cfg_file} | sed -e "s%.*\[\([[:digit:].]*\)\].*%\1%g"`
47         fi
48
49         if [ "${ver}" = "${SALOME_VERSION}" ]; then
50             return 0
51         fi
52     fi
53 fi
54 return 1
55 }
56
57 #this function takes several parameters
58 #first parameter contains descriptor of output file
59 #next parameters is command for execution
60 #in case of bad result of execution ask user about furher steps
61 #(user can cancel installation procedure)
62 check_job()
63 {
64   out=$1
65   shift
66   errfile=/tmp/errlog
67   if [ -n "${INSTALL_WORK}" ] ; then errfile=${INSTALL_WORK}/errlog; fi
68   cmd="`pwd` -> $*"
69   if [ "${out}" != "1" ] ; then cmd="${cmd} >> ${out}" ; fi
70   echo -e ${cmd}
71   if [ "${out}" != "1" ] ; then
72       $* >> ${out} 2>${errfile}
73   else
74       $*
75   fi
76   if [ "$?" -ne "0" ] ; then
77     if [ ${out} != "1" ] ; then
78       cat ${out}
79       cat ${errfile} >&2
80       cat ${errfile} >> ${out}
81     fi
82     # VSR : 10/11/05: disable answer mode ==>
83     #echo -n " " >&2
84     #echo -e "NOT DONE !!! => $*"
85     #echo -n "Would you like to continue to install this product: (Y,N) [Y] : "
86     #read rep;
87     #rep=`echo ${rep}  | tr "[A-Z]" "[a-z]"`
88     #if test -z ${rep} || [ ${rep} = "y" ] ; then
89     #  return 1
90     #fi
91     # VSR : 10/11/05: disable answer mode <==
92     exit 1
93   fi
94   return 0
95 }
96
97 #invoke check_job function
98 #all output will be put into terminal
99 check_jb()
100 {
101   check_job 1 $*
102   return
103 }
104
105 # make directory
106 makedir()
107 {
108   rm -rf "$1" > /dev/null
109   mkdir -p "$1"
110 }
111
112 #create environment for sh and csh
113 make_env()
114 {
115 install_root=$1;  shift
116 install_work=$1;
117
118 for i in ${SHRC} ${CSHRC} ; do
119     if [ -e ${install_work}/${i} ]; then
120         rm ${install_work}/${i}
121     fi
122     touch ${install_work}/${i}
123 done
124
125 if [ $# -eq 4 ] ; then
126     product_name=$4;
127     product_env=${install_work}/env_${product_name}.sh
128     (test -e ${product_env} && rm ${product_env} )
129 fi
130 ### !!! writing salome.sh file !!!  -> define INST_ROOT
131 cat >> ${install_work}/${SHRC} <<EOF
132 #${DELIM} Setting products installation directory ${DELIM}
133 export INST_ROOT=${install_root}
134
135 #${DELIM} Environment switch: 0 for SALOME building, 1 for SALOME launching ${DELIM}
136 export ENV_FOR_LAUNCH=1
137
138 #${DELIM} Setting numeric locale ${DELIM}
139 export LC_NUMERIC=C
140
141 EOF
142 ### !!! The next is for RedHat 9 only !!!
143 if [ -f /etc/redhat-release ] ; then
144   grep -e "Red Hat Linux release 9" /etc/redhat-release > /dev/null
145   if [ $? -eq 0 ] ; then
146     cat >> ${install_work}/${SHRC} <<EOF
147 #${DELIM} Force RH9 to use old implementation of threads ${DELIM}
148 export LD_ASSUME_KERNEL=2.4.18
149
150 EOF
151   fi
152 fi
153 ### !!! writing salome.csh file !!! -> set inital variables
154 pre_vars="PATH LD_LIBRARY_PATH LD_RUN_PATH PYTHONPATH TCLLIBPATH"
155 for i in ${pre_vars} ; do
156 cat >> ${install_work}/${CSHRC} <<EOF
157 #${DELIM} setting initial ${i} ${DELIM}
158 if (! (\$?${i}) ) then
159   setenv ${i}
160 endif
161
162 EOF
163 done
164
165 ### !!! writing salome.(c)sh files !!! -> dump products environment files, changing 'export' by 'setenv(a|p)' where necessary
166 ### Note, that for performance reasons temporary environment files used during installation procedure itself
167 ### are created without using setenv(a|p) aliases.
168
169 # 0. add /usr/lib or /usr/lib64 dir to the LD_LIBRARY_PATH
170 #if test `uname -m` = "x86_64" ; then
171 #echo 'export LD_LIBRARY_PATH=/usr/lib64:${LD_LIBRARY_PATH}' >> ${install_work}/${SHRC} 2>/dev/null
172 #echo '' >> ${install_work}/${SHRC} 2>/dev/null
173 #else
174 #echo 'export LD_LIBRARY_PATH=/usr/lib:${LD_LIBRARY_PATH}' >> ${install_work}/${SHRC} 2>/dev/null
175 #echo '' >> ${install_work}/${SHRC} 2>/dev/null
176 #fi
177
178 # 1. first dump all environment files into the ${SHRC} file
179 product_sequence="$2"
180 install_products="$3"
181 for i in ${product_sequence} ; do
182     env_file=${install_work}/env_${i}.sh
183     _env_file=${install_work}/_env_${i}.sh
184     if [ -e ${_env_file} ] ; then
185         cat ${_env_file} >> ${install_work}/${SHRC} 2>/dev/null
186     elif [ -e ${env_file} ] ; then
187         echo ${install_products} | grep -q "\b${i}\b"
188         if [ $? -eq 1 ] ; then
189             cat ${env_file} | sed 's/^/## /' >> ${install_work}/${SHRC} 2>/dev/null
190         else
191             cat ${env_file} >> ${install_work}/${SHRC} 2>/dev/null
192         fi
193     fi
194 done
195
196 # 2. writing global functions to _salome.sh file
197 cat >> ${install_work}/_${SHRC} <<EOF
198 ##########################################################################
199 # Functions exporta and exportp are used to append/prepend correspondingly
200 # one directory or a set of directories separated by semicolon symbol (':')
201 # to the environment variables like PATH, LD_LIBRARY_PATH, PYTHONPATH,
202 # LD_RUN_PATH etc.
203 # The main purpose is to replace default setenv command behavior:
204 # exporta, exportp also remove duplicated entries, shortening in that way
205 # the environment variables.
206 # If some directory being added is already included into the variable
207 # nothing is done for it.
208 # Note, that these functions work some slower that setenv command itself.
209 #
210 #### cleandup ###
211 # appends/prepends set of directories (second parameter)
212 # to the another set of directories (first parameter) and
213 # removes duplicated entries;
214 # the third parameter defines the mode: 0 - append, 1 - prepend
215 cleandup() {
216 out_var=\`echo \$1 \$2 | awk -v dir=\$3 '{                   \\
217      na = split(\$2,a,":");                               \\
218      k1=0;                                               \\
219      bbb[k1++]="";                                       \\
220      ccc[""];                                            \\
221      if(\$1 != "<empty>") {                               \\
222        nb = split(\$1,b,":");                             \\
223        for(i=1;i<=nb;i++) {                              \\
224          if(!(b[i] in ccc) ) {                           \\
225            ccc[b[i]];                                    \\
226            bbb[k1++]=b[i];                               \\
227          };                                              \\
228        };                                                \\
229      };                                                  \\
230      k2=0;                                               \\
231      aaa[k2++]="";                                       \\
232      for(i=1;i<=na;i++) {                                \\
233        if(!(a[i] in ccc)) {                              \\
234          ccc[a[i]];                                      \\
235          aaa[k2++]=a[i];                                 \\
236        };                                                \\
237      };                                                  \\
238      ORS=":";                                            \\
239      if(dir) {                                           \\
240        for(i=1;i<k2;i++) {                               \\
241          print aaa[i];                                   \\
242        }                                                 \\
243        for(i=1;i<k1;i++) {                               \\
244          print bbb[i];                                   \\
245        }                                                 \\
246      }                                                   \\
247      else {                                              \\
248        for(i=1;i<k1;i++) {                               \\
249          print bbb[i];                                   \\
250        }                                                 \\
251        for(i=1;i<k2;i++) {                               \\
252          print aaa[i];                                   \\
253        }                                                 \\
254      }                                                   \\
255    }' | sed -e 's/\(.*\):/\1/g'\`
256 echo \${out_var}
257 }
258 ### exporta ###
259 # appends directory or set of directories, separated by ':' (second parameter)
260 # to the variable (first parameter)
261 exporta () {
262 xenv=\${!1}
263 if [ -z "\${xenv}" ]; then xenv="<empty>"; fi
264 out_var=\`cleandup \${xenv} \$2 0\`
265 export \$1=\${out_var}
266 }
267 ### exportp ###
268 # prepends directory or set of directories, separated by ':' (second parameter)
269 # to the variable (first parameter)
270 exportp () {
271 xenv=\${!1}
272 if [ -z "\${xenv}" ]; then xenv="<empty>"; fi
273 out_var=\`cleandup \${xenv} \$2 1\`
274 export \$1=\${out_var}
275 }
276 ###########################################################################
277
278 EOF
279
280 # 3. writing global functions to _salome.csh file
281 cat >> ${install_work}/_${CSHRC} <<EOF
282
283 ###########################################################################
284 # Aliases setenva and setenvp are used to append/prepend correspondingly
285 # one directory or a set of directories separated by semicolon symbol (':')
286 # to the environment variables like PATH, LD_LIBRARY_PATH, PYTHONPATH,
287 # LD_RUN_PATH etc.
288 # The main purpose is to replace default setenv command behavior:
289 # setenva, setenvp also remove duplicated entries, shortening in that way
290 # the environment variables.
291 # If some directory being added is already included into the variable
292 # nothing is done for it.
293 # Note, that these aliases work some slower that setenv command itself.
294 #
295 #### cleandup ###
296 # appends/prepends set of directories (second parameter)
297 # to the another set of directories (first parameter) and
298 # removes duplicated entries;
299 # the third parameter defines the mode: 0 - append, 1 - prepend
300 alias cleandup "echo \!:1 \!:2 | awk -v dir=\!:3         \\\\
301 '"'{ na = split(\$2,a,":");                               \\\\
302      k1=0;                                               \\\\
303      bbb[k1++]="";                                       \\\\
304      ccc[""];                                            \\\\
305      if(\$1 != "<empty>") {                               \\\\
306        nb = split(\$1,b,":");                             \\\\
307        for(i=1;i<=nb;i++) {                              \\\\
308          if(!(b[i] in ccc) ) {                           \\\\
309            ccc[b[i]];                                    \\\\
310            bbb[k1++]=b[i];                               \\\\
311          };                                              \\\\
312        };                                                \\\\
313      };                                                  \\\\
314      k2=0;                                               \\\\
315      aaa[k2++]="";                                       \\\\
316      for(i=1;i<=na;i++) {                                \\\\
317        if(!(a[i] in ccc)) {                              \\\\
318          ccc[a[i]];                                      \\\\
319          aaa[k2++]=a[i];                                 \\\\
320        };                                                \\\\
321      };                                                  \\\\
322      ORS=":";                                            \\\\
323      if(dir) {                                           \\\\
324        for(i=1;i<k2;i++) {                               \\\\
325          print aaa[i];                                   \\\\
326        }                                                 \\\\
327        for(i=1;i<k1;i++) {                               \\\\
328          print bbb[i];                                   \\\\
329        }                                                 \\\\
330      }                                                   \\\\
331      else {                                              \\\\
332        for(i=1;i<k1;i++) {                               \\\\
333          print bbb[i];                                   \\\\
334        }                                                 \\\\
335        for(i=1;i<k2;i++) {                               \\\\
336          print aaa[i];                                   \\\\
337        }                                                 \\\\
338      }                                                   \\\\
339   }'"' | sed -e 's/\(.*\):/\1/g'"
340 ### setenva ###
341 # appends directory or set of directories, separated by ':' (second parameter)
342 # to the variable (first parameter)
343 alias setenva 'set a=\!:1 ; set b=\!:2 ;      \\
344                set c=\`printenv \${a}\` ;        \\
345                set b=\`cleandup \${c} \${b} 0\` ; \\
346                setenv \${a} \${b} ;             \\
347                unset a, b, c'
348
349 ### setenvp ###
350 # prepends directory or set of directories, separated by ':' (second parameter)
351 # to the variable (first parameter)
352 alias setenvp 'set a=\!:1 ; set b=\!:2 ;      \\
353                set c=\`printenv \${a}\` ;        \\
354                set b=\`cleandup \${c} \${b} 1\` ; \\
355                setenv \${a} \${b} ;             \\
356                unset a, b, c'
357 ###########################################################################
358
359 EOF
360 cat ${install_work}/${CSHRC} >> ${install_work}/_${CSHRC}
361
362 # 4. put the contents of salome.sh to _salome.sh replacing export by export(a|p) aliases where necessary
363 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
364 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
365 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
366 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
367
368 cat ${INSTALL_WORK}/_tmp2 >> ${install_work}/_${SHRC}
369
370 # 5. Create a salome.csh file from salome.sh by replacing export by setenv, etc.
371 sed -e 's%export \([[:alnum:]_[:blank:]]*\)\=%setenv \1 %g' ${install_work}/${SHRC} > ${INSTALL_WORK}/_tmp1 2>/dev/null
372 cat ${INSTALL_WORK}/_tmp1 >> ${install_work}/${CSHRC}
373
374 # 6. Create a _salome.csh file from _salome.sh by replacing export by setenv, exporta by setenva, etc.
375 sed -e 's%export \([[:alnum:]_[:blank:]]*\)\=%setenv \1 %g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
376 sed -e 's%exporta \([[:alnum:]_[:blank:]]*\)%setenva \1%g'  ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
377 sed -e 's%exportp \([[:alnum:]_[:blank:]]*\)%setenvp \1%g'  ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
378 sed -e 's%if \[ -n "\${PYTHONPATH}" \] ; then%if ( ${?PYTHONPATH} ) then%g' ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
379 sed -e 's%if \[ -n "\${ENV_FOR_LAUNCH}" \] ; then%if ( ${?ENV_FOR_LAUNCH} ) then%g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
380 sed -e 's%if \[ "\${ENV_FOR_LAUNCH}" =\?= "1" \] ; then%if ( "\${ENV_FOR_LAUNCH}" == "1" ) then%g' ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
381 sed -e 's%^\([[:blank:]]*\)fi\([[:blank:]]*\)$%\1endif\2%g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
382 sed -e 's%var.sh%var.csh%g' ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
383 sed -e 's%if \[ -e "\${LICENSE_FILE}" \] ; then%if ( -e ${LICENSE_FILE} ) then%g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
384
385 cat ${INSTALL_WORK}/_tmp1 >> ${install_work}/_${CSHRC} 2>/dev/null
386
387 rm -f ${INSTALL_WORK}/_tmp1 ${INSTALL_WORK}/_tmp2
388
389 if [ $# -eq 5 ] ; then
390     product_dir=$5
391     if [ -e ${product_dir} ] ; then
392         test -e ${product_dir}/${SHRC} && mv ${product_dir}/${SHRC} ${product_dir}/${SHRC}_`date +%F_%T`
393         cp ${install_work}/_${SHRC}  ${product_dir}/${SHRC}
394         test -e ${product_dir}/${CSHRC} && mv ${product_dir}/${CSHRC} ${product_dir}/${CSHRC}_`date +%F_%T`
395         cp ${install_work}/_${CSHRC} ${product_dir}/${CSHRC}
396     fi
397 fi
398 sed -e 's%setenv ENV_FOR_LAUNCH 1%setenv ENV_FOR_LAUNCH 0%' ${install_work}/_${CSHRC} > ${install_root}/env_build.csh
399 sed -e 's%export ENV_FOR_LAUNCH=1%export ENV_FOR_LAUNCH=0%' ${install_work}/_${SHRC}  > ${install_root}/env_build.sh
400
401 cp -f ${install_work}/_${CSHRC} ${install_root}/env_products.csh
402 cp -f ${install_work}/_${SHRC}  ${install_root}/env_products.sh
403
404 rm -f ${install_work}/_${SHRC} ${install_work}/_${CSHRC}
405 ### !!! copying build.csh and build.sh scripts
406 if [ -e ./build.csh ] && [ ! -e ${install_root}/build.csh ]; then
407     cp -f ./build.csh ${install_root}
408 fi
409 if [ -e ./build.sh ] && [ ! -e ${install_root}/build.sh ]; then
410     cp -f ./build.sh ${install_root}
411 fi
412 ### !!! copying release notes
413 for p in `ls ../` ; do
414     export pdf=`echo ${p} | sed s/[.]/" "/g | awk '{print $2}'`
415     if [ "${pdf}" = "pdf" ]; then
416         export RN=${p}
417         if [ ! -e ${install_root}/${RN} ]; then
418             cp -f ../${RN} ${install_root}
419         fi
420     fi
421 done
422
423 }
424
425 #try use already existing product
426 try_existing()
427 {
428 product_dir=$1;  install_root=$2;  install_work=$3;
429 product_sequence="$4"; installed_products="$5";  product_type=$6
430 env_file=${product_dir}/env_${product_type}.sh
431 if [ -f ${env_file} ] ; then
432     cp -f ${env_file} ${install_work}/_env_${product_type}.sh
433     make_env ${install_root} ${install_work} "${product_sequence}" "${installed_products}"
434     source ${install_work}/${SHRC}
435     check_version
436     if [ $? -eq 0 ] ; then
437         return 0
438     fi
439 fi
440 echo ${product_type} | grep -q '_src$'
441 if [ $? -eq 1 ] ; then
442     print_env_bin
443 else
444     print_env_src
445 fi
446 return 0
447 }
448
449 #check existance of lib passed as first parameter
450 #return 0 if lib exists
451 #if you pass second parameter search will be done in it
452 #otherwise search will be done in ${LD_LIBRARY_PATH}
453 #you should use : as dilimeter if you are going to pass second parameter
454 check_lib_version(){
455 if [ -n "$2" ]; then
456    whereIs=$2
457 else
458    whereIs=${LD_LIBRARY_PATH}
459 fi
460 for d in `echo ${whereIs} | sed -e"s%:% %g"` ;  do
461     ret=`find ${d} -name $1 2>/dev/null`
462     if [ -n "${ret}" ] ; then
463         #echo "The $1 exists on yours system in a ${d} folder"
464         return 0
465     fi
466 done
467 return 1
468 }
469
470 find_in_path(){
471 file=$1;  shift;
472 path=$*
473 for i in `echo ${path} | sed -e"s%:% %g"` ; do
474     ret=`find ${i} -name ${file} -maxdepth 1 2>/dev/null`
475     if [ -n "${ret}" ] ; then
476         ret=`echo ${ret} | sed -e"s%/\${file}$%%g"`
477         echo ${ret}
478         return 0
479     fi
480 done
481 return 1
482 }
483
484 sort_path(){
485 arg1=$1;  val1=$2;  arg2=$3;  val2=$4
486 tmp="^${val1}$|^${val1}:|:${val1}$|:${val1}:"
487 #echo ${val2} | grep -E "${tmp}" >/dev/null 2>&1
488 #if [ $? -eq 0 ] ; then
489 #    echo "${arg2}"
490 #    return
491 #fi
492 to_tail=1
493 exclude_list="usr lib bin sbin etc"
494 for i in ${exclude_list} ; do
495     tmp="^/${i}/|^/${i}\$"
496     echo ${val1} | grep -E "${tmp}" >/dev/null 2>&1
497     if [ "$?" = "0" ] ; then to_tail=0; break; fi
498 done
499 if [ ${to_tail} -eq 0 ] ; then
500     echo ${arg2}:${arg1}
501 else
502     echo ${arg1}:${arg2}
503 fi
504 return ${to_tail}
505 }
506
507 where_gcc(){
508 maj_ver=`echo $1 | awk -F. '{if(NF>0) print $1; else print 0}'`
509 min_ver=`echo $1 | awk -F. '{if(NF>1) print $2; else print 0}'`
510 rel_ver=`echo $1 | awk -F. '{if(NF>2) print $3; else print 0}'`
511 let ver=${maj_ver}*10000+${min_ver}*100+${rel_ver}
512 newer=""
513 newerver=0
514 for i in `echo ${PATH}:/usr/bin:/usr/local/bin | sed -e"s%:% %g"` ; do
515     ret=`find ${i} -name gcc -maxdepth 1 2>/dev/null`
516     if [ -n "${ret}" ] ; then
517         maj_ver=`${ret} -dumpversion | awk -F. '{if(NF>0) print $1; else print 0}'`
518         min_ver=`${ret} -dumpversion | awk -F. '{if(NF>1) print $2; else print 0}'`
519         rel_ver=`${ret} -dumpversion | awk -F. '{if(NF>2) print $3; else print 0}'`
520         let ver1=${maj_ver}*10000+${min_ver}*100+${rel_ver}
521         if [ ${ver1} -eq ${ver} ] ; then
522             ret=`echo ${ret} | sed -e"s%/gcc$%%g"`
523             echo ${ret}
524             return 0
525         fi
526         if [ ${ver1} -gt ${ver} ] && [ ${ver1} -gt ${newerver} ] ; then
527             let newerver=${ver1}
528             newer=`echo ${ret} | sed -e"s%/gcc$%%g"`
529         fi
530     fi
531 done
532 if [ -n "${newer}" ] ; then
533     echo ${newer}
534     return 0
535 fi
536 return 1
537 }
538
539 where_tcl(){
540 if test -z "${TCLHOME}"; then
541     TCLHOME=/usr
542 fi
543 tclcfg=`find ${TCLHOME}/lib -name "tclConfig.sh" 2> /dev/null`
544 file=""
545 maxver=0
546 for f in ${tclcfg} ; do
547     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;}'`
548     if [ ${maxver} -lt ${ver} ]; then
549         maxver=${ver}
550         file=${f}
551     fi
552 done
553 if test -n "${file}"; then
554     echo `dirname ${file}`
555     return 0
556 else
557     echo ""
558     return 1
559 fi
560 }
561
562 where_tk(){
563 if test -z "${TCLHOME}"; then
564     TCLHOME=/usr
565 fi
566 tclcfg=`find ${TCLHOME}/lib -name "tkConfig.sh" 2> /dev/null`
567 file=""
568 maxver=0
569 for f in ${tclcfg} ; do
570     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;}'`
571     if [ ${maxver} -lt ${ver} ]; then
572         maxver=${ver}
573         file=${f}
574     fi
575 done
576 if test -n "${file}"; then
577     echo `dirname ${file}`
578     return 0
579 else
580     echo ""
581     return 1
582 fi
583 }
584
585 where_dps(){
586 if test -f /usr/X11R6/include/DPS/dpsconfig.h ; then
587     echo "/usr/X11R6"
588     return 0
589 fi
590 if test -f /usr/include/DPS/dpsconfig.h ; then
591     echo "/usr"
592     return 0
593 fi
594 echo ""
595 return 1
596 }
597
598 where_gl_includes(){
599 for d in /usr/X11R6/include /usr/include ; do
600     if [ -d ${d}/GL ] && [ -f ${d}/GL/gl.h ] ; then
601         echo "${d}"
602         return 0
603     fi
604 done
605 echo ""
606 return 1
607 }
608
609 where_gl_libs(){
610 local d
611 local libdir
612 local libdirs="/usr/X11R6/lib64 /usr/lib64 /usr/lib/`uname -m`-linux-gnu /usr/X11R6/lib /usr/lib"
613
614 # search libGL.so* file and correct libGL.la in the same directory
615 for d in ${libdirs} ; do
616     if [ "`ls ${d}/libGL.so* 2>/dev/null`" ] && [ -f ${d}/libGL.la ]; then
617         libdir=`grep "libdir=" ${d}/libGL.la | sed -e "s%libdir='\(.*\)'%\1%" -e "s%/*$%%g"`
618         if [ "${libdir}" = "${d}" ] ; then
619             echo "${d}"
620             return 0
621         fi
622     fi
623 done
624 # search libGL.la file and check if this file is correct
625 for d in ${libdirs} ; do
626     if [ -f ${d}/libGL.la ] ; then
627         libdir=`grep "libdir=" ${d}/libGL.la | sed -e "s%libdir='\(.*\)'%\1%"`
628         if [ "`ls ${libdir}/libGL.so* 2>/dev/null`" ] ; then
629             echo "${d}"
630             return 0
631         fi
632     fi
633 done
634 # then search libGL.so* file
635 for d in ${libdirs} ; do
636     if [ "`ls ${d}/libGL.so* 2>/dev/null`" ] ; then
637         echo "${d}"
638         return 0
639     fi
640 done
641 echo ""
642 return 1
643 }
644
645 where_libgl_so(){
646 local libdirs="/usr/X11R6/lib64 /usr/lib64 /usr/lib/`uname -m`-linux-gnu /usr/X11R6/lib /usr/lib"
647 local d
648 for d in ${libdirs} ; do
649     if [ -f ${d}/libGL.so ] ; then
650         echo ${d}/libGL.so
651         return 0
652     fi
653 done
654 echo ""
655 return 1
656 }
657
658 fix_gl_libs(){
659     local gllibdir="`where_gl_libs`"
660     if [ "${gllibdir}" != "" ] ; then
661 #VSR: 02/04/2013 - next block is commented as it seems to be wrong :( libGL.la should not be ever mentioned
662 #       if [ -f ${gllibdir}/libGL.la ] ; then
663 #           libdir=`grep "libdir=" ${gllibdir}/libGL.la | sed -e "s%libdir='\(.*\)'%\1%"`
664 #           if [ "`ls ${libdir}/libGL.so* 2>/dev/null`" ] ; then
665 #               str_to_replace="${gllibdir}/libGL.la"
666 #           fi
667 #       fi
668         if [ "${str_to_replace}" = "" ] ; then
669             str_to_replace="-L${gllibdir} -lGL"
670         fi
671
672         la_files=`find . -name "*.la"`
673         for la_file in ${la_files} XXX ; do
674             if [ "${la_file}" = "XXX" ] ; then continue; fi
675             grep -e "libGL.la" ${la_file} >& /dev/null || grep -e "-lGL\b" ${la_file} >& /dev/null && \
676             sed -e "s%-lGL\b%%g"                                                       \
677                 -e "s%[^[:space:]']*libGL.la[[:space:]]%%g"                            \
678                 -e "s%^dependency_libs='\(.*\)%dependency_libs='${str_to_replace} \1%" \
679                 ${la_file} > ${la_file}.new && \
680                 mv -f ${la_file}.new ${la_file}
681         done
682     fi
683 }
684
685 ##
686 # function: workaround on some platforms to use latest available version of gcc (e.g. gcc44 on CentOS 5.5)
687 ##
688 use_latest_gcc(){
689     local gcc_min=$1
690     local gcc_ver=`gcc -dumpversion | awk -F. '{a1=0;a2=0;a3=0;if(NF>0)a1=$1;if(NF>1)a2=$2;if(NF>2)a3=$3;printf("%02d%02d%02d",a1,a2,a3);}'`
691     local gcc_found
692     local gxx_found
693     if [ ${gcc_ver} -le ${gcc_min} ] ; then
694         local wheregcc=$(dirname `which gcc`)
695         local all_gcc=$(find ${wheregcc}/gcc*)
696         local gcc_alt
697         local gcc_max=0
698         for gcc_alt in ${all_gcc} XXX ; do
699             if [ ${gcc_alt} = "XXX" ] ; then continue ; fi
700             gcc_ver=`${gcc_alt} -dumpversion 2>/dev/null | awk -F. '{a1=0;a2=0;a3=0;if(NF>0)a1=$1;if(NF>1)a2=$2;if(NF>2)a3=$3;printf("%02d%02d%02d",a1,a2,a3);}'`
701             if [ "${gcc_ver}" = "" ] ; then continue ; fi
702             if [ ${gcc_ver} -gt ${gcc_min} ] && [ ${gcc_ver} -gt ${gcc_max} ] ; then
703                 gcc_max=${gcc_ver}
704                 gcc_found=${gcc_alt}
705                 gxx_found=`echo ${gcc_found} | sed -e "s%gcc%g++%"`
706             fi
707         done
708         if [ "${gcc_found}" != "" ] ; then
709             echo "CC=${gcc_found} CXX=${gxx_found}"
710         fi
711     fi
712 }
713
714 modif_la_files(){
715 return 0
716 # obsolete
717 ldir=$1
718 if [ -z "${ldir}" ] || [ ! -d "${ldir}" ]; then return 1; fi
719
720 srcdir=`pwd`
721
722 SALOME_MODULES="`env | awk -F_ '/[a-zA-Z0-9]*_ROOT_DIR/ { print $1 }'`"
723
724 cd ${ldir}
725 ldir=`pwd`
726 la_files=`find . -name "*.la"`
727
728 # netgen dir
729 netgendir=${NETGEN_ROOT_DIR}
730 # freetype dir
731 freetypedir=${FREETYPE_ROOT_DIR}
732 # ftgl dir
733 ftgldir=${FTGL_ROOT_DIR}
734 # gl2ps dir
735 gl2psdir=${GL2PS_ROOT_DIR}
736 # freeimage dir
737 freeimagedir=${FREEIMAGE_ROOT_DIR}
738 # tbb dir
739 tbbbasedir=${TBB_ROOT_DIR}
740 TBBKERNEL='cc4.1.0_libc2.4_kernel2.6.16.21'
741 if test `uname -m` = "x86_64" ; then
742     export TBBMODE="intel64/${TBBKERNEL}"
743 else
744     export TBBMODE="ia32/${TBBKERNEL}"
745 fi
746 tbbdir=${tbbbasedir}/lib/${TBBMODE}
747 # cgns dir
748 cgnslibdir=${CGNS_ROOT_DIR}
749 # occt dir
750 casdir=${CAS_ROOT_DIR}/lib
751 if [ ! -d ${casdir} ] ; then casdir=${CAS_ROOT_DIR}/Linux/lib ; fi
752 if [ ! -d ${casdir} ] ; then casdir=${CAS_ROOT_DIR}/lin/lib ; fi
753 # omniorb dir
754 omnidir=${OMNIORB_ROOT_DIR}/lib
755 # vtk dir
756 vtkpath=${VTK_DIR}
757 if [ `uname -m` = "x86_64" ] && [ -d ${vtkpath}/lib64 ] ; then
758     LIB_PREFIX=64
759 elif [ -d ${vtkpath}/lib ] ; then
760     LIB_PREFIX=""
761 else
762     LIB_PREFIX=64
763 fi
764 vtkldir=${vtkpath}/lib${LIB_PREFIX}
765 vtkdir=${vtkldir}/vtk-5.0
766 # hdf dir
767 hdfdir=${HDF5_ROOT_DIR}/lib
768 # med dir
769 meddir=${MEDFILE_ROOT_DIR}/lib
770 # qwt dir
771 qwtdir=`find_in_path libqwt.so ${LD_LIBRARY_PATH}`
772 # python dir
773 where_python=`which python`                 # e.g. /usr/bin/python
774 if [ -n "${where_python}" ] ; then
775     where_python=`dirname ${where_python}`    # --> /usr/bin
776     where_python=`dirname ${where_python}`    # --> /usr
777     python_version=`python -c "import sys; print sys.version[:3]"`
778     pythondir=${where_python}/lib/python${python_version}
779 fi
780 # sip dir
781 sipdir=`find_in_path sip.so ${LD_LIBRARY_PATH}`
782 # pyqt dir
783 pyqtdir=`find_in_path Qt.so ${LD_LIBRARY_PATH}`
784 # tcl/tk dir
785 tcldir=${TCLHOME}/lib
786 # boost dir
787 boostdir=${BOOST_ROOT_DIR}/lib
788 # blsurf dir
789 blsurfdir=${BLSURFHOME}/lib
790 # libxml2 dir
791 libxmldir=${LIBXML2_ROOT_DIR}/lib
792 # metis dir
793 metisdir=${METIS_ROOT_DIR}
794 # scotch dir
795 scotchbindir=${SCOTCH_ROOT_DIR}/bin
796 scotchlibdir=${SCOTCH_ROOT_DIR}/lib
797 # gl dir
798 if test `uname -m` = "x86_64" ; then
799     libGLpath=/usr/lib64/libGL.la
800 else
801     libGLpath=/usr/lib/libGL.la
802 fi
803 # graphviz dir
804 graphvizdir=${GRAPHVIZ_ROOT_DIR}/lib
805 # qscintilla dir
806 qscintilladir=${QSCINTILLA_ROOT_DIR}/lib
807 # expat dir
808 expatdir=${EXPAT_ROOT_DIR}/lib
809 # paraview dir
810 paraviewdir=${PARAVIEW_ROOT_DIR}/lib
811 # qt dir
812 qtdir=${QT4_ROOT_DIR}/lib
813 # distene meshgems dir
814 if test `uname -m` = "x86_64" ; then
815     mgemsdir=${MESHGEMS_ROOT_DIR}/lib/Linux_64
816 else
817     mgemsdir=${MESHGEMS_ROOT_DIR}/lib/Linux
818 fi
819
820 for l in X ${la_files}; do
821
822 if [ "${l}" != "X" ] ; then
823     d=`dirname ${l}`
824     l=`basename ${l}`
825     cd ${ldir}; cd ${d}
826
827     # . process salome modules dependencies
828     for mod in ${SALOME_MODULES} ; do
829         moddir=${mod}_ROOT_DIR
830         moddir=${!moddir}
831         if [ -n "${moddir}" ] ; then
832             sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*${mod}[1]\?/lib% \1${moddir}/lib%g" \
833                 -e "s%[[:space:]]\(-L\)\?[^[:space:]]*${mod}WOGUI[1]\?/lib% \1${moddir}/lib%g" \
834                 -e "s%^libdir='[^[:space:]]*${mod}[1]\?/\(lib.*\)'%libdir='${moddir}/\1'%g" \
835                 -e "s%^libdir='[^[:space:]]*${mod}WOGUI[1]\?/\(lib.*\)'%libdir='${moddir}/\1'%g" ${l} > ${l}"_"
836             mv -f ${l}"_" ${l}
837         fi
838     done
839
840     # . process netgen dependencies
841     if [ -n "${netgendir}" ] && [ -d "${netgendir}" ] ; then
842         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*netgen-[0-9.]\+/lib% \1${netgendir}/lib%g" ${l}
843     fi
844
845     # . process freetype dependencies
846     if [ -n "${freetypedir}" ] && [ -d "${freetypedir}" ] ; then
847         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*freetype-[0-9.]\+/lib% \1${freetypedir}/lib%g" ${l}
848     fi
849
850     # . process ftgl dependencies
851     if [ -n "${ftgldir}" ] && [ -d "${ftgldir}" ] ; then
852         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*ftgl-[0-9.]\+/lib% \1${ftgldir}/lib%g" ${l}
853     fi
854
855     # . process gl2ps dependencies
856     if [ -n "${gl2psdir}" ] && [ -d "${gl2psdir}" ] ; then
857         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*gl2ps-[0-9.]\+/lib% \1${gl2psdir}/lib%g" ${l}
858     fi
859
860     # . process freeimage dependencies
861     if [ -n "${freeimagedir}" ] && [ -d "${freeimagedir}" ] ; then
862         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*freeimage-[0-9.]\+/lib% \1${freeimagedir}/lib%g" ${l}
863     fi
864
865     # . process tbb dependencies
866     if [ -n "${tbbdir}" ] && [ -d "${tbbdir}" ] ; then
867         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*tbb[^[:space:]]*/lib[^[:space:]]*% \1${tbbdir}%g" ${l}
868     fi
869
870     # . process cgns dependencies
871     if [ -n "${cgnslibdir}" ] && [ -d "${cgnslibdir}" ] ; then
872         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*cgnslib-[0-9.]\+/lib% \1${cgnslibdir}/lib%g" ${l}
873     fi
874
875     # . process CAS.CADE dependencies
876     if [ -n "${CAS_ROOT_DIR}" ] && [ -d "${casdir}" ] ; then
877         sed -e "s%-L[^[:space:]]*OCCT[^[:space:]]*/install/lib%-L${casdir}%g" \
878             -e "s%[^[:space:]]*OCCT[^[:space:]]*/install/lib/%${casdir}/%g"   \
879             -e "s%[[:space:]]-L[^[:space:]]*\(OCCT\|CAS\)[^[:space:]]*/lib\?% -L${CAS_ROOT_DIR}/lib%g" \
880             -e "s%[[:space:]][^[:space:]]*\(OCCT\|CAS\)[^[:space:]]*/lib/lib\?% ${CAS_ROOT_DIR}/lib/lib%g" ${l} > ${l}"_"
881         mv -f ${l}"_" ${l}
882     fi
883
884     # . process omniORB dependencies
885     if [ -n "${OMNIORB_ROOT_DIR}" ] && [ -d "${omnidir}" ] ; then
886         sed -i "s%-L[^[:space:]]*omni[^[:space:]]*%-L${omnidir}%g;s%-R[^[:space:]]*omni[^[:space:]]*%-R${omnidir}%g" ${l}
887     fi
888
889     # . process VTK dependencies
890     if [ -n "${VTK_DIR}" ] && [ -d "${vtkdir}" ] && [ -d "${vtkldir}" ] ; then
891         sed -i "s%-L[^[:space:]]*VTK[^[:space:]]*/\(lib\|lib64\)/vtk\-5\.0%-L${vtkdir}%g;s%-L[^[:space:]]*VTK[^[:space:]]*/\(lib\|lib64\)%-L${vtkldir}%g" ${l}
892     fi
893
894     # . process HDF dependencies
895     if [ -n "${HDF5_ROOT_DIR}" ] && [ -d "${hdfdir}" ] ; then
896         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*hdf[^[:space:]/]*/lib% \1${hdfdir}%g" ${l}
897     fi
898
899     # . process MED dependencies
900     if [ -n "${MEDFILE_ROOT_DIR}" ] && [ -d "${meddir}" ] ; then
901         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*med[^[:space:]/]*/lib% \1${meddir}%g" ${l}
902     fi
903
904     # . process qwt dependencies
905     if [ -n "${qwtdir}" ] && [ -d "${qwtdir}" ] ; then
906         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*qwt[^[:space:]/]*/lib% \1${qwtdir}%g" ${l}
907     fi
908
909     # . process qt dependencies
910     if [ -n "${QT4_ROOT_DIR}" ] && [ -d "${qtdir}" ] ; then
911         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*qt[^[:space:]/]*/lib% \1${qtdir}%g" ${l}
912     fi
913
914     # . process python dependencies
915     if [ -n "${pythondir}" ] && [ -d "${pythondir}" ] ; then
916         sed -i "s%-L[^[:space:]]*python[0-9]\.[0-9]\([^[:space:]]*\)%-L${pythondir}\1%g" ${l}
917     fi
918
919     # . process sip dependencies
920     if [ -n "${sipdir}" ] && [ -d "${sipdir}" ] ; then
921         sed -i "s%-L[^[:space:]]*sip[^[:space:]]*%-L${sipdir}%g" ${l}
922     fi
923
924     # . process PyQt dependencies
925     if [ -n "${pyqtdir}" ] && [ -d "${pyqtdir}" ] ; then
926         sed -i "s%-L[^[:space:]]*PyQt[^[:space:]]*%-L${pyqtdir}%g" ${l}
927     fi
928
929     # . process tcl/tk dependencies
930     if [ -n "${tcldir}" ] && [ -d "${tcldir}" ] ; then
931         sed -i "s%-L[^[:space:]]*tcltk[^[:space:]]*/lib%-L${tcldir}%g" ${l}
932     fi
933
934     # . process boost dependencies
935     if [ -n "${boostdir}" ] && [ -d "${boostdir}" ] ; then
936         sed -i "s%-L[^[:space:]]*boost[^[:space:]]*/lib%-L${boostdir}%g" ${l}
937     fi
938
939     # . process blsurf dependencies
940     if [ -n "${blsurfdir}" ] && [ -d "${blsurfdir}" ] ; then
941         sed -i "s%-L[^[:space:]]*BLSurf[^[:space:]]*/lib%-L${blsurfdir}%g" ${l}
942     fi
943
944     # . process libxml dependencies
945     if [ -n "${libxmldir}" ] && [ -d "${libxmldir}" ] ; then
946         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*libxml2-[0-9]\.[0-9]\.[0-9]/lib% \1${libxmldir}%g;s%[[:space:]]\(-L\)\?[^[:space:]]*libxml2/lib% \1${libxmldir}%g" ${l}
947     fi
948
949     # . process metis dependencies
950     if [ -n "${metisdir}" ] && [ -d "${metisdir}" ] ; then
951         sed -i "s%-L[^[:space:]]*metis[^[:space:]]*%-L${metisdir}%g" ${l}
952     fi
953
954     # . process scotch dependencies
955     if [ -n "${scotchbindir}" ] && [ -d "${scotchbindir}" ] ; then
956         sed -i "s%-L[^[:space:]]*scotch[^[:space:]]*/bin%-L${scotchbindir}%g" ${l}
957     fi
958     if [ -n "${scotchlibdir}" ] && [ -d "${scotchlibdir}" ] ; then
959         sed -i "s%-L[^[:space:]]*scotch[^[:space:]]*/lib%-L${scotchlibdir}%g" ${l}
960     fi
961
962     # . process libGL.la dependencies
963     sed -i "s%${libGLpath}%""%g" ${l}
964
965     # . process graphviz dependencies
966     if [ -n "${graphvizdir}" ] && [ -d "${graphvizdir}" ] ; then
967         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*graphviz-[0-9]\.[0-9]\+\.[0-9]/lib% \1${graphvizdir}%g;s%[[:space:]]\(-L\)\?[^[:space:]]*graphviz/lib% \1${graphvizdir}%g" ${l}
968     fi
969
970     # . process QScintilla dependencies
971     if [ -n "${qscintilladir}" ] && [ -d "${qscintilladir}" ] ; then
972         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*QScintilla-[0-9]\.[0-9]\(\.[0-9]\)\?/lib% \1${qscintilladir}%g" ${l}
973     fi
974
975     # . process expat-2.0.1 dependencies
976     if [ -n "${expatdir}" ] && [ -d "${expatdir}" ] ; then
977         sed -i "s%-L[^[:space:]]*expat[^[:space:]]*/lib%-L${expatdir}%g;s%[^[:space:]]*expat[^[:space:]]*/lib/libexpat.la%-lexpat%g" ${l}
978     fi
979
980     # . process ParaView dependencies
981     if [ -n "${paraviewdir}" ] && [ -d "${paraviewdir}" ] ; then
982         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*ParaView-[0-9]\.[0-9]\+\.[0-9]/lib% \1${paraviewdir}%g" ${l}
983     fi
984
985     # . process DISTENE MeshGems dependencies
986     if [ -n "${mgemsdir}" ] && [ -d "${mgemsdir}" ] ; then
987         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*MeshGems-[0-9.]\+/Products/lib/Linux\(_64\)\?% \1${mgemsdir}%g" ${l}
988     fi
989
990 fi
991 done
992
993 cd ${srcdir}
994 return 0
995 }
996
997 modif_cfg_file(){
998     local nf=$1
999     if [ "${nf}" = "" ] || [ ! -e ${nf} ] ; then
1000         return
1001     fi
1002     if [ "${PYTHON_ROOT_DIR}" != "" ] ; then
1003         sed -i "s%\([^/]*\)[^; ]*/Python-[0-9.]\+%\1${PYTHON_ROOT_DIR}%g" $1
1004     fi
1005     if [ "${SWIG_ROOT_DIR}" != "" ] ; then
1006         sed -i "s%\([^/]*\)[^; ]*/swig-[0-9.]\+%\1${SWIG_ROOT_DIR}%g" $1
1007     fi
1008     if [ "${OMNIORB_ROOT_DIR}" != "" ] ; then
1009         sed -i "s%\([^/]*\)[^; ]*/omniORB-[0-9.]\+%\1${OMNIORB_ROOT_DIR}%g" $1
1010     fi
1011     if [ "${HDF5_ROOT_DIR}" != "" ] ; then
1012         sed -i "s%\([^/]*\)[^; ]*/hdf5-[0-9.]\+%\1${HDF5_ROOT_DIR}%g" $1
1013     fi
1014     if [ "${BOOST_ROOT_DIR}" != "" ] ; then
1015         sed -i "s%\([^/]*\)[^; ]*/boost-[0-9.]\+%\1${BOOST_ROOT_DIR}%g" $1
1016     fi
1017     if [ "${MEDFILE_ROOT_DIR}" != "" ] ; then
1018         sed -i "s%\([^/]*\)[^; ]*/med-[0-9.]\+%\1${MEDFILE_ROOT_DIR}%g" $1
1019     fi
1020     if [ "${QT4_ROOT_DIR}" != "" ] ; then
1021         sed -i "s%\([^/]*\)[^; ]*/qt-[0-9.]\+%\1${QT4_ROOT_DIR}%g" $1
1022     fi
1023     if [ "${QWT_ROOT_DIR}" != "" ] ; then
1024         sed -i "s%\([^/]*\)[^; ]*/qwt-[0-9.]\+%\1${QWT_ROOT_DIR}%g" $1
1025     fi
1026     if [ "${SIP_ROOT_DIR}" != "" ] ; then
1027         sed -i "s%\([^/]*\)[^; ]*/sip-[0-9.]\+%\1${SIP_ROOT_DIR}%g" $1
1028     fi
1029     if [ "${PYQT4_ROOT_DIR}" != "" ] ; then
1030         sed -i "s%\([^/]*\)[^; ]*/PyQt-[0-9.]\+%\1${PYQT4_ROOT_DIR}%g" $1
1031     fi
1032     if [ "${QSCINTILLA_ROOT_DIR}" != "" ] ; then
1033         sed -i "s%\([^/]*\)[^; ]*/QScintilla-[0-9.]\+%\1${QSCINTILLA_ROOT_DIR}%g" $1
1034     fi
1035     if [ "${PARAVIEW_ROOT_DIR}" != "" ] ; then
1036         sed -i "s%\([^/]*\)[^; ]*/ParaView-[0-9.]\+%\1${PARAVIEW_ROOT_DIR}%g" $1
1037     fi
1038     if [ "${LIBXML2_ROOT_DIR}" != "" ] ; then
1039         sed -i "s%\([^/]*\)[^; ]*/libxml2-[0-9.]\+%\1${LIBXML2_ROOT_DIR}%g" $1
1040     fi
1041     if [ "${EXPAT_ROOT_DIR}" != "" ] ; then
1042         sed -i "s%\([^/]*\)[^; ]*/expat-[0-9.]\+%\1${EXPAT_ROOT_DIR}%g" $1
1043     fi
1044     if [ "${FREETYPE_ROOT_DIR}" != "" ] ; then
1045         sed -i "s%\([^/]*\)[^; ]*/freetype-[0-9.]\+%\1${FREETYPE_ROOT_DIR}%g" $1
1046     fi
1047     if [ "${FREEIMAGE_ROOT_DIR}" != "" ] ; then
1048         sed -i "s%\([^/]*\)[^; ]*/freeimage-[0-9.]\+%\1${FREEIMAGE_ROOT_DIR}%g" $1
1049     fi
1050     if [ "${GL2PS_ROOT_DIR}" != "" ] ; then
1051         sed -i "s%\([^/]*\)[^; ]*/gl2ps-[0-9.]\+%\1${GL2PS_ROOT_DIR}%g" $1
1052     fi
1053     if [ "${TBB_ROOT_DIR}" != "" ] ; then
1054         sed -i "s%\([^/]*\)[^; ]*/tbb[^/; \"]\+%\1${TBB_ROOT_DIR}%g" $1
1055     fi
1056     if [ "${CAS_ROOT_DIR}" != "" ] ; then
1057         sed -i "s%\([^/]*\)[^; ]*/OCCT[^/]*\(/[^ /;\"]*\)\?\(\"\|/inc\|/lib\)%\1${CAS_ROOT_DIR}\3%g" $1
1058     fi
1059     if [ "${NETGEN_ROOT_DIR}" != "" ] ; then
1060         sed -i "s%\([^/]*\)[^; ]*/netgen-[0-9.]\+%\1${NETGEN_ROOT_DIR}%g" $1
1061     fi
1062     if [ "${CGNS_ROOT_DIR}" != "" ] ; then
1063         sed -i "s%\([^/]*\)[^; ]*/cgnslib-[0-9.]\+%\1${CGNS_ROOT_DIR}%g" $1
1064     fi
1065     if [ "${NUMPY_ROOT_DIR}" != "" ] ; then
1066         sed -i "s%\([^/]*\)[^; ]*/numpy-[0-9.]\+%\1${NUMPY_ROOT_DIR}%g" $1
1067     fi
1068     if [ "${GRAPHVIZ_ROOT_DIR}" != "" ] ; then
1069         sed -i "s%\([^/]*\)[^; ]*/graphviz-[0-9.]\+%\1${GRAPHVIZ_ROOT_DIR}%g" $1
1070     fi
1071     if [ "${DOXYGEN_ROOT_DIR}" != "" ] ; then
1072         sed -i "s%\([^/]*\)[^; ]*/doxygen-[0-9.]\+%\1${DOXYGEN_ROOT_DIR}%g" $1
1073     fi
1074     if [ "${SPHINX_ROOT_DIR}" != "" ] ; then
1075         sed -i "s%\([^/]*\)[^; ]*/Sphinx-[0-9.]\+%\1${SPHINX_ROOT_DIR}%g" $1
1076     fi
1077     if [ "${WSO2_ROOT_DIR}" != "" ] ; then
1078         sed -i "s%\([^/]*\)[^; ]*/wso2-wsf-cpp-[0-9.]\+%\1${WSO2_ROOT_DIR}%g" $1
1079     fi
1080     if [ "${MESHGEMS_ROOT_DIR}" != "" ] ; then
1081         sed -i "s%\([^/]*\)[^; ]*/MeshGems-[0-9.]\+%\1${MESHGEMS_ROOT_DIR}%g" $1
1082     fi
1083     if [ "${METIS_ROOT_DIR}" != "" ] ; then
1084         sed -i "s%\([^/]*\)[^; ]*/metis-[0-9.]\+%\1${METIS_ROOT_DIR}%g" $1
1085     fi
1086     if [ "${SCOTCH_ROOT_DIR}" != "" ] ; then
1087         sed -i "s%\([^/]*\)[^; ]*/scotch-[0-9.]\+%\1${SCOTCH_ROOT_DIR}%g" $1
1088     fi
1089     local libglso=`where_libgl_so`
1090     local sm
1091     local smvar
1092     for sm in LIBBATCH SIMANIO KERNEL GUI GEOM MED SMESH PARAVIS YACS HEXABLOCK HOMARD JOBMANAGER \
1093         NETGENPLUGIN BLSURFPLUGIN GHS3DPLUGIN GHS3DPRLPLUGIN HexoticPLUGIN HEXABLOCKPLUGIN \
1094         CALCULATOR PYCALCULATOR COMPONENT HELLO PYHELLO LIGHT PYLIGHT ATOMIC ATOMGEN ATOMSOLV RANDOMIZER SIERPINSKY ; do
1095         smvar=${sm}_ROOT_DIR
1096         if [ "${!smvar}" != "" ] ; then
1097             sed -i "s%\([; \"]\)/[^; \"]\+/${sm}\([; \"/]\)%\1${!smvar}\2%g" $1
1098         fi
1099         grep libGL.so $1 > /dev/null && sed -i "s%\([; \"]\)/[^; \"]\+/libGL.so[0-9.]*%\1${libglso}%g" $1
1100     done
1101 }