blob: 6d3d2b5c1872261691aa8169d4a7b547a4e6d5e7 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001###########################################################
2## Standard rules for building any target-side binaries
3## with dynamic linkage (dynamic libraries or executables
4## that link with dynamic libraries)
5##
6## Files including this file must define a rule to build
7## the target $(linked_module).
8###########################################################
9
10# This constraint means that we can hard-code any $(TARGET_*) variables.
11ifdef LOCAL_IS_HOST_MODULE
12$(error This file should not be used to build host binaries. Included by (or near) $(lastword $(filter-out config/%,$(MAKEFILE_LIST))))
13endif
14
The Android Open Source Project88b60792009-03-03 19:28:42 -080015# The name of the target file, without any path prepended.
Eric Fischer7bbec3a2009-03-25 16:12:29 -070016# TODO: This duplicates logic from base_rules.mk because we need to
17# know its results before base_rules.mk is included.
18# Consolidate the duplicates.
Ying Wangfeb75862013-09-24 15:56:11 -070019ifndef LOCAL_MODULE_STEM
Eric Fischer7bbec3a2009-03-25 16:12:29 -070020 LOCAL_MODULE_STEM := $(LOCAL_MODULE)
21endif
Ying Wangfeb75862013-09-24 15:56:11 -070022
23ifndef LOCAL_BUILT_MODULE_STEM
24 LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX)
25endif
26
27ifndef LOCAL_INSTALLED_MODULE_STEM
28 LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX)
29endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080030
31# base_rules.make defines $(intermediates), but we need its value
32# before we include base_rules. Make a guess, and verify that
33# it's correct once the real value is defined.
Ying Wang791fa6a2014-01-16 12:36:34 -080034guessed_intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX))
The Android Open Source Project88b60792009-03-03 19:28:42 -080035
36# Define the target that is the unmodified output of the linker.
37# The basename of this target must be the same as the final output
38# binary name, because it's used to set the "soname" in the binary.
39# The includer of this file will define a rule to build this target.
40linked_module := $(guessed_intermediates)/LINKED/$(LOCAL_BUILT_MODULE_STEM)
41
42ALL_ORIGINAL_DYNAMIC_BINARIES += $(linked_module)
43
44# Because TARGET_SYMBOL_FILTER_FILE depends on ALL_ORIGINAL_DYNAMIC_BINARIES,
45# the linked_module rules won't necessarily inherit the PRIVATE_
46# variables from LOCAL_BUILT_MODULE. This tells binary.make to explicitly
47# define the PRIVATE_ variables for linked_module as well as for
48# LOCAL_BUILT_MODULE.
49LOCAL_INTERMEDIATE_TARGETS := $(linked_module)
50
51###################################
52include $(BUILD_SYSTEM)/binary.mk
53###################################
54
Ying Wang791fa6a2014-01-16 12:36:34 -080055$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX)
56
The Android Open Source Project88b60792009-03-03 19:28:42 -080057# Make sure that our guess at the value of intermediates was correct.
58ifneq ($(intermediates),$(guessed_intermediates))
59$(error Internal error: guessed path '$(guessed_intermediates)' doesn't match '$(intermediates))
60endif
61
62###########################################################
63## Compress
64###########################################################
65compress_input := $(linked_module)
66
67ifeq ($(strip $(LOCAL_COMPRESS_MODULE_SYMBOLS)),)
68 LOCAL_COMPRESS_MODULE_SYMBOLS := $(strip $(TARGET_COMPRESS_MODULE_SYMBOLS))
69endif
70
71ifeq ($(LOCAL_COMPRESS_MODULE_SYMBOLS),true)
72$(error Symbol compression not yet supported.)
73compress_output := $(intermediates)/COMPRESSED-$(LOCAL_BUILT_MODULE_STEM)
74
Bruce Beare45ac4342010-06-24 14:02:00 -070075#TODO: write the real $(STRIPPER) rule.
The Android Open Source Project88b60792009-03-03 19:28:42 -080076#TODO: define a rule to build TARGET_SYMBOL_FILTER_FILE, and
77# make it depend on ALL_ORIGINAL_DYNAMIC_BINARIES.
78$(compress_output): $(compress_input) $(TARGET_SYMBOL_FILTER_FILE) | $(ACP)
79 @echo "target Compress Symbols: $(PRIVATE_MODULE) ($@)"
80 $(copy-file-to-target)
81else
82# Skip this step.
83compress_output := $(compress_input)
84endif
85
Ying Wang374b3252011-03-14 11:44:57 -070086###########################################################
87## Store a copy with symbols for symbolic debugging
88###########################################################
Ying Wang8b1f9e92013-11-13 17:56:20 -080089ifeq ($(LOCAL_UNSTRIPPED_PATH),)
Ying Wange3d06792014-01-23 15:09:04 -080090my_unstripped_path := $(TARGET_OUT_UNSTRIPPED)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
91else
92my_unstripped_path := $(LOCAL_UNSTRIPPED_PATH)
Ying Wang8b1f9e92013-11-13 17:56:20 -080093endif
Ying Wang374b3252011-03-14 11:44:57 -070094symbolic_input := $(compress_output)
Ying Wange3d06792014-01-23 15:09:04 -080095symbolic_output := $(my_unstripped_path)/$(LOCAL_INSTALLED_MODULE_STEM)
Ying Wang374b3252011-03-14 11:44:57 -070096$(symbolic_output) : $(symbolic_input) | $(ACP)
97 @echo "target Symbolic: $(PRIVATE_MODULE) ($@)"
98 $(copy-file-to-target)
99
The Android Open Source Project88b60792009-03-03 19:28:42 -0800100
101###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800102## Strip
103###########################################################
Ying Wang374b3252011-03-14 11:44:57 -0700104strip_input := $(symbolic_output)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800105strip_output := $(LOCAL_BUILT_MODULE)
106
107ifeq ($(strip $(LOCAL_STRIP_MODULE)),)
108 LOCAL_STRIP_MODULE := $(strip $(TARGET_STRIP_MODULE))
109endif
110
111ifeq ($(LOCAL_STRIP_MODULE),true)
112# Strip the binary
Ying Wange3d06792014-01-23 15:09:04 -0800113$(strip_output): PRIVATE_STRIP := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
114$(strip_output): PRIVATE_OBJCOPY := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY)
115$(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800116 $(transform-to-stripped)
117else
118# Don't strip the binary, just copy it. We can't skip this step
119# because a copy of the binary must appear at LOCAL_BUILT_MODULE.
120#
121# If the binary we're copying is acp or a prerequisite,
122# use cp(1) instead.
123ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
124$(strip_output): $(strip_input) | $(ACP)
125 @echo "target Unstripped: $(PRIVATE_MODULE) ($@)"
126 $(copy-file-to-target)
127else
128$(strip_output): $(strip_input)
129 @echo "target Unstripped: $(PRIVATE_MODULE) ($@)"
130 $(copy-file-to-target-with-cp)
131endif
132endif # LOCAL_STRIP_MODULE
133
134
Ying Wangeda6ac22013-01-28 10:58:01 -0800135$(cleantarget): PRIVATE_CLEAN_FILES += \
136 $(linked_module) \
137 $(symbolic_output) \
138 $(compress_output)