From: vsr Date: Wed, 28 Dec 2005 10:59:13 +0000 (+0000) Subject: Improve try_native() function for the gcc X-Git-Tag: V_3_2_0a1_Debian~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2128b540f0f86d9283bdba25c74a3f1f25c23d03;p=tools%2Finstall.git Improve try_native() function for the gcc --- diff --git a/config_files/common.sh b/config_files/common.sh index a89c48e..395a2de 100755 --- a/config_files/common.sh +++ b/config_files/common.sh @@ -391,6 +391,38 @@ fi return $to_tail } +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 diff --git a/config_files/gcc-3.3.5.sh b/config_files/gcc-3.3.5.sh index 3678d1f..23fbcc8 100755 --- a/config_files/gcc-3.3.5.sh +++ b/config_files/gcc-3.3.5.sh @@ -26,19 +26,16 @@ make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" # looks for the native product and collects it's environment (used by make_env()) try_native(){ -gcc_root="`find_in_path gcc ${PATH}`" -if [ -z "${gcc_root}" ] ; then - gcc_root="`find_in_path gcc /usr/bin`" -fi +gcc_root="`where_gcc 3.3.5`" if [ -n "${gcc_root}" ] ; then gcc_root=`cd ${gcc_root}/..; pwd` # get version number: , and # and numbers are checked strickly, but number can be larger than required one # version number is calculated as: *10000+*100+ # e.g. for gcc 3.2 it is equal to 30200, for gcc 3.4.1 - 30401, for gcc 3.3.5 - 30305 - maj_ver=`gcc -dumpversion | awk -F. '{if(NF>0) print $1; else print 0}'` - min_ver=`gcc -dumpversion | awk -F. '{if(NF>1) print $2; else print 0}'` - rel_ver=`gcc -dumpversion | awk -F. '{if(NF>2) print $3; else print 0}'` + maj_ver=`${gcc_root}/bin/gcc -dumpversion | awk -F. '{if(NF>0) print $1; else print 0}'` + min_ver=`${gcc_root}/bin/gcc -dumpversion | awk -F. '{if(NF>1) print $2; else print 0}'` + rel_ver=`${gcc_root}/bin/gcc -dumpversion | awk -F. '{if(NF>2) print $3; else print 0}'` let gcc_ver=$maj_ver*10000+$min_ver*100+$rel_ver if [ $gcc_ver -ge 30305 ] ; then tmp="\${GCC_ROOT}/bin ${gcc_root}/bin \${PATH} ${PATH}";