-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.isp
60 lines (45 loc) · 1.76 KB
/
Makefile.isp
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
.PHONY: all
.PHONY: debug
.PHONY: release
.PHONY: install
.PHONY: clean
export ISP_PREFIX ?= $(HOME)/.local/isp/
ifeq "$(shell isp-support/check_ninja_version)" "System ninja is new enough"
NINJA := ninja
else
NINJA := $(HOME)/.local/bin/ninja
endif
$(info Found ninja at $(NINJA))
BUILD_TYPE ?= debug
COMMON_CMAKE_FLAGS += -G "Ninja"
COMMON_CMAKE_FLAGS += -DLLVM_ENABLE_PROJECTS="clang;lld;llvm"
COMMON_CMAKE_FLAGS += -DCMAKE_MAKE_PROGRAM=$(NINJA)
COMMON_CMAKE_FLAGS += -DCMAKE_INSTALL_PREFIX=$(ISP_PREFIX)
COMMON_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang
COMMON_CMAKE_FLAGS += -DCMAKE_CXX_COMPILER=clang++
COMMON_CMAKE_FLAGS += -DBUILD_SHARED_LIBS=True
COMMON_CMAKE_FLAGS += -DLLVM_OPTIMIZED_TABLEGEN=True
COMMON_CMAKE_FLAGS += -DLLVM_BUILD_TESTS=True
COMMON_CMAKE_FLAGS += -DLLVM_TARGETS_TO_BUILD="RISCV"
COMMON_CMAKE_FLAGS += -DCLANG_DEFAULT_RTLIB=compiler-rt
COMMON_CMAKE_FLAGS += -DDEFAULT_SYSROOT=$(ISP_PREFIX)/clang_sysroot/riscv64-unknown-elf
DEBUG_CMAKE_FLAGS := -DCMAKE_BUILD_TYPE=Debug
DEBUG_CMAKE_FLAGS += -DLLVM_ENABLE_ASSERTIONS=ON
DEBUG_CMAKE_FLAGS += -DCMAKE_C_FLAGS=-fstandalone-debug
DEBUG_CMAKE_FLAGS += -DCMAKE_CXX_FLAGS=-fstandalone-debug
RELEASE_CMAKE_FLAGS := -DCMAKE_BUILD_TYPE=Release
debug-build/build.ninja: CMAKE_FLAGS := $(COMMON_CMAKE_FLAGS) $(DEBUG_CMAKE_FLAGS)
release-build/build.ninja: CMAKE_FLAGS := $(COMMON_CMAKE_FLAGS) $(RELEASE_CMAKE_FLAGS)
all: $(BUILD_TYPE)
$(BUILD_TYPE): $(BUILD_TYPE)-build/build.ninja
$(NINJA) -C $(BUILD_TYPE)-build
$(BUILD_TYPE)-build/build.ninja:
$(RM) -r $(BUILD_TYPE)-build
mkdir -p $(BUILD_TYPE)-build
cd $(BUILD_TYPE)-build; cmake $(CMAKE_FLAGS) ../llvm
install: $(BUILD_TYPE)-install
debug-install release-install: %-install: $*
$(NINJA) -C $*-build install
clean:
$(RM) -r debug-build
$(RM) -r release-build