mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-13 20:12:26 +00:00
49 lines
1.5 KiB
Plaintext
Executable File
49 lines
1.5 KiB
Plaintext
Executable File
#/usr/bin/env bash
|
|
set -eu
|
|
arch=x86_64
|
|
cross_compile=
|
|
j=
|
|
while getopts a:c:j: OPT; do
|
|
case "$OPT" in
|
|
a)
|
|
arch="$OPTARG"
|
|
;;
|
|
c)
|
|
cross_compile="CROSS_COMPILE=$OPTARG"
|
|
;;
|
|
j)
|
|
j="$OPTARG"
|
|
;;
|
|
esac
|
|
done
|
|
shift "$(($OPTIND - 1))"
|
|
if [ -z "$j" ]; then
|
|
j="$(nproc)"
|
|
fi
|
|
top="$(cd $(dirname "$0") && pwd)"
|
|
system_dir="${top}/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
|
|
scons -j "$j" --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 ] || [ "$arch" = aarch64 ]; then
|
|
scons -j "$j" --ignore-style build/ARM/gem5.opt
|
|
make -C ./system/arm/dt/
|
|
# TODO use the buildroot cross compiler here, and remove the dependencies from configure.
|
|
make -C ./system/arm/simple_bootloader/ $cross_compile
|
|
cp ./system/arm/simple_bootloader/boot_emm.arm "$binaries_dir"
|
|
# TODO cross_compile is ignored because the make does not use CC...
|
|
make -C ./system/arm/aarch64_bootloader/ $cross_compile
|
|
cp ./system/arm/aarch64_bootloader/boot_emm.arm64 "$binaries_dir"
|
|
fi
|
|
# TODO vs telnet?
|
|
make -C util/term
|