ledisdb/dev.sh

97 lines
3.1 KiB
Bash
Raw Normal View History

2014-05-09 10:49:22 +04:00
#!/bin/bash
2014-07-26 14:39:54 +04:00
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
2014-05-09 10:49:22 +04:00
fi
#default snappy and leveldb install path
#you may change yourself
2015-12-19 22:30:26 +03:00
HOMEBREW_PREFIX=$(type brew >/dev/null 2>&1 && brew --prefix 2>/dev/null)
2015-10-05 07:03:01 +03:00
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
2014-05-09 10:49:22 +04:00
function add_path()
{
# $1 path variable
# $2 path to add
if [ -d "$2" ] && [[ ":$1:" != *":$2:"* ]]; then
echo "$1:$2"
else
echo "$1"
fi
}
2014-07-26 14:39:54 +04:00
export GOPATH=$(add_path $GOPATH $LEDISROOT)
2014-07-26 05:22:09 +04:00
2014-07-26 14:39:54 +04:00
GO_BUILD_TAGS=
CGO_CFLAGS=
CGO_CXXFLAGS=
CGO_LDFLAGS=
2014-07-28 08:46:17 +04:00
# check dependent libray, now we only check simply, maybe later add proper checking way.
2014-07-25 20:46:03 +04:00
# check snappy
2014-08-02 08:59:33 +04:00
if [ -f $SNAPPY_DIR/include/snappy.h ]; then
2014-07-26 05:22:09 +04:00
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"
2014-07-25 20:46:03 +04:00
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
2014-07-28 08:46:17 +04:00
if [ -f $LEVELDB_DIR/include/leveldb/c.h ]; then
2014-07-26 05:22:09 +04:00
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"
2014-07-25 20:46:03 +04:00
LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $LEVELDB_DIR/lib)
DYLD_LIBRARY_PATH=$(add_path $DYLD_LIBRARY_PATH $LEVELDB_DIR/lib)
2014-07-26 05:22:09 +04:00
GO_BUILD_TAGS="$GO_BUILD_TAGS leveldb"
2014-07-25 20:46:03 +04:00
fi
2014-07-25 20:46:03 +04:00
# check rocksdb
2014-07-28 08:46:17 +04:00
if [ -f $ROCKSDB_DIR/include/rocksdb/c.h ]; then
2014-07-26 05:22:09 +04:00
CGO_CFLAGS="$CGO_CFLAGS -I$ROCKSDB_DIR/include"
CGO_CXXFLAGS="$CGO_CXXFLAGS -I$ROCKSDB_DIR/include"
2014-07-26 14:39:54 +04:00
CGO_LDFLAGS="$CGO_LDFLAGS -L$ROCKSDB_DIR/lib -lrocksdb"
2014-07-25 20:46:03 +04:00
LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $ROCKSDB_DIR/lib)
DYLD_LIBRARY_PATH=$(add_path $DYLD_LIBRARY_PATH $ROCKSDB_DIR/lib)
2014-07-26 05:22:09 +04:00
GO_BUILD_TAGS="$GO_BUILD_TAGS rocksdb"
2014-07-25 20:46:03 +04:00
fi
2014-05-09 10:49:22 +04:00
2014-08-11 20:54:53 +04:00
#check lua
2014-09-13 10:11:05 +04:00
if [ -f $LUA_DIR/include/lua.h ]; then
2014-09-13 10:34:15 +04:00
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"
2015-10-05 07:03:01 +03:00
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
2014-07-25 20:46:03 +04:00
export CGO_CFLAGS
export CGO_CXXFLAGS
export CGO_LDFLAGS
export LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH
export GO_BUILD_TAGS