History

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.

David Matlack committed 5 months ago

Commit 785562e1 parent 4ec5e931 file · +4 −2Browse files

Unified · Split

tools/testing/selftests/vfio/lib/libvfio.mk+4−2
@@ -20,11 +20,13 @@ LIBVFIO_OUTPUT := $(OUTPUT)/libvfio · 19 unmodified lines
2020 LIBVFIO_O := $(patsubst %.c, $(LIBVFIO_OUTPUT)/%.o, $(LIBVFIO_C))
2121
2222 LIBVFIO_O_DIRS := $(shell dirname $(LIBVFIO_O) | uniq)
23−$(shell mkdir -p $(LIBVFIO_O_DIRS))
23+
24+$(LIBVFIO_O_DIRS):
25+ mkdir -p $@
2426
2527 CFLAGS += -I$(LIBVFIO_SRCDIR)/include
2628
27−$(LIBVFIO_O): $(LIBVFIO_OUTPUT)/%.o : $(LIBVFIO_SRCDIR)/%.c
29+$(LIBVFIO_O): $(LIBVFIO_OUTPUT)/%.o : $(LIBVFIO_SRCDIR)/%.c | $(LIBVFIO_O_DIRS)
2830 $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
2931
3032 EXTRA_CLEAN += $(LIBVFIO_OUTPUT)