+
+ifndef SDKROOT
+ SDKPATH:=/
+else ifeq "$(SDKROOT)" ""
+ SDKPATH:=/
+else
+ SDKPATH:=$(shell xcodebuild -version -sdk $(SDKROOT) Path)
+ ifeq "$(SDKPATH)" ""
+ SDKPATH:=/
+ endif
+endif
+$(info # SDKROOT=$(SDKROOT))
+$(info # SDKPATH=$(SDKPATH))
+
+# An Apple submission version (passed in RC_ProjectSourceVersion for official builds) is
+# X[.Y[.Z]]
+# where X is in range 0-214747, Y and Z are in range 0-99 (with no leading zeros).
+# This corresponds to MMmAA.(0 | B).T where
+# MM is U_ICU_VERSION_MAJOR_NUM
+# m is U_ICU_VERSION_MINOR_NUM
+# AA is the Apple delta version
+# B is the Apple branch version (1 or 2 digits)
+# T is the Apple train code for submissions.
+# Note The value for the SourceVersion property in version.plists will be calculated as
+# (X*10000 + Y*100 + Z).
+# We want ICU_BUILD = 100*AA + B.
+#
+ifneq "$(RC_ProjectSourceVersion)" ""
+ ifeq "$(WINDOWS)" "YES"
+ ICU_BUILD_AA := $(shell echo $(RC_ProjectSourceVersion) | sed -r -e 's/([0-9]+)([0-9]{2})(\.([0-9])([0-9])?(\.([0-9]{1,2}))?)?/\2/')
+ ICU_BUILD_B1 := $(shell echo $(RC_ProjectSourceVersion) | sed -r -e 's/([0-9]+)([0-9]{2})(\.([0-9])([0-9])?(\.([0-9]{1,2}))?)?/\4/')
+ ICU_BUILD_B2 := $(shell echo $(RC_ProjectSourceVersion) | sed -r -e 's/([0-9]+)([0-9]{2})(\.([0-9])([0-9])?(\.([0-9]{1,2}))?)?/\5/')
+ ICU_TRAIN_CODE := $(shell echo $(RC_ProjectSourceVersion) | sed -r -e 's/([0-9]+)([0-9]{2})(\.([0-9])([0-9])?(\.([0-9]{1,2}))?)?/\7/')
+ else
+ ICU_BUILD_AA := $(shell echo $(RC_ProjectSourceVersion) | sed -E -e 's/([0-9]+)([0-9]{2})(\.([0-9])([0-9])?(\.([0-9]{1,2}))?)?/\2/')
+ ICU_BUILD_B1 := $(shell echo $(RC_ProjectSourceVersion) | sed -E -e 's/([0-9]+)([0-9]{2})(\.([0-9])([0-9])?(\.([0-9]{1,2}))?)?/\4/')
+ ICU_BUILD_B2 := $(shell echo $(RC_ProjectSourceVersion) | sed -E -e 's/([0-9]+)([0-9]{2})(\.([0-9])([0-9])?(\.([0-9]{1,2}))?)?/\5/')
+ ICU_TRAIN_CODE := $(shell echo $(RC_ProjectSourceVersion) | sed -E -e 's/([0-9]+)([0-9]{2})(\.([0-9])([0-9])?(\.([0-9]{1,2}))?)?/\7/')
+ endif
+ ifeq "$(ICU_BUILD_AA)" ""
+ ICU_BUILD := 0
+ else
+ ICU_BUILD := $(subst a,$(ICU_BUILD_AA),abc)
+ ifeq "$(ICU_BUILD_B1)" ""
+ ICU_BUILD := $(subst b,0,$(ICU_BUILD))
+ ICU_BUILD := $(subst c,0,$(ICU_BUILD))
+ else
+ ifeq "$(ICU_BUILD_B2)" ""
+ ICU_BUILD := $(subst b,0,$(ICU_BUILD))
+ ICU_BUILD := $(subst c,$(ICU_BUILD_B1),$(ICU_BUILD))
+ else
+ ICU_BUILD := $(subst b,$(ICU_BUILD_B1),$(ICU_BUILD))
+ ICU_BUILD := $(subst c,$(ICU_BUILD_B2),$(ICU_BUILD))
+ endif
+ endif
+ endif
+ ifeq "$(ICU_TRAIN_CODE)" ""
+ ICU_TRAIN_CODE := 0
+ endif
+else
+ ICU_BUILD := 0
+ ICU_TRAIN_CODE := 0
+endif
+$(info # ICU_BUILD=$(ICU_BUILD))
+$(info # ICU_TRAIN_CODE=$(ICU_TRAIN_CODE))
+ifeq "$(ICU_BUILD)" "0"
+ DEFINE_BUILD_LEVEL =
+else
+ DEFINE_BUILD_LEVEL =-DU_ICU_VERSION_BUILDLEVEL_NUM=$(ICU_BUILD)
+endif
+
+# Determine build type. In some cases (e.g. running installsrc for submitproject)
+# the only accurate information we may have about build type is from ICU_TRAIN_CODE,
+# so give priority to that if nonzero.
+# The values currently defined for ICU_TRAIN_CODE and corresponding ICU_BUILD_TYPE are
+# 1 OSX trains
+# 2 embedded trains (iOS, tvos, watchos) including simulator versions thereof.
+# may have BUILD_TYPE=DEVICE,SIMULATOR,TOOL
+# 8 AAS for Windows
+# 9 linux for Siri servers
+#
+ifeq "$(WINDOWS)" "YES"
+ ICU_FOR_APPLE_PLATFORMS:=NO
+else ifeq "$(ICU_TRAIN_CODE)" "8"
+ override WINDOWS=YES
+ ICU_FOR_APPLE_PLATFORMS:=NO
+else ifeq "$(LINUX)" "YES"
+ ICU_FOR_APPLE_PLATFORMS:=NO
+else ifeq "$(ICU_TRAIN_CODE)" "9"
+ override LINUX=YES
+ ICU_FOR_APPLE_PLATFORMS:=NO
+else
+ ICU_FOR_APPLE_PLATFORMS:=YES
+endif
+
+# For Apple builds, get more details from the SDK if available
+# In TargetConditionals.h:
+# TARGET_OS_IPHONE -is 1 iff generating code for firmware, devices, or simulator (all embedded trains)
+# in that case:
+# exactly one of the following is 1: TARGET_OS_SIMULATOR, TARGET_OS_EMBEDDED (i.e. device)
+# exactly one of the following is 1: TARGET_OS_IOS, TARGET_OS_TV, TARGET_OS_WATCH, TARGET_OS_BRIDGE
+#
+ifeq "$(ICU_FOR_APPLE_PLATFORMS)" "YES"
+ HOSTCC := $(shell xcrun --sdk macosx --find cc)
+ HOSTCXX := $(shell xcrun --sdk macosx --find c++)
+ HOSTSDKPATH := $(shell xcrun --sdk macosx --show-sdk-path)
+ HOSTISYSROOT = -isysroot $(HOSTSDKPATH)
+ ifeq "$(SDKPATH)" "/"
+ ISYSROOT:= -isysroot $(HOSTSDKPATH)
+ CC := $(HOSTCC)
+ CXX := $(HOSTCXX)
+ NM := $(shell xcrun --sdk macosx --find nm)
+ STRIPCMD := $(shell xcrun --sdk macosx --find strip)
+ ifeq "$(ICU_TRAIN_CODE)" "2"
+ export ICU_FOR_EMBEDDED_TRAINS:=YES
+ else
+ export ICU_FOR_EMBEDDED_TRAINS:=NO
+ endif
+ else
+ ISYSROOT:= -isysroot $(SDKPATH)
+ CC := $(shell xcrun --sdk $(SDKPATH) --find cc)
+ CXX := $(shell xcrun --sdk $(SDKPATH) --find c++)
+ NM := $(shell xcrun --sdk $(SDKPATH) --find nm)
+ STRIPCMD := $(shell xcrun --sdk $(SDKPATH) --find strip)
+ EMBEDDEDTRAIN:=$(shell $(CXX) -E -dM -x c $(ISYSROOT) -include TargetConditionals.h /dev/null | fgrep define' 'TARGET_OS_IPHONE | cut -d' ' -f3)
+ ifeq "$(EMBEDDEDTRAIN)" "1"
+ export ICU_FOR_EMBEDDED_TRAINS:=YES
+ else
+ export ICU_FOR_EMBEDDED_TRAINS:=NO
+ endif
+ endif
+ SIMULATOROS:=$(shell $(CXX) -E -dM -x c $(ISYSROOT) -include TargetConditionals.h /dev/null | fgrep define' 'TARGET_OS_SIMULATOR | cut -d' ' -f3)
+ TVOS:=$(shell $(CXX) -E -dM -x c $(ISYSROOT) -include TargetConditionals.h /dev/null | fgrep define' 'TARGET_OS_TV | cut -d' ' -f3)
+ WATCHOS:=$(shell $(CXX) -E -dM -x c $(ISYSROOT) -include TargetConditionals.h /dev/null | fgrep define' 'TARGET_OS_WATCH | cut -d' ' -f3)
+ BRIDGEOS:=$(shell $(CXX) -E -dM -x c $(ISYSROOT) -include TargetConditionals.h /dev/null | fgrep define' 'TARGET_OS_BRIDGE | cut -d' ' -f3)
+ ifeq "$(ICU_FOR_EMBEDDED_TRAINS)" "YES"
+ ifeq "$(SIMULATOROS)" "1"
+ BUILD_TYPE=SIMULATOR
+ else
+ BUILD_TYPE=DEVICE
+ endif
+ else ifeq "$(RC_ProjectName)" "tzTools"
+ BUILD_TYPE=TOOL
+ else
+ BUILD_TYPE=
+ endif
+else
+ ifeq "$(LINUX)" "YES"
+ ISYSROOT:=
+ CC := gcc
+ CXX := g++
+ endif
+ export ICU_FOR_EMBEDDED_TRAINS:=NO
+ TVOS:=0
+ WATCHOS:=0
+ BRIDGEOS:=0
+ BUILD_TYPE=
+endif
+
+CROSS_BUILD:=$(ICU_FOR_EMBEDDED_TRAINS)