summaryrefslogtreecommitdiff
path: root/toolchain/llvm/Makefile
blob: de64924542f0a14d3d09686d029677f81f8d8675 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# This file is part of the OpenADK project. OpenADK is copyrighted
# material, please see the LICENCE file in the top-level directory.

include $(ADK_TOPDIR)/rules.mk
include ../rules.mk
include Makefile.inc

include ${ADK_TOPDIR}/mk/buildhlp.mk

BUILD_DIR_INITIAL:=	$(WRKBUILD)-initial
BUILD_DIR_FINAL:=	$(WRKBUILD)-final

LLVM_VERSION:=		$(ADK_TOOLCHAIN_LLVM_VERSION)
LLVM_TRIPLE:=		$(ADK_TARGET_ARCH)-linux

ifeq ($(ADK_TARGET_ARCH_AARCH64),y)
LLVM_TARGETS:=AArch64
endif
ifeq ($(ADK_TARGET_ARCH_ARM),y)
LLVM_TARGETS:=ARM
ifeq ($(ADK_TARGET_SOFT_FLOAT),y)
LLVM_TRIPLE:=arm-linux-eabi
endif
ifeq ($(ADK_TARGET_HARD_FLOAT),y)
LLVM_TRIPLE:=arm-linux-eabihf
endif
endif
ifeq ($(ADK_TARGET_ARCH_MIPS)$(ADK_TARGET_ARCH_MIPS64),y)
LLVM_TARGETS:=Mips
endif
ifeq ($(ADK_TARGET_ARCH_PPC)$(ADK_TARGET_ARCH_PPC64),y)
LLVM_TARGETS:=PowerPC
endif
ifeq ($(ADK_TARGET_ARCH_SPARC)$(ADK_TARGET_ARCH_SPARC64),y)
LLVM_TARGETS:=Sparc
endif
ifeq ($(ADK_TARGET_ARCH_S390),y)
LLVM_TARGETS:=SystemZ
endif
ifeq ($(ADK_TARGET_ARCH_X86)$(ADK_TARGET_ARCH_X86_64),y)
LLVM_TARGETS:=X86
endif

$(BUILD_DIR_INITIAL)/.configured:
	(cd $(DL_DIR); \
		for file in cfe lld compiler-rt libcxx libcxxabi; do \
			if [ ! -f $${file}-$(LLVM_VERSION).src.tar.xz ]; then \
				wget http://llvm.org/releases/$(LLVM_VERSION)/$${file}-$(LLVM_VERSION).src.tar.xz ; \
			fi; \
		done; \
	) 
	(cd $(WRKBUILD)/tools && tar xvf $(DL_DIR)/cfe-$(LLVM_VERSION).src.tar.xz && mv cfe-$(LLVM_VERSION).src clang)
	(cd $(WRKBUILD)/tools && tar xvf $(DL_DIR)/lld-$(LLVM_VERSION).src.tar.xz && mv lld-$(LLVM_VERSION).src lld)
	(cd $(WRKBUILD)/projects && tar xvf $(DL_DIR)/compiler-rt-$(LLVM_VERSION).src.tar.xz && mv compiler-rt-$(LLVM_VERSION).src compiler-rt)
	(cd $(WRKBUILD)/projects && tar xvf $(DL_DIR)/libcxx-$(LLVM_VERSION).src.tar.xz && mv libcxx-$(LLVM_VERSION).src libcxx)
	(cd $(WRKBUILD)/projects && tar xvf $(DL_DIR)/libcxxabi-$(LLVM_VERSION).src.tar.xz && mv libcxxabi-$(LLVM_VERSION).src libcxxabi)
	mkdir -p $(BUILD_DIR_INITIAL)
	cd $(BUILD_DIR_INITIAL); \
		PATH='$(HOST_PATH)' \
		cmake -DCMAKE_BUILD_TYPE=Release \
			-DCMAKE_INSTALL_PREFIX=$(TOOLCHAIN_DIR)/usr \
			-DCMAKE_CXX_FLAGS="-std=c++11" \
			-DLLVM_ENABLE_EH=ON \
			-DLLVM_ENABLE_RTTI=ON \
			-DLLVM_DEFAULT_TARGET_TRIPLE=$(LLVM_TRIPLE) \
			-DLLVM_TARGETS_TO_BUILD=$(LLVM_TARGETS) \
			$(WRKBUILD)
	touch $@

$(BUILD_DIR_INITIAL)/.compiled: $(BUILD_DIR_INITIAL)/.configured
	PATH='$(TARGET_PATH)' \
		$(MAKE) -j$(ADK_MAKE_JOBS) -C $(BUILD_DIR_INITIAL) all
	touch $@

$(WRKBUILD)/.configured: $(BUILD_DIR_INITIAL)/.compiled
	PATH='$(TARGET_PATH)' \
		$(MAKE) -j$(ADK_MAKE_JOBS) -C $(BUILD_DIR_INITIAL) install
	touch $@

$(WRKBUILD)/.compiled:
	touch $@

$(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
	touch $@

$(WRKBUILD)/.final:
	touch $@

include ${ADK_TOPDIR}/mk/toolchain.mk