diff --git a/build/.gitignore b/build/.gitignore
new file mode 100644
index 0000000..c9b568f
--- /dev/null
+++ b/build/.gitignore
@@ -0,0 +1,2 @@
+*.pyc
+*.swp
diff --git a/build/CleanSpec.mk b/build/CleanSpec.mk
new file mode 100644
index 0000000..e9d4455
--- /dev/null
+++ b/build/CleanSpec.mk
@@ -0,0 +1,322 @@
+# Copyright (C) 2007 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.
+#
+
+# If you don't need to do a full clean build but would like to touch
+# a file or delete some intermediate files, add a clean step to the end
+# of the list. These steps will only be run once, if they haven't been
+# run before.
+#
+# E.g.:
+# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
+# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
+#
+# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
+# files that are missing or have been moved.
+#
+# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
+# Use $(OUT_DIR) to refer to the "out" directory.
+#
+# If you need to re-do something that's already mentioned, just copy
+# the command and add it to the bottom of the list. E.g., if a change
+# that you made last week required touching a file and a change you
+# made today requires touching the same file, just copy the old
+# touch step and add it to the end of the list.
+#
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+# For example:
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
+#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system)
+
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libmediaplayerservice_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libmedia_jni_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libstagefright_omx_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/vendor)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/android-info.txt)
+$(call add-clean-step, find $(PRODUCT_OUT) -name "*.apk" | xargs rm)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/*/LINKED)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/*.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/system/lib/*.so)
+$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/iself)
+$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/lsd)
+$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/apriori)
+$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/isprelinked)
+$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/soslim)
+
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/*.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/system/lib/*.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/YouTube*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libstagefright_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libstagefright_omx_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/librtp_jni_intermediates)
+
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/android-info.txt)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/JAVA_LIBRARIES/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libbcinfo_intermediates)
+
+# ICS MR2!!!!!!!!!!!!
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libbcinfo_intermediates)
+
+# WAIT, I MEAN JELLY BEAN!!!!!!!!!!!!
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+# Changing where ro.carrier value is instantiated for system/build.prop
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+# Now we switched to build against Mac OS X SDK 10.6
+$(call add-clean-step, rm -rf $(OUT_DIR)/host/darwin-x86/obj)
+
+$(call add-clean-step, rm -f $(OUT_DIR)/versions_checked.mk)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.o)
+
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.o)
+
+# JB MR2!!!!!!! AND *NO*, THIS WILL NOT BE K-WHATEVER.
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+# Start of "K" development!
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+
+# GCC 4.7
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.o)
+
+# Wait, back to some JB development!
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+
+# And on to KLP...
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+
+# KLP now based off API 18.
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+
+# Clean up around the /system/app -> /system/priv-app migration
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+
+# Clean up old location of generated Java files from aidl
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src)
+
+# Clean up ApplicationsProvider which is being removed.
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/ApplicationsProvider_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/ApplicationsProvider.apk)
+
+# Clean up Moto OMA DM client which isn't ready yet.
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/com.android.omadm.plugin.dev_intermediates)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/com.android.omadm.plugin.diagmon_intermediates)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/com.android.omadm.pluginhelper_intermediates)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/com.android.omadm.plugin_intermediates)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/com.android.omadm.service.api_intermediates)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/DMService_intermediates)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/SprintDM_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/DMService.apk)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/SprintDM.apk)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/omadm)
+
+# GCC 4.8
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.o)
+
+# KLP I mean KitKat now API 19.
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+
+# 4.4.1
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+# 4.4.2
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+# "L" and beyond.
+# Make libart the default runtime
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+# Rename persist.sys.dalvik.vm.lib to allow new default
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+# KKWT development
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+
+# L development
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+
+# L development
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+
+# Add ro.product.cpu.abilist{32,64} to build.prop.
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+# Unset TARGET_PREFER_32_BIT_APPS for 64 bit targets.
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+# Adding dalvik.vm.dex2oat-flags to eng builds
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+# Unset TARGET_PREFER_32_BIT_APPS for 64 bit targets.
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+# Switching the x86 emulator over to a 64 bit primary zygote.
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
+
+# Rename persist.sys.dalvik.vm.lib.1 to allow new default
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+# Switching PRODUCT_RUNTIMES default for some devices
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+# Switching to 32-bit-by-default host multilib build
+$(call add-clean-step, rm -rf $(HOST_OUT_INTERMEDIATES))
+
+# KKWT has become API 20
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+
+# ims-common.jar added to BOOTCLASSPATH
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/ETC/init.environ.rc_intermediates)
+
+# Change ro.zygote for core_64_bit.mk from zygote32_64 to zygote64_32
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
+
+# Adding dalvik.vm.dex2oat-Xms, dalvik.vm.dex2oat-Xmx
+# dalvik.vm.image-dex2oat-Xms, and dalvik.vm.image-dex2oat-Xmx
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
+
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system)
+
+# Adding dalvik.vm.dex2oat-filter
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
+
+# API 21?
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+
+# API 21!
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+
+# API 22!
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+
+# 5.1!
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+
+# 5.1.1!
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+
+# Added new build props
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
diff --git a/build/buildspec.mk.default b/build/buildspec.mk.default
new file mode 100644
index 0000000..d14208e
--- /dev/null
+++ b/build/buildspec.mk.default
@@ -0,0 +1,111 @@
+#
+# Copyright (C) 2007 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 is a do-nothing template file. To use it, copy it to a file
+# named "buildspec.mk" in the root directory, and uncomment or change
+# the variables necessary for your desired configuration. The file
+# "buildspec.mk" should never be checked in to source control.
+######################################################################
+
+# Choose a product to build for. Look in the products directory for ones
+# that work.
+ifndef TARGET_PRODUCT
+#TARGET_PRODUCT:=generic
+endif
+
+# Choose a variant to build. If you don't pick one, the default is eng.
+# User is what we ship. Userdebug is that, with a few flags turned on
+# for debugging. Eng has lots of extra tools for development.
+ifndef TARGET_BUILD_VARIANT
+#TARGET_BUILD_VARIANT:=user
+#TARGET_BUILD_VARIANT:=userdebug
+#TARGET_BUILD_VARIANT:=eng
+endif
+
+# Choose additional targets to always install, even when building
+# minimal targets like "make droid". This takes simple target names
+# like "Browser" or "MyApp", the names used by LOCAL_MODULE or
+# LOCAL_PACKAGE_NAME. Modules listed here will always be installed in
+# /system, even if they'd usually go in /data.
+ifndef CUSTOM_MODULES
+#CUSTOM_MODULES:=
+endif
+
+# Set this to debug or release if you care. Otherwise, it defaults to release.
+ifndef TARGET_BUILD_TYPE
+#TARGET_BUILD_TYPE:=release
+endif
+
+# Uncomment this if you want the host tools built in debug mode. Otherwise
+# it defaults to release.
+ifndef HOST_BUILD_TYPE
+#HOST_BUILD_TYPE:=debug
+endif
+
+# Turn on debugging for selected modules. If DEBUG_MODULE_ is set
+# to a non-empty value, the appropriate HOST_/TARGET_CUSTOM_DEBUG_CFLAGS
+# will be added to LOCAL_CFLAGS when building the module.
+#DEBUG_MODULE_ModuleName:=true
+
+# Specify an alternative tool chain prefix if needed.
+#TARGET_TOOLS_PREFIX:=
+
+# Specify the extra CFLAGS to use when building a module whose
+# DEBUG_MODULE_ variable is set. Host and device flags are handled
+# separately.
+#HOST_CUSTOM_DEBUG_CFLAGS:=
+#TARGET_CUSTOM_DEBUG_CFLAGS:=
+
+# Choose additional locales, like "en_US" or "it_IT", to add to any
+# built product. Any locales that appear in CUSTOM_LOCALES but not in
+# the locale list for the selected product will be added to the end
+# of PRODUCT_LOCALES.
+ifndef CUSTOM_LOCALES
+#CUSTOM_LOCALES:=
+endif
+
+# If you have a special place to put your ouput files, set this, otherwise
+# it goes to /out
+#OUT_DIR:=/tmp/stuff
+
+# If you want to always set certain system properties, add them to this list.
+# E.g., "ADDITIONAL_BUILD_PROPERTIES += ro.prop1=5 prop2=value"
+# This mechanism does not currently support values containing spaces.
+#ADDITIONAL_BUILD_PROPERTIES +=
+
+# If you want to reduce the system.img size by several meg, and are willing to
+# lose access to CJK (and other) character sets, define NO_FALLBACK_FONT:=true
+ifndef NO_FALLBACK_FONT
+#NO_FALLBACK_FONT:=true
+endif
+
+# OVERRIDE_RUNTIMES allows you to locally override PRODUCT_RUNTIMES.
+#
+# To only build ART, use "runtime_libart_default"
+# To use Dalvik but also include ART, use "runtime_libdvm_default runtime_libart"
+# To use ART but also include Dalvik, use "runtime_libart_default runtime_libdvm"
+ifndef OVERRIDE_RUNTIMES
+#OVERRIDE_RUNTIMES:=runtime_libart_default
+#OVERRIDE_RUNTIMES:=runtime_libdvm_default runtime_libart
+#OVERRIDE_RUNTIMES:=runtime_libart_default runtime_libdvm
+endif
+
+# when the build system changes such that this file must be updated, this
+# variable will be changed. After you have modified this file with the new
+# changes (see buildspec.mk.default), update this to the new value from
+# buildspec.mk.default.
+BUILD_ENV_SEQUENCE_NUMBER := 10
diff --git a/build/core/Makefile b/build/core/Makefile
new file mode 100644
index 0000000..cce2647
--- /dev/null
+++ b/build/core/Makefile
@@ -0,0 +1,1980 @@
+# Put some miscellaneous rules here
+
+# HACK: clear LOCAL_PATH from including last build target before calling
+# intermedites-dir-for
+LOCAL_PATH := $(BUILD_SYSTEM)
+
+# Pick a reasonable string to use to identify files.
+ifneq "" "$(filter eng.%,$(BUILD_NUMBER))"
+ # BUILD_NUMBER has a timestamp in it, which means that
+ # it will change every time. Pick a stable value.
+ FILE_NAME_TAG := eng.$(USER)
+else
+ FILE_NAME_TAG := $(BUILD_NUMBER)
+endif
+
+# -----------------------------------------------------------------
+# Define rules to copy PRODUCT_COPY_FILES defined by the product.
+# PRODUCT_COPY_FILES contains words like :[:].
+# is relative to $(PRODUCT_OUT), so it should look like,
+# e.g., "system/etc/file.xml".
+# The filter part means "only eval the copy-one-file rule if this
+# src:dest pair is the first one to match the same dest"
+#$(1): the src:dest pair
+define check-product-copy-files
+$(if $(filter %.apk, $(call word-colon, 2, $(1))),$(error \
+ Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))
+endef
+# filter out the duplicate : pairs.
+unique_product_copy_files_pairs :=
+$(foreach cf,$(PRODUCT_COPY_FILES), \
+ $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
+ $(eval unique_product_copy_files_pairs += $(cf))))
+unique_product_copy_files_destinations :=
+$(foreach cf,$(unique_product_copy_files_pairs), \
+ $(eval _src := $(call word-colon,1,$(cf))) \
+ $(eval _dest := $(call word-colon,2,$(cf))) \
+ $(call check-product-copy-files,$(cf)) \
+ $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
+ $(info PRODUCT_COPY_FILES $(cf) ignored.), \
+ $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
+ $(if $(filter %.xml,$(_dest)),\
+ $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
+ $(eval $(call copy-one-file,$(_src),$(_fulldest)))) \
+ $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
+ $(eval unique_product_copy_files_destinations += $(_dest))))
+unique_product_copy_files_pairs :=
+unique_product_copy_files_destinations :=
+
+# -----------------------------------------------------------------
+# docs/index.html
+ifeq (,$(TARGET_BUILD_APPS))
+gen := $(OUT_DOCS)/index.html
+ALL_DOCS += $(gen)
+$(gen): frameworks/base/docs/docs-redirect-index.html
+ @mkdir -p $(dir $@)
+ @cp -f $< $@
+endif
+
+# -----------------------------------------------------------------
+# default.prop
+INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
+ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
+ADDITIONAL_DEFAULT_PROPERTIES := \
+ $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
+ADDITIONAL_DEFAULT_PROPERTIES += \
+ $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
+ADDITIONAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
+ $(ADDITIONAL_DEFAULT_PROPERTIES),=)
+
+$(INSTALLED_DEFAULT_PROP_TARGET):
+ @echo Target buildinfo: $@
+ @mkdir -p $(dir $@)
+ $(hide) echo "#" > $@; \
+ echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \
+ echo "#" >> $@;
+ $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \
+ echo "$(line)" >> $@;)
+ build/tools/post_process_props.py $@
+
+# -----------------------------------------------------------------
+# build.prop
+INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
+ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
+ADDITIONAL_BUILD_PROPERTIES := \
+ $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
+ADDITIONAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
+ $(ADDITIONAL_BUILD_PROPERTIES),=)
+
+# A list of arbitrary tags describing the build configuration.
+# Force ":=" so we can use +=
+BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS)
+ifeq ($(TARGET_BUILD_TYPE),debug)
+ BUILD_VERSION_TAGS += debug
+endif
+# The "test-keys" tag marks builds signed with the old test keys,
+# which are available in the SDK. "dev-keys" marks builds signed with
+# non-default dev keys (usually private keys from a vendor directory).
+# Both of these tags will be removed and replaced with "release-keys"
+# when the target-files is signed in a post-build step.
+ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/testkey)
+BUILD_KEYS := test-keys
+else
+BUILD_KEYS := dev-keys
+endif
+
+ifeq ($(TARGET_BUILD_VARIANT),user)
+BUILD_KEYS := release-keys
+endif
+
+BUILD_VERSION_TAGS += $(BUILD_KEYS)
+BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
+
+# A human-readable string that descibes this build in detail.
+build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER) $(BUILD_VERSION_TAGS)
+$(INSTALLED_BUILD_PROP_TARGET): PRIVATE_BUILD_DESC := $(build_desc)
+
+# The string used to uniquely identify the combined build and product; used by the OTA server.
+ifeq (,$(strip $(BUILD_FINGERPRINT)))
+ ifneq ($(filter eng.%,$(BUILD_NUMBER)),)
+ # Trim down BUILD_FINGERPRINT: the default BUILD_NUMBER makes it easily exceed
+ # the Android system property length limit (PROPERTY_VALUE_MAX=92).
+ BF_BUILD_NUMBER := $(USER)$(shell date +%m%d%H%M)
+ else
+ BF_BUILD_NUMBER := $(BUILD_NUMBER)
+ endif
+ BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BF_BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
+endif
+ifneq ($(words $(BUILD_FINGERPRINT)),1)
+ $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)")
+endif
+
+# The string used to uniquely identify the system build; used by the OTA server.
+# This purposefully excludes any product-specific variables.
+ifeq (,$(strip $(BUILD_THUMBPRINT)))
+ BUILD_THUMBPRINT := $(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
+endif
+ifneq ($(words $(BUILD_THUMBPRINT)),1)
+ $(error BUILD_THUMBPRINT cannot contain spaces: "$(BUILD_THUMBPRINT)")
+endif
+
+KNOWN_OEM_THUMBPRINT_PROPERTIES := \
+ ro.product.brand \
+ ro.product.name \
+ ro.product.device
+OEM_THUMBPRINT_PROPERTIES := $(filter $(KNOWN_OEM_THUMBPRINT_PROPERTIES),\
+ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES))
+
+# Display parameters shown under Settings -> About Phone
+ifeq ($(TARGET_BUILD_VARIANT),user)
+ # User builds should show:
+ # release build number or branch.buld_number non-release builds
+
+ # Dev. branches should have DISPLAY_BUILD_NUMBER set
+ ifeq "true" "$(DISPLAY_BUILD_NUMBER)"
+ BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER) $(BUILD_KEYS)
+ else
+ BUILD_DISPLAY_ID := $(BUILD_ID) $(BUILD_KEYS)
+ endif
+else
+ # Non-user builds should show detailed build information
+ BUILD_DISPLAY_ID := $(build_desc)
+endif
+
+# Whether there is default locale set in PRODUCT_PROPERTY_OVERRIDES
+product_property_override_locale_language := $(strip \
+ $(patsubst ro.product.locale.language=%,%,\
+ $(filter ro.product.locale.language=%,$(PRODUCT_PROPERTY_OVERRIDES))))
+product_property_overrides_locale_region := $(strip \
+ $(patsubst ro.product.locale.region=%,%,\
+ $(filter ro.product.locale.region=%,$(PRODUCT_PROPERTY_OVERRIDES))))
+
+# Selects the first locale in the list given as the argument,
+# and splits it into language and region, which each may be
+# empty.
+define default-locale
+$(subst _, , $(firstword $(1)))
+endef
+
+# Selects the first locale in the list given as the argument
+# and returns the language (or the region), if it's not set in PRODUCT_PROPERTY_OVERRIDES;
+# Return empty string if it's already set in PRODUCT_PROPERTY_OVERRIDES.
+define default-locale-language
+$(if $(product_property_override_locale_language),,$(word 1, $(call default-locale, $(1))))
+endef
+define default-locale-region
+$(if $(product_property_overrides_locale_region),,$(word 2, $(call default-locale, $(1))))
+endef
+
+BUILDINFO_SH := build/tools/buildinfo.sh
+
+ifdef TARGET_SYSTEM_PROP
+system_prop_file := $(TARGET_SYSTEM_PROP)
+else
+system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
+endif
+$(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(BUILD_SYSTEM)/version_defaults.mk $(system_prop_file)
+ @echo Target buildinfo: $@
+ @mkdir -p $(dir $@)
+ $(hide) echo > $@
+ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES),)
+ $(hide) echo "#" >> $@; \
+ echo "# PRODUCT_OEM_PROPERTIES" >> $@; \
+ echo "#" >> $@;
+ $(hide) $(foreach prop,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES), \
+ echo "import /oem/oem.prop $(prop)" >> $@;)
+endif
+ $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
+ TARGET_BUILD_FLAVOR="$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)" \
+ TARGET_DEVICE="$(TARGET_DEVICE)" \
+ PRODUCT_NAME="$(TARGET_PRODUCT)" \
+ PRODUCT_BRAND="$(PRODUCT_BRAND)" \
+ PRODUCT_DEFAULT_LANGUAGE="$(call default-locale-language,$(PRODUCT_LOCALES))" \
+ PRODUCT_DEFAULT_REGION="$(call default-locale-region,$(PRODUCT_LOCALES))" \
+ PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
+ PRODUCT_MODEL="$(PRODUCT_MODEL)" \
+ PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
+ PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
+ BUILD_ID="$(BUILD_ID)" \
+ BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
+ BUILD_NUMBER="$(BUILD_NUMBER)" \
+ PLATFORM_VERSION="$(PLATFORM_VERSION)" \
+ PLATFORM_SECURITY_PATCH="$(PLATFORM_SECURITY_PATCH)" \
+ PLATFORM_BASE_OS="$(PLATFORM_BASE_OS)" \
+ PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
+ PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
+ PLATFORM_VERSION_ALL_CODENAMES="$(PLATFORM_VERSION_ALL_CODENAMES)" \
+ BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
+ TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
+ BUILD_FINGERPRINT="$(BUILD_FINGERPRINT)" \
+ $(if $(OEM_THUMBPRINT_PROPERTIES),BUILD_THUMBPRINT="$(BUILD_THUMBPRINT)") \
+ TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
+ TARGET_CPU_ABI_LIST="$(TARGET_CPU_ABI_LIST)" \
+ TARGET_CPU_ABI_LIST_32_BIT="$(TARGET_CPU_ABI_LIST_32_BIT)" \
+ TARGET_CPU_ABI_LIST_64_BIT="$(TARGET_CPU_ABI_LIST_64_BIT)" \
+ TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
+ TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
+ TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \
+ bash $(BUILDINFO_SH) >> $@
+ $(hide) $(foreach file,$(system_prop_file), \
+ if [ -f "$(file)" ]; then \
+ echo "#" >> $@; \
+ echo Target buildinfo from: "$(file)"; \
+ echo "# from $(file)" >> $@; \
+ echo "#" >> $@; \
+ cat $(file) >> $@; \
+ fi;)
+ $(if $(ADDITIONAL_BUILD_PROPERTIES), \
+ $(hide) echo >> $@; \
+ echo "#" >> $@; \
+ echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
+ echo "#" >> $@; )
+ $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
+ echo "$(line)" >> $@;)
+ $(hide) build/tools/post_process_props.py $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_PROPERTY_BLACKLIST)
+
+build_desc :=
+
+# -----------------------------------------------------------------
+# vendor build.prop
+#
+# For verifying that the vendor build is what we thing it is
+ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
+INSTALLED_VENDOR_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR)/build.prop
+ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_BUILD_PROP_TARGET)
+$(INSTALLED_VENDOR_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
+ @echo Target vendor buildinfo: $@
+ @mkdir -p $(dir $@)
+ $(hide) echo > $@
+ $(hide) echo ro.vendor.build.date=`date`>>$@
+ $(hide) echo ro.vendor.build.date.utc=`date +%s`>>$@
+ $(hide) echo ro.vendor.build.fingerprint="$(BUILD_FINGERPRINT)">>$@
+endif
+
+# -----------------------------------------------------------------
+# sdk-build.prop
+#
+# There are certain things in build.prop that we don't want to
+# ship with the sdk; remove them.
+
+# This must be a list of entire property keys followed by
+# "=" characters, without any internal spaces.
+sdk_build_prop_remove := \
+ ro.build.user= \
+ ro.build.host= \
+ ro.product.brand= \
+ ro.product.manufacturer= \
+ ro.product.device=
+# TODO: Remove this soon-to-be obsolete property
+sdk_build_prop_remove += ro.build.product=
+INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
+$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
+ @echo SDK buildinfo: $@
+ @mkdir -p $(dir $@)
+ $(hide) grep -v "$(subst $(space),\|,$(strip \
+ $(sdk_build_prop_remove)))" $< > $@.tmp
+ $(hide) for x in $(sdk_build_prop_remove); do \
+ echo "$$x"generic >> $@.tmp; done
+ $(hide) mv $@.tmp $@
+
+# -----------------------------------------------------------------
+# package stats
+PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt
+PACKAGES_TO_STAT := \
+ $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \
+ $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES))))
+$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
+ @echo Package stats: $@
+ @mkdir -p $(dir $@)
+ $(hide) rm -f $@
+ $(hide) build/tools/dump-package-stats $^ > $@
+
+.PHONY: package-stats
+package-stats: $(PACKAGE_STATS_FILE)
+
+# -----------------------------------------------------------------
+# Cert-to-package mapping. Used by the post-build signing tools.
+# Use a macro to add newline to each echo command
+define _apkcerts_echo_with_newline
+$(hide) echo $(1)
+
+endef
+
+name := $(TARGET_PRODUCT)
+ifeq ($(TARGET_BUILD_TYPE),debug)
+ name := $(name)_debug
+endif
+name := $(name)-apkcerts-$(FILE_NAME_TAG)
+intermediates := \
+ $(call intermediates-dir-for,PACKAGING,apkcerts)
+APKCERTS_FILE := $(intermediates)/$(name).txt
+# We don't need to really build all the modules.
+# TODO: rebuild APKCERTS_FILE if any app change its cert.
+$(APKCERTS_FILE):
+ @echo APK certs list: $@
+ @mkdir -p $(dir $@)
+ @rm -f $@
+ $(foreach p,$(PACKAGES),\
+ $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
+ $(call _apkcerts_echo_with_newline,\
+ 'name="$(p).apk" certificate="EXTERNAL" \
+ private_key=""' >> $@),\
+ $(call _apkcerts_echo_with_newline,\
+ 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
+ private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@)))
+ # In case value of PACKAGES is empty.
+ $(hide) touch $@
+
+.PHONY: apkcerts-list
+apkcerts-list: $(APKCERTS_FILE)
+
+ifneq (,$(TARGET_BUILD_APPS))
+ $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
+endif
+
+# -----------------------------------------------------------------
+# module info file
+ifdef CREATE_MODULE_INFO_FILE
+ MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt
+ $(info Generating $(MODULE_INFO_FILE)...)
+ $(shell rm -f $(MODULE_INFO_FILE))
+ $(foreach m,$(ALL_MODULES), \
+ $(shell echo "NAME=\"$(m)\"" \
+ "PATH=\"$(strip $(ALL_MODULES.$(m).PATH))\"" \
+ "TAGS=\"$(strip $(filter-out _%,$(ALL_MODULES.$(m).TAGS)))\"" \
+ "BUILT=\"$(strip $(ALL_MODULES.$(m).BUILT))\"" \
+ "INSTALLED=\"$(strip $(ALL_MODULES.$(m).INSTALLED))\"" >> $(MODULE_INFO_FILE)))
+endif
+
+# -----------------------------------------------------------------
+
+# The dev key is used to sign this package, and as the key required
+# for future OTA packages installed by this system. Actual product
+# deliverables will be re-signed by hand. We expect this file to
+# exist with the suffixes ".x509.pem" and ".pk8".
+DEFAULT_KEY_CERT_PAIR := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
+
+
+# Rules that need to be present for the all targets, even
+# if they don't do anything.
+.PHONY: systemimage
+systemimage:
+
+# -----------------------------------------------------------------
+
+.PHONY: event-log-tags
+
+# Produce an event logs tag file for everything we know about, in order
+# to properly allocate numbers. Then produce a file that's filtered
+# for what's going to be installed.
+
+all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
+
+event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
+
+# Include tags from all packages that we know about
+all_event_log_tags_src := \
+ $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
+
+# PDK builds will already have a full list of tags that needs to get merged
+# in with the ones from source
+pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES)))
+
+$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
+$(all_event_log_tags_file): $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
+ $(hide) mkdir -p $(dir $@)
+ $(hide) build/tools/merge-event-log-tags.py -o $@ $(PRIVATE_SRC_FILES)
+
+# Include tags from all packages included in this product, plus all
+# tags that are part of the system (ie, not in a vendor/ or device/
+# directory).
+event_log_tags_src := \
+ $(sort $(foreach m,\
+ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \
+ $(call module-names-for-tag-list,user), \
+ $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
+ $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
+
+$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file)
+$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
+$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) $(pdk_fusion_log_tags_file)
+ $(hide) mkdir -p $(dir $@)
+ $(hide) build/tools/merge-event-log-tags.py -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
+
+event-log-tags: $(event_log_tags_file)
+
+ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
+
+
+# #################################################################
+# Targets for boot/OS images
+# #################################################################
+ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
+ INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
+ ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
+ INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
+ else
+ INSTALLED_2NDBOOTLOADER_TARGET ?=
+ endif
+else
+ INSTALLED_BOOTLOADER_MODULE :=
+ INSTALLED_2NDBOOTLOADER_TARGET ?=
+endif # TARGET_NO_BOOTLOADER
+ifneq ($(strip $(TARGET_NO_KERNEL)),true)
+ INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
+else
+ INSTALLED_KERNEL_TARGET :=
+endif
+
+ifeq ($(TARGET_BOARD_PLATFORM),sofia3gr)
+ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
+ifneq ($(INSTALLED_2NDBOOTLOADER_TARGET), $(wildcard $(INSTALLED_2NDBOOTLOADER_TARGET)))
+$(INSTALLED_2NDBOOTLOADER_TARGET):
+ @echo "TODO" > $(INSTALLED_2NDBOOTLOADER_TARGET)
+endif
+
+
+ifneq ($(INSTALLED_2NDBOOTLOADER_RECOVERY_TARGET), $(wildcard $(INSTALLED_2NDBOOTLOADER_RECOVERY_TARGET)))
+$(INSTALLED_2NDBOOTLOADER_RECOVERY_TARGET):
+ @echo "TODO" > $(INSTALLED_2NDBOOTLOADER_RECOVERY_TARGET)
+endif
+
+endif
+
+ifeq ($(strip $(TARGET_BOOTLOADER_IS_3ND)),true)
+ifneq ($(INSTALLED_3NDBOOTLOADER_TARGET), $(wildcard $(INSTALLED_3NDBOOTLOADER_TARGET)))
+$(INSTALLED_3NDBOOTLOADER_TARGET):
+ @echo "TODO" > $(INSTALLED_3NDBOOTLOADER_TARGET)
+endif
+endif
+
+endif
+
+# -----------------------------------------------------------------
+# the ramdisk
+INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
+ $(ALL_PREBUILT) \
+ $(ALL_COPIED_HEADERS) \
+ $(ALL_GENERATED_SOURCES) \
+ $(ALL_DEFAULT_INSTALLED_MODULES))
+
+BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
+
+# We just build this directly to the install location.
+INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
+$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP)
+ $(call pretty,"Target ram disk: $@")
+ $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@
+
+.PHONY: ramdisk-nodeps
+ramdisk-nodeps: $(MKBOOTFS) | $(MINIGZIP)
+ @echo "make $@: ignoring dependencies"
+ $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $(INSTALLED_RAMDISK_TARGET)
+
+ifneq ($(strip $(TARGET_NO_KERNEL)),true)
+
+# -----------------------------------------------------------------
+# the boot image, which is a collection of other images.
+INTERNAL_BOOTIMAGE_ARGS := \
+ --kernel $(INSTALLED_KERNEL_TARGET) \
+ --ramdisk $(INSTALLED_RAMDISK_TARGET)
+
+ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
+INTERNAL_BOOTIMAGE_ARGS += \
+ $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
+endif
+
+ifeq ($(TARGET_BOARD_PLATFORM),sofia3gr)
+ifeq ($(strip $(TARGET_BOOTLOADER_IS_3ND)),true)
+ INTERNAL_BOOTIMAGE_ARGS += \
+ $(addprefix --third ,$(INSTALLED_3NDBOOTLOADER_TARGET))
+endif
+endif
+
+INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
+
+BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
+ifdef BOARD_KERNEL_CMDLINE
+ INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
+endif
+
+BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
+ifdef BOARD_KERNEL_BASE
+ INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
+endif
+
+BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
+ifdef BOARD_KERNEL_PAGESIZE
+ INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
+endif
+
+INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
+
+ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
+tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg
+INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image)
+INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG)
+
+ifeq ($(TARGET_BOOTIMAGE_USE_EXTLINUX),true)
+INTERNAL_BOOTIMAGE_ARGS += --extlinuxconf $(TARGET_BOOTIMAGE_EXTLINUX_CONFIG)
+endif
+
+$(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES)
+ $(call pretty,"Target boot image: $@")
+ $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
+
+.PHONY: bootimage-nodeps
+bootimage-nodeps: $(MKEXT2IMG)
+ @echo "make $@: ignoring dependencies"
+ $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
+
+else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)) # TARGET_BOOTIMAGE_USE_EXT2 != true
+
+$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
+ $(call pretty,"Target boot image: $@")
+ $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
+ $(BOOT_SIGNER) /boot $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $@
+ $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
+
+.PHONY: bootimage-nodeps
+bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
+ @echo "make $@: ignoring dependencies"
+ $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
+ $(BOOT_SIGNER) /boot $(INSTALLED_BOOTIMAGE_TARGET) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(INSTALLED_BOOTIMAGE_TARGET)
+ $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
+
+else # PRODUCT_SUPPORTS_VERITY != true
+
+$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
+ $(call pretty,"Target boot image: $@")
+ $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
+ $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
+
+.PHONY: bootimage-nodeps
+bootimage-nodeps: $(MKBOOTIMG)
+ @echo "make $@: ignoring dependencies"
+ $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
+ $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
+
+endif # TARGET_BOOTIMAGE_USE_EXT2
+
+else # TARGET_NO_KERNEL
+# HACK: The top-level targets depend on the bootimage. Not all targets
+# can produce a bootimage, though, and emulator targets need the ramdisk
+# instead. Fake it out by calling the ramdisk the bootimage.
+# TODO: make the emulator use bootimages, and make mkbootimg accept
+# kernel-less inputs.
+INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
+endif
+
+# -----------------------------------------------------------------
+# the rk loader bin
+INSTALLED_LOADER_MISC_TARGET := $(TARGET_DEVICE_DIR)/loader/misc_loadercmd.img
+INSTALLED_LOADER_TARGET := $(strip $(wildcard $(TARGET_DEVICE_DIR)/loader/RK*Loader*.bin))
+INSTALLED_NEW_LOADER_TARGET := $(PRODUCT_OUT)/RKLoader_new.bin
+INSTALLED_UBOOT_TARGET := $(strip $(wildcard u-boot/uboot.img))
+INSTALLED_CHARGE_TARGET := $(strip $(wildcard u-boot/charge.img))
+INSTALLED_TRUST_TARHET := $(strip $(wildcard u-boot/trust.img))
+# -----------------------------------------------------------------
+# the parameter image
+INSTALLED_PARAMETER_TARGET := $(strip $(wildcard $(TARGET_DEVICE_DIR)/parameter/parameter*))
+
+# -----------------------------------------------------------------
+# NOTICE files
+#
+# We are required to publish the licenses for all code under BSD, GPL and
+# Apache licenses (and possibly other more exotic ones as well). We err on the
+# side of caution, so the licenses for other third-party code are included here
+# too.
+#
+# This needs to be before the systemimage rules, because it adds to
+# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
+# go into the systemimage.
+
+.PHONY: notice_files
+
+# Create the rule to combine the files into text and html forms
+# $(1) - Plain text output file
+# $(2) - HTML output file
+# $(3) - File title
+# $(4) - Directory to use. Notice files are all $(4)/src. Other
+# directories in there will be used for scratch
+# $(5) - Dependencies for the output files
+#
+# The algorithm here is that we go collect a hash for each of the notice
+# files and write the names of the files that match that hash. Then
+# to generate the real files, we go print out all of the files and their
+# hashes.
+#
+# These rules are fairly complex, so they depend on this makefile so if
+# it changes, they'll run again.
+#
+# TODO: We could clean this up so that we just record the locations of the
+# original notice files instead of making rules to copy them somwehere.
+# Then we could traverse that without quite as much bash drama.
+define combine-notice-files
+$(1) $(2): PRIVATE_MESSAGE := $(3)
+$(1) $(2): PRIVATE_DIR := $(4)
+$(1) : $(2)
+$(2) : $(5) $(BUILD_SYSTEM)/Makefile build/tools/generate-notice-files.py
+ build/tools/generate-notice-files.py $(1) $(2) $$(PRIVATE_MESSAGE) $$(PRIVATE_DIR)/src
+notice_files: $(1) $(2)
+endef
+
+# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
+# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
+# the src subdirectory.
+
+target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
+target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
+target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
+tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
+tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
+
+ifndef TARGET_BUILD_APPS
+kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
+pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES))
+
+$(eval $(call combine-notice-files, \
+ $(target_notice_file_txt), \
+ $(target_notice_file_html), \
+ "Notices for files contained in the filesystem images in this directory:", \
+ $(TARGET_OUT_NOTICE_FILES), \
+ $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)))
+
+$(eval $(call combine-notice-files, \
+ $(tools_notice_file_txt), \
+ $(tools_notice_file_html), \
+ "Notices for files contained in the tools directory:", \
+ $(HOST_OUT_NOTICE_FILES), \
+ $(ALL_DEFAULT_INSTALLED_MODULES)))
+
+# Install the html file at /system/etc/NOTICE.html.gz.
+# This is not ideal, but this is very late in the game, after a lot of
+# the module processing has already been done -- in fact, we used the
+# fact that all that has been done to get the list of modules that we
+# need notice files for.
+$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
+ $(hide) $(MINIGZIP) -9 < $< > $@
+installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
+$(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP)
+ $(copy-file-to-target)
+
+# if we've been run my mm, mmm, etc, don't reinstall this every time
+ifeq ($(ONE_SHOT_MAKEFILE),)
+ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz)
+endif
+endif # TARGET_BUILD_APPS
+
+# The kernel isn't really a module, so to get its module file in there, we
+# make the target NOTICE files depend on this particular file too, which will
+# then be in the right directory for the find in combine-notice-files to work.
+$(kernel_notice_file): \
+ prebuilts/qemu-kernel/arm/LINUX_KERNEL_COPYING \
+ | $(ACP)
+ @echo Copying: $@
+ $(hide) mkdir -p $(dir $@)
+ $(hide) $(ACP) $< $@
+
+
+# -----------------------------------------------------------------
+# Build a keystore with the authorized keys in it, used to verify the
+# authenticity of downloaded OTA packages.
+#
+# This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come
+# before the rules that use that variable to build the image.
+ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip
+$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
+$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR)) $(RADICAL_UPDATE_CERT)
+ $(hide) rm -f $@
+ $(hide) mkdir -p $(dir $@)
+ $(hide) zip -qj $@ $^
+
+.PHONY: otacerts
+otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
+
+
+# #################################################################
+# Targets for user images
+# #################################################################
+
+INTERNAL_USERIMAGES_EXT_VARIANT :=
+ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
+INTERNAL_USERIMAGES_USE_EXT := true
+INTERNAL_USERIMAGES_EXT_VARIANT := ext2
+else
+ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
+INTERNAL_USERIMAGES_USE_EXT := true
+INTERNAL_USERIMAGES_EXT_VARIANT := ext3
+else
+ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
+INTERNAL_USERIMAGES_USE_EXT := true
+INTERNAL_USERIMAGES_EXT_VARIANT := ext4
+endif
+endif
+endif
+
+# These options tell the recovery updater/installer how to mount the partitions writebale.
+# =[|]...
+# fstype_opts := [,]...
+# opt := [=]
+# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
+DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS := ext4=max_batch_time=0,commit=1,data=ordered,barrier=1,errors=panic,nodelalloc
+
+ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
+ INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
+endif
+
+ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
+INTERNAL_USERIMAGES_DEPS := $(SIMG2IMG)
+INTERNAL_USERIMAGES_DEPS += $(MKEXTUSERIMG) $(MAKE_EXT4FS) $(E2FSCK)
+ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
+INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG) $(MAKE_F2FS)
+endif
+else
+INTERNAL_USERIMAGES_DEPS := $(MKYAFFS2)
+endif
+
+INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
+
+ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY))
+INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
+endif
+
+SELINUX_FC := $(TARGET_ROOT_OUT)/file_contexts
+INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
+
+# $(1): the path of the output dictionary file
+# $(2): additional "key=value" pairs to append to the dictionary file.
+define generate-userimage-prop-dictionary
+$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
+$(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
+$(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
+$(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
+$(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
+$(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
+$(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
+$(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
+$(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
+$(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
+$(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
+$(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
+$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
+$(if $(mkyaffs2_extra_flags),$(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(1))
+$(hide) echo "selinux_fc=$(SELINUX_FC)" >> $(1)
+$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)" >> $(1))
+$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
+$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(VERITY_SIGNER)" >> $(1))
+$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
+$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
+$(if $(2),$(hide) $(foreach kv,$(2),echo "$(kv)" >> $(1);))
+endef
+
+# -----------------------------------------------------------------
+# Recovery image
+
+# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
+ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
+
+INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
+
+recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
+recovery_initrc_private := $(TARGET_DEVICE_DIR)/recovery/etc/init.rc
+recovery_initrc_private := $(if $(wildcard $(recovery_initrc_private)), $(recovery_initrc_private),\
+ device/rockchip/common/recovery/etc/init.rc)
+recovery_initrc_emmc_private := $(TARGET_DEVICE_DIR)/recovery/etc/init.bootmode.emmc.rc
+recovery_initrc_emmc_private := $(if $(wildcard $(recovery_initrc_emmc_private)), $(recovery_initrc_emmc_private),\
+ device/rockchip/common/recovery/etc/init.bootmode.emmc.rc)
+recovery_initrc_mtd_private := $(TARGET_DEVICE_DIR)/recovery/etc/init.bootmode.unknown.rc
+recovery_initrc_mtd_private := $(if $(wildcard $(recovery_initrc_mtd_private)), $(recovery_initrc_mtd_private),\
+ device/rockchip/common/recovery/etc/init.bootmode.unknown.rc)
+recovery_sepolicy := $(call intermediates-dir-for,ETC,sepolicy.recovery)/sepolicy.recovery
+recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
+recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
+recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET)
+recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery,,,$(TARGET_PREFER_32_BIT))/recovery
+recovery_resources_common := $(call include-path-for, recovery)/res
+
+# Set recovery_density to the density bucket of the device.
+recovery_density := unknown
+ifneq (,$(PRODUCT_AAPT_PREF_CONFIG))
+# If PRODUCT_AAPT_PREF_CONFIG includes a dpi bucket, then use that value.
+recovery_density := $(filter %dpi,$(PRODUCT_AAPT_PREF_CONFIG))
+else
+# Otherwise, use the default medium density.
+recovery_densities := mdpi
+endif
+
+ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
+recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
+else
+recovery_resources_common := $(recovery_resources_common)-xhdpi
+endif
+
+# Select the 18x32 font on high-density devices (xhdpi and up); and
+# the 12x22 font on other devices. Note that the font selected here
+# can be overridden for a particular device by putting a font.png in
+# its private recovery resources.
+
+ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
+recovery_font := $(call include-path-for, recovery)/fonts/18x32.png
+else
+recovery_font := $(call include-path-for, recovery)/fonts/12x22.png
+endif
+
+recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res))
+recovery_resources_private := $(if $(wildcard $(recovery_resources_private)), $(recovery_resources_private),\
+ device/rockchip/common/recovery/res)
+recovery_resource_deps := $(shell find $(recovery_resources_common) \
+ $(recovery_resources_private) -type f)
+ifdef TARGET_RECOVERY_FSTAB
+recovery_fstab := $(TARGET_RECOVERY_FSTAB)
+#---------------- TARGET_BOARD_PLATFORM
+ifeq ($(TARGET_BOARD_PLATFORM),sofia3gr)
+TARGET_FSTAB_RECOVERY_NAME_EMMC := recovery.fstab_emmc
+TARGET_FSTAB_RECOVERY_NAME_NAND := recovery.fstab_nand
+recovery_fstab_mtd := $(TARGET_RECOVERY_FSTAB_NAND)
+else
+TARGET_FSTAB_RECOVERY_NAME_EMMC := recovery.fstab
+TARGET_FSTAB_RECOVERY_NAME_NAND := recovery.fstab
+recovery_fstab_mtd := $(TARGET_RECOVERY_FSTAB)
+endif
+#---------------- TARGET_BOARD_PLATFORM
+else
+recovery_fstab :=
+recovery_fstab_mtd := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
+recovery_fstab_mtd := $(if $(wildcard $(recovery_fstab_mtd)), $(recovery_fstab_mtd),\
+ device/rockchip/common/recovery.fstab)
+recovery_fstab_emmc := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.emmc.fstab))
+recovery_fstab_emmc := $(if $(wildcard $(recovery_fstab_emmc)), $(recovery_fstab_emmc),\
+ device/rockchip/common/recovery.emmc.fstab)
+endif
+
+ifneq ($(strip $(TARGET_BOARD_PLATFORM)),sofia3gr)
+# Named '.dat' so we don't attempt to use imgdiff for patching it.
+RECOVERY_RESOURCE_ZIP := $(TARGET_OUT)/etc/recovery-resource.dat
+endif
+
+ifeq ($(TARGET_ROCKCHIP_PCBATEST),true)
+pcba_core := $(call intermediates-dir-for,EXECUTABLES,pcba_core)/pcba_core
+recovery_contents := $(TOPDIR)device/rockchip/common/recovery_contents.sh
+else
+recovery_contents := $(TOPDIR)device/rockchip/common/recovery_contents.sh
+endif
+
+ifeq ($(recovery_resources_private),)
+ $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
+endif
+
+ifeq ($(recovery_fstab_mtd),)
+ifeq ($(recovery_fstab),)
+ $(info No recovery.fstab for TARGET_DEVICE $(TARGET_DEVICE))
+endif
+endif
+
+INTERNAL_RECOVERYIMAGE_ARGS := \
+ --kernel $(recovery_kernel) \
+ --ramdisk $(recovery_ramdisk)
+
+ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
+INTERNAL_RECOVERYIMAGE_ARGS += \
+ $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
+endif
+
+# Assumes this has already been stripped
+ifdef BOARD_KERNEL_CMDLINE
+ INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
+endif
+ifdef BOARD_KERNEL_BASE
+ INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
+endif
+BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
+ifdef BOARD_KERNEL_PAGESIZE
+ INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
+endif
+
+# Keys authorized to sign OTA packages this build will accept. The
+# build always uses dev-keys for this; release packaging tools will
+# substitute other keys for this one.
+OTA_PUBLIC_KEYS := $(DEFAULT_SYSTEM_DEV_CERTIFICATE).x509.pem
+ifeq ($(RECOVERY_UPDATEIMG_RSA_CHECK),true)
+RK_PUBLIC_KEY := build/target/product/security/publicKey.bin
+else
+RK_PUBLIC_KEY :=
+endif
+
+# Generate a file containing the keys that will be read by the
+# recovery binary.
+RECOVERY_INSTALL_OTA_KEYS := \
+ $(call intermediates-dir-for,PACKAGING,ota_keys)/keys
+DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
+$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
+$(RECOVERY_INSTALL_OTA_KEYS): extra_keys := $(patsubst %,%.x509.pem,$(PRODUCT_EXTRA_RECOVERY_KEYS))
+$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) $(extra_keys) $(RK_PUBLIC_KEY) $(RADICAL_UPDATE_CERT)
+ @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys)"
+ @rm -rf $@
+ @mkdir -p $(dir $@)
+ java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) $(RADICAL_UPDATE_CERT) > $@
+
+ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
+ifeq ($(TARGET_BOARD_PLATFORM),sofia3gr)
+$(INSTALLED_RECOVERYIMAGE_TARGET): $(INSTALLED_2NDBOOTLOADER_RECOVERY_TARGET)
+else
+$(INSTALLED_RECOVERYIMAGE_TARGET): $(INSTALLED_2NDBOOTLOADER_TARGET)
+endif
+endif
+$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
+ $(INSTALLED_RAMDISK_TARGET) \
+ $(INSTALLED_BOOTIMAGE_TARGET) \
+ $(recovery_binary) \
+ $(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
+ $(recovery_build_prop) $(recovery_resource_deps) \
+ $(recovery_fstab) \
+ $(recovery_fstab_mtd) \
+ $(recovery_fstab_emmc) \
+ $(RECOVERY_INSTALL_OTA_KEYS) \
+ $(pcba_core)
+ @echo ----- Making recovery image ------
+ $(hide) rm -rf $(TARGET_RECOVERY_OUT)
+ $(hide) mkdir -p $(TARGET_RECOVERY_OUT)
+ $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc $(TARGET_RECOVERY_ROOT_OUT)/tmp
+ @echo Copying baseline ramdisk...
+ $(hide) cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
+ @echo Modifying ramdisk contents...
+ $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/init*.rc
+ $(hide) cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
+ $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/sepolicy
+ $(hide) cp -f $(recovery_sepolicy) $(TARGET_RECOVERY_ROOT_OUT)/sepolicy
+ $(hide) -cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/
+ $(hide)cp -f $(recovery_initrc_private) $(TARGET_RECOVERY_ROOT_OUT)/
+ $(hide)cp -f $(recovery_initrc_emmc_private) $(TARGET_RECOVERY_ROOT_OUT)/
+ $(hide)cp -f $(recovery_initrc_mtd_private) $(TARGET_RECOVERY_ROOT_OUT)/
+ $(hide) cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
+ $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
+ $(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
+ $(hide) cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
+ $(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
+ $(recovery_contents) $(TARGET_PRODUCT) $(PRODUCT_OUT) $(TARGET_BOARD_PLATFORM) $(TARGET_ROCKCHIP_PCBATEST) $(TARGET_ARCH)
+ $(hide) $(foreach item,$(recovery_resources_private), \
+ cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
+ $(hide) $(foreach item,$(recovery_fstab), \
+ cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/$(TARGET_FSTAB_RECOVERY_NAME_EMMC))
+ $(hide) $(foreach item,$(recovery_fstab_mtd), \
+ cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/$(TARGET_FSTAB_RECOVERY_NAME_NAND))
+ $(hide) $(foreach item,$(recovery_fstab_emmc), \
+ cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.emmc.fstab)
+ $(hide) cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
+ifeq ($(RECOVERY_UPDATEIMG_RSA_CHECK),true)
+ cp $(RK_PUBLIC_KEY) $(TARGET_RECOVERY_ROOT_OUT)/res/
+endif
+ $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
+ > $(TARGET_RECOVERY_ROOT_OUT)/default.prop
+ $(hide) $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
+ $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
+ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY))
+ $(BOOT_SIGNER) /recovery $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $@
+endif
+ $(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))
+ @echo ----- Made recovery image: $@ --------
+
+$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET)
+ $(hide) mkdir -p $(dir $@)
+ @echo "the @ is: $@"
+ $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort #| zip -0qrj $@ -@
+
+else
+INSTALLED_RECOVERYIMAGE_TARGET :=
+RECOVERY_RESOURCE_ZIP :=
+endif
+
+.PHONY: recoveryimage
+recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
+
+ifneq ($(BOARD_NAND_PAGE_SIZE),)
+mkyaffs2_extra_flags := -c $(BOARD_NAND_PAGE_SIZE)
+else
+mkyaffs2_extra_flags :=
+BOARD_NAND_PAGE_SIZE := 2048
+endif
+
+ifneq ($(BOARD_NAND_SPARE_SIZE),)
+mkyaffs2_extra_flags += -s $(BOARD_NAND_SPARE_SIZE)
+else
+BOARD_NAND_SPARE_SIZE := 64
+endif
+
+# -----------------------------------------------------------------
+# system image
+#
+# Remove overridden packages from $(ALL_PDK_FUSION_FILES)
+PDK_FUSION_SYSIMG_FILES := \
+ $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
+ $(ALL_PDK_FUSION_FILES))
+
+INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
+ $(ALL_PREBUILT) \
+ $(ALL_COPIED_HEADERS) \
+ $(ALL_GENERATED_SOURCES) \
+ $(ALL_DEFAULT_INSTALLED_MODULES) \
+ $(PDK_FUSION_SYSIMG_FILES) \
+ $(RECOVERY_RESOURCE_ZIP))
+
+FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
+# -----------------------------------------------------------------
+# installed file list
+# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
+# We put installed-files.txt ahead of image itself in the dependency graph
+# so that we can get the size stat even if the build fails due to too large
+# system image.
+INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
+$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS)
+ @echo Installed file list: $@
+ @mkdir -p $(dir $@)
+ @rm -f $@
+ $(hide) build/tools/fileslist.py $(TARGET_OUT) > $@
+
+.PHONY: installed-file-list
+installed-file-list: $(INSTALLED_FILES_FILE)
+
+$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
+
+systemimage_intermediates := \
+ $(call intermediates-dir-for,PACKAGING,systemimage)
+BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
+
+# Create symlink /system/vendor to /vendor if necessary.
+ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
+define create-system-vendor-symlink
+$(hide) if [ -d $(TARGET_OUT)/vendor ] && [ ! -h $(TARGET_OUT)/vendor ]; then \
+ echo 'Non-symlink $(TARGET_OUT)/vendor detected!' 1>&2; \
+ echo 'You cannot install files to $(TARGET_OUT)/vendor while building a separate vendor.img!' 1>&2; \
+ exit 1; \
+fi
+$(hide) ln -sf /vendor $(TARGET_OUT)/vendor
+endef
+else
+define create-system-vendor-symlink
+endef
+endif
+
+# $(1): output file
+define build-systemimage-target
+ @echo "Target system fs image: $(1)"
+ $(call create-system-vendor-symlink)
+ @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
+ $(call generate-userimage-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt, \
+ skip_fsck=true)
+ $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
+ ./build/tools/releasetools/build_image.py \
+ $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) \
+ || ( echo "Out of space? the tree size of $(TARGET_OUT) is (MB): " 1>&2 ;\
+ du -sm $(TARGET_OUT) 1>&2;\
+ echo "The max is $$(( $(BOARD_SYSTEMIMAGE_PARTITION_SIZE) / 1048576 )) MB." 1>&2 ;\
+ mkdir -p $(DIST_DIR); cp $(INSTALLED_FILES_FILE) $(DIST_DIR)/installed-files-rescued.txt; \
+ exit 1 )
+endef
+
+$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
+ $(call build-systemimage-target,$@)
+
+INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
+SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
+
+# The system partition needs room for the recovery image as well. We
+# now store the recovery image as a binary patch using the boot image
+# as the source (since they are very similar). Generate the patch so
+# we can see how big it's going to be, and include that in the system
+# image size check calculation.
+ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
+intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
+RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
+$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
+ $(INSTALLED_BOOTIMAGE_TARGET) \
+ $(HOST_OUT_EXECUTABLES)/imgdiff \
+ $(HOST_OUT_EXECUTABLES)/bsdiff
+ @echo "Construct recovery from boot"
+ mkdir -p $(dir $@)
+ PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
+endif
+
+
+$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
+ @echo "Install system fs image: $@"
+ $(copy-file-to-target)
+ $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
+
+systemimage: $(INSTALLED_SYSTEMIMAGE)
+
+.PHONY: systemimage-nodeps snod
+systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
+ | $(INTERNAL_USERIMAGES_DEPS)
+ @echo "make $@: ignoring dependencies"
+ $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
+ $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
+
+ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS)))
+ifeq (true,$(WITH_DEXPREOPT))
+$(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
+endif
+endif
+
+#######
+## system tarball
+define build-systemtarball-target
+ $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)")
+ $(call create-system-vendor-symlink)
+ $(MKTARBALL) $(FS_GET_STATS) \
+ $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \
+ $(INSTALLED_SYSTEMTARBALL_TARGET)
+endef
+
+ifndef SYSTEM_TARBALL_FORMAT
+ SYSTEM_TARBALL_FORMAT := bz2
+endif
+
+system_tar := $(PRODUCT_OUT)/system.tar
+INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
+$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
+$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
+ $(build-systemtarball-target)
+
+.PHONY: systemtarball-nodeps
+systemtarball-nodeps: $(FS_GET_STATS) \
+ $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS))
+ $(build-systemtarball-target)
+
+.PHONY: stnod
+stnod: systemtarball-nodeps
+
+#######
+## platform.zip: system, plus other files to be used in PDK fusion build,
+## in a zip file
+##
+## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip.
+## The variable will be typically set from BoardConfig.mk.
+## Files under out dir will be rejected to prevent possible conflicts with other rules.
+PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))
+INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
+$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES)
+ $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
+ $(hide) rm -f $@
+ $(hide) cd $(dir $@) && zip -qry $(notdir $@) \
+ $(TARGET_COPY_OUT_SYSTEM) \
+ $(patsubst $(PRODUCT_OUT)/%, %, $(TARGET_OUT_NOTICE_FILES)) \
+ $(addprefix symbols/,$(PDK_SYMBOL_FILES_LIST))
+ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
+ $(hide) cd $(dir $@) && zip -qry $(notdir $@) \
+ $(TARGET_COPY_OUT_VENDOR)
+endif
+ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),)
+ $(hide) cd $(OUT_DIR) && zip -qry $(patsubst $(OUT_DIR)/%,%,$@) $(PDK_PLATFORM_JAVA_ZIP_CONTENTS)
+endif
+ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
+ $(hide) zip -qry $@ $(PDK_PLATFORM_ZIP_PRODUCT_BINARIES)
+endif
+
+.PHONY: platform
+platform: $(INSTALLED_PLATFORM_ZIP)
+
+.PHONY: platform-java
+platform-java: platform
+
+# Dist the platform.zip
+ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
+$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
+endif
+
+#######
+## boot tarball
+define build-boottarball-target
+ $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
+ $(hide) mkdir -p $(PRODUCT_OUT)/boot
+ $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
+ $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
+ $(hide) $(MKTARBALL) $(FS_GET_STATS) \
+ $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
+ $(INSTALLED_BOOTTARBALL_TARGET)
+endef
+
+ifndef BOOT_TARBALL_FORMAT
+ BOOT_TARBALL_FORMAT := bz2
+endif
+
+boot_tar := $(PRODUCT_OUT)/boot.tar
+INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
+$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
+$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
+ $(build-boottarball-target)
+
+.PHONY: boottarball-nodeps btnod
+boottarball-nodeps btnod: $(FS_GET_STATS) \
+ $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
+ $(build-boottarball-target)
+
+
+# -----------------------------------------------------------------
+# data partition image
+INTERNAL_USERDATAIMAGE_FILES := \
+ $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
+
+# Don't build userdata.img if it's extfs but no partition size
+skip_userdata.img :=
+ifdef INTERNAL_USERIMAGES_EXT_VARIANT
+ifndef BOARD_USERDATAIMAGE_PARTITION_SIZE
+skip_userdata.img := true
+endif
+endif
+
+ifneq ($(skip_userdata.img),true)
+userdataimage_intermediates := \
+ $(call intermediates-dir-for,PACKAGING,userdata)
+BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
+
+define build-userdataimage-target
+ $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
+ @mkdir -p $(TARGET_OUT_DATA)
+ @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
+ $(call generate-userimage-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt, skip_fsck=true)
+ $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
+ ./build/tools/releasetools/build_image.py \
+ $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt $(INSTALLED_USERDATAIMAGE_TARGET)
+ $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
+endef
+
+# We just build this directly to the install location.
+INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
+$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \
+ $(INTERNAL_USERDATAIMAGE_FILES)
+ $(build-userdataimage-target)
+
+.PHONY: userdataimage-nodeps
+userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
+ $(build-userdataimage-target)
+
+endif # not skip_userdata.img
+skip_userdata.img :=
+
+#######
+## data partition tarball
+define build-userdatatarball-target
+ $(call pretty,"Target userdata fs tarball: " \
+ "$(INSTALLED_USERDATATARBALL_TARGET)")
+ $(MKTARBALL) $(FS_GET_STATS) \
+ $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \
+ $(INSTALLED_USERDATATARBALL_TARGET)
+endef
+
+userdata_tar := $(PRODUCT_OUT)/userdata.tar
+INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2
+$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar)
+$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES)
+ $(build-userdatatarball-target)
+
+.PHONY: userdatatarball-nodeps
+userdatatarball-nodeps: $(FS_GET_STATS)
+ $(build-userdatatarball-target)
+
+
+# -----------------------------------------------------------------
+# cache partition image
+ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
+INTERNAL_CACHEIMAGE_FILES := \
+ $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
+
+cacheimage_intermediates := \
+ $(call intermediates-dir-for,PACKAGING,cache)
+BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
+
+define build-cacheimage-target
+ $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
+ @mkdir -p $(TARGET_OUT_CACHE)
+ @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
+ $(call generate-userimage-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt, skip_fsck=true)
+ $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
+ ./build/tools/releasetools/build_image.py \
+ $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt $(INSTALLED_CACHEIMAGE_TARGET)
+ $(hide) $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
+endef
+
+# We just build this directly to the install location.
+INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
+$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
+ $(build-cacheimage-target)
+
+.PHONY: cacheimage-nodeps
+cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
+ $(build-cacheimage-target)
+
+endif # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
+
+
+# -----------------------------------------------------------------
+# vendor partition image
+ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
+INTERNAL_VENDORIMAGE_FILES := \
+ $(filter $(TARGET_OUT_VENDOR)/%,\
+ $(ALL_DEFAULT_INSTALLED_MODULES)\
+ $(ALL_PDK_FUSION_FILES))
+
+# platform.zip depends on $(INTERNAL_VENDORIMAGE_FILES).
+$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES)
+
+vendorimage_intermediates := \
+ $(call intermediates-dir-for,PACKAGING,vendor)
+BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
+
+define build-vendorimage-target
+ $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
+ @mkdir -p $(TARGET_OUT_VENDOR)
+ @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
+ $(call generate-userimage-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt, skip_fsck=true)
+ $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
+ ./build/tools/releasetools/build_image.py \
+ $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt $(INSTALLED_VENDORIMAGE_TARGET)
+ $(hide) $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
+endef
+
+# We just build this directly to the install location.
+INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
+$(INSTALLED_VENDORIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES)
+ $(build-vendorimage-target)
+
+.PHONY: vendorimage-nodeps
+vendorimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
+ $(build-vendorimage-target)
+
+endif # BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
+
+# -----------------------------------------------------------------
+# bring in the installer image generation defines if necessary
+ifeq ($(TARGET_USE_DISKINSTALLER),true)
+include bootable/diskinstaller/config.mk
+endif
+
+ifeq ($(strip $(TARGET_USE_USERFASTBOOT)),true)
+include bootable/userfastboot/ramdisk.mk
+endif
+
+# -----------------------------------------------------------------
+# host tools needed to build dist and OTA packages
+
+DISTTOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \
+ $(HOST_OUT_EXECUTABLES)/mkbootfs \
+ $(HOST_OUT_EXECUTABLES)/mkbootimg \
+ $(HOST_OUT_EXECUTABLES)/fs_config \
+ $(HOST_OUT_EXECUTABLES)/mkyaffs2image \
+ $(HOST_OUT_EXECUTABLES)/zipalign \
+ $(HOST_OUT_EXECUTABLES)/bsdiff \
+ $(HOST_OUT_EXECUTABLES)/imgdiff \
+ $(HOST_OUT_EXECUTABLES)/remkloader \
+ $(HOST_OUT_EXECUTABLES)/mkparameter \
+ $(HOST_OUT_EXECUTABLES)/drmsigntool \
+ $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
+ $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
+ $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
+ $(HOST_OUT_EXECUTABLES)/make_ext4fs \
+ $(HOST_OUT_EXECUTABLES)/simg2img \
+ $(HOST_OUT_EXECUTABLES)/e2fsck \
+ $(HOST_OUT_EXECUTABLES)/build_verity_tree \
+ $(HOST_OUT_EXECUTABLES)/verity_signer \
+ $(HOST_OUT_EXECUTABLES)/append2simg \
+ $(HOST_OUT_EXECUTABLES)/boot_signer
+
+OTATOOLS := $(DISTTOOLS) \
+ $(HOST_OUT_EXECUTABLES)/aapt
+
+.PHONY: otatools
+otatools: $(OTATOOLS)
+
+# -----------------------------------------------------------------
+# A zip of the directories that map to the target filesystem.
+# This zip can be used to create an OTA package or filesystem image
+# as a post-build step.
+#
+name := $(TARGET_PRODUCT)
+ifeq ($(TARGET_BUILD_TYPE),debug)
+ name := $(name)_debug
+endif
+name := $(name)-target_files-$(FILE_NAME_TAG)
+
+intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
+BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
+$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
+$(BUILT_TARGET_FILES_PACKAGE): \
+ zip_root := $(intermediates)/$(name)
+
+# $(1): Directory to copy
+# $(2): Location to copy it to
+# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
+define package_files-copy-root
+ if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
+ mkdir -p $(2) && \
+ $(ACP) -rd $(strip $(1))/* $(2); \
+ fi
+endef
+
+built_ota_tools := \
+ $(call intermediates-dir-for,EXECUTABLES,applypatch,,,$(TARGET_PREFER_32_BIT))/applypatch \
+ $(call intermediates-dir-for,EXECUTABLES,applypatch_static,,,$(TARGET_PREFER_32_BIT))/applypatch_static \
+ $(call intermediates-dir-for,EXECUTABLES,check_prereq,,,$(TARGET_PREFER_32_BIT))/check_prereq \
+ $(call intermediates-dir-for,EXECUTABLES,sqlite3,,,$(TARGET_PREFER_32_BIT))/sqlite3 \
+ $(call intermediates-dir-for,EXECUTABLES,updater,,,$(TARGET_PREFER_32_BIT))/updater
+$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
+
+$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
+$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_FSTAB_VERSION := $(RECOVERY_FSTAB_VERSION)
+
+ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
+# default to common dir for device vendor
+$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common
+else
+$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
+endif
+
+# Depending on the various images guarantees that the underlying
+# directories are up-to-date.
+$(BUILT_TARGET_FILES_PACKAGE): \
+ $(INSTALLED_BOOTIMAGE_TARGET) \
+ $(INSTALLED_RADIOIMAGE_TARGET) \
+ $(INSTALLED_LOADER_TARGET) \
+ $(INSTALLED_UBOOT_TARGET) \
+ $(INSTALLED_CHARGE_TARGET) \
+ $(INSTALLED_PARAMETER_TARGET) \
+ $(INSTALLED_RECOVERYIMAGE_TARGET) \
+ $(INSTALLED_SYSTEMIMAGE) \
+ $(INSTALLED_USERDATAIMAGE_TARGET) \
+ $(INSTALLED_CACHEIMAGE_TARGET) \
+ $(INSTALLED_VENDORIMAGE_TARGET) \
+ $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
+ $(SELINUX_FC) \
+ $(built_ota_tools) \
+ $(APKCERTS_FILE) \
+ $(HOST_OUT_EXECUTABLES)/fs_config \
+ | $(ACP)
+ @echo "Package target files: $@"
+ $(hide) rm -rf $@ $(zip_root)
+ $(hide) mkdir -p $(dir $@) $(zip_root)
+ @# Components of the recovery image
+ $(hide) mkdir -p $(zip_root)/RECOVERY
+ $(hide) $(call package_files-copy-root, \
+ $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
+ifdef INSTALLED_KERNEL_TARGET
+ $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
+endif
+ifdef INSTALLED_2NDBOOTLOADER_TARGET
+ifeq ($(TARGET_BOARD_PLATFORM),sofia3gr)
+ $(hide) $(ACP) \
+ $(INSTALLED_2NDBOOTLOADER_RECOVERY_TARGET) $(zip_root)/RECOVERY/second
+else
+ $(hide) $(ACP) \
+ $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
+endif
+endif
+ifdef BOARD_KERNEL_CMDLINE
+ $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
+endif
+ifdef BOARD_KERNEL_BASE
+ $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
+endif
+ifdef BOARD_KERNEL_PAGESIZE
+ $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
+endif
+ @# Components of the boot image
+ $(hide) mkdir -p $(zip_root)/BOOT
+ $(hide) $(call package_files-copy-root, \
+ $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
+ifdef INSTALLED_KERNEL_TARGET
+ $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
+endif
+ifdef INSTALLED_2NDBOOTLOADER_TARGET
+ $(hide) $(ACP) \
+ $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
+endif
+
+ifdef INSTALLED_3NDBOOTLOADER_TARGET
+ifeq ($(TARGET_BOARD_PLATFORM),sofia3gr)
+ $(hide) $(ACP) \
+ $(INSTALLED_3NDBOOTLOADER_TARGET) $(zip_root)/BOOT/third
+endif
+endif
+
+ifdef BOARD_KERNEL_CMDLINE
+ $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
+endif
+ifdef BOARD_KERNEL_BASE
+ $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
+endif
+ifdef BOARD_KERNEL_PAGESIZE
+ $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
+endif
+ $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
+ mkdir -p $(zip_root)/RADIO; \
+ $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
+ifeq ($(INSTALLED_LOADER_TARGET),)
+ $(info No RK Loader for TARGET_DEVICE $(TARGET_DEVICE) to otapackage)
+else
+ @# Contents of the rk loader bin
+ $(hide) mkdir -p $(zip_root)/LOADER
+ $(hide) $(HOST_OUT_EXECUTABLES)/remkloader '$(INSTALLED_LOADER_TARGET)' $(INSTALLED_NEW_LOADER_TARGET)
+ $(hide) cat $(INSTALLED_LOADER_MISC_TARGET) $(INSTALLED_NEW_LOADER_TARGET) > $(zip_root)/LOADER/RKLoader.img
+endif
+
+ifdef TARGET_PREBUILT_RESOURCE
+ $(info package add resource.img to BOOT and RECOVERY)
+ $(hide) cp $(TARGET_PREBUILT_RESOURCE) $(zip_root)/BOOT/resource.img
+ $(hide) cp $(TARGET_PREBUILT_RESOURCE) $(zip_root)/RECOVERY/resource.img
+endif
+
+ifeq ($(INSTALLED_UBOOT_TARGET),)
+ $(info No uboot for uboot/uboot.img to otapackage)
+else
+ $(hide) cp $(INSTALLED_UBOOT_TARGET) $(zip_root)/uboot.img
+endif
+
+ifeq ($(INSTALLED_TRUST_TARHET),)
+ $(info No trust for uboot/trust.img to otapackage)
+else
+ $(hide) cp $(INSTALLED_TRUST_TARHET) $(zip_root)/trust.img
+endif
+
+ifeq ($(INSTALLED_CHARGE_TARGET),)
+ $(info No charge for uboot/charge.img to otapackage)
+else
+ $(hide) cp $(INSTALLED_CHARGE_TARGET) $(zip_root)/charge.img
+endif
+
+ifeq ($(INSTALLED_PARAMETER_TARGET),)
+ $(info No parameter for TARGET_DEVICE $(TARGET_DEVICE) to otapackage)
+else
+ $(hide) rm -rf $(zip_root)/PARAMETER
+ $(hide) mkdir -p $(zip_root)/PARAMETER
+ $(hide) $(HOST_OUT_EXECUTABLES)/mkparameter '$(INSTALLED_PARAMETER_TARGET)' $(zip_root)/PARAMETER/parameter
+endif
+
+ @# Contents of the system image
+ $(hide) $(call package_files-copy-root, \
+ $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
+ @# Contents of the data image
+ $(hide) $(call package_files-copy-root, \
+ $(TARGET_OUT_DATA),$(zip_root)/DATA)
+ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
+ @# Contents of the vendor image
+ $(hide) $(call package_files-copy-root, \
+ $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
+endif
+ @# Extra contents of the OTA package
+ $(hide) mkdir -p $(zip_root)/OTA/bin
+ $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
+ $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
+ @# Files that do not end up in any images, but are necessary to
+ @# build them.
+ $(hide) mkdir -p $(zip_root)/META
+ $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
+ $(hide) if test -e $(tool_extensions)/releasetools.py; then $(ACP) $(tool_extensions)/releasetools.py $(zip_root)/META/; fi
+ $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
+ $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
+ $(hide) echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(zip_root)/META/misc_info.txt
+ifdef BOARD_FLASH_BLOCK_SIZE
+ $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt
+endif
+ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
+ $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
+endif
+ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
+ $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
+endif
+ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
+ @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
+ $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt
+else
+ $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt
+endif
+ $(hide) echo "tool_extensions=$(tool_extensions)/releasetools.py" >> $(zip_root)/META/misc_info.txt
+ $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(zip_root)/META/misc_info.txt
+ifdef PRODUCT_EXTRA_RECOVERY_KEYS
+ $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt
+endif
+ $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $(zip_root)/META/misc_info.txt
+ $(hide) echo "use_set_metadata=1" >> $(zip_root)/META/misc_info.txt
+ $(hide) echo "multistage_support=1" >> $(zip_root)/META/misc_info.txt
+ $(hide) echo "update_rename_support=1" >> $(zip_root)/META/misc_info.txt
+ $(hide) echo "blockimgdiff_versions=1,2" >> $(zip_root)/META/misc_info.txt
+ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
+ # OTA scripts are only interested in fingerprint related properties
+ $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $(zip_root)/META/misc_info.txt
+endif
+ $(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
+ifneq ($(strip $(TARGET_BOARD_PLATFORM)),sofia3gr)
+ $(hide) ./build/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root)
+endif
+ @# Zip everything up, preserving symlinks
+ $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
+ @# Run fs_config on all the system, vendor, boot ramdisk,
+ @# and recovery ramdisk files in the zip, and save the output
+ $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="SYSTEM/" } /^SYSTEM\// {print "system/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/filesystem_config.txt
+ $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="VENDOR/" } /^VENDOR\// {print "vendor/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/vendor_filesystem_config.txt
+ $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/boot_filesystem_config.txt
+ $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="RECOVERY/RAMDISK/" } /^RECOVERY\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/recovery_filesystem_config.txt
+ $(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/*filesystem_config.txt)
+ $(hide) ./build/tools/releasetools/add_img_to_target_files -p $(HOST_OUT) $@
+
+.PHONY: target-files-package
+target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
+
+ifneq ($(filter $(MAKECMDGOALS),target-files-package),)
+$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
+endif
+
+ifneq ($(TARGET_PRODUCT),sdk)
+ifeq ($(filter generic%,$(TARGET_DEVICE)),)
+ifneq ($(TARGET_NO_KERNEL),true)
+ifneq ($(recovery_fstab_mtd),)
+
+# -----------------------------------------------------------------
+# OTA update package
+
+name := $(TARGET_PRODUCT)
+ifeq ($(TARGET_BUILD_TYPE),debug)
+ name := $(name)_debug
+endif
+name := $(name)-ota-$(FILE_NAME_TAG)
+
+INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
+
+$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
+
+$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
+ @echo "Package OTA: $@"
+ $(hide) MKBOOTIMG=$(MKBOOTIMG) \
+ ./build/tools/releasetools/ota_from_target_files -v \
+ -p $(HOST_OUT) \
+ -k $(KEY_CERT_PAIR) \
+ $(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \
+ $(BUILT_TARGET_FILES_PACKAGE) $@
+
+.PHONY: otapackage
+otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
+
+endif # recovery_fstab is defined
+endif # TARGET_NO_KERNEL != true
+endif # TARGET_DEVICE != generic*
+endif # TARGET_PRODUCT != sdk
+
+# -----------------------------------------------------------------
+# The update package
+
+name := $(TARGET_PRODUCT)
+ifeq ($(TARGET_BUILD_TYPE),debug)
+ name := $(name)_debug
+endif
+name := $(name)-img-$(FILE_NAME_TAG)
+
+INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
+
+$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
+ @echo "Package: $@"
+ $(hide) MKBOOTIMG=$(MKBOOTIMG) \
+ ./build/tools/releasetools/img_from_target_files -v \
+ -p $(HOST_OUT) \
+ $(BUILT_TARGET_FILES_PACKAGE) $@
+
+.PHONY: updatepackage
+updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
+
+# -----------------------------------------------------------------
+# A zip of the symbols directory. Keep the full paths to make it
+# more obvious where these files came from.
+#
+name := $(TARGET_PRODUCT)
+ifeq ($(TARGET_BUILD_TYPE),debug)
+ name := $(name)_debug
+endif
+name := $(name)-symbols-$(FILE_NAME_TAG)
+
+SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
+# For apps_only build we'll establish the dependency later in build/core/main.mk.
+ifndef TARGET_BUILD_APPS
+$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
+endif
+$(SYMBOLS_ZIP):
+ @echo "Package symbols: $@"
+ $(hide) rm -rf $@
+ $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED)
+ $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED)
+
+# -----------------------------------------------------------------
+# A zip of the Android Apps. Not keeping full path so that we don't
+# include product names when distributing
+#
+name := $(TARGET_PRODUCT)
+ifeq ($(TARGET_BUILD_TYPE),debug)
+ name := $(name)_debug
+endif
+name := $(name)-apps-$(FILE_NAME_TAG)
+
+APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
+$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
+ @echo "Package apps: $@"
+ $(hide) rm -rf $@
+ $(hide) mkdir -p $(dir $@)
+ $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*/*.apk $(TARGET_OUT_APPS_PRIVILEGED)/*/*.apk
+
+
+#------------------------------------------------------------------
+# A zip of emma code coverage meta files. Generated for fully emma
+# instrumented build.
+#
+ifeq (true,$(EMMA_INSTRUMENT))
+EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip
+# the dependency will be set up later in build/core/main.mk.
+$(EMMA_META_ZIP) :
+ @echo "Collecting Emma coverage meta files."
+ $(hide) find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "coverage.em" | \
+ zip -@ -q $@
+
+endif # EMMA_INSTRUMENT=true
+
+#------------------------------------------------------------------
+# A zip of Proguard obfuscation dictionary files.
+# Only for apps_only build.
+#
+ifdef TARGET_BUILD_APPS
+PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
+# the dependency will be set up later in build/core/main.mk.
+$(PROGUARD_DICT_ZIP) :
+ @echo "Packaging Proguard obfuscation dictionary files."
+ $(hide) dict_files=`find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary`; \
+ if [ -n "$$dict_files" ]; then \
+ unobfuscated_jars=$${dict_files//proguard_dictionary/classes.jar}; \
+ zip -q $@ $$dict_files $$unobfuscated_jars; \
+ else \
+ touch $(dir $@)/dummy; \
+ (cd $(dir $@) && zip -q $(notdir $@) dummy); \
+ zip -qd $@ dummy; \
+ rm $(dir $@)/dummy; \
+ fi
+
+endif # TARGET_BUILD_APPS
+
+# -----------------------------------------------------------------
+# dalvik something
+.PHONY: dalvikfiles
+dalvikfiles: $(INTERNAL_DALVIK_MODULES)
+
+# -----------------------------------------------------------------
+# The emulator package
+ifeq ($(BUILD_EMULATOR),true)
+INTERNAL_EMULATOR_PACKAGE_FILES += \
+ $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
+ prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
+ $(INSTALLED_RAMDISK_TARGET) \
+ $(INSTALLED_SYSTEMIMAGE) \
+ $(INSTALLED_USERDATAIMAGE_TARGET)
+
+name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
+
+INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
+
+$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
+ @echo "Package: $@"
+ $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
+
+endif
+# -----------------------------------------------------------------
+# Old PDK stuffs, retired
+# The pdk package (Platform Development Kit)
+
+#ifneq (,$(filter pdk,$(MAKECMDGOALS)))
+# include development/pdk/Pdk.mk
+#endif
+
+
+# -----------------------------------------------------------------
+# The SDK
+
+# The SDK includes host-specific components, so it belongs under HOST_OUT.
+sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
+
+# Build a name that looks like:
+#
+# linux-x86 --> android-sdk_12345_linux-x86
+# darwin-x86 --> android-sdk_12345_mac-x86
+# windows-x86 --> android-sdk_12345_windows
+#
+sdk_name := android-sdk_$(FILE_NAME_TAG)
+ifeq ($(HOST_OS),darwin)
+ INTERNAL_SDK_HOST_OS_NAME := mac
+else
+ INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
+endif
+ifneq ($(HOST_OS),windows)
+ INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
+endif
+sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
+
+sdk_dep_file := $(sdk_dir)/sdk_deps.mk
+
+ATREE_FILES :=
+-include $(sdk_dep_file)
+
+# if we don't have a real list, then use "everything"
+ifeq ($(strip $(ATREE_FILES)),)
+ATREE_FILES := \
+ $(ALL_PREBUILT) \
+ $(ALL_COPIED_HEADERS) \
+ $(ALL_DEFAULT_INSTALLED_MODULES) \
+ $(INSTALLED_RAMDISK_TARGET) \
+ $(ALL_DOCS) \
+ $(ALL_SDK_FILES)
+endif
+
+atree_dir := development/build
+
+
+sdk_atree_files := \
+ $(atree_dir)/sdk.exclude.atree \
+ $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
+
+# development/build/sdk-android-.atree is used to differentiate
+# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
+# files like the kernel image. We use TARGET_CPU_ABI because we don't
+# have a better way to distinguish between CPU models.
+ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
+ sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
+endif
+
+ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES),)
+sdk_atree_files += $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES)
+else
+sdk_atree_files += $(atree_dir)/sdk.atree
+endif
+
+include $(BUILD_SYSTEM)/sdk_font.mk
+
+deps := \
+ $(target_notice_file_txt) \
+ $(tools_notice_file_txt) \
+ $(OUT_DOCS)/offline-sdk-timestamp \
+ $(SYMBOLS_ZIP) \
+ $(INSTALLED_SYSTEMIMAGE) \
+ $(INSTALLED_USERDATAIMAGE_TARGET) \
+ $(INSTALLED_RAMDISK_TARGET) \
+ $(INSTALLED_SDK_BUILD_PROP_TARGET) \
+ $(INSTALLED_BUILD_PROP_TARGET) \
+ $(ATREE_FILES) \
+ $(sdk_atree_files) \
+ $(HOST_OUT_EXECUTABLES)/atree \
+ $(HOST_OUT_EXECUTABLES)/line_endings \
+ $(SDK_FONT_DEPS)
+
+INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
+$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
+$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
+$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
+$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
+
+# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
+#
+#SDK_GNU_ERROR := true
+
+$(INTERNAL_SDK_TARGET): $(deps)
+ @echo "Package SDK: $@"
+ $(hide) rm -rf $(PRIVATE_DIR) $@
+ $(hide) for f in $(target_gnu_MODULES); do \
+ if [ -f $$f ]; then \
+ echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
+ including GNU target $$f >&2; \
+ FAIL=$(SDK_GNU_ERROR); \
+ fi; \
+ done; \
+ if [ $$FAIL ]; then exit 1; fi
+ $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
+ $(hide) ( \
+ ATREE_STRIP="strip -x" \
+ $(HOST_OUT_EXECUTABLES)/atree \
+ $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
+ -m $(PRIVATE_DEP_FILE) \
+ -I . \
+ -I $(PRODUCT_OUT) \
+ -I $(HOST_OUT) \
+ -I $(TARGET_COMMON_OUT_ROOT) \
+ -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
+ -v "OUT_DIR=$(OUT_DIR)" \
+ -v "HOST_OUT=$(HOST_OUT)" \
+ -v "TARGET_ARCH=$(TARGET_ARCH)" \
+ -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
+ -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
+ -v "FONT_OUT=$(SDK_FONT_TEMP)" \
+ -o $(PRIVATE_DIR) && \
+ cp -f $(target_notice_file_txt) \
+ $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
+ cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
+ HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
+ development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
+ chmod -R ug+rwX $(PRIVATE_DIR) && \
+ cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
+ ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
+
+
+# Is a Windows SDK requested? If so, we need some definitions from here
+# in order to find the Linux SDK used to create the Windows one.
+MAIN_SDK_NAME := $(sdk_name)
+MAIN_SDK_DIR := $(sdk_dir)
+MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
+ifneq ($(filter win_sdk,$(MAKECMDGOALS)),)
+include $(TOPDIR)development/build/tools/windows_sdk.mk
+endif
+
+# -----------------------------------------------------------------
+# Findbugs
+INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
+INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
+$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
+ @echo UnionBugs: $@
+ $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
+ > $@
+$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
+ @echo ConvertXmlToText: $@
+ $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
+ $(INTERNAL_FINDBUGS_XML_TARGET) > $@
+
+# -----------------------------------------------------------------
+# Findbugs
+
+# -----------------------------------------------------------------
+# These are some additional build tasks that need to be run.
+ifneq ($(dont_bother),true)
+include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
+-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
+-include $(sort $(wildcard device/*/build/tasks/*.mk))
+# Also the project-specific tasks
+-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
+-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
+endif
+
+# -----------------------------------------------------------------
+# Create SDK repository packages. Must be done after tasks/* since
+# we need the addon rules defined.
+ifneq ($(sdk_repo_goal),)
+include $(TOPDIR)development/build/tools/sdk_repo.mk
+endif
diff --git a/build/core/android_manifest.mk b/build/core/android_manifest.mk
new file mode 100644
index 0000000..c641b75
--- /dev/null
+++ b/build/core/android_manifest.mk
@@ -0,0 +1,39 @@
+# Handle AndroidManifest.xmls
+# Input: LOCAL_MANIFEST_FILE, LOCAL_FULL_MANIFEST_FILE, LOCAL_FULL_LIBS_MANIFEST_FILES
+# Output: full_android_manifest
+
+ifeq ($(strip $(LOCAL_MANIFEST_FILE)),)
+ LOCAL_MANIFEST_FILE := AndroidManifest.xml
+endif
+ifdef LOCAL_FULL_MANIFEST_FILE
+ full_android_manifest := $(LOCAL_FULL_MANIFEST_FILE)
+else
+ full_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE)
+endif
+
+my_full_libs_manifest_files := $(LOCAL_FULL_LIBS_MANIFEST_FILES)
+my_full_libs_manifest_deps := $(LOCAL_FULL_LIBS_MANIFEST_FILES)
+
+# Set up dependency on aar libraries
+ifdef LOCAL_STATIC_JAVA_AAR_LIBRARIES
+my_full_libs_manifest_deps += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),\
+ $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/classes.jar)
+my_full_libs_manifest_files += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),\
+ $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/AndroidManifest.xml)
+
+LOCAL_RESOURCE_DIR += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),\
+ $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/res)
+endif
+
+# Set up rules to merge library manifest files
+ifdef my_full_libs_manifest_files
+main_android_manifest := $(full_android_manifest)
+full_android_manifest := $(intermediates.COMMON)/AndroidManifest.xml
+$(full_android_manifest): PRIVATE_LIBS_MANIFESTS := $(my_full_libs_manifest_files)
+$(full_android_manifest) : $(main_android_manifest) $(my_full_libs_manifest_deps)
+ @echo "Merge android manifest files: $@ <-- $< $(PRIVATE_LIBS_MANIFESTS)"
+ @mkdir -p $(dir $@)
+ $(hide) $(ANDROID_MANIFEST_MERGER) --main $< --libs $(PRIVATE_LIBS_MANIFESTS) \
+ --out $@
+
+endif
diff --git a/build/core/apicheck_msg_current.txt b/build/core/apicheck_msg_current.txt
new file mode 100644
index 0000000..440e7f8
--- /dev/null
+++ b/build/core/apicheck_msg_current.txt
@@ -0,0 +1,17 @@
+
+******************************
+You have tried to change the API from what has been previously approved.
+
+To make these errors go away, you have two choices:
+ 1) You can add "@hide" javadoc comments to the methods, etc. listed in the
+ errors above.
+
+ 2) You can update current.txt by executing the following command:
+ make update-api
+
+ To submit the revised current.txt to the main Android repository,
+ you will need approval.
+******************************
+
+
+
diff --git a/build/core/apicheck_msg_last.txt b/build/core/apicheck_msg_last.txt
new file mode 100644
index 0000000..2993157
--- /dev/null
+++ b/build/core/apicheck_msg_last.txt
@@ -0,0 +1,7 @@
+
+******************************
+You have tried to change the API from what has been previously released in
+an SDK. Please fix the errors listed above.
+******************************
+
+
diff --git a/build/core/base_rules.mk b/build/core/base_rules.mk
new file mode 100644
index 0000000..8c25897
--- /dev/null
+++ b/build/core/base_rules.mk
@@ -0,0 +1,690 @@
+#
+# Copyright (C) 2008 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.
+#
+
+# Users can define base-rules-hook in their buildspec.mk to perform
+# arbitrary operations as each module is included.
+ifdef base-rules-hook
+$(if $(base-rules-hook),)
+endif
+
+###########################################################
+## Common instructions for a generic module.
+###########################################################
+
+LOCAL_MODULE := $(strip $(LOCAL_MODULE))
+ifeq ($(LOCAL_MODULE),)
+ $(error $(LOCAL_PATH): LOCAL_MODULE is not defined)
+endif
+
+LOCAL_IS_HOST_MODULE := $(strip $(LOCAL_IS_HOST_MODULE))
+ifdef LOCAL_IS_HOST_MODULE
+ ifneq ($(LOCAL_IS_HOST_MODULE),true)
+ $(error $(LOCAL_PATH): LOCAL_IS_HOST_MODULE must be "true" or empty, not "$(LOCAL_IS_HOST_MODULE)")
+ endif
+ my_prefix := HOST_
+ my_host := host-
+else
+ my_prefix := TARGET_
+ my_host :=
+endif
+
+my_module_tags := $(LOCAL_MODULE_TAGS)
+
+###########################################################
+## Validate and define fallbacks for input LOCAL_* variables.
+###########################################################
+
+## Dump a .csv file of all modules and their tags
+#ifneq ($(tag-list-first-time),false)
+#$(shell rm -f tag-list.csv)
+#tag-list-first-time := false
+#endif
+#$(shell echo $(lastword $(filter-out config/% out/%,$(MAKEFILE_LIST))),$(LOCAL_MODULE),$(strip $(LOCAL_MODULE_CLASS)),$(subst $(space),$(comma),$(sort $(my_module_tags))) >> tag-list.csv)
+
+LOCAL_UNINSTALLABLE_MODULE := $(strip $(LOCAL_UNINSTALLABLE_MODULE))
+my_module_tags := $(sort $(my_module_tags))
+ifeq (,$(my_module_tags))
+ my_module_tags := optional
+endif
+
+# User tags are not allowed anymore. Fail early because it will not be installed
+# like it used to be.
+ifneq ($(filter $(my_module_tags),user),)
+ $(warning *** Module name: $(LOCAL_MODULE))
+ $(warning *** Makefile location: $(LOCAL_MODULE_MAKEFILE))
+ $(warning * )
+ $(warning * Module is attempting to use the 'user' tag. This)
+ $(warning * used to cause the module to be installed automatically.)
+ $(warning * Now, the module must be listed in the PRODUCT_PACKAGES)
+ $(warning * section of a product makefile to have it installed.)
+ $(warning * )
+ $(error user tag detected on module.)
+endif
+
+# Only the tags mentioned in this test are expected to be set by module
+# makefiles. Anything else is either a typo or a source of unexpected
+# behaviors.
+ifneq ($(filter-out debug eng tests optional samples,$(my_module_tags)),)
+$(warning unusual tags $(my_module_tags) on $(LOCAL_MODULE) at $(LOCAL_PATH))
+endif
+
+# Add implicit tags.
+#
+# If the local directory or one of its parents contains a MODULE_LICENSE_GPL
+# file, tag the module as "gnu". Search for "*_GPL*", "*_LGPL*" and "*_MPL*"
+# so that we can also find files like MODULE_LICENSE_GPL_AND_AFL
+#
+gpl_license_file := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL* MODULE_LICENSE*_MPL* MODULE_LICENSE*_LGPL*)
+ifneq ($(gpl_license_file),)
+ my_module_tags += gnu
+ ALL_GPL_MODULE_LICENSE_FILES := $(sort $(ALL_GPL_MODULE_LICENSE_FILES) $(gpl_license_file))
+endif
+
+LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS))
+ifneq ($(words $(LOCAL_MODULE_CLASS)),1)
+ $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS must contain exactly one word, not "$(LOCAL_MODULE_CLASS)")
+endif
+
+my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32)
+
+ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
+my_multilib_module_path := $(strip $(LOCAL_MODULE_PATH_$(my_32_64_bit_suffix)))
+ifdef my_multilib_module_path
+my_module_path := $(my_multilib_module_path)
+else
+my_module_path := $(strip $(LOCAL_MODULE_PATH))
+endif
+my_module_relative_path := $(strip $(LOCAL_MODULE_RELATIVE_PATH))
+ifeq ($(my_module_path),)
+ ifdef LOCAL_IS_HOST_MODULE
+ partition_tag :=
+ else
+ ifeq (true,$(LOCAL_PROPRIETARY_MODULE))
+ partition_tag := _VENDOR
+ else ifeq (true,$(LOCAL_OEM_MODULE))
+ partition_tag := _OEM
+ else
+ # The definition of should-install-to-system will be different depending
+ # on which goal (e.g., sdk or just droid) is being built.
+ partition_tag := $(if $(call should-install-to-system,$(my_module_tags)),,_DATA)
+ endif
+ endif
+ install_path_var := $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS)
+ ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
+ install_path_var := $(install_path_var)_PRIVILEGED
+ endif
+
+ my_module_path := $($(install_path_var))
+ ifeq ($(strip $(my_module_path)),)
+ $(error $(LOCAL_PATH): unhandled install path "$(install_path_var) for $(LOCAL_MODULE)")
+ endif
+endif
+ifneq ($(my_module_relative_path),)
+ my_module_path := $(my_module_path)/$(my_module_relative_path)
+endif
+endif # not LOCAL_UNINSTALLABLE_MODULE
+
+ifneq ($(strip $(LOCAL_BUILT_MODULE)$(LOCAL_INSTALLED_MODULE)),)
+ $(error $(LOCAL_PATH): LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE must not be defined by component makefiles)
+endif
+
+my_register_name := $(LOCAL_MODULE)
+ifdef LOCAL_2ND_ARCH_VAR_PREFIX
+ifndef LOCAL_NO_2ND_ARCH_MODULE_SUFFIX
+my_register_name := $(LOCAL_MODULE)$($(my_prefix)2ND_ARCH_MODULE_SUFFIX)
+endif
+endif
+# Make sure that this IS_HOST/CLASS/MODULE combination is unique.
+module_id := MODULE.$(if \
+ $(LOCAL_IS_HOST_MODULE),HOST,TARGET).$(LOCAL_MODULE_CLASS).$(my_register_name)
+ifdef $(module_id)
+$(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id)))
+endif
+$(module_id) := $(LOCAL_PATH)
+
+intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX))
+intermediates.COMMON := $(call local-intermediates-dir,COMMON)
+generated_sources_dir := $(call local-generated-sources-dir)
+
+###########################################################
+# Pick a name for the intermediate and final targets
+###########################################################
+include $(BUILD_SYSTEM)/configure_module_stem.mk
+
+# OVERRIDE_BUILT_MODULE_PATH is only allowed to be used by the
+# internal SHARED_LIBRARIES build files.
+OVERRIDE_BUILT_MODULE_PATH := $(strip $(OVERRIDE_BUILT_MODULE_PATH))
+ifdef OVERRIDE_BUILT_MODULE_PATH
+ ifneq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
+ $(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH)
+ endif
+ built_module_path := $(OVERRIDE_BUILT_MODULE_PATH)
+else
+ built_module_path := $(intermediates)
+endif
+LOCAL_BUILT_MODULE := $(built_module_path)/$(my_built_module_stem)
+
+ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
+ # Apk and its attachments reside in its own subdir.
+ ifeq ($(LOCAL_MODULE_CLASS),APPS)
+ # framework-res.apk doesn't like the additional layer.
+ ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
+ my_module_path := $(my_module_path)/$(LOCAL_MODULE)
+ endif
+ endif
+ LOCAL_INSTALLED_MODULE := $(my_module_path)/$(my_installed_module_stem)
+endif
+
+# Assemble the list of targets to create PRIVATE_ variables for.
+LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE)
+
+
+###########################################################
+## AIDL: Compile .aidl files to .java
+###########################################################
+
+aidl_sources := $(filter %.aidl,$(LOCAL_SRC_FILES))
+
+ifneq ($(strip $(aidl_sources)),)
+
+aidl_java_sources := $(patsubst %.aidl,%.java,$(addprefix $(intermediates.COMMON)/src/, $(aidl_sources)))
+aidl_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(aidl_sources))
+
+aidl_preprocess_import :=
+LOCAL_SDK_VERSION:=$(strip $(LOCAL_SDK_VERSION))
+ifdef LOCAL_SDK_VERSION
+ifneq ($(filter current system_current, $(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS)),)
+ # LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS
+ aidl_preprocess_import := $(TARGET_OUT_COMMON_INTERMEDIATES)/framework.aidl
+else
+ aidl_preprocess_import := $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_VERSION)/framework.aidl
+endif # not current or system_current
+else
+# build against the platform.
+LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS)
+endif # LOCAL_SDK_VERSION
+$(aidl_java_sources): PRIVATE_AIDL_FLAGS := -b $(addprefix -p,$(aidl_preprocess_import)) -I$(LOCAL_PATH) -I$(LOCAL_PATH)/src $(addprefix -I,$(LOCAL_AIDL_INCLUDES))
+
+$(aidl_java_sources): $(intermediates.COMMON)/src/%.java: $(TOPDIR)$(LOCAL_PATH)/%.aidl $(LOCAL_ADDITIONAL_DEPENDENCIES) $(AIDL) $(aidl_preprocess_import)
+ $(transform-aidl-to-java)
+-include $(aidl_java_sources:%.java=%.P)
+
+else
+aidl_java_sources :=
+endif
+
+###########################################################
+## logtags: Add .logtags files to global list, emit java source
+###########################################################
+
+logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES))
+
+ifneq ($(strip $(logtags_sources)),)
+
+event_log_tags := $(addprefix $(LOCAL_PATH)/,$(logtags_sources))
+
+# Emit a java source file with constants for the tags, if
+# LOCAL_MODULE_CLASS is "APPS" or "JAVA_LIBRARIES".
+ifneq ($(filter $(LOCAL_MODULE_CLASS),APPS JAVA_LIBRARIES),)
+
+logtags_java_sources := $(patsubst %.logtags,%.java,$(addprefix $(intermediates.COMMON)/src/, $(logtags_sources)))
+logtags_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(logtags_sources))
+
+$(logtags_java_sources): $(intermediates.COMMON)/src/%.java: $(TOPDIR)$(LOCAL_PATH)/%.logtags $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
+ $(transform-logtags-to-java)
+
+endif
+
+else
+logtags_java_sources :=
+event_log_tags :=
+endif
+
+###########################################################
+## .proto files: Compile proto files to .java
+###########################################################
+proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
+# Because names of the .java files compiled from .proto files are unknown until the
+# .proto files are compiled, we use a timestamp file as depedency.
+proto_java_sources_file_stamp :=
+ifneq ($(proto_sources),)
+proto_sources_fullpath := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(proto_sources))
+# By putting the generated java files into $(LOCAL_INTERMEDIATE_SOURCE_DIR), they will be
+# automatically found by the java compiling function transform-java-to-classes.jar.
+ifneq ($(LOCAL_INTERMEDIATE_SOURCE_DIR),)
+proto_java_intemediate_dir := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/proto
+else
+# LOCAL_INTERMEDIATE_SOURCE_DIR may be not defined in non-java modules.
+proto_java_intemediate_dir := $(intermediates)/proto
+endif
+proto_java_sources_file_stamp := $(proto_java_intemediate_dir)/Proto.stamp
+proto_java_sources_dir := $(proto_java_intemediate_dir)/src
+
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_INCLUDES := $(TOP)
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_SRC_FILES := $(proto_sources_fullpath)
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_DIR := $(proto_java_sources_dir)
+ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro)
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javamicro_out
+else
+ ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano)
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javanano_out
+ else
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --java_out
+ endif
+endif
+$(proto_java_sources_file_stamp): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_PARAMS := $(LOCAL_PROTO_JAVA_OUTPUT_PARAMS)
+$(proto_java_sources_file_stamp) : $(proto_sources_fullpath) $(PROTOC)
+ $(call transform-proto-to-java)
+
+#TODO: protoc should output the dependencies introduced by imports.
+
+LOCAL_INTERMEDIATE_TARGETS += $(proto_java_sources_file_stamp)
+endif # proto_sources
+
+
+###########################################################
+## Java: Compile .java files to .class
+###########################################################
+#TODO: pull this into java.make once host and target are combined
+
+java_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) $(aidl_java_sources) $(logtags_java_sources) \
+ $(filter %.java,$(LOCAL_GENERATED_SOURCES))
+all_java_sources := $(java_sources) $(addprefix $($(my_prefix)OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES)))
+
+## Java resources #########################################
+
+# Look for resource files in any specified directories.
+# Non-java and non-doc files will be picked up as resources
+# and included in the output jar file.
+java_resource_file_groups :=
+
+LOCAL_JAVA_RESOURCE_DIRS := $(strip $(LOCAL_JAVA_RESOURCE_DIRS))
+ifneq ($(LOCAL_JAVA_RESOURCE_DIRS),)
+ # This makes a list of words like
+ # ::::::
+ # where each of the files is relative to the directory it's grouped with.
+ # Directories that don't contain any resource files will result in groups
+ # that end with a colon, and they are stripped out in the next step.
+ java_resource_file_groups += \
+ $(foreach dir,$(LOCAL_JAVA_RESOURCE_DIRS), \
+ $(subst $(space),:,$(strip \
+ $(TOP_DIR)$(LOCAL_PATH)/$(dir): \
+ $(patsubst ./%,%,$(shell cd $(TOP_DIR)$(LOCAL_PATH)/$(dir) && \
+ find . \
+ -type d -a -name ".svn" -prune -o \
+ -type f \
+ -a \! -name "*.java" \
+ -a \! -name "package.html" \
+ -a \! -name "overview.html" \
+ -a \! -name ".*.swp" \
+ -a \! -name ".DS_Store" \
+ -a \! -name "*~" \
+ -print \
+ )) \
+ )) \
+ )
+ java_resource_file_groups := $(filter-out %:,$(java_resource_file_groups))
+endif # LOCAL_JAVA_RESOURCE_DIRS
+
+LOCAL_JAVA_RESOURCE_FILES := $(strip $(LOCAL_JAVA_RESOURCE_FILES))
+ifneq ($(LOCAL_JAVA_RESOURCE_FILES),)
+ java_resource_file_groups += \
+ $(foreach f,$(LOCAL_JAVA_RESOURCE_FILES), \
+ $(patsubst %/,%,$(dir $(f)))::$(notdir $(f)) \
+ )
+endif # LOCAL_JAVA_RESOURCE_FILES
+
+ifdef java_resource_file_groups
+ # The full paths to all resources, used for dependencies.
+ java_resource_sources := \
+ $(foreach group,$(java_resource_file_groups), \
+ $(addprefix $(word 1,$(subst :,$(space),$(group)))/, \
+ $(wordlist 2,9999,$(subst :,$(space),$(group))) \
+ ) \
+ )
+ # The arguments to jar that will include these files in a jar file.
+ # Quote the file name to handle special characters (such as #) correctly.
+ extra_jar_args := \
+ $(foreach group,$(java_resource_file_groups), \
+ $(addprefix -C "$(word 1,$(subst :,$(space),$(group)))" , \
+ $(foreach w, $(wordlist 2,9999,$(subst :,$(space),$(group))), "$(w)" ) \
+ ) \
+ )
+ java_resource_file_groups :=
+else
+ java_resource_sources :=
+ extra_jar_args :=
+endif # java_resource_file_groups
+
+## PRIVATE java vars ######################################
+# LOCAL_SOURCE_FILES_ALL_GENERATED is set only if the module does not have static source files,
+# but generated source files in its LOCAL_INTERMEDIATE_SOURCE_DIR.
+# You have to set up the dependency in some other way.
+need_compile_java := $(strip $(all_java_sources)$(all_res_assets))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED))
+ifdef need_compile_java
+
+full_static_java_libs := \
+ $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \
+ $(call intermediates-dir-for, \
+ JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/javalib.jar)
+
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_INSTALL_DIR := $(dir $(LOCAL_INSTALLED_MODULE))
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates)/classes
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates)/src
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_SOURCES := $(all_java_sources)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_OBJECTS := $(patsubst %.java,%.class,$(LOCAL_SRC_FILES))
+ifeq ($(my_prefix),TARGET_)
+ifeq ($(LOCAL_SDK_VERSION),)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,core-libart)
+else
+ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
+# LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS.
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,android_stubs_current)
+else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),system_current)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,android_system_stubs_current)
+else
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,sdk_v$(LOCAL_SDK_VERSION))
+endif # current or system_current
+endif # LOCAL_SDK_VERSION
+endif # TARGET_
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASSET_DIR := $(LOCAL_ASSET_DIR)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JAVA_LIBRARIES := $(full_static_java_libs)
+
+# full_java_libs: The list of files that should be used as the classpath.
+# Using this list as a dependency list WILL NOT WORK.
+# full_java_lib_deps: Should be specified as a prerequisite of this module
+# to guarantee that the files in full_java_libs will
+# be up-to-date.
+ifdef LOCAL_IS_HOST_MODULE
+ifeq ($(USE_CORE_LIB_BOOTCLASSPATH),true)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-deps,core-libart-hostdex,$(LOCAL_IS_HOST_MODULE))
+
+full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
+full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
+else
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH :=
+
+full_shared_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,\
+ $(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES)))
+full_java_lib_deps := $(full_shared_java_libs)
+endif # USE_CORE_LIB_BOOTCLASSPATH
+else # !LOCAL_IS_HOST_MODULE
+full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
+full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
+endif # !LOCAL_IS_HOST_MODULE
+full_java_libs := $(full_shared_java_libs) $(full_static_java_libs) $(LOCAL_CLASSPATH)
+full_java_lib_deps += $(full_static_java_libs) $(LOCAL_CLASSPATH)
+
+# This is set by packages that are linking to other packages that export
+# shared libraries, allowing them to make use of the code in the linked apk.
+apk_libraries := $(sort $(LOCAL_APK_LIBRARIES) $(LOCAL_RES_LIBRARIES))
+ifneq ($(apk_libraries),)
+ link_apk_libraries := \
+ $(foreach lib,$(apk_libraries), \
+ $(call intermediates-dir-for, \
+ APPS,$(lib),,COMMON)/classes.jar)
+
+ # link against the jar with full original names (before proguard processing).
+ full_shared_java_libs += $(link_apk_libraries)
+ full_java_libs += $(link_apk_libraries)
+ full_java_lib_deps += $(link_apk_libraries)
+endif
+
+# This is set by packages that contain instrumentation, allowing them to
+# link against the package they are instrumenting. Currently only one such
+# package is allowed.
+LOCAL_INSTRUMENTATION_FOR := $(strip $(LOCAL_INSTRUMENTATION_FOR))
+ifdef LOCAL_INSTRUMENTATION_FOR
+ ifneq ($(words $(LOCAL_INSTRUMENTATION_FOR)),1)
+ $(error \
+ $(LOCAL_PATH): Multiple LOCAL_INSTRUMENTATION_FOR members defined)
+ endif
+
+ link_instr_intermediates_dir.COMMON := $(call intermediates-dir-for, \
+ APPS,$(LOCAL_INSTRUMENTATION_FOR),,COMMON)
+ # link against the jar with full original names (before proguard processing).
+ link_instr_classes_jar := $(link_instr_intermediates_dir.COMMON)/classes.jar
+ full_java_libs += $(link_instr_classes_jar)
+ full_java_lib_deps += $(link_instr_classes_jar)
+endif
+
+endif # need_compile_java
+
+# We may want to add jar manifest or jar resource files even if there is no java code at all.
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args)
+jar_manifest_file :=
+ifneq ($(strip $(LOCAL_JAR_MANIFEST)),)
+jar_manifest_file := $(LOCAL_PATH)/$(LOCAL_JAR_MANIFEST)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST := $(jar_manifest_file)
+else
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST :=
+endif
+
+###########################################################
+## make clean- targets
+###########################################################
+cleantarget := clean-$(my_register_name)
+$(cleantarget) : PRIVATE_MODULE := $(my_register_name)
+$(cleantarget) : PRIVATE_CLEAN_FILES := \
+ $(LOCAL_BUILT_MODULE) \
+ $(LOCAL_INSTALLED_MODULE) \
+ $(intermediates)
+$(cleantarget)::
+ @echo "Clean: $(PRIVATE_MODULE)"
+ $(hide) rm -rf $(PRIVATE_CLEAN_FILES)
+
+###########################################################
+## Common definitions for module.
+###########################################################
+
+# aapt doesn't accept multiple --extra-packages flags.
+# We have to collapse them into a single --extra-packages flag here.
+LOCAL_AAPT_FLAGS := $(strip $(LOCAL_AAPT_FLAGS))
+ifdef LOCAL_AAPT_FLAGS
+ifeq ($(filter 0 1,$(words $(filter --extra-packages,$(LOCAL_AAPT_FLAGS)))),)
+aapt_flags := $(subst --extra-packages$(space),--extra-packages@,$(LOCAL_AAPT_FLAGS))
+aapt_flags_extra_packages := $(patsubst --extra-packages@%,%,$(filter --extra-packages@%,$(aapt_flags)))
+aapt_flags_extra_packages := $(sort $(subst :,$(space),$(aapt_flags_extra_packages)))
+LOCAL_AAPT_FLAGS := $(filter-out --extra-packages@%,$(aapt_flags)) \
+ --extra-packages $(subst $(space),:,$(aapt_flags_extra_packages))
+aapt_flags_extra_packages :=
+aapt_flags :=
+endif
+endif
+
+# Propagate local configuration options to this target.
+$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH)
+$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_AAPT_FLAGS:= $(LOCAL_AAPT_FLAGS) $(PRODUCT_AAPT_FLAGS)
+$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_JAVA_LIBRARIES:= $(LOCAL_JAVA_LIBRARIES)
+$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MANIFEST_PACKAGE_NAME:= $(LOCAL_MANIFEST_PACKAGE_NAME)
+$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MANIFEST_INSTRUMENTATION_FOR:= $(LOCAL_MANIFEST_INSTRUMENTATION_FOR)
+
+$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_ALL_JAVA_LIBRARIES:= $(full_java_libs)
+$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE)
+$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host)
+
+$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_INTERMEDIATES_DIR:= $(intermediates)
+
+$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX)
+
+# Tell the module and all of its sub-modules who it is.
+$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MODULE:= $(my_register_name)
+
+# Provide a short-hand for building this module.
+# We name both BUILT and INSTALLED in case
+# LOCAL_UNINSTALLABLE_MODULE is set.
+.PHONY: $(my_register_name)
+$(my_register_name): $(LOCAL_BUILT_MODULE) $(LOCAL_INSTALLED_MODULE)
+
+###########################################################
+## Module installation rule
+###########################################################
+
+# Some hosts do not have ACP; override the LOCAL version if that's the case.
+ifneq ($(strip $(HOST_ACP_UNAVAILABLE)),)
+ LOCAL_ACP_UNAVAILABLE := $(strip $(HOST_ACP_UNAVAILABLE))
+endif
+
+ifndef LOCAL_UNINSTALLABLE_MODULE
+ # Define a copy rule to install the module.
+ # acp and libraries that it uses can't use acp for
+ # installation; hence, LOCAL_ACP_UNAVAILABLE.
+$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
+ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
+$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) | $(ACP)
+ @echo "Install: $@"
+ $(copy-file-to-new-target)
+ $(PRIVATE_POST_INSTALL_CMD)
+else
+$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
+ @echo "Install: $@"
+ $(copy-file-to-target-with-cp)
+endif
+
+endif # !LOCAL_UNINSTALLABLE_MODULE
+
+
+###########################################################
+## CHECK_BUILD goals
+###########################################################
+
+ifdef java_alternative_checked_module
+ LOCAL_CHECKED_MODULE := $(java_alternative_checked_module)
+endif
+
+# If nobody has defined a more specific module for the
+# checked modules, use LOCAL_BUILT_MODULE.
+ifndef LOCAL_CHECKED_MODULE
+ LOCAL_CHECKED_MODULE := $(LOCAL_BUILT_MODULE)
+endif
+
+# If they request that this module not be checked, then don't.
+# PLEASE DON'T SET THIS. ANY PLACES THAT SET THIS WITHOUT
+# GOOD REASON WILL HAVE IT REMOVED.
+ifdef LOCAL_DONT_CHECK_MODULE
+ LOCAL_CHECKED_MODULE :=
+endif
+# Don't check build target module defined for the 2nd arch
+ifndef LOCAL_IS_HOST_MODULE
+ifdef LOCAL_2ND_ARCH_VAR_PREFIX
+ LOCAL_CHECKED_MODULE :=
+endif
+endif
+
+###########################################################
+## Register with ALL_MODULES
+###########################################################
+
+ALL_MODULES += $(my_register_name)
+
+# Don't use += on subvars, or else they'll end up being
+# recursively expanded.
+ALL_MODULES.$(my_register_name).CLASS := \
+ $(ALL_MODULES.$(my_register_name).CLASS) $(LOCAL_MODULE_CLASS)
+ALL_MODULES.$(my_register_name).PATH := \
+ $(ALL_MODULES.$(my_register_name).PATH) $(LOCAL_PATH)
+ALL_MODULES.$(my_register_name).TAGS := \
+ $(ALL_MODULES.$(my_register_name).TAGS) $(my_module_tags)
+ALL_MODULES.$(my_register_name).CHECKED := \
+ $(ALL_MODULES.$(my_register_name).CHECKED) $(LOCAL_CHECKED_MODULE)
+ALL_MODULES.$(my_register_name).BUILT := \
+ $(ALL_MODULES.$(my_register_name).BUILT) $(LOCAL_BUILT_MODULE)
+ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
+ALL_MODULES.$(my_register_name).INSTALLED := \
+ $(strip $(ALL_MODULES.$(my_register_name).INSTALLED) $(LOCAL_INSTALLED_MODULE))
+ALL_MODULES.$(my_register_name).BUILT_INSTALLED := \
+ $(strip $(ALL_MODULES.$(my_register_name).BUILT_INSTALLED) $(LOCAL_BUILT_MODULE):$(LOCAL_INSTALLED_MODULE))
+endif
+ifdef LOCAL_PICKUP_FILES
+# Files or directories ready to pick up by the build system
+# when $(LOCAL_BUILT_MODULE) is done.
+ALL_MODULES.$(my_register_name).PICKUP_FILES := \
+ $(ALL_MODULES.$(my_register_name).PICKUP_FILES) $(LOCAL_PICKUP_FILES)
+endif
+ALL_MODULES.$(my_register_name).REQUIRED := \
+ $(strip $(ALL_MODULES.$(my_register_name).REQUIRED) $(LOCAL_REQUIRED_MODULES) \
+ $(LOCAL_REQUIRED_MODULES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
+ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS := \
+ $(ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS) $(event_log_tags)
+ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR := \
+ $(ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR) $(LOCAL_INTERMEDIATE_SOURCE_DIR)
+ALL_MODULES.$(my_register_name).MAKEFILE := \
+ $(ALL_MODULES.$(my_register_name).MAKEFILE) $(LOCAL_MODULE_MAKEFILE)
+ifdef LOCAL_MODULE_OWNER
+ALL_MODULES.$(my_register_name).OWNER := \
+ $(sort $(ALL_MODULES.$(my_register_name).OWNER) $(LOCAL_MODULE_OWNER))
+endif
+ifdef LOCAL_2ND_ARCH_VAR_PREFIX
+ALL_MODULES.$(my_register_name).FOR_2ND_ARCH := true
+endif
+ifdef aidl_sources
+ALL_MODULES.$(my_register_name).AIDL_FILES := $(aidl_sources)
+endif
+
+INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(my_register_name)
+
+###########################################################
+## Take care of my_module_tags
+###########################################################
+
+# Keep track of all the tags we've seen.
+ALL_MODULE_TAGS := $(sort $(ALL_MODULE_TAGS) $(my_module_tags))
+
+# Add this module to the tag list of each specified tag.
+# Don't use "+=". If the variable hasn't been set with ":=",
+# it will default to recursive expansion.
+$(foreach tag,$(my_module_tags),\
+ $(eval ALL_MODULE_TAGS.$(tag) := \
+ $(ALL_MODULE_TAGS.$(tag)) \
+ $(LOCAL_INSTALLED_MODULE)))
+
+# Add this module name to the tag list of each specified tag.
+$(foreach tag,$(my_module_tags),\
+ $(eval ALL_MODULE_NAME_TAGS.$(tag) += $(my_register_name)))
+
+###########################################################
+## umbrella targets used to verify builds
+###########################################################
+j_or_n :=
+ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)))
+j_or_n := native
+else
+ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS)))
+j_or_n := java
+endif
+endif
+ifdef LOCAL_IS_HOST_MODULE
+h_or_t := host
+else
+h_or_t := target
+endif
+
+ifdef j_or_n
+$(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_t) : $(LOCAL_CHECKED_MODULE)
+ifneq (,$(filter $(my_module_tags),tests))
+$(j_or_n)-$(h_or_t)-tests $(j_or_n)-tests $(h_or_t)-tests : $(LOCAL_CHECKED_MODULE)
+endif
+endif
+
+###########################################################
+## NOTICE files
+###########################################################
+
+include $(BUILD_NOTICE_FILE)
+
+#:vi noexpandtab
diff --git a/build/core/binary.mk b/build/core/binary.mk
new file mode 100644
index 0000000..1e313ff
--- /dev/null
+++ b/build/core/binary.mk
@@ -0,0 +1,996 @@
+###########################################################
+## Standard rules for building binary object files from
+## asm/c/cpp/yacc/lex/etc source files.
+##
+## The list of object files is exported in $(all_objects).
+###########################################################
+
+#######################################
+include $(BUILD_SYSTEM)/base_rules.mk
+#######################################
+
+my_ndk_sysroot :=
+my_ndk_sysroot_include :=
+my_ndk_sysroot_lib :=
+ifdef LOCAL_SDK_VERSION
+ ifdef LOCAL_NDK_VERSION
+ $(error $(LOCAL_PATH): LOCAL_NDK_VERSION is now retired.)
+ endif
+ ifdef LOCAL_IS_HOST_MODULE
+ $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module)
+ endif
+ my_ndk_source_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources
+ my_ndk_sysroot := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/platforms/android-$(LOCAL_SDK_VERSION)/arch-$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
+ my_ndk_sysroot_include := $(my_ndk_sysroot)/usr/include
+ ifeq (x86_64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
+ my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib64
+ else
+ my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib
+ endif
+
+ # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location.
+ # See ndk/docs/CPLUSPLUS-SUPPORT.html
+ my_ndk_stl_include_path :=
+ my_ndk_stl_shared_lib_fullpath :=
+ my_ndk_stl_shared_lib :=
+ my_ndk_stl_static_lib :=
+ my_ndk_stl_cppflags :=
+ LOCAL_NDK_STL_VARIANT := $(strip $(LOCAL_NDK_STL_VARIANT))
+ ifeq (,$(LOCAL_NDK_STL_VARIANT))
+ LOCAL_NDK_STL_VARIANT := system
+ endif
+ ifneq (1,$(words $(filter system stlport_static stlport_shared c++_static c++_shared gnustl_static, $(LOCAL_NDK_STL_VARIANT))))
+ $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT))
+ endif
+ ifeq (system,$(LOCAL_NDK_STL_VARIANT))
+ my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include
+ # for "system" variant, the shared library exists in the system library and -lstdc++ is added by default.
+ else # LOCAL_NDK_STL_VARIANT is not system
+ ifneq (,$(filter stlport_%, $(LOCAL_NDK_STL_VARIANT)))
+ my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/stlport/stlport
+ ifeq (stlport_static,$(LOCAL_NDK_STL_VARIANT))
+ my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libstlport_static.a
+ else
+ my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libstlport_shared.so
+ my_ndk_stl_shared_lib := -lstlport_shared
+ endif
+ else # LOCAL_NDK_STL_VARIANT is not stlport_* either
+ ifneq (,$(filter c++_%, $(LOCAL_NDK_STL_VARIANT)))
+ my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libcxx/include \
+ $(my_ndk_source_root)/cxx-stl/llvm-libc++/gabi++/include \
+ $(my_ndk_source_root)/android/support/include
+ ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT))
+ my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libc++_static.a
+ else
+ my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libc++_shared.so
+ my_ndk_stl_shared_lib := -lc++_shared
+ endif
+ my_ndk_stl_cppflags := -std=c++11
+ else
+ # LOCAL_NDK_STL_VARIANT is gnustl_static
+ my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/include \
+ $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/include
+ my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libgnustl_static.a
+ endif
+ endif
+ endif
+endif
+
+##################################################
+# Compute the dependency of the shared libraries
+##################################################
+# On the target, we compile with -nostdlib, so we must add in the
+# default system shared libraries, unless they have requested not
+# to by supplying a LOCAL_SYSTEM_SHARED_LIBRARIES value. One would
+# supply that, for example, when building libc itself.
+ifdef LOCAL_IS_HOST_MODULE
+ ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
+ my_system_shared_libraries :=
+ else
+ my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
+ endif
+else
+ ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
+ my_system_shared_libraries := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES)
+ else
+ my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
+ endif
+endif
+
+# The following LOCAL_ variables will be modified in this file.
+# Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch,
+# we can't modify them in place.
+my_src_files := $(LOCAL_SRC_FILES)
+my_static_libraries := $(LOCAL_STATIC_LIBRARIES)
+my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES)
+my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
+my_cflags := $(LOCAL_CFLAGS)
+my_cppflags := $(LOCAL_CPPFLAGS)
+my_ldflags := $(LOCAL_LDFLAGS)
+my_asflags := $(LOCAL_ASFLAGS)
+my_cc := $(LOCAL_CC)
+my_cxx := $(LOCAL_CXX)
+my_c_includes := $(LOCAL_C_INCLUDES)
+my_generated_sources := $(LOCAL_GENERATED_SOURCES)
+
+# MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
+# all code is position independent, and then those warnings get promoted to
+# errors.
+ifeq ($(strip $(USE_MINGW)),)
+ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
+my_cflags += -fpie
+else
+my_cflags += -fPIC
+endif
+endif
+
+my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix))
+my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix))
+my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix))
+my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix))
+my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix))
+my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix))
+my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix))
+my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_GENERATED_SOURCES_$(my_32_64_bit_suffix))
+
+my_clang := $(LOCAL_CLANG)
+ifdef LOCAL_CLANG_$(my_32_64_bit_suffix)
+my_clang := $(LOCAL_CLANG_$(my_32_64_bit_suffix))
+endif
+ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
+my_clang := $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
+endif
+
+# arch-specific static libraries go first so that generic ones can depend on them
+my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries)
+my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_WHOLE_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_whole_static_libraries)
+
+my_cflags := $(filter-out $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_UNSUPPORTED_CFLAGS),$(my_cflags))
+
+
+# Replace libstdc++ with libc++ if it's seen
+my_libcxx := $(filter libc++, $(my_shared_libraries))
+ifdef my_libcxx
+my_system_shared_libraries := $(filter-out libstdc++, $(my_system_shared_libraries))
+endif
+
+# Add static HAL libraries
+ifdef LOCAL_HAL_STATIC_LIBRARIES
+$(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \
+ $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\
+ $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\
+ $(eval my_static_libraries += $(lib).default)))
+b_lib :=
+endif
+
+ifeq ($(strip $(LOCAL_ADDRESS_SANITIZER)),true)
+ my_clang := true
+ # Frame pointer based unwinder in ASan requires ARM frame setup.
+ LOCAL_ARM_MODE := arm
+ my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
+ my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
+ my_shared_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES)
+ my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
+endif
+
+ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_$(my_prefix)CLANG)),true)
+ my_clang :=
+endif
+
+# Add in libcompiler_rt for all regular device builds
+ifeq (,$(LOCAL_SDK_VERSION)$(LOCAL_IS_HOST_MODULE)$(WITHOUT_LIBCOMPILER_RT))
+ my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
+endif
+
+my_compiler_dependencies :=
+
+##################################################################
+## Add FDO flags if FDO is turned on and supported
+## Please note that we will do option filtering during FDO build.
+## i.e. Os->O2, remove -fno-early-inline and -finline-limit.
+##################################################################
+ifeq ($(strip $(LOCAL_FDO_SUPPORT)), true)
+ ifeq ($(strip $(LOCAL_IS_HOST_MODULE)),)
+ my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS)
+ my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_LDFLAGS)
+ endif
+endif
+
+###########################################################
+## Explicitly declare assembly-only __ASSEMBLY__ macro for
+## assembly source
+###########################################################
+my_asflags += -D__ASSEMBLY__
+
+
+##########################################################
+## Set up installed module dependency
+## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
+## they may cusomize their install path with LOCAL_MODULE_PATH
+##########################################################
+# Get the list of INSTALLED libraries as module names.
+ifdef LOCAL_SDK_VERSION
+ installed_shared_library_module_names := \
+ $(my_shared_libraries)
+else
+ installed_shared_library_module_names := \
+ $(my_system_shared_libraries) $(my_shared_libraries)
+endif
+installed_shared_library_module_names := $(sort $(installed_shared_library_module_names))
+
+# 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 installed_shared_library_module_names
+$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
+ $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(installed_shared_library_module_names))
+endif
+endif
+
+###########################################################
+## Define PRIVATE_ variables from global vars
+###########################################################
+ifndef LOCAL_IS_HOST_MODULE
+ifdef LOCAL_SDK_VERSION
+my_target_project_includes :=
+my_target_c_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include)
+my_target_global_cppflags := $(my_ndk_stl_cppflags)
+else
+my_target_project_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES)
+my_target_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_INCLUDES)
+my_target_global_cppflags :=
+endif # LOCAL_SDK_VERSION
+
+ifeq ($(my_clang),true)
+my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS)
+my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS)
+my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS)
+my_target_c_includes += $(CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES)
+else
+my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS)
+my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS)
+my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LDFLAGS)
+endif # my_clang
+
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
+
+else # LOCAL_IS_HOST_MODULE
+
+ifeq ($(my_clang),true)
+my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CFLAGS)
+my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CPPFLAGS)
+my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_LDFLAGS)
+my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES) $(CLANG_CONFIG_EXTRA_HOST_C_INCLUDES)
+else
+my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS)
+my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS)
+my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LDFLAGS)
+my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES)
+endif # my_clang
+
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags)
+endif # LOCAL_IS_HOST_MODULE
+
+###########################################################
+## Define PRIVATE_ variables used by multiple module types
+###########################################################
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \
+ $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS))
+
+ifeq ($(strip $(WITH_SYNTAX_CHECK)),)
+ LOCAL_NO_SYNTAX_CHECK := true
+endif
+
+ifeq ($(strip $(WITH_STATIC_ANALYZER)),)
+ LOCAL_NO_STATIC_ANALYZER := true
+endif
+
+ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
+ my_syntax_arch := host
+else
+ my_syntax_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
+endif
+
+ifeq ($(strip $(my_cc)),)
+ ifeq ($(strip $(my_clang)),true)
+ my_cc := $(CLANG)
+ else
+ my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC)
+ endif
+endif
+ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
+ my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer $(my_syntax_arch) "$(my_cc)"
+else
+ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
+ my_cc := $(SYNTAX_TOOLS_PREFIX)/ccc-syntax $(my_syntax_arch) "$(my_cc)"
+endif
+endif
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc)
+
+ifeq ($(strip $(my_cxx)),)
+ ifeq ($(strip $(my_clang)),true)
+ my_cxx := $(CLANG_CXX)
+ else
+ my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX)
+ endif
+endif
+ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
+ my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-analyzer $(my_syntax_arch) "$(my_cxx)"
+else
+ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
+ my_cxx := $(SYNTAX_TOOLS_PREFIX)/cxx-syntax $(my_syntax_arch) "$(my_cxx)"
+endif
+endif
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLANG := $(my_clang)
+
+# TODO: support a mix of standard extensions so that this isn't necessary
+LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
+ifeq ($(LOCAL_CPP_EXTENSION),)
+ LOCAL_CPP_EXTENSION := .cpp
+endif
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPP_EXTENSION := $(LOCAL_CPP_EXTENSION)
+
+# Certain modules like libdl have to have symbols resolved at runtime and blow
+# up if --no-undefined is passed to the linker.
+ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
+ifeq ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),)
+ my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS)
+endif
+endif
+
+ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
+$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true
+else
+$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES :=
+endif
+
+###########################################################
+## Define arm-vs-thumb-mode flags.
+###########################################################
+LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
+ifeq ($(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm)
+arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm)
+normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
+
+# Read the values from something like TARGET_arm_CFLAGS or
+# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't
+# actually used (although they are usually empty).
+arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)
+normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)
+ifeq ($(strip $(my_clang)),true)
+arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags))
+normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags))
+endif
+
+else
+arm_objects_mode :=
+normal_objects_mode :=
+arm_objects_cflags :=
+normal_objects_cflags :=
+endif
+
+###########################################################
+## Define per-module debugging flags. Users can turn on
+## debugging for a particular module by setting DEBUG_MODULE_ModuleName
+## to a non-empty value in their environment or buildspec.mk,
+## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the
+## debug flags that they want to use.
+###########################################################
+ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE))
+ debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS)
+else
+ debug_cflags :=
+endif
+
+####################################################
+## Compile RenderScript with reflected C++
+####################################################
+
+renderscript_sources := $(filter %.rs %.fs,$(my_src_files))
+
+ifneq (,$(renderscript_sources))
+
+renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
+RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp
+renderscript_intermediate := $(intermediates)/renderscript
+
+ifeq ($(LOCAL_RENDERSCRIPT_CC),)
+LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
+endif
+
+# Turn on all warnings and warnings as errors for RS compiles.
+# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error
+renderscript_flags := -Wall -Werror
+renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS)
+# -m32 or -m64
+renderscript_flags += -m$(my_32_64_bit_suffix)
+
+renderscript_includes := \
+ $(TOPDIR)external/clang/lib/Headers \
+ $(TOPDIR)frameworks/rs/scriptc \
+ $(LOCAL_RENDERSCRIPT_INCLUDES)
+
+ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
+renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
+endif
+
+$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes)
+$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
+$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags)
+$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath)
+$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate)
+$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
+ $(transform-renderscripts-to-cpp-and-bc)
+
+# include the dependency files (.d) generated by llvm-rs-cc.
+renderscript_generated_dep_files := $(addprefix $(renderscript_intermediate)/, \
+ $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources)))))
+-include $(renderscript_generated_dep_files)
+
+LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
+
+rs_generated_cpps := $(addprefix \
+ $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \
+ $(notdir $(renderscript_sources)))))
+
+# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
+$(rs_generated_cpps) : $(RenderScript_file_stamp)
+ @echo "Updated RS generated cpp file $@."
+
+my_c_includes += $(renderscript_intermediate)
+my_generated_sources += $(rs_generated_cpps)
+
+endif
+
+
+###########################################################
+## Stuff source generated from one-off tools
+###########################################################
+$(my_generated_sources): PRIVATE_MODULE := $(my_register_name)
+
+my_gen_sources_copy := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(filter $(generated_sources_dir)/%,$(my_generated_sources)))
+
+$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% | $(ACP)
+ @echo "Copy: $@"
+ $(copy-file-to-target)
+
+my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources))
+
+ALL_GENERATED_SOURCES += $(my_generated_sources)
+
+###########################################################
+## Compile the .proto files to .cc and then to .o
+###########################################################
+proto_sources := $(filter %.proto,$(my_src_files))
+proto_generated_objects :=
+proto_generated_headers :=
+ifneq ($(proto_sources),)
+proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
+proto_generated_cc_sources_dir := $(generated_sources_dir)/proto
+proto_generated_cc_sources := $(addprefix $(proto_generated_cc_sources_dir)/, \
+ $(patsubst %.proto,%.pb.cc,$(proto_sources_fullpath)))
+proto_generated_headers := $(patsubst %.pb.cc,%.pb.h, $(proto_generated_cc_sources))
+proto_generated_obj_dir := $(intermediates)/proto
+proto_generated_objects := $(addprefix $(proto_generated_obj_dir)/, \
+ $(patsubst %.proto,%.pb.o,$(proto_sources_fullpath)))
+
+# Auto-export the generated proto source dir.
+LOCAL_EXPORT_C_INCLUDE_DIRS += $(proto_generated_cc_sources_dir)
+
+# Ensure the transform-proto-to-cc rule is only defined once in multilib build.
+ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined
+$(proto_generated_cc_sources): PRIVATE_PROTO_INCLUDES := $(TOP)
+$(proto_generated_cc_sources): PRIVATE_PROTO_CC_OUTPUT_DIR := $(proto_generated_cc_sources_dir)
+$(proto_generated_cc_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
+$(proto_generated_cc_sources): $(proto_generated_cc_sources_dir)/%.pb.cc: %.proto $(PROTOC)
+ $(transform-proto-to-cc)
+
+# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
+$(proto_generated_headers): $(proto_generated_cc_sources_dir)/%.pb.h: $(proto_generated_cc_sources_dir)/%.pb.cc
+ @echo "Updated header file $@."
+
+$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true
+endif # transform-proto-to-cc rule included only once
+
+$(proto_generated_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
+$(proto_generated_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
+$(proto_generated_objects): $(proto_generated_obj_dir)/%.o: $(proto_generated_cc_sources_dir)/%.cc $(proto_generated_headers)
+ $(transform-$(PRIVATE_HOST)cpp-to-o)
+-include $(proto_generated_objects:%.o=%.P)
+
+my_c_includes += external/protobuf/src $(proto_generated_cc_sources_dir)
+my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
+ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
+my_static_libraries += libprotobuf-cpp-2.3.0-full
+else
+my_static_libraries += libprotobuf-cpp-2.3.0-lite
+endif
+endif # $(proto_sources) non-empty
+
+
+###########################################################
+## YACC: Compile .y and .yy files to .cpp and the to .o.
+###########################################################
+
+y_yacc_sources := $(filter %.y,$(my_src_files))
+y_yacc_cpps := $(addprefix \
+ $(intermediates)/,$(y_yacc_sources:.y=$(LOCAL_CPP_EXTENSION)))
+
+yy_yacc_sources := $(filter %.yy,$(my_src_files))
+yy_yacc_cpps := $(addprefix \
+ $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION)))
+
+yacc_cpps := $(y_yacc_cpps) $(yy_yacc_cpps)
+yacc_headers := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.h)
+yacc_objects := $(yacc_cpps:$(LOCAL_CPP_EXTENSION)=.o)
+
+ifneq ($(strip $(y_yacc_cpps)),)
+$(y_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
+ $(TOPDIR)$(LOCAL_PATH)/%.y \
+ $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+ $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
+$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
+endif
+
+ifneq ($(strip $(yy_yacc_cpps)),)
+$(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
+ $(TOPDIR)$(LOCAL_PATH)/%.yy \
+ $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+ $(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
+$(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
+endif
+
+ifneq ($(strip $(yacc_cpps)),)
+$(yacc_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
+$(yacc_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
+$(yacc_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
+ $(transform-$(PRIVATE_HOST)cpp-to-o)
+endif
+
+###########################################################
+## LEX: Compile .l and .ll files to .cpp and then to .o.
+###########################################################
+
+l_lex_sources := $(filter %.l,$(my_src_files))
+l_lex_cpps := $(addprefix \
+ $(intermediates)/,$(l_lex_sources:.l=$(LOCAL_CPP_EXTENSION)))
+
+ll_lex_sources := $(filter %.ll,$(my_src_files))
+ll_lex_cpps := $(addprefix \
+ $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION)))
+
+lex_cpps := $(l_lex_cpps) $(ll_lex_cpps)
+lex_objects := $(lex_cpps:$(LOCAL_CPP_EXTENSION)=.o)
+
+ifneq ($(strip $(l_lex_cpps)),)
+$(l_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
+ $(TOPDIR)$(LOCAL_PATH)/%.l
+ $(transform-l-to-cpp)
+endif
+
+ifneq ($(strip $(ll_lex_cpps)),)
+$(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
+ $(TOPDIR)$(LOCAL_PATH)/%.ll
+ $(transform-l-to-cpp)
+endif
+
+ifneq ($(strip $(lex_cpps)),)
+$(lex_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
+$(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
+$(lex_objects): $(intermediates)/%.o: \
+ $(intermediates)/%$(LOCAL_CPP_EXTENSION) \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES) \
+ $(yacc_headers)
+ $(transform-$(PRIVATE_HOST)cpp-to-o)
+endif
+
+###########################################################
+## C++: Compile .cpp files to .o.
+###########################################################
+
+# we also do this on host modules, even though
+# it's not really arm, because there are files that are shared.
+cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files)))
+cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
+
+cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files))
+cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o))
+
+$(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
+$(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
+$(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
+$(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
+
+cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects)
+
+ifneq ($(strip $(cpp_objects)),)
+$(cpp_objects): $(intermediates)/%.o: \
+ $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
+ $(yacc_cpps) $(proto_generated_headers) \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES) \
+ | $(my_compiler_dependencies)
+ $(transform-$(PRIVATE_HOST)cpp-to-o)
+-include $(cpp_objects:%.o=%.P)
+endif
+
+###########################################################
+## C++: Compile generated .cpp files to .o.
+###########################################################
+
+gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources))
+gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o)
+
+ifneq ($(strip $(gen_cpp_objects)),)
+# Compile all generated files as thumb.
+# TODO: support compiling certain generated files as arm.
+$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
+$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
+$(gen_cpp_objects): $(intermediates)/%.o: \
+ $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) \
+ $(proto_generated_headers) \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES) \
+ | $(my_compiler_dependencies)
+ $(transform-$(PRIVATE_HOST)cpp-to-o)
+-include $(gen_cpp_objects:%.o=%.P)
+endif
+
+###########################################################
+## S: Compile generated .S and .s files to .o.
+###########################################################
+
+gen_S_sources := $(filter %.S,$(my_generated_sources))
+gen_S_objects := $(gen_S_sources:%.S=%.o)
+
+ifneq ($(strip $(gen_S_sources)),)
+$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES) \
+ | $(my_compiler_dependencies)
+ $(transform-$(PRIVATE_HOST)s-to-o)
+-include $(gen_S_objects:%.o=%.P)
+endif
+
+gen_s_sources := $(filter %.s,$(my_generated_sources))
+gen_s_objects := $(gen_s_sources:%.s=%.o)
+
+ifneq ($(strip $(gen_s_objects)),)
+$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES) \
+ | $(my_compiler_dependencies)
+ $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
+-include $(gen_s_objects:%.o=%.P)
+endif
+
+gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
+
+###########################################################
+## o: Include generated .o files in output.
+###########################################################
+
+gen_o_objects := $(filter %.o,$(my_generated_sources))
+
+###########################################################
+## C: Compile .c files to .o.
+###########################################################
+
+c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files)))
+c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
+
+c_normal_sources := $(filter %.c,$(my_src_files))
+c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o))
+
+$(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
+$(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
+$(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
+$(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
+
+c_objects := $(c_arm_objects) $(c_normal_objects)
+
+ifneq ($(strip $(c_objects)),)
+$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES) \
+ | $(my_compiler_dependencies)
+ $(transform-$(PRIVATE_HOST)c-to-o)
+-include $(c_objects:%.o=%.P)
+endif
+
+###########################################################
+## C: Compile generated .c files to .o.
+###########################################################
+
+gen_c_sources := $(filter %.c,$(my_generated_sources))
+gen_c_objects := $(gen_c_sources:%.c=%.o)
+
+ifneq ($(strip $(gen_c_objects)),)
+# Compile all generated files as thumb.
+# TODO: support compiling certain generated files as arm.
+$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
+$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
+$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES) \
+ | $(my_compiler_dependencies)
+ $(transform-$(PRIVATE_HOST)c-to-o)
+-include $(gen_c_objects:%.o=%.P)
+endif
+
+###########################################################
+## ObjC: Compile .m files to .o
+###########################################################
+
+objc_sources := $(filter %.m,$(my_src_files))
+objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
+
+ifneq ($(strip $(objc_objects)),)
+$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES) \
+ | $(my_compiler_dependencies)
+ $(transform-$(PRIVATE_HOST)m-to-o)
+-include $(objc_objects:%.o=%.P)
+endif
+
+###########################################################
+## AS: Compile .S files to .o.
+###########################################################
+
+asm_sources_S := $(filter %.S,$(my_src_files))
+asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
+
+ifneq ($(strip $(asm_objects_S)),)
+$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES) \
+ | $(my_compiler_dependencies)
+ $(transform-$(PRIVATE_HOST)s-to-o)
+-include $(asm_objects_S:%.o=%.P)
+endif
+
+asm_sources_s := $(filter %.s,$(my_src_files))
+asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
+
+ifneq ($(strip $(asm_objects_s)),)
+$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES) \
+ | $(my_compiler_dependencies)
+ $(transform-$(PRIVATE_HOST)s-to-o-no-deps)
+-include $(asm_objects_s:%.o=%.P)
+endif
+
+asm_objects := $(asm_objects_S) $(asm_objects_s)
+
+
+# .asm for x86 needs to be compiled with yasm.
+ifeq (x86,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
+asm_sources_asm := $(filter %.asm,$(my_src_files))
+ifneq ($(strip $(asm_sources_asm)),)
+asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o))
+$(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES)
+ $(transform-asm-to-o)
+
+asm_objects += $(asm_objects_asm)
+endif
+endif
+
+####################################################
+## Import includes
+####################################################
+import_includes := $(intermediates)/import_includes
+import_includes_deps := $(strip \
+ $(foreach l, $(installed_shared_library_module_names), \
+ $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/export_includes) \
+ $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \
+ $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/export_includes))
+$(import_includes) : $(import_includes_deps)
+ @echo Import includes file: $@
+ $(hide) mkdir -p $(dir $@) && rm -f $@
+ifdef import_includes_deps
+ $(hide) for f in $^; do \
+ cat $$f >> $@; \
+ done
+else
+ $(hide) touch $@
+endif
+
+###########################################################
+## Common object handling.
+###########################################################
+
+# some rules depend on asm_objects being first. If your code depends on
+# being first, it's reasonable to require it to be assembly
+normal_objects := \
+ $(asm_objects) \
+ $(cpp_objects) \
+ $(gen_cpp_objects) \
+ $(gen_asm_objects) \
+ $(c_objects) \
+ $(gen_c_objects) \
+ $(objc_objects) \
+ $(yacc_objects) \
+ $(lex_objects) \
+ $(proto_generated_objects) \
+ $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
+
+all_objects := $(normal_objects) $(gen_o_objects)
+
+my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir)
+
+ifndef LOCAL_SDK_VERSION
+ my_c_includes += $(JNI_H_INCLUDE)
+endif
+
+# all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES;
+# use normal_objects here to avoid creating circular dependencies. This assumes
+# that custom build rules which generate .o files don't consume other generated
+# sources as input (or if they do they take care of that dependency themselves).
+$(normal_objects) : | $(my_generated_sources)
+$(all_objects) : | $(import_includes)
+ALL_C_CPP_ETC_OBJECTS += $(all_objects)
+
+
+###########################################################
+# Standard library handling.
+###########################################################
+
+###########################################################
+# The list of libraries that this module will link against are in
+# these variables. Each is a list of bare module names like "libc libm".
+#
+# LOCAL_SHARED_LIBRARIES
+# LOCAL_STATIC_LIBRARIES
+# LOCAL_WHOLE_STATIC_LIBRARIES
+#
+# We need to convert the bare names into the dependencies that
+# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE.
+# LOCAL_BUILT_MODULE should depend on the BUILT versions of the
+# libraries, so that simply building this module doesn't force
+# an install of a library. Similarly, LOCAL_INSTALLED_MODULE
+# should depend on the INSTALLED versions of the libraries so
+# that they get installed when this module does.
+###########################################################
+# NOTE:
+# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the
+# module without leaving anything out, which is useful for turning
+# a collection of .a files into a .so file. Linking against a
+# normal STATIC_LIBRARY will only pull in code/symbols that are
+# referenced by the module. (see gcc/ld's --whole-archive option)
+###########################################################
+
+# Get the list of BUILT libraries, which are under
+# various intermediates directories.
+so_suffix := $($(my_prefix)SHLIB_SUFFIX)
+a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
+
+ifdef LOCAL_SDK_VERSION
+built_shared_libraries := \
+ $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
+ $(addsuffix $(so_suffix), \
+ $(my_shared_libraries)))
+
+# Add the NDK libraries to the built module dependency
+my_system_shared_libraries_fullpath := \
+ $(my_ndk_stl_shared_lib_fullpath) \
+ $(addprefix $(my_ndk_sysroot_lib)/, \
+ $(addsuffix $(so_suffix), $(my_system_shared_libraries)))
+
+built_shared_libraries += $(my_system_shared_libraries_fullpath)
+else
+built_shared_libraries := \
+ $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
+ $(addsuffix $(so_suffix), \
+ $(installed_shared_library_module_names)))
+endif
+
+built_static_libraries := \
+ $(foreach lib,$(my_static_libraries), \
+ $(call intermediates-dir-for, \
+ STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/$(lib)$(a_suffix))
+
+ifdef LOCAL_SDK_VERSION
+built_static_libraries += $(my_ndk_stl_static_lib)
+endif
+
+built_whole_libraries := \
+ $(foreach lib,$(my_whole_static_libraries), \
+ $(call intermediates-dir-for, \
+ STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/$(lib)$(a_suffix))
+
+# We don't care about installed static libraries, since the
+# libraries have already been linked into the module at that point.
+# We do, however, care about the NOTICE files for any static
+# libraries that we use. (see notice_files.mk)
+
+installed_static_library_notice_file_targets := \
+ $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \
+ NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib))
+
+# Default is -fno-rtti.
+ifeq ($(strip $(LOCAL_RTTI_FLAG)),)
+LOCAL_RTTI_FLAG := -fno-rtti
+endif
+
+###########################################################
+# Rule-specific variable definitions
+###########################################################
+
+ifeq ($(my_clang),true)
+my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags))
+my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags))
+my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags))
+my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags))
+endif
+
+ifeq ($(LOCAL_FDO_SUPPORT), true)
+ build_with_fdo := false
+ ifeq ($(BUILD_FDO_INSTRUMENT), true)
+ build_with_fdo := true
+ endif
+ ifeq ($(BUILD_FDO_OPTIMIZE), true)
+ build_with_fdo := true
+ endif
+ ifeq ($(build_with_fdo), true)
+ my_cflags := $(patsubst -Os,-O2,$(my_cflags))
+ fdo_incompatible_flags=-fno-early-inlining -finline-limit=%
+ my_cflags := $(filter-out $(fdo_incompatible_flags),$(my_cflags))
+ endif
+endif
+
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(LOCAL_CONLYFLAGS)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(LOCAL_LDLIBS)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_CRT := $(strip $(LOCAL_NO_CRT) $(LOCAL_NO_CRT_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LIBCXX := $(my_libcxx)
+
+# this is really the way to get the files onto the command line instead
+# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects)
+
+###########################################################
+# Define library dependencies.
+###########################################################
+# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
+all_libraries := \
+ $(built_shared_libraries) \
+ $(built_static_libraries) \
+ $(built_whole_libraries)
+
+# Also depend on the notice files for any static libraries that
+# are linked into this module. This will force them to be installed
+# when this module is.
+$(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets)
+
+###########################################################
+# Export includes
+###########################################################
+export_includes := $(intermediates)/export_includes
+$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
+# Make sure .pb.h are already generated before any dependent source files get compiled.
+$(export_includes) : $(LOCAL_MODULE_MAKEFILE) $(proto_generated_headers)
+ @echo Export includes file: $< -- $@
+ $(hide) mkdir -p $(dir $@) && rm -f $@
+ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
+ $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
+ echo "-I $$d" >> $@; \
+ done
+else
+ $(hide) touch $@
+endif
+
+# Make sure export_includes gets generated when you are running mm/mmm
+$(LOCAL_BUILT_MODULE) : | $(export_includes)
diff --git a/build/core/build-system.html b/build/core/build-system.html
new file mode 100644
index 0000000..caade58
--- /dev/null
+++ b/build/core/build-system.html
@@ -0,0 +1,962 @@
+
+
+
+
+
+
+
+ Android Build System
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Android Build System
+
+
+
+ Status:Draft
+ (as of May 18, 2006)
+
+
+
Contents
+
+
+
+
Objective
+
The primary goals of reworking the build system are (1) to make dependencies
+work more reliably, so that when files need to rebuilt, they are, and (2) to
+improve performance of the build system so that unnecessary modules are not
+rebuilt, and so doing a top-level build when little or nothing needs to be done
+for a build takes as little time as possible.
+
+
Principles and Use Cases and Policy
+
Given the above objective, these are the overall principles and use cases
+that we will support. This is not an exhaustive list.
+
Multiple Targets
+
It needs to be possible to build the Android platform for multiple targets.
+This means:
+
+
The build system will support building tools for the host platform,
+ both ones that are used in the build process itself, and developer tools
+ like the simulator.
+
The build system will need to be able to build tools on Linux
+ (definitely Goobuntu and maybe Grhat), MacOS, and to some degree on
+ Windows.
+
The build system will need to be able to build the OS on Linux, and in
+ the short-term, MacOS. Note that this is a conscious decision to stop
+ building the OS on Windows. We are going to rely on the emulator there
+ and not attempt to use the simulator. This is a requirement change now
+ that the emulator story is looking brighter.
+
+
Non-Recursive Make
+
To achieve the objectives, the build system will be rewritten to use make
+non-recursively. For more background on this, read Recursive Make Considered Harmful. For those that don't
+want PDF, here is the
+Google translated version.
+
Rapid Compile-Test Cycles
+
When developing a component, for example a C++ shared library, it must be
+possible to easily rebuild just that component, and not have to wait more than a
+couple seconds for dependency checks, and not have to wait for unneeded
+components to be built.
+
Both Environment and Config File Based Settings
+
To set the target, and other options, some people on the team like to have a
+configuration file in a directory so they do not have an environment setup
+script to run, and others want an environment setup script to run so they can
+run builds in different terminals on the same tree, or switch back and forth
+in one terminal. We will support both.
+
Object File Directory / make clean
+
Object files and other intermediate files will be generated into a directory
+that is separate from the source tree. The goal is to have make clean be
+"rm -rf " in the tree root directory. The primary goals of
+this are to simplify searching the source tree, and to make "make clean" more
+reliable.
+
+
SDK
+
The SDK will be a tarball that will allow non-OS-developers to write apps.
+The apps will actually be built by first building the SDK, and then building
+the apps against that SDK. This will hopefully (1) make writing apps easier
+for us, because we won't have to rebuild the OS as much, and we can use the
+standard java-app development tools, and (2) allow us to dog-food the SDK, to
+help ensure its quality. Cedric has suggested (and I agree) that apps built
+from the SDK should be built with ant. Stay tuned for more details as we
+figure out exactly how this will work.
+
+
Dependecies
+
Dependencies should all be automatic. Unless there is a custom tool involved
+(e.g. the webkit has several), the dependencies for shared and static libraries,
+.c, .cpp, .h, .java, java libraries, etc., should all work without intervention
+in the Android.mk file.
+
+
Hiding command lines
+
The default of the build system will be to hide the command lines being
+executed for make steps. It will be possible to override this by specifying
+the showcommands pseudo-target, and possibly by setting an environment
+variable.
+
+
Wildcard source files
+
Wildcarding source file will be discouraged. It may be useful in some
+scenarios. The default $(wildcard *) will not work due to the
+current directory being set to the root of the build tree.
+
+
Multiple targets in one directory
+
It will be possible to generate more than one target from a given
+subdirectory. For example, libutils generates a shared library for the target
+and a static library for the host.
+
+
Makefile fragments for modules
+
Android.mk is the standard name for the makefile fragments that
+control the building of a given module. Only the top directory should
+have a file named "Makefile".
+
+
Use shared libraries
+
Currently, the simulator is not built to use shared libraries. This should
+be fixed, and now is a good time to do it. This implies getting shared
+libraries to work on Mac OS.
+
+
+
Nice to Have
+
+
These things would be nice to have, and this is a good place to record them,
+however these are not promises.
+
+
Simultaneous Builds
+
The hope is to be able to do two builds for different combos in the same
+tree at the same time, but this is a stretch goal, not a requirement.
+Doing two builds in the same tree, not at the same time must work. (update:
+it's looking like we'll get the two builds at the same time working)
+
+
Deleting headers (or other dependecies)
+
Problems can arise if you delete a header file that is referenced in
+".d" files. The easy way to deal with this is "make clean". There
+should be a better way to handle it. (from fadden)
+
One way of solving this is introducing a dependency on the directory. The
+problem is that this can create extra dependecies and slow down the build.
+It's a tradeoff.
+
+
Multiple builds
+
General way to perform builds across the set of known platforms. This
+would make it easy to perform multiple platform builds when testing a
+change, and allow a wide-scale "make clean". Right now the buildspec.mk
+or environment variables need to be updated before each build. (from fadden)
+
+
Aftermarket Locales and Carrier
+
We will eventually need to add support for creating locales and carrier
+customizations to the SDK, but that will not be addressed right now.
+
+
+
Usage
+
You've read (or scrolled past) all of the motivations for this build system,
+and you want to know how to use it. This is the place.
+
+
Your first build
+
The Building document describes how do do
+builds.
+
+
build/envsetup.sh functions
+If you source the file build/envsetup.sh into your bash environment,
+. build/envsetup.shyou'll get a few helpful shell functions:
+
+
+
printconfig - Prints the current configuration as set by the
+lunch and choosecombo commands.
+
m - Runs make from the top of the tree. This is
+useful because you can run make from within subdirectories. If you have the
+TOP environment variable set, it uses that. If you don't, it looks
+up the tree from the current directory, trying to find the top of the tree.
+
croot - cd to the top of the tree.
+
sgrep - grep for the regex you provide in all .c, .cpp, .h, .java,
+and .xml files below the current directory.
+
+
+
Build flavors/types
+
+When building for a particular product, it's often useful to have minor
+variations on what is ultimately the final release build. These are the
+currently-defined "flavors" or "types" (we need to settle on a real name
+for these).
+
+
+
+
+
+ eng
+
+
+ This is the default flavor. A plain "make" is the
+ same as "make eng". droid is an alias
+ for eng.
+
Installs non-APK modules that have no tags specified.
+
Installs APKs according to the product definition files, in
+ addition to tagged APKs.
+
ro.secure=0
+
ro.debuggable=1
+
ro.kernel.android.checkjni=1
+
adb is enabled by default.
+
+
+
+
+ user
+
+
+ "make user"
+
+ This is the flavor intended to be the final release bits.
+
+
Installs modules tagged with user.
+
Installs non-APK modules that have no tags specified.
+
Installs APKs according to the product definition files; tags
+ are ignored for APK modules.
+
ro.secure=1
+
ro.debuggable=0
+
adb is disabled by default.
+
+
+
+
+ userdebug
+
+
+ "make userdebug"
+
+ The same as user, except:
+
+
Also installs modules tagged with debug.
+
ro.debuggable=1
+
adb is enabled by default.
+
+
+
+
+
+If you build one flavor and then want to build another, you should run
+"make installclean" between the two makes to guarantee that
+you don't pick up files installed by the previous flavor. "make
+clean" will also suffice, but it takes a lot longer.
+
+
+
+
More pseudotargets
+
Sometimes you want to just build one thing. The following pseudotargets are
+there for your convenience:
+
+
+
droid - make droid is the normal build. This target
+is here because the default target has to have a name.
+
all - make all builds everything make
+droid does, plus everything whose LOCAL_MODULE_TAGS do not
+include the "droid" tag. The build server runs this to make sure
+that everything that is in the tree and has an Android.mk builds.
+
clean-$(LOCAL_MODULE) and clean-$(LOCAL_PACKAGE_NAME) -
+Let you selectively clean one target. For example, you can type
+make clean-libutils and it will delete libutils.so and all of the
+intermediate files, or you can type make clean-Home and it will
+clean just the Home app.
+
clean - make clean deletes all of the output and
+intermediate files for this configuration. This is the same as rm -rf
+out/<configuration>/
+
clobber - make clobber deletes all of the output
+and intermediate files for all configurations. This is the same as
+rm -rf out/.
+
dataclean - make dataclean deletes contents of the data
+directory inside the current combo directory. This is especially useful on the
+simulator and emulator, where the persistent data remains present between
+builds.
+
showcommands - showcommands is a modifier target
+which causes the build system to show the actual command lines for the build
+steps, instead of the brief descriptions. Most people don't like seeing the
+actual commands, because they're quite long and hard to read, but if you need
+to for debugging purposes, you can add showcommands to the list
+of targets you build. For example make showcommands will build
+the default android configuration, and make runtime showcommands
+will build just the runtime, and targets that it depends on, while displaying
+the full command lines. Please note that there are a couple places where the
+commands aren't shown here. These are considered bugs, and should be fixed,
+but they're often hard to track down. Please let
+android-build-team know if you find
+any.
+
LOCAL_MODULE - Anything you specify as a LOCAL_MODULE
+in an Android.mk is made into a pseudotarget. For example, make
+runtime might be shorthand for make
+out/linux-x86-debug/system/bin/runtime (which would work), and
+make libkjs might be shorthand for make
+out/linux-x86-debug/system/lib/libkjs.so (which would also work).
+
targets - make targets will print a list of all of
+the LOCAL_MODULE names you can make.
+
+
+
How to add another component to the build - Android.mk templates
+
You have a new library, a new app, or a new executable. For each of the
+common types of modules, there is a corresponding file in the templates
+directory. It will usually be enough to copy one of these, and fill in your
+own values. Some of the more esoteric values are not included in the
+templates, but are instead just documented here, as is the documentation
+on using custom tools to generate files.
+
Mostly, you can just look for the TODO comments in the templates and do
+what it says. Please remember to delete the TODO comments when you're done
+to keep the files clean. The templates have minimal documentation in them,
+because they're going to be copied, and when that gets stale, the copies just
+won't get updated. So read on...
+
+
Apps
+
Use the templates/apps file.
+
This template is pretty self-explanitory. See the variables below for more
+details.
+
+
Java Libraries
+
Use the templates/java_library file.
+
The interesting thing here is the value of LOCAL_MODULE, which becomes
+the name of the jar file. (Actually right now, we're not making jar files yet,
+just directories of .class files, but the directory is named according to
+what you put in LOCAL_MODULE). This name will be what goes in the
+LOCAL_JAVA_LIBRARIES variable in modules that depend on your java library.
+
+
C/C++ Executables
+
Use the templates/executable file, or the
+templates/executable_host file.
+
This template has a couple extra options that you usually don't need.
+Please delete the ones you don't need, and remove the TODO comments. It makes
+the rest of them easier to read, and you can always refer back to the templates
+if you need them again later.
+
By default, on the target these are built into /system/bin, and on the
+host, they're built into /host/bin. These can be overridden by setting
+LOCAL_MODULE_PATH or LOCAL_MODULE_RELATIVE_PATH. See
+Putting targets elsewhere
+for more.
+
+
Shared Libraries
+
Use the templates/shared_library file, or the
+templates/shared_library_host file.
+
Remember that on the target, we use shared libraries, and on the host,
+we use static libraries, since executable size isn't as big an issue, and it
+simplifies distribution in the SDK.
+
+
Static Libraries
+
Use the templates/static_library file, or the
+templates/static_library_host file.
+
Remember that on the target, we use shared libraries, and on the host,
+we use static libraries, since executable size isn't as big an issue, and it
+simplifies distribution in the SDK.
+
+
Using Custom Tools
+
If you have a tool that generates source files for you, it's possible
+to have the build system get the dependencies correct for it. Here are
+a couple of examples. $@ is the make built-in variable for
+"the current target." The red parts are the parts you'll
+need to change.
+
+
You need to put this after you have declared LOCAL_PATH and
+LOCAL_MODULE, because the $(local-generated-sources-dir)
+and $(local-host-generated-sources-dir) macros use these variables
+to determine where to put the files.
+
+
Example 1
+
Here, there is one generated file, called
+chartables.c, which doesn't depend on anything. And is built by the tool
+built to $(HOST_OUT_EXECUTABLES)/dftables. Note on the second to last line
+that a dependency is created on the tool.
Here as a hypothetical example, we use use cat as if it were to transform
+a file. Pretend that it does something useful. Note how we use a
+target-specific variable called PRIVATE_INPUT_FILE to store the name of the
+input file.
If you have several files that are all similar in
+name, and use the same tool, you can combine them. (here the *.lut.h files are
+the generated ones, and the *.cpp files are the input files)
Sometimes you need to set flags specifically for different platforms. Here
+is a list of which values the different build-system defined variables will be
+set to and some examples.
+
For a device build, TARGET_OS is linux (we're using
+linux!), and TARGET_ARCH is arm.
+
For a simulator build, TARGET_OS and TARGET_ARCH
+are set to the same as HOST_OS and HOST_ARCH are
+on your platform. TARGET_PRODUCT is the name of the target
+hardware/product you are building for. The value sim is used
+for the simulator. We haven't thought through the full extent of customization
+that will happen here, but likely there will be additional UI configurations
+specified here as well.
+
+
+
+ HOST_OS
+ linux
+ darwin
+ (cygwin)
+
+
+ HOST_ARCH
+ x86
+
+
+ HOST_BUILD_TYPE
+ release
+ debug
+
+
+
+
+ TARGET_OS
+ linux
+ darwin
+ (cygwin)
+
+
+ TARGET_ARCH
+ arm
+ x86
+
+
+ TARGET_BUILD_TYPE
+ release
+ debug
+
+
+ TARGET_PRODUCT
+ sim
+ dream
+ sooner
+
+
+
+
+
Some Examples
+
ifeq ($(TARGET_BUILD_TYPE),release)
+LOCAL_CFLAGS += -DNDEBUG=1
+endif
+
+# from libutils
+ifeq ($(TARGET_OS),linux)
+# Use the futex based mutex and condition variable
+# implementation from android-arm because it's shared mem safe
+LOCAL_SRC_FILES += futex_synchro.c
+LOCAL_LDLIBS += -lrt -ldl
+endif
+
+
+
+
+
Putting modules elsewhere
+
If you have modules that normally go somewhere, and you need to have them
+build somewhere else, read this.
+
If you have modules that need to go in a subdirectory of their normal
+location, for example HAL modules that need to go in /system/lib/hw or
+/vendor/lib/hw, set LOCAL_MODULE_RELATIVE_PATH in your Android.mk, for
+example:
+
+LOCAL_MODULE_RELATIVE_PATH := hw
+
+
If you have modules that need to go in an entirely different location, for
+example the root filesystem instead of in /system, add these lines to your
+Android.mk:
For executables and libraries, you need to specify a
+LOCAL_UNSTRIPPED_PATH location if you specified a
+LOCAL_MODULE_PATH, because on target builds, we keep
+the unstripped executables so GDB can find the symbols.
+LOCAL_UNSTRIPPED_PATH is not necessary if you only specified
+LOCAL_MODULE_RELATIVE_PATH.
+
Look in config/envsetup.make for all of the variables defining
+places to build things.
+
FYI: If you're installing an executable to /sbin, you probably also want to
+set LOCAL_FORCE_STATIC_EXCUTABLE := true in your Android.mk, which
+will force the linker to only accept static libraries.
+
+
+
Android.mk variables
+
These are the variables that you'll commonly see in Android.mk files, listed
+alphabetically.
+
But first, a note on variable naming:
+
+
LOCAL_ - These variables are set per-module. They are cleared
+ by the include $(CLEAR_VARS) line, so you can rely on them
+ being empty after including that file. Most of the variables you'll use
+ in most modules are LOCAL_ variables.
+
PRIVATE_ - These variables are make-target-specific variables. That
+ means they're only usable within the commands for that module. It also
+ means that they're unlikely to change behind your back from modules that
+ are included after yours. This
+ link to the make documentation
+ describes more about target-specific variables. Please note that there
+ are a couple of these laying around the tree that aren't prefixed with
+ PRIVATE_. It is safe, and they will be fixed as they are discovered.
+ Sorry for the confusion.
+
INTERNAL_ - These variables are critical to functioning of
+ the build system, so you shouldn't create variables named like this, and
+ you probably shouldn't be messing with these variables in your makefiles.
+
+
HOST_ and TARGET_ - These contain the directories
+ and definitions that are specific to either the host or the target builds.
+ Do not set variables that start with HOST_ or TARGET_ in your makefiles.
+
+
BUILD_ and CLEAR_VARS - These contain the names of
+ well-defined template makefiles to include. Some examples are CLEAR_VARS
+ and BUILD_HOST_PACKAGE.
+
Any other name is fair-game for you to use in your Android.mk. However,
+ remember that this is a non-recursive build system, so it is possible that
+ your variable will be changed by another Android.mk included later, and be
+ different when the commands for your rule / module are executed.
+
+
+
+
LOCAL_ASSET_FILES
+
In Android.mk files that include $(BUILD_PACKAGE) set this
+to the set of files you want built into your app. Usually:
+
LOCAL_ASSET_FILES += $(call find-subdir-assets)
+
This will probably change when we switch to ant for the apps' build
+system.
+
+
LOCAL_CC
+
If you want to use a different C compiler for this module, set LOCAL_CC
+to the path to the compiler. If LOCAL_CC is blank, the appropriate default
+compiler is used.
+
+
LOCAL_CXX
+
If you want to use a different C++ compiler for this module, set LOCAL_CXX
+to the path to the compiler. If LOCAL_CXX is blank, the appropriate default
+compiler is used.
+
+
LOCAL_CFLAGS
+
If you have additional flags to pass into the C or C++ compiler, add
+them here. For example:
+
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1
+
+
LOCAL_CPPFLAGS
+
If you have additional flags to pass into only the C++ compiler, add
+them here. For example:
+
LOCAL_CPPFLAGS += -ffriend-injection
+LOCAL_CPPFLAGS is guaranteed to be after LOCAL_CFLAGS
+on the compile line, so you can use it to override flags listed in
+LOCAL_CFLAGS.
+
+
LOCAL_CPP_EXTENSION
+
If your C++ files end in something other than ".cpp",
+you can specify the custom extension here. For example:
+
LOCAL_CPP_EXTENSION := .cc
+Note that all C++ files for a given module must have the same
+extension; it is not currently possible to mix different extensions.
+
+
LOCAL_NO_DEFAULT_COMPILER_FLAGS
+
Normally, the compile line for C and C++ files includes global include
+paths and global cflags. If LOCAL_NO_DEFAULT_COMPILER_FLAGS
+is non-empty, none of the default includes or flags will be used when compiling
+C and C++ files in this module.
+LOCAL_C_INCLUDES, LOCAL_CFLAGS, and
+LOCAL_CPPFLAGS will still be used in this case, as will
+any DEBUG_CFLAGS that are defined for the module.
+
+
LOCAL_COPY_HEADERS
+
This will be going away.
+
The set of files to copy to the install include tree. You must also
+supply LOCAL_COPY_HEADERS_TO.
+
This is going away because copying headers messes up the error messages, and
+may lead to people editing those headers instead of the correct ones. It also
+makes it easier to do bad layering in the system, which we want to avoid. We
+also aren't doing a C/C++ SDK, so there is no ultimate requirement to copy any
+headers.
+
+
LOCAL_COPY_HEADERS_TO
+
This will be going away.
+
The directory within "include" to copy the headers listed in
+LOCAL_COPY_HEADERS to.
+
This is going away because copying headers messes up the error messages, and
+may lead to people editing those headers instead of the correct ones. It also
+makes it easier to do bad layering in the system, which we want to avoid. We
+also aren't doing a C/C++ SDK, so there is no ultimate requirement to copy any
+headers.
+
+
LOCAL_C_INCLUDES
+
Additional directories to instruct the C/C++ compilers to look for header
+files in. These paths are rooted at the top of the tree. Use
+LOCAL_PATH if you have subdirectories of your own that you
+want in the include paths. For example:
You should not add subdirectories of include to
+LOCAL_C_INCLUDES, instead you should reference those files
+in the #include statement with their subdirectories. For
+example:
There are some components that are doing this wrong, and should be cleaned
+up.
+
+
LOCAL_MODULE_TAGS
+
Set LOCAL_MODULE_TAGS to any number of whitespace-separated
+tags. If the tag list is empty or contains droid, the module
+will get installed as part of a make droid. Otherwise, it will
+only get installed by running make <your-module>
+or with the make all pseudotarget.
+
+
LOCAL_REQUIRED_MODULES
+
Set LOCAL_REQUIRED_MODULES to any number of whitespace-separated
+module names, like "libblah" or "Email". If this module is installed, all
+of the modules that it requires will be installed as well. This can be
+used to, e.g., ensure that necessary shared libraries or providers are
+installed when a given app is installed.
+
+
LOCAL_FORCE_STATIC_EXECUTABLE
+
If your executable should be linked statically, set
+LOCAL_FORCE_STATIC_EXECUTABLE:=true. There is a very short
+list of libraries that we have in static form (currently only libc). This is
+really only used for executables in /sbin on the root filesystem.
+
+
LOCAL_GENERATED_SOURCES
+
Files that you add to LOCAL_GENERATED_SOURCES will be
+automatically generated and then linked in when your module is built.
+See the Custom Tools template makefile for an
+example.
+
+
LOCAL_JAVACFLAGS
+
If you have additional flags to pass into the javac compiler, add
+them here. For example:
+
LOCAL_JAVACFLAGS += -Xlint:deprecation
+
+
LOCAL_JAVA_LIBRARIES
+
When linking Java apps and libraries, LOCAL_JAVA_LIBRARIES
+specifies which sets of java classes to include. Currently there are
+two of these: core and framework.
+In most cases, it will look like this:
+
LOCAL_JAVA_LIBRARIES := core framework
+
Note that setting LOCAL_JAVA_LIBRARIES is not necessary
+(and is not allowed) when building an APK with
+"include $(BUILD_PACKAGE)". The appropriate libraries
+will be included automatically.
+
+
LOCAL_LDFLAGS
+
You can pass additional flags to the linker by setting
+LOCAL_LDFLAGS. Keep in mind that the order of parameters is
+very important to ld, so test whatever you do on all platforms.
+
+
LOCAL_LDLIBS
+
LOCAL_LDLIBS allows you to specify additional libraries
+that are not part of the build for your executable or library. Specify
+the libraries you want in -lxxx format; they're passed directly to the
+link line. However, keep in mind that there will be no dependency generated
+for these libraries. It's most useful in simulator builds where you want
+to use a library preinstalled on the host. The linker (ld) is a particularly
+fussy beast, so it's sometimes necessary to pass other flags here if you're
+doing something sneaky. Some examples:
If your package doesn't have a manifest (AndroidManifest.xml), then
+set LOCAL_NO_MANIFEST:=true. The common resources package
+does this.
+
+
LOCAL_PACKAGE_NAME
+
LOCAL_PACKAGE_NAME is the name of an app. For example,
+Dialer, Contacts, etc. This will probably change or go away when we switch
+to an ant-based build system for the apps.
+
+
LOCAL_PATH
+
The directory your Android.mk file is in. You can set it by putting the
+following as the first line in your Android.mk:
+
LOCAL_PATH := $(my-dir)
+
The my-dir macro uses the
+MAKEFILE_LIST
+variable, so you must call it before you include any other makefiles. Also,
+consider that any subdirectories you inlcude might reset LOCAL_PATH, so do your
+own stuff before you include them. This also means that if you try to write
+several include lines that reference LOCAL_PATH,
+it won't work, because those included makefiles might reset LOCAL_PATH.
+
+
LOCAL_POST_PROCESS_COMMAND
+
For host executables, you can specify a command to run on the module
+after it's been linked. You might have to go through some contortions
+to get variables right because of early or late variable evaluation:
When including $(BUILD_PREBUILT) or $(BUILD_HOST_PREBUILT), set these to
+executables that you want copied. They're located automatically into the
+right bin directory.
+
+
LOCAL_PREBUILT_LIBS
+
When including $(BUILD_PREBUILT) or $(BUILD_HOST_PREBUILT), set these to
+libraries that you want copied. They're located automatically into the
+right lib directory.
+
+
LOCAL_SHARED_LIBRARIES
+
These are the libraries you directly link against. You don't need to
+pass transitively included libraries. Specify the name without the suffix:
The build system looks at LOCAL_SRC_FILES to know what source
+files to compile -- .cpp .c .y .l .java. For lex and yacc files, it knows
+how to correctly do the intermediate .h and .c/.cpp files automatically. If
+the files are in a subdirectory of the one containing the Android.mk, prefix
+them with the directory name:
These are the static libraries that you want to include in your module.
+Mostly, we use shared libraries, but there are a couple of places, like
+executables in sbin and host executables where we use static libraries instead.
+
LOCAL_MODULE is the name of what's supposed to be generated
+from your Android.mk. For exmample, for libkjs, the LOCAL_MODULE
+is "libkjs" (the build system adds the appropriate suffix -- .so .dylib .dll).
+For app modules, use LOCAL_PACKAGE_NAME instead of
+LOCAL_MODULE. We're planning on switching to ant for the apps,
+so this might become moot.
+
+
LOCAL_MODULE_PATH
+
Instructs the build system to put the module somewhere other than what's
+normal for its type. If you override this, make sure you also set
+LOCAL_UNSTRIPPED_PATH if it's an executable or a shared library
+so the unstripped binary has somewhere to go. An error will occur if you forget
+to.
Instructs the build system to put the module in a subdirectory under the
+directory that is normal for its type. If you set this you do not need to
+set LOCAL_UNSTRIPPED_PATH, the unstripped binaries will also use
+the relative path.
Instructs the build system to put the unstripped version of the module
+somewhere other than what's normal for its type. Usually, you override this
+because you overrode LOCAL_MODULE_PATH for an executable or a
+shared library. If you overrode LOCAL_MODULE_PATH, but not
+LOCAL_UNSTRIPPED_PATH, an error will occur.
These are the static libraries that you want to include in your module without allowing
+the linker to remove dead code from them. This is mostly useful if you want to add a static library
+to a shared library and have the static library's content exposed from the shared library.
+
Any flags to pass to invocations of yacc for your module. A known limitation
+here is that the flags will be the same for all invocations of YACC for your
+module. This can be fixed. If you ever need it to be, just ask.
+
LOCAL_YACCFLAGS := -p kjsyy
+
+
+
+
Implementation Details
+
+
You should never have to touch anything in the config directory unless
+you're adding a new platform, new tools, or adding new features to the
+build system. In general, please consult with the build system owner(s)
+(android-build-team) before you go
+mucking around in here. That said, here are some notes on what's going on
+under the hood.
+
+
Environment Setup / buildspec.mk Versioning
+
In order to make easier for people when the build system changes, when
+it is necessary to make changes to buildspec.mk or to rerun the environment
+setup scripts, they contain a version number in the variable
+BUILD_ENV_SEQUENCE_NUMBER. If this variable does not match what the build
+system expects, it fails printing an error message explaining what happened.
+If you make a change that requires an update, you need to update two places
+so this message will be printed.
+
+
In config/envsetup.make, increment the
+ CORRECT_BUILD_ENV_SEQUENCE_NUMBER definition.
+
In buildspec.mk.default, update the BUILD_ENV_SEQUENCE_DUMBER
+ definition to match the one in config/envsetup.make
+
+The scripts automatically get the value from the build system, so they will
+trigger the warning as well.
+
+
+
Additional makefile variables
+
You probably shouldn't use these variables. Please consult
+android-build-team before using them.
+These are mostly there for workarounds for other issues, or things that aren't
+completely done right.
+
+
LOCAL_ADDITIONAL_DEPENDENCIES
+
If your module needs to depend on anything else that
+isn't actually built in to it, you can add those make targets to
+LOCAL_ADDITIONAL_DEPENDENCIES. Usually this is a workaround
+for some other dependency that isn't created automatically.
+
+
LOCAL_BUILT_MODULE
+
When a module is built, the module is created in an intermediate
+directory then copied to its final location. LOCAL_BUILT_MODULE is
+the full path to the intermediate file. See LOCAL_INSTALLED_MODULE
+for the path to the final installed location of the module.
+
+
LOCAL_HOST
+
Set by the host_xxx.make includes to tell base_rules.make and the other
+includes that we're building for the host. Kenneth did this as part of
+openbinder, and I would like to clean it up so the rules, includes and
+definitions aren't duplicated for host and target.
+
+
LOCAL_INSTALLED_MODULE
+
The fully qualified path name of the final location of the module.
+See LOCAL_BUILT_MODULE for the location of the intermediate file that
+the make rules should actually be constructing.
+
+
LOCAL_REPLACE_VARS
+
Used in some stuff remaining from the openbinder for building scripts
+with particular values set,
+
+
LOCAL_SCRIPTS
+
Used in some stuff remaining from the openbinder build system that we
+might find handy some day.
+
+
LOCAL_MODULE_CLASS
+
Which kind of module this is. This variable is used to construct other
+variable names used to locate the modules. See base_rules.make and
+envsetup.make.
+
+
LOCAL_MODULE_NAME
+
Set to the leaf name of the LOCAL_BUILT_MODULE. I'm not sure,
+but it looks like it's just used in the WHO_AM_I variable to identify
+in the pretty printing what's being built.
+
+
LOCAL_MODULE_SUFFIX
+
The suffix that will be appended to LOCAL_MODULE to form
+LOCAL_MODULE_NAME. For example, .so, .a, .dylib.
+
+
LOCAL_STRIP_MODULE
+
Calculated in base_rules.make to determine if this module should actually
+be stripped or not, based on whether LOCAL_STRIPPABLE_MODULE
+is set, and whether the combo is configured to ever strip modules. With
+Iliyan's stripping tool, this might change.
+
+
LOCAL_STRIPPABLE_MODULE
+
Set by the include makefiles if that type of module is strippable.
+Executables and shared libraries are.
+
+
LOCAL_SYSTEM_SHARED_LIBRARIES
+
Used while building the base libraries: libc, libm, libdl. Usually
+it should be set to "none," as it is in $(CLEAR_VARS). When building
+these libraries, it's set to the ones they link against. For example,
+libc, libstdc++ and libdl don't link against anything, and libm links against
+libc. Normally, when the value is none, these libraries are automatically
+linked in to executables and libraries, so you don't need to specify them
+manually.
+
+
+
+
diff --git a/build/core/build_id.mk b/build/core/build_id.mk
new file mode 100644
index 0000000..2279028
--- /dev/null
+++ b/build/core/build_id.mk
@@ -0,0 +1,21 @@
+#
+# Copyright (C) 2008 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.
+#
+# BUILD_ID is usually used to specify the branch name
+# (like "MAIN") or a branch name and a release candidate
+# (like "CRB01"). It must be a single word, and is
+# capitalized by convention.
+
+export BUILD_ID=LMY49F
diff --git a/build/core/checktree b/build/core/checktree
new file mode 100755
index 0000000..b0b9cfa
--- /dev/null
+++ b/build/core/checktree
@@ -0,0 +1,113 @@
+#!/usr/bin/python -E
+
+import sys, os, re
+
+excludes = [r'.*?/\.obj.*?',
+ r'.*?~',
+ r'.*?\/.DS_Store',
+ r'.*?\/.gdb_history',
+ r'.*?\/buildspec.mk',
+ r'.*?/\..*?\.swp',
+ r'.*?/out/.*?',
+ r'.*?/install/.*?']
+
+excludes_compiled = map(re.compile, excludes)
+
+def filter_excludes(str):
+ for e in excludes_compiled:
+ if e.match(str):
+ return False
+ return True
+
+def split_perforce_parts(s):
+ spaces = ((s.count(" ") + 1) / 3) * 2
+ pos = 0
+ while spaces > 0:
+ pos = s.find(" ", pos) + 1
+ spaces = spaces - 1
+ return s[pos:]
+
+def quotate(s):
+ return '"' + s + '"'
+
+class PerforceError(Exception):
+ def __init__(self,value):
+ self.value = value
+ def __str__(self):
+ return repr(self.value)
+
+
+def run(command, regex, filt):
+ def matchit(s):
+ m = regex_compiled.match(s)
+ if m:
+ return m.group(1)
+ else:
+ return ""
+ def filterit(s):
+ if filt_compiled.match(s):
+ return True
+ else:
+ return False
+
+ fd = os.popen(command);
+ lines = fd.readlines()
+ status = fd.close()
+ if status:
+ raise PerforceError("error calling " + command)
+
+ regex_compiled = re.compile(regex)
+ filt_compiled = re.compile(filt)
+
+ if len(lines) >= 1:
+ lines = filter(filterit, lines)
+ if len(lines) >= 1:
+ return map(matchit, lines)
+ return None
+
+try:
+ if len(sys.argv) == 1:
+ do_exclude = True
+ elif len(sys.argv) == 2 and sys.argv[1] == "-a":
+ do_exclude = False
+ else:
+ print "usage: checktree [-a]"
+ print " -a don't filter common crud in the tree"
+ sys.exit(1)
+
+ have = run("p4 have ...", r'[^#]+#[0-9]+ - (.*)', r'.*')
+
+ cwd = os.getcwd()
+ files = run("find . -not -type d", r'.(.*)', r'.*')
+ files = map(lambda s: cwd+s, files)
+
+ added_depot_path = run("p4 opened ...", r'([^#]+)#.*', r'.*?#[0-9]+ - add .*');
+ added = []
+ if added_depot_path:
+ added_depot_path = map(quotate, added_depot_path)
+
+ where = "p4 where " + " ".join(added_depot_path)
+ added = run(where, r'(.*)', r'.*')
+ added = map(split_perforce_parts, added)
+
+ extras = []
+
+ # Python 2.3 -- still default on Mac OS X -- does not have set()
+ # Make dict's here to support the "in" operations below
+ have = dict().fromkeys(have, 1)
+ added = dict().fromkeys(added, 1)
+
+ for file in files:
+ if not file in have:
+ if not file in added:
+ extras.append(file)
+
+ if do_exclude:
+ extras = filter(filter_excludes, extras)
+
+ for s in extras:
+ print s.replace(" ", "\\ ")
+
+except PerforceError, e:
+ sys.exit(2)
+
diff --git a/build/core/clang/HOST_x86.mk b/build/core/clang/HOST_x86.mk
new file mode 100644
index 0000000..510a74d
--- /dev/null
+++ b/build/core/clang/HOST_x86.mk
@@ -0,0 +1,64 @@
+
+include $(BUILD_SYSTEM)/clang/x86.mk
+include $(BUILD_SYSTEM)/clang/HOST_x86_common.mk
+
+ifeq ($(HOST_OS),linux)
+CLANG_CONFIG_x86_HOST_TRIPLE := i686-linux-gnu
+CLANG_CONFIG_x86_HOST_COMBO_EXTRA_ASFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_ASFLAGS)
+CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CFLAGS)
+CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CPPFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CPPFLAGS)
+CLANG_CONFIG_x86_HOST_COMBO_EXTRA_LDFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_LDFLAGS)
+endif
+ifeq ($(HOST_OS),darwin)
+CLANG_CONFIG_x86_HOST_TRIPLE := i686-apple-darwin
+endif
+ifeq ($(HOST_OS),windows)
+CLANG_CONFIG_x86_HOST_TRIPLE := i686-pc-mingw32
+endif
+
+CLANG_CONFIG_x86_HOST_EXTRA_ASFLAGS := \
+ $(CLANG_CONFIG_EXTRA_ASFLAGS) \
+ $(CLANG_CONFIG_HOST_EXTRA_ASFLAGS) \
+ $(CLANG_CONFIG_x86_EXTRA_ASFLAGS) \
+ $(CLANG_CONFIG_x86_HOST_COMBO_EXTRA_ASFLAGS) \
+ -target $(CLANG_CONFIG_x86_HOST_TRIPLE)
+
+CLANG_CONFIG_x86_HOST_EXTRA_CFLAGS := \
+ $(CLANG_CONFIG_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_HOST_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_x86_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_x86_HOST_EXTRA_ASFLAGS)
+
+CLANG_CONFIG_x86_HOST_EXTRA_CPPFLAGS := \
+ $(CLANG_CONFIG_EXTRA_CPPFLAGS) \
+ $(CLANG_CONFIG_HOST_EXTRA_CPPFLAGS) \
+ $(CLANG_CONFIG_x86_EXTRA_CPPFLAGS) \
+ $(CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CPPFLAGS) \
+ -target $(CLANG_CONFIG_x86_HOST_TRIPLE)
+
+CLANG_CONFIG_x86_HOST_EXTRA_LDFLAGS := \
+ $(CLANG_CONFIG_EXTRA_LDFLAGS) \
+ $(CLANG_CONFIG_HOST_EXTRA_LDFLAGS) \
+ $(CLANG_CONFIG_x86_EXTRA_LDFLAGS) \
+ $(CLANG_CONFIG_x86_HOST_COMBO_EXTRA_LDFLAGS) \
+ -target $(CLANG_CONFIG_x86_HOST_TRIPLE)
+
+define $(clang_2nd_arch_prefix)convert-to-host-clang-flags
+ $(strip \
+ $(call subst-clang-incompatible-x86-flags,\
+ $(filter-out $(CLANG_CONFIG_x86_UNKNOWN_CFLAGS),\
+ $(1))))
+endef
+
+$(clang_2nd_arch_prefix)CLANG_HOST_GLOBAL_CFLAGS := \
+ $(call $(clang_2nd_arch_prefix)convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_GLOBAL_CFLAGS)) \
+ $(CLANG_CONFIG_x86_HOST_EXTRA_CFLAGS)
+
+$(clang_2nd_arch_prefix)CLANG_HOST_GLOBAL_CPPFLAGS := \
+ $(call $(clang_2nd_arch_prefix)convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_GLOBAL_CPPFLAGS)) \
+ $(CLANG_CONFIG_x86_HOST_EXTRA_CPPFLAGS)
+
+$(clang_2nd_arch_prefix)CLANG_HOST_GLOBAL_LDFLAGS := \
+ $(call $(clang_2nd_arch_prefix)convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS)) \
+ $(CLANG_CONFIG_x86_HOST_EXTRA_LDFLAGS)
diff --git a/build/core/clang/HOST_x86_64.mk b/build/core/clang/HOST_x86_64.mk
new file mode 100644
index 0000000..6b94525
--- /dev/null
+++ b/build/core/clang/HOST_x86_64.mk
@@ -0,0 +1,64 @@
+
+include $(BUILD_SYSTEM)/clang/x86_64.mk
+include $(BUILD_SYSTEM)/clang/HOST_x86_common.mk
+
+ifeq ($(HOST_OS),linux)
+CLANG_CONFIG_x86_64_HOST_TRIPLE := x86_64-linux-gnu
+CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_ASFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_ASFLAGS)
+CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CFLAGS)
+CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CPPFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CPPFLAGS)
+CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_LDFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_LDFLAGS)
+endif
+ifeq ($(HOST_OS),darwin)
+CLANG_CONFIG_x86_64_HOST_TRIPLE := x86_64-apple-darwin
+endif
+ifeq ($(HOST_OS),windows)
+CLANG_CONFIG_x86_64_HOST_TRIPLE := x86_64-pc-mingw64
+endif
+
+CLANG_CONFIG_x86_64_HOST_EXTRA_ASFLAGS := \
+ $(CLANG_CONFIG_EXTRA_ASFLAGS) \
+ $(CLANG_CONFIG_HOST_EXTRA_ASFLAGS) \
+ $(CLANG_CONFIG_x86_64_EXTRA_ASFLAGS) \
+ $(CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_ASFLAGS) \
+ -target $(CLANG_CONFIG_x86_64_HOST_TRIPLE)
+
+CLANG_CONFIG_x86_64_HOST_EXTRA_CFLAGS := \
+ $(CLANG_CONFIG_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_HOST_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_x86_64_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_x86_64_HOST_EXTRA_ASFLAGS)
+
+CLANG_CONFIG_x86_64_HOST_EXTRA_CPPFLAGS := \
+ $(CLANG_CONFIG_EXTRA_CPPFLAGS) \
+ $(CLANG_CONFIG_HOST_EXTRA_CPPFLAGS) \
+ $(CLANG_CONFIG_x86_64_EXTRA_CPPFLAGS) \
+ $(CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CPPFLAGS) \
+ -target $(CLANG_CONFIG_x86_64_HOST_TRIPLE)
+
+CLANG_CONFIG_x86_64_HOST_EXTRA_LDFLAGS := \
+ $(CLANG_CONFIG_EXTRA_LDFLAGS) \
+ $(CLANG_CONFIG_HOST_EXTRA_LDFLAGS) \
+ $(CLANG_CONFIG_x86_64_EXTRA_LDFLAGS) \
+ $(CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_LDFLAGS) \
+ -target $(CLANG_CONFIG_x86_64_HOST_TRIPLE)
+
+define convert-to-host-clang-flags
+ $(strip \
+ $(call subst-clang-incompatible-x86_64-flags,\
+ $(filter-out $(CLANG_CONFIG_x86_64_UNKNOWN_CFLAGS),\
+ $(1))))
+endef
+
+CLANG_HOST_GLOBAL_CFLAGS := \
+ $(call convert-to-host-clang-flags,$(HOST_GLOBAL_CFLAGS)) \
+ $(CLANG_CONFIG_x86_64_HOST_EXTRA_CFLAGS)
+
+CLANG_HOST_GLOBAL_CPPFLAGS := \
+ $(call convert-to-host-clang-flags,$(HOST_GLOBAL_CPPFLAGS)) \
+ $(CLANG_CONFIG_x86_64_HOST_EXTRA_CPPFLAGS)
+
+CLANG_HOST_GLOBAL_LDFLAGS := \
+ $(call convert-to-host-clang-flags,$(HOST_GLOBAL_LDFLAGS)) \
+ $(CLANG_CONFIG_x86_64_HOST_EXTRA_LDFLAGS)
diff --git a/build/core/clang/HOST_x86_common.mk b/build/core/clang/HOST_x86_common.mk
new file mode 100644
index 0000000..0241cb6
--- /dev/null
+++ b/build/core/clang/HOST_x86_common.mk
@@ -0,0 +1,56 @@
+# Shared by HOST_x86.mk and HOST_x86_64.mk.
+
+ifeq ($(HOST_OS),darwin)
+# nothing required here yet
+endif
+
+ifeq ($(HOST_OS),linux)
+CLANG_CONFIG_x86_LINUX_HOST_EXTRA_ASFLAGS := \
+ --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) \
+ --sysroot=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/sysroot \
+ -no-integrated-as
+
+CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CFLAGS := \
+ --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) \
+ -no-integrated-as
+
+ifneq ($(strip $($(clang_2nd_arch_prefix)HOST_IS_64_BIT)),)
+CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CPPFLAGS := \
+ --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) \
+ --sysroot=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/sysroot \
+ -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.6 \
+ -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.6/x86_64-linux \
+ -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.6/backward \
+ -no-integrated-as
+
+CLANG_CONFIG_x86_LINUX_HOST_EXTRA_LDFLAGS := \
+ --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) \
+ --sysroot=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/sysroot \
+ -B$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/bin \
+ -B$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/lib/gcc/x86_64-linux/4.6 \
+ -L$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/lib/gcc/x86_64-linux/4.6 \
+ -L$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/lib64/ \
+ -no-integrated-as
+else
+CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CPPFLAGS := \
+ --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) \
+ --sysroot=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/sysroot \
+ -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.6 \
+ -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.6/x86_64-linux/32 \
+ -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.6/backward \
+ -no-integrated-as
+
+CLANG_CONFIG_x86_LINUX_HOST_EXTRA_LDFLAGS := \
+ --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) \
+ --sysroot=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/sysroot \
+ -B$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/bin \
+ -B$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/lib/gcc/x86_64-linux/4.6/32 \
+ -L$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/lib/gcc/x86_64-linux/4.6/32 \
+ -L$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/lib32/ \
+ -no-integrated-as
+endif
+endif # Linux
+
+ifeq ($(HOST_OS),windows)
+# nothing required here yet
+endif
diff --git a/build/core/clang/TARGET_arm.mk b/build/core/clang/TARGET_arm.mk
new file mode 100644
index 0000000..59ed41f
--- /dev/null
+++ b/build/core/clang/TARGET_arm.mk
@@ -0,0 +1,57 @@
+
+include $(BUILD_SYSTEM)/clang/arm.mk
+
+CLANG_CONFIG_arm_TARGET_TRIPLE := arm-linux-androideabi
+CLANG_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX := \
+ $($(clang_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/$(CLANG_CONFIG_arm_TARGET_TRIPLE)/bin
+
+CLANG_CONFIG_arm_TARGET_EXTRA_ASFLAGS := \
+ $(CLANG_CONFIG_EXTRA_ASFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \
+ $(CLANG_CONFIG_arm_EXTRA_ASFLAGS) \
+ -target $(CLANG_CONFIG_arm_TARGET_TRIPLE) \
+ -B$(CLANG_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX)
+
+CLANG_CONFIG_arm_TARGET_EXTRA_CFLAGS := \
+ $(CLANG_CONFIG_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_arm_EXTRA_CFLAGS) \
+ -target $(CLANG_CONFIG_arm_TARGET_TRIPLE) \
+ $(CLANG_CONFIG_arm_TARGET_EXTRA_ASFLAGS)
+
+CLANG_CONFIG_arm_TARGET_EXTRA_CPPFLAGS := \
+ $(CLANG_CONFIG_EXTRA_CPPFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \
+ $(CLANG_CONFIG_arm_EXTRA_CPPFLAGS) \
+ -target $(CLANG_CONFIG_arm_TARGET_TRIPLE)
+
+CLANG_CONFIG_arm_TARGET_EXTRA_LDFLAGS := \
+ $(CLANG_CONFIG_EXTRA_LDFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \
+ $(CLANG_CONFIG_arm_EXTRA_LDFLAGS) \
+ -target $(CLANG_CONFIG_arm_TARGET_TRIPLE) \
+ -B$(CLANG_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX)
+
+
+define $(clang_2nd_arch_prefix)convert-to-clang-flags
+ $(strip \
+ $(call subst-clang-incompatible-arm-flags,\
+ $(filter-out $(CLANG_CONFIG_arm_UNKNOWN_CFLAGS),\
+ $(1))))
+endef
+
+$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CFLAGS := \
+ $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS)) \
+ $(CLANG_CONFIG_arm_TARGET_EXTRA_CFLAGS)
+
+$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CPPFLAGS := \
+ $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS)) \
+ $(CLANG_CONFIG_arm_TARGET_EXTRA_CPPFLAGS)
+
+$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_LDFLAGS := \
+ $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS)) \
+ $(CLANG_CONFIG_arm_TARGET_EXTRA_LDFLAGS)
+
+$(clang_2nd_arch_prefix)RS_TRIPLE := armv7-none-linux-gnueabi
+$(clang_2nd_arch_prefix)RS_TRIPLE_CFLAGS :=
+RS_COMPAT_TRIPLE := armv7-none-linux-gnueabi
diff --git a/build/core/clang/TARGET_arm64.mk b/build/core/clang/TARGET_arm64.mk
new file mode 100644
index 0000000..6f9e540
--- /dev/null
+++ b/build/core/clang/TARGET_arm64.mk
@@ -0,0 +1,55 @@
+
+include $(BUILD_SYSTEM)/clang/arm64.mk
+
+CLANG_CONFIG_arm64_TARGET_TRIPLE := aarch64-linux-android
+CLANG_CONFIG_arm64_TARGET_TOOLCHAIN_PREFIX := \
+ $(TARGET_TOOLCHAIN_ROOT)/$(CLANG_CONFIG_arm64_TARGET_TRIPLE)/bin
+
+CLANG_CONFIG_arm64_TARGET_EXTRA_ASFLAGS := \
+ $(CLANG_CONFIG_EXTRA_ASFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \
+ $(CLANG_CONFIG_arm64_EXTRA_ASFLAGS) \
+ -target $(CLANG_CONFIG_arm64_TARGET_TRIPLE) \
+ -B$(CLANG_CONFIG_arm64_TARGET_TOOLCHAIN_PREFIX)
+
+CLANG_CONFIG_arm64_TARGET_EXTRA_CFLAGS := \
+ $(CLANG_CONFIG_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_arm64_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_arm64_TARGET_EXTRA_ASFLAGS)
+
+CLANG_CONFIG_arm64_TARGET_EXTRA_CPPFLAGS := \
+ $(CLANG_CONFIG_EXTRA_CPPFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \
+ $(CLANG_CONFIG_arm64_EXTRA_CPPFLAGS) \
+
+CLANG_CONFIG_arm64_TARGET_EXTRA_LDFLAGS := \
+ $(CLANG_CONFIG_EXTRA_LDFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \
+ $(CLANG_CONFIG_arm64_EXTRA_LDFLAGS) \
+ -target $(CLANG_CONFIG_arm64_TARGET_TRIPLE) \
+ -B$(CLANG_CONFIG_arm64_TARGET_TOOLCHAIN_PREFIX)
+
+
+define convert-to-clang-flags
+ $(strip \
+ $(call subst-clang-incompatible-arm64-flags,\
+ $(filter-out $(CLANG_CONFIG_arm64_UNKNOWN_CFLAGS),\
+ $(1))))
+endef
+
+CLANG_TARGET_GLOBAL_CFLAGS := \
+ $(call convert-to-clang-flags,$(TARGET_GLOBAL_CFLAGS)) \
+ $(CLANG_CONFIG_arm64_TARGET_EXTRA_CFLAGS)
+
+CLANG_TARGET_GLOBAL_CPPFLAGS := \
+ $(call convert-to-clang-flags,$(TARGET_GLOBAL_CPPFLAGS)) \
+ $(CLANG_CONFIG_arm64_TARGET_EXTRA_CPPFLAGS)
+
+CLANG_TARGET_GLOBAL_LDFLAGS := \
+ $(call convert-to-clang-flags,$(TARGET_GLOBAL_LDFLAGS)) \
+ $(CLANG_CONFIG_arm64_TARGET_EXTRA_LDFLAGS)
+
+RS_TRIPLE := aarch64-linux-android
+RS_TRIPLE_CFLAGS :=
+RS_COMPAT_TRIPLE := aarch64-linux-android
diff --git a/build/core/clang/TARGET_mips.mk b/build/core/clang/TARGET_mips.mk
new file mode 100644
index 0000000..91067f5
--- /dev/null
+++ b/build/core/clang/TARGET_mips.mk
@@ -0,0 +1,55 @@
+
+include $(BUILD_SYSTEM)/clang/mips.mk
+
+CLANG_CONFIG_mips_TARGET_TRIPLE := mipsel-linux-android
+CLANG_CONFIG_mips_TARGET_TOOLCHAIN_PREFIX := \
+ $($(clang_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/mips64el-linux-android/bin
+
+CLANG_CONFIG_mips_TARGET_EXTRA_ASFLAGS := \
+ $(CLANG_CONFIG_EXTRA_ASFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \
+ $(CLANG_CONFIG_mips_EXTRA_ASFLAGS) \
+ -target $(CLANG_CONFIG_mips_TARGET_TRIPLE) \
+ -B$(CLANG_CONFIG_mips_TARGET_TOOLCHAIN_PREFIX)
+
+CLANG_CONFIG_mips_TARGET_EXTRA_CFLAGS := \
+ $(CLANG_CONFIG_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_mips_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_mips_TARGET_EXTRA_ASFLAGS)
+
+CLANG_CONFIG_mips_TARGET_EXTRA_CPPFLAGS := \
+ $(CLANG_CONFIG_EXTRA_CPPFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \
+ $(CLANG_CONFIG_mips_EXTRA_CPPFLAGS) \
+
+CLANG_CONFIG_mips_TARGET_EXTRA_LDFLAGS := \
+ $(CLANG_CONFIG_EXTRA_LDFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \
+ $(CLANG_CONFIG_mips_EXTRA_LDFLAGS) \
+ -target $(CLANG_CONFIG_mips_TARGET_TRIPLE) \
+ -B$(CLANG_CONFIG_mips_TARGET_TOOLCHAIN_PREFIX)
+
+
+define $(clang_2nd_arch_prefix)convert-to-clang-flags
+ $(strip \
+ $(call subst-clang-incompatible-mips-flags,\
+ $(filter-out $(CLANG_CONFIG_mips_UNKNOWN_CFLAGS),\
+ $(1))))
+endef
+
+$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CFLAGS := \
+ $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS)) \
+ $(CLANG_CONFIG_mips_TARGET_EXTRA_CFLAGS)
+
+$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CPPFLAGS := \
+ $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS)) \
+ $(CLANG_CONFIG_mips_TARGET_EXTRA_CPPFLAGS)
+
+$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_LDFLAGS := \
+ $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS)) \
+ $(CLANG_CONFIG_mips_TARGET_EXTRA_LDFLAGS)
+
+$(clang_2nd_arch_prefix)RS_TRIPLE := armv7-none-linux-gnueabi
+$(clang_2nd_arch_prefix)RS_TRIPLE_CFLAGS :=
+RS_COMPAT_TRIPLE := mipsel-linux-android
diff --git a/build/core/clang/TARGET_mips64.mk b/build/core/clang/TARGET_mips64.mk
new file mode 100644
index 0000000..ab69aed
--- /dev/null
+++ b/build/core/clang/TARGET_mips64.mk
@@ -0,0 +1,55 @@
+
+include $(BUILD_SYSTEM)/clang/mips64.mk
+
+CLANG_CONFIG_mips64_TARGET_TRIPLE := mips64el-linux-android
+CLANG_CONFIG_mips64_TARGET_TOOLCHAIN_PREFIX := \
+ $(TARGET_TOOLCHAIN_ROOT)/$(CLANG_CONFIG_mips64_TARGET_TRIPLE)/bin
+
+CLANG_CONFIG_mips64_TARGET_EXTRA_ASFLAGS := \
+ $(CLANG_CONFIG_EXTRA_ASFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \
+ $(CLANG_CONFIG_mips64_EXTRA_ASFLAGS) \
+ -target $(CLANG_CONFIG_mips64_TARGET_TRIPLE) \
+ -B$(CLANG_CONFIG_mips64_TARGET_TOOLCHAIN_PREFIX)
+
+CLANG_CONFIG_mips64_TARGET_EXTRA_CFLAGS := \
+ $(CLANG_CONFIG_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_mips64_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_mips64_TARGET_EXTRA_ASFLAGS)
+
+CLANG_CONFIG_mips64_TARGET_EXTRA_CPPFLAGS := \
+ $(CLANG_CONFIG_EXTRA_CPPFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \
+ $(CLANG_CONFIG_mips64_EXTRA_CPPFLAGS) \
+
+CLANG_CONFIG_mips64_TARGET_EXTRA_LDFLAGS := \
+ $(CLANG_CONFIG_EXTRA_LDFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \
+ $(CLANG_CONFIG_mips64_EXTRA_LDFLAGS) \
+ -target $(CLANG_CONFIG_mips64_TARGET_TRIPLE) \
+ -B$(CLANG_CONFIG_mips64_TARGET_TOOLCHAIN_PREFIX)
+
+
+define convert-to-clang-flags
+ $(strip \
+ $(call subst-clang-incompatible-mips64-flags,\
+ $(filter-out $(CLANG_CONFIG_mips64_UNKNOWN_CFLAGS),\
+ $(1))))
+endef
+
+CLANG_TARGET_GLOBAL_CFLAGS := \
+ $(call convert-to-clang-flags,$(TARGET_GLOBAL_CFLAGS)) \
+ $(CLANG_CONFIG_mips64_TARGET_EXTRA_CFLAGS)
+
+CLANG_TARGET_GLOBAL_CPPFLAGS := \
+ $(call convert-to-clang-flags,$(TARGET_GLOBAL_CPPFLAGS)) \
+ $(CLANG_CONFIG_mips64_TARGET_EXTRA_CPPFLAGS)
+
+CLANG_TARGET_GLOBAL_LDFLAGS := \
+ $(call convert-to-clang-flags,$(TARGET_GLOBAL_LDFLAGS)) \
+ $(CLANG_CONFIG_mips64_TARGET_EXTRA_LDFLAGS)
+
+RS_TRIPLE := aarch64-linux-android
+RS_TRIPLE_CFLAGS :=
+RS_COMPAT_TRIPLE := mips64el-linux-android
diff --git a/build/core/clang/TARGET_x86.mk b/build/core/clang/TARGET_x86.mk
new file mode 100644
index 0000000..60ee06f
--- /dev/null
+++ b/build/core/clang/TARGET_x86.mk
@@ -0,0 +1,57 @@
+
+include $(BUILD_SYSTEM)/clang/x86.mk
+
+CLANG_CONFIG_x86_TARGET_TRIPLE := i686-linux-android
+# NOTE: There is no i686-linux-android prebuilt, so we must hardcode the
+# x86_64 target instead.
+CLANG_CONFIG_x86_TARGET_TOOLCHAIN_PREFIX := \
+ $($(clang_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/x86_64-linux-android/bin
+
+CLANG_CONFIG_x86_TARGET_EXTRA_ASFLAGS := \
+ $(CLANG_CONFIG_EXTRA_ASFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \
+ $(CLANG_CONFIG_x86_EXTRA_ASFLAGS) \
+ -target $(CLANG_CONFIG_x86_TARGET_TRIPLE) \
+ -B$(CLANG_CONFIG_x86_TARGET_TOOLCHAIN_PREFIX)
+
+CLANG_CONFIG_x86_TARGET_EXTRA_CFLAGS := \
+ $(CLANG_CONFIG_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_x86_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_x86_TARGET_EXTRA_ASFLAGS)
+
+CLANG_CONFIG_x86_TARGET_EXTRA_CPPFLAGS := \
+ $(CLANG_CONFIG_EXTRA_CPPFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \
+ $(CLANG_CONFIG_x86_EXTRA_CPPFLAGS) \
+
+CLANG_CONFIG_x86_TARGET_EXTRA_LDFLAGS := \
+ $(CLANG_CONFIG_EXTRA_LDFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \
+ $(CLANG_CONFIG_x86_EXTRA_LDFLAGS) \
+ -target $(CLANG_CONFIG_x86_TARGET_TRIPLE) \
+ -B$(CLANG_CONFIG_x86_TARGET_TOOLCHAIN_PREFIX)
+
+
+define $(clang_2nd_arch_prefix)convert-to-clang-flags
+ $(strip \
+ $(call subst-clang-incompatible-x86-flags,\
+ $(filter-out $(CLANG_CONFIG_x86_UNKNOWN_CFLAGS),\
+ $(1))))
+endef
+
+$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CFLAGS := \
+ $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS)) \
+ $(CLANG_CONFIG_x86_TARGET_EXTRA_CFLAGS)
+
+$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CPPFLAGS := \
+ $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS)) \
+ $(CLANG_CONFIG_x86_TARGET_EXTRA_CPPFLAGS)
+
+$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_LDFLAGS := \
+ $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS)) \
+ $(CLANG_CONFIG_x86_TARGET_EXTRA_LDFLAGS)
+
+$(clang_2nd_arch_prefix)RS_TRIPLE := armv7-none-linux-gnueabi
+$(clang_2nd_arch_prefix)RS_TRIPLE_CFLAGS := -D__i386__
+RS_COMPAT_TRIPLE := i686-linux-android
diff --git a/build/core/clang/TARGET_x86_64.mk b/build/core/clang/TARGET_x86_64.mk
new file mode 100644
index 0000000..5561e42
--- /dev/null
+++ b/build/core/clang/TARGET_x86_64.mk
@@ -0,0 +1,55 @@
+
+include $(BUILD_SYSTEM)/clang/x86_64.mk
+
+CLANG_CONFIG_x86_64_TARGET_TRIPLE := x86_64-linux-android
+CLANG_CONFIG_x86_64_TARGET_TOOLCHAIN_PREFIX := \
+ $(TARGET_TOOLCHAIN_ROOT)/$(CLANG_CONFIG_x86_64_TARGET_TRIPLE)/bin
+
+CLANG_CONFIG_x86_64_TARGET_EXTRA_ASFLAGS := \
+ $(CLANG_CONFIG_EXTRA_ASFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \
+ $(CLANG_CONFIG_x86_64_EXTRA_ASFLAGS) \
+ -target $(CLANG_CONFIG_x86_64_TARGET_TRIPLE) \
+ -B$(CLANG_CONFIG_x86_64_TARGET_TOOLCHAIN_PREFIX)
+
+CLANG_CONFIG_x86_64_TARGET_EXTRA_CFLAGS := \
+ $(CLANG_CONFIG_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_x86_64_EXTRA_CFLAGS) \
+ $(CLANG_CONFIG_x86_64_TARGET_EXTRA_ASFLAGS)
+
+CLANG_CONFIG_x86_64_TARGET_EXTRA_CPPFLAGS := \
+ $(CLANG_CONFIG_EXTRA_CPPFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \
+ $(CLANG_CONFIG_x86_64_EXTRA_CPPFLAGS) \
+
+CLANG_CONFIG_x86_64_TARGET_EXTRA_LDFLAGS := \
+ $(CLANG_CONFIG_EXTRA_LDFLAGS) \
+ $(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \
+ $(CLANG_CONFIG_x86_64_EXTRA_LDFLAGS) \
+ -target $(CLANG_CONFIG_x86_64_TARGET_TRIPLE) \
+ -B$(CLANG_CONFIG_x86_64_TARGET_TOOLCHAIN_PREFIX)
+
+
+define convert-to-clang-flags
+ $(strip \
+ $(call subst-clang-incompatible-x86_64-flags,\
+ $(filter-out $(CLANG_CONFIG_x86_64_UNKNOWN_CFLAGS),\
+ $(1))))
+endef
+
+CLANG_TARGET_GLOBAL_CFLAGS := \
+ $(call convert-to-clang-flags,$(TARGET_GLOBAL_CFLAGS)) \
+ $(CLANG_CONFIG_x86_64_TARGET_EXTRA_CFLAGS)
+
+CLANG_TARGET_GLOBAL_CPPFLAGS := \
+ $(call convert-to-clang-flags,$(TARGET_GLOBAL_CPPFLAGS)) \
+ $(CLANG_CONFIG_x86_64_TARGET_EXTRA_CPPFLAGS)
+
+CLANG_TARGET_GLOBAL_LDFLAGS := \
+ $(call convert-to-clang-flags,$(TARGET_GLOBAL_LDFLAGS)) \
+ $(CLANG_CONFIG_x86_64_TARGET_EXTRA_LDFLAGS)
+
+RS_TRIPLE := aarch64-linux-android
+RS_TRIPLE_CFLAGS := -D__x86_64__
+RS_COMPAT_TRIPLE := x86_64-linux-android
diff --git a/build/core/clang/arm.mk b/build/core/clang/arm.mk
new file mode 100644
index 0000000..22c7397
--- /dev/null
+++ b/build/core/clang/arm.mk
@@ -0,0 +1,32 @@
+# Clang flags for arm arch, target or host.
+
+CLANG_CONFIG_arm_EXTRA_ASFLAGS := \
+ -no-integrated-as
+
+CLANG_CONFIG_arm_EXTRA_CFLAGS := \
+ -no-integrated-as
+
+CLANG_CONFIG_arm_EXTRA_CPPFLAGS := \
+ -no-integrated-as
+
+CLANG_CONFIG_arm_EXTRA_LDFLAGS := \
+ -no-integrated-as
+
+# Include common unknown flags
+CLANG_CONFIG_arm_UNKNOWN_CFLAGS := \
+ $(CLANG_CONFIG_UNKNOWN_CFLAGS) \
+ -mthumb-interwork \
+ -fgcse-after-reload \
+ -frerun-cse-after-loop \
+ -frename-registers \
+ -fno-builtin-sin \
+ -fno-strict-volatile-bitfields \
+ -fno-align-jumps \
+ -Wa,--noexecstack
+
+define subst-clang-incompatible-arm-flags
+ $(subst -march=armv5te,-march=armv5t,\
+ $(subst -march=armv5e,-march=armv5,\
+ $(subst -mcpu=cortex-a15,-march=armv7-a,\
+ $(1))))
+endef
diff --git a/build/core/clang/arm64.mk b/build/core/clang/arm64.mk
new file mode 100644
index 0000000..9fb3670
--- /dev/null
+++ b/build/core/clang/arm64.mk
@@ -0,0 +1,24 @@
+# Clang flags for arm64 arch, target or host.
+
+CLANG_CONFIG_arm64_EXTRA_ASFLAGS := \
+ -no-integrated-as
+
+CLANG_CONFIG_arm64_EXTRA_CFLAGS := \
+ -no-integrated-as
+
+CLANG_CONFIG_arm64_EXTRA_LDFLAGS :=
+
+# Include common unknown flags
+CLANG_CONFIG_arm64_UNKNOWN_CFLAGS := \
+ $(CLANG_CONFIG_UNKNOWN_CFLAGS) \
+ -fgcse-after-reload \
+ -frerun-cse-after-loop \
+ -frename-registers \
+ -fno-strict-volatile-bitfields \
+ -fno-align-jumps \
+ -Wa,--noexecstack
+
+# We don't have any arm64 flags to substitute yet.
+define subst-clang-incompatible-arm64-flags
+ $(1)
+endef
diff --git a/build/core/clang/config.mk b/build/core/clang/config.mk
new file mode 100644
index 0000000..9c11797
--- /dev/null
+++ b/build/core/clang/config.mk
@@ -0,0 +1,108 @@
+## Clang configurations.
+
+# WITHOUT_CLANG covers both HOST and TARGET
+ifeq ($(WITHOUT_CLANG),true)
+WITHOUT_TARGET_CLANG := true
+WITHOUT_HOST_CLANG := true
+endif
+
+LLVM_PREBUILTS_PATH := prebuilts/clang/$(BUILD_OS)-x86/host/3.5/bin
+LLVM_PREBUILTS_HEADER_PATH := prebuilts/clang/$(BUILD_OS)-x86/host/3.5/lib/clang/3.5/include/
+
+CLANG := $(LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX)
+CLANG_CXX := $(LLVM_PREBUILTS_PATH)/clang++$(BUILD_EXECUTABLE_SUFFIX)
+LLVM_AS := $(LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX)
+LLVM_LINK := $(LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX)
+
+CLANG_TBLGEN := $(BUILD_OUT_EXECUTABLES)/clang-tblgen$(BUILD_EXECUTABLE_SUFFIX)
+LLVM_TBLGEN := $(BUILD_OUT_EXECUTABLES)/llvm-tblgen$(BUILD_EXECUTABLE_SUFFIX)
+
+# The C/C++ compiler can be wrapped by setting the CC/CXX_WRAPPER vars.
+ifdef CC_WRAPPER
+ ifneq ($(CC_WRAPPER),$(firstword $(CLANG)))
+ CLANG := $(CC_WRAPPER) $(CLANG)
+ endif
+endif
+ifdef CXX_WRAPPER
+ ifneq ($(CXX_WRAPPER),$(firstword $(CLANG_CXX)))
+ CLANG_CXX := $(CXX_WRAPPER) $(CLANG_CXX)
+ endif
+endif
+
+# Clang flags for all host or target rules
+CLANG_CONFIG_EXTRA_ASFLAGS :=
+CLANG_CONFIG_EXTRA_CFLAGS :=
+CLANG_CONFIG_EXTRA_CPPFLAGS :=
+CLANG_CONFIG_EXTRA_LDFLAGS :=
+
+CLANG_CONFIG_EXTRA_CFLAGS += \
+ -D__compiler_offsetof=__builtin_offsetof
+
+# Help catch common 32/64-bit errors.
+CLANG_CONFIG_EXTRA_CFLAGS += \
+ -Werror=int-conversion
+
+# Workaround for ccache with clang.
+# See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html.
+CLANG_CONFIG_EXTRA_CFLAGS += \
+ -Wno-unused-command-line-argument
+
+CLANG_CONFIG_UNKNOWN_CFLAGS := \
+ -funswitch-loops \
+ -fno-tree-sra \
+ -finline-limit=64 \
+ -Wno-psabi \
+ -Wno-unused-but-set-variable \
+ -Wno-unused-but-set-parameter \
+ -Wmaybe-uninitialized \
+ -Wno-maybe-uninitialized \
+ -Wno-error=maybe-uninitialized \
+ -fno-canonical-system-headers
+
+# Clang flags for all host rules
+CLANG_CONFIG_HOST_EXTRA_ASFLAGS :=
+CLANG_CONFIG_HOST_EXTRA_CFLAGS :=
+CLANG_CONFIG_HOST_EXTRA_CPPFLAGS :=
+CLANG_CONFIG_HOST_EXTRA_LDFLAGS :=
+
+# Clang flags for all target rules
+CLANG_CONFIG_TARGET_EXTRA_ASFLAGS :=
+CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc
+CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc
+CLANG_CONFIG_TARGET_EXTRA_LDFLAGS :=
+
+# HOST config
+clang_2nd_arch_prefix :=
+include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk
+
+# HOST_2ND_ARCH config
+ifdef HOST_2ND_ARCH
+clang_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/clang/HOST_$(HOST_2ND_ARCH).mk
+endif
+
+# TARGET config
+clang_2nd_arch_prefix :=
+include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk
+
+# TARGET_2ND_ARCH config
+ifdef TARGET_2ND_ARCH
+clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk
+endif
+
+
+# Clang compiler-specific libc headers
+CLANG_CONFIG_EXTRA_HOST_C_INCLUDES := $(LLVM_PREBUILTS_HEADER_PATH)
+CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES := $(LLVM_PREBUILTS_HEADER_PATH) $(TARGET_OUT_HEADERS)/clang
+
+# Address sanitizer clang config
+ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan_$(TARGET_ARCH)_android
+ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address -fno-omit-frame-pointer
+ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
+ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl $(ADDRESS_SANITIZER_RUNTIME_LIBRARY)
+ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
+
+# This allows us to use the superset of functionality that compiler-rt
+# provides to Clang (for supporting features like -ftrapv).
+COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras
diff --git a/build/core/clang/mips.mk b/build/core/clang/mips.mk
new file mode 100644
index 0000000..08daf40
--- /dev/null
+++ b/build/core/clang/mips.mk
@@ -0,0 +1,20 @@
+# Clang flags for mips arch, target or host.
+
+CLANG_CONFIG_mips_EXTRA_ASFLAGS :=
+CLANG_CONFIG_mips_EXTRA_CFLAGS :=
+CLANG_CONFIG_mips_EXTRA_LDFLAGS :=
+
+# Include common unknown flags
+CLANG_CONFIG_mips_UNKNOWN_CFLAGS := \
+ $(CLANG_CONFIG_UNKNOWN_CFLAGS) \
+ -fno-strict-volatile-bitfields \
+ -fgcse-after-reload \
+ -frerun-cse-after-loop \
+ -frename-registers \
+ -msynci \
+ -mno-fused-madd
+
+# We don't have any mips flags to substitute yet.
+define subst-clang-incompatible-mips-flags
+ $(1)
+endef
diff --git a/build/core/clang/mips64.mk b/build/core/clang/mips64.mk
new file mode 100644
index 0000000..612175c
--- /dev/null
+++ b/build/core/clang/mips64.mk
@@ -0,0 +1,20 @@
+# Clang flags for mips64 arch, target or host.
+
+CLANG_CONFIG_mips64_EXTRA_ASFLAGS :=
+CLANG_CONFIG_mips64_EXTRA_CFLAGS :=
+CLANG_CONFIG_mips64_EXTRA_LDFLAGS :=
+
+# Include common unknown flags
+CLANG_CONFIG_mips64_UNKNOWN_CFLAGS := \
+ $(CLANG_CONFIG_UNKNOWN_CFLAGS) \
+ -fno-strict-volatile-bitfields \
+ -fgcse-after-reload \
+ -frerun-cse-after-loop \
+ -frename-registers \
+ -msynci \
+ -mno-fused-madd
+
+# We don't have any mips64 flags to substitute yet.
+define subst-clang-incompatible-mips64-flags
+ $(1)
+endef
diff --git a/build/core/clang/x86.mk b/build/core/clang/x86.mk
new file mode 100644
index 0000000..69c3fb2
--- /dev/null
+++ b/build/core/clang/x86.mk
@@ -0,0 +1,19 @@
+# Clang flags for x86 arch, target or host.
+
+CLANG_CONFIG_x86_EXTRA_ASFLAGS := \
+ -msse3
+CLANG_CONFIG_x86_EXTRA_CFLAGS :=
+CLANG_CONFIG_x86_EXTRA_LDFLAGS :=
+
+# Include common unknown flags
+CLANG_CONFIG_x86_UNKNOWN_CFLAGS := \
+ $(CLANG_CONFIG_UNKNOWN_CFLAGS) \
+ -finline-limit=300 \
+ -fno-inline-functions-called-once \
+ -mfpmath=sse \
+ -mbionic
+
+# We don't have any x86 flags to substitute yet.
+define subst-clang-incompatible-x86-flags
+ $(1)
+endef
diff --git a/build/core/clang/x86_64.mk b/build/core/clang/x86_64.mk
new file mode 100644
index 0000000..cba10d4
--- /dev/null
+++ b/build/core/clang/x86_64.mk
@@ -0,0 +1,18 @@
+# Clang flags for x86_64 arch, target or host.
+
+CLANG_CONFIG_x86_64_EXTRA_ASFLAGS :=
+CLANG_CONFIG_x86_64_EXTRA_CFLAGS :=
+CLANG_CONFIG_x86_64_EXTRA_LDFLAGS :=
+
+# Include common unknown flags
+CLANG_CONFIG_x86_64_UNKNOWN_CFLAGS := \
+ $(CLANG_CONFIG_UNKNOWN_CFLAGS) \
+ -finline-limit=300 \
+ -fno-inline-functions-called-once \
+ -mfpmath=sse \
+ -mbionic
+
+# We don't have any x86_64 flags to substitute yet.
+define subst-clang-incompatible-x86_64-flags
+ $(1)
+endef
diff --git a/build/core/cleanbuild.mk b/build/core/cleanbuild.mk
new file mode 100644
index 0000000..982274e
--- /dev/null
+++ b/build/core/cleanbuild.mk
@@ -0,0 +1,250 @@
+# Copyright (C) 2007 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.
+#
+
+# Don't bother with the cleanspecs if you are running mm/mmm
+ifeq ($(ONE_SHOT_MAKEFILE)$(dont_bother),)
+
+INTERNAL_CLEAN_STEPS :=
+
+# Builds up a list of clean steps. Creates a unique
+# id for each step by taking makefile path, INTERNAL_CLEAN_BUILD_VERSION
+# and appending an increasing number of '@' characters.
+#
+# $(1): shell command to run
+# $(2): indicate to not use makefile path as part of step id if not empty.
+# $(2) should only be used in build/core/cleanspec.mk: just for compatibility.
+define _add-clean-step
+ $(if $(strip $(INTERNAL_CLEAN_BUILD_VERSION)),, \
+ $(error INTERNAL_CLEAN_BUILD_VERSION not set))
+ $(eval _acs_makefile_prefix := $(lastword $(MAKEFILE_LIST)))
+ $(eval _acs_makefile_prefix := $(subst /,_,$(_acs_makefile_prefix)))
+ $(eval _acs_makefile_prefix := $(subst .,-,$(_acs_makefile_prefix)))
+ $(eval _acs_makefile_prefix := $(_acs_makefile_prefix)_acs)
+ $(if $($(_acs_makefile_prefix)),,\
+ $(eval $(_acs_makefile_prefix) := $(INTERNAL_CLEAN_BUILD_VERSION)))
+ $(eval $(_acs_makefile_prefix) := $($(_acs_makefile_prefix))@)
+ $(if $(strip $(2)),$(eval _acs_id := $($(_acs_makefile_prefix))),\
+ $(eval _acs_id := $(_acs_makefile_prefix)$($(_acs_makefile_prefix))))
+ $(eval INTERNAL_CLEAN_STEPS += $(_acs_id))
+ $(eval INTERNAL_CLEAN_STEP.$(_acs_id) := $(1))
+ $(eval _acs_id :=)
+ $(eval _acs_makefile_prefix :=)
+endef
+define add-clean-step
+$(eval # for build/core/cleanspec.mk, dont use makefile path as part of step id) \
+$(if $(filter %/cleanspec.mk,$(lastword $(MAKEFILE_LIST))),\
+ $(eval $(call _add-clean-step,$(1),true)),\
+ $(eval $(call _add-clean-step,$(1))))
+endef
+
+# Defines INTERNAL_CLEAN_BUILD_VERSION and the individual clean steps.
+# cleanspec.mk is outside of the core directory so that more people
+# can have permission to touch it.
+include $(BUILD_SYSTEM)/cleanspec.mk
+INTERNAL_CLEAN_BUILD_VERSION := $(strip $(INTERNAL_CLEAN_BUILD_VERSION))
+
+# If the clean_steps.mk file is missing (usually after a clean build)
+# then we won't do anything.
+CURRENT_CLEAN_BUILD_VERSION := $(INTERNAL_CLEAN_BUILD_VERSION)
+CURRENT_CLEAN_STEPS := $(INTERNAL_CLEAN_STEPS)
+
+# Read the current state from the file, if present.
+# Will set CURRENT_CLEAN_BUILD_VERSION and CURRENT_CLEAN_STEPS.
+#
+clean_steps_file := $(PRODUCT_OUT)/clean_steps.mk
+-include $(clean_steps_file)
+
+ifneq ($(CURRENT_CLEAN_BUILD_VERSION),$(INTERNAL_CLEAN_BUILD_VERSION))
+ # The major clean version is out-of-date. Do a full clean, and
+ # don't even bother with the clean steps.
+ $(info *** A clean build is required because of a recent change.)
+ $(shell rm -rf $(OUT_DIR))
+ $(info *** Done with the cleaning, now starting the real build.)
+else
+ # The major clean version is correct. Find the list of clean steps
+ # that we need to execute to get up-to-date.
+ steps := \
+ $(filter-out $(CURRENT_CLEAN_STEPS),$(INTERNAL_CLEAN_STEPS))
+ $(foreach step,$(steps), \
+ $(info Clean step: $(INTERNAL_CLEAN_STEP.$(step))) \
+ $(shell $(INTERNAL_CLEAN_STEP.$(step))) \
+ )
+
+ # Rewrite the clean step for the second arch.
+ ifdef TARGET_2ND_ARCH
+ # $(1): the clean step cmd
+ # $(2): the prefix to search for
+ # $(3): the prefix to replace with
+ define -cs-rewrite-cleanstep
+ $(if $(filter $(2)/%,$(1)),\
+ $(eval _crs_new_cmd := $(patsubst $(2)/%,$(3)/%,$(1)))\
+ $(info Clean step: $(_crs_new_cmd))\
+ $(shell $(_crs_new_cmd)))
+ endef
+ $(foreach step,$(steps), \
+ $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$(TARGET_OUT_INTERMEDIATES),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES))\
+ $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$(TARGET_OUT_SHARED_LIBRARIES),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES))\
+ $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$(TARGET_OUT_VENDOR_SHARED_LIBRARIES),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES))\
+ $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES),$(TARGET_OUT_INTERMEDIATES))\
+ $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES),$(TARGET_OUT_SHARED_LIBRARIES))\
+ $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES),$(TARGET_OUT_VENDOR_SHARED_LIBRARIES))\
+ )
+ endif
+ _crs_new_cmd :=
+ steps :=
+endif
+CURRENT_CLEAN_BUILD_VERSION :=
+CURRENT_CLEAN_STEPS :=
+
+# Write the new state to the file.
+#
+$(shell \
+ mkdir -p $(dir $(clean_steps_file)) && \
+ echo "CURRENT_CLEAN_BUILD_VERSION := $(INTERNAL_CLEAN_BUILD_VERSION)" > \
+ $(clean_steps_file) ;\
+ echo "CURRENT_CLEAN_STEPS := $(INTERNAL_CLEAN_STEPS)" >> \
+ $(clean_steps_file) \
+ )
+
+clean_steps_file :=
+INTERNAL_CLEAN_STEPS :=
+INTERNAL_CLEAN_BUILD_VERSION :=
+
+endif # if not ONE_SHOT_MAKEFILE dont_bother
+
+# Since products and build variants (unfortunately) share the same
+# PRODUCT_OUT staging directory, things can get out of sync if different
+# build configurations are built in the same tree. The following logic
+# will notice when the configuration has changed and remove the files
+# necessary to keep things consistent.
+
+previous_build_config_file := $(PRODUCT_OUT)/previous_build_config.mk
+
+# A change in the list of aapt configs warrants an installclean, too.
+aapt_config_list := $(strip $(PRODUCT_AAPT_CONFIG) $(PRODUCT_AAPT_PREF_CONFIG))
+
+current_build_config := \
+ $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)-{$(aapt_config_list)}
+aapt_config_list :=
+force_installclean := false
+
+# Read the current state from the file, if present.
+# Will set PREVIOUS_BUILD_CONFIG.
+#
+PREVIOUS_BUILD_CONFIG :=
+-include $(previous_build_config_file)
+PREVIOUS_BUILD_CONFIG := $(strip $(PREVIOUS_BUILD_CONFIG))
+ifdef PREVIOUS_BUILD_CONFIG
+ ifneq "$(current_build_config)" "$(PREVIOUS_BUILD_CONFIG)"
+ $(info *** Build configuration changed: "$(PREVIOUS_BUILD_CONFIG)" -> "$(current_build_config)")
+ ifneq ($(DISABLE_AUTO_INSTALLCLEAN),true)
+ force_installclean := true
+ else
+ $(info DISABLE_AUTO_INSTALLCLEAN is set; skipping auto-clean. Your tree may be in an inconsistent state.)
+ endif
+ endif
+endif # else, this is the first build, so no need to clean.
+PREVIOUS_BUILD_CONFIG :=
+
+# Write the new state to the file.
+#
+$(shell \
+ mkdir -p $(dir $(previous_build_config_file)) && \
+ echo "PREVIOUS_BUILD_CONFIG := $(current_build_config)" > \
+ $(previous_build_config_file) \
+ )
+previous_build_config_file :=
+current_build_config :=
+
+#
+# installclean logic
+#
+
+# The files/dirs to delete during an installclean. This includes the
+# non-common APPS directory, which may contain the wrong resources.
+#
+# Deletes all of the files that change between different build types,
+# like "make user" vs. "make sdk". This lets you work with different
+# build types without having to do a full clean each time. E.g.:
+#
+# $ make -j8 all
+# $ make installclean
+# $ make -j8 user
+# $ make installclean
+# $ make -j8 sdk
+#
+installclean_files := \
+ $(HOST_OUT)/obj/NOTICE_FILES \
+ $(HOST_OUT)/sdk \
+ $(PRODUCT_OUT)/*.img \
+ $(PRODUCT_OUT)/*.ini \
+ $(PRODUCT_OUT)/*.txt \
+ $(PRODUCT_OUT)/*.xlb \
+ $(PRODUCT_OUT)/*.zip \
+ $(PRODUCT_OUT)/kernel \
+ $(PRODUCT_OUT)/data \
+ $(PRODUCT_OUT)/skin \
+ $(PRODUCT_OUT)/obj/APPS \
+ $(PRODUCT_OUT)/obj/NOTICE_FILES \
+ $(PRODUCT_OUT)/obj/PACKAGING \
+ $(PRODUCT_OUT)/recovery \
+ $(PRODUCT_OUT)/root \
+ $(PRODUCT_OUT)/system \
+ $(PRODUCT_OUT)/vendor \
+ $(PRODUCT_OUT)/oem \
+ $(PRODUCT_OUT)/userfastboot \
+ $(PRODUCT_OUT)/dex_bootjars \
+ $(PRODUCT_OUT)/obj/JAVA_LIBRARIES \
+ $(PRODUCT_OUT)/obj/FAKE \
+ $(PRODUCT_OUT)/obj/EXECUTABLES/adbd_intermediates \
+ $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libfs_mgr_intermediates \
+ $(PRODUCT_OUT)/obj/EXECUTABLES/init_intermediates \
+ $(PRODUCT_OUT)/obj/ETC/mac_permissions.xml_intermediates \
+ $(PRODUCT_OUT)/obj/ETC/sepolicy_intermediates \
+ $(PRODUCT_OUT)/obj/ETC/init.environ.rc_intermediates
+
+# The files/dirs to delete during a dataclean, which removes any files
+# in the staging and emulator data partitions.
+dataclean_files := \
+ $(PRODUCT_OUT)/data/* \
+ $(PRODUCT_OUT)/data-qemu/* \
+ $(PRODUCT_OUT)/userdata-qemu.img
+
+# make sure *_OUT is set so that we won't result in deleting random parts
+# of the filesystem.
+ifneq (2,$(words $(HOST_OUT) $(PRODUCT_OUT)))
+ $(error both HOST_OUT and PRODUCT_OUT should be set at this point.)
+endif
+
+# Define the rules for commandline invocation.
+.PHONY: dataclean
+dataclean: FILES := $(dataclean_files)
+dataclean:
+ $(hide) rm -rf $(FILES)
+ @echo "Deleted emulator userdata images."
+
+.PHONY: installclean
+installclean: FILES := $(installclean_files)
+installclean: dataclean
+ $(hide) rm -rf $(FILES)
+ @echo "Deleted images and staging directories."
+
+ifeq "$(force_installclean)" "true"
+ $(info *** Forcing "make installclean"...)
+ $(info *** rm -rf $(dataclean_files) $(installclean_files))
+ $(shell rm -rf $(dataclean_files) $(installclean_files))
+ $(info *** Done with the cleaning, now starting the real build.)
+endif
+force_installclean :=
diff --git a/build/core/cleanspec.mk b/build/core/cleanspec.mk
new file mode 100644
index 0000000..500ce54
--- /dev/null
+++ b/build/core/cleanspec.mk
@@ -0,0 +1,69 @@
+# Copyright (C) 2007 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.
+#
+
+# Just bump this if you want to force a clean build.
+# **********************************************************************
+# WHEN DOING SO
+# 1. DELETE ANY "add-clean-step" ENTRIES THAT HAVE PILED UP IN THIS FILE.
+# 2. REMOVE ALL FILES NAMED CleanSpec.mk.
+# 3. BUMP THE VERSION.
+# IDEALLY, THOSE STEPS SHOULD BE DONE ATOMICALLY.
+# **********************************************************************
+#
+INTERNAL_CLEAN_BUILD_VERSION := 6
+#
+# ***********************************************************************
+# Do not touch INTERNAL_CLEAN_BUILD_VERSION if you've added a clean step!
+# ***********************************************************************
+
+# If you don't need to do a full clean build but would like to touch
+# a file or delete some intermediate files, add a clean step to the end
+# of the list. These steps will only be run once, if they haven't been
+# run before.
+#
+# E.g.:
+# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
+# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
+#
+# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
+# files that are missing or have been moved.
+#
+# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
+# Use $(OUT_DIR) to refer to the "out" directory.
+#
+# If you need to re-do something that's already mentioned, just copy
+# the command and add it to the bottom of the list. E.g., if a change
+# that you made last week required touching a file and a change you
+# made today requires touching the same file, just copy the old
+# touch step and add it to the end of the list.
+#
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+# For example:
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
+#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+subdir_cleanspecs := \
+ $(shell build/tools/findleaves.py --prune=$(OUT_DIR) --prune=.repo --prune=.git . CleanSpec.mk)
+include $(subdir_cleanspecs)
+subdir_cleanspecs :=
diff --git a/build/core/clear_vars.mk b/build/core/clear_vars.mk
new file mode 100644
index 0000000..52bca70
--- /dev/null
+++ b/build/core/clear_vars.mk
@@ -0,0 +1,258 @@
+###########################################################
+## Clear out values of all variables used by rule templates.
+###########################################################
+
+LOCAL_MODULE:=
+LOCAL_MODULE_PATH:=
+LOCAL_MODULE_RELATIVE_PATH :=
+LOCAL_MODULE_STEM:=
+LOCAL_DONT_CHECK_MODULE:=
+LOCAL_CHECKED_MODULE:=
+LOCAL_BUILT_MODULE:=
+LOCAL_BUILT_MODULE_STEM:=
+OVERRIDE_BUILT_MODULE_PATH:=
+LOCAL_INSTALLED_MODULE:=
+LOCAL_INSTALLED_MODULE_STEM:=
+LOCAL_PICKUP_FILES:=
+LOCAL_UNINSTALLABLE_MODULE:=
+LOCAL_INTERMEDIATE_TARGETS:=
+LOCAL_UNSTRIPPED_PATH:=
+LOCAL_MODULE_CLASS:=
+LOCAL_MODULE_SUFFIX:=
+LOCAL_PACKAGE_NAME:=
+LOCAL_OVERRIDES_PACKAGES:=
+LOCAL_EXPORT_PACKAGE_RESOURCES:=
+LOCAL_MANIFEST_PACKAGE_NAME:=
+LOCAL_PACKAGE_SPLITS:=
+LOCAL_REQUIRED_MODULES:=
+LOCAL_ACP_UNAVAILABLE:=
+LOCAL_MODULE_TAGS:=
+LOCAL_SRC_FILES:=
+LOCAL_PREBUILT_OBJ_FILES:=
+LOCAL_STATIC_JAVA_LIBRARIES:=
+LOCAL_STATIC_JAVA_AAR_LIBRARIES:=
+LOCAL_STATIC_LIBRARIES:=
+# Group static libraries with "-Wl,--start-group" and "-Wl,--end-group" when linking.
+LOCAL_GROUP_STATIC_LIBRARIES:=
+LOCAL_WHOLE_STATIC_LIBRARIES:=
+LOCAL_SHARED_LIBRARIES:=
+LOCAL_IS_HOST_MODULE:=
+LOCAL_CC:=
+LOCAL_CXX:=
+LOCAL_CPP_EXTENSION:=
+LOCAL_NO_DEFAULT_COMPILER_FLAGS:=
+LOCAL_FDO_SUPPORT:=
+LOCAL_ARM_MODE:=
+LOCAL_YACCFLAGS:=
+LOCAL_ASFLAGS:=
+LOCAL_CFLAGS:=
+LOCAL_CPPFLAGS:=
+LOCAL_CONLYFLAGS:=
+LOCAL_RTTI_FLAG:=
+LOCAL_C_INCLUDES:=
+LOCAL_EXPORT_C_INCLUDE_DIRS:=
+LOCAL_LDFLAGS:=
+LOCAL_LDLIBS:=
+LOCAL_AAPT_FLAGS:=
+LOCAL_AAPT_INCLUDE_ALL_RESOURCES:=
+LOCAL_SYSTEM_SHARED_LIBRARIES:=none
+LOCAL_PREBUILT_LIBS:=
+LOCAL_PREBUILT_EXECUTABLES:=
+LOCAL_PREBUILT_JAVA_LIBRARIES:=
+LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES:=
+LOCAL_PREBUILT_STRIP_COMMENTS:=
+LOCAL_INTERMEDIATE_SOURCES:=
+LOCAL_INTERMEDIATE_SOURCE_DIR:=
+LOCAL_JAVACFLAGS:=
+LOCAL_JAVA_LIBRARIES:=
+LOCAL_JAVA_LAYERS_FILE:=
+LOCAL_NO_STANDARD_LIBRARIES:=
+LOCAL_CLASSPATH:=
+LOCAL_DROIDDOC_USE_STANDARD_DOCLET:=
+LOCAL_DROIDDOC_SOURCE_PATH:=
+LOCAL_DROIDDOC_TEMPLATE_DIR:=
+LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=
+LOCAL_DROIDDOC_ASSET_DIR:=
+LOCAL_DROIDDOC_CUSTOM_ASSET_DIR:=
+LOCAL_DROIDDOC_OPTIONS:=
+LOCAL_DROIDDOC_HTML_DIR:=
+LOCAL_ADDITIONAL_HTML_DIR:=
+LOCAL_ASSET_DIR:=
+LOCAL_RESOURCE_DIR:=
+LOCAL_JAVA_RESOURCE_DIRS:=
+LOCAL_JAVA_RESOURCE_FILES:=
+LOCAL_GENERATED_SOURCES:=
+LOCAL_COPY_HEADERS_TO:=
+LOCAL_COPY_HEADERS:=
+LOCAL_FORCE_STATIC_EXECUTABLE:=
+LOCAL_ADDITIONAL_DEPENDENCIES:=
+LOCAL_COMPRESS_MODULE_SYMBOLS:=
+LOCAL_STRIP_MODULE:=
+LOCAL_JNI_SHARED_LIBRARIES:=
+LOCAL_JNI_SHARED_LIBRARIES_ABI:=
+LOCAL_PREBUILT_JNI_LIBS:=
+LOCAL_JAR_MANIFEST:=
+LOCAL_INSTRUMENTATION_FOR:=
+LOCAL_APK_LIBRARIES:=
+LOCAL_RES_LIBRARIES:=
+LOCAL_MANIFEST_INSTRUMENTATION_FOR:=
+LOCAL_AIDL_INCLUDES:=
+LOCAL_JARJAR_RULES:=
+LOCAL_ADDITIONAL_JAVA_DIR:=
+LOCAL_ALLOW_UNDEFINED_SYMBOLS:=
+LOCAL_DX_FLAGS:=
+LOCAL_CERTIFICATE:=
+LOCAL_SDK_VERSION:=
+LOCAL_SDK_RES_VERSION:=
+LOCAL_NDK_STL_VARIANT:=
+LOCAL_EMMA_INSTRUMENT:=
+LOCAL_PROGUARD_ENABLED:= # '',full,custom,nosystem,disabled,obfuscation,optimization
+LOCAL_PROGUARD_FLAGS:=
+LOCAL_PROGUARD_FLAG_FILES:=
+LOCAL_TEST_MODULE_TO_PROGUARD_WITH:=
+LOCAL_EMMA_COVERAGE_FILTER:=
+LOCAL_WARNINGS_ENABLE:=
+LOCAL_FULL_MANIFEST_FILE:=
+LOCAL_MANIFEST_FILE:=
+LOCAL_FULL_LIBS_MANIFEST_FILES:=
+LOCAL_RENDERSCRIPT_INCLUDES:=
+LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE:=
+LOCAL_RENDERSCRIPT_CC:=
+LOCAL_RENDERSCRIPT_COMPATIBILITY:=
+LOCAL_RENDERSCRIPT_FLAGS:=
+LOCAL_RENDERSCRIPT_SKIP_INSTALL:=
+LOCAL_RENDERSCRIPT_TARGET_API:=
+LOCAL_DEX_PREOPT:= # '',true,false,nostripping
+LOCAL_DEX_PREOPT_IMAGE_LOCATION:=
+LOCAL_DEX_PREOPT_FLAGS:=
+LOCAL_PROTOC_OPTIMIZE_TYPE:= # lite(default),micro,nano,full
+LOCAL_PROTOC_FLAGS:=
+LOCAL_PROTO_JAVA_OUTPUT_PARAMS:=
+LOCAL_NO_CRT:=
+LOCAL_PROPRIETARY_MODULE:=
+LOCAL_OEM_MODULE:=
+LOCAL_PRIVILEGED_MODULE:=
+LOCAL_MODULE_OWNER:=
+LOCAL_CTS_TEST_PACKAGE:=
+LOCAL_CTS_TEST_RUNNER:=
+LOCAL_CLANG:=
+LOCAL_ADDRESS_SANITIZER:=
+LOCAL_JAR_EXCLUDE_FILES:=
+LOCAL_JAR_PACKAGES:=
+LOCAL_JAR_EXCLUDE_PACKAGES:=
+LOCAL_LINT_FLAGS:=
+LOCAL_SOURCE_FILES_ALL_GENERATED:= # '',true
+# Don't delete the META_INF dir when merging static Java libraries.
+LOCAL_DONT_DELETE_JAR_META_INF:=
+LOCAL_ADDITIONAL_CERTIFICATES:=
+LOCAL_PREBUILT_MODULE_FILE:=
+LOCAL_POST_INSTALL_CMD:=
+LOCAL_DIST_BUNDLED_BINARIES:=
+LOCAL_HAL_STATIC_LIBRARIES:=
+LOCAL_ADD_ENCED_PLATFORM_KEYS_TO_APK:=
+LOCAL_PUBLIC_KEY_TO_ENC_RANDOM_PROTECTION_KEY:=
+LOCAL_RMTYPEDEFS:=
+LOCAL_NO_SYNTAX_CHECK:=
+LOCAL_NO_STATIC_ANALYZER:=
+LOCAL_32_BIT_ONLY:= # '',true
+LOCAL_MULTILIB:=
+LOCAL_MODULE_TARGET_ARCH:=
+LOCAL_MODULE_TARGET_ARCH_WARN:=
+LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH:=
+LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH_WARN:=
+LOCAL_MODULE_HOST_ARCH:=
+LOCAL_DPI_VARIANTS:=
+LOCAL_DPI_FILE_STEM:=
+
+# arch specific variables
+LOCAL_SRC_FILES_$(TARGET_ARCH):=
+LOCAL_CFLAGS_$(TARGET_ARCH):=
+LOCAL_CPPFLAGS_$(TARGET_ARCH):=
+LOCAL_C_INCLUDES_$(TARGET_ARCH):=
+LOCAL_ASFLAGS_$(TARGET_ARCH):=
+LOCAL_NO_CRT_$(TARGET_ARCH):=
+LOCAL_LDFLAGS_$(TARGET_ARCH):=
+LOCAL_SHARED_LIBRARIES_$(TARGET_ARCH):=
+LOCAL_STATIC_LIBRARIES_$(TARGET_ARCH):=
+LOCAL_WHOLE_STATIC_LIBRARIES_$(TARGET_ARCH):=
+LOCAL_GENERATED_SOURCES_$(TARGET_ARCH):=
+LOCAL_REQUIRED_MODULES_$(TARGET_ARCH):=
+LOCAL_CLANG_$(TARGET_ARCH):=
+LOCAL_PREBUILT_JNI_LIBS_$(TARGET_ARCH):=
+ifdef TARGET_2ND_ARCH
+LOCAL_SRC_FILES_$(TARGET_2ND_ARCH):=
+LOCAL_CFLAGS_$(TARGET_2ND_ARCH):=
+LOCAL_CPPFLAGS_$(TARGET_2ND_ARCH):=
+LOCAL_C_INCLUDES_$(TARGET_2ND_ARCH):=
+LOCAL_ASFLAGS_$(TARGET_2ND_ARCH):=
+LOCAL_NO_CRT_$(TARGET_2ND_ARCH):=
+LOCAL_LDFLAGS_$(TARGET_2ND_ARCH):=
+LOCAL_SHARED_LIBRARIES_$(TARGET_2ND_ARCH):=
+LOCAL_STATIC_LIBRARIES_$(TARGET_2ND_ARCH):=
+LOCAL_WHOLE_STATIC_LIBRARIES_$(TARGET_2ND_ARCH):=
+LOCAL_GENERATED_SOURCES_$(TARGET_2ND_ARCH):=
+LOCAL_REQUIRED_MODULES_$(TARGET_2ND_ARCH):=
+LOCAL_CLANG_$(TARGET_2ND_ARCH):=
+LOCAL_PREBUILT_JNI_LIBS_$(TARGET_2ND_ARCH):=
+endif
+LOCAL_SRC_FILES_$(HOST_ARCH):=
+LOCAL_CFLAGS_$(HOST_ARCH):=
+LOCAL_CPPFLAGS_$(HOST_ARCH):=
+LOCAL_C_INCLUDES_$(HOST_ARCH):=
+LOCAL_ASFLAGS_$(HOST_ARCH):=
+LOCAL_NO_CRT_$(HOST_ARCH):=
+LOCAL_LDFLAGS_$(HOST_ARCH):=
+LOCAL_SHARED_LIBRARIES_$(HOST_ARCH):=
+LOCAL_STATIC_LIBRARIES_$(HOST_ARCH):=
+LOCAL_WHOLE_STATIC_LIBRARIES_$(HOST_ARCH):=
+LOCAL_GENERATED_SOURCES_$(HOST_ARCH):=
+LOCAL_REQUIRED_MODULES_$(HOST_ARCH):=
+LOCAL_CLANG_$(HOST_ARCH):=
+ifdef HOST_2ND_ARCH
+LOCAL_SRC_FILES_$(HOST_2ND_ARCH):=
+LOCAL_CFLAGS_$(HOST_2ND_ARCH):=
+LOCAL_CPPFLAGS_$(HOST_2ND_ARCH):=
+LOCAL_C_INCLUDES_$(HOST_2ND_ARCH):=
+LOCAL_ASFLAGS_$(HOST_2ND_ARCH):=
+LOCAL_NO_CRT_$(HOST_2ND_ARCH):=
+LOCAL_LDFLAGS_$(HOST_2ND_ARCH):=
+LOCAL_SHARED_LIBRARIES_$(HOST_2ND_ARCH):=
+LOCAL_STATIC_LIBRARIES_$(HOST_2ND_ARCH):=
+LOCAL_WHOLE_STATIC_LIBRARIES_$(HOST_2ND_ARCH):=
+LOCAL_GENERATED_SOURCES_$(HOST_2ND_ARCH):=
+LOCAL_REQUIRED_MODULES_$(HOST_2ND_ARCH):=
+LOCAL_CLANG_$(HOST_2ND_ARCH):=
+endif
+
+LOCAL_SRC_FILES_32:=
+LOCAL_SRC_FILES_64:=
+LOCAL_SHARED_LIBRARIES_32:=
+LOCAL_SHARED_LIBRARIES_64:=
+LOCAL_STATIC_LIBRARIES_32:=
+LOCAL_STATIC_LIBRARIES_64:=
+LOCAL_WHOLE_STATIC_LIBRARIES_32:=
+LOCAL_WHOLE_STATIC_LIBRARIES_64:=
+LOCAL_GENERATED_SOURCES_32:=
+LOCAL_GENERATED_SOURCES_64:=
+LOCAL_CFLAGS_32:=
+LOCAL_CFLAGS_64:=
+LOCAL_CPPFLAGS_32:=
+LOCAL_CPPFLAGS_64:=
+LOCAL_LDFLAGS_32:=
+LOCAL_LDFLAGS_64:=
+LOCAL_ASFLAGS_32:=
+LOCAL_ASFLAGS_64:=
+LOCAL_C_INCLUDES_32:=
+LOCAL_C_INCLUDES_64:=
+LOCAL_MODULE_PATH_32:=
+LOCAL_MODULE_PATH_64:=
+LOCAL_MODULE_STEM_32:=
+LOCAL_MODULE_STEM_64:=
+LOCAL_CLANG_32:=
+LOCAL_CLANG_64:=
+
+# Trim MAKEFILE_LIST so that $(call my-dir) doesn't need to
+# iterate over thousands of entries every time.
+# Leave the current makefile to make sure we don't break anything
+# that expects to be able to find the name of the current makefile.
+MAKEFILE_LIST := $(lastword $(MAKEFILE_LIST))
diff --git a/build/core/combo/HOST_darwin-x86.mk b/build/core/combo/HOST_darwin-x86.mk
new file mode 100644
index 0000000..ec37993
--- /dev/null
+++ b/build/core/combo/HOST_darwin-x86.mk
@@ -0,0 +1,120 @@
+#
+# Copyright (C) 2006 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.
+#
+
+# Configuration for Darwin (Mac OS X) on x86.
+# Included by combo/select.mk
+
+$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -m32
+$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -m32
+
+ifneq ($(strip $(BUILD_HOST_static)),)
+# Statically-linked binaries are desirable for sandboxed environment
+$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -static
+endif # BUILD_HOST_static
+
+# Workaround differences in inttypes.h between host and target.
+# See bug 12708004.
+$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS
+
+include $(BUILD_COMBOS)/mac_version.mk
+
+$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT := prebuilts/gcc/darwin-x86/host/i686-apple-darwin-4.2.1
+$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT)/bin/i686-apple-darwin$(gcc_darwin_version)
+# Don't do anything if the toolchain is not there
+ifneq (,$(strip $(wildcard $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)-gcc)))
+$(combo_2nd_arch_prefix)HOST_CC := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)-gcc
+$(combo_2nd_arch_prefix)HOST_CXX := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)-g++
+ifneq ($(filter 10.8 10.9, $(mac_sdk_version)),)
+# Mac SDK 10.8+ no longer has stdarg.h, etc
+host_toolchain_header := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT)/lib/gcc/i686-apple-darwin$(gcc_darwin_version)/4.2.1/include
+$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -isystem $(host_toolchain_header)
+endif
+else
+$(combo_2nd_arch_prefix)HOST_CC := gcc
+$(combo_2nd_arch_prefix)HOST_CXX := g++
+endif # $(HOST_TOOLCHAIN_PREFIX)-gcc exists
+
+# gcc location for clang; to be updated when clang is updated
+# HOST_TOOLCHAIN_ROOT is a Darwin-specific define
+$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT)
+
+$(combo_2nd_arch_prefix)HOST_AR := $(AR)
+
+$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) -DMACOSX_DEPLOYMENT_TARGET=$(mac_sdk_version)
+$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -Wl,-syslibroot,$(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)
+
+$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -fPIC -funwind-tables
+$(combo_2nd_arch_prefix)HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error
+
+$(combo_2nd_arch_prefix)HOST_SHLIB_SUFFIX := .dylib
+$(combo_2nd_arch_prefix)HOST_JNILIB_SUFFIX := .jnilib
+
+# TODO: add AndroidConfig.h for darwin-x86_64
+$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += \
+ -include $(call select-android-config-h,darwin-x86)
+
+ifneq ($(filter 10.7 10.7.% 10.8 10.8.%, $(build_mac_version)),)
+ $(combo_2nd_arch_prefix)HOST_RUN_RANLIB_AFTER_COPYING := false
+else
+ $(combo_2nd_arch_prefix)HOST_RUN_RANLIB_AFTER_COPYING := true
+ PRE_LION_DYNAMIC_LINKER_OPTIONS := -Wl,-dynamic
+endif
+$(combo_2nd_arch_prefix)HOST_GLOBAL_ARFLAGS := cqs
+
+############################################################
+## Macros after this line are shared by the 64-bit config.
+
+HOST_CUSTOM_LD_COMMAND := true
+
+define transform-host-o-to-shared-lib-inner
+$(hide) $(PRIVATE_CXX) \
+ -dynamiclib -single_module -read_only_relocs suppress \
+ $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \
+ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
+ $(PRIVATE_HOST_GLOBAL_LDFLAGS) \
+ ) \
+ $(PRIVATE_ALL_OBJECTS) \
+ $(addprefix -force_load , $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+ $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
+ $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ $(PRIVATE_LDLIBS) \
+ -o $@ \
+ -install_name @rpath/$(notdir $@) \
+ -Wl,-rpath,@loader_path/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
+ $(PRIVATE_LDFLAGS)
+endef
+
+define transform-host-o-to-executable-inner
+$(hide) $(PRIVATE_CXX) \
+ -Wl,-rpath,@loader_path/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
+ -o $@ \
+ $(PRE_LION_DYNAMIC_LINKER_OPTIONS) -Wl,-headerpad_max_install_names \
+ $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \
+ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
+ $(PRIVATE_HOST_GLOBAL_LDFLAGS) \
+ ) \
+ $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
+ $(PRIVATE_ALL_OBJECTS) \
+ $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+ $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ $(PRIVATE_LDFLAGS) \
+ $(PRIVATE_LDLIBS)
+endef
+
+# $(1): The file to check
+define get-file-size
+stat -f "%z" $(1)
+endef
diff --git a/build/core/combo/HOST_darwin-x86_64.mk b/build/core/combo/HOST_darwin-x86_64.mk
new file mode 100644
index 0000000..a776a69
--- /dev/null
+++ b/build/core/combo/HOST_darwin-x86_64.mk
@@ -0,0 +1,78 @@
+#
+# Copyright (C) 2006 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.
+#
+
+# Configuration for Darwin (Mac OS X) on x86_64.
+# Included by combo/select.mk
+
+HOST_GLOBAL_CFLAGS += -m64
+HOST_GLOBAL_LDFLAGS += -m64
+
+ifneq ($(strip $(BUILD_HOST_static)),)
+# Statically-linked binaries are desirable for sandboxed environment
+HOST_GLOBAL_LDFLAGS += -static
+endif # BUILD_HOST_static
+
+# Workaround differences in inttypes.h between host and target.
+# See bug 12708004.
+HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS
+
+include $(BUILD_COMBOS)/mac_version.mk
+
+HOST_TOOLCHAIN_ROOT := prebuilts/gcc/darwin-x86/host/i686-apple-darwin-4.2.1
+HOST_TOOLCHAIN_PREFIX := $(HOST_TOOLCHAIN_ROOT)/bin/i686-apple-darwin$(gcc_darwin_version)
+# Don't do anything if the toolchain is not there
+ifneq (,$(strip $(wildcard $(HOST_TOOLCHAIN_PREFIX)-gcc)))
+HOST_CC := $(HOST_TOOLCHAIN_PREFIX)-gcc
+HOST_CXX := $(HOST_TOOLCHAIN_PREFIX)-g++
+ifneq ($(filter 10.8 10.9, $(mac_sdk_version)),)
+# Mac SDK 10.8+ no longer has stdarg.h, etc
+host_toolchain_header := $(HOST_TOOLCHAIN_ROOT)/lib/gcc/i686-apple-darwin$(gcc_darwin_version)/4.2.1/include
+HOST_GLOBAL_CFLAGS += -isystem $(host_toolchain_header)
+endif
+else
+HOST_CC := gcc
+HOST_CXX := g++
+endif # $(HOST_TOOLCHAIN_PREFIX)-gcc exists
+
+# gcc location for clang; to be updated when clang is updated
+# HOST_TOOLCHAIN_ROOT is a Darwin-specific define
+HOST_TOOLCHAIN_FOR_CLANG := $(HOST_TOOLCHAIN_ROOT)
+
+HOST_AR := $(AR)
+
+HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) -DMACOSX_DEPLOYMENT_TARGET=$(mac_sdk_version)
+HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -Wl,-syslibroot,$(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)
+
+HOST_GLOBAL_CFLAGS += -fPIC -funwind-tables
+HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error
+
+HOST_SHLIB_SUFFIX := .dylib
+HOST_JNILIB_SUFFIX := .jnilib
+
+HOST_GLOBAL_CFLAGS += \
+ -include $(call select-android-config-h,darwin-x86)
+
+ifneq ($(filter 10.7 10.7.% 10.8 10.8.%, $(build_mac_version)),)
+ HOST_RUN_RANLIB_AFTER_COPYING := false
+else
+ HOST_RUN_RANLIB_AFTER_COPYING := true
+endif
+HOST_GLOBAL_ARFLAGS := cqs
+
+# We Reuse the following functions with the same name from HOST_darwin-x86.mk:
+# transform-host-o-to-shared-lib-inner
+# transform-host-o-to-executable-inner
+# get-file-size
diff --git a/build/core/combo/HOST_linux-x86.mk b/build/core/combo/HOST_linux-x86.mk
new file mode 100644
index 0000000..3ca7443
--- /dev/null
+++ b/build/core/combo/HOST_linux-x86.mk
@@ -0,0 +1,62 @@
+#
+# Copyright (C) 2006 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.
+#
+
+# Configuration for builds hosted on linux-x86.
+# Included by combo/select.mk
+
+ifeq ($(strip $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)),)
+$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/bin/x86_64-linux-
+endif
+# Don't do anything if the toolchain is not there
+ifneq (,$(strip $(wildcard $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)gcc)))
+$(combo_2nd_arch_prefix)HOST_CC := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)gcc
+$(combo_2nd_arch_prefix)HOST_CXX := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)g++
+$(combo_2nd_arch_prefix)HOST_AR := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)ar
+endif # $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)gcc exists
+
+# gcc location for clang; to be updated when clang is updated
+$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/
+
+# We expect SSE3 floating point math.
+$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -mstackrealign -msse3 -mfpmath=sse -m32 -Wa,--noexecstack -march=prescott
+$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -m32 -Wl,-z,noexecstack
+
+ifneq ($(strip $(BUILD_HOST_static)),)
+# Statically-linked binaries are desirable for sandboxed environment
+$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -static
+endif # BUILD_HOST_static
+
+$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -fPIC \
+ -no-canonical-prefixes \
+ -include $(call select-android-config-h,linux-x86)
+
+# Disable new longjmp in glibc 2.11 and later. See bug 2967937.
+$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
+
+# Workaround differences in inttypes.h between host and target.
+# See bug 12708004.
+$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS
+
+$(combo_2nd_arch_prefix)HOST_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
+
+
+############################################################
+## Macros after this line are shared by the 64-bit config.
+
+# $(1): The file to check
+define get-file-size
+stat --format "%s" "$(1)" | tr -d '\n'
+endef
diff --git a/build/core/combo/HOST_linux-x86_64.mk b/build/core/combo/HOST_linux-x86_64.mk
new file mode 100644
index 0000000..53a3ae8
--- /dev/null
+++ b/build/core/combo/HOST_linux-x86_64.mk
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2006 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.
+#
+
+# Configuration for builds hosted on linux-x86_64.
+# Included by combo/select.mk
+
+ifeq ($(strip $(HOST_TOOLCHAIN_PREFIX)),)
+HOST_TOOLCHAIN_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/bin/x86_64-linux-
+endif
+# Don't do anything if the toolchain is not there
+ifneq (,$(strip $(wildcard $(HOST_TOOLCHAIN_PREFIX)gcc)))
+HOST_CC := $(HOST_TOOLCHAIN_PREFIX)gcc
+HOST_CXX := $(HOST_TOOLCHAIN_PREFIX)g++
+HOST_AR := $(HOST_TOOLCHAIN_PREFIX)ar
+endif # $(HOST_TOOLCHAIN_PREFIX)gcc exists
+
+# gcc location for clang; to be updated when clang is updated
+HOST_TOOLCHAIN_FOR_CLANG := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/
+
+HOST_GLOBAL_CFLAGS += -m64 -Wa,--noexecstack
+HOST_GLOBAL_LDFLAGS += -m64 -Wl,-z,noexecstack
+
+ifneq ($(strip $(BUILD_HOST_static)),)
+# Statically-linked binaries are desirable for sandboxed environment
+HOST_GLOBAL_LDFLAGS += -static
+endif # BUILD_HOST_static
+
+# TODO: Add AndroidConfig.h for linux-x86_64
+HOST_GLOBAL_CFLAGS += -fPIC \
+ -no-canonical-prefixes \
+ -include $(call select-android-config-h,linux-x86)
+
+# Disable new longjmp in glibc 2.11 and later. See bug 2967937.
+HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
+
+# Workaround differences in inttypes.h between host and target.
+# See bug 12708004.
+HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS
+
+HOST_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
diff --git a/build/core/combo/HOST_windows-x86.mk b/build/core/combo/HOST_windows-x86.mk
new file mode 100644
index 0000000..00e1974
--- /dev/null
+++ b/build/core/combo/HOST_windows-x86.mk
@@ -0,0 +1,86 @@
+#
+# Copyright (C) 2006 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.
+#
+
+# Configuration for Linux on x86.
+# Included by combo/select.make
+
+# right now we get these from the environment, but we should
+# pick them from the tree somewhere
+TOOLS_PREFIX := #prebuilt/windows/host/bin/
+TOOLS_EXE_SUFFIX := .exe
+
+# Settings to use MinGW has a cross-compiler under Linux
+ifneq ($(findstring Linux,$(UNAME)),)
+ifneq ($(strip $(USE_MINGW)),)
+HOST_ACP_UNAVAILABLE := true
+TOOLS_EXE_SUFFIX :=
+$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -DUSE_MINGW -DWIN32_LEAN_AND_MEAN
+$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -Wno-unused-parameter
+$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += --sysroot=prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32
+$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -m32
+$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -m32
+TOOLS_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/bin/x86_64-w64-mingw32-
+$(combo_2nd_arch_prefix)HOST_C_INCLUDES += prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/include
+$(combo_2nd_arch_prefix)HOST_C_INCLUDES += prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/lib/gcc/x86_64-w64-mingw32/4.8.3/include
+$(combo_2nd_arch_prefix)HOST_GLOBAL_LD_DIRS += -Lprebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/lib32
+endif # USE_MINGW
+endif # Linux
+
+# Workaround differences in inttypes.h between host and target.
+# See bug 12708004.
+$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -D__USE_MINGW_ANSI_STDIO
+
+$(combo_2nd_arch_prefix)HOST_CC := $(TOOLS_PREFIX)gcc$(TOOLS_EXE_SUFFIX)
+$(combo_2nd_arch_prefix)HOST_CXX := $(TOOLS_PREFIX)g++$(TOOLS_EXE_SUFFIX)
+$(combo_2nd_arch_prefix)HOST_AR := $(TOOLS_PREFIX)ar$(TOOLS_EXE_SUFFIX)
+
+$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += \
+ -include $(call select-android-config-h,windows)
+$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += \
+ --enable-stdcall-fixup
+
+ifneq ($(strip $(BUILD_HOST_static)),)
+# Statically-linked binaries are desirable for sandboxed environment
+$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -static
+endif # BUILD_HOST_static
+
+# when building under Cygwin, ensure that we use Mingw compilation by default.
+# you can disable this (i.e. to generate Cygwin executables) by defining the
+# USE_CYGWIN variable in your environment, e.g.:
+#
+# export USE_CYGWIN=1
+#
+# note that the -mno-cygwin flags are not needed when cross-compiling the
+# Windows host tools on Linux
+#
+ifneq ($(findstring CYGWIN,$(UNAME)),)
+ifeq ($(strip $(USE_CYGWIN)),)
+$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -mno-cygwin
+$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -mno-cygwin -mconsole
+endif
+endif
+
+############################################################
+## Macros after this line are shared by the 64-bit config.
+
+HOST_SHLIB_SUFFIX := .dll
+HOST_EXECUTABLE_SUFFIX := .exe
+
+# $(1): The file to check
+# TODO: find out what format cygwin's stat(1) uses
+define get-file-size
+999999999
+endef
diff --git a/build/core/combo/HOST_windows-x86_64.mk b/build/core/combo/HOST_windows-x86_64.mk
new file mode 100644
index 0000000..c77d82c
--- /dev/null
+++ b/build/core/combo/HOST_windows-x86_64.mk
@@ -0,0 +1,66 @@
+#
+# Copyright (C) 2006 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.
+#
+
+# Configuration for Windows on x86_64.
+# Included by combo/select.make
+
+# right now we get these from the environment, but we should
+# pick them from the tree somewhere
+TOOLS_PREFIX := #prebuilt/windows/host/bin/
+TOOLS_EXE_SUFFIX := .exe
+
+# Settings to use MinGW has a cross-compiler under Linux
+ifneq ($(findstring Linux,$(UNAME)),)
+ifneq ($(strip $(USE_MINGW)),)
+HOST_ACP_UNAVAILABLE := true
+TOOLS_EXE_SUFFIX :=
+HOST_GLOBAL_CFLAGS += -DUSE_MINGW
+TOOLS_PREFIX := /usr/bin/amd64-mingw32msvc-
+HOST_C_INCLUDES += /usr/lib/gcc/amd64-mingw32msvc/4.4.2/include
+HOST_GLOBAL_LD_DIRS += -L/usr/amd64-mingw32msvc/lib
+endif # USE_MINGW
+endif # Linux
+
+# Workaround differences in inttypes.h between host and target.
+# See bug 12708004.
+HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -D__USE_MINGW_ANSI_STDIO
+
+HOST_CC := $(TOOLS_PREFIX)gcc$(TOOLS_EXE_SUFFIX)
+HOST_CXX := $(TOOLS_PREFIX)g++$(TOOLS_EXE_SUFFIX)
+HOST_AR := $(TOOLS_PREFIX)ar$(TOOLS_EXE_SUFFIX)
+
+HOST_GLOBAL_CFLAGS += -include $(call select-android-config-h,windows)
+HOST_GLOBAL_LDFLAGS += --enable-stdcall-fixup
+ifneq ($(strip $(BUILD_HOST_static)),)
+# Statically-linked binaries are desirable for sandboxed environment
+HOST_GLOBAL_LDFLAGS += -static
+endif # BUILD_HOST_static
+
+# when building under Cygwin, ensure that we use Mingw compilation by default.
+# you can disable this (i.e. to generate Cygwin executables) by defining the
+# USE_CYGWIN variable in your environment, e.g.:
+#
+# export USE_CYGWIN=1
+#
+# note that the -mno-cygwin flags are not needed when cross-compiling the
+# Windows host tools on Linux
+#
+ifneq ($(findstring CYGWIN,$(UNAME)),)
+ifeq ($(strip $(USE_CYGWIN)),)
+HOST_GLOBAL_CFLAGS += -mno-cygwin
+HOST_GLOBAL_LDFLAGS += -mno-cygwin -mconsole
+endif
+endif
diff --git a/build/core/combo/TARGET_linux-arm.mk b/build/core/combo/TARGET_linux-arm.mk
new file mode 100644
index 0000000..df81cd5
--- /dev/null
+++ b/build/core/combo/TARGET_linux-arm.mk
@@ -0,0 +1,266 @@
+#
+# Copyright (C) 2006 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.
+#
+
+# Configuration for Linux on ARM.
+# Included by combo/select.mk
+
+# You can set TARGET_ARCH_VARIANT to use an arch version other
+# than ARMv5TE. Each value should correspond to a file named
+# $(BUILD_COMBOS)/arch/.mk which must contain
+# makefile variable definitions similar to the preprocessor
+# defines in build/core/combo/include/arch//AndroidConfig.h. Their
+# purpose is to allow module Android.mk files to selectively compile
+# different versions of code based upon the funtionality and
+# instructions available in a given architecture version.
+#
+# The blocks also define specific arch_variant_cflags, which
+# include defines, and compiler settings for the given architecture
+# version.
+#
+ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT)),)
+TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT := armv5te
+endif
+
+# Decouple NDK library selection with platform compiler version
+$(combo_2nd_arch_prefix)TARGET_NDK_GCC_VERSION := 4.8
+
+ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
+$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := 4.8
+else
+$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
+endif
+
+TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_$(combo_2nd_arch_prefix)ARCH)/$(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT).mk
+ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
+$(error Unknown ARM architecture version: $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT))
+endif
+
+include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
+include $(BUILD_SYSTEM)/combo/fdo.mk
+
+# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
+ifeq ($(strip $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)),)
+$(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-$($(combo_2nd_arch_prefix)TARGET_GCC_VERSION)
+$(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX := $($(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/bin/arm-linux-androideabi-
+endif
+
+$(combo_2nd_arch_prefix)TARGET_CC := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
+$(combo_2nd_arch_prefix)TARGET_CXX := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
+$(combo_2nd_arch_prefix)TARGET_AR := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
+$(combo_2nd_arch_prefix)TARGET_OBJCOPY := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
+$(combo_2nd_arch_prefix)TARGET_LD := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
+$(combo_2nd_arch_prefix)TARGET_READELF := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)readelf$(HOST_EXECUTABLE_SUFFIX)
+$(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
+
+$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
+
+$(combo_2nd_arch_prefix)TARGET_arm_CFLAGS := -O2 \
+ -fomit-frame-pointer \
+ -fstrict-aliasing \
+ -funswitch-loops
+
+# Modules can choose to compile some source as thumb.
+$(combo_2nd_arch_prefix)TARGET_thumb_CFLAGS := -mthumb \
+ -Os \
+ -fomit-frame-pointer \
+ -fno-strict-aliasing
+
+# Set FORCE_ARM_DEBUGGING to "true" in your buildspec.mk
+# or in your environment to force a full arm build, even for
+# files that are normally built as thumb; this can make
+# gdb debugging easier. Don't forget to do a clean build.
+#
+# NOTE: if you try to build a -O0 build with thumb, several
+# of the libraries (libpv, libwebcore, libkjs) need to be built
+# with -mlong-calls. When built at -O0, those libraries are
+# too big for a thumb "BL