Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 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 | |
Andrew Hsieh | ed6b815 | 2012-02-27 21:03:30 -0800 | [diff] [blame] | 20 | ifneq ($(strip $(BUILD_HOST_64bit)),) |
| 21 | # By default we build everything in 32-bit, because it gives us |
Jeff Hamilton | ebc2869 | 2010-05-26 18:13:54 -0500 | [diff] [blame] | 22 | # more consistency between the host tools and the target. |
Andrew Hsieh | ed6b815 | 2012-02-27 21:03:30 -0800 | [diff] [blame] | 23 | # BUILD_HOST_64bit=1 overrides it for tool like emulator |
| 24 | # which can benefit from 64-bit host arch. |
| 25 | HOST_GLOBAL_CFLAGS += -m64 |
| 26 | HOST_GLOBAL_LDFLAGS += -m64 |
| 27 | else |
Jeff Hamilton | ebc2869 | 2010-05-26 18:13:54 -0500 | [diff] [blame] | 28 | HOST_GLOBAL_CFLAGS += -m32 |
| 29 | HOST_GLOBAL_LDFLAGS += -m32 |
Andrew Hsieh | ed6b815 | 2012-02-27 21:03:30 -0800 | [diff] [blame] | 30 | endif # BUILD_HOST_64bit |
Jeff Hamilton | ebc2869 | 2010-05-26 18:13:54 -0500 | [diff] [blame] | 31 | |
Andrew Hsieh | f9613a4 | 2012-04-28 00:35:19 +0800 | [diff] [blame] | 32 | ifneq ($(strip $(BUILD_HOST_static)),) |
| 33 | # Statically-linked binaries are desirable for sandboxed environment |
| 34 | HOST_GLOBAL_LDFLAGS += -static |
| 35 | endif # BUILD_HOST_static |
| 36 | |
Ian Rogers | 61e5059 | 2014-01-29 13:09:30 -0800 | [diff] [blame] | 37 | # Workaround differences in inttypes.h between host and target. |
| 38 | # See bug 12708004. |
Ian Rogers | aa54033 | 2014-03-10 16:49:41 -0700 | [diff] [blame] | 39 | HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS |
Ian Rogers | 61e5059 | 2014-01-29 13:09:30 -0800 | [diff] [blame] | 40 | |
SangWook Han | 02eb37c | 2012-06-08 14:55:05 +0900 | [diff] [blame] | 41 | build_mac_version := $(shell sw_vers -productVersion) |
SangWook Han | 691e024 | 2012-07-31 02:09:38 +0900 | [diff] [blame] | 42 | |
Andrew Hsieh | e2e28f6 | 2012-11-09 21:12:02 -0800 | [diff] [blame] | 43 | mac_sdk_versions_supported := 10.6 10.7 10.8 |
| 44 | ifneq ($(strip $(MAC_SDK_VERSION)),) |
| 45 | mac_sdk_version := $(MAC_SDK_VERSION) |
| 46 | ifeq ($(filter $(mac_sdk_version),$(mac_sdk_versions_supported)),) |
| 47 | $(warning ****************************************************************) |
| 48 | $(warning * MAC_SDK_VERSION $(MAC_SDK_VERSION) isn't one of the supported $(mac_sdk_versions_supported)) |
| 49 | $(warning ****************************************************************) |
| 50 | $(error Stop.) |
| 51 | endif |
SangWook Han | 691e024 | 2012-07-31 02:09:38 +0900 | [diff] [blame] | 52 | else |
Andrew Hsieh | e2e28f6 | 2012-11-09 21:12:02 -0800 | [diff] [blame] | 53 | mac_sdk_versions_installed := $(shell xcodebuild -showsdks | grep macosx | sort | sed -e "s/.*macosx//g") |
SangWook Han | 691e024 | 2012-07-31 02:09:38 +0900 | [diff] [blame] | 54 | mac_sdk_version := $(firstword $(filter $(mac_sdk_versions_installed), $(mac_sdk_versions_supported))) |
| 55 | ifeq ($(mac_sdk_version),) |
| 56 | mac_sdk_version := $(firstword $(mac_sdk_versions_supported)) |
| 57 | endif |
SangWook Han | 691e024 | 2012-07-31 02:09:38 +0900 | [diff] [blame] | 58 | endif |
Andrew Hsieh | 31ef103 | 2012-08-21 14:40:16 +0800 | [diff] [blame] | 59 | |
| 60 | mac_sdk_path := $(shell xcode-select -print-path) |
Andrew Hsieh | e2e28f6 | 2012-11-09 21:12:02 -0800 | [diff] [blame] | 61 | # try /Applications/Xcode*.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.?.sdk |
| 62 | # or /Volume/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.?.sdk |
SangWook Han | 691e024 | 2012-07-31 02:09:38 +0900 | [diff] [blame] | 63 | mac_sdk_root := $(mac_sdk_path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(mac_sdk_version).sdk |
Andrew Hsieh | e2e28f6 | 2012-11-09 21:12:02 -0800 | [diff] [blame] | 64 | ifeq ($(wildcard $(mac_sdk_root)),) |
| 65 | # try legacy /Developer/SDKs/MacOSX10.?.sdk |
| 66 | mac_sdk_root := /Developer/SDKs/MacOSX$(mac_sdk_version).sdk |
SangWook Han | 691e024 | 2012-07-31 02:09:38 +0900 | [diff] [blame] | 67 | endif |
Ying Wang | abf72cf | 2012-05-25 15:14:12 -0700 | [diff] [blame] | 68 | ifeq ($(wildcard $(mac_sdk_root)),) |
Ying Wang | d6683f0 | 2010-08-24 18:33:22 -0700 | [diff] [blame] | 69 | $(warning *****************************************************) |
Ying Wang | 644dc16 | 2012-05-25 15:14:12 -0700 | [diff] [blame] | 70 | $(warning * Can not find SDK $(mac_sdk_version) at $(mac_sdk_root)) |
Ying Wang | d6683f0 | 2010-08-24 18:33:22 -0700 | [diff] [blame] | 71 | $(warning *****************************************************) |
| 72 | $(error Stop.) |
| 73 | endif |
| 74 | |
Andrew Hsieh | e2e28f6 | 2012-11-09 21:12:02 -0800 | [diff] [blame] | 75 | ifeq ($(mac_sdk_version),10.6) |
| 76 | gcc_darwin_version := 10 |
| 77 | else |
| 78 | gcc_darwin_version := 11 |
| 79 | endif |
| 80 | |
| 81 | HOST_TOOLCHAIN_ROOT := prebuilts/gcc/darwin-x86/host/i686-apple-darwin-4.2.1 |
Ying Wang | 85e8cda | 2012-11-12 14:31:20 -0800 | [diff] [blame] | 82 | HOST_TOOLCHAIN_PREFIX := $(HOST_TOOLCHAIN_ROOT)/bin/i686-apple-darwin$(gcc_darwin_version) |
Andrew Hsieh | e2e28f6 | 2012-11-09 21:12:02 -0800 | [diff] [blame] | 83 | # Don't do anything if the toolchain is not there |
Ying Wang | 85e8cda | 2012-11-12 14:31:20 -0800 | [diff] [blame] | 84 | ifneq (,$(strip $(wildcard $(HOST_TOOLCHAIN_PREFIX)-gcc))) |
| 85 | HOST_CC := $(HOST_TOOLCHAIN_PREFIX)-gcc |
| 86 | HOST_CXX := $(HOST_TOOLCHAIN_PREFIX)-g++ |
Andrew Hsieh | e2e28f6 | 2012-11-09 21:12:02 -0800 | [diff] [blame] | 87 | ifeq ($(mac_sdk_version),10.8) |
| 88 | # Mac SDK 10.8 no longer has stdarg.h, etc |
| 89 | host_toolchain_header := $(HOST_TOOLCHAIN_ROOT)/lib/gcc/i686-apple-darwin$(gcc_darwin_version)/4.2.1/include |
| 90 | HOST_GLOBAL_CFLAGS += -isystem $(host_toolchain_header) |
| 91 | endif |
| 92 | else |
| 93 | HOST_CC := gcc |
| 94 | HOST_CXX := g++ |
Ying Wang | 85e8cda | 2012-11-12 14:31:20 -0800 | [diff] [blame] | 95 | endif # $(HOST_TOOLCHAIN_PREFIX)-gcc exists |
Andrew Hsieh | e2e28f6 | 2012-11-09 21:12:02 -0800 | [diff] [blame] | 96 | HOST_AR := $(AR) |
| 97 | HOST_STRIP := $(STRIP) |
C. Sean Young | b47c863 | 2014-02-19 12:53:43 -0800 | [diff] [blame] | 98 | HOST_STRIP_COMMAND = $(HOST_STRIP) --strip-all $< -o $@ |
Andrew Hsieh | e2e28f6 | 2012-11-09 21:12:02 -0800 | [diff] [blame] | 99 | |
Ying Wang | 10f7753 | 2012-06-06 20:33:26 -0700 | [diff] [blame] | 100 | HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) -DMACOSX_DEPLOYMENT_TARGET=$(mac_sdk_version) |
| 101 | HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -Wl,-syslibroot,$(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) |
Jeff Hamilton | ebc2869 | 2010-05-26 18:13:54 -0500 | [diff] [blame] | 102 | |
Elliott Hughes | 468d6a5 | 2012-05-23 17:32:32 -0700 | [diff] [blame] | 103 | HOST_GLOBAL_CFLAGS += -fPIC -funwind-tables |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 104 | HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error |
| 105 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 106 | HOST_SHLIB_SUFFIX := .dylib |
| 107 | HOST_JNILIB_SUFFIX := .jnilib |
| 108 | |
| 109 | HOST_GLOBAL_CFLAGS += \ |
Ying Wang | 130ae6a | 2012-06-05 15:44:21 -0700 | [diff] [blame] | 110 | -include $(call select-android-config-h,darwin-x86) |
Ying Wang | 5bdf305 | 2012-09-20 10:06:33 -0700 | [diff] [blame] | 111 | |
Al Sutton | 35bb642 | 2012-05-07 09:33:34 +0100 | [diff] [blame] | 112 | ifneq ($(filter 10.7 10.7.% 10.8 10.8.%, $(build_mac_version)),) |
Al Sutton | 9ce06f1 | 2011-12-21 13:12:05 -0800 | [diff] [blame] | 113 | HOST_RUN_RANLIB_AFTER_COPYING := false |
| 114 | else |
| 115 | HOST_RUN_RANLIB_AFTER_COPYING := true |
Al Sutton | 80cfc37 | 2012-01-04 15:16:50 -0800 | [diff] [blame] | 116 | PRE_LION_DYNAMIC_LINKER_OPTIONS := -Wl,-dynamic |
Al Sutton | 9ce06f1 | 2011-12-21 13:12:05 -0800 | [diff] [blame] | 117 | endif |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 118 | HOST_GLOBAL_ARFLAGS := cqs |
| 119 | |
| 120 | HOST_CUSTOM_LD_COMMAND := true |
| 121 | |
| 122 | define transform-host-o-to-shared-lib-inner |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 123 | $(hide) $(PRIVATE_CXX) \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 124 | -dynamiclib -single_module -read_only_relocs suppress \ |
| 125 | $(HOST_GLOBAL_LD_DIRS) \ |
Tim Murray | d318ba6 | 2014-04-21 14:00:31 -0700 | [diff] [blame^] | 126 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 127 | $(PRIVATE_HOST_GLOBAL_LDFLAGS) \ |
| 128 | ) \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 129 | $(PRIVATE_ALL_OBJECTS) \ |
Shih-wei Liao | b268075 | 2012-05-02 04:41:41 -0700 | [diff] [blame] | 130 | $(addprefix -force_load , $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 131 | $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 132 | $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 133 | $(PRIVATE_LDLIBS) \ |
| 134 | -o $@ \ |
Ying Wang | 5dea692 | 2012-02-01 13:18:20 -0800 | [diff] [blame] | 135 | -install_name @rpath/$(notdir $@) \ |
| 136 | -Wl,-rpath,@loader_path/../lib \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 137 | $(PRIVATE_LDFLAGS) \ |
| 138 | $(HOST_LIBGCC) |
| 139 | endef |
| 140 | |
| 141 | define transform-host-o-to-executable-inner |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 142 | $(hide) $(PRIVATE_CXX) \ |
Ying Wang | 5dea692 | 2012-02-01 13:18:20 -0800 | [diff] [blame] | 143 | -Wl,-rpath,@loader_path/../lib \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 144 | -o $@ \ |
Tim Murray | d318ba6 | 2014-04-21 14:00:31 -0700 | [diff] [blame^] | 145 | $(PRE_LION_DYNAMIC_LINKER_OPTIONS) -Wl,-headerpad_max_install_names \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 146 | $(HOST_GLOBAL_LD_DIRS) \ |
Tim Murray | d318ba6 | 2014-04-21 14:00:31 -0700 | [diff] [blame^] | 147 | $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ |
| 148 | $(PRIVATE_HOST_GLOBAL_LDFLAGS) \ |
| 149 | ) \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 150 | $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 151 | $(PRIVATE_ALL_OBJECTS) \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 152 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 153 | $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 154 | $(PRIVATE_LDFLAGS) \ |
| 155 | $(PRIVATE_LDLIBS) \ |
| 156 | $(HOST_LIBGCC) |
| 157 | endef |
| 158 | |
| 159 | # $(1): The file to check |
| 160 | define get-file-size |
| 161 | stat -f "%z" $(1) |
| 162 | endef |
Tim Murray | 02cefc9 | 2014-03-20 13:48:35 -0700 | [diff] [blame] | 163 | |
| 164 | # gcc location for clang; to be updated when clang is updated |
| 165 | # HOST_TOOLCHAIN_ROOT is a Darwin-specific define |
| 166 | HOST_TOOLCHAIN_FOR_CLANG := $(HOST_TOOLCHAIN_ROOT) |