2011-12-22 15:19:25 +00:00
|
|
|
#
|
2023-11-20 13:53:05 +00:00
|
|
|
# Determine dependencies of a library from other libraries
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# The following variables must be defined by the caller:
|
|
|
|
#
|
2023-11-20 13:53:05 +00:00
|
|
|
# LIB - library name
|
|
|
|
# REPOSITORIES - repository directories to search for the library
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
|
2016-02-04 11:20:03 +00:00
|
|
|
ACCUMULATE_MISSING_PORTS = 1
|
|
|
|
|
2014-05-08 14:42:38 +00:00
|
|
|
include $(BASE_DIR)/mk/util.inc
|
2012-03-06 14:16:22 +00:00
|
|
|
|
2023-11-20 13:53:05 +00:00
|
|
|
all:
|
2011-12-22 15:19:25 +00:00
|
|
|
@true
|
|
|
|
|
2023-11-20 13:53:05 +00:00
|
|
|
LIB_MK := $(firstword $(wildcard $(addsuffix /$(LIB).mk,\
|
|
|
|
$(foreach REP,$(REPOSITORIES),\
|
|
|
|
$(addprefix $(REP)/lib/mk/spec/,$(SPECS))\
|
|
|
|
$(REP)/lib/mk))))
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# Determine the repository base directory from the absolute pathname
|
2023-11-20 13:53:05 +00:00
|
|
|
# of the chosen libname.mk file. We need to specify the override
|
2011-12-22 15:19:25 +00:00
|
|
|
# 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:/=)
|
|
|
|
|
2014-01-08 14:01:26 +00:00
|
|
|
include $(LIB_MK)
|
|
|
|
|
2023-11-20 13:53:05 +00:00
|
|
|
include $(BASE_DIR)/mk/dep.inc
|
|
|
|
|
|
|
|
ifneq ($(UNSATISFIED_REQUIREMENTS),)
|
|
|
|
WARNING_SKIP := "Skip library $(LIB) because it requires '$(UNSATISFIED_REQUIREMENTS)'"
|
|
|
|
endif
|
|
|
|
|
|
|
|
SYMBOLS := $(call _symbol_file,$(LIB))
|
|
|
|
|
|
|
|
#
|
|
|
|
# Sanity check to detect missing library-description file
|
|
|
|
#
|
|
|
|
ifeq ($(sort $(LIB_MK) $(SYMBOLS)),)
|
|
|
|
WARNING_SKIP := "Library-description file '$(LIB).mk' is missing"
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(SYMBOLS),)
|
|
|
|
SHARED_LIB := yes
|
|
|
|
endif
|
|
|
|
|
2014-01-08 14:01:26 +00:00
|
|
|
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
|
|
|
|
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
|
|
|
|
|
|
|
|
#
|
2023-11-20 13:53:05 +00:00
|
|
|
# Trigger the rule generation for the ABI of this library
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
2023-11-20 13:53:05 +00:00
|
|
|
ifdef SHARED_LIB
|
|
|
|
ifneq ($(SYMBOLS),)
|
|
|
|
generate: generate_abi_dep.$(LIB)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(filter $(LIBS_READY),$(LIB)),)
|
|
|
|
all: $(if $(WARNING_SKIP),generate_skip,generate)
|
2011-12-22 15:19:25 +00:00
|
|
|
endif
|
|
|
|
|
2023-11-20 13:53:05 +00:00
|
|
|
log_progress:
|
|
|
|
@echo "LIBS_READY += $(LIB)" >> $(LIB_PROGRESS_LOG)
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2023-11-20 13:53:05 +00:00
|
|
|
generate_skip:
|
|
|
|
@echo $(WARNING_SKIP)
|
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)"; \
|
2023-11-20 13:53:05 +00:00
|
|
|
echo "$(LIB).lib.a $(LIB).lib.so:"; \
|
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 "") >> $(LIB_DEP_FILE)
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2023-11-20 13:53:05 +00:00
|
|
|
generate: $(call deps_for_libs,$(LIBS))
|
|
|
|
ifdef SHARED_LIB
|
|
|
|
ifeq ($(SYMBOLS),) # if no symbols exist, the shared object is the ABI
|
|
|
|
@(echo "SO_NAME($(LIB)) := $(LIB).lib.so"; \
|
|
|
|
echo "$(LIB).abi.so: $(LIB).lib.so"; \
|
|
|
|
echo "$(LIB).lib.a:"; \
|
|
|
|
echo " @true"; ) >> $(LIB_DEP_FILE)
|
2016-02-04 11:20:03 +00:00
|
|
|
endif
|
2023-11-20 13:53:05 +00:00
|
|
|
@(echo "$(LIB).lib.so: check_ports $(if $(SYMBOLS),$(LIB).abi.so) $(addsuffix .lib.a,$(LIBS)) $(addsuffix .abi.so,$(LIBS))"; \
|
|
|
|
echo " \$$(VERBOSE)\$$(call _prepare_lib_step,\$$@,$(LIB),$(BUILD_ARTIFACTS))"; \
|
|
|
|
echo " \$$(VERBOSE_MK)\$$(MAKE) \$$(VERBOSE_DIR) -C \$$(LIB_CACHE_DIR)/$(LIB) -f \$$(BASE_DIR)/mk/so.mk \\"; \
|
2011-12-22 15:19:25 +00:00
|
|
|
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)
|
2023-11-20 13:53:05 +00:00
|
|
|
else # not SHARED_LIB
|
|
|
|
@(echo "$(LIB).lib.a: check_ports $(addsuffix .lib.a,$(LIBS)) $(addsuffix .abi.so,$(LIBS))"; \
|
|
|
|
echo " \$$(VERBOSE)\$$(call _prepare_lib_step,\$$@,$(LIB),$(BUILD_ARTIFACTS))"; \
|
|
|
|
echo " \$$(VERBOSE_MK)\$$(MAKE) \$$(VERBOSE_DIR) -C \$$(LIB_CACHE_DIR)/$(LIB) -f \$$(BASE_DIR)/mk/a.mk \\"; \
|
|
|
|
echo " REP_DIR=$(REP_DIR) \\"; \
|
|
|
|
echo " LIB_MK=$(LIB_MK) \\"; \
|
|
|
|
echo " LIB=$(LIB) \\"; \
|
|
|
|
echo " ARCHIVES=\"\$$(sort \$$($(DEP_A_VAR_NAME)))\" \\"; \
|
|
|
|
echo " SHARED_LIBS=\"\$$(sort \$$($(DEP_SO_VAR_NAME)))\" \\"; \
|
|
|
|
echo " BUILD_BASE_DIR=$(BUILD_BASE_DIR) \\"; \
|
|
|
|
echo " SHELL=$(SHELL) \\"; \
|
|
|
|
echo " INSTALL_DIR=\$$(INSTALL_DIR) \\"; \
|
|
|
|
echo " DEBUG_DIR=\$$(DEBUG_DIR)"; \
|
|
|
|
echo "$(LIB).lib.so $(LIB).abi.so:"; \
|
|
|
|
echo " @true"; \
|
|
|
|
echo "ARCHIVE_NAME($(LIB)) := $(LIB).lib.a"; \
|
2011-12-22 15:19:25 +00:00
|
|
|
echo "") >> $(LIB_DEP_FILE)
|
|
|
|
endif
|
|
|
|
|