blob: c84e375f7f42e6cd41dba021857a5e483e3d0e60 [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
Andrew Hsiehed6b8152012-02-27 21:03:30 -080020ifneq ($(strip $(BUILD_HOST_64bit)),)
21# By default we build everything in 32-bit, because it gives us
Jeff Hamiltonebc28692010-05-26 18:13:54 -050022# more consistency between the host tools and the target.
Andrew Hsiehed6b8152012-02-27 21:03:30 -080023# BUILD_HOST_64bit=1 overrides it for tool like emulator
24# which can benefit from 64-bit host arch.
25HOST_GLOBAL_CFLAGS += -m64
26HOST_GLOBAL_LDFLAGS += -m64
27else
Jeff Hamiltonebc28692010-05-26 18:13:54 -050028HOST_GLOBAL_CFLAGS += -m32
29HOST_GLOBAL_LDFLAGS += -m32
Andrew Hsiehed6b8152012-02-27 21:03:30 -080030endif # BUILD_HOST_64bit
Jeff Hamiltonebc28692010-05-26 18:13:54 -050031
Andrew Hsiehf9613a42012-04-28 00:35:19 +080032ifneq ($(strip $(BUILD_HOST_static)),)
33# Statically-linked binaries are desirable for sandboxed environment
34HOST_GLOBAL_LDFLAGS += -static
35endif # BUILD_HOST_static
36
Ying Wangabf72cf2012-05-25 15:14:12 -070037mac_sdk_version := 10.6
38mac_sdk_root := /Developer/SDKs/MacOSX$(mac_sdk_version).sdk
39ifeq ($(wildcard $(mac_sdk_root)),)
Ying Wangd6683f02010-08-24 18:33:22 -070040$(warning *****************************************************)
Ying Wangabf72cf2012-05-25 15:14:12 -070041$(warning * Can not find SDK $(mac_sdk_version) at $(mac_sdk_root))
Ying Wangd6683f02010-08-24 18:33:22 -070042$(warning *****************************************************)
43$(error Stop.)
44endif
45
Ying Wangabf72cf2012-05-25 15:14:12 -070046HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)
47HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)
Jeff Hamiltonebc28692010-05-26 18:13:54 -050048
Elliott Hughes468d6a52012-05-23 17:32:32 -070049HOST_GLOBAL_CFLAGS += -fPIC -funwind-tables
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080050HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error
51
Al Sutton0d07c732012-02-23 18:14:27 +000052GCC_REALPATH = $(realpath $(shell which gcc))
53ifneq ($(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 ****************************************)
60endif
61
62HOST_CC := gcc
63HOST_CXX := g++
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080064HOST_AR := $(AR)
Bruce Beare45ac4342010-06-24 14:02:00 -070065HOST_STRIP := $(STRIP)
66HOST_STRIP_COMMAND = $(HOST_STRIP) --strip-debug $< -o $@
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080067
68HOST_SHLIB_SUFFIX := .dylib
69HOST_JNILIB_SUFFIX := .jnilib
70
71HOST_GLOBAL_CFLAGS += \
72 -include $(call select-android-config-h,darwin-x86)
Al Sutton35bb6422012-05-07 09:33:34 +010073ifneq ($(filter 10.7 10.7.% 10.8 10.8.%, $(build_mac_version)),)
Al Sutton9ce06f12011-12-21 13:12:05 -080074 HOST_RUN_RANLIB_AFTER_COPYING := false
75else
76 HOST_RUN_RANLIB_AFTER_COPYING := true
Al Sutton80cfc372012-01-04 15:16:50 -080077 PRE_LION_DYNAMIC_LINKER_OPTIONS := -Wl,-dynamic
Al Sutton9ce06f12011-12-21 13:12:05 -080078endif
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080079HOST_GLOBAL_ARFLAGS := cqs
80
81HOST_CUSTOM_LD_COMMAND := true
82
83define transform-host-o-to-shared-lib-inner
Ying Wang3a7e4cc2011-01-28 14:14:47 -080084$(hide) $(PRIVATE_CXX) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080085 -dynamiclib -single_module -read_only_relocs suppress \
86 $(HOST_GLOBAL_LD_DIRS) \
Jeff Hamiltonebc28692010-05-26 18:13:54 -050087 $(HOST_GLOBAL_LDFLAGS) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080088 $(PRIVATE_ALL_OBJECTS) \
Shih-wei Liaob2680752012-05-02 04:41:41 -070089 $(addprefix -force_load , $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
Ying Wang80e6cce2011-01-24 23:25:36 -080090 $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -070091 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
Ying Wang80e6cce2011-01-24 23:25:36 -080092 $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -070093 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080094 $(PRIVATE_LDLIBS) \
95 -o $@ \
Ying Wang5dea6922012-02-01 13:18:20 -080096 -install_name @rpath/$(notdir $@) \
97 -Wl,-rpath,@loader_path/../lib \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080098 $(PRIVATE_LDFLAGS) \
99 $(HOST_LIBGCC)
100endef
101
102define transform-host-o-to-executable-inner
Ying Wang3a7e4cc2011-01-28 14:14:47 -0800103$(hide) $(PRIVATE_CXX) \
Ying Wang5dea6922012-02-01 13:18:20 -0800104 -Wl,-rpath,@loader_path/../lib \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800105 -o $@ \
Al Sutton80cfc372012-01-04 15:16:50 -0800106 $(PRE_LION_DYNAMIC_LINKER_OPTIONS) -headerpad_max_install_names \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800107 $(HOST_GLOBAL_LD_DIRS) \
Jeff Hamiltonebc28692010-05-26 18:13:54 -0500108 $(HOST_GLOBAL_LDFLAGS) \
Ying Wang80e6cce2011-01-24 23:25:36 -0800109 $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800110 $(PRIVATE_ALL_OBJECTS) \
Ying Wang80e6cce2011-01-24 23:25:36 -0800111 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -0700112 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
Ying Wang80e6cce2011-01-24 23:25:36 -0800113 $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -0700114 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800115 $(PRIVATE_LDFLAGS) \
116 $(PRIVATE_LDLIBS) \
117 $(HOST_LIBGCC)
118endef
119
120# $(1): The file to check
121define get-file-size
122stat -f "%z" $(1)
123endef