@@ -116,6 +116,10 @@ ARCH ?= $(SUBARCH)
export KSFT_KHDR_INSTALL_DONE := 1
export BUILD
+ifneq (1,$(DEFAULT_INSTALL_HDR_PATH))
+export INSTALL_HDR_PATH := $(BUILD)/usr
+endif
+
# build and run gpio when output directory is the src dir.
# gpio has dependency on tools/gpio and builds tools/gpio
# objects in the src directory in all cases making the src
@@ -148,7 +152,7 @@ khdr:
ifeq (1,$(DEFAULT_INSTALL_HDR_PATH))
$(MAKE) --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install
else
- $(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$$BUILD/usr \
+ $(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$(INSTALL_HDR_PATH) \
ARCH=$(ARCH) -C $(top_srcdir) headers_install
endif
@@ -44,7 +44,7 @@ TEST_GEN_PROGS_s390x += kvm_create_max_vcpus
TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M))
LIBKVM += $(LIBKVM_$(UNAME_M))
-INSTALL_HDR_PATH = $(top_srcdir)/usr
+INSTALL_HDR_PATH ?= $(top_srcdir)/usr
LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include
LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/x86/include
When build kvm selftests in tools/testing/selftests directory with make O=~/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; kvm's Makefile unconditionally thinks kernel headers are installed in the "kernel-src/usr" with "INSTALL_HDR_PATH = $(top_srcdir)/usr". However, with "O" is specified, it also takes effect on "make headers_install", that causes no header files generated in "kernel-src/usr". Export INSTALL_HDR_PATH when "O" is specified, so that kvm get the right kernel headers by checking if INSTALL_HDR_PATH is defined. Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com> --- tools/testing/selftests/Makefile | 6 +++++- tools/testing/selftests/kvm/Makefile | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-)