Support to package prebuilt NDK libstlport_shared.so into apk

To package libstlport_shared.so, use the following syntax in the app
module definition:
LOCAL_NDK_STL_VARIANT := stlport_shared
LOCAL_NDK_VERSION := <num>

The rationale behind is:
The NDK prebiult libstlport_shared.so is intentionally different from
the system libstlport.so.
Essentially they are slightly different versions of the library so
shouldn't be mixed up.
libstlport.so is used by the system, but not exposed by the NDK, it is
routinely tweaked in various ways between platform releases, and there
is no guarantee that its ABI is stable, or that it will not be replaced
by something else in the future.
libstlport_shared.so is typically distributed with application packages,
and should not be part of the system.

Change-Id: I72c9911781f7d8402687e9891f3f605f3a60be22
diff --git a/core/package.mk b/core/package.mk
index 398e487..b894f99 100644
--- a/core/package.mk
+++ b/core/package.mk
@@ -289,6 +289,18 @@
       $(addsuffix $(so_suffix), \
         $(LOCAL_JNI_SHARED_LIBRARIES)))
 
+# App explicitly requires the prebuilt NDK libstlport_shared.so.
+# libstlport_shared.so should never go to the system image.
+# Instead it should be packaged into the apk.
+ifeq (stlport_shared,$(LOCAL_NDK_STL_VARIANT))
+ifndef LOCAL_NDK_VERSION
+$(error LOCAL_NDK_VERSION has to be defined together with LOCAL_NDK_STL_VARIANT, \
+    LOCAL_PACKAGE_NAME=$(LOCAL_PACKAGE_NAME))
+endif
+jni_shared_libraries += \
+    $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r$(LOCAL_NDK_VERSION)/sources/cxx-stl/stlport/libs/$(TARGET_CPU_ABI)/libstlport_shared.so
+endif
+
 # Set the abi directory used by the local JNI shared libraries.
 # (Doesn't change how the local shared libraries are compiled, just
 # sets where they are stored in the apk.)