xref: /freebsd/lib/clang/llvm.build.mk (revision 2f513db72b034fd5ef7f080b11be5c711c15186a)
1# $FreeBSD$
2
3.include <src.opts.mk>
4
5.ifndef LLVM_BASE
6.error Please define LLVM_BASE before including this file
7.endif
8
9.ifndef LLVM_SRCS
10.error Please define LLVM_SRCS before including this file
11.endif
12
13.ifndef SRCDIR
14.error Please define SRCDIR before including this file
15.endif
16
17.PATH:		${LLVM_BASE}/${SRCDIR}
18
19CFLAGS+=	-I${SRCTOP}/lib/clang/include
20CFLAGS+=	-I${LLVM_SRCS}/include
21CFLAGS+=	-D__STDC_CONSTANT_MACROS
22CFLAGS+=	-D__STDC_FORMAT_MACROS
23CFLAGS+=	-D__STDC_LIMIT_MACROS
24CFLAGS+=	-DHAVE_VCS_VERSION_INC
25#CFLAGS+=	-DNDEBUG
26
27TARGET_ARCH?=	${MACHINE_ARCH}
28BUILD_ARCH?=	${MACHINE_ARCH}
29
30# Armv6 and armv7 uses hard float abi, unless the CPUTYPE has soft in it.
31# arm (for armv4 and armv5 CPUs) always uses the soft float ABI.
32# For all other targets, we stick with 'unknown'.
33.if ${TARGET_ARCH:Marmv[67]*} && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "")
34TARGET_ABI=	-gnueabihf
35.elif ${TARGET_ARCH:Marm*}
36TARGET_ABI=	-gnueabi
37.else
38TARGET_ABI=
39.endif
40VENDOR=		unknown
41OS_VERSION=	freebsd13.0
42
43LLVM_TARGET_TRIPLE?=	${TARGET_ARCH:C/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${VENDOR}-${OS_VERSION}${TARGET_ABI}
44LLVM_BUILD_TRIPLE?=	${BUILD_ARCH:C/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${VENDOR}-${OS_VERSION}
45
46CFLAGS+=	-DLLVM_DEFAULT_TARGET_TRIPLE=\"${LLVM_TARGET_TRIPLE}\"
47CFLAGS+=	-DLLVM_HOST_TRIPLE=\"${LLVM_BUILD_TRIPLE}\"
48CFLAGS+=	-DDEFAULT_SYSROOT=\"${TOOLS_PREFIX}\"
49
50.if ${MK_LLVM_TARGET_AARCH64} != "no"
51CFLAGS+=	-DLLVM_TARGET_ENABLE_AARCH64
52. if ${MACHINE_CPUARCH} == "aarch64"
53LLVM_NATIVE_ARCH=	AArch64
54. endif
55.endif
56.if ${MK_LLVM_TARGET_ARM} != "no"
57CFLAGS+=	-DLLVM_TARGET_ENABLE_ARM
58. if ${MACHINE_CPUARCH} == "arm"
59LLVM_NATIVE_ARCH=	ARM
60. endif
61.endif
62.if ${MK_LLVM_TARGET_BPF} != "no"
63CFLAGS+=	-DLLVM_TARGET_ENABLE_BPF
64.endif
65.if ${MK_LLVM_TARGET_MIPS} != "no"
66CFLAGS+=	-DLLVM_TARGET_ENABLE_MIPS
67. if ${MACHINE_CPUARCH} == "mips"
68LLVM_NATIVE_ARCH=	Mips
69. endif
70.endif
71.if ${MK_LLVM_TARGET_POWERPC} != "no"
72CFLAGS+=	-DLLVM_TARGET_ENABLE_POWERPC
73. if ${MACHINE_CPUARCH} == "powerpc"
74LLVM_NATIVE_ARCH=	PowerPC
75. endif
76.endif
77.if ${MK_LLVM_TARGET_RISCV} != "no"
78CFLAGS+=	-DLLVM_TARGET_ENABLE_RISCV
79. if ${MACHINE_CPUARCH} == "riscv"
80LLVM_NATIVE_ARCH=	RISCV
81. endif
82.endif
83.if ${MK_LLVM_TARGET_SPARC} != "no"
84CFLAGS+=	-DLLVM_TARGET_ENABLE_SPARC
85. if ${MACHINE_CPUARCH} == "sparc64"
86LLVM_NATIVE_ARCH=	Sparc
87. endif
88.endif
89.if ${MK_LLVM_TARGET_X86} != "no"
90CFLAGS+=	-DLLVM_TARGET_ENABLE_X86
91. if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
92LLVM_NATIVE_ARCH=	X86
93. endif
94.endif
95
96.ifdef LLVM_NATIVE_ARCH
97CFLAGS+=	-DLLVM_NATIVE_ASMPARSER=LLVMInitialize${LLVM_NATIVE_ARCH}AsmParser
98CFLAGS+=	-DLLVM_NATIVE_ASMPRINTER=LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter
99CFLAGS+=	-DLLVM_NATIVE_DISASSEMBLER=LLVMInitialize${LLVM_NATIVE_ARCH}Disassembler
100CFLAGS+=	-DLLVM_NATIVE_TARGET=LLVMInitialize${LLVM_NATIVE_ARCH}Target
101CFLAGS+=	-DLLVM_NATIVE_TARGETINFO=LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo
102CFLAGS+=	-DLLVM_NATIVE_TARGETMC=LLVMInitialize${LLVM_NATIVE_ARCH}TargetMC
103.endif
104
105CFLAGS+=	-ffunction-sections
106CFLAGS+=	-fdata-sections
107LDFLAGS+=	-Wl,--gc-sections
108
109CXXSTD?=	c++11
110CXXFLAGS+=	-fno-exceptions
111CXXFLAGS+=	-fno-rtti
112CXXFLAGS.clang+= -stdlib=libc++
113
114.if ${MACHINE_CPUARCH} == "arm"
115STATIC_CFLAGS+= -mlong-calls
116STATIC_CXXFLAGS+= -mlong-calls
117.endif
118