-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
93 lines (67 loc) · 2.81 KB
/
Makefile
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
90
91
92
93
# Default LLVM installation directory
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
DISTRO := $(shell lsb_release -si)
ifeq ($(DISTRO),Ubuntu)
LLVM_DIR ?= /usr/lib/llvm-17
CLANG_COMMAND ?= /usr/bin/clang-17
OPT_COMMAND ?= /usr/bin/opt-17
endif
else ifeq ($(UNAME_S),Darwin)
LLVM_DIR ?= /usr/local/opt/llvm
CLANG_COMMAND ?= clang -I/usr/local/include
OPT_COMMAND ?= opt
endif
# Target for cloning the repository
REPO_URL = https://github.com/ncsu-csc512-project/part1-dev.git
REPO_DIR = part1-dev
all: run
install-deps-on-ubuntu:
sudo apt install tmux cmake fd-find -y
inputs/input.ll: inputs/input.c
# clang -S -emit-llvm inputs/input.c -o inputs/input.ll -g -O0
$(CLANG_COMMAND) -S -emit-llvm inputs/input.c -o inputs/input.ll -g -O0
# $(CLANG_COMMAND) -S -emit-llvm inputs/input.c -o inputs/input.ll -g
# clang -S -emit-llvm inputs/input.c -o inputs/input.ll
# $(REPO_DIR):
# git clone $(REPO_URL)
#
# clone: $(REPO_DIR)
setup: clone
export LLVM_DIR=$(LLVM_DIR)
build_dir:
mkdir -p build
prereq:
# if on ubuntu and clang-17 not found, run scripts/ubuntu-install-llvm.sh
if [ `uname` = "Linux" ] && [ ! -f $(CLANG_COMMAND) ]; then ./scripts/ubuntu-install-llvm.sh; fi
# if cmake not installed
if [ `uname` = "Linux" ] && [ -z `command -v cmake` ]; then sudo apt install cmake -y; fi
build: prereq setup build_dir
# if not on linux
# check UNAME_S
if [ "$(UNAME_S)" != "Linux" ]; then \
cmake -DMY_LLVM_INSTALL_DIR=$(LLVM_DIR) -S . -B build && cmake --build build; \
else \
VCPKG_CMAKE="$$(scripts/setup-vcpkg.sh)" && \
cmake -DMY_LLVM_INSTALL_DIR=$(LLVM_DIR) -S . -B build -DCMAKE_TOOLCHAIN_FILE="$${VCPKG_CMAKE}" && cmake --build build; \
fi
run: build inputs/input.ll
$(OPT_COMMAND) -load-pass-plugin ./build/BranchPointerPass/libBranchPointerPass.so -passes=branch-pointer-pass -disable-output inputs/input.ll
clean:
rm -rf build
sync-to-submission-repo-dryrun:
rsync -au --delete --progress -h --include-from='include.txt' ./ ../part1-submission/ -n
sync-to-submission-repo:
rsync -au --delete --progress -h --include-from='include.txt' ./ ../part1-submission/
push-and-open-submission-repo:
cd ../part1-submission/ && git add . && git commit -m "update" && git push origin master && cd - && open https://github.com/ncsu-csc512-project/part1-submission
push-and-sync-all: sync-to-submission-repo
# git add . && git commit -m "update" && git push origin master && make sync-to-submission-repo && make push-and-open-submission-repo
git-pp -p . ../part1-submission/
update-vcl:
rsync -au --progress -h . vcl:1 --exclude 'build' --exclude '.git'
update-vcl2:
rsync -au --progress -h . vcl2:1 --exclude 'build' --exclude '.git'
update-vcl3:
rsync -au --progress -h . vcl3:1 --exclude 'build' --exclude '.git'
.PHONY: all clone setup build run clean sync-to-submission-repo* prereq *push* *sync*