xref: /freebsd/lib/clang/clang.build.mk (revision e3466a89fd9c3d0be2f831d42a5b5cf65cb0fd53)
1# $FreeBSD$
2
3CLANG_SRCS=	${LLVM_SRCS}/tools/clang
4
5CFLAGS+=	-I${LLVM_SRCS}/include -I${CLANG_SRCS}/include \
6		-I${LLVM_SRCS}/${SRCDIR} ${INCDIR:C/^/-I${LLVM_SRCS}\//} -I. \
7		-I${LLVM_SRCS}/../../lib/clang/include \
8		-DLLVM_ON_UNIX -DLLVM_ON_FREEBSD \
9		-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS #-DNDEBUG
10
11.if !defined(EARLY_BUILD) && defined(MK_CLANG_FULL) && ${MK_CLANG_FULL} != "no"
12CFLAGS+=	-DCLANG_ENABLE_ARCMT \
13		-DCLANG_ENABLE_REWRITER \
14		-DCLANG_ENABLE_STATIC_ANALYZER
15.endif # !EARLY_BUILD && MK_CLANG_FULL
16
17# LLVM is not strict aliasing safe as of 12/31/2011
18CFLAGS+=	-fno-strict-aliasing
19
20TARGET_ARCH?=	${MACHINE_ARCH}
21BUILD_ARCH?=	${MACHINE_ARCH}
22
23.if (${TARGET_ARCH} == "arm" || ${TARGET_ARCH} == "armv6") && \
24    ${MK_ARM_EABI} != "no"
25TARGET_ABI=	gnueabi
26.else
27TARGET_ABI=	unknown
28.endif
29
30TARGET_TRIPLE?=	${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd10.0
31BUILD_TRIPLE?=	${BUILD_ARCH:C/amd64/x86_64/}-unknown-freebsd10.0
32CFLAGS+=	-DLLVM_DEFAULT_TARGET_TRIPLE=\"${TARGET_TRIPLE}\" \
33		-DLLVM_HOSTTRIPLE=\"${BUILD_TRIPLE}\" \
34		-DDEFAULT_SYSROOT=\"${TOOLS_PREFIX}\"
35CXXFLAGS+=	-fno-exceptions -fno-rtti
36
37.PATH:	${LLVM_SRCS}/${SRCDIR}
38
39TBLGEN?=	tblgen
40CLANG_TBLGEN?=	clang-tblgen
41TBLINC+=	-I ${LLVM_SRCS}/include -I ${LLVM_SRCS}/lib/Target
42
43Intrinsics.inc.h: ${LLVM_SRCS}/include/llvm/Intrinsics.td
44	${TBLGEN} -I ${LLVM_SRCS}/lib/VMCore ${TBLINC} -gen-intrinsic \
45	    -o ${.TARGET} ${LLVM_SRCS}/include/llvm/Intrinsics.td
46.for arch in \
47	ARM/ARM Mips/Mips PowerPC/PPC X86/X86
48. for hdr in \
49	AsmMatcher/-gen-asm-matcher \
50	AsmWriter1/-gen-asm-writer,-asmwriternum=1 \
51	AsmWriter/-gen-asm-writer \
52	CallingConv/-gen-callingconv \
53	CodeEmitter/-gen-emitter \
54	DAGISel/-gen-dag-isel \
55	DisassemblerTables/-gen-disassembler \
56	EDInfo/-gen-enhanced-disassembly-info \
57	FastISel/-gen-fast-isel \
58	InstrInfo/-gen-instr-info \
59	MCCodeEmitter/-gen-emitter,-mc-emitter \
60	MCPseudoLowering/-gen-pseudo-lowering \
61	RegisterInfo/-gen-register-info \
62	SubtargetInfo/-gen-subtarget
63${arch:T}Gen${hdr:H:C/$/.inc.h/}: ${LLVM_SRCS}/lib/Target/${arch:H}/${arch:T}.td
64	${TBLGEN} -I ${LLVM_SRCS}/lib/Target/${arch:H} ${TBLINC} \
65	    ${hdr:T:C/,/ /g} -o ${.TARGET} \
66	    ${LLVM_SRCS}/lib/Target/${arch:H}/${arch:T}.td
67. endfor
68.endfor
69
70Attrs.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
71	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
72	    -gen-clang-attr-classes -o ${.TARGET} \
73	    -I ${CLANG_SRCS}/include ${.ALLSRC}
74
75AttrImpl.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
76	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
77	    -gen-clang-attr-impl -o ${.TARGET} \
78	    -I ${CLANG_SRCS}/include ${.ALLSRC}
79
80AttrLateParsed.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
81	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
82	    -gen-clang-attr-late-parsed-list -o ${.TARGET} \
83	    -I ${CLANG_SRCS}/include ${.ALLSRC}
84
85AttrList.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
86	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
87	    -gen-clang-attr-list -o ${.TARGET} \
88	    -I ${CLANG_SRCS}/include ${.ALLSRC}
89
90AttrParsedAttrKinds.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
91	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
92	    -gen-clang-attr-parsed-attr-kinds -o ${.TARGET} \
93	    -I ${CLANG_SRCS}/include ${.ALLSRC}
94
95AttrParsedAttrList.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
96	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
97	    -gen-clang-attr-parsed-attr-list -o ${.TARGET} \
98	    -I ${CLANG_SRCS}/include ${.ALLSRC}
99
100AttrPCHRead.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
101	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Serialization \
102	    ${TBLINC} -gen-clang-attr-pch-read -o ${.TARGET} \
103	    -I ${CLANG_SRCS}/include ${.ALLSRC}
104
105AttrPCHWrite.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
106	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Serialization \
107	    ${TBLINC} -gen-clang-attr-pch-write -o ${.TARGET} \
108	    -I ${CLANG_SRCS}/include ${.ALLSRC}
109
110AttrSpellings.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
111	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Lex ${TBLINC} \
112	    -gen-clang-attr-spelling-list -o ${.TARGET} \
113	    -I ${CLANG_SRCS}/include ${.ALLSRC}
114
115AttrTemplateInstantiate.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
116	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
117	    -gen-clang-attr-template-instantiate -o ${.TARGET} \
118	    -I ${CLANG_SRCS}/include ${.ALLSRC}
119
120CommentCommandInfo.inc.h: ${CLANG_SRCS}/include/clang/AST/CommentCommands.td
121	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
122	    -gen-clang-comment-command-info -o ${.TARGET} ${.ALLSRC}
123
124CommentHTMLTags.inc.h: ${CLANG_SRCS}/include/clang/AST/CommentHTMLTags.td
125	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
126	    -gen-clang-comment-html-tags -o ${.TARGET} ${.ALLSRC}
127
128CommentHTMLTagsProperties.inc.h: ${CLANG_SRCS}/include/clang/AST/CommentHTMLTags.td
129	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
130	    -gen-clang-comment-html-tags-properties -o ${.TARGET} ${.ALLSRC}
131
132CommentNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/CommentNodes.td
133	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
134	    -gen-clang-comment-nodes -o ${.TARGET} ${.ALLSRC}
135
136DeclNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/DeclNodes.td
137	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
138	    -gen-clang-decl-nodes -o ${.TARGET} ${.ALLSRC}
139
140StmtNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/StmtNodes.td
141	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
142	    -gen-clang-stmt-nodes -o ${.TARGET} ${.ALLSRC}
143
144arm_neon.inc.h: ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
145	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
146	    -gen-arm-neon-sema -o ${.TARGET} ${.ALLSRC}
147
148DiagnosticGroups.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
149	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
150	    -gen-clang-diag-groups -o ${.TARGET} ${.ALLSRC}
151
152DiagnosticIndexName.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
153	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
154	    -gen-clang-diags-index-name -o ${.TARGET} ${.ALLSRC}
155
156.for hdr in AST Analysis Comment Common Driver Frontend Lex Parse Sema Serialization
157Diagnostic${hdr}Kinds.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
158	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
159	    -gen-clang-diags-defs -clang-component=${hdr} \
160	    -o ${.TARGET} ${.ALLSRC}
161.endfor
162
163Options.inc.h: ${CLANG_SRCS}/include/clang/Driver/Options.td
164	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Driver ${TBLINC} \
165	    -gen-opt-parser-defs -o ${.TARGET} ${.ALLSRC}
166
167CC1AsOptions.inc.h: ${CLANG_SRCS}/include/clang/Driver/CC1AsOptions.td
168	${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Driver ${TBLINC} \
169	    -gen-opt-parser-defs -o ${.TARGET} ${.ALLSRC}
170
171Checkers.inc.h: ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers/Checkers.td \
172	    ${CLANG_SRCS}/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
173	${CLANG_TBLGEN} -I ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers \
174	    ${TBLINC} -gen-clang-sa-checkers -o ${.TARGET} \
175	    -I ${CLANG_SRCS}/include \
176	    ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers/Checkers.td
177
178SRCS+=		${TGHDRS:C/$/.inc.h/}
179DPADD+=		${TGHDRS:C/$/.inc.h/}
180CLEANFILES+=	${TGHDRS:C/$/.inc.h/}
181