blob: ff4bbb542074acb6ddc49b191c5a8b5dd59d7af8 [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
Ying Wangd6683f02010-08-24 18:33:22 -070032# Use the Mac OSX SDK 10.5 if the build host is 10.6
33build_mac_version := $(shell sw_vers -productVersion)
34ifneq ($(filter 10.6.%, $(build_mac_version)),)
35sdk_105_root := /Developer/SDKs/MacOSX10.5.sdk
36ifeq ($(wildcard $(sdk_105_root)),)
37$(warning *****************************************************)
38$(warning * You are building on Mac OSX 10.6.)
39$(warning * Can not find SDK 10.5 at $(sdk_105_root))
40$(warning *****************************************************)
41$(error Stop.)
42endif
43
44HOST_GLOBAL_CFLAGS += -isysroot $(sdk_105_root) -mmacosx-version-min=10.5
45HOST_GLOBAL_LDFLAGS += -isysroot $(sdk_105_root) -mmacosx-version-min=10.5
46endif # build_mac_version is 10.6
Jeff Hamiltonebc28692010-05-26 18:13:54 -050047
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080048HOST_GLOBAL_CFLAGS += -fPIC
49HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error
50
51HOST_CC := $(CC)
52HOST_CXX := $(CXX)
53HOST_AR := $(AR)
Bruce Beare45ac4342010-06-24 14:02:00 -070054HOST_STRIP := $(STRIP)
55HOST_STRIP_COMMAND = $(HOST_STRIP) --strip-debug $< -o $@
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080056
57HOST_SHLIB_SUFFIX := .dylib
58HOST_JNILIB_SUFFIX := .jnilib
59
60HOST_GLOBAL_CFLAGS += \
61 -include $(call select-android-config-h,darwin-x86)
Al Sutton9ce06f12011-12-21 13:12:05 -080062ifneq ($(filter 10.7.%, $(build_mac_version)),)
63 HOST_RUN_RANLIB_AFTER_COPYING := false
64else
65 HOST_RUN_RANLIB_AFTER_COPYING := true
Al Sutton80cfc372012-01-04 15:16:50 -080066 PRE_LION_DYNAMIC_LINKER_OPTIONS := -Wl,-dynamic
Al Sutton9ce06f12011-12-21 13:12:05 -080067endif
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080068HOST_GLOBAL_ARFLAGS := cqs
69
70HOST_CUSTOM_LD_COMMAND := true
71
72define transform-host-o-to-shared-lib-inner
Ying Wang3a7e4cc2011-01-28 14:14:47 -080073$(hide) $(PRIVATE_CXX) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080074 -dynamiclib -single_module -read_only_relocs suppress \
75 $(HOST_GLOBAL_LD_DIRS) \
Jeff Hamiltonebc28692010-05-26 18:13:54 -050076 $(HOST_GLOBAL_LDFLAGS) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080077 $(PRIVATE_ALL_OBJECTS) \
Shih-wei Liaob2680752012-05-02 04:41:41 -070078 $(addprefix -force_load , $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
Ying Wang80e6cce2011-01-24 23:25:36 -080079 $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -070080 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
Ying Wang80e6cce2011-01-24 23:25:36 -080081 $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -070082 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080083 $(PRIVATE_LDLIBS) \
84 -o $@ \
Ying Wang5dea6922012-02-01 13:18:20 -080085 -install_name @rpath/$(notdir $@) \
86 -Wl,-rpath,@loader_path/../lib \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080087 $(PRIVATE_LDFLAGS) \
88 $(HOST_LIBGCC)
89endef
90
91define transform-host-o-to-executable-inner
Ying Wang3a7e4cc2011-01-28 14:14:47 -080092$(hide) $(PRIVATE_CXX) \
Ying Wang5dea6922012-02-01 13:18:20 -080093 -Wl,-rpath,@loader_path/../lib \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080094 -o $@ \
Al Sutton80cfc372012-01-04 15:16:50 -080095 $(PRE_LION_DYNAMIC_LINKER_OPTIONS) -headerpad_max_install_names \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080096 $(HOST_GLOBAL_LD_DIRS) \
Jeff Hamiltonebc28692010-05-26 18:13:54 -050097 $(HOST_GLOBAL_LDFLAGS) \
Ying Wang80e6cce2011-01-24 23:25:36 -080098 $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080099 $(PRIVATE_ALL_OBJECTS) \
Ying Wang80e6cce2011-01-24 23:25:36 -0800100 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -0700101 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
Ying Wang80e6cce2011-01-24 23:25:36 -0800102 $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -0700103 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800104 $(PRIVATE_LDFLAGS) \
105 $(PRIVATE_LDLIBS) \
106 $(HOST_LIBGCC)
107endef
108
109# $(1): The file to check
110define get-file-size
111stat -f "%z" $(1)
112endef