From: vsr Date: Tue, 27 Dec 2005 11:43:23 +0000 (+0000) Subject: Improve try_native() function for the gcc X-Git-Tag: V_2_2_7~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=671e4e1cd7f4e39aa4b7d68a44be050465c6deb7;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.2.sh b/config_files/gcc-3.2.sh index 958ba32..3d8b9b4 100755 --- a/config_files/gcc-3.2.sh +++ b/config_files/gcc-3.2.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.2.0`" 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.3.2 - 30202 - 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 30200 ] ; then tmp="\${GCC_ROOT}/bin ${gcc_root}/bin \${PATH} ${PATH}"; diff --git a/config_files/gcc-3.4.sh b/config_files/gcc-3.4.sh index db364ac..eac3103 100755 --- a/config_files/gcc-3.4.sh +++ b/config_files/gcc-3.4.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.4.1`" 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 - 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 30401 ] ; then tmp="\${GCC_ROOT}/bin ${gcc_root}/bin \${PATH} ${PATH}"; @@ -95,4 +92,4 @@ export PRODUCT="gcc-3.4.1" export PRODUCT_DIR=${INSTALL_ROOT}/${PRODUCT} export PRODUCT_WORK=${INSTALL_WORK}/${PRODUCT} source ./common.sh -$PROCEDURE \ No newline at end of file +$PROCEDURE