Add prebuilt static library support.

This is done with the new PREBUILT_STATIC_LIBRARY include script.

+ Simplify prebuilts dependencies by removing LOCAL_PREBUILTS.
  You can now simply list your prebuilts into LOCAL_STATIC_LIBRARIES
  and/or LOCAL_SHARED_LIBRARIES.

+ pretty-print paths during install build commands.

Change-Id: I4aca605fc6f818d9669343c6aefc419a78ee0df2
diff --git a/build/core/build-all.mk b/build/core/build-all.mk
index cbc4859..5fe4169 100644
--- a/build/core/build-all.mk
+++ b/build/core/build-all.mk
@@ -69,6 +69,7 @@
 BUILD_SHARED_LIBRARY      := $(BUILD_SYSTEM)/build-shared-library.mk
 BUILD_EXECUTABLE          := $(BUILD_SYSTEM)/build-executable.mk
 PREBUILT_SHARED_LIBRARY   := $(BUILD_SYSTEM)/prebuilt-shared-library.mk
+PREBUILT_STATIC_LIBRARY   := $(BUILD_SYSTEM)/prebuilt-static-library.mk
 
 ANDROID_MK_INCLUDED := \
   $(CLEAR_VARS) \
diff --git a/build/core/build-binary.mk b/build/core/build-binary.mk
index 54d0fb7..cb9fef1 100644
--- a/build/core/build-binary.mk
+++ b/build/core/build-binary.mk
@@ -189,6 +189,7 @@
 #$(dump-src-file-tags)
 
 LOCAL_DEPENDENCY_DIRS :=
+LOCAL_OBJECTS :=
 
 # Build the sources to object files
 #
@@ -279,6 +280,16 @@
 endif
 
 #
+# If this is a prebuilt module
+#
+ifeq ($(call module-is-prebuilt,$(LOCAL_MODULE)),$(true))
+$(LOCAL_BUILT_MODULE): $(LOCAL_OBJECTS)
+	@ mkdir -p $(dir $@)
+	@ echo "Prebuilt       : $(call pretty-dir,$@) <= $(call pretty-dir,$<)"
+	$(hide) cp -f $< $@
+endif
+
+#
 # If this is an installable module
 #
 ifeq ($(call module-is-installable,$(LOCAL_MODULE)),$(true))
@@ -288,7 +299,7 @@
 $(LOCAL_INSTALLED): PRIVATE_DST     := $(LOCAL_INSTALLED)
 
 $(LOCAL_INSTALLED): $(LOCAL_BUILT_MODULE) clean-installed-binaries
-	@ echo "Install        : $(PRIVATE_NAME) => $(PRIVATE_DST_DIR)"
+	@ echo "Install        : $(PRIVATE_NAME) => $(call pretty-dir,$(PRIVATE_DST))"
 	$(hide) mkdir -p $(PRIVATE_DST_DIR)
 	$(hide) install -p $(PRIVATE_SRC) $(PRIVATE_DST)
 	$(hide) $(call cmd-strip, $(PRIVATE_DST))
diff --git a/build/core/definitions.mk b/build/core/definitions.mk
index eb89865..26c46e5 100644
--- a/build/core/definitions.mk
+++ b/build/core/definitions.mk
@@ -164,7 +164,6 @@
     CPPFLAGS \
     STATIC_LIBRARIES \
     SHARED_LIBRARIES \
-    PREBUILTS \
     LDLIBS \
     ALLOW_UNDEFINED_SYMBOLS \
     ARM_MODE \
@@ -267,7 +266,13 @@
 # An installable module is one that will be copied to $PROJECT/libs/<abi>/
 # (e.g. shared libraries).
 #
-module-is-installable    = $(call module-class-is-installable,$(call module-get-class,$1))
+module-is-installable = $(call module-class-is-installable,$(call module-get-class,$1))
+
+# Returns $(true) if module $1 is prebuilt
+# A prebuilt module is one declared with BUILD_PREBUILT_SHARED_LIBRARY or
+# BUILD_PREBUILT_STATIC_LIBRARY
+#
+module-is-prebuilt = $(call module-class-is-prebuilt,$(call module-get-class,$1))
 
 # -----------------------------------------------------------------------------
 # Function : module-get-export
