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