vfio: selftests: Ensure libvfio output dirs are always created
Subsystems (4)
David Matlack
maintainerPATCH 1/1 vfio: selftests: Ensure libvfio output dirs are always created
Add an explicit dependency between the output object files and the output directories that need to be created to hold those files. This ensures that the output directories are always created.
Creating the output directories at parse time (current behavior) doesn't support the scenario where someone does "make clean all". The directories will be created during parsing, deleted during "clean" and then not available for the "all" target.
Use an order-only prerequisite for the output directories, rather than a normal prerequisite, to avoid unnecessary recompilations.
---
Cc: Sean Christopherson <[email protected]>
tools/testing/selftests/vfio/lib/libvfio.mk | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/testing/selftests/vfio/lib/libvfio.mk +4 -2
@@ -20,11 +20,13 @@ LIBVFIO_OUTPUT := $(OUTPUT)/libvfio LIBVFIO_O := $(patsubst %.c, $(LIBVFIO_OUTPUT)/%.o, $(LIBVFIO_C)) LIBVFIO_O_DIRS := $(shell dirname $(LIBVFIO_O) | uniq) -$(shell mkdir -p $(LIBVFIO_O_DIRS)) + +$(LIBVFIO_O_DIRS): + mkdir -p $@ CFLAGS += -I$(LIBVFIO_SRCDIR)/include -$(LIBVFIO_O): $(LIBVFIO_OUTPUT)/%.o : $(LIBVFIO_SRCDIR)/%.c +$(LIBVFIO_O): $(LIBVFIO_OUTPUT)/%.o : $(LIBVFIO_SRCDIR)/%.c | $(LIBVFIO_O_DIRS) $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ EXTRA_CLEAN += $(LIBVFIO_OUTPUT)
base-commit: a26b499b757cfc8bbff1088bb1b844639e250893
Signature · 1 line
2.54.0.1136.gdb2ca164c4-goog
Quoted 43 lines · On Thu, 11 Jun 2026 21:39:45 +0000 David Matlack <[email protected]> wrote:
Add an explicit dependency between the output object files and the output directories that need to be created to hold those files. This ensures that the output directories are always created.
Creating the output directories at parse time (current behavior) doesn't support the scenario where someone does "make clean all". The directories will be created during parsing, deleted during "clean" and then not available for the "all" target.
Use an order-only prerequisite for the output directories, rather than a normal prerequisite, to avoid unnecessary recompilations.
Fixes 19faf6fd969c ("vfio: selftests: Add a helper library for VFIO selftests")Reported-by Sashiko <[email protected]>Signed-off-by David Matlack <[email protected]>---
Cc: Sean Christopherson <[email protected]>tools/testing/selftests/vfio/lib/libvfio.mk | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)tools/testing/selftests/vfio/lib/libvfio.mk +4
-2@@ -20,11 +20,13 @@ LIBVFIO_OUTPUT := $(OUTPUT)/libvfio LIBVFIO_O := $(patsubst %.c, $(LIBVFIO_OUTPUT)/%.o, $(LIBVFIO_C)) LIBVFIO_O_DIRS := $(shell dirname $(LIBVFIO_O) | uniq) -$(shell mkdir -p $(LIBVFIO_O_DIRS)) + +$(LIBVFIO_O_DIRS): + mkdir -p $@ CFLAGS += -I$(LIBVFIO_SRCDIR)/include -$(LIBVFIO_O): $(LIBVFIO_OUTPUT)/%.o : $(LIBVFIO_SRCDIR)/%.c +$(LIBVFIO_O): $(LIBVFIO_OUTPUT)/%.o : $(LIBVFIO_SRCDIR)/%.c | $(LIBVFIO_O_DIRS) $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ EXTRA_CLEAN += $(LIBVFIO_OUTPUT)
Quoted 1 line
base-commit:
a26b499b757cfc8bbff1088bb1b844639e250893
Applied to vfio next branch for v7.2. Thanks,
Alex