@@ -341,9 +346,6 @@
 module-add-shared-depends = \
     $(call module-add-depends-any,$1,$2,depends) \
 
-module-add-prebuilt-depends = \
-    $(call module-add-depends-any,$1,$2,depends) \
-
 # Used internally by module-add-static-depends and module-add-shared-depends
 # NOTE: this function must not modify the existing dependency order when new depends are added.
 #
@@ -360,7 +362,6 @@
 module-compute-depends = \
     $(call module-add-static-depends,$1,$(__ndk_modules.$1.STATIC_LIBRARIES))\
     $(call module-add-shared-depends,$1,$(__ndk_modules.$1.SHARED_LIBRARIES))\
-    $(call module-add-prebuilt-depends,$1,$(__ndk_modules.$1.PREBUILTS))
 
 module-get-installed = $(__ndk_modules.$1.INSTALLED)
 
@@ -447,6 +448,15 @@
 # -----------------------------------------------------------------------------
 parent-dir = $(patsubst %/,%,$(dir $1))
 
+
+# -----------------------------------------------------------------------------
+# Function : pretty-dir
+# Arguments: 1: path
+# Returns  : Remove NDK_PROJECT_PATH prefix from a given path. This can be
+#            used to perform pretty-printing for logs.
+# -----------------------------------------------------------------------------
+pretty-dir = $(patsubst $(NDK_PROJECT_PATH)/%,%,$1)
+
 # -----------------------------------------------------------------------------
 # Function : check-user-define
 # Arguments: 1: name of variable that must be defined by the user
@@ -504,26 +514,63 @@
 # -----------------------------------------------------------------------------
 handle-module-filename = $(eval $(call ev-handle-module-filename,$1,$2))
 
+#
+# Check that LOCAL_MODULE_FILENAME is properly defined
+# - with one single item
+# - without a library file extension
+# - with no directory separators
+#
+define ev-check-module-filename
+ifneq (1,$$(words $$(LOCAL_MODULE_FILENAME)))
+    $$(call __ndk_info,$$(LOCAL_MAKEFILE):$$(LOCAL_MODULE): LOCAL_MODULE_FILENAME must not contain any space)
+    $$(call __ndk_error,Aborting)
+endif
+ifneq (,$$(filter %.a %.so,$$(LOCAL_MODULE_FILENAME)))
+    $$(call __ndk_info,$$(LOCAL_MAKEFILE):$$(LOCAL_MODULE): LOCAL_MODULE_FILENAME must not contain a file extension)
+    $$(call __ndk_error,Aborting)
+endif
+ifneq (1,$$(words $$(subst /, ,$$(LOCAL_MODULE_FILENAME))))
+    $$(call __ndk_info,$$(LOCAL_MAKEFILE):$$(LOCAL_MODULE): LOCAL_MODULE_FILENAME must not contain directory separators)
+    $$(call __ndk_error,Aborting)
+endif
+endef
 
+#
+# Check the definition of LOCAL_MODULE_FILENAME. If none exists,
+# infer it from the LOCAL_MODULE name.
+#
 # $1: default file prefix
 # $2: default file suffix
+#
 define ev-handle-module-filename
 LOCAL_MODULE_FILENAME := $$(strip $$(LOCAL_MODULE_FILENAME))
