Dont use/link ARCMT, StaticAnalyzer and Rewriter to clang when the user
specifies not to. Dont build ASTMatchers with Rewriter disabled and
StaticAnalyzer when it's disabled.

Without all those three, the clang binary shrinks (x86_64) from ~36MB
to ~32MB (unstripped).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170135 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Makefile b/lib/Makefile
index 17db50e..2e32dfe 100755
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -8,9 +8,19 @@
 ##===----------------------------------------------------------------------===##
 CLANG_LEVEL := ..
 
-PARALLEL_DIRS = Headers Basic Lex Parse AST ASTMatchers Sema CodeGen Analysis \
-                StaticAnalyzer Edit Rewrite ARCMigrate Serialization Frontend \
-                FrontendTool Tooling Driver Format
+# ARCMigrate and Rewrite are always needed because of libclang.
+PARALLEL_DIRS = Headers Basic Lex Parse AST Sema CodeGen Analysis Frontend \
+                FrontendTool Tooling Driver Format Edit ARCMigrate Rewrite \
+                Serialization
+
+include $(CLANG_LEVEL)/../../Makefile.config
+
+ifeq ($(ENABLE_CLANG_REWRITER),1)
+PARALLEL_DIRS += ASTMatchers
+endif
+
+ifeq ($(ENABLE_CLANG_STATIC_ANALYZER),1)
+PARALLEL_DIRS += StaticAnalyzer
+endif
 
 include $(CLANG_LEVEL)/Makefile
-