blob: 85bb2cd55c9fee07be786fea955f472fab615584 [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
SangWook Han02eb37c2012-06-08 14:55:05 +090032build_mac_version := $(shell sw_vers -productVersion)
Ying Wang644dc162012-05-25 15:14:12 -070033mac_sdk_version := 10.6
34mac_sdk_root := /Developer/SDKs/MacOSX$(mac_sdk_version).sdk
35ifeq ($(wildcard $(mac_sdk_root)),)
Al Sutton51f9bb02012-06-07 19:10:13 +010036recent_xcode4_mac_sdk_root := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(mac_sdk_version).sdk
37ifeq ($(wildcard $(recent_xcode4_mac_sdk_root)),)
Ying Wangd6683f02010-08-24 18:33:22 -070038$(warning *****************************************************)
Ying Wang644dc162012-05-25 15:14:12 -070039$(warning * Can not find SDK $(mac_sdk_version) at $(mac_sdk_root))
Al Sutton51f9bb02012-06-07 19:10:13 +010040$(warning * or $(recent_xcode4_mac_sdk_root))
Ying Wangd6683f02010-08-24 18:33:22 -070041$(warning *****************************************************)
42$(error Stop.)
43endif
Al Sutton51f9bb02012-06-07 19:10:13 +010044mac_sdk_root := $(recent_xcode4_mac_sdk_root)
45endif
Ying Wangd6683f02010-08-24 18:33:22 -070046
Ying Wang644dc162012-05-25 15:14:12 -070047HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)
48HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)
Jeff Hamiltonebc28692010-05-26 18:13:54 -050049
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080050HOST_GLOBAL_CFLAGS += -fPIC
51HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error
52
Al Sutton0d07c732012-02-23 18:14:27 +000053HOST_CC := gcc
54HOST_CXX := g++
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080055HOST_AR := $(AR)
Bruce Beare45ac4342010-06-24 14:02:00 -070056HOST_STRIP := $(STRIP)
57HOST_STRIP_COMMAND = $(HOST_STRIP) --strip-debug $< -o $@
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080058
59HOST_SHLIB_SUFFIX := .dylib
60HOST_JNILIB_SUFFIX := .jnilib
61
62HOST_GLOBAL_CFLAGS += \
63 -include $(call select-android-config-h,darwin-x86)
Al Sutton35bb6422012-05-07 09:33:34 +010064ifneq ($(filter 10.7 10.7.% 10.8 10.8.%, $(build_mac_version)),)
Al Sutton9ce06f12011-12-21 13:12:05 -080065 HOST_RUN_RANLIB_AFTER_COPYING := false
66else
67 HOST_RUN_RANLIB_AFTER_COPYING := true
Al Sutton80cfc372012-01-04 15:16:50 -080068 PRE_LION_DYNAMIC_LINKER_OPTIONS := -Wl,-dynamic
Al Sutton9ce06f12011-12-21 13:12:05 -080069endif
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080070HOST_GLOBAL_ARFLAGS := cqs
71
72HOST_CUSTOM_LD_COMMAND := true
73
Ying Wangfcf246c2012-01-20 12:22:49 -080074# Workaround for lack of "-Wl,--whole-archive" in MacOS's linker.
75define _darwin-extract-and-include-single-whole-static-lib
76@echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(1)]"
77$(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\
78 mkdir -p $$ldir; \
Ying Wang92ca6092012-02-23 16:27:43 -080079 for f in `$(HOST_AR) t $(1)`; do \
80 $(HOST_AR) p $(1) $$f > $$ldir/$$f; \
Ying Wangfcf246c2012-01-20 12:22:49 -080081 done ;
82
83endef
84
85define darwin-extract-and-include-whole-static-libs
86$(if $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), $(hide) rm -rf $(PRIVATE_INTERMEDIATES_DIR)/WHOLE)
87$(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \
88 $(call _darwin-extract-and-include-single-whole-static-lib, $(lib)))
89endef
90
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080091define transform-host-o-to-shared-lib-inner
Ying Wangfcf246c2012-01-20 12:22:49 -080092$(call darwin-extract-and-include-whole-static-libs)
Ying Wang3a7e4cc2011-01-28 14:14:47 -080093$(hide) $(PRIVATE_CXX) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080094 -dynamiclib -single_module -read_only_relocs suppress \
95 $(HOST_GLOBAL_LD_DIRS) \
Jeff Hamiltonebc28692010-05-26 18:13:54 -050096 $(HOST_GLOBAL_LDFLAGS) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080097 $(PRIVATE_ALL_OBJECTS) \
Ying Wangfcf246c2012-01-20 12:22:49 -080098 $(if $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), `find $(PRIVATE_INTERMEDIATES_DIR)/WHOLE -name '*.o' 2>/dev/null`) \
Ying Wang80e6cce2011-01-24 23:25:36 -080099 $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -0700100 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
Ying Wang80e6cce2011-01-24 23:25:36 -0800101 $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -0700102 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800103 $(PRIVATE_LDLIBS) \
104 -o $@ \
Ying Wang5dea6922012-02-01 13:18:20 -0800105 -install_name @rpath/$(notdir $@) \
106 -Wl,-rpath,@loader_path/../lib \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800107 $(PRIVATE_LDFLAGS) \
108 $(HOST_LIBGCC)
109endef
110
111define transform-host-o-to-executable-inner
Ying Wang3a7e4cc2011-01-28 14:14:47 -0800112$(hide) $(PRIVATE_CXX) \
Ying Wang5dea6922012-02-01 13:18:20 -0800113 -Wl,-rpath,@loader_path/../lib \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800114 -o $@ \
Al Sutton80cfc372012-01-04 15:16:50 -0800115 $(PRE_LION_DYNAMIC_LINKER_OPTIONS) -headerpad_max_install_names \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800116 $(HOST_GLOBAL_LD_DIRS) \
Jeff Hamiltonebc28692010-05-26 18:13:54 -0500117 $(HOST_GLOBAL_LDFLAGS) \
Ying Wang80e6cce2011-01-24 23:25:36 -0800118 $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800119 $(PRIVATE_ALL_OBJECTS) \
Ying Wang80e6cce2011-01-24 23:25:36 -0800120 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -0700121 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
Ying Wang80e6cce2011-01-24 23:25:36 -0800122 $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
Ying Wangfcdabd42011-04-25 14:22:41 -0700123 $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800124 $(PRIVATE_LDFLAGS) \
125 $(PRIVATE_LDLIBS) \
126 $(HOST_LIBGCC)
127endef
128
129# $(1): The file to check
130define get-file-size
131stat -f "%z" $(1)
132endef