HOST_darwin-x86.mk revision 31ef1037bf7b66e949ecf52a1a29672d43ebfef8
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 37build_mac_version := $(shell sw_vers -productVersion) 38mac_sdk_version := 10.6 39mac_sdk_root := /Developer/SDKs/MacOSX$(mac_sdk_version).sdk 40ifeq ($(wildcard $(mac_sdk_root)),) 41recent_xcode4_mac_sdk_root := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(mac_sdk_version).sdk 42ifeq ($(wildcard $(recent_xcode4_mac_sdk_root)),) 43$(warning *****************************************************) 44$(warning * Can not find SDK $(mac_sdk_version) at $(mac_sdk_root)) 45$(warning * or $(recent_xcode4_mac_sdk_root)) 46$(warning *****************************************************) 47$(error Stop.) 48endif 49mac_sdk_root := $(recent_xcode4_mac_sdk_root) 50endif 51 52HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) 53HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) 54 55HOST_GLOBAL_CFLAGS += -fPIC 56HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error 57 58HOST_CC := gcc 59HOST_CXX := g++ 60HOST_AR := $(AR) 61HOST_STRIP := $(STRIP) 62HOST_STRIP_COMMAND = $(HOST_STRIP) --strip-debug $< -o $@ 63 64HOST_SHLIB_SUFFIX := .dylib 65HOST_JNILIB_SUFFIX := .jnilib 66 67HOST_GLOBAL_CFLAGS += \ 68 -include $(call select-android-config-h,darwin-x86) 69ifneq ($(filter 10.7 10.7.% 10.8 10.8.%, $(build_mac_version)),) 70 HOST_RUN_RANLIB_AFTER_COPYING := false 71else 72 HOST_RUN_RANLIB_AFTER_COPYING := true 73 PRE_LION_DYNAMIC_LINKER_OPTIONS := -Wl,-dynamic 74endif 75HOST_GLOBAL_ARFLAGS := cqs 76 77HOST_CUSTOM_LD_COMMAND := true 78 79# Workaround for lack of "-Wl,--whole-archive" in MacOS's linker. 80define _darwin-extract-and-include-single-whole-static-lib 81@echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(1)]" 82$(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\ 83 mkdir -p $$ldir; \ 84 for f in `$(HOST_AR) t $(1)`; do \ 85 $(HOST_AR) p $(1) $$f > $$ldir/$$f; \ 86 done ; 87 88endef 89 90define darwin-extract-and-include-whole-static-libs 91$(if $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), $(hide) rm -rf $(PRIVATE_INTERMEDIATES_DIR)/WHOLE) 92$(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \ 93 $(call _darwin-extract-and-include-single-whole-static-lib, $(lib))) 94endef 95 96define transform-host-o-to-shared-lib-inner 97$(call darwin-extract-and-include-whole-static-libs) 98$(hide) $(PRIVATE_CXX) \ 99 -dynamiclib -single_module -read_only_relocs suppress \ 100 $(HOST_GLOBAL_LD_DIRS) \ 101 $(HOST_GLOBAL_LDFLAGS) \ 102 $(PRIVATE_ALL_OBJECTS) \ 103 $(if $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), `find $(PRIVATE_INTERMEDIATES_DIR)/WHOLE -name '*.o' 2>/dev/null`) \ 104 $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ 105 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ 106 $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ 107 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ 108 $(PRIVATE_LDLIBS) \ 109 -o $@ \ 110 -install_name @rpath/$(notdir $@) \ 111 -Wl,-rpath,@loader_path/../lib \ 112 $(PRIVATE_LDFLAGS) \ 113 $(HOST_LIBGCC) 114endef 115 116define transform-host-o-to-executable-inner 117$(hide) $(PRIVATE_CXX) \ 118 -Wl,-rpath,@loader_path/../lib \ 119 -o $@ \ 120 $(PRE_LION_DYNAMIC_LINKER_OPTIONS) -headerpad_max_install_names \ 121 $(HOST_GLOBAL_LD_DIRS) \ 122 $(HOST_GLOBAL_LDFLAGS) \ 123 $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ 124 $(PRIVATE_ALL_OBJECTS) \ 125 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ 126 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ 127 $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ 128 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ 129 $(PRIVATE_LDFLAGS) \ 130 $(PRIVATE_LDLIBS) \ 131 $(HOST_LIBGCC) 132endef 133 134# $(1): The file to check 135define get-file-size 136stat -f "%z" $(1) 137endef 138