From a15a86b02485bbde78163559552784dc42fb38ac Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Tue, 17 May 2016 20:28:44 +0200 Subject: [PATCH] Build-system support for building a single library This patch equips the build system with the feature of building an individual library with its dependencies by specifying the library as 'LIB' argument. E.g., 'make LIB=libc' builds the libc. --- tool/builddir/build.mk | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tool/builddir/build.mk b/tool/builddir/build.mk index 227df29a40..c4e15e38ab 100644 --- a/tool/builddir/build.mk +++ b/tool/builddir/build.mk @@ -195,7 +195,7 @@ endif # we would need to spawn one additional shell per target, which would take # 10-20 percent more time. # -traverse_dependencies: $(dir $(LIB_DEP_FILE)) init_libdep_file init_progress_log +traverse_target_dependencies: $(dir $(LIB_DEP_FILE)) init_libdep_file init_progress_log $(VERBOSE_MK) \ for target in $(TARGETS_TO_VISIT); do \ for rep in $(REPOSITORIES); do \ @@ -209,8 +209,31 @@ traverse_dependencies: $(dir $(LIB_DEP_FILE)) init_libdep_file init_progress_log done; \ done; $$result; +# +# Generate content of libdep file if manually building a single library +# specified via the 'LIB' argument. +# +traverse_lib_dependencies: $(dir $(LIB_DEP_FILE)) init_libdep_file init_progress_log + $(VERBOSE_MK) \ + $(MAKE) $(VERBOSE_DIR) -f $(BASE_DIR)/mk/dep_lib.mk \ + REP_DIR=$$rep LIB=$(LIB) \ + BUILD_BASE_DIR=$(BUILD_BASE_DIR) \ + SHELL=$(SHELL) \ + DARK_COL="$(DARK_COL)" DEFAULT_COL="$(DEFAULT_COL)"; \ + echo "all: $(LIB).lib" >> $(LIB_DEP_FILE); \ + .PHONY: $(LIB_DEP_FILE) -$(LIB_DEP_FILE): traverse_dependencies + +# +# Depending on whether the top-level target is a list of targets or a +# single library, we populate the LIB_DEP_FILE differently. +# +ifeq ($(LIB),) +$(LIB_DEP_FILE): traverse_target_dependencies +else +$(LIB_DEP_FILE): traverse_lib_dependencies +endif + ## ## Second stage: build targets based on the result of the first stage