Re: [PATCH] KVM: selftests: Depend on kernel headers when making selftests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/20/23 13:35, Colton Lewis wrote:
Add a makefile dependency for the kernel headers when building KVM
selftests. As the selftests do depend on the kernel headers, needing
to do things such as build selftests for a different architecture
requires rebuilding the headers. That is an extra annoying manual step
that should be handled by make.


It does if you use the kselftest-* targets from the main Makefile:

# Kernel selftest

PHONY += kselftest
kselftest: headers
        $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests

kselftest-%: headers FORCE
        $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*

You can use the following commands to just build what you want to build:
make kselftest-all TARGETS=kvm

I would like to see the above used to make kselftest easier to maintain
and easier to add features.

If you choose to build from the test directory - then you do have
to manually run headers_install.


Signed-off-by: Colton Lewis <coltonlewis@xxxxxxxxxx>
---

This change has been sitting in my local git repo as a stach for a
long time to make it easier to build selftests for multiple
architectures and I just realized I never sent it upstream. I don't
know if this is the best way to accomplish the goal, but it was the
only obvious one I found.

  tools/testing/selftests/kvm/Makefile | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
index 1750f91dd936..857c6f78e4da 100644
--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -221,12 +221,16 @@ LIBKVM_OBJS = $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ) $(LIBKVM_STRING_OBJ)
  EXTRA_CLEAN += $(LIBKVM_OBJS) cscope.*

  x := $(shell mkdir -p $(sort $(dir $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ))))
-$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c
+$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c headers
  	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@

  $(LIBKVM_S_OBJ): $(OUTPUT)/%.o: %.S
  	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@

+PHONY += headers
+headers:
+	$(MAKE) -C $(top_srcdir) headers
+

This will install headers under the repo and doesn't work with out
of tree builds.

thanks,
-- Shuah



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux