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