xref: /freebsd/lib/clang/clang.build.mk (revision 1f4bcc459a76b7aa664f3fd557684cd0ba6da352)
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
38CXXFLAGS.clang+= -stdlib=libc++
39
40.PATH:	${LLVM_SRCS}/${SRCDIR}
41
42TBLGEN?=	tblgen
43CLANG_TBLGEN?=	clang-tblgen
44
45Intrinsics.inc.h: ${LLVM_SRCS}/include/llvm/IR/Intrinsics.td
46	${TBLGEN} -gen-intrinsic \
47	    -I ${LLVM_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
48	    ${LLVM_SRCS}/include/llvm/IR/Intrinsics.td
49.for arch in \
50	AArch64/AArch64 ARM/ARM Mips/Mips PowerPC/PPC Sparc/Sparc X86/X86
51. for hdr in \
52	AsmMatcher/-gen-asm-matcher \
53	AsmWriter1/-gen-asm-writer,-asmwriternum=1 \
54	AsmWriter/-gen-asm-writer \
55	CallingConv/-gen-callingconv \
56	CodeEmitter/-gen-emitter \
57	DAGISel/-gen-dag-isel \
58	DisassemblerTables/-gen-disassembler \
59	FastISel/-gen-fast-isel \
60	InstrInfo/-gen-instr-info \
61	MCCodeEmitter/-gen-emitter \
62	MCPseudoLowering/-gen-pseudo-lowering \
63	RegisterInfo/-gen-register-info \
64	SubtargetInfo/-gen-subtarget
65${arch:T}Gen${hdr:H:C/$/.inc.h/}: ${LLVM_SRCS}/lib/Target/${arch:H}/${arch:T}.td
66	${TBLGEN} ${hdr:T:C/,/ /g} \
67	    -I ${LLVM_SRCS}/include -I ${LLVM_SRCS}/lib/Target/${arch:H} \
68	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
69	    ${LLVM_SRCS}/lib/Target/${arch:H}/${arch:T}.td
70. endfor
71.endfor
72
73Attrs.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
74	${CLANG_TBLGEN} -gen-clang-attr-classes \
75	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
76	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
77
78AttrDump.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
79	${CLANG_TBLGEN} -gen-clang-attr-dump \
80	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
81	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
82
83AttrHasAttributeImpl.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
84	${CLANG_TBLGEN} -gen-clang-attr-has-attribute-impl \
85	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
86	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
87
88AttrImpl.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
89	${CLANG_TBLGEN} -gen-clang-attr-impl \
90	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
91	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
92
93AttrList.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
94	${CLANG_TBLGEN} -gen-clang-attr-list \
95	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
96	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
97
98AttrParsedAttrImpl.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
99	${CLANG_TBLGEN} -gen-clang-attr-parsed-attr-impl \
100	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
101	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
102
103AttrParsedAttrKinds.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
104	${CLANG_TBLGEN} -gen-clang-attr-parsed-attr-kinds \
105	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
106	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
107
108AttrParsedAttrList.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
109	${CLANG_TBLGEN} -gen-clang-attr-parsed-attr-list \
110	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
111	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
112
113AttrParserStringSwitches.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
114	${CLANG_TBLGEN} -gen-clang-attr-parser-string-switches \
115	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
116	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
117
118AttrPCHRead.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
119	${CLANG_TBLGEN} -gen-clang-attr-pch-read \
120	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
121	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
122
123AttrPCHWrite.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
124	${CLANG_TBLGEN} -gen-clang-attr-pch-write \
125	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
126	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
127
128AttrSpellingListIndex.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
129	${CLANG_TBLGEN} -gen-clang-attr-spelling-index \
130	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
131	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
132
133AttrTemplateInstantiate.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
134	${CLANG_TBLGEN} -gen-clang-attr-template-instantiate \
135	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
136	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
137
138AttrVisitor.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
139	${CLANG_TBLGEN} -gen-clang-attr-ast-visitor \
140	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
141	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
142
143CommentCommandInfo.inc.h: ${CLANG_SRCS}/include/clang/AST/CommentCommands.td
144	${CLANG_TBLGEN} -gen-clang-comment-command-info \
145	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
146	    ${CLANG_SRCS}/include/clang/AST/CommentCommands.td
147
148CommentCommandList.inc.h: ${CLANG_SRCS}/include/clang/AST/CommentCommands.td
149	${CLANG_TBLGEN} -gen-clang-comment-command-list \
150	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
151	    ${CLANG_SRCS}/include/clang/AST/CommentCommands.td
152
153CommentHTMLNamedCharacterReferences.inc.h: \
154	${CLANG_SRCS}/include/clang/AST/CommentHTMLNamedCharacterReferences.td
155	${CLANG_TBLGEN} -gen-clang-comment-html-named-character-references \
156	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
157	    ${CLANG_SRCS}/include/clang/AST/CommentHTMLNamedCharacterReferences.td
158
159CommentHTMLTags.inc.h: ${CLANG_SRCS}/include/clang/AST/CommentHTMLTags.td
160	${CLANG_TBLGEN} -gen-clang-comment-html-tags \
161	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
162	    ${CLANG_SRCS}/include/clang/AST/CommentHTMLTags.td
163
164CommentHTMLTagsProperties.inc.h: \
165	${CLANG_SRCS}/include/clang/AST/CommentHTMLTags.td
166	${CLANG_TBLGEN} -gen-clang-comment-html-tags-properties \
167	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
168	    ${CLANG_SRCS}/include/clang/AST/CommentHTMLTags.td
169
170CommentNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/CommentNodes.td
171	${CLANG_TBLGEN} -gen-clang-comment-nodes \
172	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
173	    ${CLANG_SRCS}/include/clang/Basic/CommentNodes.td
174
175DeclNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/DeclNodes.td
176	${CLANG_TBLGEN} -gen-clang-decl-nodes \
177	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
178	    ${CLANG_SRCS}/include/clang/Basic/DeclNodes.td
179
180StmtNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/StmtNodes.td
181	${CLANG_TBLGEN} -gen-clang-stmt-nodes \
182	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
183	    ${CLANG_SRCS}/include/clang/Basic/StmtNodes.td
184
185arm_neon.h: ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
186	${CLANG_TBLGEN} -gen-arm-neon \
187	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
188	    ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
189
190arm_neon.inc.h: ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
191	${CLANG_TBLGEN} -gen-arm-neon-sema \
192	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
193	    ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
194
195DiagnosticGroups.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
196	${CLANG_TBLGEN} -gen-clang-diag-groups \
197	    -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/\.h$/.d/} \
198	    -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
199
200DiagnosticIndexName.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
201	${CLANG_TBLGEN} -gen-clang-diags-index-name \
202	    -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/\.h$/.d/} \
203	    -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
204
205.for hdr in AST Analysis Comment Common Driver Frontend Lex Parse Sema Serialization
206Diagnostic${hdr}Kinds.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
207	${CLANG_TBLGEN} -gen-clang-diags-defs -clang-component=${hdr} \
208	    -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/\.h$/.d/} \
209	    -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
210.endfor
211
212# XXX: Atrocious hack, need to clean this up later
213.if defined(LIB) && ${LIB} == "llvmlibdriver"
214Options.inc.h: ${LLVM_SRCS}/lib/LibDriver/Options.td
215	${TBLGEN} -gen-opt-parser-defs \
216	    -I ${LLVM_SRCS}/include \
217	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
218	    ${LLVM_SRCS}/lib/LibDriver/Options.td
219.else
220Options.inc.h: ${CLANG_SRCS}/include/clang/Driver/Options.td
221	${TBLGEN} -gen-opt-parser-defs \
222	    -I ${LLVM_SRCS}/include -I ${CLANG_SRCS}/include/clang/Driver \
223	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
224	    ${CLANG_SRCS}/include/clang/Driver/Options.td
225.endif
226
227Checkers.inc.h: ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers/Checkers.td
228	${CLANG_TBLGEN} -gen-clang-sa-checkers \
229	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
230	    ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers/Checkers.td
231
232.if !make(depend)
233. for dep in ${TGHDRS:C/$/.inc.d/}
234.  sinclude "${dep}"
235. endfor
236.endif
237
238SRCS+=		${TGHDRS:C/$/.inc.h/}
239CLEANFILES+=	${TGHDRS:C/$/.inc.h/} ${TGHDRS:C/$/.inc.d/}
240
241# if we are not doing explicit 'make depend', there is
242# nothing to cause these to be generated.
243beforebuild: ${SRCS:M*.inc.h}
244