forked from silviucpp/ezstd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_deps.sh
executable file
·70 lines (56 loc) · 1.39 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
#!/usr/bin/env bash
ROOT=$(pwd)
DEPS_LOCATION=_build/deps
OS=$(uname -s)
KERNEL=$(echo $(lsb_release -ds 2>/dev/null || cat /etc/*release 2>/dev/null | head -n1 | awk '{print $1;}') | awk '{print $1;}')
CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -n hw.ncpu`
# https://github.com/facebook/zstd.git
ZSTD_DESTINATION=zstd
ZSTD_REPO=https://github.com/facebook/zstd.git
ZSTD_BRANCH=release
ZSTD_TAG=v1.5.5
ZSTD_SUCCESS=lib/libzstd.a
fail_check()
{
"$@"
local status=$?
if [ $status -ne 0 ]; then
echo "error with $1" >&2
exit 1
fi
}
CheckoutLib()
{
if [ -f "$DEPS_LOCATION/$4/$5" ]; then
echo "$4 fork already exist. delete $DEPS_LOCATION/$4 for a fresh checkout ..."
else
#repo rev branch destination
echo "repo=$1 tag=$2 branch=$3"
mkdir -p $DEPS_LOCATION
pushd $DEPS_LOCATION
if [ ! -d "$4" ]; then
fail_check git clone -b $3 $1 $4
fi
pushd $4
fail_check git checkout $2
BuildLibrary $4
popd
popd
fi
}
BuildLibrary()
{
case $OS in
Linux)
export CFLAGS="-fPIC"
export CXXFLAGS="-fPIC"
;;
*)
;;
esac
fail_check make -j $CPUS
rm -rf lib/*.so
rm -rf lib/*.so.*
rm -rf lib/*.dylib
}
CheckoutLib $ZSTD_REPO $ZSTD_TAG $ZSTD_BRANCH $ZSTD_DESTINATION $ZSTD_SUCCESS