diff --git a/repos/base/mk/dep_lib.mk b/repos/base/mk/dep_lib.mk index c788b8ff64..0648a8c2db 100644 --- a/repos/base/mk/dep_lib.mk +++ b/repos/base/mk/dep_lib.mk @@ -119,8 +119,9 @@ warn_unsatisfied_requirements: generate_lib_rule_for_defect_library @$(ECHO) "Skip library $(LIB) because it requires $(DARK_COL)$(UNSATISFIED_REQUIREMENTS)$(DEFAULT_COL)" generate_lib_rule_for_defect_library: - @echo "INVALID_DEPS += $(LIB)" >> $(LIB_DEP_FILE) - @echo "" >> $(LIB_DEP_FILE) + @(echo "INVALID_DEPS += $(LIB)"; \ + echo "$(LIB).lib:"; \ + echo "") >> $(LIB_DEP_FILE) LIBS_TO_VISIT = $(filter-out $(LIBS_READY),$(LIBS)) diff --git a/repos/base/src/lib/target.mk b/repos/base/src/lib/target.mk deleted file mode 100644 index c7315d49ca..0000000000 --- a/repos/base/src/lib/target.mk +++ /dev/null @@ -1,33 +0,0 @@ -# -# This is a dummy target description file with the sole purpose of building -# all libraries. -# -TARGET = libs - -# -# Determine all 'lib/mk' sub directories residing within the repositories. -# Use 'wildcard' to handle the case when a repository does not host any -# 'lib/mk' sub directory. -# -LIB_MK_DIRS := $(wildcard $(addsuffix /lib/mk,$(REPOSITORIES))) - -# -# Scan the 'lib/mk' directories of all repositories for library description -# files. -# -ALL_LIB_MK_FILES := $(notdir $(foreach DIR,$(LIB_MK_DIRS),$(shell find $(DIR) -name "*.mk"))) - -# -# Make the pseudo target depend on all libraries, for which an lib.mk file -# exists. Discard the '.mk' suffix and remove duplicates (via 'sort'). -# -LIBS = $(sort $(ALL_LIB_MK_FILES:.mk=)) - -# -# Among all libraries found above, there may be several libraries with -# unsatisfied build requirements. Normally, the build system won't attempt to -# build the target (and its library dependencies) if one or more libraries -# cannot be built. By enabling 'FORCE_BUILD_LIBS', we let the build system -# visit all non-invalid libraries even in the presence of invalid libraries. -# -FORCE_BUILD_LIBS = yes diff --git a/tool/builddir/build.mk b/tool/builddir/build.mk index a0fe37bae2..ed31c74654 100644 --- a/tool/builddir/build.mk +++ b/tool/builddir/build.mk @@ -154,12 +154,35 @@ export LIBGCC_INC_DIR := $(shell dirname `$(CUSTOM_CXX_LIB) -print-libgcc-file-n # # Find out about the target directories to build # -DST_DIRS := $(filter-out clean cleanall again run/%,$(MAKECMDGOALS)) +# Arguments starting with 'run/' and 'lib/' are special. The former triggers +# the execution of a run script. The latter issues the build of a library. +# +DST_DIRS := $(filter-out clean cleanall again run/% lib/%,$(MAKECMDGOALS)) ifeq ($(MAKECMDGOALS),) DST_DIRS := * endif +# +# Detect use of obsoleted LIB= option +# +ifneq ($(LIB),) +$(error the 'LIB=$(LIB)' option is no longer supported, use 'make lib/$(LIB)') +endif + +# +# Determine library targets specified as lib/ at the command line +# +LIBS := $(notdir $(filter lib/%,$(MAKECMDGOALS))) + +ifeq ($(MAKECMDGOALS),) +ALL_LIB_MK_DIRS := $(wildcard \ + $(foreach R,$(REPOSITORIES),\ + $R/lib/mk $(foreach S,$(SPECS),$R/lib/mk/spec/$S))) +ALL_LIB_MK_FILES := $(wildcard $(addsuffix /*.mk,$(ALL_LIB_MK_DIRS))) +LIBS := $(sort $(notdir $(ALL_LIB_MK_FILES:.mk=))) +endif + # # Helper function to check if a needed tool is installed # @@ -187,7 +210,7 @@ endif # # Default rule: build all directories specified as make arguments # -_all $(DST_DIRS): gen_deps_and_build_targets +_all $(DST_DIRS) $(addprefix lib/,$(LIBS)) : gen_deps_and_build_targets @true ## @@ -275,8 +298,15 @@ endif # we would need to spawn one additional shell per target, which would take # 10-20 percent more time. # -traverse_target_dependencies: $(dir $(LIB_DEP_FILE)) init_libdep_file init_progress_log +traverse_dependencies: $(dir $(LIB_DEP_FILE)) init_libdep_file init_progress_log $(VERBOSE_MK) \ + for lib in $(LIBS); do \ + $(MAKE) $(VERBOSE_DIR) -f $(BASE_DIR)/mk/dep_lib.mk \ + REP_DIR=$$rep LIB=$$lib \ + BUILD_BASE_DIR=$(BUILD_BASE_DIR) \ + DARK_COL="$(DARK_COL)" DEFAULT_COL="$(DEFAULT_COL)"; \ + echo "all: $$lib.lib" >> $(LIB_DEP_FILE); \ + done; \ for target in $(TARGETS_TO_VISIT); do \ for rep in $(REPOSITORIES); do \ test -f $$rep/src/$$target || continue; \ @@ -288,29 +318,9 @@ traverse_target_dependencies: $(dir $(LIB_DEP_FILE)) init_libdep_file init_progr 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) \ - DARK_COL="$(DARK_COL)" DEFAULT_COL="$(DEFAULT_COL)"; \ - echo "all: $(LIB).lib" >> $(LIB_DEP_FILE); \ - .PHONY: $(LIB_DEP_FILE) -# -# 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 +$(LIB_DEP_FILE): traverse_dependencies ## diff --git a/tool/run/boot_dir/okl4 b/tool/run/boot_dir/okl4 index 30d60f2620..fd430acafb 100644 --- a/tool/run/boot_dir/okl4 +++ b/tool/run/boot_dir/okl4 @@ -99,7 +99,7 @@ proc core_link_address { } { return "0x03000000" } proc elfweaver {} { - if { ![file exists tool/okl4/elfweaver] } { build LIB=tools } + if { ![file exists tool/okl4/elfweaver] } { build lib/tools } return tool/okl4/elfweaver }