-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.sh
executable file
·159 lines (126 loc) · 3.39 KB
/
build.sh
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash
RED="\033[31m"
GREEN="\033[32m"
YELLOW="\033[33m"
BOLD="\033[1m"
OFF="\033[0m"
CAPSTONE_VERSION="4.0.2"
KEYSTONE_VERSION="0.9.2"
GLIB_VERSION="2.72.0"
LIBUNWIND_VERSION="1.5"
set -e
#
# check necessary command
#
check_command () {
for cmd in $@
do
if [ ! -x "$(command -v $cmd)" ]; then
echo -e "${RED}Error${OFF}: $cmd is not installed." >&2
exit 1
fi
done
}
check_command "wget" "unzip" "make" "cmake" "meson" "ninja" "pkg-config" "clang" "python3"
#
# check clang version (>= 6.0.0)
#
CLANG_VERSION=$(clang --version | head -n 1 | grep -o -E "[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+" | uniq | sort)
CLANG_MAJOR_VERSION=$(echo $CLANG_VERSION | awk -F '.' '{ print $1 }')
if [[ $CLANG_VERSION < "6.0.0" && ${#CLANG_MAJOR_VERSION} = "1" ]]; then
echo "clang-6.0 or a newer version is required"
exit 1
fi
#
# build capstone
#
CAPSTONE_URL="https://github.com/aquynh/capstone/archive/$CAPSTONE_VERSION.zip"
if [ ! -d capstone ]
then
if [ ! -f capstone.zip ]
then
echo -e "${GREEN}$0${OFF}: downloading capstone.zip..."
wget -O capstone.zip $CAPSTONE_URL
fi
echo -e "${GREEN}$0${OFF}: extracting capstone.zip..."
unzip capstone.zip
mv capstone-$CAPSTONE_VERSION capstone
echo -e "${GREEN}$0${OFF}: building capstone.zip..."
cd capstone
CAPSTONE_DIET=no CAPSTONE_X86_REDUCE=no CAPSTONE_ARCHS="x86" ./make.sh
cd ..
fi
#
# build keystone
#
KEYSTONE_URL="https://github.com/keystone-engine/keystone/archive/$KEYSTONE_VERSION.zip"
if [ ! -d keystone ]
then
if [ ! -f keystone.zip ]
then
echo -e "${GREEN}$0${OFF}: downloading keystone.zip..."
wget -O keystone.zip $KEYSTONE_URL
fi
echo -e "${GREEN}$0${OFF}: extracting keystone.zip..."
unzip keystone.zip
mv keystone-$KEYSTONE_VERSION keystone
echo -e "${GREEN}$0${OFF}: building keystone.zip..."
cd keystone
if [ -d build ]
then
rm -rf build
fi
mkdir build
cd build
cmake -DBUILD_LIBS_ONLY=1 -DLLVM_BUILD_32_BITS=0 -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DLLVM_TARGETS_TO_BUILD="AArch64;X86" -G "Unix Makefiles" ..
make -j8
cd ../..
fi
#
# build glib
#
GLIB_URL="https://github.com/GNOME/glib/archive/$GLIB_VERSION.zip"
if [ ! -d glib ]
then
if [ ! -f glib.zip ]
then
echo -e "${GREEN}$0${OFF}: downloading glib.zip..."
wget -O glib.zip $GLIB_URL
fi
echo -e "${GREEN}$0${OFF}: extracting glib.zip..."
unzip glib.zip
mv glib-$GLIB_VERSION glib
echo -e "${GREEN}$0${OFF}: building glib.zip..."
cd glib
meson _build --buildtype=release --default-library=static --prefix=$(realpath .)
ninja -C _build
ninja -C _build install
cd ..
fi
#
# build libunwind
#
LIBUNWIND_URL="https://github.com/libunwind/libunwind/archive/v$LIBUNWIND_VERSION.zip"
if [ ! -d libunwind ]
then
if [ ! -f libunwind.zip ]
then
echo -e "${GREEN}$0${OFF}: downloading libunwind.zip..."
wget -O libunwind.zip $LIBUNWIND_URL
fi
echo -e "${GREEN}$0${OFF}: extracting libunwind.zip..."
unzip libunwind.zip
mv libunwind-$LIBUNWIND_VERSION libunwind
echo -e "${GREEN}$0${OFF}: building libunwind.zip..."
cd libunwind
mkdir install
./autogen.sh
./configure --prefix=`pwd`/install --enable-cxx-exceptions
make install -j8
cd ..
fi
#
# build src
#
# cd src
# make release