Salome HOME
9904eda0e2f06dd4a421510f6656fa0a44bdfd94
[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 modif_la_files(){
686 return 0
687 # obsolete
688 ldir=$1
689 if [ -z "${ldir}" ] || [ ! -d "${ldir}" ]; then return 1; fi
690
691 srcdir=`pwd`
692
693 SALOME_MODULES="`env | awk -F_ '/[a-zA-Z0-9]*_ROOT_DIR/ { print $1 }'`"
694
695 cd ${ldir}
696 ldir=`pwd`
697 la_files=`find . -name "*.la"`
698
699 # netgen dir
700 netgendir=${NETGEN_ROOT_DIR}
701 # freetype dir
702 freetypedir=${FREETYPE_ROOT_DIR}
703 # ftgl dir
704 ftgldir=${FTGL_ROOT_DIR}
705 # gl2ps dir
706 gl2psdir=${GL2PS_ROOT_DIR}
707 # freeimage dir
708 freeimagedir=${FREEIMAGE_ROOT_DIR}
709 # tbb dir
710 tbbbasedir=${TBB_ROOT_DIR}
711 TBBKERNEL='cc4.1.0_libc2.4_kernel2.6.16.21'
712 if test `uname -m` = "x86_64" ; then
713     export TBBMODE="intel64/${TBBKERNEL}"
714 else
715     export TBBMODE="ia32/${TBBKERNEL}"
716 fi
717 tbbdir=${tbbbasedir}/lib/${TBBMODE}
718 # cgns dir
719 cgnslibdir=${CGNS_ROOT_DIR}
720 # occt dir
721 casdir=${CAS_ROOT_DIR}/lib
722 if [ ! -d ${casdir} ] ; then casdir=${CAS_ROOT_DIR}/Linux/lib ; fi
723 if [ ! -d ${casdir} ] ; then casdir=${CAS_ROOT_DIR}/lin/lib ; fi
724 # omniorb dir
725 omnidir=${OMNIORB_ROOT_DIR}/lib
726 # vtk dir
727 vtkpath=${VTK_DIR}
728 if [ `uname -m` = "x86_64" ] && [ -d ${vtkpath}/lib64 ] ; then
729     LIB_PREFIX=64
730 elif [ -d ${vtkpath}/lib ] ; then
731     LIB_PREFIX=""
732 else
733     LIB_PREFIX=64
734 fi
735 vtkldir=${vtkpath}/lib${LIB_PREFIX}
736 vtkdir=${vtkldir}/vtk-5.0
737 # hdf dir
738 hdfdir=${HDF5_ROOT_DIR}/lib
739 # med dir
740 meddir=${MEDFILE_ROOT_DIR}/lib
741 # qwt dir
742 qwtdir=`find_in_path libqwt.so ${LD_LIBRARY_PATH}`
743 # python dir
744 where_python=`which python`                 # e.g. /usr/bin/python
745 if [ -n "${where_python}" ] ; then
746     where_python=`dirname ${where_python}`    # --> /usr/bin
747     where_python=`dirname ${where_python}`    # --> /usr
748     python_version=`python -c "import sys; print sys.version[:3]"`
749     pythondir=${where_python}/lib/python${python_version}
750 fi
751 # sip dir
752 sipdir=`find_in_path sip.so ${LD_LIBRARY_PATH}`
753 # pyqt dir
754 pyqtdir=`find_in_path Qt.so ${LD_LIBRARY_PATH}`
755 # tcl/tk dir
756 tcldir=${TCLHOME}/lib
757 # boost dir
758 boostdir=${BOOST_ROOT_DIR}/lib
759 # blsurf dir
760 blsurfdir=${BLSURFHOME}/lib
761 # libxml2 dir
762 libxmldir=${LIBXML2_ROOT_DIR}/lib
763 # metis dir
764 metisdir=${METIS_ROOT_DIR}
765 # scotch dir
766 scotchbindir=${SCOTCH_ROOT_DIR}/bin
767 scotchlibdir=${SCOTCH_ROOT_DIR}/lib
768 # gl dir
769 if test `uname -m` = "x86_64" ; then
770     libGLpath=/usr/lib64/libGL.la
771 else
772     libGLpath=/usr/lib/libGL.la
773 fi
774 # graphviz dir
775 graphvizdir=${GRAPHVIZ_ROOT_DIR}/lib
776 # qscintilla dir
777 qscintilladir=${QSCINTILLA_ROOT_DIR}/lib
778 # expat dir
779 expatdir=${EXPAT_ROOT_DIR}/lib
780 # paraview dir
781 paraviewdir=${PARAVIEW_ROOT_DIR}/lib
782 # qt dir
783 qtdir=${QT4_ROOT_DIR}/lib
784 # distene meshgems dir
785 if test `uname -m` = "x86_64" ; then
786     mgemsdir=${MESHGEMS_ROOT_DIR}/lib/Linux_64
787 else
788     mgemsdir=${MESHGEMS_ROOT_DIR}/lib/Linux
789 fi
790
791 for l in X ${la_files}; do
792
793 if [ "${l}" != "X" ] ; then
794     d=`dirname ${l}`
795     l=`basename ${l}`
796     cd ${ldir}; cd ${d}
797
798     # . process salome modules dependencies
799     for mod in ${SALOME_MODULES} ; do
800         moddir=${mod}_ROOT_DIR
801         moddir=${!moddir}
802         if [ -n "${moddir}" ] ; then
803             sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*${mod}[1]\?/lib% \1${moddir}/lib%g" \
804                 -e "s%[[:space:]]\(-L\)\?[^[:space:]]*${mod}WOGUI[1]\?/lib% \1${moddir}/lib%g" \
805                 -e "s%^libdir='[^[:space:]]*${mod}[1]\?/\(lib.*\)'%libdir='${moddir}/\1'%g" \
806                 -e "s%^libdir='[^[:space:]]*${mod}WOGUI[1]\?/\(lib.*\)'%libdir='${moddir}/\1'%g" ${l} > ${l}"_"
807             mv -f ${l}"_" ${l}
808         fi
809     done
810
811     # . process netgen dependencies
812     if [ -n "${netgendir}" ] && [ -d "${netgendir}" ] ; then
813         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*netgen-[0-9.]\+/lib% \1${netgendir}/lib%g" ${l}
814     fi
815
816     # . process freetype dependencies
817     if [ -n "${freetypedir}" ] && [ -d "${freetypedir}" ] ; then
818         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*freetype-[0-9.]\+/lib% \1${freetypedir}/lib%g" ${l}
819     fi
820
821     # . process ftgl dependencies
822     if [ -n "${ftgldir}" ] && [ -d "${ftgldir}" ] ; then
823         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*ftgl-[0-9.]\+/lib% \1${ftgldir}/lib%g" ${l}
824     fi
825
826     # . process gl2ps dependencies
827     if [ -n "${gl2psdir}" ] && [ -d "${gl2psdir}" ] ; then
828         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*gl2ps-[0-9.]\+/lib% \1${gl2psdir}/lib%g" ${l}
829     fi
830
831     # . process freeimage dependencies
832     if [ -n "${freeimagedir}" ] && [ -d "${freeimagedir}" ] ; then
833         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*freeimage-[0-9.]\+/lib% \1${freeimagedir}/lib%g" ${l}
834     fi
835
836     # . process tbb dependencies
837     if [ -n "${tbbdir}" ] && [ -d "${tbbdir}" ] ; then
838         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*tbb[^[:space:]]*/lib[^[:space:]]*% \1${tbbdir}%g" ${l}
839     fi
840
841     # . process cgns dependencies
842     if [ -n "${cgnslibdir}" ] && [ -d "${cgnslibdir}" ] ; then
843         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*cgnslib-[0-9.]\+/lib% \1${cgnslibdir}/lib%g" ${l}
844     fi
845
846     # . process CAS.CADE dependencies
847     if [ -n "${CAS_ROOT_DIR}" ] && [ -d "${casdir}" ] ; then
848         sed -e "s%-L[^[:space:]]*OCCT[^[:space:]]*/install/lib%-L${casdir}%g" \
849             -e "s%[^[:space:]]*OCCT[^[:space:]]*/install/lib/%${casdir}/%g"   \
850             -e "s%[[:space:]]-L[^[:space:]]*\(OCCT\|CAS\)[^[:space:]]*/lib\?% -L${CAS_ROOT_DIR}/lib%g" \
851             -e "s%[[:space:]][^[:space:]]*\(OCCT\|CAS\)[^[:space:]]*/lib/lib\?% ${CAS_ROOT_DIR}/lib/lib%g" ${l} > ${l}"_"
852         mv -f ${l}"_" ${l}
853     fi
854
855     # . process omniORB dependencies
856     if [ -n "${OMNIORB_ROOT_DIR}" ] && [ -d "${omnidir}" ] ; then
857         sed -i "s%-L[^[:space:]]*omni[^[:space:]]*%-L${omnidir}%g;s%-R[^[:space:]]*omni[^[:space:]]*%-R${omnidir}%g" ${l}
858     fi
859
860     # . process VTK dependencies
861     if [ -n "${VTK_DIR}" ] && [ -d "${vtkdir}" ] && [ -d "${vtkldir}" ] ; then
862         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}
863     fi
864
865     # . process HDF dependencies
866     if [ -n "${HDF5_ROOT_DIR}" ] && [ -d "${hdfdir}" ] ; then
867         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*hdf[^[:space:]/]*/lib% \1${hdfdir}%g" ${l}
868     fi
869
870     # . process MED dependencies
871     if [ -n "${MEDFILE_ROOT_DIR}" ] && [ -d "${meddir}" ] ; then
872         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*med[^[:space:]/]*/lib% \1${meddir}%g" ${l}
873     fi
874
875     # . process qwt dependencies
876     if [ -n "${qwtdir}" ] && [ -d "${qwtdir}" ] ; then
877         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*qwt[^[:space:]/]*/lib% \1${qwtdir}%g" ${l}
878     fi
879
880     # . process qt dependencies
881     if [ -n "${QT4_ROOT_DIR}" ] && [ -d "${qtdir}" ] ; then
882         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*qt[^[:space:]/]*/lib% \1${qtdir}%g" ${l}
883     fi
884
885     # . process python dependencies
886     if [ -n "${pythondir}" ] && [ -d "${pythondir}" ] ; then
887         sed -i "s%-L[^[:space:]]*python[0-9]\.[0-9]\([^[:space:]]*\)%-L${pythondir}\1%g" ${l}
888     fi
889
890     # . process sip dependencies
891     if [ -n "${sipdir}" ] && [ -d "${sipdir}" ] ; then
892         sed -i "s%-L[^[:space:]]*sip[^[:space:]]*%-L${sipdir}%g" ${l}
893     fi
894
895     # . process PyQt dependencies
896     if [ -n "${pyqtdir}" ] && [ -d "${pyqtdir}" ] ; then
897         sed -i "s%-L[^[:space:]]*PyQt[^[:space:]]*%-L${pyqtdir}%g" ${l}
898     fi
899
900     # . process tcl/tk dependencies
901     if [ -n "${tcldir}" ] && [ -d "${tcldir}" ] ; then
902         sed -i "s%-L[^[:space:]]*tcltk[^[:space:]]*/lib%-L${tcldir}%g" ${l}
903     fi
904
905     # . process boost dependencies
906     if [ -n "${boostdir}" ] && [ -d "${boostdir}" ] ; then
907         sed -i "s%-L[^[:space:]]*boost[^[:space:]]*/lib%-L${boostdir}%g" ${l}
908     fi
909
910     # . process blsurf dependencies
911     if [ -n "${blsurfdir}" ] && [ -d "${blsurfdir}" ] ; then
912         sed -i "s%-L[^[:space:]]*BLSurf[^[:space:]]*/lib%-L${blsurfdir}%g" ${l}
913     fi
914
915     # . process libxml dependencies
916     if [ -n "${libxmldir}" ] && [ -d "${libxmldir}" ] ; then
917         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}
918     fi
919
920     # . process metis dependencies
921     if [ -n "${metisdir}" ] && [ -d "${metisdir}" ] ; then
922         sed -i "s%-L[^[:space:]]*metis[^[:space:]]*%-L${metisdir}%g" ${l}
923     fi
924
925     # . process scotch dependencies
926     if [ -n "${scotchbindir}" ] && [ -d "${scotchbindir}" ] ; then
927         sed -i "s%-L[^[:space:]]*scotch[^[:space:]]*/bin%-L${scotchbindir}%g" ${l}
928     fi
929     if [ -n "${scotchlibdir}" ] && [ -d "${scotchlibdir}" ] ; then
930         sed -i "s%-L[^[:space:]]*scotch[^[:space:]]*/lib%-L${scotchlibdir}%g" ${l}
931     fi
932
933     # . process libGL.la dependencies
934     sed -i "s%${libGLpath}%""%g" ${l}
935
936     # . process graphviz dependencies
937     if [ -n "${graphvizdir}" ] && [ -d "${graphvizdir}" ] ; then
938         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}
939     fi
940
941     # . process QScintilla dependencies
942     if [ -n "${qscintilladir}" ] && [ -d "${qscintilladir}" ] ; then
943         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*QScintilla-[0-9]\.[0-9]\(\.[0-9]\)\?/lib% \1${qscintilladir}%g" ${l}
944     fi
945
946     # . process expat-2.0.1 dependencies
947     if [ -n "${expatdir}" ] && [ -d "${expatdir}" ] ; then
948         sed -i "s%-L[^[:space:]]*expat[^[:space:]]*/lib%-L${expatdir}%g;s%[^[:space:]]*expat[^[:space:]]*/lib/libexpat.la%-lexpat%g" ${l}
949     fi
950
951     # . process ParaView dependencies
952     if [ -n "${paraviewdir}" ] && [ -d "${paraviewdir}" ] ; then
953         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*ParaView-[0-9]\.[0-9]\+\.[0-9]/lib% \1${paraviewdir}%g" ${l}
954     fi
955
956     # . process DISTENE MeshGems dependencies
957     if [ -n "${mgemsdir}" ] && [ -d "${mgemsdir}" ] ; then
958         sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*MeshGems-[0-9.]\+/Products/lib/Linux\(_64\)\?% \1${mgemsdir}%g" ${l}
959     fi
960
961 fi
962 done
963
964 cd ${srcdir}
965 return 0
966 }
967
968 modif_cfg_file(){
969     local nf=$1
970     if [ "${nf}" = "" ] || [ ! -e ${nf} ] ; then
971         return
972     fi
973     if [ "${PYTHON_ROOT_DIR}" != "" ] ; then
974         sed -i "s%\([^/]*\)[^; ]*/Python-[0-9.]\+%\1${PYTHON_ROOT_DIR}%g" $1
975     fi
976     if [ "${SWIG_ROOT_DIR}" != "" ] ; then
977         sed -i "s%\([^/]*\)[^; ]*/swig-[0-9.]\+%\1${SWIG_ROOT_DIR}%g" $1
978     fi
979     if [ "${OMNIORB_ROOT_DIR}" != "" ] ; then
980         sed -i "s%\([^/]*\)[^; ]*/omniORB-[0-9.]\+%\1${OMNIORB_ROOT_DIR}%g" $1
981     fi
982     if [ "${HDF5_ROOT_DIR}" != "" ] ; then
983         sed -i "s%\([^/]*\)[^; ]*/hdf5-[0-9.]\+%\1${HDF5_ROOT_DIR}%g" $1
984     fi
985     if [ "${BOOST_ROOT_DIR}" != "" ] ; then
986         sed -i "s%\([^/]*\)[^; ]*/boost-[0-9.]\+%\1${BOOST_ROOT_DIR}%g" $1
987     fi
988     if [ "${MEDFILE_ROOT_DIR}" != "" ] ; then
989         sed -i "s%\([^/]*\)[^; ]*/med-[0-9.]\+%\1${MEDFILE_ROOT_DIR}%g" $1
990     fi
991     if [ "${QT4_ROOT_DIR}" != "" ] ; then
992         sed -i "s%\([^/]*\)[^; ]*/qt-[0-9.]\+%\1${QT4_ROOT_DIR}%g" $1
993     fi
994     if [ "${QWT_ROOT_DIR}" != "" ] ; then
995         sed -i "s%\([^/]*\)[^; ]*/qwt-[0-9.]\+%\1${QWT_ROOT_DIR}%g" $1
996     fi
997     if [ "${SIP_ROOT_DIR}" != "" ] ; then
998         sed -i "s%\([^/]*\)[^; ]*/sip-[0-9.]\+%\1${SIP_ROOT_DIR}%g" $1
999     fi
1000     if [ "${PYQT4_ROOT_DIR}" != "" ] ; then
1001         sed -i "s%\([^/]*\)[^; ]*/PyQt-[0-9.]\+%\1${PYQT4_ROOT_DIR}%g" $1
1002     fi
1003     if [ "${QSCINTILLA_ROOT_DIR}" != "" ] ; then
1004         sed -i "s%\([^/]*\)[^; ]*/QScintilla-[0-9.]\+%\1${QSCINTILLA_ROOT_DIR}%g" $1
1005     fi
1006     if [ "${PARAVIEW_ROOT_DIR}" != "" ] ; then
1007         sed -i "s%\([^/]*\)[^; ]*/ParaView-[0-9.]\+%\1${PARAVIEW_ROOT_DIR}%g" $1
1008     fi
1009     if [ "${LIBXML2_ROOT_DIR}" != "" ] ; then
1010         sed -i "s%\([^/]*\)[^; ]*/libxml2-[0-9.]\+%\1${LIBXML2_ROOT_DIR}%g" $1
1011     fi
1012     if [ "${EXPAT_ROOT_DIR}" != "" ] ; then
1013         sed -i "s%\([^/]*\)[^; ]*/expat-[0-9.]\+%\1${EXPAT_ROOT_DIR}%g" $1
1014     fi
1015     if [ "${FREETYPE_ROOT_DIR}" != "" ] ; then
1016         sed -i "s%\([^/]*\)[^; ]*/freetype-[0-9.]\+%\1${FREETYPE_ROOT_DIR}%g" $1
1017     fi
1018     if [ "${FREEIMAGE_ROOT_DIR}" != "" ] ; then
1019         sed -i "s%\([^/]*\)[^; ]*/freeimage-[0-9.]\+%\1${FREEIMAGE_ROOT_DIR}%g" $1
1020     fi
1021     if [ "${GL2PS_ROOT_DIR}" != "" ] ; then
1022         sed -i "s%\([^/]*\)[^; ]*/gl2ps-[0-9.]\+%\1${GL2PS_ROOT_DIR}%g" $1
1023     fi
1024     if [ "${TBB_ROOT_DIR}" != "" ] ; then
1025         sed -i "s%\([^/]*\)[^; ]*/tbb[^/; \"]\+%\1${TBB_ROOT_DIR}%g" $1
1026     fi
1027     if [ "${CAS_ROOT_DIR}" != "" ] ; then
1028         sed -i "s%\([^/]*\)[^; ]*/OCCT[^/]*\(/[^ /;\"]*\)\?\(\"\|/inc\|/lib\)%\1${CAS_ROOT_DIR}\3%g" $1
1029     fi
1030     if [ "${NETGEN_ROOT_DIR}" != "" ] ; then
1031         sed -i "s%\([^/]*\)[^; ]*/netgen-[0-9.]\+%\1${NETGEN_ROOT_DIR}%g" $1
1032     fi
1033     if [ "${CGNS_ROOT_DIR}" != "" ] ; then
1034         sed -i "s%\([^/]*\)[^; ]*/cgnslib-[0-9.]\+%\1${CGNS_ROOT_DIR}%g" $1
1035     fi
1036     if [ "${NUMPY_ROOT_DIR}" != "" ] ; then
1037         sed -i "s%\([^/]*\)[^; ]*/numpy-[0-9.]\+%\1${NUMPY_ROOT_DIR}%g" $1
1038     fi
1039     if [ "${GRAPHVIZ_ROOT_DIR}" != "" ] ; then
1040         sed -i "s%\([^/]*\)[^; ]*/graphviz-[0-9.]\+%\1${GRAPHVIZ_ROOT_DIR}%g" $1
1041     fi
1042     if [ "${DOXYGEN_ROOT_DIR}" != "" ] ; then
1043         sed -i "s%\([^/]*\)[^; ]*/doxygen-[0-9.]\+%\1${DOXYGEN_ROOT_DIR}%g" $1
1044     fi
1045     if [ "${SPHINX_ROOT_DIR}" != "" ] ; then
1046         sed -i "s%\([^/]*\)[^; ]*/Sphinx-[0-9.]\+%\1${SPHINX_ROOT_DIR}%g" $1
1047     fi
1048     if [ "${WSO2_ROOT_DIR}" != "" ] ; then
1049         sed -i "s%\([^/]*\)[^; ]*/wso2-wsf-cpp-[0-9.]\+%\1${WSO2_ROOT_DIR}%g" $1
1050     fi
1051     if [ "${MESHGEMS_ROOT_DIR}" != "" ] ; then
1052         sed -i "s%\([^/]*\)[^; ]*/MeshGems-[0-9.]\+%\1${MESHGEMS_ROOT_DIR}%g" $1
1053     fi
1054     if [ "${METIS_ROOT_DIR}" != "" ] ; then
1055         sed -i "s%\([^/]*\)[^; ]*/metis-[0-9.]\+%\1${METIS_ROOT_DIR}%g" $1
1056     fi
1057     if [ "${SCOTCH_ROOT_DIR}" != "" ] ; then
1058         sed -i "s%\([^/]*\)[^; ]*/scotch-[0-9.]\+%\1${SCOTCH_ROOT_DIR}%g" $1
1059     fi
1060     local libglso=`where_libgl_so`
1061     local sm
1062     local smvar
1063     for sm in LIBBATCH SIMANIO KERNEL GUI GEOM MED SMESH PARAVIS YACS HEXABLOCK HOMARD JOBMANAGER \
1064         NETGENPLUGIN BLSURFPLUGIN GHS3DPLUGIN GHS3DPRLPLUGIN HexoticPLUGIN HEXABLOCKPLUGIN \
1065         CALCULATOR PYCALCULATOR COMPONENT HELLO PYHELLO LIGHT PYLIGHT ATOMIC ATOMGEN ATOMSOLV RANDOMIZER SIERPINSKY ; do
1066         smvar=${sm}_ROOT_DIR
1067         if [ "${!smvar}" != "" ] ; then
1068             sed -i "s%\([; \"]\)/[^; \"]\+/${sm}\([; \"/]\)%\1${!smvar}\2%g" $1
1069         fi
1070         grep libGL.so $1 > /dev/null && sed -i "s%\([; \"]\)/[^; \"]\+/libGL.so[0-9.]*%\1${libglso}%g" $1
1071     done
1072 }