xref: /freebsd/lib/clang/clang.build.mk (revision 545ddfbe7d4fe8adfb862903b24eac1d5896c1ef)
1# $FreeBSD$
2
3.include <src.opts.mk>
4
5CLANG_SRCS=	${LLVM_SRCS}/tools/clang
6
7CFLAGS+=	-I${LLVM_SRCS}/include -I${CLANG_SRCS}/include \
8		-I${LLVM_SRCS}/${SRCDIR} ${INCDIR:C/^/-I${LLVM_SRCS}\//} -I. \
9		-I${LLVM_SRCS}/../../lib/clang/include \
10		-DLLVM_ON_UNIX -DLLVM_ON_FREEBSD \
11		-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS #-DNDEBUG
12
13.if ${MK_CLANG_FULL} != "no"
14CFLAGS+=	-DCLANG_ENABLE_ARCMT \
15		-DCLANG_ENABLE_STATIC_ANALYZER
16.endif # MK_CLANG_FULL
17
18# LLVM is not strict aliasing safe as of 12/31/2011
19CFLAGS+=	-fno-strict-aliasing
20
21TARGET_ARCH?=	${MACHINE_ARCH}
22BUILD_ARCH?=	${MACHINE_ARCH}
23
24.if ${TARGET_ARCH:Marm*hf*} != ""
25TARGET_ABI=	gnueabihf
26.elif ${TARGET_ARCH:Marm*} != ""
27TARGET_ABI=	gnueabi
28.else
29TARGET_ABI=	unknown
30.endif
31
32TARGET_TRIPLE?=	${TARGET_ARCH:C/amd64/x86_64/:C/armv6hf/armv6/:C/arm64/aarch64/}-${TARGET_ABI}-freebsd11.0
33BUILD_TRIPLE?=	${BUILD_ARCH:C/amd64/x86_64/:C/armv6hf/armv6/:C/arm64/aarch64/}-unknown-freebsd11.0
34CFLAGS+=	-DLLVM_DEFAULT_TARGET_TRIPLE=\"${TARGET_TRIPLE}\" \
35		-DLLVM_HOST_TRIPLE=\"${BUILD_TRIPLE}\" \
36		-DDEFAULT_SYSROOT=\"${TOOLS_PREFIX}\"
37CXXFLAGS+=	-std=c++11 -fno-exceptions -fno-rtti
38
39.PATH:	${LLVM_SRCS}/${SRCDIR}
40
41TBLGEN?=	tblgen
42CLANG_TBLGEN?=	clang-tblgen
43
44Intrinsics.inc.h: ${LLVM_SRCS}/include/llvm/IR/Intrinsics.td
45	${TBLGEN} -gen-intrinsic \
46	    -I ${LLVM_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
47	    ${LLVM_SRCS}/include/llvm/IR/Intrinsics.td
48.for arch in \
49	AArch64/AArch64 ARM/ARM Mips/Mips PowerPC/PPC Sparc/Sparc X86/X86
50. for hdr in \
51	AsmMatcher/-gen-asm-matcher \
52	AsmWriter1/-gen-asm-writer,-asmwriternum=1 \
53	AsmWriter/-gen-asm-writer \
54	CallingConv/-gen-callingconv \
55	CodeEmitter/-gen-emitter \
56	DAGISel/-gen-dag-isel \
57	DisassemblerTables/-gen-disassembler \
58	FastISel/-gen-fast-isel \
59	InstrInfo/-gen-instr-info \
60	MCCodeEmitter/-gen-emitter,-mc-emitter \
61	MCPseudoLowering/-gen-pseudo-lowering \
62	RegisterInfo/-gen-register-info \
63	SubtargetInfo/-gen-subtarget
64${arch:T}Gen${hdr:H:C/$/.inc.h/}: ${LLVM_SRCS}/lib/Target/${arch:H}/${arch:T}.td
65	${TBLGEN} ${hdr:T:C/,/ /g} \
66	    -I ${LLVM_SRCS}/include -I ${LLVM_SRCS}/lib/Target/${arch:H} \
67	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
68	    ${LLVM_SRCS}/lib/Target/${arch:H}/${arch:T}.td
69. endfor
70.endfor
71
72Attrs.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
73	${CLANG_TBLGEN} -gen-clang-attr-classes \
74	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
75	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
76
77AttrDump.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
78	${CLANG_TBLGEN} -gen-clang-attr-dump \
79	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
80	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
81
82AttrHasAttributeImpl.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
83	${CLANG_TBLGEN} -gen-clang-attr-has-attribute-impl \
84	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
85	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
86
87AttrImpl.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
88	${CLANG_TBLGEN} -gen-clang-attr-impl \
89	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
90	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
91
92AttrList.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
93	${CLANG_TBLGEN} -gen-clang-attr-list \
94	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
95	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
96
97AttrParsedAttrImpl.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
98	${CLANG_TBLGEN} -gen-clang-attr-parsed-attr-impl \
99	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
100	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
101
102AttrParsedAttrKinds.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
103	${CLANG_TBLGEN} -gen-clang-attr-parsed-attr-kinds \
104	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
105	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
106
107AttrParsedAttrList.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
108	${CLANG_TBLGEN} -gen-clang-attr-parsed-attr-list \
109	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
110	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
111
112AttrParserStringSwitches.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
113	${CLANG_TBLGEN} -gen-clang-attr-parser-string-switches \
114	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
115	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
116
117AttrPCHRead.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
118	${CLANG_TBLGEN} -gen-clang-attr-pch-read \
119	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
120	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
121
122AttrPCHWrite.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
123	${CLANG_TBLGEN} -gen-clang-attr-pch-write \
124	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
125	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
126
127AttrSpellingListIndex.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
128	${CLANG_TBLGEN} -gen-clang-attr-spelling-index \
129	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
130	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
131
132AttrTemplateInstantiate.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
133	${CLANG_TBLGEN} -gen-clang-attr-template-instantiate \
134	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
135	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
136
137AttrVisitor.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
138	${CLANG_TBLGEN} -gen-clang-attr-ast-visitor \
139	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
140	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
141
142CommentCommandInfo.inc.h: ${CLANG_SRCS}/include/clang/AST/CommentCommands.td
143	${CLANG_TBLGEN} -gen-clang-comment-command-info \
144	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
145	    ${CLANG_SRCS}/include/clang/AST/CommentCommands.td
146
147CommentCommandList.inc.h: ${CLANG_SRCS}/include/clang/AST/CommentCommands.td
148	${CLANG_TBLGEN} -gen-clang-comment-command-list \
149	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
150	    ${CLANG_SRCS}/include/clang/AST/CommentCommands.td
151
152CommentHTMLNamedCharacterReferences.inc.h: \
153	${CLANG_SRCS}/include/clang/AST/CommentHTMLNamedCharacterReferences.td
154	${CLANG_TBLGEN} -gen-clang-comment-html-named-character-references \
155	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
156	    ${CLANG_SRCS}/include/clang/AST/CommentHTMLNamedCharacterReferences.td
157
158CommentHTMLTags.inc.h: ${CLANG_SRCS}/include/clang/AST/CommentHTMLTags.td
159	${CLANG_TBLGEN} -gen-clang-comment-html-tags \
160	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
161	    ${CLANG_SRCS}/include/clang/AST/CommentHTMLTags.td
162
163CommentHTMLTagsProperties.inc.h: \
164	${CLANG_SRCS}/include/clang/AST/CommentHTMLTags.td
165	${CLANG_TBLGEN} -gen-clang-comment-html-tags-properties \
166	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
167	    ${CLANG_SRCS}/include/clang/AST/CommentHTMLTags.td
168
169CommentNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/CommentNodes.td
170	${CLANG_TBLGEN} -gen-clang-comment-nodes \
171	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
172	    ${CLANG_SRCS}/include/clang/Basic/CommentNodes.td
173
174DeclNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/DeclNodes.td
175	${CLANG_TBLGEN} -gen-clang-decl-nodes \
176	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
177	    ${CLANG_SRCS}/include/clang/Basic/DeclNodes.td
178
179StmtNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/StmtNodes.td
180	${CLANG_TBLGEN} -gen-clang-stmt-nodes \
181	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
182	    ${CLANG_SRCS}/include/clang/Basic/StmtNodes.td
183
184arm_neon.h: ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
185	${CLANG_TBLGEN} -gen-arm-neon \
186	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
187	    ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
188
189arm_neon.inc.h: ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
190	${CLANG_TBLGEN} -gen-arm-neon-sema \
191	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
192	    ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
193
194DiagnosticGroups.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
195	${CLANG_TBLGEN} -gen-clang-diag-groups \
196	    -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/\.h$/.d/} \
197	    -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
198
199DiagnosticIndexName.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
200	${CLANG_TBLGEN} -gen-clang-diags-index-name \
201	    -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/\.h$/.d/} \
202	    -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
203
204.for hdr in AST Analysis Comment Common Driver Frontend Lex Parse Sema Serialization
205Diagnostic${hdr}Kinds.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
206	${CLANG_TBLGEN} -gen-clang-diags-defs -clang-component=${hdr} \
207	    -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/\.h$/.d/} \
208	    -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
209.endfor
210
211Options.inc.h: ${CLANG_SRCS}/include/clang/Driver/Options.td
212	${TBLGEN} -gen-opt-parser-defs \
213	    -I ${LLVM_SRCS}/include -I ${CLANG_SRCS}/include/clang/Driver \
214	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
215	    ${CLANG_SRCS}/include/clang/Driver/Options.td
216
217Checkers.inc.h: ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers/Checkers.td
218	${CLANG_TBLGEN} -gen-clang-sa-checkers \
219	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
220	    ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers/Checkers.td
221
222.for dep in ${TGHDRS:C/$/.inc.d/}
223. sinclude "${dep}"
224.endfor
225
226SRCS+=		${TGHDRS:C/$/.inc.h/}
227DPSRCS+=	${TGHDRS:C/$/.inc.h/}
228CLEANFILES+=	${TGHDRS:C/$/.inc.h/} ${TGHDRS:C/$/.inc.d/}
229