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 | |
Jeff Hamilton | ebc2869 | 2010-05-26 18:13:54 -0500 | [diff] [blame] | 20 | # We build everything in 32-bit, because some host tools are |
| 21 | # 32-bit-only anyway (emulator, acc), and because it gives us |
| 22 | # more consistency between the host tools and the target. |
| 23 | HOST_GLOBAL_CFLAGS += -m32 |
| 24 | HOST_GLOBAL_LDFLAGS += -m32 |
| 25 | |
Ying Wang | 644dc16 | 2012-05-25 15:14:12 -0700 | [diff] [blame] | 26 | mac_sdk_version := 10.6 |
| 27 | mac_sdk_root := /Developer/SDKs/MacOSX$(mac_sdk_version).sdk |
| 28 | ifeq ($(wildcard $(mac_sdk_root)),) |
Al Sutton | 51f9bb0 | 2012-06-07 19:10:13 +0100 | [diff] [blame] | 29 | recent_xcode4_mac_sdk_root := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(mac_sdk_version).sdk |
| 30 | ifeq ($(wildcard $(recent_xcode4_mac_sdk_root)),) |
Ying Wang | d6683f0 | 2010-08-24 18:33:22 -0700 | [diff] [blame] | 31 | $(warning *****************************************************) |
Ying Wang | 644dc16 | 2012-05-25 15:14:12 -0700 | [diff] [blame] | 32 | $(warning * Can not find SDK $(mac_sdk_version) at $(mac_sdk_root)) |
Al Sutton | 51f9bb0 | 2012-06-07 19:10:13 +0100 | [diff] [blame] | 33 | $(warning * or $(recent_xcode4_mac_sdk_root)) |
Ying Wang | d6683f0 | 2010-08-24 18:33:22 -0700 | [diff] [blame] | 34 | $(warning *****************************************************) |
| 35 | $(error Stop.) |
| 36 | endif |
Al Sutton | 51f9bb0 | 2012-06-07 19:10:13 +0100 | [diff] [blame] | 37 | mac_sdk_root := $(recent_xcode4_mac_sdk_root) |
| 38 | endif |
Ying Wang | d6683f0 | 2010-08-24 18:33:22 -0700 | [diff] [blame] | 39 | |
Ying Wang | 644dc16 | 2012-05-25 15:14:12 -0700 | [diff] [blame] | 40 | HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) |
| 41 | HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) |
Jeff Hamilton | ebc2869 | 2010-05-26 18:13:54 -0500 | [diff] [blame] | 42 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 43 | HOST_GLOBAL_CFLAGS += -fPIC |
| 44 | HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error |
| 45 | |
Al Sutton | 0d07c73 | 2012-02-23 18:14:27 +0000 | [diff] [blame] | 46 | GCC_REALPATH = $(realpath $(shell which gcc)) |
| 47 | ifneq ($(findstring llvm-gcc,$(GCC_REALPATH)),) |
| 48 | # Using LLVM GCC results in a non functional emulator due to it |
| 49 | # not honouring global register variables |
| 50 | $(warning ****************************************) |
| 51 | $(warning * gcc is linked to llvm-gcc which will *) |
| 52 | $(warning * not create a useable emulator. *) |
| 53 | $(warning ****************************************) |
| 54 | endif |
| 55 | |
| 56 | HOST_CC := gcc |
| 57 | HOST_CXX := g++ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 58 | HOST_AR := $(AR) |
Bruce Beare | 45ac434 | 2010-06-24 14:02:00 -0700 | [diff] [blame] | 59 | HOST_STRIP := $(STRIP) |
| 60 | HOST_STRIP_COMMAND = $(HOST_STRIP) --strip-debug $< -o $@ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 61 | |
| 62 | HOST_SHLIB_SUFFIX := .dylib |
| 63 | HOST_JNILIB_SUFFIX := .jnilib |
| 64 | |
| 65 | HOST_GLOBAL_CFLAGS += \ |
| 66 | -include $(call select-android-config-h,darwin-x86) |
Al Sutton | 35bb642 | 2012-05-07 09:33:34 +0100 | [diff] [blame] | 67 | 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] | 68 | HOST_RUN_RANLIB_AFTER_COPYING := false |
| 69 | else |
| 70 | HOST_RUN_RANLIB_AFTER_COPYING := true |
Al Sutton | 80cfc37 | 2012-01-04 15:16:50 -0800 | [diff] [blame] | 71 | PRE_LION_DYNAMIC_LINKER_OPTIONS := -Wl,-dynamic |
Al Sutton | 9ce06f1 | 2011-12-21 13:12:05 -0800 | [diff] [blame] | 72 | endif |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 73 | HOST_GLOBAL_ARFLAGS := cqs |
| 74 | |
| 75 | HOST_CUSTOM_LD_COMMAND := true |
| 76 | |
| 77 | define transform-host-o-to-shared-lib-inner |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 78 | $(hide) $(PRIVATE_CXX) \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 79 | -dynamiclib -single_module -read_only_relocs suppress \ |
| 80 | $(HOST_GLOBAL_LD_DIRS) \ |
Jeff Hamilton | ebc2869 | 2010-05-26 18:13:54 -0500 | [diff] [blame] | 81 | $(HOST_GLOBAL_LDFLAGS) \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 82 | $(PRIVATE_ALL_OBJECTS) \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 83 | $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 84 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 85 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 86 | $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 87 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 88 | $(PRIVATE_LDLIBS) \ |
| 89 | -o $@ \ |
| 90 | $(PRIVATE_LDFLAGS) \ |
| 91 | $(HOST_LIBGCC) |
| 92 | endef |
| 93 | |
| 94 | define transform-host-o-to-executable-inner |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 95 | $(hide) $(PRIVATE_CXX) \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 96 | -o $@ \ |
Al Sutton | 80cfc37 | 2012-01-04 15:16:50 -0800 | [diff] [blame] | 97 | $(PRE_LION_DYNAMIC_LINKER_OPTIONS) -headerpad_max_install_names \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 98 | $(HOST_GLOBAL_LD_DIRS) \ |
Jeff Hamilton | ebc2869 | 2010-05-26 18:13:54 -0500 | [diff] [blame] | 99 | $(HOST_GLOBAL_LDFLAGS) \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 100 | $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 101 | $(PRIVATE_ALL_OBJECTS) \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 102 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 103 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 104 | $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 105 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 106 | $(PRIVATE_LDFLAGS) \ |
| 107 | $(PRIVATE_LDLIBS) \ |
| 108 | $(HOST_LIBGCC) |
| 109 | endef |
| 110 | |
| 111 | # $(1): The file to check |
| 112 | define get-file-size |
| 113 | stat -f "%z" $(1) |
| 114 | endef |