-ifdef LOCAL_MODULE_FILENAME
-    ifneq ($$(words $$(LOCAL_MODULE_FILENAME)),1)
-        $$(call __ndk_info,$$(LOCAL_MAKEFILE):$$(LOCAL_MODULE): LOCAL_MODULE_FILENAME must not contain any space)
-        $$(call __ndk_error,Aborting)
-    endif
-    ifneq ($$(filter %.a %.so,$$(LOCAL_MODULE_FILENAME)),)
-        $$(call __ndk_info,$$(LOCAL_MAKEFILE):$$(LOCAL_MODULE): LOCAL_MODULE_FILENAME must not contain a file extension)
-        $$(call __ndk_error,Aborting)
-    endif
-else
-    LOCAL_MODULE_FILENAME := $1$(LOCAL_MODULE)
+ifndef LOCAL_MODULE_FILENAME
+    LOCAL_MODULE_FILENAME := $1$$(LOCAL_MODULE)
 endif
+$$(eval $$(call ev-check-module-filename))
 LOCAL_MODULE_FILENAME := $$(LOCAL_MODULE_FILENAME)$2
 endef
 
+handle-prebuilt-module-filename = $(eval $(call ev-handle-prebuilt-module-filename,$1))
+
+#
+# Check the definition of LOCAL_MODULE_FILENAME for a _prebuilt_ module.
+# If none exists, infer it from $(LOCAL_SRC_FILES)
+#
+# $1: default file suffix
+#
+define ev-handle-prebuilt-module-filename
+LOCAL_MODULE_FILENAME := $$(strip $$(LOCAL_MODULE_FILENAME))
+ifndef LOCAL_MODULE_FILENAME
+    LOCAL_MODULE_FILENAME := $$(notdir $(LOCAL_SRC_FILES))
+    LOCAL_MODULE_FILENAME := $$(LOCAL_MODULE_FILENAME:%.a=%)
+    LOCAL_MODULE_FILENAME := $$(LOCAL_MODULE_FILENAME:%.so=%)
+endif
+LOCAL_MODULE_FILENAME := $$(LOCAL_MODULE_FILENAME)$1
+$$(eval $$(call ev-check-module-filename))
+endef
+
+
 # -----------------------------------------------------------------------------
 # Function  : handle-module-built
 # Returns   : None
@@ -1075,6 +1122,9 @@
     $(call module-class-register,$1,$2,$3) \
     $(eval NDK_MODULE_CLASS.$1.INSTALLABLE := $(true))
 
+module-class-set-prebuilt = \
+    $(eval NDK_MODULE_CLASS.$1.PREBUILT := $(true))
+
 # Returns $(true) if $1 is a valid/registered LOCAL_MODULE_CLASS value
 #
 module-class-check = $(call set_is_member,$(NDK_MODULE_CLASSES),$1)
@@ -1083,6 +1133,9 @@
 #
 module-class-is-installable = $(if $(NDK_MODULE_CLASS.$1.INSTALLABLE),$(true),$(false))
 
+# Returns $(true) if $1 corresponds to an installable module class
+#
+module-class-is-prebuilt = $(if $(NDK_MODULE_CLASS.$1.PREBUILT),$(true),$(false))
 
 #
 # Register valid module classes
@@ -1102,7 +1155,13 @@
 # an executable is installable.
 $(call module-class-register-installable,EXECUTABLE,,)
 
-# prebuild shared library
+# prebuilt shared library
 # <foo> -> <foo>  (we assume it is already well-named)
 # it is installable
 $(call module-class-register-installable,PREBUILT_SHARED_LIBRARY,,)
