1CLANG_LEVEL := ../../..
2BUILT_SOURCES = \
3	DiagnosticAnalysisKinds.inc DiagnosticASTKinds.inc \
4	DiagnosticCommentKinds.inc \
5	DiagnosticCommonKinds.inc DiagnosticDriverKinds.inc \
6	DiagnosticFrontendKinds.inc DiagnosticLexKinds.inc \
7	DiagnosticParseKinds.inc DiagnosticSemaKinds.inc \
8	DiagnosticSerializationKinds.inc \
9	DiagnosticIndexName.inc DiagnosticGroups.inc AttrList.inc arm_neon.inc \
10	Version.inc
11
12TABLEGEN_INC_FILES_COMMON = 1
13
14include $(CLANG_LEVEL)/Makefile
15
16INPUT_TDS = $(wildcard $(PROJ_SRC_DIR)/Diagnostic*.td)
17
18# Compute the Clang version from the LLVM version, unless specified explicitly.
19ifndef CLANG_VERSION
20CLANG_VERSION := $(subst svn,,$(LLVMVersion))
21CLANG_VERSION := $(subst rc,,$(CLANG_VERSION))
22endif
23
24CLANG_VERSION_COMPONENTS := $(subst ., ,$(CLANG_VERSION))
25CLANG_VERSION_MAJOR := $(word 1,$(CLANG_VERSION_COMPONENTS))
26CLANG_VERSION_MINOR := $(word 2,$(CLANG_VERSION_COMPONENTS))
27CLANG_VERSION_PATCHLEVEL := $(word 3,$(CLANG_VERSION_COMPONENTS))
28ifeq ($(CLANG_VERSION_PATCHLEVEL),)
29CLANG_HAS_VERSION_PATCHLEVEL := 0
30else
31CLANG_HAS_VERSION_PATCHLEVEL := 1
32endif
33
34$(ObjDir)/Diagnostic%Kinds.inc.tmp : Diagnostic.td $(INPUT_TDS) $(CLANG_TBLGEN) $(ObjDir)/.dir
35	$(Echo) "Building Clang $(patsubst Diagnostic%Kinds.inc.tmp,%,$(@F)) diagnostic tables with tblgen"
36	$(Verb) $(ClangTableGen) -gen-clang-diags-defs -clang-component=$(patsubst Diagnostic%Kinds.inc.tmp,%,$(@F)) -o $(call SYSPATH, $@) $<
37
38$(ObjDir)/DiagnosticIndexName.inc.tmp : Diagnostic.td $(INPUT_TDS) $(CLANG_TBLGEN) $(ObjDir)/.dir
39	$(Echo) "Building Clang diagnostic name index with tblgen"
40	$(Verb) $(ClangTableGen) -gen-clang-diags-index-name -o $(call SYSPATH, $@) $<
41
42$(ObjDir)/DiagnosticGroups.inc.tmp : Diagnostic.td DiagnosticGroups.td $(INPUT_TDS) $(CLANG_TBLGEN) $(ObjDir)/.dir
43	$(Echo) "Building Clang diagnostic groups with tblgen"
44	$(Verb) $(ClangTableGen) -gen-clang-diag-groups -o $(call SYSPATH, $@) $<
45
46$(ObjDir)/AttrList.inc.tmp : Attr.td $(CLANG_TBLGEN) $(ObjDir)/.dir
47	$(Echo) "Building Clang attribute list with tblgen"
48	$(Verb) $(ClangTableGen) -gen-clang-attr-list -o $(call SYSPATH, $@) \
49	  -I $(PROJ_SRC_DIR)/../.. $<
50
51$(ObjDir)/arm_neon.inc.tmp : arm_neon.td $(CLANG_TBLGEN) $(ObjDir)/.dir
52	$(Echo) "Building Clang arm_neon.inc with tblgen"
53	$(Verb) $(ClangTableGen) -gen-arm-neon-sema -o $(call SYSPATH, $@) $<
54
55$(ObjDir)/Version.inc.tmp : Version.inc.in Makefile $(LLVM_OBJ_ROOT)/Makefile.config $(ObjDir)/.dir
56	$(Echo) "Updating Clang version info."
57	$(Verb)sed -e "s#@CLANG_VERSION@#$(CLANG_VERSION)#g" \
58	           -e "s#@CLANG_VERSION_MAJOR@#$(CLANG_VERSION_MAJOR)#g" \
59	           -e "s#@CLANG_VERSION_MINOR@#$(CLANG_VERSION_MINOR)#g" \
60	           -e "s#@CLANG_VERSION_PATCHLEVEL@#$(CLANG_VERSION_PATCHLEVEL)#g" \
61	           -e "s#@CLANG_HAS_VERSION_PATCHLEVEL@#$(CLANG_HAS_VERSION_PATCHLEVEL)#g" \
62	           $< > $@
63