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 | d6683f0 | 2010-08-24 18:33:22 -0700 | [diff] [blame] | 26 | # Use the Mac OSX SDK 10.5 if the build host is 10.6 |
| 27 | build_mac_version := $(shell sw_vers -productVersion) |
| 28 | ifneq ($(filter 10.6.%, $(build_mac_version)),) |
| 29 | sdk_105_root := /Developer/SDKs/MacOSX10.5.sdk |
| 30 | ifeq ($(wildcard $(sdk_105_root)),) |
| 31 | $(warning *****************************************************) |
| 32 | $(warning * You are building on Mac OSX 10.6.) |
| 33 | $(warning * Can not find SDK 10.5 at $(sdk_105_root)) |
| 34 | $(warning *****************************************************) |
| 35 | $(error Stop.) |
| 36 | endif |
| 37 | |
| 38 | HOST_GLOBAL_CFLAGS += -isysroot $(sdk_105_root) -mmacosx-version-min=10.5 |
| 39 | HOST_GLOBAL_LDFLAGS += -isysroot $(sdk_105_root) -mmacosx-version-min=10.5 |
| 40 | endif # build_mac_version is 10.6 |
Jeff Hamilton | ebc2869 | 2010-05-26 18:13:54 -0500 | [diff] [blame] | 41 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 42 | HOST_GLOBAL_CFLAGS += -fPIC |
| 43 | HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error |
| 44 | |
| 45 | HOST_CC := $(CC) |
| 46 | HOST_CXX := $(CXX) |
| 47 | HOST_AR := $(AR) |
Bruce Beare | 45ac434 | 2010-06-24 14:02:00 -0700 | [diff] [blame] | 48 | HOST_STRIP := $(STRIP) |
| 49 | HOST_STRIP_COMMAND = $(HOST_STRIP) --strip-debug $< -o $@ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 50 | |
| 51 | HOST_SHLIB_SUFFIX := .dylib |
| 52 | HOST_JNILIB_SUFFIX := .jnilib |
| 53 | |
| 54 | HOST_GLOBAL_CFLAGS += \ |
| 55 | -include $(call select-android-config-h,darwin-x86) |
Al Sutton | 9ce06f1 | 2011-12-21 13:12:05 -0800 | [diff] [blame] | 56 | ifneq ($(filter 10.7.%, $(build_mac_version)),) |
| 57 | HOST_RUN_RANLIB_AFTER_COPYING := false |
| 58 | else |
| 59 | HOST_RUN_RANLIB_AFTER_COPYING := true |
Al Sutton | 80cfc37 | 2012-01-04 15:16:50 -0800 | [diff] [blame] | 60 | PRE_LION_DYNAMIC_LINKER_OPTIONS := -Wl,-dynamic |
Al Sutton | 9ce06f1 | 2011-12-21 13:12:05 -0800 | [diff] [blame] | 61 | endif |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 62 | HOST_GLOBAL_ARFLAGS := cqs |
| 63 | |
| 64 | HOST_CUSTOM_LD_COMMAND := true |
| 65 | |
Ying Wang | fcf246c | 2012-01-20 12:22:49 -0800 | [diff] [blame] | 66 | # Workaround for lack of "-Wl,--whole-archive" in MacOS's linker. |
| 67 | define _darwin-extract-and-include-single-whole-static-lib |
| 68 | @echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(1)]" |
| 69 | $(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\ |
| 70 | mkdir -p $$ldir; \ |
Ying Wang | 92ca609 | 2012-02-23 16:27:43 -0800 | [diff] [blame] | 71 | for f in `$(HOST_AR) t $(1)`; do \ |
| 72 | $(HOST_AR) p $(1) $$f > $$ldir/$$f; \ |
Ying Wang | fcf246c | 2012-01-20 12:22:49 -0800 | [diff] [blame] | 73 | done ; |
| 74 | |
| 75 | endef |
| 76 | |
| 77 | define darwin-extract-and-include-whole-static-libs |
| 78 | $(if $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), $(hide) rm -rf $(PRIVATE_INTERMEDIATES_DIR)/WHOLE) |
| 79 | $(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \ |
| 80 | $(call _darwin-extract-and-include-single-whole-static-lib, $(lib))) |
| 81 | endef |
| 82 | |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 83 | define transform-host-o-to-shared-lib-inner |
Ying Wang | fcf246c | 2012-01-20 12:22:49 -0800 | [diff] [blame] | 84 | $(call darwin-extract-and-include-whole-static-libs) |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 85 | $(hide) $(PRIVATE_CXX) \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 86 | -dynamiclib -single_module -read_only_relocs suppress \ |
| 87 | $(HOST_GLOBAL_LD_DIRS) \ |
Jeff Hamilton | ebc2869 | 2010-05-26 18:13:54 -0500 | [diff] [blame] | 88 | $(HOST_GLOBAL_LDFLAGS) \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 89 | $(PRIVATE_ALL_OBJECTS) \ |
Ying Wang | fcf246c | 2012-01-20 12:22:49 -0800 | [diff] [blame] | 90 | $(if $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), `find $(PRIVATE_INTERMEDIATES_DIR)/WHOLE -name '*.o' 2>/dev/null`) \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 91 | $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 92 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 93 | $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 94 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 95 | $(PRIVATE_LDLIBS) \ |
| 96 | -o $@ \ |
Ying Wang | 5dea692 | 2012-02-01 13:18:20 -0800 | [diff] [blame] | 97 | -install_name @rpath/$(notdir $@) \ |
| 98 | -Wl,-rpath,@loader_path/../lib \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 99 | $(PRIVATE_LDFLAGS) \ |
| 100 | $(HOST_LIBGCC) |
| 101 | endef |
| 102 | |
| 103 | define transform-host-o-to-executable-inner |
Ying Wang | 3a7e4cc | 2011-01-28 14:14:47 -0800 | [diff] [blame] | 104 | $(hide) $(PRIVATE_CXX) \ |
Ying Wang | 5dea692 | 2012-02-01 13:18:20 -0800 | [diff] [blame] | 105 | -Wl,-rpath,@loader_path/../lib \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 106 | -o $@ \ |
Al Sutton | 80cfc37 | 2012-01-04 15:16:50 -0800 | [diff] [blame] | 107 | $(PRE_LION_DYNAMIC_LINKER_OPTIONS) -headerpad_max_install_names \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 108 | $(HOST_GLOBAL_LD_DIRS) \ |
Jeff Hamilton | ebc2869 | 2010-05-26 18:13:54 -0500 | [diff] [blame] | 109 | $(HOST_GLOBAL_LDFLAGS) \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 110 | $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 111 | $(PRIVATE_ALL_OBJECTS) \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 112 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 113 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ |
Ying Wang | 80e6cce | 2011-01-24 23:25:36 -0800 | [diff] [blame] | 114 | $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
Ying Wang | fcdabd4 | 2011-04-25 14:22:41 -0700 | [diff] [blame] | 115 | $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ |
Jean-Baptiste Queru | 9b4a812 | 2010-02-23 12:36:56 -0800 | [diff] [blame] | 116 | $(PRIVATE_LDFLAGS) \ |
| 117 | $(PRIVATE_LDLIBS) \ |
| 118 | $(HOST_LIBGCC) |
| 119 | endef |
| 120 | |
| 121 | # $(1): The file to check |
| 122 | define get-file-size |
| 123 | stat -f "%z" $(1) |
| 124 | endef |