Use $(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES

To disentangle the host/target shared library dependencies.

Change-Id: I3122b370a7c24425861ab6dba91e6d8d84b27249
diff --git a/core/prebuilt.mk b/core/prebuilt.mk
index 46771e4..6b8e3f8 100644
--- a/core/prebuilt.mk
+++ b/core/prebuilt.mk
@@ -39,9 +39,6 @@
   prebuilt_module_is_a_library :=
 endif
 
-# Install the shared libraries if necessary
-LOCAL_REQUIRED_MODULES += $(LOCAL_SHARED_LIBRARIES)
-
 # Don't install static libraries by default.
 ifndef LOCAL_UNINSTALLABLE_MODULE
 ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))
@@ -61,7 +58,7 @@
   endif
   include $(BUILD_SYSTEM)/dynamic_binary.mk
   built_module := $(linked_module)
-else
+else  # LOCAL_STRIP_MODULE not true
   include $(BUILD_SYSTEM)/base_rules.mk
   built_module := $(LOCAL_BUILT_MODULE)
 
@@ -81,7 +78,16 @@
 
 $(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes
 endif  # prebuilt_module_is_a_library
+
+# The real dependency will be added after all Android.mks are loaded and the install paths
+# of the shared libraries are determined.
+ifdef LOCAL_INSTALLED_MODULE
+ifdef LOCAL_SHARED_LIBRARIES
+$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += $(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(LOCAL_SHARED_LIBRARIES))
 endif
+endif
+
+endif  # LOCAL_STRIP_MODULE not true
 
 PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))