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