2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# This file determines dependencies of a library from other libraries
|
|
|
|
#
|
|
|
|
# The following variables must be defined by the caller:
|
|
|
|
#
|
|
|
|
# VERBOSE - controls the make verboseness
|
|
|
|
# VERBOSE_DIR - verboseness of directory change messages
|
|
|
|
# VERBOSE_MK - verboseness of make calls
|
|
|
|
# REPOSITORIES - source code repositories to use
|
|
|
|
# BASE_DIR - base directory of build system repository
|
|
|
|
# TARGET_DIR - target build directory
|
|
|
|
# BUILD_BASE_DIR - build directory with build config
|
|
|
|
# LIB_CACHE_DIR - destination directory for object files
|
|
|
|
# LIB_PROGRESS_LOG - library build log file
|
|
|
|
# BUILD_LIBS - list of libraries to build (without .lib.a or .lib.so suffix)
|
|
|
|
# INSTALL_DIR - destination directory for installing shared libraries
|
2017-04-05 14:51:47 +00:00
|
|
|
# DEBUG_DIR - destination directory for installing unstripped shared libraries
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
|
2016-02-04 11:20:03 +00:00
|
|
|
ACCUMULATE_MISSING_PORTS = 1
|
|
|
|
|
2012-03-06 14:16:22 +00:00
|
|
|
#
|
2014-05-08 14:42:38 +00:00
|
|
|
# Include common utility functions
|
2012-03-06 14:16:22 +00:00
|
|
|
#
|
2014-05-08 14:42:38 +00:00
|
|
|
include $(BASE_DIR)/mk/util.inc
|
2012-03-06 14:16:22 +00:00
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# Generate dependencies only for those libs that are
|
|
|
|
# not already contained in the library build log
|
|
|
|
#
|
|
|
|
include $(LIB_PROGRESS_LOG)
|
|
|
|
ifneq ($(filter $(LIB),$(LIBS_READY)),)
|
|
|
|
already_visited:
|
|
|
|
@true
|
|
|
|
else
|
|
|
|
all: append_lib_to_progress_log
|
|
|
|
endif
|
|
|
|
|
|
|
|
append_lib_to_progress_log:
|
|
|
|
@echo "LIBS_READY += $(LIB)" >> $(LIB_PROGRESS_LOG)
|
|
|
|
|
2022-01-07 12:39:45 +00:00
|
|
|
|
2016-12-29 17:27:45 +00:00
|
|
|
LIB_MK_DIRS = $(foreach REP,$(REPOSITORIES),$(addprefix $(REP)/lib/mk/spec/, $(SPECS)) $(REP)/lib/mk)
|
|
|
|
SYMBOLS_DIRS = $(foreach REP,$(REPOSITORIES),$(addprefix $(REP)/lib/symbols/spec/,$(SPECS)) $(REP)/lib/symbols)
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Of all possible file locations, use the (first) one that actually exist.
|
|
|
|
#
|
2016-12-29 17:27:45 +00:00
|
|
|
LIB_MK = $(firstword $(wildcard $(addsuffix /$(LIB).mk,$(LIB_MK_DIRS))))
|
|
|
|
SYMBOLS = $(firstword $(wildcard $(addsuffix /$(LIB), $(SYMBOLS_DIRS))))
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2017-03-15 18:02:38 +00:00
|
|
|
ifneq ($(SYMBOLS),)
|
|
|
|
SHARED_LIB := yes
|
|
|
|
endif
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
2017-03-15 18:02:38 +00:00
|
|
|
# Sanity check to detect missing library-description file
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
2017-03-15 18:02:38 +00:00
|
|
|
ifeq ($(sort $(LIB_MK) $(SYMBOLS)),)
|
2011-12-22 15:19:25 +00:00
|
|
|
all: warn_missing_lib_mk
|
|
|
|
else
|
|
|
|
all: check_unsatisfied_requirements
|
|
|
|
endif
|
|
|
|
|
|
|
|
warn_missing_lib_mk: generate_lib_rule_for_defect_library
|
|
|
|
@$(ECHO) "Library-description file $(DARK_COL)$(LIB).mk$(DEFAULT_COL) is missing"
|
|
|
|
|
|
|
|
#
|
|
|
|
# Determine the repository base directory from the absolute pathname
|
|
|
|
# of the choosen libname.mk file. We need to specify the override
|
|
|
|
# command because REP_DIR was first set by prg.mk when building a
|
|
|
|
# program target. The repository of a library could be a different
|
|
|
|
# one.
|
|
|
|
#
|
|
|
|
# Finally, we strip the trailing slash from the path. The slash was
|
|
|
|
# used to match the whole directory in 'findstring'.
|
|
|
|
#
|
|
|
|
override REP_DIR := $(firstword $(foreach REP,$(REPOSITORIES),$(findstring $(REP)/,$(LIB_MK))))
|
|
|
|
override REP_DIR := $(REP_DIR:/=)
|
|
|
|
|
|
|
|
include $(BASE_DIR)/mk/base-libs.mk
|
2014-01-08 14:01:26 +00:00
|
|
|
include $(LIB_MK)
|
|
|
|
|
|
|
|
ifdef SHARED_LIB
|
2022-09-02 13:17:19 +00:00
|
|
|
BUILD_ARTIFACTS ?= $(LIB).lib.so
|
|
|
|
endif
|
2022-01-07 12:39:45 +00:00
|
|
|
|
|
|
|
# record creation of shared library build artifact
|
|
|
|
append_artifact_to_progress_log:
|
2022-09-02 13:17:19 +00:00
|
|
|
@( $(foreach A,$(BUILD_ARTIFACTS),\
|
|
|
|
echo -e "\n# Build artifact $A\n";) true \
|
|
|
|
) >> $(LIB_PROGRESS_LOG)
|
2022-01-07 12:39:45 +00:00
|
|
|
append_lib_to_progress_log: append_artifact_to_progress_log
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2022-09-02 13:17:19 +00:00
|
|
|
ifdef SHARED_LIB
|
|
|
|
LIBS += ldso_so_support
|
|
|
|
endif
|
2022-01-07 12:39:45 +00:00
|
|
|
|
2014-01-08 14:01:26 +00:00
|
|
|
#
|
2016-12-29 17:27:45 +00:00
|
|
|
# Hide archive dependencies of shared libraries from users of the shared
|
|
|
|
# library. Library users examine the 'DEP_A_<lib>' variable to determine
|
|
|
|
# transitive dependencies. For shared libraries, this variable remains
|
|
|
|
# undefined.
|
2014-01-08 14:01:26 +00:00
|
|
|
#
|
2016-12-29 17:27:45 +00:00
|
|
|
ifdef SHARED_LIB
|
2022-02-08 15:14:27 +00:00
|
|
|
DEP_A_VAR_NAME := PRIVATE_DEP_A_$(LIB)
|
|
|
|
DEP_SO_VAR_NAME := PRIVATE_DEP_SO_$(LIB)
|
2011-12-22 15:19:25 +00:00
|
|
|
else
|
2022-02-08 15:14:27 +00:00
|
|
|
DEP_A_VAR_NAME := DEP_A_$(LIB)
|
|
|
|
DEP_SO_VAR_NAME := DEP_SO_$(LIB)
|
2011-12-22 15:19:25 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
#
|
|
|
|
# Check if the requirements of the target are satisfied
|
|
|
|
#
|
|
|
|
UNSATISFIED_REQUIREMENTS = $(filter-out $(SPECS),$(REQUIRES))
|
|
|
|
ifneq ($(UNSATISFIED_REQUIREMENTS),)
|
|
|
|
check_unsatisfied_requirements: warn_unsatisfied_requirements
|
|
|
|
else
|
|
|
|
check_unsatisfied_requirements: generate_lib_rule
|
|
|
|
endif
|
|
|
|
|
|
|
|
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:
|
build: support library builds via lib/<libname>
This patch adds special handling for lib/<libname> arguments to the
build system, which supersedes the former LIB=<libname> mechanism.
Whereas the old mechanism was limited to a single library, the new
convention allows multiple library arguments, similar to regular
targets. The change brings the two immediate benefits.
First, the streamlining of library and target arguments allows for the
building of libraries via the 'build' command of the run tool.
Second, it alleviates the need for pseudo target.mk files for building
shared libraries that have no direct dependencies, in particular VFS
plugins.
Since this change eases the explicit creation of shared libraries
from run scripts, we may reconsider the automatic implicit building
of shared libraries driven by targets. E.g., while developing a Qt
application, a run script could import the Qt libraries from the
depot and combine those with the developed (fresh built) target without
triggering the build of the Qt libraries in the build directory.
When issueing 'make' without arguments, all targets are built. This
patch applies this behavior to libraries as well, thereby removing the
need for the base/src/lib/target.mk pseudo target as used by the CI
tools to build all libraries.
Note that target.mk files located under src/lib/ are no longer
reachable. Therefore, all run scripts that used to trigger the
build of a shared library via a pseudo target must be adapted.
E.g., 'build lib/vfs/tap' must be replaced by 'build lib/vfs_tap'.
With this patch, the LIB=<libname> option is no longer supported.
Fixes #4599
2022-08-31 14:50:07 +00:00
|
|
|
@(echo "INVALID_DEPS += $(LIB)"; \
|
|
|
|
echo "$(LIB).lib:"; \
|
|
|
|
echo "") >> $(LIB_DEP_FILE)
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
LIBS_TO_VISIT = $(filter-out $(LIBS_READY),$(LIBS))
|
|
|
|
|
|
|
|
generate_lib_rule:
|
2016-02-04 11:20:03 +00:00
|
|
|
ifneq ($(DEP_MISSING_PORTS),)
|
|
|
|
@(echo "MISSING_PORTS += $(DEP_MISSING_PORTS)"; \
|
|
|
|
echo "") >> $(LIB_DEP_FILE)
|
2016-12-29 17:27:45 +00:00
|
|
|
endif
|
|
|
|
@for i in $(LIBS_TO_VISIT); do \
|
|
|
|
$(MAKE) $(VERBOSE_DIR) -f $(BASE_DIR)/mk/dep_lib.mk REP_DIR=$(REP_DIR) LIB=$$i; done
|
|
|
|
ifneq ($(LIBS),)
|
2022-02-08 15:14:27 +00:00
|
|
|
@(echo "$(DEP_A_VAR_NAME) = $(foreach l,$(LIBS),\$${ARCHIVE_NAME($l)} \$$(DEP_A_$l))"; \
|
|
|
|
echo "$(DEP_SO_VAR_NAME) = $(foreach l,$(LIBS),\$${SO_NAME($l)} \$$(DEP_SO_$l))"; \
|
2016-12-29 17:27:45 +00:00
|
|
|
echo "") >> $(LIB_DEP_FILE)
|
2016-02-04 11:20:03 +00:00
|
|
|
endif
|
|
|
|
@(echo "$(LIB).lib: check_ports $(addsuffix .lib,$(LIBS))"; \
|
2011-12-22 15:19:25 +00:00
|
|
|
echo " @\$$(MKDIR) -p \$$(LIB_CACHE_DIR)/$(LIB)"; \
|
|
|
|
echo " \$$(VERBOSE_MK)\$$(MAKE) $(VERBOSE_DIR) -C \$$(LIB_CACHE_DIR)/$(LIB) -f \$$(BASE_DIR)/mk/lib.mk \\"; \
|
|
|
|
echo " REP_DIR=$(REP_DIR) \\"; \
|
|
|
|
echo " LIB_MK=$(LIB_MK) \\"; \
|
2016-12-29 17:27:45 +00:00
|
|
|
echo " SYMBOLS=$(SYMBOLS) \\"; \
|
2011-12-22 15:19:25 +00:00
|
|
|
echo " LIB=$(LIB) \\"; \
|
2016-12-29 17:27:45 +00:00
|
|
|
echo " ARCHIVES=\"\$$(sort \$$($(DEP_A_VAR_NAME)))\" \\"; \
|
2022-02-08 15:14:27 +00:00
|
|
|
echo " SHARED_LIBS=\"\$$(sort \$$($(DEP_SO_VAR_NAME)))\" \\"; \
|
2011-12-22 15:19:25 +00:00
|
|
|
echo " BUILD_BASE_DIR=$(BUILD_BASE_DIR) \\"; \
|
|
|
|
echo " SHELL=$(SHELL) \\"; \
|
2017-04-05 14:51:47 +00:00
|
|
|
echo " INSTALL_DIR=\$$(INSTALL_DIR) \\"; \
|
|
|
|
echo " DEBUG_DIR=\$$(DEBUG_DIR)"; \
|
2011-12-22 15:19:25 +00:00
|
|
|
echo "") >> $(LIB_DEP_FILE)
|
|
|
|
ifdef SHARED_LIB
|
2016-12-29 17:27:45 +00:00
|
|
|
@(echo "SO_NAME($(LIB)) := $(LIB).lib.so"; \
|
|
|
|
echo "") >> $(LIB_DEP_FILE)
|
|
|
|
else
|
|
|
|
@(echo "ARCHIVE_NAME($(LIB)) := $(LIB).lib.a"; \
|
2011-12-22 15:19:25 +00:00
|
|
|
echo "") >> $(LIB_DEP_FILE)
|
|
|
|
endif
|
|
|
|
|