build.sh 906 B

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