diff --git a/base/mk/dep_prg.mk b/base/mk/dep_prg.mk
index f7fc0664a5..3bb5d13f8e 100644
--- a/base/mk/dep_prg.mk
+++ b/base/mk/dep_prg.mk
@@ -73,7 +73,28 @@ endif
 	  echo "") >> $(LIB_DEP_FILE)
 	@for i in $(LIBS_TO_VISIT); do \
 	  $(MAKE) $(VERBOSE_DIR) -f $(BASE_DIR)/mk/dep_lib.mk REP_DIR=$(REP_DIR) LIB=$$i; done
+#
+# Make 'all' depend on the target, which triggers the building of the target
+# and the traversal of the target's library dependencies. But we only do so
+# if the target does not depend on any library with unsatisfied build
+# requirements. In such a case, the target cannot be linked anyway.
+#
 	@(echo ""; \
 	  echo "ifeq (\$$(filter \$$(DEP_$(TARGET).prg:.lib=),\$$(INVALID_DEPS)),)"; \
 	  echo "all: $(TARGET).prg"; \
 	  echo "endif") >> $(LIB_DEP_FILE)
+#
+# Normally, if the target depends on a library, which cannot be built (such
+# libraries get recorded in the 'INVALID_DEPS' variable), we skip the target
+# altogether. In some cases, however, we want to build all non-invalid
+# libraries of a target regardless of whether the final target can be created
+# or not. (i.e., for implementing the mechanism for building all libraries,
+# see 'base/src/lib/target.mk'). This use case is supported via the
+# 'FORCE_BUILD_LIBS' variable. If the 'target.mk' file assigns the value
+# 'yes' to this variable, we build all non-invalid libraries regardless of
+# the validity of the final target.
+#
+ifeq ($(FORCE_BUILD_LIBS),yes)
+	@(echo ""; \
+	  echo "all: \$$(addsuffix .lib,\$$(filter-out \$$(INVALID_DEPS), $(LIBS)))") >> $(LIB_DEP_FILE)
+endif
diff --git a/base/src/lib/target.mk b/base/src/lib/target.mk
new file mode 100644
index 0000000000..c7315d49ca
--- /dev/null
+++ b/base/src/lib/target.mk
@@ -0,0 +1,33 @@
+#
+# 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