xref: /freebsd/lib/clang/clang.build.mk (revision 3823d5e198425b4f5e5a80267d195769d1063773)
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_REWRITER \
16		-DCLANG_ENABLE_STATIC_ANALYZER
17.endif # MK_CLANG_FULL
18
19# LLVM is not strict aliasing safe as of 12/31/2011
20CFLAGS+=	-fno-strict-aliasing
21
22TARGET_ARCH?=	${MACHINE_ARCH}
23BUILD_ARCH?=	${MACHINE_ARCH}
24
25.if ${TARGET_ARCH:Marm*hf*} != ""
26TARGET_ABI=	gnueabihf
27.elif ${TARGET_ARCH:Marm*} != ""
28TARGET_ABI=	gnueabi
29.else
30TARGET_ABI=	unknown
31.endif
32
33TARGET_TRIPLE?=	${TARGET_ARCH:C/amd64/x86_64/:C/armv6hf/armv6/}-${TARGET_ABI}-freebsd11.0
34BUILD_TRIPLE?=	${BUILD_ARCH:C/amd64/x86_64/:C/armv6hf/armv6/}-unknown-freebsd11.0
35CFLAGS+=	-DLLVM_DEFAULT_TARGET_TRIPLE=\"${TARGET_TRIPLE}\" \
36		-DLLVM_HOST_TRIPLE=\"${BUILD_TRIPLE}\" \
37		-DDEFAULT_SYSROOT=\"${TOOLS_PREFIX}\"
38CXXFLAGS+=	-fno-exceptions -fno-rtti
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	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,-mc-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
83AttrIdentifierArg.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
84	${CLANG_TBLGEN} -gen-clang-attr-identifier-arg-list \
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
93AttrLateParsed.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
94	${CLANG_TBLGEN} -gen-clang-attr-late-parsed-list \
95	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
96	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
97
98AttrList.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
99	${CLANG_TBLGEN} -gen-clang-attr-list \
100	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
101	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
102
103AttrParsedAttrImpl.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
104	${CLANG_TBLGEN} -gen-clang-attr-parsed-attr-impl \
105	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
106	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
107
108AttrParsedAttrKinds.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
109	${CLANG_TBLGEN} -gen-clang-attr-parsed-attr-kinds \
110	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
111	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
112
113AttrParsedAttrList.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
114	${CLANG_TBLGEN} -gen-clang-attr-parsed-attr-list \
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
128AttrSpellings.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
129	${CLANG_TBLGEN} -gen-clang-attr-spelling-list \
130	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
131	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
132
133AttrSpellingListIndex.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
134	${CLANG_TBLGEN} -gen-clang-attr-spelling-index \
135	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
136	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
137
138AttrTemplateInstantiate.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
139	${CLANG_TBLGEN} -gen-clang-attr-template-instantiate \
140	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
141	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
142
143AttrTypeArg.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
144	${CLANG_TBLGEN} -gen-clang-attr-type-arg-list \
145	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
146	    ${CLANG_SRCS}/include/clang/Basic/Attr.td
147
148CommentCommandInfo.inc.h: ${CLANG_SRCS}/include/clang/AST/CommentCommands.td
149	${CLANG_TBLGEN} -gen-clang-comment-command-info \
150	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
151	    ${CLANG_SRCS}/include/clang/AST/CommentCommands.td
152
153CommentCommandList.inc.h: ${CLANG_SRCS}/include/clang/AST/CommentCommands.td
154	${CLANG_TBLGEN} -gen-clang-comment-command-list \
155	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
156	    ${CLANG_SRCS}/include/clang/AST/CommentCommands.td
157
158CommentHTMLNamedCharacterReferences.inc.h: \
159	${CLANG_SRCS}/include/clang/AST/CommentHTMLNamedCharacterReferences.td
160	${CLANG_TBLGEN} -gen-clang-comment-html-named-character-references \
161	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
162	    ${CLANG_SRCS}/include/clang/AST/CommentHTMLNamedCharacterReferences.td
163
164CommentHTMLTags.inc.h: ${CLANG_SRCS}/include/clang/AST/CommentHTMLTags.td
165	${CLANG_TBLGEN} -gen-clang-comment-html-tags \
166	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
167	    ${CLANG_SRCS}/include/clang/AST/CommentHTMLTags.td
168
169CommentHTMLTagsProperties.inc.h: \
170	${CLANG_SRCS}/include/clang/AST/CommentHTMLTags.td
171	${CLANG_TBLGEN} -gen-clang-comment-html-tags-properties \
172	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
173	    ${CLANG_SRCS}/include/clang/AST/CommentHTMLTags.td
174
175CommentNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/CommentNodes.td
176	${CLANG_TBLGEN} -gen-clang-comment-nodes \
177	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
178	    ${CLANG_SRCS}/include/clang/Basic/CommentNodes.td
179
180DeclNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/DeclNodes.td
181	${CLANG_TBLGEN} -gen-clang-decl-nodes \
182	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
183	    ${CLANG_SRCS}/include/clang/Basic/DeclNodes.td
184
185StmtNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/StmtNodes.td
186	${CLANG_TBLGEN} -gen-clang-stmt-nodes \
187	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
188	    ${CLANG_SRCS}/include/clang/Basic/StmtNodes.td
189
190arm_neon.h: ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
191	${CLANG_TBLGEN} -gen-arm-neon \
192	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
193	    ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
194
195arm_neon.inc.h: ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
196	${CLANG_TBLGEN} -gen-arm-neon-sema \
197	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
198	    ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
199
200DiagnosticGroups.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
201	${CLANG_TBLGEN} -gen-clang-diag-groups \
202	    -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/\.h$/.d/} \
203	    -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
204
205DiagnosticIndexName.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
206	${CLANG_TBLGEN} -gen-clang-diags-index-name \
207	    -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/\.h$/.d/} \
208	    -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
209
210.for hdr in AST Analysis Comment Common Driver Frontend Lex Parse Sema Serialization
211Diagnostic${hdr}Kinds.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
212	${CLANG_TBLGEN} -gen-clang-diags-defs -clang-component=${hdr} \
213	    -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/\.h$/.d/} \
214	    -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
215.endfor
216
217Options.inc.h: ${CLANG_SRCS}/include/clang/Driver/Options.td
218	${TBLGEN} -gen-opt-parser-defs \
219	    -I ${LLVM_SRCS}/include -I ${CLANG_SRCS}/include/clang/Driver \
220	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
221	    ${CLANG_SRCS}/include/clang/Driver/Options.td
222
223CC1AsOptions.inc.h: ${CLANG_SRCS}/include/clang/Driver/CC1AsOptions.td
224	${TBLGEN} -gen-opt-parser-defs \
225	    -I ${LLVM_SRCS}/include -I ${CLANG_SRCS}/include/clang/Driver \
226	    -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
227	    ${CLANG_SRCS}/include/clang/Driver/CC1AsOptions.td
228
229Checkers.inc.h: ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers/Checkers.td
230	${CLANG_TBLGEN} -gen-clang-sa-checkers \
231	    -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \
232	    ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers/Checkers.td
233
234.for dep in ${TGHDRS:C/$/.inc.d/}
235. sinclude "${dep}"
236.endfor
237
238SRCS+=		${TGHDRS:C/$/.inc.h/}
239DPSRCS+=	${TGHDRS:C/$/.inc.h/}
240CLEANFILES+=	${TGHDRS:C/$/.inc.h/} ${TGHDRS:C/$/.inc.d/}
241