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