-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall_gcc.sh
executable file
·88 lines (74 loc) · 3.47 KB
/
install_gcc.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash
if [ "X$app_dir" == "X" ]; then
. $(dirname $0)/utils.sh $@
fi
function install_lzip {
cd $src_dir
wget http://download.savannah.gnu.org/releases/lzip/lzip-1.22-rc1.tar.gz && tar -zxf lzip-1.22-rc1.tar.gz && cd lzip-1.22-rc1 || exit $?
./configure --prefix=$app_dir && make -j $make_threads && make install || exit $?
cd -
}
function install_gmp {
cd $src_dir
blue_echo '========= installing gmp 6.2.0 ========='
if [ ! -e gmp-6.2.0.tar.lz ]; then wget https://gmplib.org/download/gmp/gmp-6.2.0.tar.lz || wget https://ftp.gnu.org/gnu/gmp/gmp-6.2.0.tar.lz || exit $?; fi
if [ ! -e gmp-6.2.0 ]; then
hash lzip 2>/dev/null || install_lzip
tar -xf gmp-6.2.0.tar.lz || exit $?
fi
cd gmp-6.2.0 && ./configure --prefix=$app_dir && make -j $make_threads && make install || exit $?
}
function install_mpfr {
cd $src_dir
blue_echo '======== installing mpfr 4.1.0 ========='
if [ ! -e mpfr-4.1.0.tar.gz ]; then wget https://www.mpfr.org/mpfr-current/mpfr-4.1.0.tar.gz || exit $?; fi
if [ ! -e mpfr-4.1.0 ]; then tar -xf mpfr-4.1.0.tar.gz || exit $?; fi
cd mpfr-4.1.0 && ./configure --prefix=$app_dir --with-gmp=$app_dir && make -j $make_threads && make install || exit $?
}
function install_mpc {
cd $src_dir
blue_echo '========= installing mpc 1.2.0 ========='
if [ ! -e mpc-1.2.0.tar.gz ]; then wget https://ftp.gnu.org/gnu/mpc/mpc-1.2.0.tar.gz || exit; fi
if [ ! -e mpc-1.2.0 ]; then tar -xf mpc-1.2.0.tar.gz || exit; fi
cd mpc-1.2.0 && ./configure --prefix=$app_dir --with-gmp=$app_dir --with-mpfr=$app_dir && make -j $make_threads && make install || exit $?
}
function install_gcc {
if [ "X$GCC_VERSION" == "X" ]; then
GCC_VERSION=10.2.0
fi
export GCC_HOME=$app_dir/gcc-${GCC_VERSION}
export PATH=$GCC_HOME/bin:$PATH
export CC=$GCC_HOME/bin/gcc
export CXX=$GCC_HOME/bin/g++
export LD_LIBRARY_PATH=$GCC_HOME/lib:$GCC_HOME/lib64:$LD_LIBRARY_PATH
cd $src_dir
blue_echo ======== installing gcc $GCC_VERSION =========
if [ ! -e gcc-$GCC_VERSION.tar.gz ]; then wget https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.gz || exit 1; fi
if [ ! -e gcc-${GCC_VERSION} ]; then tar -xf gcc-${GCC_VERSION}.tar.gz || exit 1; fi
cd gcc-${GCC_VERSION} && CC=/usr/bin/gcc CXX=/usr/bin/g++ ./configure --disable-multilib --prefix=$app_dir/gcc-${GCC_VERSION} --with-gmp=$app_dir --with-mpfr=$app_dir --with-mpc=$app_dir && make -j $make_threads && make install || exit 1
echo export GCC_HOME=$GCC_HOME >> $bashrc
echo export PATH=\$GCC_HOME/bin:\$PATH >> $bashrc
echo export CC=\$GCC_HOME/bin/gcc >> $bashrc
echo export CXX=\$GCC_HOME/bin/g++ >> $bashrc
echo export LD_LIBRARY_PATH=\$GCC_HOME/lib:\$GCC_HOME/lib64:\$LD_LIBRARY_PATH >> $bashrc
}
if hash dpkg 2>/dev/null; then
echo
dpkg -l | grep libgmp || install_gmp
echo
dpkg -l | grep libmpfr || install_mpfr
echo
dpkg -l | grep libmpc || install_mpc
else
bold_echo This script requires dpkg, but not found. Now skipping checking libgmp, libmpfr and libmpc dependency.
fi
echo
if hash gcc 2> /dev/null; then
CURRENT_GCC_VERSION=`gcc --version | grep [0-9]*[.][0-9]*[.][0-9]* -o`
if [ "X$GCC_VERSION" == "X" ]; then return; fi
echo Detected GCC version ${CURRENT_GCC_VERSION}, required ${GCC_VERSION}
version_no=(${CURRENT_GCC_VERSION//./ })
required_version_no=(${GCC_VERSION//./ })
if [[ ${version_no[0]} -eq ${required_version_no[0]} ]] && [[ ${version_no[1]} -eq ${required_version_no[1]} ]]; then return; fi
fi
install_gcc || echo Failed to install GCC