configure 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. ## apt-get
  27. pkgs="\
  28. automake \
  29. bc \
  30. build-essential \
  31. coreutils \
  32. cpio \
  33. git \
  34. unzip \
  35. wget \
  36. "
  37. if "$gem5"; then
  38. pkgs="$pkgs \
  39. gcc-aarch64-linux-gnu \
  40. gcc-arm-linux-gnueabi \
  41. libgoogle-perftools-dev \
  42. protobuf-compiler \
  43. python-dev \
  44. scons \
  45. "
  46. fi
  47. command -v apt-get >/dev/null 2>&1 || {
  48. cat <<EOF
  49. apt-get not found. You're on your own for installing dependencies.
  50. On Ubuntu they are:
  51. $pkgs
  52. EOF
  53. exit 0
  54. }
  55. # Without this started failing in kernel 4.15 with:
  56. # Makefile:932: *** "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel". Stop.
  57. pkgs="$pkgs libelf-dev"
  58. # https://stackoverflow.com/questions/20010199/determining-if-a-process-runs-inside-lxc-docker
  59. if [ -f /.dockerenv ]; then
  60. # --jobs is not available in git 2.7.4 from Ubuntu 16.04.
  61. gitjobs=
  62. mysudo=
  63. # https://askubuntu.com/questions/496549/error-you-must-put-some-source-uris-in-your-sources-list
  64. sed -Ei 's/^# deb-src/deb-src/' /etc/apt/sources.list
  65. y=-y
  66. else
  67. gitjobs="--jobs $(nproc)"
  68. mysudo=sudo
  69. fi
  70. $mysudo apt-get update $y
  71. # Building SDL for QEMU in Buildroot was rejected upstream because it adds many dependencies:
  72. # https://patchwork.ozlabs.org/patch/770684/
  73. # We are just using the host SDL for now, if it causes too much problems we might remove it.
  74. # libsdl2-dev needs to be installed separatedly from sudo apt-get build-dep qemu
  75. # because Ubuntu 16.04's QEMU uses SDL 1.
  76. $mysudo apt-get install $y \
  77. $pkgs \
  78. $interactive_pkgs \
  79. ;
  80. if "$qemu"; then
  81. $mysudo apt-get build-dep $y qemu
  82. fi
  83. ## Submodules
  84. if "$qemu"; then
  85. submodules="$submodules qemu"
  86. fi
  87. if "$gem5"; then
  88. submodules="$submodules gem5/gem5"
  89. fi
  90. (
  91. set -e
  92. # Shallow cloning saves a considerable amount of time, specially because of the linux kernel.
  93. # However, git submodules are buggy as usual, and this is the best way I've found to get it done:
  94. # https://stackoverflow.com/questions/2144406/git-shallow-submodules/47374702#47374702
  95. # In particular:
  96. # - `shallow = true` on the submodule has no effect for the non default educational branches of our submodules
  97. # - QEMU's submodules point to commits that are neither under branches nor tags, and so `--shallow-submodules` fails
  98. #
  99. git submodule update --depth 1 $gitjobs --init -- $submodules
  100. if "$qemu"; then
  101. cd qemu
  102. git submodule update --init
  103. fi
  104. ) &
  105. wait $! || git submodule update --init -- $submodules