]> SALOME platform Git repositories - tools/install.git/blob - config_files/gcc-3.2.sh
Salome HOME
Fix a problem with *.la files caused by modifications in KERNEL module compilation...
[tools/install.git] / config_files / gcc-3.2.sh
1 #!/bin/sh
2
3 check_version(){
4 # version number is calculated as: <major>*10000+<minor>*100+<release>
5 # e.g. for gcc 3.2 it is equal to 30200, for gcc 3.3.2 - 30202
6 gcc_ver=`gcc -dumpversion | awk -F. '{v1=0;v2=0;v3=0;if(NF>0)v1=$1;if(NF>1)v2=$2;if(NF>2)v3=$3;print v1*10000+v2*100+v3}'`
7 if [ $gcc_ver -eq 30200 ]  ; then
8     return 0
9 fi
10 return 1
11 }
12
13 print_env(){
14 cat > ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh <<EOF 
15 #$DELIM ${PRODUCT_TYPE} $DELIM
16 export GCC_ROOT=\${INSTALL_ROOT}/${PRODUCT}
17 export CXX=\${GCC_ROOT}/bin/g++
18 export CC=\${GCC_ROOT}/bin/gcc
19 export PATH=\${GCC_ROOT}/bin:\${PATH}
20 export LD_LIBRARY_PATH=\${GCC_ROOT}/lib:\${LD_LIBRARY_PATH}
21 ##
22 EOF
23 (test -w ${PRODUCT_DIR} && cp ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh ${PRODUCT_DIR})
24 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}"
25 }
26
27 # looks for the native product and collects it's environment (used by make_env())
28 try_native(){
29 gcc_root="`where_gcc 3.2.0`"
30 if [ -n "${gcc_root}" ] ; then
31     gcc_root=`cd ${gcc_root}/..; pwd`
32     # get version number: <major>, <minor> and <release>
33     # <major> and <minor> numbers are checked strickly, but <release> number can be larger than required one
34     # version number is calculated as: <major>*10000+<minor>*100+<release>
35     # e.g. for gcc 3.2 it is equal to 30200, for gcc 3.3.2 - 30202
36     maj_ver=`${gcc_root}/bin/gcc -dumpversion | awk -F. '{if(NF>0) print $1; else print 0}'`
37     min_ver=`${gcc_root}/bin/gcc -dumpversion | awk -F. '{if(NF>1) print $2; else print 0}'`
38     rel_ver=`${gcc_root}/bin/gcc -dumpversion | awk -F. '{if(NF>2) print $3; else print 0}'`
39     let gcc_ver=$maj_ver*10000+$min_ver*100+$rel_ver
40     if [ $gcc_ver -ge 30200 ]  ; then
41         tmp="\${GCC_ROOT}/bin ${gcc_root}/bin \${PATH} ${PATH}";  
42         path=`sort_path ${tmp}`
43         tmp="\${GCC_ROOT}/lib ${gcc_root}/lib \${LD_LIBRARY_PATH} ${LD_LIBRARY_PATH}";  
44         ld_library_path=`sort_path ${tmp}`
45         cat > ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh <<EOF 
46 #$DELIM ${PRODUCT_TYPE} $DELIM
47 export GCC_ROOT=${gcc_root}
48 export CXX=\${GCC_ROOT}/bin/g++
49 export CC=\${GCC_ROOT}/bin/gcc
50 export PATH=${path}
51 export LD_LIBRARY_PATH=${ld_library_path}
52 ##
53 EOF
54         make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}"
55 #######       THIS COULD BE USED FOR STRICT COMPARISON  ##############################
56 #       if [ $maj_ver -eq 3 ] && [ $min_ver -eq 2 ] && [ $rel_ver -eq 0 ] ;  then 
57 ######################################################################################
58         if [ $maj_ver -eq 3 ] && [ $min_ver -eq 2 ] && [ $rel_ver -ge 0 ] ;  then 
59             return 0
60         else
61             return 2
62         fi
63    fi
64 fi
65 return 1
66 }
67
68 try_preinstalled(){
69 try_existing ${PRODUCT_DIR} ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE}
70 return $?
71 }
72
73 install_source()
74 {
75 check_version
76 if [ $? == 0 ] ; then
77     echo "It impossible to build gcc-3.2 on your current compiler (gcc-3.2)."
78     echo "Installation aborted."
79     return 1
80 fi
81
82 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE}
83 source ${INSTALL_WORK}/$SHRC
84
85 #check if $LIBRARY_PATH and $GCC_EXEC_PREFIX are set and then remove path to current dir from them
86 if [ -n "$LIBRARY_PATH" ]; then
87 export LIBRARY_PATH=`echo $LIBRARY_PATH | sed -e's/^[:\;]*//g' -e's/[:\;]*$//g' -e's/::*/:/g' -e's/;;*/;/g' -e's/[:\;].$//g' -e's/^.[:\;]//g' -e's/[:\;].[:\;]/:/g' -e's/^.$//g'`
88 fi
89 if [ -n "$GCC_EXEC_PREFIX" ]; then
90 export GCC_EXEC_PREFIX=`echo $GCC_EXEC_PREFIX | sed -e's/^[:\;]*//g' -e's/[:\;]*$//g' -e's/::*/:/g' -e's/;;*/;/g' -e's/[:\;].$//g' -e's/^.[:\;]//g' -e's/[:\;].[:\;]/:/g' -e's/^.$//g'`
91 fi
92
93 check_jb tar xfz ${SOURCE_DIR}/gcc-3.2.tar.gz  -C ${INSTALL_WORK}
94
95 makedir ${PRODUCT_DIR}
96
97 makedir ${PRODUCT_WORK}-build
98 cd ${PRODUCT_WORK}-build
99
100 check_job ${PRODUCT_DIR}/CONFIGURE.LOG ${PRODUCT_WORK}/configure --prefix=${PRODUCT_DIR} --enable-static --enable-shared --enable-threads
101 check_job ${PRODUCT_DIR}/BOOTSTRAP.LOG make bootstrap
102 check_job ${PRODUCT_DIR}/INSTALL.LOG make install
103
104 cd ${PRODUCT_DIR}; rm -fr ${PRODUCT_WORK} ${PRODUCT_WORK}-build
105 print_env
106 }
107
108 install_binary()
109 {
110 echo "It impossible to install gcc from binaries, try install from sources."
111 return 1
112 }
113
114 export PROCEDURE=$1;
115 export INSTALL_WORK=$2;
116 export SOURCE_DIR=$3;
117 export INSTALL_ROOT=$4;
118 export PRODUCT_SEQUENCE=$5;
119 if [ $# == 6 ] ; then export PRODUCT_TYPE=$6 ; else export PRODUCT_TYPE="gcc" ; fi
120 export PRODUCT="gcc-3.2"
121 export PRODUCT_DIR=${INSTALL_ROOT}/${PRODUCT}
122 export PRODUCT_WORK=${INSTALL_WORK}/${PRODUCT}
123 source ./common.sh
124 $PROCEDURE