+# 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
+#
+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)
+ 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
+ BUILD_TYPE=
+endif
+
+CROSS_BUILD:=$(ICU_FOR_EMBEDDED_TRAINS)
+CROSSHOST_OBJROOT=$(OBJROOT)/crossbuildhost
+
+$(info # ICU_FOR_APPLE_PLATFORMS=$(ICU_FOR_APPLE_PLATFORMS))
+$(info # HOSTCC=$(HOSTCC))
+$(info # HOSTCXX=$(HOSTCXX))
+$(info # HOSTISYSROOT=$(HOSTISYSROOT))
+$(info # CC=$(CC))
+$(info # CXX=$(CXX))
+$(info # ISYSROOT=$(ISYSROOT))
+$(info # ICU_FOR_EMBEDDED_TRAINS=$(ICU_FOR_EMBEDDED_TRAINS))
+$(info # CROSS_BUILD=$(CROSS_BUILD))
+$(info # BUILD_TYPE=$(BUILD_TYPE))
+
+# Disallow cross builds on Windows/Linux for now
+# (since those builds are not out-of-source as required for cross-builds)
+ifeq "$(CROSS_BUILD)" "YES"
+ifeq "$(WINDOWS)" "YES"
+$(error Cross-builds currently not allowed on Windows)
+endif
+ifeq "$(LINUX)" "YES"
+$(error Cross-builds currently not allowed on Linux)
+endif
+endif
+
+MAC_OS_X_VERSION_MIN_REQUIRED=101000
+OSX_HOST_VERSION_MIN_STRING=10.10
+
+ifndef IPHONEOS_DEPLOYMENT_TARGET
+ IOS_VERSION_TARGET_STRING=10.0
+else ifeq "$(IPHONEOS_DEPLOYMENT_TARGET)" ""
+ IOS_VERSION_TARGET_STRING=10.0
+else
+ IOS_VERSION_TARGET_STRING=$(IPHONEOS_DEPLOYMENT_TARGET)
+endif
+
+ifndef MACOSX_DEPLOYMENT_TARGET
+ OSX_VERSION_TARGET_STRING=10.12
+else ifeq "$(MACOSX_DEPLOYMENT_TARGET)" ""
+ OSX_VERSION_TARGET_STRING=10.12
+else
+ OSX_VERSION_TARGET_STRING=$(MACOSX_DEPLOYMENT_TARGET)
+endif
+
+ifndef WATCHOS_DEPLOYMENT_TARGET
+ WATCHOS_VERSION_TARGET_STRING=3.0
+else ifeq "$(WATCHOS_DEPLOYMENT_TARGET)" ""
+ WATCHOS_VERSION_TARGET_STRING=3.0
+else
+ WATCHOS_VERSION_TARGET_STRING=$(WATCHOS_DEPLOYMENT_TARGET)
+endif
+
+ifndef TVOS_DEPLOYMENT_TARGET
+ TVOS_VERSION_TARGET_STRING=10.0
+else ifeq "$(TVOS_DEPLOYMENT_TARGET)" ""
+ TVOS_VERSION_TARGET_STRING=10.0
+else
+ TVOS_VERSION_TARGET_STRING=$(TVOS_DEPLOYMENT_TARGET)
+endif
+
+$(info # IOS_VERSION_TARGET_STRING=$(IOS_VERSION_TARGET_STRING))
+$(info # OSX_VERSION_TARGET_STRING=$(OSX_VERSION_TARGET_STRING))
+$(info # WATCHOS_VERSION_TARGET_STRING=$(WATCHOS_VERSION_TARGET_STRING))
+$(info # TVOS_VERSION_TARGET_STRING=$(TVOS_VERSION_TARGET_STRING))
+
+ifeq "$(BUILD_TYPE)" "DEVICE"
+ ifeq "$(WATCHOS)" "1"
+ ICU_TARGET_VERSION := -mwatchos-version-min=$(WATCHOS_VERSION_TARGET_STRING)
+ else ifeq "$(TVOS)" "1"
+ ICU_TARGET_VERSION := -mtvos-version-min=$(TVOS_VERSION_TARGET_STRING)
+ else
+ ICU_TARGET_VERSION := -miphoneos-version-min=$(IOS_VERSION_TARGET_STRING)
+ endif
+else ifeq "$(BUILD_TYPE)" "SIMULATOR"
+ ifeq "$(WATCHOS)" "1"
+ ICU_TARGET_VERSION := -mwatchos-simulator-version-min=$(WATCHOS_VERSION_TARGET_STRING)
+ else ifeq "$(TVOS)" "1"
+ ICU_TARGET_VERSION := -mtvos-simulator-version-min=$(TVOS_VERSION_TARGET_STRING)
+ else
+ ICU_TARGET_VERSION := -mios-simulator-version-min=$(IOS_VERSION_TARGET_STRING)
+ endif
+else
+ ICU_TARGET_VERSION :=
+endif
+$(info # ICU_TARGET_VERSION=$(ICU_TARGET_VERSION))
+
+
+DISABLE_DRAFT:=$(ICU_FOR_EMBEDDED_TRAINS)
+ifeq "$(DISABLE_DRAFT)" "YES"
+ DRAFT_FLAG=--disable-draft
+else
+ DRAFT_FLAG=
+endif
+
+# For some reason, under cygwin, bash uname is not found, and
+# sh uname does not produce a result with -p or -m. So we just
+# hardcode here.
+ifeq "$(WINDOWS)" "YES"
+ UNAME_PROCESSOR:=i386
+else
+ UNAME_PROCESSOR:=$(shell uname -p)
+endif
+
+ifneq "$(RC_ARCHS)" ""
+ INSTALLHDRS_ARCH=-arch $(shell echo $(RC_ARCHS) | cut -d' ' -f1)
+else
+ INSTALLHDRS_ARCH=
+endif
+$(info # INSTALLHDRS_ARCH=$(INSTALLHDRS_ARCH))
+$(info # buildhost=$(UNAME_PROCESSOR))
+
+
+# FORCEENDIAN below is to override silly configure behavior in which if
+# __APPLE_CC__ is defined and archs are in { ppc, ppc64, i386, x86_64 }
+# then it assumes a universal build (ac_cv_c_bigendian=universal) with
+# data file initially built big-endian.
+#
+ifeq "$(CROSS_BUILD)" "YES"
+ RC_ARCHS_FIRST=$(shell echo $(RC_ARCHS) | cut -d' ' -f1)
+ TARGET_SPEC=$(RC_ARCHS_FIRST)-apple-darwin15.0.0
+ ENV_CONFIGURE_ARCHS=-arch $(RC_ARCHS_FIRST)
+ ICUPKGTOOLIBS="$(CROSSHOST_OBJROOT)/lib:$(CROSSHOST_OBJROOT)/stubdata"
+ ICUPKGTOOL=$(CROSSHOST_OBJROOT)/bin/icupkg
+ ifeq "$(filter-out i386 x86_64,$(RC_ARCHS))" ""
+ FORCEENDIAN= ac_cv_c_bigendian=no
+ else
+ FORCEENDIAN=
+ endif
+else ifeq "$(LINUX)" "YES"
+ TARGET_SPEC=$(UNAME_PROCESSOR)-unknown-linux-gnu
+ ENV_CONFIGURE_ARCHS=
+ ICUPKGTOOLIBS="$(OBJROOT_CURRENT)/lib:$(OBJROOT_CURRENT)/stubdata"
+ ICUPKGTOOL=$(OBJROOT_CURRENT)/bin/icupkg
+ FORCEENDIAN=
+else
+ TARGET_SPEC=$(UNAME_PROCESSOR)-apple-darwin15.0.0
+ ENV_CONFIGURE_ARCHS=
+ ICUPKGTOOLIBS="$(OBJROOT_CURRENT)/lib:$(OBJROOT_CURRENT)/stubdata"
+ ICUPKGTOOL=$(OBJROOT_CURRENT)/bin/icupkg
+ FORCEENDIAN=
+endif
+$(info # TARGET_SPEC=$(TARGET_SPEC))
+$(info # ENV_CONFIGURE_ARCHS=$(ENV_CONFIGURE_ARCHS))
+
+ICU_TARGET_VERSION_FOR_TZ_EXTRA :=
+ifeq "$(BUILD_TYPE)" "SIMULATOR"
+ ICU_TARGET_VERSION_FOR_TZ_EXTRA := -mmacosx-version-min=$(OSX_HOST_VERSION_MIN_STRING)
+endif
+
+ifeq "$(BUILD_TYPE)" "DEVICE"
+ THUMB_FLAG = -mthumb
+else
+ THUMB_FLAG =