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
20LIBVFIO_O := $(patsubst %.c, $(LIBVFIO_OUTPUT)/%.o, $(LIBVFIO_C))20LIBVFIO_O := $(patsubst %.c, $(LIBVFIO_OUTPUT)/%.o, $(LIBVFIO_C))
21 21
22LIBVFIO_O_DIRS := $(shell dirname $(LIBVFIO_O) | uniq)22LIBVFIO_O_DIRS := $(shell dirname $(LIBVFIO_O) | uniq)
23$(shell mkdir -p $(LIBVFIO_O_DIRS))23
24$(LIBVFIO_O_DIRS):
25 mkdir -p $@
24 26
25CFLAGS += -I$(LIBVFIO_SRCDIR)/include27CFLAGS += -I$(LIBVFIO_SRCDIR)/include
26 28
27$(LIBVFIO_O): $(LIBVFIO_OUTPUT)/%.o : $(LIBVFIO_SRCDIR)/%.c29$(LIBVFIO_O): $(LIBVFIO_OUTPUT)/%.o : $(LIBVFIO_SRCDIR)/%.c | $(LIBVFIO_O_DIRS)
28 $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@30 $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
29 31
30EXTRA_CLEAN += $(LIBVFIO_OUTPUT)32EXTRA_CLEAN += $(LIBVFIO_OUTPUT)