-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.sh
executable file
·72 lines (67 loc) · 1.95 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
#! /bin/bash
# configure and build Kunlun computing node program.
# If you don't need to configure it, simply do make install.
# usage: build.sh <build-type> <prefix> Then build.sh install
# build-type: Release or Debug
# e.g. bash build.sh Release /home/dzw/mysql_installs/postgresql-11.5-rel
# then (probably run as root): bash build.sh install
export SRCROOT=`pwd`
action="$1"
usage(){
echo "Usage: build.sh <build-type> <prefix> Then build.sh install"
echo " build-type: Debug | Release"
exit 1
}
init() {
test "$1" = "" && usage
cd $SRCROOT
idir="$1"
echo "$idir" > installdir
cd $SRCROOT/resources
test -d mysql || tar -xzf mysql_client.tgz
# ln -s ./libmariadb.so.3 libmariadb.so
cd $SRCROOT/src/include/sharding
ln -s $SRCROOT/resources/mysql mysql
cd $SRCROOT
}
build() {
idir="$2"
init "$idir"
export LIBS=-lmariadb
export LDFLAGS=-L$SRCROOT/resources
if test "$1" = "Release"; then
export CFLAGS="-O2 -ggdb3"
export CXXFLAGS="-O2 -ggdb3"
./configure --with-openssl --with-icu --prefix="$idir"
# ./configure --with-openssl --with-icu --with-llvm --prefix="$idir"
elif test "$1" = "Debug"; then
export CFLAGS="-O0 -ggdb3 -DENABLE_DEBUG"
export CXXFLAGS="-O0 -ggdb3 -DENABLE_DEBUG "
./configure --with-openssl --with-icu --enable-debug --enable-cassert --prefix="$idir"
# ./configure --with-openssl --with-icu --with-llvm --enable-debug --enable-cassert --prefix="$idir"
# in current ubuntu-20.04 latest llvm there is build error.
else #defensive
usage
fi
cd $SRCROOT/src && make clean
cd $SRCROOT && make -j8 2> $SRCROOT/err.txt
}
install() {
test -f installdir || {
echo "installation directory is not set, call 'build.sh build' first!"
usage
}
idir=`cat installdir`
mkdir -p "$idir"
make install
bash ./post-install.sh "$idir"
}
if test "$action" = "Debug" -o "$action" = "Release"; then
test "$#" != 2 && usage
build "$1" "$2"
elif test "$action" = "install"; then
test "$#" != 1 && usage
install
else
usage
fi