-#!/bin/sh
-#
-# This script installs a subset of products necessary for SALOME application
-#
-# Usage: install <target-directory> [all]
-# install <target-directory> <product> ... <product>
-#
-# Type 'install --help' to get more information
-#
-# Important note:
-# <target-directory> must be an absolute path
+#!/bin/bash -noprofile
+
+####################################################################################
+# File : common.sh
+# Created : Thu Dec 18 12:01:00 2002
+# Author : Vadim SANDLER, Open CASCADE SAS (vadim.sandler@opencascade.com)
+# Project : SALOME
+# Module : Installation Wizard
+# Copyright : 2002-2008 CEA
#
-# The script is the part of the SALOME PRO installation procedure.
+# This script is the part of the SALOME installation procedure.
#
-# Copyright : 2003 CEA/DEN, EDF R&D
####################################################################################
export DELIM="------"
export SHRC="salome.sh"
export CSHRC="salome.csh"
-export DEBUG=1
+
+#####################################################
+# !WARNING! This is current SALOME version number
+####################################################
+export SALOME_VERSION="5.1.2"
+
+# Name of the single directory for SALOME modules
+export SDIR_NAME="SALOME_${SALOME_VERSION}"
+
+#this function takes one parameter - path to module source folder
+check_salome_src_version(){
+root_dir=`printenv $1`
+
+if [ -n "$root_dir" ]; then
+ cfg_file=configure.ac
+ if [ ! -f ${root_dir}/${cfg_file} ] ; then
+ cfg_file=configure.in.base
+ fi
+ if [ -f ${root_dir}/${cfg_file} ] ; then
+ ver=`grep -e "^AC_INIT" ${root_dir}/${cfg_file} | sed -e "s%.*\[\([[:digit:].]*\)\].*%\1%g"`
+ if [ "$ver" = "${SALOME_VERSION}" ]; then
+ return 0
+ fi
+ fi
+fi
+return 1
+}
#this function takes several parameters
#first parameter contains descriptor of output file
{
out=$1
shift
- echo -e "`pwd` -> $* >> $out"
- if [ $DEBUG == 0 ] ; then
- $* | tee $out
+ errfile=/tmp/errlog
+ if [ -n "$INSTALL_WORK" ] ; then errfile=$INSTALL_WORK/errlog; fi
+ cmd="`pwd` -> $*"
+ if [ "$out" != "1" ] ; then cmd="$cmd >> $out" ; fi
+ echo -e $cmd
+ if [ "$out" != "1" ] ; then
+ $* >> $out 2>$errfile
else
- if [ $out == "1" ] ; then
$*
- else
- $* >> $out 2>&1
- fi
fi
if [ "$?" -ne "0" ] ; then
if [ $out != "1" ] ; then
cat $out
+ cat $errfile >&2
+ cat $errfile >> $out
fi
- echo -n " " >&2
- echo -e "NOT DONE !!! => $*"
- echo -n "Would you like to continue to install this product: (Y,N) [Y] : "
- read rep;
- rep=`echo $rep | tr "[A-Z]" "[a-z]"`
- if test -z $rep || [ $rep = "y" ] ; then
- return 1
- fi
+ # VSR : 10/11/05: disable answer mode ==>
+ #echo -n " " >&2
+ #echo -e "NOT DONE !!! => $*"
+ #echo -n "Would you like to continue to install this product: (Y,N) [Y] : "
+ #read rep;
+ #rep=`echo $rep | tr "[A-Z]" "[a-z]"`
+ #if test -z $rep || [ $rep = "y" ] ; then
+ # return 1
+ #fi
+ # VSR : 10/11/05: disable answer mode <==
exit 1
fi
return 0
{
install_root=$1; shift
install_work=$1;
+
for i in $SHRC $CSHRC ; do
if [ -e ${install_work}/$i ]; then
rm ${install_work}/$i
touch ${install_work}/$i
done
-if [ $# -eq 3 ] ; then
- product_name=$3;
+if [ $# -eq 4 ] ; then
+ product_name=$4;
product_env=${install_work}/env_${product_name}.sh
(test -e ${product_env} && rm ${product_env} )
fi
-
+### !!! writing salome.sh file !!! -> define INST_ROOT
cat >> ${install_work}/$SHRC <<EOF
-export INSTALL_ROOT=${install_root}
+#${DELIM} Setting products installation directory ${DELIM}
+export INST_ROOT=${install_root}
+
+#${DELIM} Environment switch: 0 for SALOME building, 1 for SALOME launching ${DELIM}
+export ENV_FOR_LAUNCH=1
+
EOF
-product_sequence="$2"
-#for i in `ls -a ${install_work} | grep -E "..*" | grep -v ".salome.*"` ; do
-for i in $product_sequence ; do
- cat ${install_work}/env_${i}.sh >> ${install_work}/$SHRC 2>/dev/null
-done
+### !!! The next is for RedHat 9 only !!!
+if [ -f /etc/redhat-release ] ; then
+ grep -e "Red Hat Linux release 9" /etc/redhat-release > /dev/null
+ if [ $? -eq 0 ] ; then
+ cat >> ${install_work}/$SHRC <<EOF
+#${DELIM} Force RH9 to use old implementation of threads ${DELIM}
+export LD_ASSUME_KERNEL=2.4.18
-sed -e 's%^export \([[:alnum:]_[:blank:]]*\)\=%setenv \1 %g' -e 's%^#csh-specific %%g' ${INSTALL_WORK}/$SHRC > ${INSTALL_WORK}/_$CSHRC
-pre_vars="PATH LD_LIBRARY_PATH LD_RUN_PATH PYTHONPATH"
+EOF
+ fi
+fi
+### !!! writing salome.csh file !!! -> set inital variables
+pre_vars="PATH LD_LIBRARY_PATH LD_RUN_PATH PYTHONPATH TCLLIBPATH"
for i in $pre_vars ; do
cat >> ${install_work}/$CSHRC <<EOF
+#${DELIM} setting initial ${i} ${DELIM}
if (! (\$?${i}) ) then
setenv $i
endif
+
EOF
done
-cat ${INSTALL_WORK}/_$CSHRC >> ${INSTALL_WORK}/$CSHRC
-rm -f ${INSTALL_WORK}/_$CSHRC
-if [ $# -eq 4 ] ; then
- product_dir=$4
+### !!! writing salome.(c)sh files !!! -> dump products environment files, changing 'export' by 'setenv(a|p)' where necessary
+### Note, that for performance reasons temporary environment files used during installation procedure itself
+### are created without using setenv(a|p) aliases.
+
+# 0. add /usr/lib or /usr/lib64 dir to the LD_LIBRARY_PATH
+#if test `uname -m` = "x86_64" ; then
+#echo 'export LD_LIBRARY_PATH=/usr/lib64:${LD_LIBRARY_PATH}' >> ${install_work}/$SHRC 2>/dev/null
+#echo '' >> ${install_work}/$SHRC 2>/dev/null
+#else
+#echo 'export LD_LIBRARY_PATH=/usr/lib:${LD_LIBRARY_PATH}' >> ${install_work}/$SHRC 2>/dev/null
+#echo '' >> ${install_work}/$SHRC 2>/dev/null
+#fi
+
+# Licence activation
+
+# Source of license environment file
+
+echo '#------ License activation ------' >> ${install_work}/$SHRC 2>/dev/null
+echo 'export LICENSE_FILE=/product/distene/dlim8.var.sh' >> ${install_work}/$SHRC 2>/dev/null
+echo '' >> ${install_work}/$SHRC 2>/dev/null
+echo 'if [ -e "${LICENSE_FILE}" ] ; then' >> ${install_work}/$SHRC 2>/dev/null
+echo 'export SIMULOGD_LICENSE_FILE=29029@amun' >> ${install_work}/$SHRC 2>/dev/null
+echo 'source ${LICENSE_FILE}' >> ${install_work}/$SHRC 2>/dev/null
+echo 'fi' >> ${install_work}/$SHRC 2>/dev/null
+echo '' >> ${install_work}/$SHRC 2>/dev/null
+
+# 1. first dump all environment files into the $SHRC file
+product_sequence="$2"
+install_products="$3"
+for i in $product_sequence ; do
+ env_file=${install_work}/env_${i}.sh
+ _env_file=${install_work}/_env_${i}.sh
+ if [ -e $_env_file ] ; then
+ cat $_env_file >> ${install_work}/$SHRC 2>/dev/null
+ elif [ -e $env_file ] ; then
+ echo $install_products | grep -q "\b${i}\b"
+ if [ $? -eq 1 ] ; then
+ cat $env_file | sed 's/^/## /' >> ${install_work}/$SHRC 2>/dev/null
+ else
+ cat $env_file >> ${install_work}/$SHRC 2>/dev/null
+ fi
+ fi
+done
+
+# 2. writing global functions to _salome.sh file
+cat >> ${install_work}/_$SHRC <<EOF
+##########################################################################
+# Functions exporta and exportp are used to append/prepend correspondingly
+# one directory or a set of directories separated by semicolon symbol (':')
+# to the environment variables like PATH, LD_LIBRARY_PATH, PYTHONPATH,
+# LD_RUN_PATH etc.
+# The main purpose is to replace default setenv command behavior:
+# exporta, exportp also remove duplicated entries, shortening in that way
+# the environment variables.
+# If some directory being added is already included into the variable
+# nothing is done for it.
+# Note, that these functions work some slower that setenv command itself.
+#
+#### cleandup ###
+# appends/prepends set of directories (second parameter)
+# to the another set of directories (first parameter) and
+# removes duplicated entries;
+# the third parameter defines the mode: 0 - append, 1 - prepend
+cleandup() {
+out_var=\`echo \$1 \$2 | awk -v dir=\$3 '{ \\
+ na = split(\$2,a,":"); \\
+ k1=0; \\
+ bbb[k1++]=""; \\
+ ccc[""]; \\
+ if(\$1 != "<empty>") { \\
+ nb = split(\$1,b,":"); \\
+ for(i=1;i<=nb;i++) { \\
+ if(!(b[i] in ccc) ) { \\
+ ccc[b[i]]; \\
+ bbb[k1++]=b[i]; \\
+ }; \\
+ }; \\
+ }; \\
+ k2=0; \\
+ aaa[k2++]=""; \\
+ for(i=1;i<=na;i++) { \\
+ if(!(a[i] in ccc)) { \\
+ ccc[a[i]]; \\
+ aaa[k2++]=a[i]; \\
+ }; \\
+ }; \\
+ ORS=":"; \\
+ if(dir) { \\
+ for(i=1;i<k2;i++) { \\
+ print aaa[i]; \\
+ } \\
+ for(i=1;i<k1;i++) { \\
+ print bbb[i]; \\
+ } \\
+ } \\
+ else { \\
+ for(i=1;i<k1;i++) { \\
+ print bbb[i]; \\
+ } \\
+ for(i=1;i<k2;i++) { \\
+ print aaa[i]; \\
+ } \\
+ } \\
+ }' | sed -e 's/\(.*\):/\1/g'\`
+echo \$out_var
+}
+### exporta ###
+# appends directory or set of directories, separated by ':' (second parameter)
+# to the variable (first parameter)
+exporta () {
+xenv=\`printenv \$1\`
+if [ -z "\$xenv" ]; then xenv="<empty>"; fi
+out_var=\`cleandup \$xenv \$2 0\`
+export \$1=\$out_var
+}
+### exportp ###
+# prepends directory or set of directories, separated by ':' (second parameter)
+# to the variable (first parameter)
+exportp () {
+xenv=\`printenv \$1\`
+if [ -z "\$xenv" ]; then xenv="<empty>"; fi
+out_var=\`cleandup \$xenv \$2 1\`
+export \$1=\$out_var
+}
+###########################################################################
+
+EOF
+
+# 3. writing global functions to _salome.csh file
+cat >> ${install_work}/_$CSHRC <<EOF
+
+###########################################################################
+# Aliases setenva and setenvp are used to append/prepend correspondingly
+# one directory or a set of directories separated by semicolon symbol (':')
+# to the environment variables like PATH, LD_LIBRARY_PATH, PYTHONPATH,
+# LD_RUN_PATH etc.
+# The main purpose is to replace default setenv command behavior:
+# setenva, setenvp also remove duplicated entries, shortening in that way
+# the environment variables.
+# If some directory being added is already included into the variable
+# nothing is done for it.
+# Note, that these aliases work some slower that setenv command itself.
+#
+#### cleandup ###
+# appends/prepends set of directories (second parameter)
+# to the another set of directories (first parameter) and
+# removes duplicated entries;
+# the third parameter defines the mode: 0 - append, 1 - prepend
+alias cleandup "echo \!:1 \!:2 | awk -v dir=\!:3 \\\\
+'"'{ na = split(\$2,a,":"); \\\\
+ k1=0; \\\\
+ bbb[k1++]=""; \\\\
+ ccc[""]; \\\\
+ if(\$1 != "<empty>") { \\\\
+ nb = split(\$1,b,":"); \\\\
+ for(i=1;i<=nb;i++) { \\\\
+ if(!(b[i] in ccc) ) { \\\\
+ ccc[b[i]]; \\\\
+ bbb[k1++]=b[i]; \\\\
+ }; \\\\
+ }; \\\\
+ }; \\\\
+ k2=0; \\\\
+ aaa[k2++]=""; \\\\
+ for(i=1;i<=na;i++) { \\\\
+ if(!(a[i] in ccc)) { \\\\
+ ccc[a[i]]; \\\\
+ aaa[k2++]=a[i]; \\\\
+ }; \\\\
+ }; \\\\
+ ORS=":"; \\\\
+ if(dir) { \\\\
+ for(i=1;i<k2;i++) { \\\\
+ print aaa[i]; \\\\
+ } \\\\
+ for(i=1;i<k1;i++) { \\\\
+ print bbb[i]; \\\\
+ } \\\\
+ } \\\\
+ else { \\\\
+ for(i=1;i<k1;i++) { \\\\
+ print bbb[i]; \\\\
+ } \\\\
+ for(i=1;i<k2;i++) { \\\\
+ print aaa[i]; \\\\
+ } \\\\
+ } \\\\
+ }'"' | sed -e 's/\(.*\):/\1/g'"
+### setenva ###
+# appends directory or set of directories, separated by ':' (second parameter)
+# to the variable (first parameter)
+alias setenva 'set a=\!:1 ; set b=\!:2 ; \\
+ set c=\`printenv \$a\` ; \\
+ set b=\`cleandup \$c \$b 0\` ; \\
+ setenv \$a \$b ; \\
+ unset a, b, c'
+
+### setenvp ###
+# prepends directory or set of directories, separated by ':' (second parameter)
+# to the variable (first parameter)
+alias setenvp 'set a=\!:1 ; set b=\!:2 ; \\
+ set c=\`printenv \$a\` ; \\
+ set b=\`cleandup \$c \$b 1\` ; \\
+ setenv \$a \$b ; \\
+ unset a, b, c'
+###########################################################################
+
+EOF
+cat ${install_work}/$CSHRC >> ${install_work}/_$CSHRC
+
+# 4. put the contents of salome.sh to _salome.sh replacing export by export(a|p) aliases where necessary
+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
+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
+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
+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
+
+# Setting "/usr/X11R6/lib" path in LD_LIBRARY_PATH for the libGL.so.1 file
+#if test `uname -m` = "x86_64" ; then
+#echo '# Setting /usr/X11R6/lib64 path in LD_LIBRARY_PATH for the libGL.so.1 file' >> ${INSTALL_WORK}/_tmp2
+#echo 'export LD_LIBRARY_PATH=/usr/X11R6/lib64:${LD_LIBRARY_PATH}' >> ${INSTALL_WORK}/_tmp2
+#else
+#echo '# Setting /usr/X11R6/lib path in LD_LIBRARY_PATH for the libGL.so.1 file' >> ${INSTALL_WORK}/_tmp2
+#echo 'export LD_LIBRARY_PATH=/usr/X11R6/lib:${LD_LIBRARY_PATH}' >> ${INSTALL_WORK}/_tmp2
+#fi
+
+cat ${INSTALL_WORK}/_tmp2 >> ${install_work}/_$SHRC
+
+# 5. Create a salome.csh file from salome.sh by replacing export by setenv, etc.
+sed -e 's%export \([[:alnum:]_[:blank:]]*\)\=%setenv \1 %g' ${install_work}/$SHRC > ${INSTALL_WORK}/_tmp1 2>/dev/null
+cat ${INSTALL_WORK}/_tmp1 >> ${install_work}/$CSHRC
+
+# 6. Create a _salome.csh file from _salome.sh by replacing export by setenv, exporta by setenva, etc.
+sed -e 's%export \([[:alnum:]_[:blank:]]*\)\=%setenv \1 %g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
+sed -e 's%exporta \([[:alnum:]_[:blank:]]*\)%setenva \1%g' ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
+sed -e 's%exportp \([[:alnum:]_[:blank:]]*\)%setenvp \1%g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
+sed -e 's%if \[ -n "\${PYTHONPATH}" \] ; then%if ( ${?PYTHONPATH} ) then%g' ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
+sed -e 's%if \[ -n "\${ENV_FOR_LAUNCH}" \] ; then%if ( ${?ENV_FOR_LAUNCH} ) then%g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
+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
+sed -e 's%^\([[:blank:]]*\)fi\([[:blank:]]*\)$%\1endif\2%g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
+sed -e 's%var.sh%var.csh%g' ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
+sed -e 's%if \[ -e "\${LICENSE_FILE}" \] ; then%if ( -e ${LICENSE_FILE} ) then%g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
+
+cat ${INSTALL_WORK}/_tmp1 >> ${install_work}/_$CSHRC 2>/dev/null
+
+rm -f ${INSTALL_WORK}/_tmp1 ${INSTALL_WORK}/_tmp2
+
+if [ $# -eq 5 ] ; then
+ product_dir=$5
if [ -e ${product_dir} ] ; then
- cp -f ${install_work}/$SHRC ${install_work}/$CSHRC ${product_dir}/.
+ test -e ${product_dir}/$SHRC && mv ${product_dir}/$SHRC ${product_dir}/${SHRC}_`date +%F_%T`
+ cp ${install_work}/_$SHRC ${product_dir}/$SHRC
+ test -e ${product_dir}/$CSHRC && mv ${product_dir}/$CSHRC ${product_dir}/${CSHRC}_`date +%F_%T`
+ cp ${install_work}/_$CSHRC ${product_dir}/$CSHRC
fi
fi
-cp -f ${install_work}/$CSHRC ${install_root}/env_products.csh
-cp -f ${install_work}/$SHRC ${install_root}/env_products.sh
+sed -e 's%setenv ENV_FOR_LAUNCH 1%setenv ENV_FOR_LAUNCH 0%' ${install_work}/_$CSHRC > ${install_root}/env_build.csh
+sed -e 's%export ENV_FOR_LAUNCH=1%export ENV_FOR_LAUNCH=0%' ${install_work}/_$SHRC > ${install_root}/env_build.sh
+
+cp -f ${install_work}/_$CSHRC ${install_root}/env_products.csh
+cp -f ${install_work}/_$SHRC ${install_root}/env_products.sh
+
+rm -f ${install_work}/_$SHRC ${install_work}/_$CSHRC
+### !!! copying build.csh and build.sh scripts
+if [ -e ./build.csh ]; then
+ cp -f ./build.csh ${install_root}
+fi
+if [ -e ./build.sh ]; then
+ cp -f ./build.sh ${install_root}
+fi
+### !!! copying release notes
+for p in `ls ../` ; do
+ export pdf=`echo ${p} | sed s/[.]/" "/g | awk '{print $2}'`
+ if [ "${pdf}" = "pdf" ]; then
+ export RN=$p
+ if [ ! -e ${install_root}/${RN} ]; then
+ cp -f ../${RN} ${install_root}
+ fi
+ fi
+done
+
}
#try use already existing product
try_existing()
{
-product_dir=$1; install_root=$2; install_work=$3; product_sequence="$4"; product_type=$5
+product_dir=$1; install_root=$2; install_work=$3;
+product_sequence="$4"; installed_products="$5"; product_type=$6
env_file=${product_dir}/env_${product_type}.sh
if [ -f ${env_file} ] ; then
- cp -f ${env_file} ${install_work}
- make_env ${install_root} ${install_work} "${product_sequence}"
+ cp -f ${env_file} ${install_work}/_env_${product_type}.sh
+ make_env ${install_root} ${install_work} "${product_sequence}" "${installed_products}"
source ${install_work}/$SHRC
check_version
if [ $? -eq 0 ] ; then
- if [ -d ${product_dir} ] && [ -w ${product_dir} ] ; then
- #makedir ${product_dir}
- print_env
- return 0
- fi
+ return 0
fi
fi
-return 1;
+echo ${product_type} | grep -q '_src$'
+if [ $? -eq 1 ] ; then
+ print_env_bin
+else
+ print_env_src
+fi
+return 0
}
#check existance of lib passed as first parameter
file=$1; shift;
path=$*
for i in `echo ${path} | sed -e"s%:% %g"` ; do
- ret=`find $i -name $file 2>/dev/null`
+ ret=`find $i -name $file -maxdepth 1 2>/dev/null`
if [ -n "$ret" ] ; then
ret=`echo $ret | sed -e"s%/\$file$%%g"`
echo $ret
echo $arg1:$arg2
fi
return $to_tail
-}
\ No newline at end of file
+}
+
+where_gcc(){
+maj_ver=`echo $1 | awk -F. '{if(NF>0) print $1; else print 0}'`
+min_ver=`echo $1 | awk -F. '{if(NF>1) print $2; else print 0}'`
+rel_ver=`echo $1 | awk -F. '{if(NF>2) print $3; else print 0}'`
+let ver=$maj_ver*10000+$min_ver*100+$rel_ver
+newer=""
+newerver=0
+for i in `echo ${PATH}:/usr/bin:/usr/local/bin | sed -e"s%:% %g"` ; do
+ ret=`find $i -name gcc -maxdepth 1 2>/dev/null`
+ if [ -n "$ret" ] ; then
+ maj_ver=`$ret -dumpversion | awk -F. '{if(NF>0) print $1; else print 0}'`
+ min_ver=`$ret -dumpversion | awk -F. '{if(NF>1) print $2; else print 0}'`
+ rel_ver=`$ret -dumpversion | awk -F. '{if(NF>2) print $3; else print 0}'`
+ let ver1=$maj_ver*10000+$min_ver*100+$rel_ver
+ if [ $ver1 -eq $ver ] ; then
+ ret=`echo $ret | sed -e"s%/gcc$%%g"`
+ echo $ret
+ return 0
+ fi
+ if [ $ver1 -gt $ver ] && [ $ver1 -gt $newerver ] ; then
+ let newerver=$ver1
+ newer=`echo $ret | sed -e"s%/gcc$%%g"`
+ fi
+ fi
+done
+if [ -n "$newer" ] ; then
+ echo $newer
+ return 0
+fi
+return 1
+}
+
+where_tcl(){
+if test -z "${TCLHOME}"; then
+ TCLHOME=/usr
+fi
+tclcfg=`find ${TCLHOME}/lib -name "tclConfig.sh" 2> /dev/null`
+file=""
+maxver=0
+for f in $tclcfg; do
+ 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;}'`
+ if [ $maxver -lt $ver ]; then
+ maxver=$ver
+ file=$f
+ fi
+done
+if test -n "$file"; then
+ echo `dirname $file`
+ return 0
+else
+ echo ""
+ return 1
+fi
+}
+
+where_tk(){
+if test -z "${TCLHOME}"; then
+ TCLHOME=/usr
+fi
+tclcfg=`find ${TCLHOME}/lib -name "tkConfig.sh" 2> /dev/null`
+file=""
+maxver=0
+for f in $tclcfg; do
+ 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;}'`
+ if [ $maxver -lt $ver ]; then
+ maxver=$ver
+ file=$f
+ fi
+done
+if test -n "$file"; then
+ echo `dirname $file`
+ return 0
+else
+ echo ""
+ return 1
+fi
+}
+
+where_dps(){
+if test -f /usr/X11R6/include/DPS/dpsconfig.h ; then
+ echo "/usr/X11R6"
+ return 0
+fi
+if test -f /usr/include/DPS/dpsconfig.h ; then
+ echo "/usr"
+ return 0
+fi
+echo ""
+return 1
+}
+
+where_gl_includes(){
+for d in /usr/X11R6/include /usr/include ; do
+ if [ -d ${d}/GL ] && [ -f ${d}/GL/gl.h ] ; then
+ echo "$d"
+ return 0
+ fi
+done
+echo ""
+return 1
+}
+
+where_gl_libs(){
+# search libGL.so* file and correct libGL.la in the same directory
+for d in /usr/X11R6/lib64 /usr/lib64 /usr/X11R6/lib /usr/lib ; do
+ if [ "`ls ${d}/libGL.so* 2>/dev/null`" ] && [ -f ${d}/libGL.la ]; then
+ libdir=`grep "libdir=" ${d}/libGL.la | sed -e "s%libdir='\(.*\)'%\1%" -e "s%/*$%%g"`
+ if [ "$libdir" == "$d" ] ; then
+ echo "$d"
+ return 0
+ fi
+ fi
+done
+# search libGL.la file and check if this file is correct
+for d in /usr/X11R6/lib64 /usr/lib64 /usr/X11R6/lib /usr/lib ; do
+ if [ -f ${d}/libGL.la ] ; then
+ libdir=`grep "libdir=" ${d}/libGL.la | sed -e "s%libdir='\(.*\)'%\1%"`
+ if [ "`ls $libdir/libGL.so* 2>/dev/null`" ] ; then
+ echo "$d"
+ return 0
+ fi
+ fi
+done
+# then search libGL.so* file
+for d in /usr/X11R6/lib64 /usr/lib64 /usr/X11R6/lib /usr/lib ; do
+ if [ "`ls ${d}/libGL.so* 2>/dev/null`" ] ; then
+ echo "$d"
+ return 0
+ fi
+done
+echo ""
+return 1
+}
+
+modif_la_files(){
+ldir=$1
+if [ -z "$ldir" ] || [ ! -d "$ldir" ]; then return 1; fi
+
+srcdir=`pwd`
+
+#SALOME_MODULES="`env | awk -F_ '/[[:alnum:]]*_ROOT_DIR/ { print $1 }'`"
+SALOME_MODULES="`env | awk -F_ '/[a-zA-Z0-9]*_ROOT_DIR/ { print $1 }'`"
+
+cd $ldir
+ldir=`pwd`
+la_files=`find . -name "*.la"`
+
+for l in X ${la_files}; do
+if [ "$l" != "X" ] ; then
+ d=`dirname $l`
+ l=`basename $l`
+ cd $ldir; cd $d
+ # 1. process salome modules dependencies
+
+ for mod in $SALOME_MODULES; do
+ moddir=`printenv ${mod}_ROOT_DIR`
+ if [ -n "${moddir}" ] ; then
+ #echo $l $mod $moddir
+# sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*${mod}[^[:space:]/]*/\(lib\|lib64\)% \1${moddir}/${myldir}%g" $l > $l"_"
+# sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*${mod}[^[:space:]/]*/lib% \1${moddir}/lib%g" $l > $l"_"
+ sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*${mod}[^[:space:]/]*/lib% \1${moddir}/lib%g" \
+ -e "s%^libdir='[^[:space:]]*${mod}[^[:space:]]*/\(lib.*\)'%libdir='${moddir}/\1'%g" $l > $l"_"
+ mv -f $l"_" $l
+# for mod1 in $SALOME_MODULES; do
+# sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*${mod1}[^[:space:]]*/${mod1}_build%%g" $l > $l"_"
+# mv -f $l"_" $l
+# done
+ fi
+ done
+
+ # 2. process CAS.CADE dependencies
+ casdir=`printenv CASROOT`/lib
+ if [ ! -d ${casdir} ] ; then casdir=`printenv CASROOT`/Linux/lib ; fi
+ if [ ! -d ${casdir} ] ; then casdir=`printenv CASROOT`/lin/lib ; fi
+ if [ -n "${CASROOT}" ] && [ -d "${casdir}" ] ; then
+ # echo $l $CASROOT $casdir
+ sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*\(OCT\|CAS\)[^[:space:]/]*/Linux/lib% \1${casdir}%g" \
+ -e "s%[[:space:]]\(-L\)\?[^[:space:]]*\(OCT\|CAS\)[^[:space:]/]*/lin/lib% \1${casdir}%g" \
+ -e "s%[[:space:]]\(-L\)\?[^[:space:]]*\(OCT\|CAS\)[^[:space:]/]*/lib% \1${casdir}%g" $l > $l"_"
+ mv -f $l"_" $l
+ sed -e "s%-L[^[:space:]]*OCCT[^[:space:]]*/Linux/lib%-L${casdir}%g" \
+ -e "s%[^[:space:]]*OCCT[^[:space:]]*/lib/%${casdir}/%g" $l > $l"_"
+ mv -f $l"_" $l
+ fi
+ # 3. process omniORB dependencies
+ omnidir=`printenv OMNIORBDIR`/lib/i586_linux_2.0_glibc2.1
+ if [ ! -d ${omnidir} ] ; then omnidir=`printenv OMNIORBDIR`/lib ; fi
+ if [ -n "${OMNIORBDIR}" ] && [ -d "${omnidir}" ] ; then
+ # echo $l $OMNIORBDIR $omnidir
+ sed -e "s%-L[^[:space:]]*omni[^[:space:]]*%-L${omnidir}%g" \
+ -e "s%-R[^[:space:]]*omni[^[:space:]]*%-R${omnidir}%g" $l > $l"_"
+ mv -f $l"_" $l
+ fi
+ # 4. process VTK dependencies
+ vtkpath=`printenv VTKHOME`
+ if [ `uname -m` = "x86_64" ] && [ -d ${vtkpath}/lib64 ] ; then
+ LIB_PREFIX=64
+ elif [ -d ${vtkpath}/lib ] ; then
+ LIB_PREFIX=""
+ else
+ LIB_PREFIX=64
+ fi
+ vtkldir=${vtkpath}/lib${LIB_PREFIX}
+ vtkdir=${vtkldir}/vtk-5.0
+ if [ -n "${VTKHOME}" ] && [ -d "${vtkdir}" ] && [ -d "${vtkldir}" ] ; then
+ # echo $l $VTKHOME $vtkdir
+ sed -e "s%-L[^[:space:]]*VTK[^[:space:]]*/\(lib\|lib64\)/vtk\-5\.0%-L${vtkdir}%g" \
+ -e "s%-L[^[:space:]]*VTK[^[:space:]]*/\(lib\|lib64\)%-L${vtkldir}%g" $l > $l"_"
+ mv -f $l"_" $l
+ fi
+ # 5. process HDF dependencies
+ hdfdir=`printenv HDF5HOME`/lib
+ if [ -n "${HDF5HOME}" ] && [ -d "${hdfdir}" ] ; then
+ # echo $l $HDF5HOME $hdfdir
+ sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*hdf[^[:space:]/]*/lib% \1${hdfdir}%g" $l > $l"_"
+ mv -f $l"_" $l
+ fi
+ # 6. process MED dependencies
+ meddir=`printenv MED2HOME`/lib
+ if [ -n "${MED2HOME}" ] && [ -d "${meddir}" ] ; then
+ # echo $l $MED2HOME $meddir
+ sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*med[^[:space:]/]*/lib% \1${meddir}%g" $l > $l"_"
+ mv -f $l"_" $l
+ fi
+ # 7. process qwt dependencies
+ qwtdir=`find_in_path libqwt.so ${LD_LIBRARY_PATH}`
+ if [ -n "${qwtdir}" ] && [ -d "${qwtdir}" ] ; then
+ # echo $l $qwtdir
+ sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*qwt[^[:space:]/]*/lib% \1${qwtdir}%g" $l > $l"_"
+ mv -f $l"_" $l
+ fi
+ # 8. process qt dependencies
+ qtdir=`printenv QTDIR`/lib
+ if [ -n "${QTDIR}" ] && [ -d "${qtdir}" ] ; then
+ # echo $l $QTDIR $qtdir
+ sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*qt[^[:space:]/]*/lib% \1${qtdir}%g" $l > $l"_"
+ mv -f $l"_" $l
+ fi
+ # 9. process python dependencies
+ where_python=`which python` # e.g. /usr/bin/python
+ if [ -n "$where_python" ] ; then
+ where_python=`dirname $where_python` # --> /usr/bin
+ where_python=`dirname $where_python` # --> /usr
+ python_version=`python -c "import sys; print sys.version[:3]"`
+ # echo $l $where_python $python_version
+ sed -e "s%-L[^[:space:]]*python[0-9]\.[0-9]\([^[:space:]]*\)%-L${where_python}/lib/python${python_version}\1%g" $l > $l"_"
+ mv -f $l"_" $l
+ fi
+ # 10. process sip dependencies
+ sipdir=`find_in_path sip.so ${LD_LIBRARY_PATH}`
+ if [ -n "${sipdir}" ] && [ -d "${sipdir}" ] ; then
+ # echo $l $sipdir
+ sed -e "s%-L[^[:space:]]*sip[^[:space:]]*%-L${sipdir}%g" $l > $l"_"
+ mv -f $l"_" $l
+ fi
+ # 11. process PyQt dependencies
+ pyqtdir=`find_in_path Qt.so ${LD_LIBRARY_PATH}`
+ if [ -n "${pyqtdir}" ] && [ -d "${pyqtdir}" ] ; then
+ # echo $l $pyqtdir
+ sed -e "s%-L[^[:space:]]*PyQt[^[:space:]]*%-L${pyqtdir}%g" $l > $l"_"
+ mv -f $l"_" $l
+ fi
+ # 12. process tcl/tk dependencies
+ tcldir=`printenv TCLHOME`/lib
+ if [ -n "${tcldir}" ] && [ -d "${tcldir}" ] ; then
+ # echo $l $TCLHOME $tcldir
+ sed -e "s%-L[^[:space:]]*tcltk[^[:space:]]*/lib%-L${tcldir}%g" $l > $l"_"
+ mv -f $l"_" $l
+ fi
+ # 13. process boost dependencies
+ boostdir=`printenv BOOSTDIR`/lib
+ if [ -n "${boostdir}" ] && [ -d "${boostdir}" ] ; then
+ # echo $l $BOOSTDIR $boostdir
+ sed -e "s%-L[^[:space:]]*boost[^[:space:]]*/lib%-L${boostdir}%g" $l > $l"_"
+ mv -f $l"_" $l
+ fi
+
+ blsurfdir=`printenv BLSURFHOME`/lib
+ if [ -n "${blsurfdir}" ] && [ -d "${blsurfdir}" ] ; then
+ # echo $l $BOOSTDIR $boostdir
+ sed -e "s%-L[^[:space:]]*blsurf[^[:space:]]*/lib%-L${blsurfdir}%g" $l > $l"_"
+ mv -f $l"_" $l
+ fi
+
+# # 14. modify libdir
+# #sed -e "s%^libdir='\(.*\)'%libdir='${PRODUCT_DIR}/lib/salome'%g" $l > $l"_"
+# mod=`basename $ldir | awk -F_ '{print $1}'`
+# moddir=`printenv ${mod}_ROOT_DIR`
+# sed -e "s%^libdir='[^[:space:]]*${mod}[^[:space:]]*/\(lib.*\)'%libdir='${moddir}/\1'%g" $l > $l"_"
+# mv -f $l"_" $l
+
+ # 15. process libxml dependencies
+ libxmldir=`printenv LIBXML_DIR`/lib
+ if [ ! -d ${libxmldir} ] ; then libxmldir=`printenv LIBXML_DIR`/lib ; fi
+ sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*libxml2-[0-9]\.[0-9]\.[0-9][0-9]/lib% \1${libxmldir}%g" $l > $l"_"
+ mv -f $l"_" $l
+ sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*libxml2/lib% \1${libxmldir}%g" $l > $l"_"
+ mv -f $l"_" $l
+
+ # 16. process metis dependencies
+ metisdir=`printenv METISDIR`
+ if [ ! -d ${metisdir} ] ; then metisdir=`printenv METISDIR` ; fi
+ sed -e "s%-L[^[:space:]]*metis[^[:space:]]*%-L${metisdir}%g" $l > $l"_"
+ mv -f $l"_" $l
+
+ # 17. process scotch dependencies
+ scotchdir=`printenv SCOTCHDIR`/bin
+ if [ ! -d ${scotchdir} ] ; then scotchdir=`printenv SCOTCHDIR`/bin ; fi
+ sed -e "s%-L[^[:space:]]*scotch[^[:space:]]*/bin%-L${scotchdir}%g" $l > $l"_"
+ mv -f $l"_" $l
+
+ # 18. process libGL.la dependencies
+ if test `uname -m` = "x86_64" ; then
+ libGLpath=/usr/lib64/libGL.la
+ else
+ libGLpath=/usr/lib/libGL.la
+ fi
+ sed -e "s%$libGLpath%""%g" $l > $l"_"
+ mv -f $l"_" $l
+
+ # 19. process graphviz dependencies
+ graphvizdir=`printenv GRAPHVIZHOME`/lib
+ if [ ! -d ${graphvizdir} ] ; then graphvizdir=`printenv GRAPHVIZHOME`/lib ; fi
+ sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*graphviz-[0-9]\.[0-9]\+\.[0-9]/lib% \1${graphvizdir}%g" \
+ -e "s%[[:space:]]\(-L\)\?[^[:space:]]*graphviz/lib% \1${graphvizdir}%g" $l > $l"_"
+ chmod -f --reference=$l $l"_"
+ mv -f $l"_" $l
+
+ # 20. process QScintilla-2.3 dependencies
+ qscintilladir=`printenv QSCINTILLA_DIR`/lib
+ if [ ! -d ${qscintilladir} ] ; then qscintilladir=`printenv QSCINTILLA_DIR`/lib ; fi
+ sed -e "s%[[:space:]]\(-L\)\?[^[:space:]]*QScintilla-[0-9]\.[0-9]\.[0-9]/lib% \1${qscintilladir}%g" $l > $l"_"
+ chmod -f --reference=$l $l"_"
+ mv -f $l"_" $l
+
+fi
+done
+
+cd $srcdir
+return 0
+}