HOST_darwin-x86.mk revision 468d6a584f45227a13f15c8ebb17002f80f79d93
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 20ifneq ($(strip $(BUILD_HOST_64bit)),) 21# By default we build everything in 32-bit, because it gives us 22# more consistency between the host tools and the target. 23# BUILD_HOST_64bit=1 overrides it for tool like emulator 24# which can benefit from 64-bit host arch. 25HOST_GLOBAL_CFLAGS += -m64 26HOST_GLOBAL_LDFLAGS += -m64 27else 28HOST_GLOBAL_CFLAGS += -m32 29HOST_GLOBAL_LDFLAGS += -m32 30endif # BUILD_HOST_64bit 31 32ifneq ($(strip $(BUILD_HOST_static)),) 33# Statically-linked binaries are desirable for sandboxed environment 34HOST_GLOBAL_LDFLAGS += -static 35endif # BUILD_HOST_static 36 37# Use the Mac OSX SDK 10.5 if the build host is 10.6 38build_mac_version := $(shell sw_vers -productVersion) 39ifneq ($(filter 10.6.%, $(build_mac_version)),) 40sdk_105_root := /Developer/SDKs/MacOSX10.5.sdk 41ifeq ($(wildcard $(sdk_105_root)),) 42$(warning *****************************************************) 43$(warning * You are building on Mac OSX 10.6.) 44$(warning * Can not find SDK 10.5 at $(sdk_105_root)) 45$(warning *****************************************************) 46$(error Stop.) 47endif 48 49HOST_GLOBAL_CFLAGS += -isysroot $(sdk_105_root) -mmacosx-version-min=10.5 50HOST_GLOBAL_LDFLAGS += -isysroot $(sdk_105_root) -mmacosx-version-min=10.5 51endif # build_mac_version is 10.6 52 53HOST_GLOBAL_CFLAGS += -fPIC -funwind-tables 54HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error 55 56GCC_REALPATH = $(realpath $(shell which gcc)) 57ifneq ($(findstring llvm-gcc,$(GCC_REALPATH)),) 58 # Using LLVM GCC results in a non functional emulator due to it 59 # not honouring global register variables 60 $(warning ****************************************) 61 $(warning * gcc is linked to llvm-gcc which will *) 62 $(warning * not create a useable emulator. *) 63 $(warning ****************************************) 64endif 65 66HOST_CC := gcc 67HOST_CXX := g++ 68HOST_AR := $(AR) 69HOST_STRIP := $(STRIP) 70HOST_STRIP_COMMAND = $(HOST_STRIP) --strip-debug $< -o $@ 71 72HOST_SHLIB_SUFFIX := .dylib 73HOST_JNILIB_SUFFIX := .jnilib 74 75HOST_GLOBAL_CFLAGS += \ 76 -include $(call select-android-config-h,darwin-x86) 77ifneq ($(filter 10.7 10.7.% 10.8 10.8.%, $(build_mac_version)),) 78 HOST_RUN_RANLIB_AFTER_COPYING := false 79else 80 HOST_RUN_RANLIB_AFTER_COPYING := true 81 PRE_LION_DYNAMIC_LINKER_OPTIONS := -Wl,-dynamic 82endif 83HOST_GLOBAL_ARFLAGS := cqs 84 85HOST_CUSTOM_LD_COMMAND := true 86 87define transform-host-o-to-shared-lib-inner 88$(hide) $(PRIVATE_CXX) \ 89 -dynamiclib -single_module -read_only_relocs suppress \ 90 $(HOST_GLOBAL_LD_DIRS) \ 91 $(HOST_GLOBAL_LDFLAGS) \ 92 $(PRIVATE_ALL_OBJECTS) \ 93 $(addprefix -force_load , $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ 94 $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ 95 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ 96 $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ 97 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ 98 $(PRIVATE_LDLIBS) \ 99 -o $@ \ 100 -install_name @rpath/$(notdir $@) \ 101 -Wl,-rpath,@loader_path/../lib \ 102 $(PRIVATE_LDFLAGS) \ 103 $(HOST_LIBGCC) 104endef 105 106define transform-host-o-to-executable-inner 107$(hide) $(PRIVATE_CXX) \ 108 -Wl,-rpath,@loader_path/../lib \ 109 -o $@ \ 110 $(PRE_LION_DYNAMIC_LINKER_OPTIONS) -headerpad_max_install_names \ 111 $(HOST_GLOBAL_LD_DIRS) \ 112 $(HOST_GLOBAL_LDFLAGS) \ 113 $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ 114 $(PRIVATE_ALL_OBJECTS) \ 115 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ 116 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ 117 $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ 118 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ 119 $(PRIVATE_LDFLAGS) \ 120 $(PRIVATE_LDLIBS) \ 121 $(HOST_LIBGCC) 122endef 123 124# $(1): The file to check 125define get-file-size 126stat -f "%z" $(1) 127endef 128