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-2015 CEA
11 # This script is the part of the SALOME installation procedure.
13 ####################################################################################
16 export SHRC="salome.sh"
17 export CSHRC="salome.csh"
18 export CFGRC="salome.cfg"
20 #####################################################
21 # !WARNING! This is current SALOME version number
22 ####################################################
23 export SALOME_VERSION="7.5.1"
24 export YACSGEN_VERSION=${SALOME_VERSION}
26 # Name of the single directory for SALOME modules
27 export SDIR_NAME="SALOME_${SALOME_VERSION}"
29 #this function takes one parameter - path to module source folder
30 check_salome_src_version(){
33 if [ -n "${root_dir}" ]; then
35 if [ ! -f ${root_dir}/${cfg_file} ] ; then
36 cfg_file=configure.in.base
38 cfg_file=CMakeLists.txt
40 if [ -f ${root_dir}/${cfg_file} ] ; then
41 if [ "${cfg_file}" = "CMakeLists.txt" ] ; then
42 ver_maj=`cat ${root_dir}/${cfg_file} | grep SET\(VERSION_MAJOR | sed -e "s%[A-Z_() ]%%g"`
43 ver_min=`cat ${root_dir}/${cfg_file} | grep SET\(VERSION_MINOR | sed -e "s%[A-Z_() ]%%g"`
44 ver_maintenance=`cat ${root_dir}/${cfg_file} | grep SET\(VERSION_MAINTENANCE | sed -e "s%[A-Z_() ]%%g"`
45 ver="${ver_maj}.${ver_min}.${ver_maintenance}"
47 ver=`grep -e "^AC_INIT" ${root_dir}/${cfg_file} | sed -e "s%.*\[\([[:digit:].]*\)\].*%\1%g"`
50 if [ "${ver}" = "${SALOME_VERSION}" ]; then
58 #this function takes several parameters
59 #first parameter contains descriptor of output file
60 #next parameters is command for execution
61 #in case of bad result of execution ask user about furher steps
62 #(user can cancel installation procedure)
68 if [ -n "${INSTALL_WORK}" ] ; then errfile=${INSTALL_WORK}/errlog; fi
70 if [ "${out}" != "1" ] ; then cmd="${cmd} >> ${out}" ; fi
72 if [ "${out}" != "1" ] ; then
73 "$@" >> ${out} 2>${errfile}
77 if [ "$?" -ne "0" ] ; then
78 if [ ${out} != "1" ] ; then
81 cat ${errfile} >> ${out}
83 # VSR : 10/11/05: disable answer mode ==>
85 #echo -e "NOT DONE !!! => $*"
86 #echo -n "Would you like to continue to install this product: (Y,N) [Y] : "
88 #rep=`echo ${rep} | tr "[A-Z]" "[a-z]"`
89 #if test -z ${rep} || [ ${rep} = "y" ] ; then
92 # VSR : 10/11/05: disable answer mode <==
98 #invoke check_job function
99 #all output will be put into terminal
109 rm -rf "$1" > /dev/null
113 #create environment for sh and csh
116 install_root=$1; shift
119 for i in ${SHRC} ${CSHRC} ${CFGRC} ; do
120 if [ -e ${install_work}/${i} ]; then
121 rm ${install_work}/${i}
123 touch ${install_work}/${i}
126 if [ $# -eq 4 ] ; then
128 product_env=${install_work}/env_${product_name}.sh
129 (test -e ${product_env} && rm ${product_env} )
132 ### !!! writing salome.sh file !!! -> define INST_ROOT
133 cat >> ${install_work}/${SHRC} <<EOF
134 #${DELIM} Setting products installation directory ${DELIM}
135 export INST_ROOT=${install_root}
137 #${DELIM} Environment switch: 0 for SALOME building, 1 for SALOME launching ${DELIM}
138 export ENV_FOR_LAUNCH=1
140 #${DELIM} Setting numeric locale ${DELIM}
145 ### !!! writing salome.csh file !!! -> set inital variables
146 pre_vars="PATH LD_LIBRARY_PATH LD_RUN_PATH PYTHONPATH TCLLIBPATH"
147 for i in ${pre_vars} ; do
148 cat >> ${install_work}/${CSHRC} <<EOF
149 #${DELIM} setting initial ${i} ${DELIM}
150 if (! (\$?${i}) ) then
157 ### !!! writing salome.cfs file !!! -> set inital variables
158 cat >> ${install_work}/${CFGRC} <<EOF
159 [SALOME Configuration]
163 ### !!! writing salome.(c)sh files !!! -> dump products environment files, changing 'export' by 'setenv(a|p)' where necessary
164 ### Note, that for performance reasons temporary environment files used during installation procedure itself
165 ### are created without using setenv(a|p) aliases.
167 # 0. add /usr/lib or /usr/lib64 dir to the LD_LIBRARY_PATH
168 #if test `uname -m` = "x86_64" ; then
169 #echo 'export LD_LIBRARY_PATH=/usr/lib64:${LD_LIBRARY_PATH}' >> ${install_work}/${SHRC} 2>/dev/null
170 #echo '' >> ${install_work}/${SHRC} 2>/dev/null
172 #echo 'export LD_LIBRARY_PATH=/usr/lib:${LD_LIBRARY_PATH}' >> ${install_work}/${SHRC} 2>/dev/null
173 #echo '' >> ${install_work}/${SHRC} 2>/dev/null
176 # 1. first dump all environment files into the ${SHRC} file
177 product_sequence="$2"
178 install_products="$3"
179 for i in ${product_sequence} ; do
180 env_file=${install_work}/env_${i}.sh
181 _env_file=${install_work}/_env_${i}.sh
182 if [ -e ${_env_file} ] ; then
183 cat ${_env_file} >> ${install_work}/${SHRC} 2>/dev/null
184 elif [ -e ${env_file} ] ; then
185 echo ${install_products} | grep -q "\b${i}\b"
186 if [ $? -eq 1 ] ; then
187 cat ${env_file} | sed 's/^/## /' >> ${install_work}/${SHRC} 2>/dev/null
189 cat ${env_file} >> ${install_work}/${SHRC} 2>/dev/null
194 # 2. writing global functions to _salome.sh file
195 cat >> ${install_work}/_${SHRC} <<EOF
196 ##########################################################################
197 # Functions exporta and exportp are used to append/prepend correspondingly
198 # one directory or a set of directories separated by semicolon symbol (':')
199 # to the environment variables like PATH, LD_LIBRARY_PATH, PYTHONPATH,
201 # The main purpose is to replace default setenv command behavior:
202 # exporta, exportp also remove duplicated entries, shortening in that way
203 # the environment variables.
204 # If some directory being added is already included into the variable
205 # nothing is done for it.
206 # Note, that these functions work some slower that setenv command itself.
209 # appends/prepends set of directories (second parameter)
210 # to the another set of directories (first parameter) and
211 # removes duplicated entries;
212 # the third parameter defines the mode: 0 - append, 1 - prepend
214 out_var=\`echo \$1 \$2 | awk -v dir=\$3 '{ \\
215 na = split(\$2,a,":"); \\
219 if(\$1 != "<empty>") { \\
220 nb = split(\$1,b,":"); \\
221 for(i=1;i<=nb;i++) { \\
222 if(!(b[i] in ccc) ) { \\
230 for(i=1;i<=na;i++) { \\
231 if(!(a[i] in ccc)) { \\
238 for(i=1;i<k2;i++) { \\
241 for(i=1;i<k1;i++) { \\
246 for(i=1;i<k1;i++) { \\
249 for(i=1;i<k2;i++) { \\
253 }' | sed -e 's/\(.*\):/\1/g'\`
257 # appends directory or set of directories, separated by ':' (second parameter)
258 # to the variable (first parameter)
261 if [ -z "\${xenv}" ]; then xenv="<empty>"; fi
262 out_var=\`cleandup \${xenv} \$2 0\`
263 export \$1=\${out_var}
266 # prepends directory or set of directories, separated by ':' (second parameter)
267 # to the variable (first parameter)
270 if [ -z "\${xenv}" ]; then xenv="<empty>"; fi
271 out_var=\`cleandup \${xenv} \$2 1\`
272 export \$1=\${out_var}
274 ###########################################################################
278 # 3. writing global functions to _salome.csh file
279 cat >> ${install_work}/_${CSHRC} <<EOF
281 ###########################################################################
282 # Aliases setenva and setenvp are used to append/prepend correspondingly
283 # one directory or a set of directories separated by semicolon symbol (':')
284 # to the environment variables like PATH, LD_LIBRARY_PATH, PYTHONPATH,
286 # The main purpose is to replace default setenv command behavior:
287 # setenva, setenvp also remove duplicated entries, shortening in that way
288 # the environment variables.
289 # If some directory being added is already included into the variable
290 # nothing is done for it.
291 # Note, that these aliases work some slower that setenv command itself.
294 # appends/prepends set of directories (second parameter)
295 # to the another set of directories (first parameter) and
296 # removes duplicated entries;
297 # the third parameter defines the mode: 0 - append, 1 - prepend
298 alias cleandup "echo \!:1 \!:2 | awk -v dir=\!:3 \\\\
299 '"'{ na = split(\$2,a,":"); \\\\
303 if(\$1 != "<empty>") { \\\\
304 nb = split(\$1,b,":"); \\\\
305 for(i=1;i<=nb;i++) { \\\\
306 if(!(b[i] in ccc) ) { \\\\
314 for(i=1;i<=na;i++) { \\\\
315 if(!(a[i] in ccc)) { \\\\
322 for(i=1;i<k2;i++) { \\\\
325 for(i=1;i<k1;i++) { \\\\
330 for(i=1;i<k1;i++) { \\\\
333 for(i=1;i<k2;i++) { \\\\
337 }'"' | sed -e 's/\(.*\):/\1/g'"
339 # appends directory or set of directories, separated by ':' (second parameter)
340 # to the variable (first parameter)
341 alias setenva 'set a=\!:1 ; set b=\!:2 ; \\
342 set c=\`printenv \${a}\` ; \\
343 set b=\`cleandup \${c} \${b} 0\` ; \\
344 setenv \${a} \${b} ; \\
348 # prepends directory or set of directories, separated by ':' (second parameter)
349 # to the variable (first parameter)
350 alias setenvp 'set a=\!:1 ; set b=\!:2 ; \\
351 set c=\`printenv \${a}\` ; \\
352 set b=\`cleandup \${c} \${b} 1\` ; \\
353 setenv \${a} \${b} ; \\
355 ###########################################################################
358 cat ${install_work}/${CSHRC} >> ${install_work}/_${CSHRC}
360 # 4. put the contents of salome.sh to _salome.sh replacing export by export(a|p) aliases where necessary
361 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
362 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
363 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
364 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
366 cat ${INSTALL_WORK}/_tmp2 >> ${install_work}/_${SHRC}
368 # 5. Create a salome.csh file from salome.sh by replacing export by setenv, etc.
369 sed -e 's%export \([[:alnum:]_[:blank:]]*\)\=%setenv \1 %g' ${install_work}/${SHRC} > ${INSTALL_WORK}/_tmp1 2>/dev/null
370 cat ${INSTALL_WORK}/_tmp1 >> ${install_work}/${CSHRC}
372 # 6. Create a _salome.csh file from _salome.sh by replacing export by setenv, exporta by setenva, etc.
373 sed -e 's%export \([[:alnum:]_[:blank:]]*\)\=%setenv \1 %g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
374 sed -e 's%exporta \([[:alnum:]_[:blank:]]*\)%setenva \1%g' ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
375 sed -e 's%exportp \([[:alnum:]_[:blank:]]*\)%setenvp \1%g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
376 sed -e 's%if \[ -n "\${PYTHONPATH}" \] ; then%if ( ${?PYTHONPATH} ) then%g' ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
377 sed -e 's%if \[ -n "\${ENV_FOR_LAUNCH}" \] ; then%if ( ${?ENV_FOR_LAUNCH} ) then%g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
378 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
379 sed -e 's%^\([[:blank:]]*\)fi\([[:blank:]]*\)$%\1endif\2%g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
380 sed -e 's%var.sh%var.csh%g' ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
381 sed -e 's%if \[ -e "\${LICENSE_FILE}" \] ; then%if ( -e ${LICENSE_FILE} ) then%g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
383 cat ${INSTALL_WORK}/_tmp1 >> ${install_work}/_${CSHRC} 2>/dev/null
385 rm -f ${INSTALL_WORK}/_tmp1 ${INSTALL_WORK}/_tmp2
387 # 7. Create a salome.cfg file from salome.sh
388 cat ${install_work}/${SHRC} | grep -v -e "^## " | awk 'BEGIN {v=1} /if / {if(v!=2)v=0;} /fi/ {if(v!=2)v=1;} /KERNEL/ {v=2;} {if(v==1 && match($0, "^ *fi *$")==0) print $0;}' >> ${install_work}/${CFGRC}
389 sed -i "s%export PATH=\(.*\):\${\?PATH}\?%ADD_TO_PATH: \1%g" ${install_work}/${CFGRC}
390 sed -i "s%export LD_LIBRARY_PATH=\(.*\):\${\?LD_LIBRARY_PATH}\?%ADD_TO_LD_LIBRARY_PATH: \1%g" ${install_work}/${CFGRC}
391 sed -i "s%export PYTHONPATH=\(.*\):\${\?PYTHONPATH}\?%ADD_TO_PYTHONPATH: \1%g" ${install_work}/${CFGRC}
392 sed -i "s%export PV_PLUGIN_PATH=\(.*\)%ADD_TO_PV_PLUGIN_PATH: \1%g" ${install_work}/${CFGRC}
393 sed -i "s%export %%g" ${install_work}/${CFGRC}
394 sed -i "s%INST_ROOT%ROOT_SALOME%g" ${install_work}/${CFGRC}
395 sed -i "s%\${\?\([A-Za-z0-9_]\+\)}\?%\%(\1)s%g" ${install_work}/${CFGRC}
397 if [ $# -eq 5 ] ; then
399 if [ -d ${product_dir} ] ; then
400 test -e ${product_dir}/${SHRC} && mv ${product_dir}/${SHRC} ${product_dir}/${SHRC}_`date +%F_%T`
401 cp ${install_work}/_${SHRC} ${product_dir}/${SHRC}
402 test -e ${product_dir}/${CSHRC} && mv ${product_dir}/${CSHRC} ${product_dir}/${CSHRC}_`date +%F_%T`
403 cp ${install_work}/_${CSHRC} ${product_dir}/${CSHRC}
404 test -e ${product_dir}/${CFGRC} && mv ${product_dir}/${CFGRC} ${product_dir}/${CFGRC}_`date +%F_%T`
405 cp ${install_work}/${CFGRC} ${product_dir}/${CFGRC}
408 sed -e 's%setenv ENV_FOR_LAUNCH 1%setenv ENV_FOR_LAUNCH 0%' ${install_work}/_${CSHRC} > ${install_root}/env_build.csh
409 sed -e 's%export ENV_FOR_LAUNCH=1%export ENV_FOR_LAUNCH=0%' ${install_work}/_${SHRC} > ${install_root}/env_build.sh
411 cp -f ${install_work}/_${CSHRC} ${install_root}/env_products.csh
412 cp -f ${install_work}/_${SHRC} ${install_root}/env_products.sh
414 rm -f ${install_work}/_${SHRC} ${install_work}/_${CSHRC}
416 ### !!! copying build.csh and build.sh scripts
417 if [ -e ./build.csh ] && [ ! -e ${install_root}/build.csh ]; then
418 cp -f ./build.csh ${install_root}
420 if [ -e ./build.sh ] && [ ! -e ${install_root}/build.sh ]; then
421 cp -f ./build.sh ${install_root}
424 ### !!! copying release notes
425 for p in `ls ../` ; do
426 export pdf=`echo ${p} | sed s/[.]/" "/g | awk '{print $2}'`
427 if [ "${pdf}" = "pdf" ]; then
429 if [ ! -e ${install_root}/${RN} ]; then
430 cp -f ../${RN} ${install_root}
437 #try use already existing product
440 product_dir=$1; install_root=$2; install_work=$3;
441 product_sequence="$4"; installed_products="$5"; product_type=$6
442 env_file=${product_dir}/env_${product_type}.sh
443 if [ -f ${env_file} ] ; then
444 cp -f ${env_file} ${install_work}/_env_${product_type}.sh
445 make_env ${install_root} ${install_work} "${product_sequence}" "${installed_products}"
446 source ${install_work}/${SHRC}
448 if [ $? -eq 0 ] ; then
452 echo ${product_type} | grep -q '_src$'
453 if [ $? -eq 1 ] ; then
461 #check existance of lib passed as first parameter
462 #return 0 if lib exists
463 #if you pass second parameter search will be done in it
464 #otherwise search will be done in ${LD_LIBRARY_PATH}
465 #you should use : as dilimeter if you are going to pass second parameter
470 whereIs=${LD_LIBRARY_PATH}
472 for d in `echo ${whereIs} | sed -e"s%:% %g"` ; do
473 ret=`find ${d} -name $1 2>/dev/null`
474 if [ -n "${ret}" ] ; then
475 #echo "The $1 exists on yours system in a ${d} folder"
485 for i in `echo ${path} | sed -e"s%:% %g"` ; do
486 ret=`find ${i} -name ${file} -maxdepth 1 2>/dev/null`
487 if [ -n "${ret}" ] ; then
488 ret=`echo ${ret} | sed -e"s%/\${file}$%%g"`
497 arg1=$1; val1=$2; arg2=$3; val2=$4
498 tmp="^${val1}$|^${val1}:|:${val1}$|:${val1}:"
499 #echo ${val2} | grep -E "${tmp}" >/dev/null 2>&1
500 #if [ $? -eq 0 ] ; then
505 exclude_list="usr lib bin sbin etc"
506 for i in ${exclude_list} ; do
507 tmp="^/${i}/|^/${i}\$"
508 echo ${val1} | grep -E "${tmp}" >/dev/null 2>&1
509 if [ "$?" = "0" ] ; then to_tail=0; break; fi
511 if [ ${to_tail} -eq 0 ] ; then
520 if test -z "${TCLHOME}"; then
523 tclcfg=`find ${TCLHOME}/lib -name "tclConfig.sh" 2> /dev/null`
526 for f in ${tclcfg} ; do
527 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;}'`
528 if [ ${maxver} -lt ${ver} ]; then
533 if test -n "${file}"; then
534 echo `dirname ${file}`
543 if test -z "${TCLHOME}"; then
546 tclcfg=`find ${TCLHOME}/lib -name "tkConfig.sh" 2> /dev/null`
549 for f in ${tclcfg} ; do
550 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;}'`
551 if [ ${maxver} -lt ${ver} ]; then
556 if test -n "${file}"; then
557 echo `dirname ${file}`
566 if test -f /usr/X11R6/include/DPS/dpsconfig.h ; then
570 if test -f /usr/include/DPS/dpsconfig.h ; then
579 for d in /usr/X11R6/include /usr/include ; do
580 if [ -d ${d}/GL ] && [ -f ${d}/GL/gl.h ] ; then
592 local libdirs="/usr/X11R6/lib64 /usr/lib64 /usr/lib/`uname -m`-linux-gnu /usr/X11R6/lib /usr/lib"
594 # search libGL.so* file and correct libGL.la in the same directory
595 for d in ${libdirs} ; do
596 if [ "`ls ${d}/libGL.so* 2>/dev/null`" ] && [ -f ${d}/libGL.la ]; then
597 libdir=`grep "libdir=" ${d}/libGL.la | sed -e "s%libdir='\(.*\)'%\1%" -e "s%/*$%%g"`
598 if [ "${libdir}" = "${d}" ] ; then
604 # search libGL.la file and check if this file is correct
605 for d in ${libdirs} ; do
606 if [ -f ${d}/libGL.la ] ; then
607 libdir=`grep "libdir=" ${d}/libGL.la | sed -e "s%libdir='\(.*\)'%\1%"`
608 if [ "`ls ${libdir}/libGL.so* 2>/dev/null`" ] ; then
614 # then search libGL.so* file
615 for d in ${libdirs} ; do
616 if [ "`ls ${d}/libGL.so* 2>/dev/null`" ] ; then
626 local libdirs="/usr/X11R6/lib64 /usr/lib64 /usr/lib/`uname -m`-linux-gnu /usr/X11R6/lib /usr/lib"
628 for d in ${libdirs} ; do
629 if [ -f ${d}/libGL.so ] ; then
639 local gllibdir="`where_gl_libs`"
640 if [ "${gllibdir}" != "" ] ; then
641 #VSR: 02/04/2013 - next block is commented as it seems to be wrong :( libGL.la should not be ever mentioned
642 # if [ -f ${gllibdir}/libGL.la ] ; then
643 # libdir=`grep "libdir=" ${gllibdir}/libGL.la | sed -e "s%libdir='\(.*\)'%\1%"`
644 # if [ "`ls ${libdir}/libGL.so* 2>/dev/null`" ] ; then
645 # str_to_replace="${gllibdir}/libGL.la"
648 if [ "${str_to_replace}" = "" ] ; then
649 str_to_replace="-L${gllibdir} -lGL"
652 la_files=`find . -name "*.la"`
653 for la_file in ${la_files} XXX ; do
654 if [ "${la_file}" = "XXX" ] ; then continue; fi
655 grep -e "libGL.la" ${la_file} >& /dev/null || grep -e "-lGL\b" ${la_file} >& /dev/null && \
656 sed -e "s%-lGL\b%%g" \
657 -e "s%[^[:space:]']*libGL.la[[:space:]]%%g" \
658 -e "s%^dependency_libs='\(.*\)%dependency_libs='${str_to_replace} \1%" \
659 ${la_file} > ${la_file}.new && \
660 mv -f ${la_file}.new ${la_file}
666 # function: create .qmake.cache file for compilation of custom gcc compiler
667 # usage: gen_qmake_cache <dir>
668 # <dir> is a directory to put .qmake.cache
674 if [ "${d}" != "" ] && [ -d ${d} ] && [ "${CXX}" != "" ] ; then
675 touch ${d}/.qmake.cache >& /dev/null
676 if [ "$?" != "0" ] ; then
679 cat > ${d}/.qmake.cache <<EOF
682 QMAKE_LINK_SHLIB = ${CXX}
685 QMAKE_LINK_C_SHLIB = ${CC}
695 if [ -z "${ldir}" ] || [ ! -d "${ldir}" ]; then return 1; fi
699 SALOME_MODULES="`env | awk -F_ '/[a-zA-Z0-9]*_ROOT_DIR/ { print $1 }'`"
703 la_files=`find . -name "*.la"`
706 netgendir=${NETGEN_ROOT_DIR}
708 freetypedir=${FREETYPE_ROOT_DIR}
710 ftgldir=${FTGL_ROOT_DIR}
712 gl2psdir=${GL2PS_ROOT_DIR}
714 freeimagedir=${FREEIMAGE_ROOT_DIR}
716 tbbbasedir=${TBB_ROOT_DIR}
717 TBBKERNEL='cc4.1.0_libc2.4_kernel2.6.16.21'
718 if test `uname -m` = "x86_64" ; then
719 export TBBMODE="intel64/${TBBKERNEL}"
721 export TBBMODE="ia32/${TBBKERNEL}"
723 tbbdir=${tbbbasedir}/lib/${TBBMODE}
725 cgnslibdir=${CGNS_ROOT_DIR}
727 casdir=${CAS_ROOT_DIR}/lib
728 if [ ! -d ${casdir} ] ; then casdir=${CAS_ROOT_DIR}/Linux/lib ; fi
729 if [ ! -d ${casdir} ] ; then casdir=${CAS_ROOT_DIR}/lin/lib ; fi
731 omnidir=${OMNIORB_ROOT_DIR}/lib
734 if [ `uname -m` = "x86_64" ] && [ -d ${vtkpath}/lib64 ] ; then
736 elif [ -d ${vtkpath}/lib ] ; then
741 vtkldir=${vtkpath}/lib${LIB_PREFIX}
742 vtkdir=${vtkldir}/vtk-5.0
744 hdfdir=${HDF5_ROOT_DIR}/lib
746 meddir=${MEDFILE_ROOT_DIR}/lib
748 qwtdir=`find_in_path libqwt.so ${LD_LIBRARY_PATH}`
750 where_python=`which python` # e.g. /usr/bin/python
751 if [ -n "${where_python}" ] ; then
752 where_python=`dirname ${where_python}` # --> /usr/bin
753 where_python=`dirname ${where_python}` # --> /usr
754 python_version=`python -c "import sys; print sys.version[:3]"`
755 pythondir=${where_python}/lib/python${python_version}
758 sipdir=`find_in_path sip.so ${LD_LIBRARY_PATH}`
760 pyqtdir=`find_in_path Qt.so ${LD_LIBRARY_PATH}`
762 tcldir=${TCLHOME}/lib
764 boostdir=${BOOST_ROOT_DIR}/lib
766 blsurfdir=${BLSURFHOME}/lib
768 libxmldir=${LIBXML2_ROOT_DIR}/lib
770 metisdir=${METIS_ROOT_DIR}
772 scotchbindir=${SCOTCH_ROOT_DIR}/bin
773 scotchlibdir=${SCOTCH_ROOT_DIR}/lib
775 if test `uname -m` = "x86_64" ; then
776 libGLpath=/usr/lib64/libGL.la
778 libGLpath=/usr/lib/libGL.la
781 graphvizdir=${GRAPHVIZ_ROOT_DIR}/lib
783 qscintilladir=${QSCINTILLA_ROOT_DIR}/lib
785 paraviewdir=${PARAVIEW_ROOT_DIR}/lib
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
792 mgemsdir=${MESHGEMS_ROOT_DIR}/lib/Linux
795 for l in X ${la_files}; do
797 if [ "${l}" != "X" ] ; then
802 # . process salome modules dependencies
803 for mod in ${SALOME_MODULES} ; do
804 moddir=${mod}_ROOT_DIR
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}"_"
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}
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}
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}
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}
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}
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}
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}
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}"_"
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}
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}
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}
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}
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}
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}
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}
894 # . process sip dependencies
895 if [ -n "${sipdir}" ] && [ -d "${sipdir}" ] ; then
896 sed -i "s%-L[^[:space:]]*sip[^[:space:]]*%-L${sipdir}%g" ${l}
899 # . process PyQt dependencies
900 if [ -n "${pyqtdir}" ] && [ -d "${pyqtdir}" ] ; then
901 sed -i "s%-L[^[:space:]]*PyQt[^[:space:]]*%-L${pyqtdir}%g" ${l}
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}
909 # . process boost dependencies
910 if [ -n "${boostdir}" ] && [ -d "${boostdir}" ] ; then
911 sed -i "s%-L[^[:space:]]*boost[^[:space:]]*/lib%-L${boostdir}%g" ${l}
914 # . process blsurf dependencies
915 if [ -n "${blsurfdir}" ] && [ -d "${blsurfdir}" ] ; then
916 sed -i "s%-L[^[:space:]]*BLSurf[^[:space:]]*/lib%-L${blsurfdir}%g" ${l}
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}
924 # . process metis dependencies
925 if [ -n "${metisdir}" ] && [ -d "${metisdir}" ] ; then
926 sed -i "s%-L[^[:space:]]*metis[^[:space:]]*%-L${metisdir}%g" ${l}
929 # . process scotch dependencies
930 if [ -n "${scotchbindir}" ] && [ -d "${scotchbindir}" ] ; then
931 sed -i "s%-L[^[:space:]]*scotch[^[:space:]]*/bin%-L${scotchbindir}%g" ${l}
933 if [ -n "${scotchlibdir}" ] && [ -d "${scotchlibdir}" ] ; then
934 sed -i "s%-L[^[:space:]]*scotch[^[:space:]]*/lib%-L${scotchlibdir}%g" ${l}
937 # . process libGL.la dependencies
938 sed -i "s%${libGLpath}%""%g" ${l}
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}
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}
950 # . process ParaView dependencies
951 if [ -n "${paraviewdir}" ] && [ -d "${paraviewdir}" ] ; then
952 sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*ParaView-[0-9]\.[0-9]\+\.[0-9]/lib% \1${paraviewdir}%g" ${l}
955 # . process DISTENE MeshGems dependencies
956 if [ -n "${mgemsdir}" ] && [ -d "${mgemsdir}" ] ; then
957 sed -i "s%[[:space:]]\(-L\)\?[^[:space:]]*MeshGems-[0-9.]\+/Products/lib/Linux\(_64\)\?% \1${mgemsdir}%g" ${l}
969 if [ "${nf}" = "" ] || [ ! -e ${nf} ] ; then
972 if [ "${PYTHON_ROOT_DIR}" != "" ] ; then
973 sed -i "s%\([^/]*\)[^; ]*/Python-[0-9.]\+%\1${PYTHON_ROOT_DIR}%g" $1
975 if [ "${SWIG_ROOT_DIR}" != "" ] ; then
976 sed -i "s%\([^/]*\)[^; ]*/swig-[0-9.]\+%\1${SWIG_ROOT_DIR}%g" $1
978 if [ "${OMNIORB_ROOT_DIR}" != "" ] ; then
979 sed -i "s%\([^/]*\)[^; ]*/omniORB-[0-9.]\+%\1${OMNIORB_ROOT_DIR}%g" $1
981 if [ "${HDF5_ROOT_DIR}" != "" ] ; then
982 sed -i "s%\([^/]*\)[^; ]*/hdf5-[0-9.]\+%\1${HDF5_ROOT_DIR}%g" $1
984 if [ "${BOOST_ROOT_DIR}" != "" ] ; then
985 sed -i "s%\([^/]*\)[^; ]*/boost-[0-9.]\+%\1${BOOST_ROOT_DIR}%g" $1
987 if [ "${MEDFILE_ROOT_DIR}" != "" ] ; then
988 sed -i "s%\([^/]*\)[^; ]*/med-[0-9.]\+%\1${MEDFILE_ROOT_DIR}%g" $1
990 if [ "${QT4_ROOT_DIR}" != "" ] ; then
991 sed -i "s%\([^/]*\)[^; ]*/qt-[0-9.]\+%\1${QT4_ROOT_DIR}%g" $1
993 if [ "${QWT_ROOT_DIR}" != "" ] ; then
994 sed -i "s%\([^/]*\)[^; ]*/qwt-[0-9.]\+%\1${QWT_ROOT_DIR}%g" $1
996 if [ "${SIP_ROOT_DIR}" != "" ] ; then
997 sed -i "s%\([^/]*\)[^; ]*/sip-[0-9.]\+%\1${SIP_ROOT_DIR}%g" $1
999 if [ "${PYQT4_ROOT_DIR}" != "" ] ; then
1000 sed -i "s%\([^/]*\)[^; ]*/PyQt-[0-9.]\+%\1${PYQT4_ROOT_DIR}%g" $1
1002 if [ "${QSCINTILLA_ROOT_DIR}" != "" ] ; then
1003 sed -i "s%\([^/]*\)[^; ]*/QScintilla-[0-9.]\+%\1${QSCINTILLA_ROOT_DIR}%g" $1
1005 if [ "${PARAVIEW_ROOT_DIR}" != "" ] ; then
1006 sed -i "s%\([^/]*\)[^; ]*/ParaView-[0-9.]\+%\1${PARAVIEW_ROOT_DIR}%g" $1
1008 if [ "${LIBXML2_ROOT_DIR}" != "" ] ; then
1009 sed -i "s%\([^/]*\)[^; ]*/libxml2-[0-9.]\+%\1${LIBXML2_ROOT_DIR}%g" $1
1011 if [ "${FREETYPE_ROOT_DIR}" != "" ] ; then
1012 sed -i "s%\([^/]*\)[^; ]*/freetype-[0-9.]\+%\1${FREETYPE_ROOT_DIR}%g" $1
1014 if [ "${FREEIMAGE_ROOT_DIR}" != "" ] ; then
1015 sed -i "s%\([^/]*\)[^; ]*/freeimage-[0-9.]\+%\1${FREEIMAGE_ROOT_DIR}%g" $1
1017 if [ "${GL2PS_ROOT_DIR}" != "" ] ; then
1018 sed -i "s%\([^/]*\)[^; ]*/gl2ps-[0-9.]\+%\1${GL2PS_ROOT_DIR}%g" $1
1020 if [ "${TBB_ROOT_DIR}" != "" ] ; then
1021 sed -i "s%\([^/]*\)[^; ]*/tbb[^/; \"]\+%\1${TBB_ROOT_DIR}%g" $1
1023 if [ "${CAS_ROOT_DIR}" != "" ] ; then
1024 sed -i "s%\([^/]*\)[^; ]*/OCCT[^/]*\(/[^ /;\"]*\)\?\(\"\|/inc\|/lib\)%\1${CAS_ROOT_DIR}\3%g" $1
1026 if [ "${NETGEN_ROOT_DIR}" != "" ] ; then
1027 sed -i "s%\([^/]*\)[^; ]*/netgen-[0-9.]\+%\1${NETGEN_ROOT_DIR}%g" $1
1029 if [ "${CGNS_ROOT_DIR}" != "" ] ; then
1030 sed -i "s%\([^/]*\)[^; ]*/cgnslib-[0-9.]\+%\1${CGNS_ROOT_DIR}%g" $1
1032 if [ "${NUMPY_ROOT_DIR}" != "" ] ; then
1033 sed -i "s%\([^/]*\)[^; ]*/numpy-[0-9.]\+%\1${NUMPY_ROOT_DIR}%g" $1
1035 if [ "${GRAPHVIZ_ROOT_DIR}" != "" ] ; then
1036 sed -i "s%\([^/]*\)[^; ]*/graphviz-[0-9.]\+%\1${GRAPHVIZ_ROOT_DIR}%g" $1
1038 if [ "${DOXYGEN_ROOT_DIR}" != "" ] ; then
1039 sed -i "s%\([^/]*\)[^; ]*/doxygen-[0-9.]\+%\1${DOXYGEN_ROOT_DIR}%g" $1
1041 if [ "${SPHINX_ROOT_DIR}" != "" ] ; then
1042 sed -i "s%\([^/]*\)[^; ]*/Sphinx-[0-9.]\+%\1${SPHINX_ROOT_DIR}%g" $1
1044 if [ "${WSO2_ROOT_DIR}" != "" ] ; then
1045 sed -i "s%\([^/]*\)[^; ]*/wso2-wsf-cpp-[0-9.]\+%\1${WSO2_ROOT_DIR}%g" $1
1047 if [ "${MESHGEMS_ROOT_DIR}" != "" ] ; then
1048 sed -i "s%\([^/]*\)[^; ]*/MeshGems-[0-9.]\+%\1${MESHGEMS_ROOT_DIR}%g" $1
1050 if [ "${METIS_ROOT_DIR}" != "" ] ; then
1051 sed -i "s%\([^/]*\)[^; ]*/metis-[0-9.]\+%\1${METIS_ROOT_DIR}%g" $1
1053 if [ "${SCOTCH_ROOT_DIR}" != "" ] ; then
1054 sed -i "s%\([^/]*\)[^; ]*/scotch-[0-9.]\+%\1${SCOTCH_ROOT_DIR}%g" $1
1056 local libglso=`where_libgl_so`
1059 for sm in LIBBATCH SIMANIO KERNEL GUI GEOM MED SMESH PARAVIS YACS HEXABLOCK HOMARD JOBMANAGER \
1060 NETGENPLUGIN BLSURFPLUGIN GHS3DPLUGIN GHS3DPRLPLUGIN HexoticPLUGIN HYBRIDPLUGIN HEXABLOCKPLUGIN \
1061 CALCULATOR PYCALCULATOR COMPONENT HELLO PYHELLO LIGHT PYLIGHT ATOMIC ATOMGEN ATOMSOLV RANDOMIZER SIERPINSKY ; do
1062 smvar=${sm}_ROOT_DIR
1063 if [ "${!smvar}" != "" ] ; then
1064 sed -i "s%\([; \"]\)/[^; \"]\+/${sm}\([; \"/]\)%\1${!smvar}\2%g" $1
1066 grep libGL.so $1 > /dev/null && sed -i "s%\([; \"]\)/[^; \"]\+/libGL.so[0-9.]*%\1${libglso}%g" $1