19b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru#
29b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru# Copyright (C) 2006 The Android Open Source Project
39b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru#
49b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru# Licensed under the Apache License, Version 2.0 (the "License");
59b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru# you may not use this file except in compliance with the License.
69b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru# You may obtain a copy of the License at
79b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru#
89b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru#      http://www.apache.org/licenses/LICENSE-2.0
99b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru#
109b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru# Unless required by applicable law or agreed to in writing, software
119b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru# distributed under the License is distributed on an "AS IS" BASIS,
129b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru# See the License for the specific language governing permissions and
149b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru# limitations under the License.
159b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru#
169b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru
179b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru# Configuration for Darwin (Mac OS X) on x86.
189b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru# Included by combo/select.mk
199b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru
206feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -m32
216feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -m32
22ebc2869b8d324caf93ca68be08aa2be9a09c4cceJeff Hamilton
23f9613a4f730b8a385971f95150582b9a543302aeAndrew Hsiehifneq ($(strip $(BUILD_HOST_static)),)
24f9613a4f730b8a385971f95150582b9a543302aeAndrew Hsieh# Statically-linked binaries are desirable for sandboxed environment
256feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -static
26f9613a4f730b8a385971f95150582b9a543302aeAndrew Hsiehendif # BUILD_HOST_static
27f9613a4f730b8a385971f95150582b9a543302aeAndrew Hsieh
2861e5059ef768388db01232c61879d2ba3e0c1d47Ian Rogers# Workaround differences in inttypes.h between host and target.
2961e5059ef768388db01232c61879d2ba3e0c1d47Ian Rogers# See bug 12708004.
306feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS
31691e0243ca880722f5dd86a1052fc7ffbc55f8c4SangWook Han
326feb6d5607ce86a446645564212043964628f540Ying Wanginclude $(BUILD_COMBOS)/mac_version.mk
339b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru
346feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT := prebuilts/gcc/darwin-x86/host/i686-apple-darwin-4.2.1
356feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT)/bin/i686-apple-darwin$(gcc_darwin_version)
36e2e28f6d028d74b92457b885d9184d669575a15dAndrew Hsieh# Don't do anything if the toolchain is not there
376feb6d5607ce86a446645564212043964628f540Ying Wangifneq (,$(strip $(wildcard $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)-gcc)))
386feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_CC  := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)-gcc
396feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_CXX := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)-g++
40e2e28f6d028d74b92457b885d9184d669575a15dAndrew Hsiehifeq ($(mac_sdk_version),10.8)
41e2e28f6d028d74b92457b885d9184d669575a15dAndrew Hsieh# Mac SDK 10.8 no longer has stdarg.h, etc
426feb6d5607ce86a446645564212043964628f540Ying Wanghost_toolchain_header := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT)/lib/gcc/i686-apple-darwin$(gcc_darwin_version)/4.2.1/include
436feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -isystem $(host_toolchain_header)
44e2e28f6d028d74b92457b885d9184d669575a15dAndrew Hsiehendif
45e2e28f6d028d74b92457b885d9184d669575a15dAndrew Hsiehelse
466feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_CC := gcc
476feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_CXX := g++
4885e8cda3405be4acc0da0a094209dd0e8f11cd55Ying Wangendif # $(HOST_TOOLCHAIN_PREFIX)-gcc exists
499b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru
506feb6d5607ce86a446645564212043964628f540Ying Wang# gcc location for clang; to be updated when clang is updated
516feb6d5607ce86a446645564212043964628f540Ying Wang# HOST_TOOLCHAIN_ROOT is a Darwin-specific define
52ef773d22ca2eaacda0a3e5101c76bde3efcf98aaYing Wang$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT)
536feb6d5607ce86a446645564212043964628f540Ying Wang
546feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_AR := $(AR)
55e2e28f6d028d74b92457b885d9184d669575a15dAndrew Hsieh
566feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) -DMACOSX_DEPLOYMENT_TARGET=$(mac_sdk_version)
576feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -Wl,-syslibroot,$(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)
58e2e28f6d028d74b92457b885d9184d669575a15dAndrew Hsieh
596feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -fPIC -funwind-tables
606feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error
619b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru
626feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_SHLIB_SUFFIX := .dylib
636feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_JNILIB_SUFFIX := .jnilib
646feb6d5607ce86a446645564212043964628f540Ying Wang
656feb6d5607ce86a446645564212043964628f540Ying Wang# TODO: add AndroidConfig.h for darwin-x86_64
666feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += \
67130ae6adcb418d461b78d6667527137854f54592Ying Wang    -include $(call select-android-config-h,darwin-x86)
685bdf305bbe529a85735200353478057b65bb462eYing Wang
6935bb6422bc4dddaf7871793d213c0f7144c02f0cAl Suttonifneq ($(filter 10.7 10.7.% 10.8 10.8.%, $(build_mac_version)),)
706feb6d5607ce86a446645564212043964628f540Ying Wang       $(combo_2nd_arch_prefix)HOST_RUN_RANLIB_AFTER_COPYING := false
719ce06f11d69f5154843c234fe0624f9e70d39359Al Suttonelse
726feb6d5607ce86a446645564212043964628f540Ying Wang       $(combo_2nd_arch_prefix)HOST_RUN_RANLIB_AFTER_COPYING := true
7380cfc37d0f0ddbb7db09b7662b84e816ab409537Al Sutton       PRE_LION_DYNAMIC_LINKER_OPTIONS := -Wl,-dynamic
749ce06f11d69f5154843c234fe0624f9e70d39359Al Suttonendif
756feb6d5607ce86a446645564212043964628f540Ying Wang$(combo_2nd_arch_prefix)HOST_GLOBAL_ARFLAGS := cqs
766feb6d5607ce86a446645564212043964628f540Ying Wang
776feb6d5607ce86a446645564212043964628f540Ying Wang############################################################
786feb6d5607ce86a446645564212043964628f540Ying Wang## Macros after this line are shared by the 64-bit config.
799b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru
809b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste QueruHOST_CUSTOM_LD_COMMAND := true
819b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru
829b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Querudefine transform-host-o-to-shared-lib-inner
833a7e4ccad9c910ac798a8c324f7718d137bd7692Ying Wang$(hide) $(PRIVATE_CXX) \
849b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru        -dynamiclib -single_module -read_only_relocs suppress \
856feb6d5607ce86a446645564212043964628f540Ying Wang        $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \
866feb6d5607ce86a446645564212043964628f540Ying Wang        $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
876feb6d5607ce86a446645564212043964628f540Ying Wang            $(PRIVATE_HOST_GLOBAL_LDFLAGS) \
886feb6d5607ce86a446645564212043964628f540Ying Wang        ) \
899b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru        $(PRIVATE_ALL_OBJECTS) \
90b2680757a07bfd16efae3c8710c69b14807f425fShih-wei Liao        $(addprefix -force_load , $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
9180e6cce93e36787be9123f9b5dc91da1a0d2f472Ying Wang        $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
9280e6cce93e36787be9123f9b5dc91da1a0d2f472Ying Wang        $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
939b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru        $(PRIVATE_LDLIBS) \
949b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru        -o $@ \
955dea692715dfe992432037c6005f91875a725841Ying Wang        -install_name @rpath/$(notdir $@) \
966feb6d5607ce86a446645564212043964628f540Ying Wang        -Wl,-rpath,@loader_path/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
976feb6d5607ce86a446645564212043964628f540Ying Wang        $(PRIVATE_LDFLAGS)
989b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queruendef
999b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru
1009b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Querudefine transform-host-o-to-executable-inner
1013a7e4ccad9c910ac798a8c324f7718d137bd7692Ying Wang$(hide) $(PRIVATE_CXX) \
1026feb6d5607ce86a446645564212043964628f540Ying Wang        -Wl,-rpath,@loader_path/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
1039b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru        -o $@ \
104d318ba66f90272b618e035e996e0a04f02b4481dTim Murray        $(PRE_LION_DYNAMIC_LINKER_OPTIONS) -Wl,-headerpad_max_install_names \
1056feb6d5607ce86a446645564212043964628f540Ying Wang        $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \
1066feb6d5607ce86a446645564212043964628f540Ying Wang        $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
1076feb6d5607ce86a446645564212043964628f540Ying Wang           $(PRIVATE_HOST_GLOBAL_LDFLAGS) \
1086feb6d5607ce86a446645564212043964628f540Ying Wang        ) \
10980e6cce93e36787be9123f9b5dc91da1a0d2f472Ying Wang        $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
1109b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru        $(PRIVATE_ALL_OBJECTS) \
11180e6cce93e36787be9123f9b5dc91da1a0d2f472Ying Wang        $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
11280e6cce93e36787be9123f9b5dc91da1a0d2f472Ying Wang        $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
1139b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru        $(PRIVATE_LDFLAGS) \
1146feb6d5607ce86a446645564212043964628f540Ying Wang        $(PRIVATE_LDLIBS)
1159b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queruendef
1169b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru
1179b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queru# $(1): The file to check
1189b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Querudefine get-file-size
1199b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Querustat -f "%z" $(1)
1209b4a81237be29b0aae50d1e370b63a07ea2b88b9Jean-Baptiste Queruendef
121