build 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #/usr/bin/env bash
  2. set -eu
  3. arch=x86_64
  4. cross_compile=
  5. j=
  6. while getopts a:c:j: OPT; do
  7. case "$OPT" in
  8. a)
  9. arch="$OPTARG"
  10. ;;
  11. c)
  12. cross_compile="CROSS_COMPILE=$OPTARG"
  13. ;;
  14. j)
  15. j="$OPTARG"
  16. ;;
  17. esac
  18. done
  19. shift "$(($OPTIND - 1))"
  20. if [ -z "$j" ]; then
  21. j="$(nproc)"
  22. fi
  23. top="$(cd $(dirname "$0") && pwd)"
  24. system_dir="${top}/system"
  25. binaries_dir="${system_dir}/binaries"
  26. disks_dir="${system_dir}/disks"
  27. mkdir -p "$binaries_dir" "$disks_dir"
  28. cd "${top}/gem5"
  29. if [ "$arch" = x86_64 ]; then
  30. scons -j "$j" --ignore-style build/X86/gem5.opt
  31. f="${disks_dir}/linux-bigswap2.img"
  32. dd if=/dev/zero of="$f" bs=1024 count=65536
  33. mkswap "$f"
  34. # This file must always be present, despite --kernel overriding that default and selecting the kernel.
  35. # I'm not even joking. No one has ever built x86 gem5 without the magic dist dir present.
  36. touch "${binaries_dir}/x86_64-vmlinux-2.6.22.9"
  37. elif [ "$arch" = arm ] || [ "$arch" = aarch64 ]; then
  38. scons -j "$j" --ignore-style build/ARM/gem5.opt
  39. make -C ./system/arm/dt/
  40. # TODO use the buildroot cross compiler here, and remove the dependencies from configure.
  41. make -C ./system/arm/simple_bootloader/ $cross_compile
  42. cp ./system/arm/simple_bootloader/boot_emm.arm "$binaries_dir"
  43. # TODO cross_compile is ignored because the make does not use CC...
  44. make -C ./system/arm/aarch64_bootloader/ $cross_compile
  45. cp ./system/arm/aarch64_bootloader/boot_emm.arm64 "$binaries_dir"
  46. fi
  47. # TODO vs telnet?
  48. make -C util/term