+# Don't build unittests when ONLY_TOOLS is set.
+ifneq ($(ONLY_TOOLS),)
+ DIRS := $(filter-out unittests, $(DIRS))
+endif
+
+# If we're cross-compiling, build the build-hosted tools first
+ifeq ($(LLVM_CROSS_COMPILING),1)
+all:: cross-compile-build-tools
+
+clean::
+ $(Verb) rm -rf BuildTools
+
+cross-compile-build-tools:
+ $(Verb) if [ ! -f BuildTools/Makefile ]; then \
+ $(MKDIR) BuildTools; \
+ cd BuildTools ; \
+ unset CFLAGS ; \
+ unset CXXFLAGS ; \
+ unset SDKROOT ; \
+ unset UNIVERSAL_SDK_PATH ; \
+ $(PROJ_SRC_DIR)/configure --build=$(BUILD_TRIPLE) \
+ --host=$(BUILD_TRIPLE) --target=$(BUILD_TRIPLE) \
+ --disable-polly ; \
+ cd .. ; \
+ fi; \
+ ($(MAKE) -C BuildTools \
+ BUILD_DIRS_ONLY=1 \
+ UNIVERSAL= \
+ UNIVERSAL_SDK_PATH= \
+ SDKROOT= \
+ TARGET_NATIVE_ARCH="$(TARGET_NATIVE_ARCH)" \
+ TARGETS_TO_BUILD="$(TARGETS_TO_BUILD)" \
+ ENABLE_OPTIMIZED=$(ENABLE_OPTIMIZED) \
+ ENABLE_PROFILING=$(ENABLE_PROFILING) \
+ ENABLE_COVERAGE=$(ENABLE_COVERAGE) \
+ DISABLE_ASSERTIONS=$(DISABLE_ASSERTIONS) \
+ ENABLE_EXPENSIVE_CHECKS=$(ENABLE_EXPENSIVE_CHECKS) \
+ ENABLE_LIBCPP=$(ENABLE_LIBCPP) \
+ CFLAGS= \
+ CXXFLAGS= \
+ ) || exit 1;
+endif
+