blob: 77784776e6d9e618eeb6e6bb318e1c442f1875fb [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
15LOCAL_UNSTRIPPED_PATH := $(strip $(LOCAL_UNSTRIPPED_PATH))
16ifeq ($(LOCAL_UNSTRIPPED_PATH),)
Ying Wang90ca11a2010-09-03 16:22:47 -070017 ifeq ($(LOCAL_MODULE_PATH),)
18 LOCAL_UNSTRIPPED_PATH := $(TARGET_OUT_$(LOCAL_MODULE_CLASS)_UNSTRIPPED)
19 else
20 # We have to figure out the corresponding unstripped path if LOCAL_MODULE_PATH is customized.
21 LOCAL_UNSTRIPPED_PATH := $(TARGET_OUT_UNSTRIPPED)/$(patsubst $(PRODUCT_OUT)/%,%,$(LOCAL_MODULE_PATH))
22 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080023endif
24
25# The name of the target file, without any path prepended.
Eric Fischer7bbec3a2009-03-25 16:12:29 -070026# TODO: This duplicates logic from base_rules.mk because we need to
27# know its results before base_rules.mk is included.
28# Consolidate the duplicates.
Ying Wang24084792013-09-24 15:56:11 -070029ifndef LOCAL_MODULE_STEM
Eric Fischer7bbec3a2009-03-25 16:12:29 -070030 LOCAL_MODULE_STEM := $(LOCAL_MODULE)
31endif
Ying Wang24084792013-09-24 15:56:11 -070032
33ifndef LOCAL_BUILT_MODULE_STEM
34 LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX)
35endif
36
37ifndef LOCAL_INSTALLED_MODULE_STEM
38 LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX)
39endif
The Android Open Source Project88b60792009-03-03 19:28:42 -080040
41# base_rules.make defines $(intermediates), but we need its value
42# before we include base_rules. Make a guess, and verify that
43# it's correct once the real value is defined.
44guessed_intermediates := $(call local-intermediates-dir)
45
46# Define the target that is the unmodified output of the linker.
47# The basename of this target must be the same as the final output
48# binary name, because it's used to set the "soname" in the binary.
49# The includer of this file will define a rule to build this target.
50linked_module := $(guessed_intermediates)/LINKED/$(LOCAL_BUILT_MODULE_STEM)
51
52ALL_ORIGINAL_DYNAMIC_BINARIES += $(linked_module)
53
54# Because TARGET_SYMBOL_FILTER_FILE depends on ALL_ORIGINAL_DYNAMIC_BINARIES,
55# the linked_module rules won't necessarily inherit the PRIVATE_
56# variables from LOCAL_BUILT_MODULE. This tells binary.make to explicitly
57# define the PRIVATE_ variables for linked_module as well as for
58# LOCAL_BUILT_MODULE.
59LOCAL_INTERMEDIATE_TARGETS := $(linked_module)
60
61###################################
62include $(BUILD_SYSTEM)/binary.mk
63###################################
64
65# Make sure that our guess at the value of intermediates was correct.
66ifneq ($(intermediates),$(guessed_intermediates))
67$(error Internal error: guessed path '$(guessed_intermediates)' doesn't match '$(intermediates))
68endif
69
70###########################################################
71## Compress
72###########################################################
73compress_input := $(linked_module)
74
75ifeq ($(strip $(LOCAL_COMPRESS_MODULE_SYMBOLS)),)
76 LOCAL_COMPRESS_MODULE_SYMBOLS := $(strip $(TARGET_COMPRESS_MODULE_SYMBOLS))
77endif
78
79ifeq ($(LOCAL_COMPRESS_MODULE_SYMBOLS),true)
80$(error Symbol compression not yet supported.)
81compress_output := $(intermediates)/COMPRESSED-$(LOCAL_BUILT_MODULE_STEM)
82
Bruce Beare45ac4342010-06-24 14:02:00 -070083#TODO: write the real $(STRIPPER) rule.
The Android Open Source Project88b60792009-03-03 19:28:42 -080084#TODO: define a rule to build TARGET_SYMBOL_FILTER_FILE, and
85# make it depend on ALL_ORIGINAL_DYNAMIC_BINARIES.
86$(compress_output): $(compress_input) $(TARGET_SYMBOL_FILTER_FILE) | $(ACP)
87 @echo "target Compress Symbols: $(PRIVATE_MODULE) ($@)"
88 $(copy-file-to-target)
89else
90# Skip this step.
91compress_output := $(compress_input)
92endif
93
Ying Wang374b3252011-03-14 11:44:57 -070094###########################################################
95## Store a copy with symbols for symbolic debugging
96###########################################################
97symbolic_input := $(compress_output)
Ying Wang24084792013-09-24 15:56:11 -070098symbolic_output := $(LOCAL_UNSTRIPPED_PATH)/$(LOCAL_INSTALLED_MODULE_STEM)
Ying Wang374b3252011-03-14 11:44:57 -070099$(symbolic_output) : $(symbolic_input) | $(ACP)
100 @echo "target Symbolic: $(PRIVATE_MODULE) ($@)"
101 $(copy-file-to-target)
102
The Android Open Source Project88b60792009-03-03 19:28:42 -0800103
104###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800105## Strip
106###########################################################
Ying Wang374b3252011-03-14 11:44:57 -0700107strip_input := $(symbolic_output)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800108strip_output := $(LOCAL_BUILT_MODULE)
109
110ifeq ($(strip $(LOCAL_STRIP_MODULE)),)
111 LOCAL_STRIP_MODULE := $(strip $(TARGET_STRIP_MODULE))
112endif
113
114ifeq ($(LOCAL_STRIP_MODULE),true)
115# Strip the binary
Bruce Beare45ac4342010-06-24 14:02:00 -0700116$(strip_output): $(strip_input) | $(TARGET_STRIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800117 $(transform-to-stripped)
118else
119# Don't strip the binary, just copy it. We can't skip this step
120# because a copy of the binary must appear at LOCAL_BUILT_MODULE.
121#
122# If the binary we're copying is acp or a prerequisite,
123# use cp(1) instead.
124ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
125$(strip_output): $(strip_input) | $(ACP)
126 @echo "target Unstripped: $(PRIVATE_MODULE) ($@)"
127 $(copy-file-to-target)
128else
129$(strip_output): $(strip_input)
130 @echo "target Unstripped: $(PRIVATE_MODULE) ($@)"
131 $(copy-file-to-target-with-cp)
132endif
133endif # LOCAL_STRIP_MODULE
134
135
Ying Wangeda6ac22013-01-28 10:58:01 -0800136$(cleantarget): PRIVATE_CLEAN_FILES += \
137 $(linked_module) \
138 $(symbolic_output) \
139 $(compress_output)