xref: /freebsd/lib/clang/llvm.build.mk (revision ab00ac327a66a53edaac95b536b209db3ae2cd9f)
1# $FreeBSD$
2
3.ifndef LLVM_SRCS
4.error Please define LLVM_SRCS before including this file
5.endif
6
7.ifndef SRCDIR
8.error Please define SRCDIR before including this file
9.endif
10
11.PATH:		${LLVM_SRCS}/${SRCDIR}
12
13CFLAGS+=	-I${SRCTOP}/lib/clang/include
14CFLAGS+=	-I${LLVM_SRCS}/include
15CFLAGS+=	-DLLVM_ON_UNIX
16CFLAGS+=	-DLLVM_ON_FREEBSD
17CFLAGS+=	-D__STDC_LIMIT_MACROS
18CFLAGS+=	-D__STDC_CONSTANT_MACROS
19#CFLAGS+=	-DNDEBUG
20
21TARGET_ARCH?=	${MACHINE_ARCH}
22BUILD_ARCH?=	${MACHINE_ARCH}
23
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*} == "")
28TARGET_ABI=	gnueabihf
29.elif ${TARGET_ARCH:Marm*}
30TARGET_ABI=	gnueabi
31.else
32TARGET_ABI=	unknown
33.endif
34OS_VERSION=	freebsd12.0
35
36TARGET_TRIPLE?=	${TARGET_ARCH:C/amd64/x86_64/:C/arm64/aarch64/}-${TARGET_ABI}-${OS_VERSION}
37BUILD_TRIPLE?=	${BUILD_ARCH:C/amd64/x86_64/:C/arm64/aarch64/}-unknown-${OS_VERSION}
38
39CFLAGS+=	-DLLVM_DEFAULT_TARGET_TRIPLE=\"${TARGET_TRIPLE}\"
40CFLAGS+=	-DLLVM_HOST_TRIPLE=\"${BUILD_TRIPLE}\"
41CFLAGS+=	-DDEFAULT_SYSROOT=\"${TOOLS_PREFIX}\"
42
43CFLAGS+=	-ffunction-sections
44CFLAGS+=	-fdata-sections
45LDFLAGS+=	-Wl,--gc-sections
46
47CXXFLAGS+=	-std=c++11
48CXXFLAGS+=	-fno-exceptions
49CXXFLAGS+=	-fno-rtti
50CXXFLAGS.clang+= -stdlib=libc++
51
52.if ${MACHINE_CPUARCH} == "arm"
53STATIC_CFLAGS+= -mlong-calls
54STATIC_CXXFLAGS+= -mlong-calls
55.endif
56