3 ####################################################################################
5 # Created : Thu Dec 18 12:01:00 2002
6 # Author : Vadim SANDLER, Open CASCADE SAS (vadim.sandler@opencascade.com)
8 # Module : Installation Wizard
9 # Copyright : 2002-2014 CEA
11 # This script is the part of the SALOME installation procedure.
13 ####################################################################################
16 export SHRC="salome.sh"
17 export CSHRC="salome.csh"
19 #####################################################
20 # !WARNING! This is current SALOME version number
21 ####################################################
22 export SALOME_VERSION="7.4.0"
23 export YACSGEN_VERSION=${SALOME_VERSION}
25 # Name of the single directory for SALOME modules
26 export SDIR_NAME="SALOME_${SALOME_VERSION}"
28 #this function takes one parameter - path to module source folder
29 check_salome_src_version(){
32 if [ -n "${root_dir}" ]; then
34 if [ ! -f ${root_dir}/${cfg_file} ] ; then
35 cfg_file=configure.in.base
37 cfg_file=CMakeLists.txt
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}"
46 ver=`grep -e "^AC_INIT" ${root_dir}/${cfg_file} | sed -e "s%.*\[\([[:digit:].]*\)\].*%\1%g"`
49 if [ "${ver}" = "${SALOME_VERSION}" ]; then
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)
67 if [ -n "${INSTALL_WORK}" ] ; then errfile=${INSTALL_WORK}/errlog; fi
69 if [ "${out}" != "1" ] ; then cmd="${cmd} >> ${out}" ; fi
71 if [ "${out}" != "1" ] ; then
72 $* >> ${out} 2>${errfile}
76 if [ "$?" -ne "0" ] ; then
77 if [ ${out} != "1" ] ; then
80 cat ${errfile} >> ${out}
82 # VSR : 10/11/05: disable answer mode ==>
84 #echo -e "NOT DONE !!! => $*"
85 #echo -n "Would you like to continue to install this product: (Y,N) [Y] : "
87 #rep=`echo ${rep} | tr "[A-Z]" "[a-z]"`
88 #if test -z ${rep} || [ ${rep} = "y" ] ; then
91 # VSR : 10/11/05: disable answer mode <==
97 #invoke check_job function
98 #all output will be put into terminal
108 rm -rf "$1" > /dev/null
112 #create environment for sh and csh
115 install_root=$1; shift
118 for i in ${SHRC} ${CSHRC} ; do
119 if [ -e ${install_work}/${i} ]; then
120 rm ${install_work}/${i}
122 touch ${install_work}/${i}
125 if [ $# -eq 4 ] ; then
127 product_env=${install_work}/env_${product_name}.sh
128 (test -e ${product_env} && rm ${product_env} )
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}
135 #${DELIM} Environment switch: 0 for SALOME building, 1 for SALOME launching ${DELIM}
136 export ENV_FOR_LAUNCH=1
138 #${DELIM} Setting numeric locale ${DELIM}
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
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
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.
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
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
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
191 cat ${env_file} >> ${install_work}/${SHRC} 2>/dev/null
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,
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.
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
216 out_var=\`echo \$1 \$2 | awk -v dir=\$3 '{ \\
217 na = split(\$2,a,":"); \\
221 if(\$1 != "<empty>") { \\
222 nb = split(\$1,b,":"); \\
223 for(i=1;i<=nb;i++) { \\
224 if(!(b[i] in ccc) ) { \\
232 for(i=1;i<=na;i++) { \\
233 if(!(a[i] in ccc)) { \\
240 for(i=1;i<k2;i++) { \\
243 for(i=1;i<k1;i++) { \\
248 for(i=1;i<k1;i++) { \\
251 for(i=1;i<k2;i++) { \\
255 }' | sed -e 's/\(.*\):/\1/g'\`
259 # appends directory or set of directories, separated by ':' (second parameter)
260 # to the variable (first parameter)
263 if [ -z "\${xenv}" ]; then xenv="<empty>"; fi
264 out_var=\`cleandup \${xenv} \$2 0\`
265 export \$1=\${out_var}
268 # prepends directory or set of directories, separated by ':' (second parameter)
269 # to the variable (first parameter)
272 if [ -z "\${xenv}" ]; then xenv="<empty>"; fi
273 out_var=\`cleandup \${xenv} \$2 1\`
274 export \$1=\${out_var}
276 ###########################################################################
280 # 3. writing global functions to _salome.csh file
281 cat >> ${install_work}/_${CSHRC} <<EOF
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,
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.
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,":"); \\\\
305 if(\$1 != "<empty>") { \\\\
306 nb = split(\$1,b,":"); \\\\
307 for(i=1;i<=nb;i++) { \\\\
308 if(!(b[i] in ccc) ) { \\\\
316 for(i=1;i<=na;i++) { \\\\
317 if(!(a[i] in ccc)) { \\\\
324 for(i=1;i<k2;i++) { \\\\
327 for(i=1;i<k1;i++) { \\\\
332 for(i=1;i<k1;i++) { \\\\
335 for(i=1;i<k2;i++) { \\\\
339 }'"' | sed -e 's/\(.*\):/\1/g'"
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} ; \\
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} ; \\
357 ###########################################################################
360 cat ${install_work}/${CSHRC} >> ${install_work}/_${CSHRC}
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
368 cat ${INSTALL_WORK}/_tmp2 >> ${install_work}/_${SHRC}
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}
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
385 cat ${INSTALL_WORK}/_tmp1 >> ${install_work}/_${CSHRC} 2>/dev/null
387 rm -f ${INSTALL_WORK}/_tmp1 ${INSTALL_WORK}/_tmp2
389 if [ $# -eq 5 ] ; then
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}
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
401 cp -f ${install_work}/_${CSHRC} ${install_root}/env_products.csh
402 cp -f ${install_work}/_${SHRC} ${install_root}/env_products.sh
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}
409 if [ -e ./build.sh ] && [ ! -e ${install_root}/build.sh ]; then
410 cp -f ./build.sh ${install_root}
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
417 if [ ! -e ${install_root}/${RN} ]; then
418 cp -f ../${RN} ${install_root}
425 #try use already existing product
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}
436 if [ $? -eq 0 ] ; then
440 echo ${product_type} | grep -q '_src$'
441 if [ $? -eq 1 ] ; then
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
458 whereIs=${LD_LIBRARY_PATH}
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"
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"`
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
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
499 if [ ${to_tail} -eq 0 ] ; then
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}
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"`
526 if [ ${ver1} -gt ${ver} ] && [ ${ver1} -gt ${newerver} ] ; then
528 newer=`echo ${ret} | sed -e"s%/gcc$%%g"`
532 if [ -n "${newer}" ] ; then
540 if test -z "${TCLHOME}"; then
543 tclcfg=`find ${TCLHOME}/lib -name "tclConfig.sh" 2> /dev/null`
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
553 if test -n "${file}"; then
554 echo `dirname ${file}`
563 if test -z "${TCLHOME}"; then
566 tclcfg=`find ${TCLHOME}/lib -name "tkConfig.sh" 2> /dev/null`
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
576 if test -n "${file}"; then
577 echo `dirname ${file}`
586 if test -f /usr/X11R6/include/DPS/dpsconfig.h ; then
590 if test -f /usr/include/DPS/dpsconfig.h ; then
599 for d in /usr/X11R6/include /usr/include ; do
600 if [ -d ${d}/GL ] && [ -f ${d}/GL/gl.h ] ; then
612 local libdirs="/usr/X11R6/lib64 /usr/lib64 /usr/lib/`uname -m`-linux-gnu /usr/X11R6/lib /usr/lib"
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
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
634 # then search libGL.so* file
635 for d in ${libdirs} ; do
636 if [ "`ls ${d}/libGL.so* 2>/dev/null`" ] ; then
646 local libdirs="/usr/X11R6/lib64 /usr/lib64 /usr/lib/`uname -m`-linux-gnu /usr/X11R6/lib /usr/lib"
648 for d in ${libdirs} ; do
649 if [ -f ${d}/libGL.so ] ; then
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"
668 if [ "${str_to_replace}" = "" ] ; then
669 str_to_replace="-L${gllibdir} -lGL"
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}
686 # function: workaround on some platforms to use latest available version of gcc (e.g. gcc44 on CentOS 5.5)
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);}'`
693 if [ ${gcc_ver} -le ${gcc_min} ] ; then
694 local wheregcc=$(dirname `which gcc`)
695 local all_gcc=$(find ${wheregcc}/gcc*)
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
705 gxx_found=`echo ${gcc_found} | sed -e "s%gcc%g++%"`
708 if [ "${gcc_found}" != "" ] ; then
709 echo "CC=${gcc_found} CXX=${gxx_found}"
718 if [ -z "${ldir}" ] || [ ! -d "${ldir}" ]; then return 1; fi
722 SALOME_MODULES="`env | awk -F_ '/[a-zA-Z0-9]*_ROOT_DIR/ { print $1 }'`"
726 la_files=`find . -name "*.la"`
729 netgendir=${NETGEN_ROOT_DIR}
731 freetypedir=${FREETYPE_ROOT_DIR}
733 ftgldir=${FTGL_ROOT_DIR}
735 gl2psdir=${GL2PS_ROOT_DIR}
737 freeimagedir=${FREEIMAGE_ROOT_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}"
744 export TBBMODE="ia32/${TBBKERNEL}"
746 tbbdir=${tbbbasedir}/lib/${TBBMODE}
748 cgnslibdir=${CGNS_ROOT_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
754 omnidir=${OMNIORB_ROOT_DIR}/lib
757 if [ `uname -m` = "x86_64" ] && [ -d ${vtkpath}/lib64 ] ; then
759 elif [ -d ${vtkpath}/lib ] ; then
764 vtkldir=${vtkpath}/lib${LIB_PREFIX}
765 vtkdir=${vtkldir}/vtk-5.0
767 hdfdir=${HDF5_ROOT_DIR}/lib
769 meddir=${MEDFILE_ROOT_DIR}/lib
771 qwtdir=`find_in_path libqwt.so ${LD_LIBRARY_PATH}`
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}
781 sipdir=`find_in_path sip.so ${LD_LIBRARY_PATH}`
783 pyqtdir=`find_in_path Qt.so ${LD_LIBRARY_PATH}`
785 tcldir=${TCLHOME}/lib
787 boostdir=${BOOST_ROOT_DIR}/lib
789 blsurfdir=${BLSURFHOME}/lib
791 libxmldir=${LIBXML2_ROOT_DIR}/lib
793 metisdir=${METIS_ROOT_DIR}
795 scotchbindir=${SCOTCH_ROOT_DIR}/bin
796 scotchlibdir=${SCOTCH_ROOT_DIR}/lib
798 if test `uname -m` = "x86_64" ; then
799 libGLpath=/usr/lib64/libGL.la
801 libGLpath=/usr/lib/libGL.la
804 graphvizdir=${GRAPHVIZ_ROOT_DIR}/lib
806 qscintilladir=${QSCINTILLA_ROOT_DIR}/lib
808 expatdir=${EXPAT_ROOT_DIR}/lib
810 paraviewdir=${PARAVIEW_ROOT_DIR}/lib
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
817 mgemsdir=${MESHGEMS_ROOT_DIR}/lib/Linux
820 for l in X ${la_files}; do
822 if [ "${l}" != "X" ] ; then
827 # . process salome modules dependencies
828 for mod in ${SALOME_MODULES} ; do
829 moddir=${mod}_ROOT_DIR
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}"_"
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}
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}
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}
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}
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}
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}
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}
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}"_"
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}
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}
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}
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}
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}
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}
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}
919 # . process sip dependencies
920 if [ -n "${sipdir}" ] && [ -d "${sipdir}" ] ; then
921 sed -i "s%-L[^[:space:]]*sip[^[:space:]]*%-L${sipdir}%g" ${l}
924 # . process PyQt dependencies
925 if [ -n "${pyqtdir}" ] && [ -d "${pyqtdir}" ] ; then
926 sed -i "s%-L[^[:space:]]*PyQt[^[:space:]]*%-L${pyqtdir}%g" ${l}
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}
934 # . process boost dependencies
935 if [ -n "${boostdir}" ] && [ -d "${boostdir}" ] ; then
936 sed -i "s%-L[^[:space:]]*boost[^[:space:]]*/lib%-L${boostdir}%g" ${l}
939 # . process blsurf dependencies
940 if [ -n "${blsurfdir}" ] && [ -d "${blsurfdir}" ] ; then
941 sed -i "s%-L[^[:space:]]*BLSurf[^[:space:]]*/lib%-L${blsurfdir}%g" ${l}
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}
949 # . process metis dependencies
950 if [ -n "${metisdir}" ] && [ -d "${metisdir}" ] ; then
951 sed -i "s%-L[^[:space:]]*metis[^[:space:]]*%-L${metisdir}%g" ${l}
954 # . process scotch dependencies
955 if [ -n "${scotchbindir}" ] && [ -d "${scotchbindir}" ] ; then
956 sed -i "s%-L[^[:space:]]*scotch[^[:space:]]*/bin%-L${scotchbindir}%g" ${l}
958 if [ -n "${scotchlibdir}" ] && [ -d "${scotchlibdir}" ] ; then
959 sed -i "s%-L[^[:space:]]*scotch[^[:space:]]*/lib%-L${scotchlibdir}%g" ${l}
962 # . process libGL.la dependencies
963 sed -i "s%${libGLpath}%""%g" ${l}
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}
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}
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}
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}
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}
999 if [ "${nf}" = "" ] || [ ! -e ${nf} ] ; then
1002 if [ "${PYTHON_ROOT_DIR}" != "" ] ; then
1003 sed -i "s%\([^/]*\)[^; ]*/Python-[0-9.]\+%\1${PYTHON_ROOT_DIR}%g" $1
1005 if [ "${SWIG_ROOT_DIR}" != "" ] ; then
1006 sed -i "s%\([^/]*\)[^; ]*/swig-[0-9.]\+%\1${SWIG_ROOT_DIR}%g" $1
1008 if [ "${OMNIORB_ROOT_DIR}" != "" ] ; then
1009 sed -i "s%\([^/]*\)[^; ]*/omniORB-[0-9.]\+%\1${OMNIORB_ROOT_DIR}%g" $1
1011 if [ "${HDF5_ROOT_DIR}" != "" ] ; then
1012 sed -i "s%\([^/]*\)[^; ]*/hdf5-[0-9.]\+%\1${HDF5_ROOT_DIR}%g" $1
1014 if [ "${BOOST_ROOT_DIR}" != "" ] ; then
1015 sed -i "s%\([^/]*\)[^; ]*/boost-[0-9.]\+%\1${BOOST_ROOT_DIR}%g" $1
1017 if [ "${MEDFILE_ROOT_DIR}" != "" ] ; then
1018 sed -i "s%\([^/]*\)[^; ]*/med-[0-9.]\+%\1${MEDFILE_ROOT_DIR}%g" $1
1020 if [ "${QT4_ROOT_DIR}" != "" ] ; then
1021 sed -i "s%\([^/]*\)[^; ]*/qt-[0-9.]\+%\1${QT4_ROOT_DIR}%g" $1
1023 if [ "${QWT_ROOT_DIR}" != "" ] ; then
1024 sed -i "s%\([^/]*\)[^; ]*/qwt-[0-9.]\+%\1${QWT_ROOT_DIR}%g" $1
1026 if [ "${SIP_ROOT_DIR}" != "" ] ; then
1027 sed -i "s%\([^/]*\)[^; ]*/sip-[0-9.]\+%\1${SIP_ROOT_DIR}%g" $1
1029 if [ "${PYQT4_ROOT_DIR}" != "" ] ; then
1030 sed -i "s%\([^/]*\)[^; ]*/PyQt-[0-9.]\+%\1${PYQT4_ROOT_DIR}%g" $1
1032 if [ "${QSCINTILLA_ROOT_DIR}" != "" ] ; then
1033 sed -i "s%\([^/]*\)[^; ]*/QScintilla-[0-9.]\+%\1${QSCINTILLA_ROOT_DIR}%g" $1
1035 if [ "${PARAVIEW_ROOT_DIR}" != "" ] ; then
1036 sed -i "s%\([^/]*\)[^; ]*/ParaView-[0-9.]\+%\1${PARAVIEW_ROOT_DIR}%g" $1
1038 if [ "${LIBXML2_ROOT_DIR}" != "" ] ; then
1039 sed -i "s%\([^/]*\)[^; ]*/libxml2-[0-9.]\+%\1${LIBXML2_ROOT_DIR}%g" $1
1041 if [ "${EXPAT_ROOT_DIR}" != "" ] ; then
1042 sed -i "s%\([^/]*\)[^; ]*/expat-[0-9.]\+%\1${EXPAT_ROOT_DIR}%g" $1
1044 if [ "${FREETYPE_ROOT_DIR}" != "" ] ; then
1045 sed -i "s%\([^/]*\)[^; ]*/freetype-[0-9.]\+%\1${FREETYPE_ROOT_DIR}%g" $1
1047 if [ "${FREEIMAGE_ROOT_DIR}" != "" ] ; then
1048 sed -i "s%\([^/]*\)[^; ]*/freeimage-[0-9.]\+%\1${FREEIMAGE_ROOT_DIR}%g" $1
1050 if [ "${GL2PS_ROOT_DIR}" != "" ] ; then
1051 sed -i "s%\([^/]*\)[^; ]*/gl2ps-[0-9.]\+%\1${GL2PS_ROOT_DIR}%g" $1
1053 if [ "${TBB_ROOT_DIR}" != "" ] ; then
1054 sed -i "s%\([^/]*\)[^; ]*/tbb[^/; \"]\+%\1${TBB_ROOT_DIR}%g" $1
1056 if [ "${CAS_ROOT_DIR}" != "" ] ; then
1057 sed -i "s%\([^/]*\)[^; ]*/OCCT[^/]*\(/[^ /;\"]*\)\?\(\"\|/inc\|/lib\)%\1${CAS_ROOT_DIR}\3%g" $1
1059 if [ "${NETGEN_ROOT_DIR}" != "" ] ; then
1060 sed -i "s%\([^/]*\)[^; ]*/netgen-[0-9.]\+%\1${NETGEN_ROOT_DIR}%g" $1
1062 if [ "${CGNS_ROOT_DIR}" != "" ] ; then
1063 sed -i "s%\([^/]*\)[^; ]*/cgnslib-[0-9.]\+%\1${CGNS_ROOT_DIR}%g" $1
1065 if [ "${NUMPY_ROOT_DIR}" != "" ] ; then
1066 sed -i "s%\([^/]*\)[^; ]*/numpy-[0-9.]\+%\1${NUMPY_ROOT_DIR}%g" $1
1068 if [ "${GRAPHVIZ_ROOT_DIR}" != "" ] ; then
1069 sed -i "s%\([^/]*\)[^; ]*/graphviz-[0-9.]\+%\1${GRAPHVIZ_ROOT_DIR}%g" $1
1071 if [ "${DOXYGEN_ROOT_DIR}" != "" ] ; then
1072 sed -i "s%\([^/]*\)[^; ]*/doxygen-[0-9.]\+%\1${DOXYGEN_ROOT_DIR}%g" $1
1074 if [ "${SPHINX_ROOT_DIR}" != "" ] ; then
1075 sed -i "s%\([^/]*\)[^; ]*/Sphinx-[0-9.]\+%\1${SPHINX_ROOT_DIR}%g" $1
1077 if [ "${WSO2_ROOT_DIR}" != "" ] ; then
1078 sed -i "s%\([^/]*\)[^; ]*/wso2-wsf-cpp-[0-9.]\+%\1${WSO2_ROOT_DIR}%g" $1
1080 if [ "${MESHGEMS_ROOT_DIR}" != "" ] ; then
1081 sed -i "s%\([^/]*\)[^; ]*/MeshGems-[0-9.]\+%\1${MESHGEMS_ROOT_DIR}%g" $1
1083 if [ "${METIS_ROOT_DIR}" != "" ] ; then
1084 sed -i "s%\([^/]*\)[^; ]*/metis-[0-9.]\+%\1${METIS_ROOT_DIR}%g" $1
1086 if [ "${SCOTCH_ROOT_DIR}" != "" ] ; then
1087 sed -i "s%\([^/]*\)[^; ]*/scotch-[0-9.]\+%\1${SCOTCH_ROOT_DIR}%g" $1
1089 local libglso=`where_libgl_so`
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
1099 grep libGL.so $1 > /dev/null && sed -i "s%\([; \"]\)/[^; \"]\+/libGL.so[0-9.]*%\1${libglso}%g" $1