The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | ########################################################### |
| 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. |
| 11 | ifdef 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)))) |
| 13 | endif |
| 14 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 15 | # The name of the target file, without any path prepended. |
Eric Fischer | 7bbec3a | 2009-03-25 16:12:29 -0700 | [diff] [blame] | 16 | # 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 Wang | 2408479 | 2013-09-24 15:56:11 -0700 | [diff] [blame] | 19 | ifndef LOCAL_MODULE_STEM |
Eric Fischer | 7bbec3a | 2009-03-25 16:12:29 -0700 | [diff] [blame] | 20 | LOCAL_MODULE_STEM := $(LOCAL_MODULE) |
| 21 | endif |
Ying Wang | 2408479 | 2013-09-24 15:56:11 -0700 | [diff] [blame] | 22 | |
| 23 | ifndef LOCAL_BUILT_MODULE_STEM |
| 24 | LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX) |
| 25 | endif |
| 26 | |
| 27 | ifndef LOCAL_INSTALLED_MODULE_STEM |
| 28 | LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX) |
| 29 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 30 | |
| 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. |
| 34 | guessed_intermediates := $(call local-intermediates-dir) |
| 35 | |
| 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. |
| 40 | linked_module := $(guessed_intermediates)/LINKED/$(LOCAL_BUILT_MODULE_STEM) |
| 41 | |
| 42 | ALL_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. |
| 49 | LOCAL_INTERMEDIATE_TARGETS := $(linked_module) |
| 50 | |
| 51 | ################################### |
| 52 | include $(BUILD_SYSTEM)/binary.mk |
| 53 | ################################### |
| 54 | |
| 55 | # Make sure that our guess at the value of intermediates was correct. |
| 56 | ifneq ($(intermediates),$(guessed_intermediates)) |
| 57 | $(error Internal error: guessed path '$(guessed_intermediates)' doesn't match '$(intermediates)) |
| 58 | endif |
| 59 | |
| 60 | ########################################################### |
| 61 | ## Compress |
| 62 | ########################################################### |
| 63 | compress_input := $(linked_module) |
| 64 | |
| 65 | ifeq ($(strip $(LOCAL_COMPRESS_MODULE_SYMBOLS)),) |
| 66 | LOCAL_COMPRESS_MODULE_SYMBOLS := $(strip $(TARGET_COMPRESS_MODULE_SYMBOLS)) |
| 67 | endif |
| 68 | |
| 69 | ifeq ($(LOCAL_COMPRESS_MODULE_SYMBOLS),true) |
| 70 | $(error Symbol compression not yet supported.) |
| 71 | compress_output := $(intermediates)/COMPRESSED-$(LOCAL_BUILT_MODULE_STEM) |
| 72 | |
Bruce Beare | 45ac434 | 2010-06-24 14:02:00 -0700 | [diff] [blame] | 73 | #TODO: write the real $(STRIPPER) rule. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 74 | #TODO: define a rule to build TARGET_SYMBOL_FILTER_FILE, and |
| 75 | # make it depend on ALL_ORIGINAL_DYNAMIC_BINARIES. |
| 76 | $(compress_output): $(compress_input) $(TARGET_SYMBOL_FILTER_FILE) | $(ACP) |
| 77 | @echo "target Compress Symbols: $(PRIVATE_MODULE) ($@)" |
| 78 | $(copy-file-to-target) |
| 79 | else |
| 80 | # Skip this step. |
| 81 | compress_output := $(compress_input) |
| 82 | endif |
| 83 | |
Ying Wang | 374b325 | 2011-03-14 11:44:57 -0700 | [diff] [blame] | 84 | ########################################################### |
| 85 | ## Store a copy with symbols for symbolic debugging |
| 86 | ########################################################### |
Ying Wang | f358496 | 2013-11-13 17:56:20 -0800 | [diff] [blame^] | 87 | ifeq ($(LOCAL_UNSTRIPPED_PATH),) |
| 88 | LOCAL_UNSTRIPPED_PATH := $(TARGET_OUT_UNSTRIPPED)/$(patsubst $(PRODUCT_OUT)/%,%,$(LOCAL_MODULE_PATH)) |
| 89 | endif |
Ying Wang | 374b325 | 2011-03-14 11:44:57 -0700 | [diff] [blame] | 90 | symbolic_input := $(compress_output) |
Ying Wang | 2408479 | 2013-09-24 15:56:11 -0700 | [diff] [blame] | 91 | symbolic_output := $(LOCAL_UNSTRIPPED_PATH)/$(LOCAL_INSTALLED_MODULE_STEM) |
Ying Wang | 374b325 | 2011-03-14 11:44:57 -0700 | [diff] [blame] | 92 | $(symbolic_output) : $(symbolic_input) | $(ACP) |
| 93 | @echo "target Symbolic: $(PRIVATE_MODULE) ($@)" |
| 94 | $(copy-file-to-target) |
| 95 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 96 | |
| 97 | ########################################################### |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 98 | ## Strip |
| 99 | ########################################################### |
Ying Wang | 374b325 | 2011-03-14 11:44:57 -0700 | [diff] [blame] | 100 | strip_input := $(symbolic_output) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 101 | strip_output := $(LOCAL_BUILT_MODULE) |
| 102 | |
| 103 | ifeq ($(strip $(LOCAL_STRIP_MODULE)),) |
| 104 | LOCAL_STRIP_MODULE := $(strip $(TARGET_STRIP_MODULE)) |
| 105 | endif |
| 106 | |
| 107 | ifeq ($(LOCAL_STRIP_MODULE),true) |
| 108 | # Strip the binary |
Bruce Beare | 45ac434 | 2010-06-24 14:02:00 -0700 | [diff] [blame] | 109 | $(strip_output): $(strip_input) | $(TARGET_STRIP) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 110 | $(transform-to-stripped) |
| 111 | else |
| 112 | # Don't strip the binary, just copy it. We can't skip this step |
| 113 | # because a copy of the binary must appear at LOCAL_BUILT_MODULE. |
| 114 | # |
| 115 | # If the binary we're copying is acp or a prerequisite, |
| 116 | # use cp(1) instead. |
| 117 | ifneq ($(LOCAL_ACP_UNAVAILABLE),true) |
| 118 | $(strip_output): $(strip_input) | $(ACP) |
| 119 | @echo "target Unstripped: $(PRIVATE_MODULE) ($@)" |
| 120 | $(copy-file-to-target) |
| 121 | else |
| 122 | $(strip_output): $(strip_input) |
| 123 | @echo "target Unstripped: $(PRIVATE_MODULE) ($@)" |
| 124 | $(copy-file-to-target-with-cp) |
| 125 | endif |
| 126 | endif # LOCAL_STRIP_MODULE |
| 127 | |
| 128 | |
Ying Wang | eda6ac2 | 2013-01-28 10:58:01 -0800 | [diff] [blame] | 129 | $(cleantarget): PRIVATE_CLEAN_FILES += \ |
| 130 | $(linked_module) \ |
| 131 | $(symbolic_output) \ |
| 132 | $(compress_output) |