From 2a3b6b41796ff3e46e27dfdea0741c43947b9b7b Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Tue, 13 Aug 2019 10:43:39 -0700 Subject: [PATCH] mk/lib: Build subdirs before lib dir The subdirectories of libraries are currently listed as dependencies of the library. If you look at the actual symbols they contain, the opposite is true. For all of the bdevs, event subsystems and other library directories, the subdirectories actually rely on symbols contained in the parent directory. If we want to create the proper inter-library dependencies in SPDK at compile/link time, then we need to respect the order of these symbol dependencies when executing make (e.g. make libspdk_event.so before libspdk_event_bdev.so). Otherwise we create a loop of dependencies in the make system. Change-Id: Idcbb050b2709f575d0cec46b481824d6313612b4 Signed-off-by: Seth Howell Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/465191 Reviewed-by: Jim Harris Reviewed-by: Ben Walker Tested-by: SPDK CI Jenkins --- mk/spdk.lib.mk | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/mk/spdk.lib.mk b/mk/spdk.lib.mk index a9ad7b414..22ada3554 100644 --- a/mk/spdk.lib.mk +++ b/mk/spdk.lib.mk @@ -50,11 +50,24 @@ else LOCAL_SYS_LIBS += -lrt endif +define subdirs_rule +$(1): $(2) + @+$(Q)$(MAKE) -C $(1) S=$S$(S:%=/)$@ $(MAKECMDGOALS) +endef + +$(foreach dir,$(DIRS-y),$(eval $(call subdirs_rule,$(dir),$(DEP)))) + +ifneq ($(DIRS-y),) +BUILD_DEP := $(DIRS-y) +else +BUILD_DEP := $(DEP) +endif + SPDK_DEP_LIBS = $(call spdk_lib_list_to_shared_libs,$(SPDK_DEP_LIBNAMES)) .PHONY: all clean $(DIRS-y) -all: $(DEP) $(DIRS-y) +all: $(BUILD_DEP) @: clean: $(DIRS-y) @@ -76,12 +89,10 @@ ifeq ($(CONFIG_SHARED),y) $(INSTALL_SHARED_LIB) endif -uninstall: +uninstall: $(DIRS-y) $(UNINSTALL_LIB) ifeq ($(CONFIG_SHARED),y) $(UNINSTALL_SHARED_LIB) endif include $(SPDK_ROOT_DIR)/mk/spdk.deps.mk - -include $(SPDK_ROOT_DIR)/mk/spdk.subdirs.mk