From: Peter Korsgaard Date: Fri, 6 Feb 2015 12:02:23 +0000 (+0100) Subject: qemu: correct kernel headers check when major numbers differ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=35bf4f3913fe21c5d47b982454b4487b8c71d816;p=buildroot.git qemu: correct kernel headers check when major numbers differ commit f7add51c39 (qemu: add host/target Linux version check) added a version check between the host kernel version and the version of kernel headers used by the toolchain, but the logic would fail unless BOTH major and minor versions were >=, which isn't true for E.G. host kernel = 3.2 and toolchain 2.6.x. Instead calculate a single version number (as major << 8 + minor) and compare that. Signed-off-by: Peter Korsgaard --- diff --git a/package/qemu/qemu.mk b/package/qemu/qemu.mk index 259813ccbd..581f4ee065 100644 --- a/package/qemu/qemu.mk +++ b/package/qemu/qemu.mk @@ -65,12 +65,10 @@ ifneq ($(HOST_QEMU_HOST_SYSTEM_TYPE),Linux) $(error "qemu-user can only be used on Linux hosts") endif -HOST_QEMU_HOST_SYSTEM_VERSION_MAJOR = $(shell uname -r | cut -f1 -d'.') -HOST_QEMU_HOST_SYSTEM_VERSION_MINOR = $(shell uname -r | cut -f2 -d'.') -HOST_QEMU_TARGET_SYSTEM_VERSION_MAJOR = $(shell echo $(BR2_TOOLCHAIN_HEADERS_AT_LEAST) | cut -f1 -d'.') -HOST_QEMU_TARGET_SYSTEM_VERSION_MINOR = $(shell echo $(BR2_TOOLCHAIN_HEADERS_AT_LEAST) | cut -f2 -d'.') -HOST_QEMU_COMPARE_VERSION_MAJOR = $(shell test $(HOST_QEMU_HOST_SYSTEM_VERSION_MAJOR) -ge $(HOST_QEMU_TARGET_SYSTEM_VERSION_MAJOR) && echo OK) -HOST_QEMU_COMPARE_VERSION_MINOR = $(shell test $(HOST_QEMU_HOST_SYSTEM_VERSION_MINOR) -ge $(HOST_QEMU_TARGET_SYSTEM_VERSION_MINOR) && echo OK) +# kernel version as major*256 + minor +HOST_QEMU_HOST_SYSTEM_VERSION = $(shell uname -r | awk -F. '{ print $$1 * 256 + $$2 }') +HOST_QEMU_TARGET_SYSTEM_VERSION = $(shell echo $(BR2_TOOLCHAIN_HEADERS_AT_LEAST) | awk -F. '{ print $$1 * 256 + $$2 }') +HOST_QEMU_COMPARE_VERSION = $(shell test $(HOST_QEMU_HOST_SYSTEM_VERSION) -ge $(HOST_QEMU_TARGET_SYSTEM_VERSION) && echo OK) # # The principle of qemu-user is that it emulates the instructions of @@ -82,7 +80,7 @@ HOST_QEMU_COMPARE_VERSION_MINOR = $(shell test $(HOST_QEMU_HOST_SYSTEM_VERSION_M # built with kernel headers that are older or the same as the kernel # version running on the host machine. # -ifneq ($(HOST_QEMU_COMPARE_VERSION_MAJOR)$(HOST_QEMU_COMPARE_VERSION_MINOR),OKOK) +ifneq ($(HOST_QEMU_COMPARE_VERSION),OK) $(error "Refusing to build qemu-user: target Linux version newer than host's.") endif endif