2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
## Standard rules for building any target-side binaries
|
|
|
|
## with dynamic linkage (dynamic libraries or executables
|
|
|
|
## that link with dynamic libraries)
|
|
|
|
##
|
|
|
|
## Files including this file must define a rule to build
|
|
|
|
## the target $(linked_module).
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
# This constraint means that we can hard-code any $(TARGET_*) variables.
|
|
|
|
ifdef LOCAL_IS_HOST_MODULE
|
|
|
|
$(error This file should not be used to build host binaries. Included by (or near) $(lastword $(filter-out config/%,$(MAKEFILE_LIST))))
|
|
|
|
endif
|
|
|
|
|
|
|
|
# The name of the target file, without any path prepended.
|
2014-03-21 20:27:37 +01:00
|
|
|
# This duplicates logic from base_rules.mk because we need to
|
|
|
|
# know its results before base_rules.mk is included.
|
|
|
|
include $(BUILD_SYSTEM)/configure_module_stem.mk
|
2009-03-04 04:28:42 +01:00
|
|
|
|
|
|
|
# base_rules.make defines $(intermediates), but we need its value
|
|
|
|
# before we include base_rules. Make a guess, and verify that
|
|
|
|
# it's correct once the real value is defined.
|
2014-01-16 21:36:34 +01:00
|
|
|
guessed_intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX))
|
2009-03-04 04:28:42 +01:00
|
|
|
|
|
|
|
# Define the target that is the unmodified output of the linker.
|
|
|
|
# The basename of this target must be the same as the final output
|
|
|
|
# binary name, because it's used to set the "soname" in the binary.
|
|
|
|
# The includer of this file will define a rule to build this target.
|
|
|
|
linked_module := $(guessed_intermediates)/LINKED/$(LOCAL_BUILT_MODULE_STEM)
|
|
|
|
|
|
|
|
ALL_ORIGINAL_DYNAMIC_BINARIES += $(linked_module)
|
|
|
|
|
|
|
|
# Because TARGET_SYMBOL_FILTER_FILE depends on ALL_ORIGINAL_DYNAMIC_BINARIES,
|
|
|
|
# the linked_module rules won't necessarily inherit the PRIVATE_
|
|
|
|
# variables from LOCAL_BUILT_MODULE. This tells binary.make to explicitly
|
|
|
|
# define the PRIVATE_ variables for linked_module as well as for
|
|
|
|
# LOCAL_BUILT_MODULE.
|
|
|
|
LOCAL_INTERMEDIATE_TARGETS := $(linked_module)
|
|
|
|
|
|
|
|
###################################
|
|
|
|
include $(BUILD_SYSTEM)/binary.mk
|
|
|
|
###################################
|
|
|
|
|
2014-01-16 21:36:34 +01:00
|
|
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX)
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
# Make sure that our guess at the value of intermediates was correct.
|
|
|
|
ifneq ($(intermediates),$(guessed_intermediates))
|
|
|
|
$(error Internal error: guessed path '$(guessed_intermediates)' doesn't match '$(intermediates))
|
|
|
|
endif
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Compress
|
|
|
|
###########################################################
|
|
|
|
compress_input := $(linked_module)
|
|
|
|
|
|
|
|
ifeq ($(strip $(LOCAL_COMPRESS_MODULE_SYMBOLS)),)
|
|
|
|
LOCAL_COMPRESS_MODULE_SYMBOLS := $(strip $(TARGET_COMPRESS_MODULE_SYMBOLS))
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(LOCAL_COMPRESS_MODULE_SYMBOLS),true)
|
|
|
|
$(error Symbol compression not yet supported.)
|
|
|
|
compress_output := $(intermediates)/COMPRESSED-$(LOCAL_BUILT_MODULE_STEM)
|
|
|
|
|
2010-06-24 23:02:00 +02:00
|
|
|
#TODO: write the real $(STRIPPER) rule.
|
2009-03-04 04:28:42 +01:00
|
|
|
#TODO: define a rule to build TARGET_SYMBOL_FILTER_FILE, and
|
|
|
|
# make it depend on ALL_ORIGINAL_DYNAMIC_BINARIES.
|
|
|
|
$(compress_output): $(compress_input) $(TARGET_SYMBOL_FILTER_FILE) | $(ACP)
|
|
|
|
@echo "target Compress Symbols: $(PRIVATE_MODULE) ($@)"
|
|
|
|
$(copy-file-to-target)
|
|
|
|
else
|
|
|
|
# Skip this step.
|
|
|
|
compress_output := $(compress_input)
|
|
|
|
endif
|
|
|
|
|
2011-03-14 19:44:57 +01:00
|
|
|
###########################################################
|
|
|
|
## Store a copy with symbols for symbolic debugging
|
|
|
|
###########################################################
|
2013-11-14 02:56:20 +01:00
|
|
|
ifeq ($(LOCAL_UNSTRIPPED_PATH),)
|
2014-01-24 00:09:04 +01:00
|
|
|
my_unstripped_path := $(TARGET_OUT_UNSTRIPPED)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
|
|
|
|
else
|
|
|
|
my_unstripped_path := $(LOCAL_UNSTRIPPED_PATH)
|
2013-11-14 02:56:20 +01:00
|
|
|
endif
|
2011-03-14 19:44:57 +01:00
|
|
|
symbolic_input := $(compress_output)
|
2014-01-24 00:09:04 +01:00
|
|
|
symbolic_output := $(my_unstripped_path)/$(LOCAL_INSTALLED_MODULE_STEM)
|
2011-03-14 19:44:57 +01:00
|
|
|
$(symbolic_output) : $(symbolic_input) | $(ACP)
|
|
|
|
@echo "target Symbolic: $(PRIVATE_MODULE) ($@)"
|
|
|
|
$(copy-file-to-target)
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
|
|
|
|
###########################################################
|
|
|
|
## Strip
|
|
|
|
###########################################################
|
2011-03-14 19:44:57 +01:00
|
|
|
strip_input := $(symbolic_output)
|
2009-03-04 04:28:42 +01:00
|
|
|
strip_output := $(LOCAL_BUILT_MODULE)
|
|
|
|
|
2014-03-16 20:43:49 +01:00
|
|
|
my_strip_module := $(LOCAL_STRIP_MODULE)
|
|
|
|
ifeq ($(my_strip_module),)
|
|
|
|
my_strip_module := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP_MODULE)
|
2009-03-04 04:28:42 +01:00
|
|
|
endif
|
|
|
|
|
2014-03-16 20:43:49 +01:00
|
|
|
ifeq ($(my_strip_module),true)
|
2009-03-04 04:28:42 +01:00
|
|
|
# Strip the binary
|
2014-01-24 00:09:04 +01:00
|
|
|
$(strip_output): PRIVATE_STRIP := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
|
|
|
|
$(strip_output): PRIVATE_OBJCOPY := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY)
|
|
|
|
$(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
|
2009-03-04 04:28:42 +01:00
|
|
|
$(transform-to-stripped)
|
|
|
|
else
|
2014-03-18 22:50:09 +01:00
|
|
|
ifeq ($(my_strip_module),keep_symbols)
|
|
|
|
# Strip only the debug frames, but leave the symbol table.
|
|
|
|
$(strip_output): PRIVATE_STRIP := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
|
|
|
|
$(strip_output): PRIVATE_OBJCOPY := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY)
|
|
|
|
$(strip_output): PRIVATE_READELF := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_READELF)
|
|
|
|
$(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
|
|
|
|
$(transform-to-stripped-keep-symbols)
|
|
|
|
else
|
2009-03-04 04:28:42 +01:00
|
|
|
# Don't strip the binary, just copy it. We can't skip this step
|
|
|
|
# because a copy of the binary must appear at LOCAL_BUILT_MODULE.
|
|
|
|
#
|
|
|
|
# If the binary we're copying is acp or a prerequisite,
|
|
|
|
# use cp(1) instead.
|
|
|
|
ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
|
|
|
|
$(strip_output): $(strip_input) | $(ACP)
|
|
|
|
@echo "target Unstripped: $(PRIVATE_MODULE) ($@)"
|
|
|
|
$(copy-file-to-target)
|
|
|
|
else
|
|
|
|
$(strip_output): $(strip_input)
|
|
|
|
@echo "target Unstripped: $(PRIVATE_MODULE) ($@)"
|
|
|
|
$(copy-file-to-target-with-cp)
|
|
|
|
endif
|
2014-03-18 22:50:09 +01:00
|
|
|
endif
|
2014-03-16 20:43:49 +01:00
|
|
|
endif # my_strip_module
|
2009-03-04 04:28:42 +01:00
|
|
|
|
|
|
|
|
2013-01-28 19:58:01 +01:00
|
|
|
$(cleantarget): PRIVATE_CLEAN_FILES += \
|
|
|
|
$(linked_module) \
|
|
|
|
$(symbolic_output) \
|
|
|
|
$(compress_output)
|