Skip to content

Commit 0c12e6c

Browse files
committed
KVM: selftests: Ensure sysreg-defs.h is generated at the expected path
Building the KVM selftests from the main selftests Makefile (as opposed to the kvm subdirectory) doesn't work as OUTPUT is set, forcing the generated header to spill into the selftests directory. Additionally, relative paths do not work when building outside of the srctree, as the canonical selftests path is replaced with 'kselftest' in the output. Work around both of these issues by explicitly overriding OUTPUT on the submake cmdline. Move the whole fragment below the point lib.mk gets included such that $(abs_objdir) is available. Reviewed-by: Cornelia Huck <[email protected]> Tested-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent b1a39a7 commit 0c12e6c

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

tools/testing/selftests/kvm/Makefile

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ else
1717
ARCH_DIR := $(ARCH)
1818
endif
1919

20-
ifeq ($(ARCH),arm64)
21-
tools_dir := $(top_srcdir)/tools
22-
arm64_tools_dir := $(tools_dir)/arch/arm64/tools/
23-
GEN_HDRS := $(top_srcdir)/tools/arch/arm64/include/generated/
24-
CFLAGS += -I$(GEN_HDRS)
25-
26-
$(GEN_HDRS): $(wildcard $(arm64_tools_dir)/*)
27-
$(MAKE) -C $(arm64_tools_dir) O=$(tools_dir)
28-
endif
29-
3020
LIBKVM += lib/assert.c
3121
LIBKVM += lib/elf.c
3222
LIBKVM += lib/guest_modes.c
@@ -234,6 +224,22 @@ CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
234224
ifeq ($(ARCH),s390)
235225
CFLAGS += -march=z10
236226
endif
227+
ifeq ($(ARCH),arm64)
228+
tools_dir := $(top_srcdir)/tools
229+
arm64_tools_dir := $(tools_dir)/arch/arm64/tools/
230+
231+
ifneq ($(abs_objdir),)
232+
arm64_hdr_outdir := $(abs_objdir)/tools/
233+
else
234+
arm64_hdr_outdir := $(tools_dir)/
235+
endif
236+
237+
GEN_HDRS := $(arm64_hdr_outdir)arch/arm64/include/generated/
238+
CFLAGS += -I$(GEN_HDRS)
239+
240+
$(GEN_HDRS): $(wildcard $(arm64_tools_dir)/*)
241+
$(MAKE) -C $(arm64_tools_dir) OUTPUT=$(arm64_hdr_outdir)
242+
endif
237243

238244
no-pie-option := $(call try-run, echo 'int main(void) { return 0; }' | \
239245
$(CC) -Werror $(CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie)

0 commit comments

Comments
 (0)