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