]> SALOME platform Git repositories - tools/install.git/blob - config_files/gcc-3.2.sh
Salome HOME
Add improvement (PAL7115):
[tools/install.git] / config_files / gcc-3.2.sh
1 #!/bin/sh
2
3 check_version(){
4 gcc_ver=`gcc -dumpversion`
5 gcc_ver_number=`echo $gcc_ver | cut -d . -f 1`
6 gcc_ver_subnumber=`echo $gcc_ver | cut -d . -f 2`
7 gcc_ver=$(($gcc_ver_number*1000+$gcc_ver_subnumber))
8 #if [ `gcc --version | grep 'gcc (GCC) .*' | cut -b 11-13` == "3.2" ] ;  then 
9 if [ $gcc_ver -eq 3002 ]  ; then
10     return 0
11 fi
12 return 1
13 }
14
15 print_env(){
16 cat > ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh <<EOF 
17 #$DELIM ${PRODUCT_TYPE} $DELIM
18 export GCC_ROOT=\${INSTALL_ROOT}/${PRODUCT}
19 export CXX=\${GCC_ROOT}/bin/g++
20 export CC=\${GCC_ROOT}/bin/gcc
21 export PATH=\${GCC_ROOT}/bin:\${PATH}
22 export LD_LIBRARY_PATH=\${GCC_ROOT}/lib:\${LD_LIBRARY_PATH}
23 ##
24 EOF
25 (test -w ${PRODUCT_DIR} && cp ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh ${PRODUCT_DIR})
26 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}"
27 }
28
29 # looks for the native product and collects it's environment (used by make_env())
30 try_native(){
31 gcc_root="`find_in_path gcc ${PATH}`"
32 if [ -z "${gcc_root}" ] ; then
33     gcc_root="`find_in_path gcc /usr/bin`"
34 fi
35 if [ -n "${gcc_root}" ] ; then
36     gcc_root=`cd ${gcc_root}/..; pwd`
37     gcc_ver=`gcc -dumpversion`
38     gcc_ver_number=`echo $gcc_ver | cut -d . -f 1`
39     gcc_ver_subnumber=`echo $gcc_ver | cut -d . -f 2`
40     gcc_ver=$(($gcc_ver_number*1000+$gcc_ver_subnumber))
41     #if [ "`${gcc_root}/bin/gcc --version | grep 'gcc (GCC) .*' | cut -b 11-13`" = "3.2" ] ; then
42     if [ $gcc_ver -ge 3002 ]  ; then
43         tmp="\${GCC_ROOT}/bin ${gcc_root}/bin \${PATH} ${PATH}";  
44         path=`sort_path ${tmp}`
45         tmp="\${GCC_ROOT}/lib ${gcc_root}/lib \${LD_LIBRARY_PATH} ${LD_LIBRARY_PATH}";  
46         ld_library_path=`sort_path ${tmp}`
47         cat > ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh <<EOF 
48 #$DELIM ${PRODUCT_TYPE} $DELIM
49 export GCC_ROOT=${gcc_root}
50 export CXX=\${GCC_ROOT}/bin/g++
51 export CC=\${GCC_ROOT}/bin/gcc
52 export PATH=${path}
53 export LD_LIBRARY_PATH=${ld_library_path}
54 ##
55 EOF
56         make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}"
57         if [ $gcc_ver -eq 3002 ]  ; then
58             return 0
59         else
60             return 2
61         fi
62    fi
63 fi
64 return 1
65 }
66
67 try_preinstalled(){
68 try_existing ${PRODUCT_DIR} ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE}
69 return $?
70 }
71
72 install_source()
73 {
74 check_version
75 if [ $? == 0 ] ; then
76     echo "It impossible to build gcc-3.2 on your current compiler (gcc-3.2)."
77     echo "Installation aborted."
78     return 1
79 fi
80
81 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE}
82 source ${INSTALL_WORK}/$SHRC
83
84 #check if $LIBRARY_PATH and $GCC_EXEC_PREFIX are set and then remove path to current dir from them
85 if [ -n "$LIBRARY_PATH" ]; then
86 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'`
87 fi
88 if [ -n "$GCC_EXEC_PREFIX" ]; then
89 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'`
90 fi
91
92 check_jb tar xfz ${SOURCE_DIR}/gcc-3.2.tar.gz  -C ${INSTALL_WORK}
93
94 makedir ${PRODUCT_DIR}
95
96 makedir ${PRODUCT_WORK}-build
97 cd ${PRODUCT_WORK}-build
98
99 check_job ${PRODUCT_DIR}/CONFIGURE.LOG ${PRODUCT_WORK}/configure --prefix=${PRODUCT_DIR} --enable-static --enable-shared --enable-threads
100 check_job ${PRODUCT_DIR}/BOOTSTRAP.LOG make bootstrap
101 check_job ${PRODUCT_DIR}/INSTALL.LOG make install
102
103 rm -fr ${PRODUCT_WORK} ${PRODUCT_WORK}-build
104 print_env
105 }
106
107 install_binary()
108 {
109 echo "It impossible to install gcc from binaries, try install from sources."
110 return 1
111 }
112
113 export PROCEDURE=$1;
114 export INSTALL_WORK=$2;
115 export SOURCE_DIR=$3;
116 export INSTALL_ROOT=$4;
117 export PRODUCT_SEQUENCE=$5;
118 if [ $# == 6 ] ; then export PRODUCT_TYPE=$6 ; else export PRODUCT_TYPE="gcc" ; fi
119 export PRODUCT="gcc-3.2"
120 export PRODUCT_DIR=${INSTALL_ROOT}/${PRODUCT}
121 export PRODUCT_WORK=${INSTALL_WORK}/${PRODUCT}
122 source ./common.sh
123 $PROCEDURE