Merge "Use gold linker on x86"
diff --git a/core/Makefile b/core/Makefile
index 17f45cf..d9f9a25 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1406,7 +1406,8 @@
$(atree_dir)/sdk.atree \
$(sdk_tools_atree_files) \
$(HOST_OUT_EXECUTABLES)/atree \
- $(HOST_OUT_EXECUTABLES)/line_endings
+ $(ALL_HOST_INSTALLED_FILES) \
+ $(HOST_OUT_EXECUTABLES)/line_endings
INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk
index 85bb2cd..668998f 100644
--- a/core/combo/HOST_darwin-x86.mk
+++ b/core/combo/HOST_darwin-x86.mk
@@ -29,20 +29,46 @@
HOST_GLOBAL_LDFLAGS += -m32
endif # BUILD_HOST_64bit
+ifneq ($(strip $(BUILD_HOST_static)),)
+# Statically-linked binaries are desirable for sandboxed environment
+HOST_GLOBAL_LDFLAGS += -static
+endif # BUILD_HOST_static
+
build_mac_version := $(shell sw_vers -productVersion)
-mac_sdk_version := 10.6
+
+ifneq ($(strip $(BUILD_MAC_SDK_EXPERIMENTAL)),)
+# SDK 10.7 and higher is not fully compatible with Android.
+mac_sdk_versions_supported := 10.7 10.8
+else
+mac_sdk_versions_supported := 10.6
+endif # BUILD_MAC_SDK_EXPERIMENTAL
+mac_sdk_versions_installed := $(shell xcodebuild -showsdks |grep macosx | sort | sed -e "s/.*macosx//g")
+mac_sdk_version := $(firstword $(filter $(mac_sdk_versions_installed), $(mac_sdk_versions_supported)))
+ifeq ($(mac_sdk_version),)
+mac_sdk_version := $(firstword $(mac_sdk_versions_supported))
+endif
+
+mac_sdk_path := $(shell xcode-select -print-path)
+ifeq ($(findstring /Applications,$(mac_sdk_path)),)
+# Legacy Xcode
mac_sdk_root := /Developer/SDKs/MacOSX$(mac_sdk_version).sdk
+else
+# Xcode 4.4(App Store) or higher
+# /Applications/Xcode*.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.?.sdk
+mac_sdk_root := $(mac_sdk_path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(mac_sdk_version).sdk
+endif
+
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 * Can not find SDK $(mac_sdk_version) at $(mac_sdk_root))
-$(warning * or $(recent_xcode4_mac_sdk_root))
+ifeq ($(strip $(BUILD_MAC_SDK_EXPERIMENTAL)),)
+$(warning * If you wish to build using higher version of SDK, )
+$(warning * try setting BUILD_MAC_SDK_EXPERIMENTAL=1 before )
+$(warning * rerunning this command )
+endif
$(warning *****************************************************)
$(error Stop.)
endif
-mac_sdk_root := $(recent_xcode4_mac_sdk_root)
-endif
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)
diff --git a/core/combo/HOST_linux-x86.mk b/core/combo/HOST_linux-x86.mk
index a4da5ce..b369199 100644
--- a/core/combo/HOST_linux-x86.mk
+++ b/core/combo/HOST_linux-x86.mk
@@ -52,6 +52,11 @@
HOST_GLOBAL_LDFLAGS += -m32
endif # BUILD_HOST_64bit
+ifneq ($(strip $(BUILD_HOST_static)),)
+# Statically-linked binaries are desirable for sandboxed environment
+HOST_GLOBAL_LDFLAGS += -static
+endif # BUILD_HOST_static
+
HOST_GLOBAL_CFLAGS += -fPIC
HOST_GLOBAL_CFLAGS += \
-include $(call select-android-config-h,linux-x86)
diff --git a/core/combo/HOST_windows-x86.mk b/core/combo/HOST_windows-x86.mk
index fe4bd66..85bc1e0 100644
--- a/core/combo/HOST_windows-x86.mk
+++ b/core/combo/HOST_windows-x86.mk
@@ -46,6 +46,10 @@
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
diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk
index 14c3d28..cd36197 100644
--- a/core/combo/TARGET_linux-arm.mk
+++ b/core/combo/TARGET_linux-arm.mk
@@ -252,8 +252,8 @@
-Wl,--gc-sections \
-Wl,-shared,-Bsymbolic \
$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
- $(PRIVATE_ALL_OBJECTS) \
$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
+ $(PRIVATE_ALL_OBJECTS) \
-Wl,--whole-archive \
$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
-Wl,--no-whole-archive \
diff --git a/tools/zipalign/Android.mk b/tools/zipalign/Android.mk
index 9763bd2..089c68b 100644
--- a/tools/zipalign/Android.mk
+++ b/tools/zipalign/Android.mk
@@ -28,6 +28,10 @@
LOCAL_LDLIBS += -lz
endif
+ifneq ($(strip $(BUILD_HOST_static)),)
+LOCAL_LDLIBS += -lpthread
+endif # BUILD_HOST_static
+
LOCAL_MODULE := zipalign
include $(BUILD_HOST_EXECUTABLE)
diff --git a/tools/zipalign/ZipAlign.cpp b/tools/zipalign/ZipAlign.cpp
index c2d8159..8b2d1af 100644
--- a/tools/zipalign/ZipAlign.cpp
+++ b/tools/zipalign/ZipAlign.cpp
@@ -125,7 +125,7 @@
ZipFile::kOpenReadWrite|ZipFile::kOpenCreate|ZipFile::kOpenTruncate)
!= NO_ERROR)
{
- fprintf(stderr, "Unable to open '%s' as zip archive\n", inFileName);
+ fprintf(stderr, "Unable to open '%s' as zip archive\n", outFileName);
return 1;
}