xref: /freebsd/usr.bin/clang/lld/Makefile (revision d178b1f878ae5b1b4e574bcf34d21b60855bf5a0)
1# $FreeBSD$
2
3.include <src.opts.mk>
4
5LLVM_BASE=	${SRCTOP}/contrib/llvm-project
6LLVM_SRCS=	${LLVM_BASE}/llvm
7LLD_SRCS=	${LLVM_BASE}/lld
8
9PACKAGE=	lld
10PROG_CXX=	ld.lld
11# Man page directory
12.PATH:		${LLD_SRCS}/docs
13.if (!defined(TOOLS_PREFIX) && ${MK_LLD_IS_LD} != "no") || \
14    (defined(TOOLS_PREFIX) && ${MK_LLD_BOOTSTRAP} != "no")
15SYMLINKS=	${PROG_CXX} ${BINDIR}/ld
16MLINKS=		ld.lld.1 ld.1
17.endif
18
19.if ${MK_SHARED_TOOLCHAIN} == "no"
20NO_SHARED?= yes
21.endif
22
23CFLAGS+=	-I${LLD_SRCS}/ELF
24CFLAGS+=	-I${LLD_SRCS}/include
25CFLAGS+=	-I${.OBJDIR}
26CFLAGS+=	-I${OBJTOP}/lib/clang/libllvm
27
28SRCDIR=		lld
29SRCS+=		Common/Args.cpp
30SRCS+=		Common/DWARF.cpp
31SRCS+=		Common/ErrorHandler.cpp
32SRCS+=		Common/Filesystem.cpp
33SRCS+=		Common/Memory.cpp
34SRCS+=		Common/Reproduce.cpp
35SRCS+=		Common/Strings.cpp
36SRCS+=		Common/TargetOptionsCommandFlags.cpp
37SRCS+=		Common/Version.cpp
38SRCS+=		ELF/AArch64ErrataFix.cpp
39SRCS+=		ELF/ARMErrataFix.cpp
40SRCS+=		ELF/Arch/AArch64.cpp
41SRCS+=		ELF/Arch/AMDGPU.cpp
42SRCS+=		ELF/Arch/ARM.cpp
43SRCS+=		ELF/Arch/AVR.cpp
44SRCS+=		ELF/Arch/Hexagon.cpp
45SRCS+=		ELF/Arch/MSP430.cpp
46SRCS+=		ELF/Arch/Mips.cpp
47SRCS+=		ELF/Arch/MipsArchTree.cpp
48SRCS+=		ELF/Arch/PPC.cpp
49SRCS+=		ELF/Arch/PPC64.cpp
50SRCS+=		ELF/Arch/RISCV.cpp
51SRCS+=		ELF/Arch/SPARCV9.cpp
52SRCS+=		ELF/Arch/X86.cpp
53SRCS+=		ELF/Arch/X86_64.cpp
54SRCS+=		ELF/CallGraphSort.cpp
55SRCS+=		ELF/DWARF.cpp
56SRCS+=		ELF/Driver.cpp
57SRCS+=		ELF/DriverUtils.cpp
58SRCS+=		ELF/EhFrame.cpp
59SRCS+=		ELF/ICF.cpp
60SRCS+=		ELF/InputFiles.cpp
61SRCS+=		ELF/InputSection.cpp
62SRCS+=		ELF/LTO.cpp
63SRCS+=		ELF/LinkerScript.cpp
64SRCS+=		ELF/MapFile.cpp
65SRCS+=		ELF/MarkLive.cpp
66SRCS+=		ELF/OutputSections.cpp
67SRCS+=		ELF/Relocations.cpp
68SRCS+=		ELF/ScriptLexer.cpp
69SRCS+=		ELF/ScriptParser.cpp
70SRCS+=		ELF/SymbolTable.cpp
71SRCS+=		ELF/Symbols.cpp
72SRCS+=		ELF/SyntheticSections.cpp
73SRCS+=		ELF/Target.cpp
74SRCS+=		ELF/Thunks.cpp
75SRCS+=		ELF/Writer.cpp
76SRCS+=		lib/Core/Error.cpp
77SRCS+=		lib/Core/File.cpp
78SRCS+=		lib/Core/LinkingContext.cpp
79SRCS+=		lib/Core/Reader.cpp
80SRCS+=		lib/Core/Resolver.cpp
81SRCS+=		lib/Core/SymbolTable.cpp
82SRCS+=		tools/lld/lld.cpp
83
84.include "${SRCTOP}/lib/clang/llvm.build.mk"
85
86LIBDEPS+=	llvm
87
88.for lib in ${LIBDEPS}
89DPADD+=		${OBJTOP}/lib/clang/lib${lib}/lib${lib}.a
90LDADD+=		${OBJTOP}/lib/clang/lib${lib}/lib${lib}.a
91.endfor
92
93LLVM_TBLGEN?=	llvm-tblgen
94INCFILE=	Options.inc
95TDFILE=		${LLD_SRCS}/ELF/Options.td
96GENOPT=		-gen-opt-parser-defs
97${INCFILE}: ${TDFILE}
98	${LLVM_TBLGEN} ${GENOPT} -I ${LLVM_SRCS}/include -d ${.TARGET:C/$/.d/} \
99	    -o ${.TARGET} ${TDFILE}
100TGHDRS+=	${INCFILE}
101
102DPSRCS+=	${TGHDRS}
103CLEANFILES+=	${TGHDRS} ${TGHDRS:C/$/.d/}
104
105.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)
106LIBADD+=	execinfo
107LIBADD+=	ncursesw
108.endif
109LIBADD+=	pthread
110LIBADD+=	z
111
112.include <bsd.prog.mk>
113