blob: aeb91c288ebded8cfe6d08f74316a1f1e9dcbf92 [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
Ying Wangd6683f02010-08-24 18:33:22 -070026# Use the Mac OSX SDK 10.5 if the build host is 10.6
27build_mac_version := $(shell sw_vers -productVersion)
28ifneq ($(filter 10.6.%, $(build_mac_version)),)
29sdk_105_root := /Developer/SDKs/MacOSX10.5.sdk
30ifeq ($(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.)
36endif
37
38HOST_GLOBAL_CFLAGS += -isysroot $(sdk_105_root) -mmacosx-version-min=10.5
39HOST_GLOBAL_LDFLAGS += -isysroot $(sdk_105_root) -mmacosx-version-min=10.5
40endif # build_mac_version is 10.6
Jeff Hamiltonebc28692010-05-26 18:13:54 -050041
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080042HOST_GLOBAL_CFLAGS += -fPIC
43HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error
44
Al Sutton0d07c732012-02-23 18:14:27 +000045GCC_REALPATH = $(realpath $(shell which gcc))
46ifneq ($(findstring llvm-gcc,$(GCC_REALPATH)),)
47 # Using LLVM GCC results in a non functional emulator due to it
48 # not honouring global register variables
49 $(warning ****************************************)
50 $(warning * gcc is linked to llvm-gcc which will *)
51 $(warning * not create a useable emulator. *)
52 $(warning ****************************************)
53endif
54
55HOST_CC := gcc
56HOST_CXX := g++
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080057HOST_AR := $(AR)
Bruce Beare45ac4342010-06-24 14:02:00 -070058HOST_STRIP := $(STRIP)
59HOST_STRIP_COMMAND = $(HOST_STRIP) --strip-debug $< -o $@
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080060
61HOST_SHLIB_SUFFIX := .dylib
62HOST_JNILIB_SUFFIX := .jnilib
63
64HOST_GLOBAL_CFLAGS += \
65 -include $(call select-android-config-h,darwin-x86)
Al Sutton35bb6422012-05-07 09:33:34 +010066ifneq ($(filter 10.7 10.7.% 10.8 10.8.%, $(build_mac_version)),)
Al Sutton9ce06f12011-12-21 13:12:05 -080067 HOST_RUN_RANLIB_AFTER_COPYING := false
68else
69 HOST_RUN_RANLIB_AFTER_COPYING := true
Al Sutton80cfc372012-01-04 15:16:50 -080070 PRE_LION_DYNAMIC_LINKER_OPTIONS := -Wl,-dynamic
Al Sutton9ce06f12011-12-21 13:12:05 -080071endif
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080072HOST_GLOBAL_ARFLAGS := cqs
73
74HOST_CUSTOM_LD_COMMAND := true
75
76define transform-host-o-to-shared-lib-inner
Ying Wang3a7e4cc2011-01-28 14:14:47 -080077$(hide) $(PRIVATE_CXX) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080078 -dynamiclib -single_module -read_only_relocs suppress \
79 $(HOST_GLOBAL_LD_DIRS) \
Jeff Hamiltonebc28692010-05-26 18:13:54 -050080 $(HOST_GLOBAL_LDFLAGS) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080081 $(PRIVATE_ALL_OBJECTS) \
Ying Wang80e6cce2011-01-24 23:25:36 -080082 $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
83 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -070084 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
Ying Wang80e6cce2011-01-24 23:25:36 -080085 $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -070086 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080087 $(PRIVATE_LDLIBS) \
88 -o $@ \
89 $(PRIVATE_LDFLAGS) \
90 $(HOST_LIBGCC)
91endef
92
93define transform-host-o-to-executable-inner
Ying Wang3a7e4cc2011-01-28 14:14:47 -080094$(hide) $(PRIVATE_CXX) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080095 -o $@ \
Al Sutton80cfc372012-01-04 15:16:50 -080096 $(PRE_LION_DYNAMIC_LINKER_OPTIONS) -headerpad_max_install_names \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080097 $(HOST_GLOBAL_LD_DIRS) \
Jeff Hamiltonebc28692010-05-26 18:13:54 -050098 $(HOST_GLOBAL_LDFLAGS) \
Ying Wang80e6cce2011-01-24 23:25:36 -080099 $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800100 $(PRIVATE_ALL_OBJECTS) \
Ying Wang80e6cce2011-01-24 23:25:36 -0800101 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -0700102 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
Ying Wang80e6cce2011-01-24 23:25:36 -0800103 $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -0700104 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800105 $(PRIVATE_LDFLAGS) \
106 $(PRIVATE_LDLIBS) \
107 $(HOST_LIBGCC)
108endef
109
110# $(1): The file to check
111define get-file-size
112stat -f "%z" $(1)
113endef