+$(call module-class-set-prebuilt,PREBUILT_SHARED_LIBRARY)
+
+# prebuilt static library
+# <foo> -> <foo> (we assume it is already well-named)
+$(call module-class-register,PREBUILT_STATIC_LIBRARY,,)
+$(call module-class-set-prebuilt,PREBUILT_STATIC_LIBRARY)
diff --git a/build/core/prebuilt-library.mk b/build/core/prebuilt-library.mk
new file mode 100644
index 0000000..76999ef
--- /dev/null
+++ b/build/core/prebuilt-library.mk
@@ -0,0 +1,66 @@
+# Copyright (C) 2010 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# this file is included from prebuilt-shared-library.mk or
+# prebuilt-static-library.mk to declare prebuilt library binaries.
+#
+
+$(call assert-defined, LOCAL_BUILD_SCRIPT LOCAL_MAKEFILE LOCAL_PREBUILT_PREFIX LOCAL_PREBUILT_SUFFIX)
+
+$(call check-defined-LOCAL_MODULE,$(LOCAL_BUILD_SCRIPT))
+$(call check-LOCAL_MODULE,$(LOCAL_MAKEFILE))
+$(call check-LOCAL_MODULE_FILENAME)
+
+# Check that LOCAL_SRC_FILES contains only paths to shared libraries
+ifneq ($(words $(LOCAL_SRC_FILES)),1)
+$(call __ndk_info,ERROR:$(LOCAL_MAKEFILE):$(LOCAL_MODULE): The LOCAL_SRC_FILES for a prebuilt static library should only contain one item))
+$(call __ndk_error,Aborting)
+endif
+
+bad_prebuilts := $(filter-out %$(LOCAL_PREBUILT_SUFFIX),$(LOCAL_SRC_FILES))
+ifdef bad_prebuilts
+$(call __ndk_info,ERROR:$(LOCAL_MAKEFILE):$(LOCAL_MODULE): LOCAL_SRC_FILES should point to a file ending with "$(LOCAL_PREBUILT_SUFFIX)")
+$(call __ndk_info,The following file is unsupported: $(bad_prebuilts))
+$(call __ndk_error,Aborting)
+endif
+
+prebuilt := $(strip $(wildcard $(LOCAL_PATH)/$(LOCAL_SRC_FILES)))
+ifndef prebuilt
+$(call __ndk_info,ERROR:$(LOCAL_MAKEFILE):$(LOCAL_MODULE): LOCAL_SRC_FILES points to a missing file)
+$(call __ndk_info,Check that $(LOCAL_PATH)/$(LOCAL_SRC_FILES) exists, or that its path is correct)
+$(call __ndk_error,Aborting)
+endif
+
+# If LOCAL_MODULE_FILENAME is defined, it will be used to name the file
+# in the TARGET_OUT directory, and then the installation one. Note that
+# if shouldn't have an .a or .so extension nor contain directory separators.
+#
+# If the variable is not defined, we determine its value from LOCAL_SRC_FILES
+#
+LOCAL_MODULE_FILENAME := $(strip $(LOCAL_MODULE_FILENAME))
+ifndef LOCAL_MODULE_FILENAME
+    LOCAL_MODULE_FILENAME := $(notdir $(LOCAL_SRC_FILES))
+    LOCAL_MODULE_FILENAME := $(LOCAL_MODULE_FILENAME:%$(LOCAL_PREBUILT_SUFFIX)=%)
+endif
+$(eval $(call ev-check-module-filename))
+
+LOCAL_BUILT_MODULE := $(TARGET_OUT)/$(LOCAL_MODULE_FILENAME)$(LOCAL_PREBUILT_SUFFIX)
+LOCAL_OBJS_DIR     := $(TARGET_OBJS)/$(LOCAL_MODULE)
+LOCAL_OBJECTS      := $(prebuilt)
+LOCAL_SRC_FILES    :=
+
+$(LOCAL_BUILT_MODULE): $(LOCAL_OBJECTS)
+
+include $(BUILD_SYSTEM)/build-module.mk
diff --git a/build/core/prebuilt-shared-library.mk b/build/core/prebuilt-shared-library.mk
index 3c07a1d..afe5e4b 100644
--- a/build/core/prebuilt-shared-library.mk
+++ b/build/core/prebuilt-shared-library.mk
@@ -18,40 +18,10 @@
 #
 
 LOCAL_BUILD_SCRIPT := PREBUILT_SHARED_LIBRARY
+LOCAL_MODULE_CLASS := PREBUILT_SHARED_LIBRARY
 LOCAL_MAKEFILE     := $(local-makefile)
 
