-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·82 lines (68 loc) · 2.31 KB
/
configure
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
#!/usr/bin/sh
build_tool="make"
call_dir=`pwd`
if [ $# -ne 3 ]; then
echo -e "Wrong number of arguments. Usage:"
echo -e "1) ./$(basename "$0") <llvm_src_dir> <llvm_obj_dir> <llvm_bin_dir>"
echo -e " <llvm_src_dir>: The root directory of LLVM source code."
echo -e " <llvm_obj_dir>: The directory that LLVM is built."
echo -e " Could be the same as <llvm_src_dir>."
echo -e " <llvm_bin_dir>: The directory that LLVM is installed.\n"
echo -e "2) ./$(basename "$0") \$(cat llvm_dirs)"
echo -e " The \"llvm_dirs\" file is generated by the \"download_llvm\" script."
exit 1
fi
command -v cmake >/dev/null 2>&1 || {
echo -e "cmake is required to run this script. Aborting..." >&2;
echo -e "hint: apt-get install cmake\n" >&2;
exit 1;
}
command -v g++ >/dev/null 2>&1 || {
echo -e "g++ is required to build this project. Aborting..." >&2;
echo -e "hint: apt-get install build-essential\n" >&2;
exit 1;
}
if [ -d "$1" ]; then
llvm_src_dir="$(cd "$1" && pwd)"
else
echo -e "Directory $1 does not exist."
exit 1
fi
if [ -d "$2" ]; then
llvm_obj_dir="$(cd "$2" && pwd)"
else
echo -e "Directory $2 does not exist."
exit 1
fi
if [ -d "$3" ]; then
llvm_bin_dir="$(cd "$3" && pwd)"
else
echo -e "Directory $3 does not exist."
exit 1
fi
# Find the absolute path of the project
proj_root_dir="$(cd "$(dirname "$0")" && pwd)"
# Include the projects directory in the right CMakeFiles.txt file
# under clang's project tree, in order to be able to build it.
makelist="${llvm_src_dir}/tools/clang/tools/extra/CMakeLists.txt"
if [ ! -e $makelist ]; then
echo -e "Clang and clang-extra-tools are required to build this project."
exit 1
fi
if ! grep -q ${proj_root_dir} ${makelist}; then
echo -e "\nadd_subdirectory(${proj_root_dir} ${proj_root_dir})\n" >> ${makelist}
fi
cd ${llvm_obj_dir}
if [ $build_tool = "ninja" ]; then
cmake -G Ninja ${llvm_src_dir} -DCMAKE_INSTALL_PREFIX=${llvm_bin_dir} -DLLVM_TARGETS_TO_BUILD=host
else
cmake ${llvm_src_dir} -DCMAKE_INSTALL_PREFIX=${llvm_bin_dir} -DLLVM_TARGETS_TO_BUILD=host
fi
# Create a symlink to the executable for convenience.
if [ -h ${proj_root_dir}/vygraph ]; then
echo -e "Cannot create link ${proj_root_dir}/vygraph. File already exists."
else
cd ${proj_root_dir}
ln -s ${llvm_obj_dir}/bin/vygraph vygraph
fi
cd ${call_dir}