configure 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/usr/bin/env bash
  2. set -e
  3. interactive_pkgs=libsdl2-dev
  4. gem5=false
  5. qemu=true
  6. submodules='buildroot linux'
  7. y=
  8. while getopts gpqt OPT; do
  9. case "$OPT" in
  10. g)
  11. gem5=true
  12. ;;
  13. p)
  14. submodules="$submodules parsec-benchmark/parsec-benchmark"
  15. ;;
  16. q)
  17. qemu=false
  18. ;;
  19. t)
  20. interactive_pkgs=
  21. y='-y'
  22. ;;
  23. esac
  24. done
  25. shift $(($OPTIND - 1))
  26. ## Submodules
  27. if "$qemu"; then
  28. submodules="$submodules qemu"
  29. fi
  30. if "$gem5"; then
  31. submodules="$submodules gem5/gem5"
  32. fi
  33. (
  34. set -e
  35. # Shallow cloning saves a considerable amount of time, specially because of the linux kernel.
  36. # However, git submodules are buggy as usual, and this is the best way I've found to get it done:
  37. # https://stackoverflow.com/questions/2144406/git-shallow-submodules/47374702#47374702
  38. # In particular:
  39. # - `shallow = true` on the submodule has no effect for the non default educational branches of our submodules
  40. # - QEMU's submodules point to commits that are neither under branches nor tags, and so `--shallow-submodules` fails
  41. git submodule update --depth 1 --jobs 4 --init -- $submodules
  42. if "$qemu"; then
  43. cd qemu
  44. git submodule update --init
  45. fi
  46. ) &
  47. wait $! || git submodule update --init -- $submodules
  48. ## apt-get
  49. pkgs="\
  50. automake \
  51. build-essential \
  52. coreutils \
  53. "
  54. if "$gem5"; then
  55. pkgs="$pkgs \
  56. gcc-aarch64-linux-gnu \
  57. gcc-arm-linux-gnueabi \
  58. libgoogle-perftools-dev \
  59. protobuf-compiler \
  60. "
  61. fi
  62. command -v apt-get >/dev/null 2>&1 || {
  63. cat <<EOF
  64. apt-get not found. You're on your own for installing dependencies.
  65. On Ubuntu they are:
  66. $pkgs
  67. EOF
  68. exit 0
  69. }
  70. # Without this started failing in kernel 4.15 with:
  71. # Makefile:932: *** "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel". Stop.
  72. pkgs="$pkgs libelf-dev"
  73. sudo apt-get update $y
  74. # Building SDL for QEMU in Buildroot was rejected upstream because it adds many dependencies:
  75. # https://patchwork.ozlabs.org/patch/770684/
  76. # We are just using the host SDL for now, if it causes too much problems we might remove it.
  77. # libsdl2-dev needs to be installed separatedly from sudo apt-get build-dep qemu
  78. # because Ubuntu 16.04's QEMU uses SDL 1.
  79. sudo apt-get install $y \
  80. $pkgs \
  81. $interactive_pkgs \
  82. ;
  83. if "$qemu"; then
  84. sudo apt-get build-dep $y qemu
  85. fi