1# Detect Mac OS X and SDK versions. 2# Output variables: 3# build_mac_version 4# mac_sdk_version 5# mac_sdk_root 6# gcc_darwin_version 7 8ifndef build_mac_version 9 10build_mac_version := $(shell sw_vers -productVersion) 11 12mac_sdk_versions_supported := 10.6 10.7 10.8 10.9 13ifneq ($(strip $(MAC_SDK_VERSION)),) 14mac_sdk_version := $(MAC_SDK_VERSION) 15ifeq ($(filter $(mac_sdk_version),$(mac_sdk_versions_supported)),) 16$(warning ****************************************************************) 17$(warning * MAC_SDK_VERSION $(MAC_SDK_VERSION) isn't one of the supported $(mac_sdk_versions_supported)) 18$(warning ****************************************************************) 19$(error Stop.) 20endif 21else 22mac_sdk_versions_installed := $(shell xcodebuild -showsdks | grep macosx | sort | sed -e "s/.*macosx//g") 23mac_sdk_version := $(firstword $(filter $(mac_sdk_versions_installed), $(mac_sdk_versions_supported))) 24ifeq ($(mac_sdk_version),) 25mac_sdk_version := $(firstword $(mac_sdk_versions_supported)) 26endif 27endif 28 29mac_sdk_path := $(shell xcode-select -print-path) 30# try /Applications/Xcode*.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.?.sdk 31# or /Volume/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.?.sdk 32mac_sdk_root := $(mac_sdk_path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(mac_sdk_version).sdk 33ifeq ($(wildcard $(mac_sdk_root)),) 34# try legacy /Developer/SDKs/MacOSX10.?.sdk 35mac_sdk_root := /Developer/SDKs/MacOSX$(mac_sdk_version).sdk 36endif 37ifeq ($(wildcard $(mac_sdk_root)),) 38$(warning *****************************************************) 39$(warning * Can not find SDK $(mac_sdk_version) at $(mac_sdk_root)) 40$(warning *****************************************************) 41$(error Stop.) 42endif 43 44ifeq ($(mac_sdk_version),10.6) 45 gcc_darwin_version := 10 46else 47 gcc_darwin_version := 11 48endif 49 50endif # ifndef build_mac_version 51