forked from ledisdb/ledisdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev.sh
executable file
·96 lines (84 loc) · 3.05 KB
/
dev.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
#!/bin/bash
export LEDISTOP=$(pwd)
export LEDISROOT="${LEDISROOT:-${LEDISTOP/\/src\/github.com\/siddontang\/ledisdb/}}"
# LEDISTOP sanity check
if [[ "$LEDISTOP" == "${LEDISTOP/\/src\/github.com\/siddontang\/ledisdb/}" ]]; then
echo "WARNING: LEDISTOP($LEDISTOP) does not contain src/github.com/siddontang/ledisdb"
false
fi
#default snappy and leveldb install path
#you may change yourself
HOMEBREW_PREFIX=$(type brew >/dev/null 2>&1 && brew --prefix 2>/dev/null)
if [[ ! -z "$HOMEBREW_PREFIX" ]]; then
SNAPPY_DIR=$HOMEBREW_PREFIX/opt/snappy
LEVELDB_DIR=$HOMEBREW_PREFIX/opt/leveldb
ROCKSDB_DIR=$HOMEBREW_PREFIX/opt/rocksdb
LUA_DIR=$HOMEBREW_PREFIX/opt/lua51
else
SNAPPY_DIR=/usr/local/snappy
LEVELDB_DIR=/usr/local/leveldb
ROCKSDB_DIR=/usr/local/rocksdb
LUA_DIR=/usr/local/lua
fi
function add_path()
{
# $1 path variable
# $2 path to add
if [ -d "$2" ] && [[ ":$1:" != *":$2:"* ]]; then
echo "$1:$2"
else
echo "$1"
fi
}
export GOPATH=$(add_path $GOPATH $LEDISROOT)
GO_BUILD_TAGS=
CGO_CFLAGS=
CGO_CXXFLAGS=
CGO_LDFLAGS=
# check dependent libray, now we only check simply, maybe later add proper checking way.
# check snappy
if [ -f $SNAPPY_DIR/include/snappy.h ]; then
CGO_CFLAGS="$CGO_CFLAGS -I$SNAPPY_DIR/include"
CGO_CXXFLAGS="$CGO_CXXFLAGS -I$SNAPPY_DIR/include"
CGO_LDFLAGS="$CGO_LDFLAGS -L$SNAPPY_DIR/lib -lsnappy"
LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $SNAPPY_DIR/lib)
DYLD_LIBRARY_PATH=$(add_path $DYLD_LIBRARY_PATH $SNAPPY_DIR/lib)
fi
# check leveldb
if [ -f $LEVELDB_DIR/include/leveldb/c.h ]; then
CGO_CFLAGS="$CGO_CFLAGS -I$LEVELDB_DIR/include"
CGO_CXXFLAGS="$CGO_CXXFLAGS -I$LEVELDB_DIR/include"
CGO_LDFLAGS="$CGO_LDFLAGS -L$LEVELDB_DIR/lib -lleveldb"
LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $LEVELDB_DIR/lib)
DYLD_LIBRARY_PATH=$(add_path $DYLD_LIBRARY_PATH $LEVELDB_DIR/lib)
GO_BUILD_TAGS="$GO_BUILD_TAGS leveldb"
fi
# check rocksdb
if [ -f $ROCKSDB_DIR/include/rocksdb/c.h ]; then
CGO_CFLAGS="$CGO_CFLAGS -I$ROCKSDB_DIR/include"
CGO_CXXFLAGS="$CGO_CXXFLAGS -I$ROCKSDB_DIR/include"
CGO_LDFLAGS="$CGO_LDFLAGS -L$ROCKSDB_DIR/lib -lrocksdb"
LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $ROCKSDB_DIR/lib)
DYLD_LIBRARY_PATH=$(add_path $DYLD_LIBRARY_PATH $ROCKSDB_DIR/lib)
GO_BUILD_TAGS="$GO_BUILD_TAGS rocksdb"
fi
#check lua
if [ -f $LUA_DIR/include/lua.h ]; then
CGO_CFLAGS="$CGO_CFLAGS -I$LUA_DIR/include"
CGO_LDFLAGS="$CGO_LDFLAGS -L$LUA_DIR/lib -llua"
LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $LUA_DIR/lib)
DYLD_LIBRARY_PATH=$(add_path $DYLD_LIBRARY_PATH $LUA_DIR/lib)
GO_BUILD_TAGS="$GO_BUILD_TAGS lua"
elif [ -f $LUA_DIR/include/lua-5.1/lua.h ]; then
CGO_CFLAGS="$CGO_CFLAGS -I$LUA_DIR/include/lua-5.1"
CGO_LDFLAGS="$CGO_LDFLAGS -L$LUA_DIR/lib -llua5.1"
LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $LUA_DIR/lib)
DYLD_LIBRARY_PATH=$(add_path $DYLD_LIBRARY_PATH $LUA_DIR/lib)
GO_BUILD_TAGS="$GO_BUILD_TAGS lua"
fi
export CGO_CFLAGS
export CGO_CXXFLAGS
export CGO_LDFLAGS
export LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH
export GO_BUILD_TAGS