diff mbox series

[RFC,v3,3/3] kvm: selftests: Fix header path when built from parent level with O specified

Message ID 20200326030750.173972-4-xiaoyao.li@intel.com (mailing list archive)
State New
Headers show
Series Fix errors when try to build kvm selftests on specified output | expand

Commit Message

Xiaoyao Li March 26, 2020, 3:07 a.m. UTC
When build kvm selftests in tools/testing/selftests directory with

	make O=/home/lxy/kselftests TARGETS=kvm

it fails building some kvm test binaries due to lack of header files,
e.g.,

  x86_64/vmx_set_nested_state_test.c: In function ‘set_default_vmx_state’:
  x86_64/vmx_set_nested_state_test.c:85:7: error: ‘struct
  kvm_nested_state’ has no member named ‘hdr’
    state->hdr.vmx.vmxon_pa = 0x1000;
  ...

With "O" is specified, it also takes effect on "make headers_install",
which causes no header files generated in "kernel-src/usr".

Fix INSTALL_HDR_PATH with correct path for this case.

Opportunistically fix the case when KBUILD_OUTPUT specified as well,
even though it can work currently.

Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
 tools/testing/selftests/kvm/Makefile | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
index 6a95878b2ab7..bf8f56488914 100644
--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -50,7 +50,11 @@  ifeq (0,$(MAKELEVEL))
 	INSTALL_HDR_PATH := $(top_srcdir)/usr
     endif
 else
+    ifneq ($(O)$(KBUILD_OUTPUT),)
+	INSTALL_HDR_PATH := $(BUILD)/usr
+    else
 	INSTALL_HDR_PATH := $(top_srcdir)/usr
+    endif
 endif
 LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
 LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include