#/usr/bin/env bash set -eu arch=arm while getopts 'a:' OPT; do case "$OPT" in a) arch="$OPTARG" ;; esac done shift "$(($OPTIND - 1))" top="$(pwd)/gem5" system_dir="${top}/gem5-system" binaries_dir="${system_dir}/binaries" disks_dir="${system_dir}/disks" mkdir -p "$binaries_dir" "$disks_dir" cd "${top}/gem5" if [ "$arch" = x86_64 ]; then CC=gcc-6 CXX=g++-6 scons -j"$(nproc)" --ignore-style build/X86/gem5.opt f="${disks_dir}/linux-bigswap2.img" dd if=/dev/zero of="$f" bs=1024 count=65536 mkswap "$f" # This file must always be present, despite --kernel overriding that default and selecting the kernel. # I'm not even joking. No one has ever built x86 gem5 without the magic dist dir present. touch "${binaries_dir}/x86_64-vmlinux-2.6.22.9" elif [ "$arch" = arm ]; then # Compilation fails with gcc 7 on that commit. # There were some recent portability patches, so it will likely get there soon. CC=gcc-6 CXX=g++-6 scons -j"$(nproc)" --ignore-style build/ARM/gem5.opt make -C system/arm/dt make -C system/arm/simple_bootloader make -C system/arm/aarch64_bootloader/ cp ./system/arm/simple_bootloader/boot_emm.arm "$binaries_dir" cp ./system/arm/aarch64_bootloader/boot_emm.arm64 "$binaries_dir" fi # TODO vs telnet? make -C util/term