summaryrefslogtreecommitdiffstats
path: root/core/dynamic_binary.mk
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
commitb6c1cf6de79035f58b512f4400db458c8401379a (patch)
tree68979db37c85b499bc384e4ac337ed1424baab51 /core/dynamic_binary.mk
downloadbuild-b6c1cf6de79035f58b512f4400db458c8401379a.zip
build-b6c1cf6de79035f58b512f4400db458c8401379a.tar.gz
build-b6c1cf6de79035f58b512f4400db458c8401379a.tar.bz2
Initial Contribution
Diffstat (limited to 'core/dynamic_binary.mk')
-rw-r--r--core/dynamic_binary.mk144
1 files changed, 144 insertions, 0 deletions
diff --git a/core/dynamic_binary.mk b/core/dynamic_binary.mk
new file mode 100644
index 0000000..10027b8
--- /dev/null
+++ b/core/dynamic_binary.mk
@@ -0,0 +1,144 @@
+###########################################################
+## 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
+
+LOCAL_UNSTRIPPED_PATH := $(strip $(LOCAL_UNSTRIPPED_PATH))
+ifeq ($(LOCAL_UNSTRIPPED_PATH),)
+ LOCAL_UNSTRIPPED_PATH := $(TARGET_OUT_$(LOCAL_MODULE_CLASS)_UNSTRIPPED)
+endif
+
+# The name of the target file, without any path prepended.
+LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)$(LOCAL_MODULE_SUFFIX)
+
+# 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.
+guessed_intermediates := $(call local-intermediates-dir)
+
+# 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
+###################################
+
+# 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)
+
+#TODO: write the real $(SOSLIM) rule.
+#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
+
+
+###########################################################
+## Pre-link
+###########################################################
+prelink_input := $(compress_output)
+# The output of the prelink step is the binary we want to use
+# for symbolic debugging; the prelink step may move sections
+# around, so we have to use this version.
+prelink_output := $(LOCAL_UNSTRIPPED_PATH)/$(LOCAL_MODULE_SUBDIR)$(LOCAL_BUILT_MODULE_STEM)
+
+ifeq ($(LOCAL_PRELINK_MODULE),true)
+$(prelink_output): $(prelink_input) $(TARGET_PRELINKER_MAP) $(APRIORI)
+ $(transform-to-prelinked)
+else
+# Don't prelink the binary, just copy it. We can't skip this step
+# because people always expect a copy of the binary to appear
+# in the UNSTRIPPED directory.
+#
+# If the binary we're copying is acp or a prerequisite,
+# use cp(1) instead.
+ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
+$(prelink_output): $(prelink_input) | $(ACP)
+ @echo "target Non-prelinked: $(PRIVATE_MODULE) ($@)"
+ $(copy-file-to-target)
+else
+$(prelink_output): $(prelink_input)
+ @echo "target Non-prelinked: $(PRIVATE_MODULE) ($@)"
+ $(copy-file-to-target-with-cp)
+endif
+endif
+
+
+###########################################################
+## Strip
+###########################################################
+strip_input := $(prelink_output)
+strip_output := $(LOCAL_BUILT_MODULE)
+
+ifeq ($(strip $(LOCAL_STRIP_MODULE)),)
+ LOCAL_STRIP_MODULE := $(strip $(TARGET_STRIP_MODULE))
+endif
+
+ifeq ($(LOCAL_STRIP_MODULE),true)
+# Strip the binary
+$(strip_output): $(strip_input) | $(SOSLIM)
+ $(transform-to-stripped)
+else
+# 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
+endif # LOCAL_STRIP_MODULE
+
+
+$(cleantarget): PRIVATE_CLEAN_FILES := \
+ $(PRIVATE_CLEAN_FILES) \
+ $(linked_module) \
+ $(compress_output) \
+ $(prelink_output)