Added BUILD_HOST_static to build statically linked executable/shared-lib

Statically linked executable/shared-lib (eg. SDK tools) are useful
in sandboxed environment.

In BUILD_HOST_static zipalign needs -lpthread indirectly:
zipalign->libutils.a->liblog.a->logd_write.c->pthread

Change-Id: I8fa91a937b728ccdf942c4ba199efb1e2e49da3d
This commit is contained in:
Andrew Hsieh 2012-04-28 00:35:19 +08:00
parent f8dc89b49a
commit f9613a4f73
4 changed files with 18 additions and 0 deletions

View File

@ -29,6 +29,11 @@ HOST_GLOBAL_CFLAGS += -m32
HOST_GLOBAL_LDFLAGS += -m32 HOST_GLOBAL_LDFLAGS += -m32
endif # BUILD_HOST_64bit 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
# Use the Mac OSX SDK 10.5 if the build host is 10.6 # Use the Mac OSX SDK 10.5 if the build host is 10.6
build_mac_version := $(shell sw_vers -productVersion) build_mac_version := $(shell sw_vers -productVersion)
ifneq ($(filter 10.6.%, $(build_mac_version)),) ifneq ($(filter 10.6.%, $(build_mac_version)),)

View File

@ -52,6 +52,11 @@ HOST_GLOBAL_CFLAGS += -m32
HOST_GLOBAL_LDFLAGS += -m32 HOST_GLOBAL_LDFLAGS += -m32
endif # BUILD_HOST_64bit 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 += -fPIC
HOST_GLOBAL_CFLAGS += \ HOST_GLOBAL_CFLAGS += \
-include $(call select-android-config-h,linux-x86) -include $(call select-android-config-h,linux-x86)

View File

@ -46,6 +46,10 @@ HOST_AR := $(TOOLS_PREFIX)ar$(TOOLS_EXE_SUFFIX)
HOST_GLOBAL_CFLAGS += -include $(call select-android-config-h,windows) HOST_GLOBAL_CFLAGS += -include $(call select-android-config-h,windows)
HOST_GLOBAL_LDFLAGS += --enable-stdcall-fixup 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. # 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 # you can disable this (i.e. to generate Cygwin executables) by defining the

View File

@ -28,6 +28,10 @@ else
LOCAL_LDLIBS += -lz LOCAL_LDLIBS += -lz
endif endif
ifneq ($(strip $(BUILD_HOST_static)),)
LOCAL_LDLIBS += -lpthread
endif # BUILD_HOST_static
LOCAL_MODULE := zipalign LOCAL_MODULE := zipalign
include $(BUILD_HOST_EXECUTABLE) include $(BUILD_HOST_EXECUTABLE)