HOST_darwin-x86.mk revision 3a2b9f0a49078223434927835d79d1ca9a751f16
1# 2# Copyright (C) 2006 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17# Configuration for Darwin (Mac OS X) on x86. 18# Included by combo/select.mk 19 20$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -m32 21$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -m32 22 23ifneq ($(strip $(BUILD_HOST_static)),) 24# Statically-linked binaries are desirable for sandboxed environment 25$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -static 26endif # BUILD_HOST_static 27 28# Workaround differences in inttypes.h between host and target. 29# See bug 12708004. 30$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS 31 32include $(BUILD_COMBOS)/mac_version.mk 33 34$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT := prebuilts/gcc/darwin-x86/host/i686-apple-darwin-4.2.1 35$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT)/bin/i686-apple-darwin$(gcc_darwin_version) 36# Don't do anything if the toolchain is not there 37ifneq (,$(strip $(wildcard $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)-gcc))) 38$(combo_2nd_arch_prefix)HOST_CC := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)-gcc 39$(combo_2nd_arch_prefix)HOST_CXX := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)-g++ 40ifneq ($(filter 10.8 10.9, $(mac_sdk_version)),) 41# Mac SDK 10.8+ no longer has stdarg.h, etc 42host_toolchain_header := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT)/lib/gcc/i686-apple-darwin$(gcc_darwin_version)/4.2.1/include 43$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -isystem $(host_toolchain_header) 44endif 45else 46$(combo_2nd_arch_prefix)HOST_CC := gcc 47$(combo_2nd_arch_prefix)HOST_CXX := g++ 48endif # $(HOST_TOOLCHAIN_PREFIX)-gcc exists 49 50# gcc location for clang; to be updated when clang is updated 51# HOST_TOOLCHAIN_ROOT is a Darwin-specific define 52$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT) 53 54$(combo_2nd_arch_prefix)HOST_AR := $(AR) 55 56$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) -DMACOSX_DEPLOYMENT_TARGET=$(mac_sdk_version) 57$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -Wl,-syslibroot,$(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) 58 59$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -fPIC -funwind-tables 60$(combo_2nd_arch_prefix)HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error 61 62$(combo_2nd_arch_prefix)HOST_SHLIB_SUFFIX := .dylib 63$(combo_2nd_arch_prefix)HOST_JNILIB_SUFFIX := .jnilib 64 65# TODO: add AndroidConfig.h for darwin-x86_64 66$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += \ 67 -include $(call select-android-config-h,darwin-x86) 68 69ifneq ($(filter 10.7 10.7.% 10.8 10.8.%, $(build_mac_version)),) 70 $(combo_2nd_arch_prefix)HOST_RUN_RANLIB_AFTER_COPYING := false 71else 72 $(combo_2nd_arch_prefix)HOST_RUN_RANLIB_AFTER_COPYING := true 73 PRE_LION_DYNAMIC_LINKER_OPTIONS := -Wl,-dynamic 74endif 75$(combo_2nd_arch_prefix)HOST_GLOBAL_ARFLAGS := cqs 76 77############################################################ 78## Macros after this line are shared by the 64-bit config. 79 80HOST_CUSTOM_LD_COMMAND := true 81 82define transform-host-o-to-shared-lib-inner 83$(hide) $(PRIVATE_CXX) \ 84 -dynamiclib -single_module -read_only_relocs suppress \ 85 $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \ 86 $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ 87 $(PRIVATE_HOST_GLOBAL_LDFLAGS) \ 88 ) \ 89 $(PRIVATE_ALL_OBJECTS) \ 90 $(addprefix -force_load , $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ 91 $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ 92 $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ 93 $(PRIVATE_LDLIBS) \ 94 -o $@ \ 95 -install_name @rpath/$(notdir $@) \ 96 -Wl,-rpath,@loader_path/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \ 97 $(PRIVATE_LDFLAGS) 98endef 99 100define transform-host-o-to-executable-inner 101$(hide) $(PRIVATE_CXX) \ 102 -Wl,-rpath,@loader_path/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \ 103 -o $@ \ 104 $(PRE_LION_DYNAMIC_LINKER_OPTIONS) -Wl,-headerpad_max_install_names \ 105 $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \ 106 $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ 107 $(PRIVATE_HOST_GLOBAL_LDFLAGS) \ 108 ) \ 109 $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ 110 $(PRIVATE_ALL_OBJECTS) \ 111 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ 112 $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ 113 $(PRIVATE_LDFLAGS) \ 114 $(PRIVATE_LDLIBS) 115endef 116 117# $(1): The file to check 118define get-file-size 119stat -f "%z" $(1) 120endef 121