build 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/usr/bin/env bash
  2. set -e
  3. arch=x86_64
  4. extra_targets=''
  5. qemu_sdl='--enable-sdl --with-sdlabi=2.0'
  6. j="$(($(nproc) - 2))"
  7. x11=false
  8. v=0
  9. while getopts 'a:e:j:nSt:v' OPT; do
  10. case "$OPT" in
  11. a)
  12. arch="$OPTARG"
  13. ;;
  14. j)
  15. j="$OPTARG"
  16. ;;
  17. S)
  18. qemu_sdl=''
  19. ;;
  20. t)
  21. extra_targets="$extra_args $OPTARG"
  22. ;;
  23. x)
  24. x11=true
  25. ;;
  26. v)
  27. v=1
  28. ;;
  29. esac
  30. done
  31. case "$arch" in
  32. x86_64)
  33. defconfig=qemu_x86_64_defconfig
  34. ;;
  35. arm)
  36. # qemu_arm_vexpress_defconfig required a newer QEMU than 2.0.0 on a Ubuntu host.
  37. # so let's stick to versatile for now.
  38. defconfig=qemu_arm_versatile_defconfig
  39. ;;
  40. arm-gem5)
  41. # qemu_arm_vexpress_defconfig required a newer QEMU than 2.0.0 on a Ubuntu host.
  42. # so let's stick to versatile for now.
  43. defconfig=qemu_arm_versatile_defconfig
  44. ;;
  45. aarch64)
  46. defconfig=qemu_aarch64_virt_defconfig
  47. ;;
  48. mips64)
  49. defconfig=qemu_mips64r6_malta_defconfig
  50. ;;
  51. esac
  52. cd kernel_module
  53. ./make-host.sh -j "$j" clean
  54. cd ../buildroot
  55. for p in $(find '../buildroot_patches/' -maxdepth 1 -name '*.patch' -print); do
  56. patch -N -r - -p 1 <"$p" || :
  57. done
  58. outdir="output.${arch}~"
  59. make O="$outdir" BR2_EXTERNAL="$(pwd)/../kernel_module" "$defconfig"
  60. # TODO Can't get rid of this for now.
  61. # http://stackoverflow.com/questions/44078245/is-it-possible-to-use-config-fragments-with-buildroots-config
  62. cat ../buildroot_config_fragment >> "${outdir}/.config"
  63. if [ "$arch" = 'arm-gem5' ]; then
  64. echo "\
  65. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
  66. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE=../kernel_config_gem5
  67. " >> "${outdir}/.config"
  68. else
  69. echo "\
  70. BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES=../kernel_config_fragment
  71. " >> "${outdir}/.config"
  72. fi
  73. if $x11; then
  74. cat ../buildroot_config_fragment_x11 >> "${outdir}/.config"
  75. fi
  76. make O="$outdir" olddefconfig
  77. # HOST_QEMU_OPTS is a hack that happens to work because the QEMU package luckly uses += at all times.
  78. # It shouldn't be necessary in the first place: https://bugs.busybox.net/show_bug.cgi?id=9936
  79. #
  80. # Even if were an autotools package, there is no general way currently to pass extra configs to it:
  81. # https://stackoverflow.com/questions/44341188/how-to-pass-extra-custom-configure-autotools-options-to-a-buildroot-package/44341225#44341225
  82. time \
  83. env \
  84. -u LD_LIBRARY_PATH \
  85. make \
  86. O="$outdir" \
  87. BR2_JLEVEL="$j" \
  88. HOST_QEMU_OPTS="--enable-debug --extra-cflags='-DDEBUG_PL061=1' --enable-trace-backends=simple $qemu_sdl" \
  89. V="$v" \
  90. kernel_module-rebuild \
  91. $extra_targets \
  92. all \
  93. ;
  94. if [ "$arch" = 'arm-gem5' ]; then
  95. ./build-gem5
  96. fi