-$(call check-defined-LOCAL_MODULE,$(LOCAL_BUILD_SCRIPT))
-$(call check-LOCAL_MODULE,$(LOCAL_MAKEFILE))
-$(call check-LOCAL_MODULE_FILENAME)
+LOCAL_PREBUILT_PREFIX := lib
+LOCAL_PREBUILT_SUFFIX := .so
 
-# Check that LOCAL_SRC_FILES contains only paths to shared libraries
-ifneq ($(words $(LOCAL_SRC_FILES)),1)
-$(call __ndk_info,ERROR:$(LOCAL_MAKEFILE):$(LOCAL_MODULE): The LOCAL_SRC_FILES for a prebuilt shared library should only contain one item))
-$(call __ndk_error,Aborting)
-endif
-
-bad_prebuilts := $(filter-out %.so,$(LOCAL_SRC_FILES))
-ifdef bad_prebuilts
-$(call __ndk_info,ERROR:$(LOCAL_MAKEFILE):$(LOCAL_MODULE): LOCAL_SRC_FILES should point to a prebuilt shared library)
-$(call __ndk_info,The following files are unsupported: $(bad_prebuilts))
-$(call __ndk_error,Aborting)
-endif
-
-prebuilt := $(strip $(wildcard $(LOCAL_SRC_FILES)))
-ifndef prebuilt
-$(call __ndk_info,ERROR:$(LOCAL_MAKEFILE):$(LOCAL_MODULE): LOCAL_SRC_FILES points to a missing file)
-$(call __ndk_info,Check that $(LOCAL_SRC_FILES) exists, or that its path is correct)
-$(call __ndk_error,Aborting)
-endif
-
-ifdef LOCAL_MODULE_FILENAME
-$(call __ndk_info,ERROR:$(LOCAL_MAKEFILE):$(LOCAL_MODULE): LOCAL_MODULE_FILENAME cannot be used for a prebuilt shared library)
-$(call __ndk_error,Aborting)
-endif
-
-LOCAL_BUILT_MODULE := $(LOCAL_SRC_FILES)
-LOCAL_SRC_FILES    :=
-LOCAL_OBJS_DIR     := $(TARGET_OBJS)/$(LOCAL_MODULE)
-
-LOCAL_MODULE_CLASS := PREBUILT_SHARED_LIBRARY
-include $(BUILD_SYSTEM)/build-module.mk
+include $(BUILD_SYSTEM)/prebuilt-library.mk
diff --git a/build/core/prebuilt-static-library.mk b/build/core/prebuilt-static-library.mk
new file mode 100644
index 0000000..69121ce
--- /dev/null
+++ b/build/core/prebuilt-static-library.mk
@@ -0,0 +1,27 @@
+# Copyright (C) 2010 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# this file is included from Android.mk files to build a target-specific
+# shared library
+#
+
+LOCAL_BUILD_SCRIPT := PREBUILT_STATIC_LIBRARY
+LOCAL_MODULE_CLASS := PREBUILT_STATIC_LIBRARY
+LOCAL_MAKEFILE     := $(local-makefile)
+
+LOCAL_PREBUILT_PREFIX := lib
+LOCAL_PREBUILT_SUFFIX := .a
+
+include $(BUILD_SYSTEM)/prebuilt-library.mk
diff --git a/build/core/setup-toolchain.mk b/build/core/setup-toolchain.mk
index 3caad46..c7808b6 100644
--- a/build/core/setup-toolchain.mk
+++ b/build/core/setup-toolchain.mk
@@ -107,7 +107,7 @@
 $(NDK_APP_GDBSERVER): PRIVATE_DST     := $(NDK_APP_GDBSERVER)
 
 $(NDK_APP_GDBSERVER): clean-installed-binaries
-	@ echo "Gdbserver      : [$(PRIVATE_NAME)] $(PRIVATE_DST)"
+	@ echo "Gdbserver      : [$(PRIVATE_NAME)] $(call pretty-dir,$(PRIVATE_DST))"
 	$(hide) mkdir -p $(PRIVATE_DST_DIR)
 	$(hide) install -p $(PRIVATE_SRC) $(PRIVATE_DST)
 
