Merge "generic_x86: build using the NDK ABI's processor features"
diff --git a/CleanSpec.mk b/CleanSpec.mk
index d103aa6..ea28ec0 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -109,6 +109,9 @@
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libbcinfo_intermediates)
 $(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)
+
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
diff --git a/core/Makefile b/core/Makefile
index e136c45..74883d4 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1447,6 +1447,7 @@
 	done; \
 	if [ $$FAIL ]; then exit 1; fi
 	$(hide) ( \
+		ATREE_STRIP="strip -x" \
 		$(HOST_OUT_EXECUTABLES)/atree \
 		$(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
 			-m $(PRIVATE_DEP_FILE) \
diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk
index aeb91c2..8be6a42 100644
--- a/core/combo/HOST_darwin-x86.mk
+++ b/core/combo/HOST_darwin-x86.mk
@@ -23,21 +23,23 @@
 HOST_GLOBAL_CFLAGS += -m32
 HOST_GLOBAL_LDFLAGS += -m32
 
-# Use the Mac OSX SDK 10.5 if the build host is 10.6
 build_mac_version := $(shell sw_vers -productVersion)
-ifneq ($(filter 10.6.%, $(build_mac_version)),)
-sdk_105_root := /Developer/SDKs/MacOSX10.5.sdk
-ifeq ($(wildcard $(sdk_105_root)),)
+mac_sdk_version := 10.6
+mac_sdk_root := /Developer/SDKs/MacOSX$(mac_sdk_version).sdk
+ifeq ($(wildcard $(mac_sdk_root)),)
+recent_xcode4_mac_sdk_root := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(mac_sdk_version).sdk
+ifeq ($(wildcard $(recent_xcode4_mac_sdk_root)),)
 $(warning *****************************************************)
-$(warning * You are building on Mac OSX 10.6.)
-$(warning * Can not find SDK 10.5 at $(sdk_105_root))
+$(warning * Can not find SDK $(mac_sdk_version) at $(mac_sdk_root))
+$(warning * or $(recent_xcode4_mac_sdk_root))
 $(warning *****************************************************)
 $(error Stop.)
 endif
+mac_sdk_root := $(recent_xcode4_mac_sdk_root)
+endif
 
-HOST_GLOBAL_CFLAGS += -isysroot $(sdk_105_root) -mmacosx-version-min=10.5
-HOST_GLOBAL_LDFLAGS += -isysroot $(sdk_105_root) -mmacosx-version-min=10.5
-endif # build_mac_version is 10.6
+HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)
+HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)
 
 HOST_GLOBAL_CFLAGS += -fPIC
 HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index 5020c84..f309898 100644
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -96,26 +96,22 @@
 			-fno-use-cxa-atexit
 
 ifeq ($(TARGET_ARCH_VARIANT),x86-atom)
-    # Basic ATOM flags.
-    TARGET_GLOBAL_CFLAGS += -march=atom -mstackrealign -mfpmath=sse
+    # Basic ATOM flags - only use this if you have both ssse3 and movbe instructions
+    TARGET_GLOBAL_CFLAGS += -march=atom -mstackrealign -mfpmath=sse -m32
 
     # There are various levels of ATOM processors out there. Different ones have different
-    # capabilities. This first define matches the NDK's minimum ABI requirements.
+    # capabilities.
     # Note: Not all of the flags set here are actually used in Android. They are provided
     # to allow for the addition of corresponding optimizations.
-    TARGET_GLOBAL_CFLAGS += -DUSE_MMX -DUSE_SSE -DUSE_SSE2 -DUSE_SSE3
-
-    # If you wish to build a BSP that will only be used on hardware that has additional
-    # available instructions, enable them here. By default, this is commented off so that
-    # the default images can run on all processors that are NDK ABI compliant.
-    # TARGET_GLOBAL_CFLAGS += -DUSE_SSSE3
+    TARGET_GLOBAL_CFLAGS += -DUSE_MMX -DUSE_SSE -DUSE_SSE2 -DUSE_SSE3 -DUSE_SSSE3
 else
-    # Plain 'x86' - lowest common denominator. This should run pretty much on any hardware.
+    # Plain 'x86' - Requires sse3, use if you have nossse3 or movbe
     #
     # Note: The NDK's ABI (see the NDK ABI documentation) requires many of the more recent
     # instruction set additions. You can build an "x86" BSP that will run on very old hardware,
     # but it won't be able to run much of the x86 NDK compliant code.
-    TARGET_GLOBAL_CFLAGS += -march=i686
+    TARGET_GLOBAL_CFLAGS += -march=i686 -msse3 -mfpmath=sse -m32
+    TARGET_GLOBAL_CFLAGS += -DUSE_MMX -DUSE_SSE -DUSE_SSE2 -DUSE_SSE3
 endif
 
 TARGET_GLOBAL_CFLAGS += -mbionic
@@ -174,6 +170,7 @@
 	$(TARGET_GLOBAL_LDFLAGS) \
 	-nostdlib -Bdynamic \
 	-Wl,-dynamic-linker,/system/bin/linker \
+	-Wl,--copy-dt-needed-entries \
 	-Wl,-z,nocopyreloc \
 	-o $@ \
 	$(TARGET_GLOBAL_LD_DIRS) \
diff --git a/target/board/generic_mips/BoardConfig.mk b/target/board/generic_mips/BoardConfig.mk
index 722e112..8b81c27 100644
--- a/target/board/generic_mips/BoardConfig.mk
+++ b/target/board/generic_mips/BoardConfig.mk
@@ -26,7 +26,7 @@
 ifeq (,$(TARGET_ARCH_VARIANT))
 TARGET_ARCH_VARIANT := mips32r2-fp
 endif
