2011-12-22 15:19:25 +00:00
|
|
|
#
|
2023-11-20 13:53:05 +00:00
|
|
|
# Determine library dependencies of a program
|
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
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2023-11-20 13:53:05 +00:00
|
|
|
all:
|
|
|
|
@true
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# Include target build instructions to aquire library dependecies
|
|
|
|
#
|
|
|
|
PRG_DIR := $(dir $(TARGET_MK))
|
2023-11-20 13:53:05 +00:00
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
include $(TARGET_MK)
|
|
|
|
|
2023-11-20 13:53:05 +00:00
|
|
|
#
|
|
|
|
# Check if the requirements of the target are satisfied
|
|
|
|
#
|
|
|
|
UNSATISFIED_REQUIREMENTS = $(filter-out $(SPECS),$(REQUIRES))
|
|
|
|
ifneq ($(UNSATISFIED_REQUIREMENTS),)
|
|
|
|
WARNING_SKIP := "Skip library $(LIB) because it requires '$(UNSATISFIED_REQUIREMENTS)'"
|
|
|
|
endif
|
|
|
|
|
2018-11-06 18:46:50 +00:00
|
|
|
#
|
|
|
|
# Add libgcov if coverage is requested
|
|
|
|
#
|
|
|
|
ifeq ($(COVERAGE),yes)
|
|
|
|
LIBS += libgcov
|
|
|
|
endif
|
|
|
|
|
2018-12-05 23:52:22 +00:00
|
|
|
#
|
|
|
|
# Add libraries for undefined behavior sanitizer if requested
|
|
|
|
#
|
|
|
|
ifeq ($(SANITIZE_UNDEFINED),yes)
|
|
|
|
LIBS += libubsan libsanitizer_common
|
|
|
|
endif
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# Include lib-import description files
|
|
|
|
#
|
|
|
|
include $(foreach LIB,$(LIBS),$(call select_from_repositories,lib/import/import-$(LIB).mk))
|
|
|
|
|
|
|
|
#
|
|
|
|
# Add globally defined library supplements
|
|
|
|
#
|
|
|
|
include $(SPEC_FILES)
|
|
|
|
|
2023-11-20 13:53:05 +00:00
|
|
|
#
|
|
|
|
# Evaluate library dependencies for this target
|
|
|
|
#
|
|
|
|
include $(BASE_DIR)/mk/dep.inc
|
|
|
|
|
|
|
|
DEP_A_VAR_NAME := DEP_A_$(TARGET).prg
|
|
|
|
DEP_SO_VAR_NAME := DEP_SO_$(TARGET).prg
|
|
|
|
|
2022-01-07 12:39:45 +00:00
|
|
|
#
|
|
|
|
# Names of build artifacts to appear in the 'progress.log'
|
|
|
|
#
|
|
|
|
BUILD_ARTIFACTS ?= $(TARGET)
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# Determine location of $(TARGET_MK) within 'src/', remove trailing slash
|
|
|
|
#
|
|
|
|
PRG_REL_DIR := $(subst $(REP_DIR)/src/,,$(PRG_DIR))
|
|
|
|
PRG_REL_DIR := $(PRG_REL_DIR:/=)
|
|
|
|
|
|
|
|
ifneq ($(UNSATISFIED_REQUIREMENTS),)
|
2023-11-20 13:53:05 +00:00
|
|
|
WARNING_SKIP := "Skip target $(PRG_REL_DIR) because it requires '$(UNSATISFIED_REQUIREMENTS)'"
|
2011-12-22 15:19:25 +00:00
|
|
|
endif
|
|
|
|
|
2023-11-20 13:53:05 +00:00
|
|
|
all: $(if $(WARNING_SKIP),generate_skip,generate)
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2023-11-20 13:53:05 +00:00
|
|
|
generate_skip:
|
|
|
|
@echo $(WARNING_SKIP)
|
|
|
|
|
|
|
|
generate: $(call deps_for_libs,$(LIBS))
|
|
|
|
@(echo "$(TARGET).prg: check_ports $(addsuffix .lib.a,$(LIBS)) $(addsuffix .abi.so,$(LIBS))"; \
|
|
|
|
echo " \$$(VERBOSE)\$$(call _prepare_prg_step,$(PRG_REL_DIR)/$(TARGET),$(BUILD_ARTIFACTS))"; \
|
2011-12-22 15:19:25 +00:00
|
|
|
echo " \$$(VERBOSE_MK)\$$(MAKE) $(VERBOSE_DIR) -C $(PRG_REL_DIR) -f \$$(BASE_DIR)/mk/prg.mk \\"; \
|
|
|
|
echo " REP_DIR=$(REP_DIR) \\"; \
|
|
|
|
echo " PRG_REL_DIR=$(PRG_REL_DIR) \\"; \
|
|
|
|
echo " BUILD_BASE_DIR=$(BUILD_BASE_DIR) \\"; \
|
2016-12-29 17:27:45 +00:00
|
|
|
echo " ARCHIVES=\"\$$(sort \$$(DEP_A_$(TARGET).prg))\" \\"; \
|
|
|
|
echo " SHARED_LIBS=\"\$$(sort \$$(DEP_SO_$(TARGET).prg))\" \\"; \
|
2011-12-22 15:19:25 +00:00
|
|
|
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)
|
2012-01-24 17:56:35 +00:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2016-12-29 17:27:45 +00:00
|
|
|
@(echo "ifeq (\$$(filter \$$(DEP_A_$(TARGET).prg:.lib.a=) \$$(DEP_SO_$(TARGET).prg:.lib.so=) $(LIBS),\$$(INVALID_DEPS)),)"; \
|
2011-12-22 15:19:25 +00:00
|
|
|
echo "all: $(TARGET).prg"; \
|
|
|
|
echo "endif") >> $(LIB_DEP_FILE)
|
2012-01-24 17:56:35 +00:00
|
|
|
#
|
|
|
|
# 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
|