@@ -119,7 +119,7 @@
 $(NDK_APP_GDBSETUP): PRIVATE_SRC_DIRS := $(SYSROOT)/usr/include
 
 $(NDK_APP_GDBSETUP):
-	@ echo "Gdbsetup       : $(PRIVATE_DST)"
+	@ echo "Gdbsetup       : $(call pretty-dir,$(PRIVATE_DST))"
 	$(hide) echo "set solib-search-path $(PRIVATE_SOLIB_PATH)" > $(PRIVATE_DST)
 	$(hide) echo "directory $(call uniq,$(PRIVATE_SRC_DIRS))" >> $(PRIVATE_DST)
 
diff --git a/docs/ANDROID-MK.TXT b/docs/ANDROID-MK.TXT
index d4a0b34..b4d4372 100644
--- a/docs/ANDROID-MK.TXT
+++ b/docs/ANDROID-MK.TXT
@@ -206,12 +206,16 @@
     Points to a build script used to specify a prebuilt shared library.
     Unlike BUILD_SHARED_LIBRARY and BUILD_STATIC_LIBRARY, the value
     of LOCAL_SRC_FILES must be a single path to a prebuilt shared
-    library (e.g. $(LOCAL_PATH)/libfoo.so), instead of a source file.
+    library (e.g. foo/libfoo.so), instead of a source file.
 
     You can reference the prebuilt library in another module using
     the LOCAL_PREBUILTS variable (see docs/PREBUILTS.TXT for more
     information).
 
+PREBUILT_STATIC_LIBRARY
+    This is the same than PREBUILT_SHARED_LIBRARY, but for a static library
+    file instead. See docs/PREBUILTS.TXT for more.
+
 TARGET_ARCH
     Name of the target CPU architecture as it is specified by the
     full Android open-source build. This is 'arm' for any ARM-compatible
@@ -488,20 +492,13 @@
 LOCAL_STATIC_LIBRARIES
     The list of static libraries modules (built with BUILD_STATIC_LIBRARY)
     that should be linked to this module. This only makes sense in
-    shared library modules. 
+    shared library modules.
 
 LOCAL_SHARED_LIBRARIES
     The list of shared libraries *modules* this module depends on at runtime.
     This is necessary at link time and to embed the corresponding information
     in the generated file.
 
-LOCAL_PREBUILTS
-    The list of prebuild shared library *modules* this module depends on at
-    runtime. This is necessary at link time and to embed the corresponding
-    information in the generated file.
-
-    See docs/PREBUILTS.TXT for more information.
-
 LOCAL_LDLIBS
     The list of additional linker flags to be used when building your
     module. This is useful to pass the name of specific system libraries
diff --git a/docs/CHANGES.TXT b/docs/CHANGES.TXT
index 33585a4..1866445 100644
--- a/docs/CHANGES.TXT
+++ b/docs/CHANGES.TXT
@@ -35,8 +35,8 @@
     Note that they still correspond to our minimal C++ runtime, no new feature
     was introduced here.
 
-- Add support for prebuilt shared libraries with the PREBUILT_SHARED_LIBRARY
-  build script (instead of BUILD_SHARED_LIBRARY). See the new documentation
+- Add support for prebuilt libraries with the PREBUILT_SHARED_LIBRARY and
+  PREBUILT_STATIC_LIBRARIES build scripts. See the new documentation
   file named docs/PREBUILTS.TXT for explanations and usage examples.
 
 - Add support to specify a different file name for generated files, through
diff --git a/docs/PREBUILTS.TXT b/docs/PREBUILTS.TXT
index dafbf51..0a9f1a1 100644
--- a/docs/PREBUILTS.TXT
+++ b/docs/PREBUILTS.TXT
@@ -1,54 +1,67 @@
 NDK Prebuilt library support:
 -----------------------------
 
