xref: /DragonOS/user/port/binutils/2.38/build.sh (revision 78bf93f02f84bf5e024ddfb559f040e68ce39ccf)
1# 编译前请先设置参数
2sys_root=$DRAGONOS_SYSROOT
3binutils_path=请填写binutils的路径
4
5# 要安装到的目录
6PREFIX=$HOME/opt/dragonos-host-userspace
7
8
9if [ ! -d ${binutils_path} ]; then
10    echo "Error: ${binutils_path} not found"
11    exit 1
12fi
13
14if [ ! -d ${sys_root} ]; then
15    echo "Error: ${sys_root} not found"
16    exit 1
17fi
18
19
20mkdir -p build-binutils || exit 1
21mkdir -p ${PREFIX} || exit 1
22
23# 安装依赖
24# 注意texinfo和binutils的版本是否匹配
25# 注意gmp/mpc/mpfr和gcc/g++的版本是否匹配
26sudo apt-get install -y \
27    g++ \
28    gcc \
29    make \
30    texinfo \
31    libgmp3-dev \
32    libmpc-dev \
33    libmpfr-dev \
34    flex \
35    wget
36
37cd build-binutils
38${binutils_path}/configure --prefix=${PREFIX} --target=x86_64-dragonos --with-sysroot=${sys_root} --disable-werror || exit 1
39make -j $(nproc) || exit 1
40make install || exit 1
41make clean || exit 1
42rm -rf build-binutils