configure 3.1 KB

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