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