2
0

riscvbuild.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash -xe
  2. srcdir=gnusrc
  3. dstdir=gnu.riscv.build
  4. prefix="$(pwd)/gnu"
  5. MAKE="${MAKE:-make}"
  6. make_flags="${gnu_makeflags}"
  7. if [ -z "$make_flags" ]; then make_flags="$MAKEFLAGS"; fi
  8. MAKEFLAGS="$make_flags"
  9. export MAKEFLAGS
  10. declare -A xconfig
  11. xconfig['binutils']="$riscv_binutils_configargs"
  12. xconfig['gcc0']="$riscv_gcc_configargs"
  13. xconfig['gcc']="$riscv_gcc_configargs"
  14. xconfig['newlib']="$riscv_newlib_configargs"
  15. declare -A build
  16. build['gcc']=all-gcc
  17. declare -A install
  18. install['gcc']=install-gcc
  19. PATH="$prefix/bin:$PATH"
  20. export PATH
  21. built_something=false
  22. for tool in binutils gcc newlib; do
  23. toolsrc="$srcdir"/"$tool"
  24. tooldst="$dstdir"/"$tool"
  25. mkdir -p "$tooldst"
  26. dsthead=$(cat "$tooldst"/HEAD 2>/dev/null || true)
  27. srchead=$(cd "$toolsrc" && git rev-parse HEAD)
  28. if [ x$dsthead != x$srchead ]; then
  29. cd "$tooldst"
  30. if [ ! -f ./config.status ] ||
  31. [ ./config.status -ot ../../"$toolsrc"/configure ]; then
  32. ../../"$toolsrc"/configure \
  33. $riscv_config ${xconfig[$tool]} \
  34. CFLAGS_FOR_TARGET="$riscv_target_flags" \
  35. CXXFLAGS_FOR_TARGET="$riscv_target_flags"
  36. fi
  37. $MAKE ${build[$tool]}
  38. $MAKE ${install[$tool]:-install}
  39. echo "$srchead" > HEAD
  40. built_something=true
  41. cd ../..
  42. fi
  43. done
  44. # Additional gcc stuff after newlib build
  45. if $built_something; then
  46. tool=gcc
  47. toolsrc="$srcdir"/"$tool"
  48. tooldst="$dstdir"/"$tool"
  49. cd "$tooldst"
  50. $MAKE
  51. $MAKE install
  52. cd ../..
  53. fi