-Android NDK r5 introduced support for prebuilt shared libraries, i.e.
-the ability to include and use, in your applications, prebuilt version
-of libraries. This document explains how this support works.
+Android NDK r5 introduced support for prebuilt libraries (shared and
+static), i.e. the ability to include and use, in your applications,
+prebuilt version of libraries.
+
+This feature can be useful for two things:
+
+1/ You want to distribute your own libraries to third-party NDK developers
+   without distributing your sources.
+
+2/ You want to use a prebuilt version of your own libraries to speed up
+   your build.
+
+This document explains how this support works.
 
 
-I. Declaring a prebuilt shared library module:
-----------------------------------------------
+I. Declaring a prebuilt library module:
+---------------------------------------
 
-Each prebuilt library must be declared as an independent module to the
-build system. Here is a trivial example:
+Each prebuilt library must be declared as a *single* independent module to
+the build system. Here is a trivial example where we assume that the file
+"libfoo.so" is located in the same directory than the Android.mk below:
 
    LOCAL_PATH := $(call my-dir)
 
    include $(CLEAR_VARS)
    LOCAL_MODULE := foo-prebuilt
-   LOCAL_SRC_FILES := $(LOCAL_PATH)/libfoo.so
+   LOCAL_SRC_FILES := libfoo.so
    include $(PREBUILT_SHARED_LIBRARY)
 
 Notice that, to declare such a module, you really only need the following:
 
 1. Give the module a name (here 'foo-prebuilt'). This does not need to
-   correspond to the name of the prebuilt shared library itself.
+   correspond to the name of the prebuilt library itself.
 
 2. Assign to LOCAL_SRC_FILES the path to the prebuilt library you are
-   providing.
+   providing. As usual, the path is relative to your LOCAL_PATH.
 
    IMPORTANT: You *must* ensure that the prebuilt library corresponds
               to the target ABI you are using. More on this later.
 
-3. Include PREBUILT_SHARED_LIBRARY, instead of BUILD_SHARED_LIBRARY
+3. Include PREBUILT_SHARED_LIBRARY, instead of BUILD_SHARED_LIBRARY, if
+   you are providing a shared, library. For static ones, use
+   PREBUILT_STATIC_LIBRARY.
 
 A prebuilt module does not build anything. However, a copy of your prebuilt
-shared library will be copied and stripped into $PROJECT/libs/<abi>.
-
+shared library will be copied into $PROJECT/obj/local, and another will be
+copied and stripped into $PROJECT/libs/<abi>.
 
 II. Referencing the prebuilt library in other modules:
 ------------------------------------------------------
 
-If you are building code that depends on symbols provided by the prebuilt
-library, you can reference it through the LOCAL_PREBUILTS variable. It must
-contain a list of prebuilt module names that your module depends on.
+Simply list your prebuilt module's name in the LOCAL_STATIC_LIBRARIES or
+LOCAL_SHARED_LIBRARIES declaration int he Android.mk of any module that
+depends on them.
 
 For example, a naive example of a module using libfoo.so would be:
 
     include $(CLEAR_VARS)
     LOCAL_MODULE := foo-user
     LOCAL_SRC_FILES := foo-user.c
-    LOCAL_PREBUILTS := foo-prebuilt
+    LOCAL_SHARED_LIBRARY := foo-prebuilt
     include $(BUILD_SHARED_LIBRARY)
 
 
@@ -72,7 +85,7 @@
 
    include $(CLEAR_VARS)
    LOCAL_MODULE := foo-prebuilt
-   LOCAL_SRC_FILES := $(LOCAL_PATH)/libfoo.so
+   LOCAL_SRC_FILES := libfoo.so
    LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
    include $(PREBUILT_SHARED_LIBRARY)
 
@@ -109,7 +122,7 @@
 
     include $(CLEAR_VARS)
     LOCAL_MODULE := foo-prebuilt
-    LOCAL_SRC_FILES := $(LOCAL_PATH)/$(TARGET_ARCH_ABI)/libfoo.so
+    LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libfoo.so
     LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
     include $(PREBUILT_SHARED_LIBRARY)