From 3e0b03fc75503d51b52ff4fde1a1b311594ae030 Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Fri, 30 Jun 2017 15:41:33 +0100 Subject: [PATCH] Decent multiarch with make O= --- run | 16 +++++++--------- rungdb | 11 ++++++----- runqemu | 4 ++-- setoutarch | 10 ---------- 4 files changed, 15 insertions(+), 26 deletions(-) delete mode 100755 setoutarch diff --git a/run b/run index adbb299..621a7b9 100755 --- a/run +++ b/run @@ -3,41 +3,39 @@ set -e arch='x86_64' while getopts a: OPT > /dev/null 2>&1; do case "$OPT" in - a) + 'a') arch=$OPTARG ;; esac done case "$arch" in - x86_64) + 'x86_64') defconfig=qemu_x86_64_defconfig ;; - arm) + 'arm') # qemu_arm_vexpress_defconfig required a newer QEMU than 2.0.0 on a Ubuntu host. # so let's stick to versatile for now. defconfig=qemu_arm_versatile_defconfig ;; esac -./setoutarch "$arch" cd buildroot for p in $(find '../buildroot_patches/' -maxdepth 1 -name '*.patch' -print); do patch -N -r - -p 1 <"$p" || : done -make BR2_EXTERNAL="$(pwd)/../kernel_module" "$defconfig" +outdir="output.${arch}~" +make O="$outdir" BR2_EXTERNAL="$(pwd)/../kernel_module" "$defconfig" # TODO Can't get rid of this for now. # http://stackoverflow.com/questions/44078245/is-it-possible-to-use-config-fragments-with-buildroots-config -cat ../buildroot_config_fragment >> .config +cat ../buildroot_config_fragment >> "${outdir}/.config" # HOST_QEMU_OPTS is a hack that happens to work because the QEMU package luckly uses += at all times. # It shouldn't be necessary in the first place: https://bugs.busybox.net/show_bug.cgi?id=9936 # Even if were an autotools package, there is no general way currently to pass extra configs to it: # https://stackoverflow.com/questions/44341188/how-to-pass-extra-custom-configure-autotools-options-to-a-buildroot-package/44341225#44341225 -# -# We might add this later on. -# host-qemu-rebuild \ env \ -u LD_LIBRARY_PATH \ make \ + O="$outdir" \ BR2_JLEVEL="$(($(nproc) - 2))" \ HOST_QEMU_OPTS="--enable-debug --enable-sdl --with-sdlabi=2.0" \ host-qemu-rebuild \ diff --git a/rungdb b/rungdb index 88dbd6e..c85c4ff 100755 --- a/rungdb +++ b/rungdb @@ -21,9 +21,10 @@ else brk="" fi -gdb="$(pwd)/buildroot/output/host/usr/bin/${arch}-linux-gdb" -cd buildroot/output/build/linux-?.*.*/ -if $kgdb; then +buildroot_out_dir="$(pwd)/buildroot/output.${arch}~" +gdb="${buildroot_out_dir}/host/usr/bin/${arch}-linux-gdb" +cd "${buildroot_out_dir}/build"/linux-?.*.*/ +if "$kgdb"; then cmd="$gdb \ -q \ -ex 'add-auto-load-safe-path $(pwd)' \ @@ -32,7 +33,7 @@ if $kgdb; then " else case "$arch" in - x86_64) + 'x86_64') # http://stackoverflow.com/questions/11408041/how-to-debug-the-linux-kernel-with-gdb-and-qemu/33203642#33203642 # http://stackoverflow.com/questions/4943857/linux-kernel-live-debugging-how-its-done-and-what-tools-are-used/42316607#42316607 # http://stackoverflow.com/questions/28607538/how-to-debug-linux-kernel-modules-with-qemu/44095831#44095831 @@ -50,7 +51,7 @@ else -ex 'lx-symbols ../kernel_module-1.0/' " ;; - arm) + 'arm') cmd="$gdb \ -q \ -ex 'add-auto-load-safe-path $(pwd)' \ diff --git a/runqemu b/runqemu index 25b0f2f..63b0982 100755 --- a/runqemu +++ b/runqemu @@ -43,8 +43,7 @@ done shift "$(($OPTIND - 1))" extra_flags="$extra_flags $@" -./setoutarch "$arch" -buildroot_out_dir='./buildroot/output' +buildroot_out_dir="./buildroot/output.${arch}~" images_dir="$buildroot_out_dir/images" qemu_common="\ $debug_qemu \ @@ -62,6 +61,7 @@ case "$arch" in cmd="$qemu_common \ -M pc \ -append 'root=/dev/vda $extra_append' \ + -device edu \ -drive file=${images_dir}/rootfs.ext2,if=virtio,format=raw \ -kernel ${images_dir}/bzImage \ -net nic,model=virtio \ diff --git a/setoutarch b/setoutarch deleted file mode 100755 index a0c0d39..0000000 --- a/setoutarch +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -# Maintain different buildroot/output archs with symlinks. -if [ "$#" -ne 1 ]; then - exit 1 -fi -arch="$1" -dst="output.${arch}~" -src='buildroot/output' -mkdir -p "buildroot/$dst" -ln -fns "$dst" "$src"