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 8 ifndef build_mac_version 9 10 build_mac_version := $(shell sw_vers -productVersion) 11 12 mac_sdk_versions_supported := 10.8 10.9 10.10 10.11 13 ifneq ($(strip $(MAC_SDK_VERSION)),) 14 mac_sdk_version := $(MAC_SDK_VERSION) 15 ifeq ($(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.) 20 endif 21 else 22 mac_sdk_versions_installed := $(shell xcodebuild -showsdks | grep macosx | sed -e "s/.*macosx//g") 23 mac_sdk_version := $(firstword $(filter $(mac_sdk_versions_installed), $(mac_sdk_versions_supported))) 24 ifeq ($(mac_sdk_version),) 25 mac_sdk_version := $(firstword $(mac_sdk_versions_supported)) 26 $(warning none of the installed SDKs ($mac_sdk_versions_installed) match supported versions ($(mac_sdk_versions_supported)), trying $(mac_sdk_version)) 27 endif 28 endif 29 30 mac_sdk_path := $(shell xcode-select -print-path) 31 # try /Applications/Xcode*.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.?.sdk 32 # or /Volume/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.?.sdk 33 mac_sdk_root := $(mac_sdk_path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(mac_sdk_version).sdk 34 ifeq ($(wildcard $(mac_sdk_root)),) 35 # try legacy /Developer/SDKs/MacOSX10.?.sdk 36 $(warning no SDK $(mac_sdk_version) at $(mac_sdk_root), trying legacy dir) 37 mac_sdk_root := /Developer/SDKs/MacOSX$(mac_sdk_version).sdk 38 endif 39 ifeq ($(wildcard $(mac_sdk_root)),) 40 $(warning *****************************************************) 41 $(warning * Can not find SDK $(mac_sdk_version) at $(mac_sdk_root)) 42 $(warning *****************************************************) 43 $(error Stop.) 44 endif 45 46 ifeq ($(mac_sdk_version),10.6) 47 gcc_darwin_version := 10 48 else 49 gcc_darwin_version := 11 50 endif 51 52 endif # ifndef build_mac_version 53