forked from IntelLabs/t2sp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-tool.sh
executable file
·184 lines (163 loc) · 5.64 KB
/
install-tool.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/bin/bash
function show_usage {
echo "Usage:"
echo " ./install-tool.sh m4|gmp|mpfr|mpc|cmake|gcc|llvm-clang|python-packages|cm"
}
# No matter the script is sourced or directly run, BASH_SOURCE is always this script, and $1 is the
# argument to the script
T2S_PATH="$( cd "$(dirname "$BASH_SOURCE" )" >/dev/null 2>&1 ; pwd -P )" # The path to this script
if [ "$1" != "m4" -a "$1" != "gmp" -a "$1" != "mpfr" -a "$1" != "mpc" -a "$1" != "cmake" -a "$1" != "gcc" -a "$1" != "llvm-clang" -a "$1" != "python-packages" -a "$1" != "cm" ]; then
show_usage
if [ $0 == $BASH_SOURCE ]; then
# The script is directly run
exit
else
return
fi
else
component="$1"
fi
function install_cmake {
eval major="$1"
eval minor="$2"
echo Installing cmake ...
mkdir -p cmake-$minor && cd cmake-$minor
wget -c https://cmake.org/files/v$major/cmake-$minor.tar.gz
tar -zxvf cmake-$minor.tar.gz > /dev/null
cd cmake-$minor
mkdir -p build && cd build
../configure --prefix=$T2S_PATH/install > /dev/null
make -j`nproc` > /dev/null
make install > /dev/null
cd ..
cd ..
cd ..
}
function install_m4 {
eval version="$1"
echo Installing m4 ...
wget -c http://ftp.gnu.org/gnu/m4/m4-$version.tar.xz
tar xvf m4-$version.tar.xz > /dev/null
cd m4-$version
./configure --prefix=$T2S_PATH/install > /dev/null
make -j`nproc` > /dev/null
make install > /dev/null
cd ..
}
function install_gmp {
eval version="$1"
echo Installing gmp ...
wget -c https://ftp.gnu.org/gnu/gmp/gmp-$version.tar.xz
tar xvf gmp-$version.tar.xz > /dev/null
cd gmp-$version
./configure --prefix=$T2S_PATH/install > /dev/null
make -j`nproc` > /dev/null
make install > /dev/null
cd ..
}
function install_mpfr {
eval version="$1"
echo Installing mpfr ...
wget -c https://www.mpfr.org/mpfr-current/mpfr-$version.tar.gz
tar xvzf mpfr-$version.tar.gz > /dev/null
cd mpfr-$version
./configure --prefix=$T2S_PATH/install --with-gmp=$T2S_PATH/install > /dev/null
make -j`nproc` > /dev/null
make install > /dev/null
cd ..
}
function install_mpc {
eval version="$1"
echo Installing mpc ...
wget -c https://ftp.gnu.org/gnu/mpc/mpc-$version.tar.gz
tar xvzf mpc-$version.tar.gz > /dev/null
cd mpc-$version
./configure --prefix=$T2S_PATH/install --with-gmp=$T2S_PATH/install --with-mpfr=$T2S_PATH/install > /dev/null
make -j`nproc` > /dev/null
make install > /dev/null
cd ..
}
function install_gcc {
eval version="$1"
echo Installing gcc ...
wget -c http://www.netgull.com/gcc/releases/gcc-$version/gcc-$version.tar.gz
tar xvzf gcc-$version.tar.gz > /dev/null
mkdir -p gcc-$version-build && cd gcc-$version-build
export LD_LIBRARY_PATH=$T2S_PATH/install/lib:$T2S_PATH/install/lib64:$LD_LIBRARY_PATH
../gcc-$version/configure --enable-languages=c,c++ --disable-multilib --disable-libsanitizer --prefix=$T2S_PATH/install/gcc-$version --with-gmp=$T2S_PATH/install --with-mpfr=$T2S_PATH/install --with-mpc=$T2S_PATH/install > /dev/null
make -j`nproc` > /dev/null
make install > /dev/null
cd ..
}
function install_llvm_clang {
eval release="$1"
eval version="$2"
eval gcc_version="$3"
echo Installing llvm and clang ...
git clone -b release_$release https://github.com/llvm-mirror/llvm.git llvm$version
git clone -b release_$release https://github.com/llvm-mirror/clang.git llvm$version/tools/clang
cd llvm$version
mkdir -p build && cd build
export PATH=$T2S_PATH/install/bin:$PATH
export LD_LIBRARY_PATH=$T2S_PATH/install/lib:$T2S_PATH/install/lib64:$LD_LIBRARY_PATH
CXX=$T2S_PATH/install/gcc-$gcc_version/bin/g++ CC=$T2S_PATH/install/gcc-$gcc_version/bin/gcc cmake -DCMAKE_CXX_LINK_FLAGS="-Wl,-rpath,$T2S_PATH/install/gcc-$gcc_version/lib64 -L$T2S_PATH/install/gcc-$gcc_version/lib64" \
-DLLVM_ENABLE_TERMINFO=OFF -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$T2S_PATH/install .. > /dev/null
make -j`nproc` > /dev/null
make install > /dev/null
cd ..
cd ..
}
function install_python-packages {
pip install numpy
pip install matplotlib
}
function install_cm {
wget -c https://github.com/intel/cm-compiler/releases/download/Master/Linux_C_for_Metal_Development_Package_20200119.zip
unzip Linux_C_for_Metal_Development_Package_20200119.zip
cd Linux_C_for_Metal_Development_Package_20200119
chmod +x compiler/bin/cmc
cd drivers/media_driver/release
mkdir extract
dpkg -X intel-media-u18.04-release.deb extract/
cd -
cd drivers/IGC
mkdir extract
dpkg -X intel-igc.deb extract/
cd -
cd ..
cp -rf Linux_C_for_Metal_Development_Package_20200119 $T2S_PATH/install
}
# Below we install newer version of gcc and llvm-clang and their dependencies
mkdir -p $T2S_PATH/install $T2S_PATH/install/bin
export PATH=$T2S_PATH/install/bin:$PATH
cd $T2S_PATH
mkdir -p downloads
cd downloads
if [ "$component" == "m4" ]; then
install_m4 "1.4.18"
fi
if [ "$component" == "gmp" ]; then
install_gmp "6.2.1"
fi
if [ "$component" == "mpfr" ]; then
install_mpfr "4.1.0"
fi
if [ "$component" == "mpc" ]; then
install_mpc "1.2.1"
fi
if [ "$component" == "cmake" ]; then
install_cmake "3.11" "3.11.1"
fi
if [ "$component" == "gcc" ]; then
install_gcc "7.5.0"
fi
if [ "$component" == "llvm-clang" ]; then
install_llvm_clang "90" "9.0" "7.5.0"
fi
if [ "$component" == "python-packages" ]; then
install_python-packages
fi
if [ "$component" == "cm" ]; then
install_cm
fi
cd ..