-
Notifications
You must be signed in to change notification settings - Fork 32
/
build_deps.sh
executable file
·103 lines (84 loc) · 3.03 KB
/
build_deps.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
#!/usr/bin/env bash
DEPS_LOCATION=_build/deps
if [ -d "$DEPS_LOCATION" ]; then
echo "cpp-driver fork already exist. delete $DEPS_LOCATION for a fresh checkout."
exit 0
fi
CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -n hw.ncpu`
OS=$(uname -s)
if [ -x "$(command -v lsb_release)" ]; then
KERNEL=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
elif [ -f /etc/os-release ]; then
. /etc/os-release
KERNEL=$(echo $ID)
else
KERNEL=unknown
fi
#echo $OS
#echo $KERNEL
CPP_DRIVER_REPO=https://github.com/datastax/cpp-driver.git
CPP_DRIVER_REV=$1
case $OS in
Linux)
case $KERNEL in
centos)
echo "Linux, CentOS"
sudo yum -y install automake cmake gcc-c++ git libtool openssl-devel wget
OUTPUT=`ldconfig -p | grep libuv`
if [[ $(echo $OUTPUT) != "" ]]
then echo "libuv has already been installed"
else
pushd /tmp
wget https://dist.libuv.org/dist/v1.18.0/libuv-v1.18.0.tar.gz
tar xzf libuv-v1.18.0.tar.gz
pushd libuv-v1.18.0
sh autogen.sh
./configure
sudo make install
popd
popd
sudo grep -q -F '/usr/local/lib' /etc/ld.so.conf.d/usrlocal.conf || echo '/usr/local/lib' | sudo tee --append /etc/ld.so.conf.d/usrlocal.conf > /dev/null
sudo ldconfig -v
fi
;;
ubuntu)
echo "Linux, Ubuntu"
# check ubuntu version
UBUNTU_VSN=$(lsb_release -sr)
if [[ $UBUNTU_VSN == "14.04" ]]; then
# system is Ubuntu 14.04, need to install PPA and possibly override libuv
sudo add-apt-repository ppa:acooks/libwebsockets6
LIBUDEV_PACKAGE_NAME=libuv1.dev
else
LIBUDEV_PACKAGE_NAME=libuv1-dev
fi
sudo apt-get -y update
sudo apt-get -y install g++ make cmake libssl-dev $LIBUDEV_PACKAGE_NAME
;;
*) echo "Your system $KERNEL is not supported"
esac
export CFLAGS="-fPIC -Wno-class-memaccess"
export CXXFLAGS="-fPIC -Wno-class-memaccess"
;;
Darwin)
export HOMEBREW_NO_INSTALL_UPGRADE=true
export HOMEBREW_NO_INSTALL_CLEANUP=true
export HOMEBREW_NO_AUTO_UPDATE=1
brew install libuv cmake openssl
export OPENSSL_ROOT_DIR=$(brew --prefix openssl)
export OPENSSL_INCLUDE_DIR=$OPENSSL_ROOT_DIR/include/
export OPENSSL_LIBRARIES=$OPENSSL_ROOT_DIR/lib
;;
*) echo "Your system $OS is not supported"
esac
mkdir -p $DEPS_LOCATION
#checkout repo
pushd $DEPS_LOCATION
git clone -b ${CPP_DRIVER_REV} --depth=1 ${CPP_DRIVER_REPO}
popd
#build
mkdir -p $DEPS_LOCATION/cpp-driver/build
pushd $DEPS_LOCATION/cpp-driver/build
cmake .. -DCASS_BUILD_STATIC=ON -DCMAKE_BUILD_TYPE=RELEASE
make -j $CPUS
popd