blob: 8be6a42bac3e0a779b97ff134b50085b812b0e99 [file] [log] [blame]
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -08001#
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 Hamiltonebc28692010-05-26 18:13:54 -050020# 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.
23HOST_GLOBAL_CFLAGS += -m32
24HOST_GLOBAL_LDFLAGS += -m32
25
SangWook Han02eb37c2012-06-08 14:55:05 +090026build_mac_version := $(shell sw_vers -productVersion)
Ying Wang644dc162012-05-25 15:14:12 -070027mac_sdk_version := 10.6
28mac_sdk_root := /Developer/SDKs/MacOSX$(mac_sdk_version).sdk
29ifeq ($(wildcard $(mac_sdk_root)),)
Al Sutton51f9bb02012-06-07 19:10:13 +010030recent_xcode4_mac_sdk_root := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(mac_sdk_version).sdk
31ifeq ($(wildcard $(recent_xcode4_mac_sdk_root)),)
Ying Wangd6683f02010-08-24 18:33:22 -070032$(warning *****************************************************)
Ying Wang644dc162012-05-25 15:14:12 -070033$(warning * Can not find SDK $(mac_sdk_version) at $(mac_sdk_root))
Al Sutton51f9bb02012-06-07 19:10:13 +010034$(warning * or $(recent_xcode4_mac_sdk_root))
Ying Wangd6683f02010-08-24 18:33:22 -070035$(warning *****************************************************)
36$(error Stop.)
37endif
Al Sutton51f9bb02012-06-07 19:10:13 +010038mac_sdk_root := $(recent_xcode4_mac_sdk_root)
39endif
Ying Wangd6683f02010-08-24 18:33:22 -070040
Ying Wang644dc162012-05-25 15:14:12 -070041HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)
42HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)
Jeff Hamiltonebc28692010-05-26 18:13:54 -050043
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080044HOST_GLOBAL_CFLAGS += -fPIC
45HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error
46
Al Sutton0d07c732012-02-23 18:14:27 +000047GCC_REALPATH = $(realpath $(shell which gcc))
48ifneq ($(findstring llvm-gcc,$(GCC_REALPATH)),)
49 # Using LLVM GCC results in a non functional emulator due to it
50 # not honouring global register variables
51 $(warning ****************************************)
52 $(warning * gcc is linked to llvm-gcc which will *)
53 $(warning * not create a useable emulator. *)
54 $(warning ****************************************)
55endif
56
57HOST_CC := gcc
58HOST_CXX := g++
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080059HOST_AR := $(AR)
Bruce Beare45ac4342010-06-24 14:02:00 -070060HOST_STRIP := $(STRIP)
61HOST_STRIP_COMMAND = $(HOST_STRIP) --strip-debug $< -o $@
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080062
63HOST_SHLIB_SUFFIX := .dylib
64HOST_JNILIB_SUFFIX := .jnilib
65
66HOST_GLOBAL_CFLAGS += \
67 -include $(call select-android-config-h,darwin-x86)
Al Sutton35bb6422012-05-07 09:33:34 +010068ifneq ($(filter 10.7 10.7.% 10.8 10.8.%, $(build_mac_version)),)
Al Sutton9ce06f12011-12-21 13:12:05 -080069 HOST_RUN_RANLIB_AFTER_COPYING := false
70else
71 HOST_RUN_RANLIB_AFTER_COPYING := true
Al Sutton80cfc372012-01-04 15:16:50 -080072 PRE_LION_DYNAMIC_LINKER_OPTIONS := -Wl,-dynamic
Al Sutton9ce06f12011-12-21 13:12:05 -080073endif
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080074HOST_GLOBAL_ARFLAGS := cqs
75
76HOST_CUSTOM_LD_COMMAND := true
77
78define transform-host-o-to-shared-lib-inner
Ying Wang3a7e4cc2011-01-28 14:14:47 -080079$(hide) $(PRIVATE_CXX) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080080 -dynamiclib -single_module -read_only_relocs suppress \
81 $(HOST_GLOBAL_LD_DIRS) \
Jeff Hamiltonebc28692010-05-26 18:13:54 -050082 $(HOST_GLOBAL_LDFLAGS) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080083 $(PRIVATE_ALL_OBJECTS) \
Ying Wang80e6cce2011-01-24 23:25:36 -080084 $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
85 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -070086 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
Ying Wang80e6cce2011-01-24 23:25:36 -080087 $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -070088 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080089 $(PRIVATE_LDLIBS) \
90 -o $@ \
91 $(PRIVATE_LDFLAGS) \
92 $(HOST_LIBGCC)
93endef
94
95define transform-host-o-to-executable-inner
Ying Wang3a7e4cc2011-01-28 14:14:47 -080096$(hide) $(PRIVATE_CXX) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080097 -o $@ \
Al Sutton80cfc372012-01-04 15:16:50 -080098 $(PRE_LION_DYNAMIC_LINKER_OPTIONS) -headerpad_max_install_names \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080099 $(HOST_GLOBAL_LD_DIRS) \
Jeff Hamiltonebc28692010-05-26 18:13:54 -0500100 $(HOST_GLOBAL_LDFLAGS) \
Ying Wang80e6cce2011-01-24 23:25:36 -0800101 $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800102 $(PRIVATE_ALL_OBJECTS) \
Ying Wang80e6cce2011-01-24 23:25:36 -0800103 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -0700104 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
Ying Wang80e6cce2011-01-24 23:25:36 -0800105 $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -0700106 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800107 $(PRIVATE_LDFLAGS) \
108 $(PRIVATE_LDLIBS) \
109 $(HOST_LIBGCC)
110endef
111
112# $(1): The file to check
113define get-file-size
114stat -f "%z" $(1)
115endef