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