5 CLANG_SRCS= ${LLVM_SRCS}/tools/clang
7 CFLAGS+= -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
13 .if ${MK_CLANG_FULL} != "no"
14 CFLAGS+= -DCLANG_ENABLE_ARCMT \
15 -DCLANG_ENABLE_STATIC_ANALYZER
16 .endif # MK_CLANG_FULL
18 # LLVM is not strict aliasing safe as of 12/31/2011
19 CFLAGS+= -fno-strict-aliasing
21 TARGET_ARCH?= ${MACHINE_ARCH}
22 BUILD_ARCH?= ${MACHINE_ARCH}
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*} == "")
29 .elif ${TARGET_ARCH:Marm*}
35 TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/:C/arm64/aarch64/}-${TARGET_ABI}-freebsd12.0
36 BUILD_TRIPLE?= ${BUILD_ARCH:C/amd64/x86_64/:C/arm64/aarch64/}-unknown-freebsd12.0
37 CFLAGS+= -DLLVM_DEFAULT_TARGET_TRIPLE=\"${TARGET_TRIPLE}\" \
38 -DLLVM_HOST_TRIPLE=\"${BUILD_TRIPLE}\" \
39 -DDEFAULT_SYSROOT=\"${TOOLS_PREFIX}\"
40 CXXFLAGS+= -std=c++11 -fno-exceptions -fno-rtti
41 CXXFLAGS.clang+= -stdlib=libc++
43 .PATH: ${LLVM_SRCS}/${SRCDIR}
45 LLVM_TBLGEN?= llvm-tblgen
46 CLANG_TBLGEN?= clang-tblgen
48 Attributes.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
53 AttributesCompatFunc.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
58 Intrinsics.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
64 AArch64/AArch64 ARM/ARM Mips/Mips PowerPC/PPC Sparc/Sparc X86/X86
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
87 Attrs.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
92 AttrDump.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
97 AttrHasAttributeImpl.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
102 AttrImpl.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
107 AttrList.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
112 AttrParsedAttrImpl.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
117 AttrParsedAttrKinds.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
122 AttrParsedAttrList.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
127 AttrParserStringSwitches.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
132 AttrPCHRead.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
137 AttrPCHWrite.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
142 AttrSpellingListIndex.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
147 AttrTemplateInstantiate.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
152 AttrVisitor.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
157 CommentCommandInfo.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
162 CommentCommandList.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
167 CommentHTMLNamedCharacterReferences.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
173 CommentHTMLTags.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
178 CommentHTMLTagsProperties.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
184 CommentNodes.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
189 DeclNodes.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
194 StmtNodes.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
199 arm_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
204 arm_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
209 DiagnosticGroups.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
214 DiagnosticIndexName.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
219 .for hdr in AST Analysis Comment Common Driver Frontend Lex Parse Sema Serialization
220 Diagnostic${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
226 # XXX: Atrocious hack, need to clean this up later
227 .if ${LIB:U} == llvmlibdriver
228 Options.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
235 Options.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
242 Checkers.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
247 .for dep in ${TGHDRS:C/$/.inc.d/}
248 . if ${MAKE_VERSION} < 20160220
257 SRCS+= ${TGHDRS:C/$/.inc.h/}
258 CLEANFILES+= ${TGHDRS:C/$/.inc.h/} ${TGHDRS:C/$/.inc.d/}