-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathinstall-riscv-2.sh
executable file
·48 lines (36 loc) · 1.37 KB
/
install-riscv-2.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
#!/usr/bin/env bash
# Ubuntu使用下列命令
# sudo apt-get install autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev libglib2.0-dev clang ninja-build
# Fedora/CentOS/RHEL使用下列命令
# sudo yum install autoconf automake python3 libmpc-devel mpfr-devel gmp-devel gawk bison flex texinfo patchutils gcc gcc-c++ zlib-devel expat-devel glib2-devel ninja-build boost
# Arch使用下列命令
# sudo pacman -Syyu autoconf automake curl python3 libmpc mpfr gmp gawk base-devel bison flex texinfo gperf libtool patchutils bc zlib expat ninja boost
# 设置该脚本:在出错时终止脚本运行
set -e
# 进入~目录
cd
rm -rf riscv-temp riscv
# 下载riscv-gnu-toolchain源代码
mkdir riscv-temp
cd riscv-temp
wget https://mirror.iscas.ac.cn/plct/riscv-gnu-toolchain.20220725.tar.bz2
# 校验
echo '73448b2c99cda591fdb5b51fd28bf611 riscv-gnu-toolchain.20220725.tar.bz2' | md5sum -c
if [ $? != 0 ]; then
echo "Download failed! Please run again."
exit 1
fi
# 解压
tar xvf riscv-gnu-toolchain.20220725.tar.bz2
# 新建编译目录
cd riscv-gnu-toolchain
mkdir build
cd build
# 生成配置文件
../configure --prefix=$HOME/riscv
# 进行编译
make build-sim linux -j$(nproc)
cd
# 删除临时文件
rm -rf riscv-temp
echo "Compilation Complete!"