summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--arch/x86/Makefile9
-rwxr-xr-xarch/x86/tools/qemu.sh (renamed from tools/qemu.sh)19
3 files changed, 23 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index c7a44fbd..45b4f5be 100644
--- a/Makefile
+++ b/Makefile
@@ -233,8 +233,9 @@ ifneq ($(TOOLCHAIN_NAME),)
TOOLCHAIN_PREFIX = $(TOOLCHAIN_NAME)-
endif
-CPP := $(CC) -E
-NM := $(TOOLCHAIN_PREFIX)nm
+CPP := $(CC) -E
+NM := $(TOOLCHAIN_PREFIX)nm
+OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy
CFLAGS ?= -O2 -g
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 4ae88532..e0220f84 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -1,3 +1,12 @@
+define run_qemu_x86
+ $(call xbuild_action,QEMU,$@) \
+ $(SRCDIR)/arch/x86/tools/qemu.sh "$(OBJCOPY)"
+endef
+
+.PHONY: qemu
+qemu: x15
+ $(call run_qemu_x86)
+
ifeq ($(shell uname -m),x86_64)
KCONFIG_DEFCONFIG := amd64_defconfig
else
diff --git a/tools/qemu.sh b/arch/x86/tools/qemu.sh
index 91029b10..c7488792 100755
--- a/tools/qemu.sh
+++ b/arch/x86/tools/qemu.sh
@@ -8,22 +8,25 @@ RAM=1024
# a virtual machine, which causes performance to collapse.
NR_CPUS=4
-# QEMU system emulator
-QEMU_EXE=qemu-system-i386
-QEMU_EXE=qemu-system-x86_64
-# KVM options
-KVM=
-KVM="-enable-kvm -cpu host"
+# Don't change from here unless you know what you're doing
+# QEMU system emulator
+QEMU_EXE=qemu-system-x86_64
-# Don't change from here unless you know what you're doing
+OBJCOPY="$1"
+NATIVE_ARCH=$(uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/)
+if [ "$NATIVE_ARCH" != x86 ]; then
+ KVM=
+elif lsmod | grep -q '^kvm'; then
+ KVM="-enable-kvm -cpu host"
+fi
X15=$PWD/x15
TMPDIR=$(mktemp -d)
-objcopy -O elf32-i386 $X15 $TMPDIR/x15
+$OBJCOPY -O elf32-i386 $X15 $TMPDIR/x15
cd $TMPDIR
$QEMU_EXE $KVM \