-GET_CPU_ABI  := mips
+TARGET_CPU_ABI  := mips
 
 HAVE_HTC_AUDIO_DRIVER := true
 BOARD_USES_GENERIC_AUDIO := true
@@ -51,3 +51,7 @@
 # Build and enable the OpenGL ES View renderer. When running on the emulator,
 # the GLES renderer disables itself if host GL acceleration isn't available.
 USE_OPENGL_RENDERER := true
+
+# Default to JSC until we get v8 landed
+HTTP := android
+JS_ENGINE := jsc
diff --git a/target/board/generic_mips/device.mk b/target/board/generic_mips/device.mk
index bd08fde..6edcba6 100644
--- a/target/board/generic_mips/device.mk
+++ b/target/board/generic_mips/device.mk
@@ -27,4 +27,5 @@
     development/tools/emulator/system/camera/media_profiles.xml:system/etc/media_profiles.xml
 
 PRODUCT_PACKAGES := \
-    audio.primary.goldfish
+    audio.primary.goldfish \
+    libffi
diff --git a/target/product/full_x86.mk b/target/product/full_x86.mk
index c7a4cfb..fcbb970 100644
--- a/target/product/full_x86.mk
+++ b/target/product/full_x86.mk
@@ -22,16 +22,17 @@
 # If running on an emulator or some other device that has a LAN connection
 # that isn't a wifi connection. This will instruct init.rc to enable the
 # network connection so that you can use it with ADB
-ifdef NET_ETH0_STARTONBOOT
-  PRODUCT_PROPERTY_OVERRIDES += net.eth0.startonboot=1
-endif
 
 PRODUCT_PACKAGES := \
     Camera
 
-$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base_telephony.mk)
 $(call inherit-product, $(SRC_TARGET_DIR)/board/generic_x86/device.mk)
 
+ifdef NET_ETH0_STARTONBOOT
+  PRODUCT_PROPERTY_OVERRIDES += net.eth0.startonboot=1
+endif
+
 # Ensure we package the BIOS files too.
 PRODUCT_PACKAGES += \
 	bios.bin \
diff --git a/target/product/generic_x86.mk b/target/product/generic_x86.mk
index 86710c4..0274b5b 100644
--- a/target/product/generic_x86.mk
+++ b/target/product/generic_x86.mk
@@ -14,10 +14,10 @@
 # limitations under the License.
 #
 
-# This is a generic product that isn't specialized for a specific device.
+# This is a generic phone product that isn't specialized for a specific device.
 # It includes the base Android platform.
 
-$(call inherit-product, $(SRC_TARGET_DIR)/product/generic.mk)
+include $(SRC_TARGET_DIR)/product/generic.mk
 
 # Overrides
 PRODUCT_BRAND := generic_x86
diff --git a/target/product/sdk_x86.mk b/target/product/sdk_x86.mk
index 6c5e746..873d0c0 100644
--- a/target/product/sdk_x86.mk
+++ b/target/product/sdk_x86.mk
@@ -19,7 +19,7 @@
 # build quite specifically for the emulator, and might not be
 # entirely appropriate to inherit from for on-device configurations.
 
-$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk.mk)
+include $(SRC_TARGET_DIR)/product/sdk.mk
 
 # Overrides
 PRODUCT_BRAND := generic_x86
diff --git a/tools/atree/fs.cpp b/tools/atree/fs.cpp
index b648394..9468cfd 100644
--- a/tools/atree/fs.cpp
+++ b/tools/atree/fs.cpp
@@ -152,8 +152,8 @@
 int
 strip_file(const string& path)
 {
-    // Default strip command to run is "strip" unless overridden by the STRIP env var.
-    const char* strip_cmd = getenv("STRIP");
+    // Default strip command to run is "strip" unless overridden by the ATREE_STRIP env var.
+    const char* strip_cmd = getenv("ATREE_STRIP");
     if (!strip_cmd || !strip_cmd[0]) {
         strip_cmd = "strip";
     }
@@ -163,7 +163,52 @@
         return -1;
     } else if (pid == 0) {
         // Exec in the child. Only returns if execve failed.
-        return execlp(strip_cmd, strip_cmd, path.c_str(), (char *)NULL);
+
+        int num_args = 0;
+        const char *s = strip_cmd;
+        while (*s) {
+            while (*s == ' ') ++s;
+            if (*s && *s != ' ') {
+                ++num_args;
+                while (*s && *s != ' ') ++s;
+            }
+        }
+
+        if (num_args <= 0) {
+            fprintf(stderr, "Invalid ATREE_STRIP command '%s'\n", strip_cmd);
+            return 1;
+
+        } else if (num_args == 1) {
+            return execlp(strip_cmd, strip_cmd, path.c_str(), (char *)NULL);
+
+        } else {
+            // Split the arguments if more than 1
+            char* cmd = strdup(strip_cmd);
+            const char** args = (const char**) malloc(sizeof(const char*) * (num_args + 2));
+
+            const char** curr = args;
+            char* s = cmd;
+            while (*s) {
+                while (*s == ' ') ++s;
+                if (*s && *s != ' ') {
+                    *curr = s;
+                    ++curr;
+                    while (*s && *s != ' ') ++s;
+                    if (*s) {
+                        *s = '\0';
+                        ++s;
+                    }
+                }
+            }
+
+            args[num_args] = path.c_str();
+            args[num_args + 1] = NULL;
+
+            int ret = execvp(args[0], (char* const*)args);
+            free(args);
+            free(cmd);
+            return ret;
+        }
     } else {
         // Wait for child pid and return its exit code.
         int status;