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