+
+ifeq ($(MAKECMDGOALS),libs-only)
+ DIRS := $(filter-out tools runtime docs, $(DIRS))
+ OPTIONAL_DIRS :=
+endif
+
+ifeq ($(MAKECMDGOALS),install-libs)
+ DIRS := $(filter-out tools runtime docs, $(DIRS))
+ OPTIONAL_DIRS := $(filter bindings, $(OPTIONAL_DIRS))
+endif
+
+ifeq ($(MAKECMDGOALS),tools-only)
+ DIRS := $(filter-out runtime docs, $(DIRS))
+ OPTIONAL_DIRS :=
+endif
+
+ifeq ($(MAKECMDGOALS),install-clang)
+ DIRS := tools/clang/tools/driver tools/clang/lib/Headers \
+ tools/clang/lib/Runtime tools/clang/docs
+ OPTIONAL_DIRS :=
+ NO_INSTALL = 1
+endif
+
+ifeq ($(MAKECMDGOALS),install-clang-c)
+ DIRS := tools/clang/tools/driver tools/clang/lib/Headers \
+ tools/clang/tools/libclang tools/clang/tools/c-index-test \
+ tools/clang/include/clang-c
+ OPTIONAL_DIRS :=
+ NO_INSTALL = 1
+endif
+
+ifeq ($(MAKECMDGOALS),clang-only)
+ DIRS := $(filter-out tools runtime docs unittests, $(DIRS)) tools/clang
+ OPTIONAL_DIRS :=
+endif
+
+ifeq ($(MAKECMDGOALS),unittests)
+ DIRS := $(filter-out tools runtime docs, $(DIRS)) utils unittests
+ OPTIONAL_DIRS :=
+endif
+
+# Use NO_INSTALL define of the Makefile of each directory for deciding
+# if the directory is installed or not
+ifeq ($(MAKECMDGOALS),install)
+ OPTIONAL_DIRS := $(filter bindings, $(OPTIONAL_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 ; \
+ $(PROJ_SRC_DIR)/configure --build=$(BUILD_TRIPLE) \
+ --host=$(BUILD_TRIPLE) --target=$(BUILD_TRIPLE); \
+ cd .. ; \
+ fi; \
+ ($(MAKE) -C BuildTools \
+ BUILD_DIRS_ONLY=1 \
+ UNIVERSAL= \
+ ENABLE_OPTIMIZED=$(ENABLE_OPTIMIZED) \
+ ENABLE_PROFILING=$(ENABLE_PROFILING) \
+ ENABLE_COVERAGE=$(ENABLE_COVERAGE) \
+ DISABLE_ASSERTIONS=$(DISABLE_ASSERTIONS) \
+ ENABLE_EXPENSIVE_CHECKS=$(ENABLE_EXPENSIVE_CHECKS) \
+ CFLAGS= \
+ CXXFLAGS= \
+ ) || exit 1;
+endif
+
+# Include the main makefile machinery.
+include $(LLVM_SRC_ROOT)/Makefile.rules