Home | History | Annotate | Download | only in combo
      1 #
      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 
     20 ifneq ($(strip $(BUILD_HOST_64bit)),)
     21 # By default we build everything in 32-bit, because it gives us
     22 # more consistency between the host tools and the target.
     23 # BUILD_HOST_64bit=1 overrides it for tool like emulator
     24 # which can benefit from 64-bit host arch.
     25 HOST_GLOBAL_CFLAGS += -m64
     26 HOST_GLOBAL_LDFLAGS += -m64
     27 else
     28 HOST_GLOBAL_CFLAGS += -m32
     29 HOST_GLOBAL_LDFLAGS += -m32
     30 endif # BUILD_HOST_64bit
     31 
     32 ifneq ($(strip $(BUILD_HOST_static)),)
     33 # Statically-linked binaries are desirable for sandboxed environment
     34 HOST_GLOBAL_LDFLAGS += -static
     35 endif # BUILD_HOST_static
     36 
     37 build_mac_version := $(shell sw_vers -productVersion)
     38 
     39 ifneq ($(strip $(BUILD_MAC_SDK_EXPERIMENTAL)),)
     40 # SDK 10.7 and higher is not fully compatible with Android.
     41 mac_sdk_versions_supported :=  10.7 10.8
     42 else
     43 mac_sdk_versions_supported :=  10.6
     44 endif # BUILD_MAC_SDK_EXPERIMENTAL
     45 mac_sdk_versions_installed := $(shell xcodebuild -showsdks |grep macosx | sort | sed -e "s/.*macosx//g")
     46 mac_sdk_version := $(firstword $(filter $(mac_sdk_versions_installed), $(mac_sdk_versions_supported)))
     47 ifeq ($(mac_sdk_version),)
     48 mac_sdk_version := $(firstword $(mac_sdk_versions_supported))
     49 endif
     50 
     51 mac_sdk_path := $(shell xcode-select -print-path)
     52 ifeq ($(findstring /Applications,$(mac_sdk_path)),)
     53 # Legacy Xcode
     54 mac_sdk_root := /Developer/SDKs/MacOSX$(mac_sdk_version).sdk
     55 else
     56 #  Xcode 4.4(App Store) or higher
     57 # /Applications/Xcode*.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.?.sdk
     58 mac_sdk_root := $(mac_sdk_path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(mac_sdk_version).sdk
     59 endif
     60 
     61 ifeq ($(wildcard $(mac_sdk_root)),)
     62 $(warning *****************************************************)
     63 $(warning * Cannot find SDK $(mac_sdk_version) at $(mac_sdk_root))
     64 ifeq ($(strip $(BUILD_MAC_SDK_EXPERIMENTAL)),)
     65 $(warning * If you wish to build using higher version of SDK, )
     66 $(warning * try setting BUILD_MAC_SDK_EXPERIMENTAL=1 before )
     67 $(warning * rerunning this command )
     68 endif
     69 $(warning *****************************************************)
     70 $(error Stop.)
     71 endif
     72 
     73 HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) -DMACOSX_DEPLOYMENT_TARGET=$(mac_sdk_version)
     74 HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -Wl,-syslibroot,$(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)
     75 
     76 HOST_GLOBAL_CFLAGS += -fPIC -funwind-tables
     77 HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error
     78 
     79 HOST_CC := gcc
     80 HOST_CXX := g++
     81 HOST_AR := $(AR)
     82 HOST_STRIP := $(STRIP)
     83 HOST_STRIP_COMMAND = $(HOST_STRIP) --strip-debug $< -o $@
     84 
     85 HOST_SHLIB_SUFFIX := .dylib
     86 HOST_JNILIB_SUFFIX := .jnilib
     87 
     88 HOST_GLOBAL_CFLAGS += \
     89     -include $(call select-android-config-h,darwin-x86)
     90 
     91 ifneq ($(filter 10.7 10.7.% 10.8 10.8.%, $(build_mac_version)),)
     92        HOST_RUN_RANLIB_AFTER_COPYING := false
     93 else
     94        HOST_RUN_RANLIB_AFTER_COPYING := true
     95        PRE_LION_DYNAMIC_LINKER_OPTIONS := -Wl,-dynamic
     96 endif
     97 HOST_GLOBAL_ARFLAGS := cqs
     98 
     99 HOST_CUSTOM_LD_COMMAND := true
    100 
    101 define transform-host-o-to-shared-lib-inner
    102 $(hide) $(PRIVATE_CXX) \
    103         -dynamiclib -single_module -read_only_relocs suppress \
    104         $(HOST_GLOBAL_LD_DIRS) \
    105         $(HOST_GLOBAL_LDFLAGS) \
    106         $(PRIVATE_ALL_OBJECTS) \
    107         $(addprefix -force_load , $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
    108         $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
    109         $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
    110         $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
    111         $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
    112         $(PRIVATE_LDLIBS) \
    113         -o $@ \
    114         -install_name @rpath/$(notdir $@) \
    115         -Wl,-rpath,@loader_path/../lib \
    116         $(PRIVATE_LDFLAGS) \
    117         $(HOST_LIBGCC)
    118 endef
    119 
    120 define transform-host-o-to-executable-inner
    121 $(hide) $(PRIVATE_CXX) \
    122         -Wl,-rpath,@loader_path/../lib \
    123         -o $@ \
    124         $(PRE_LION_DYNAMIC_LINKER_OPTIONS) -headerpad_max_install_names \
    125         $(HOST_GLOBAL_LD_DIRS) \
    126         $(HOST_GLOBAL_LDFLAGS) \
    127         $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
    128         $(PRIVATE_ALL_OBJECTS) \
    129         $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
    130         $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
    131         $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
    132         $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
    133         $(PRIVATE_LDFLAGS) \
    134         $(PRIVATE_LDLIBS) \
    135         $(HOST_LIBGCC)
    136 endef
    137 
    138 # $(1): The file to check
    139 define get-file-size
    140 stat -f "%z" $(1)
    141 endef
    142