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"
|
2014-05-09 10:49:22 +04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
#default snappy and leveldb install path
|
|
|
|
#you may change yourself
|
2014-07-25 20:46:03 +04:00
|
|
|
SNAPPY_DIR=/usr/local/snappy
|
|
|
|
LEVELDB_DIR=/usr/local/leveldb
|
2014-07-26 14:39:54 +04:00
|
|
|
ROCKSDB_DIR=/usr/local/rocksdb
|
2014-08-11 20:54:53 +04:00
|
|
|
HYPERLEVELDB_DIR=/usr/local/hyperleveldb
|
2014-09-13 10:11:05 +04:00
|
|
|
LUA_DIR=/usr/local/lua
|
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-05-14 13:09:47 +04:00
|
|
|
|
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-05-15 10:19:48 +04:00
|
|
|
|
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 hyperleveldb
|
|
|
|
if [ -f $HYPERLEVELDB_DIR/include/hyperleveldb/c.h ]; then
|
|
|
|
CGO_CFLAGS="$CGO_CFLAGS -I$HYPERLEVELDB_DIR/include"
|
|
|
|
CGO_CXXFLAGS="$CGO_CXXFLAGS -I$HYPERLEVELDB_DIR/include"
|
|
|
|
CGO_LDFLAGS="$CGO_LDFLAGS -L$HYPERLEVELDB_DIR/lib -lhyperleveldb"
|
|
|
|
LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $HYPERLEVELDB_DIR/lib)
|
|
|
|
DYLD_LIBRARY_PATH=$(add_path $DYLD_LIBRARY_PATH $HYPERLEVELDB_DIR/lib)
|
|
|
|
GO_BUILD_TAGS="$GO_BUILD_TAGS hyperleveldb"
|
|
|
|
fi
|
|
|
|
|
2014-09-04 12:39:23 +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)
|
2014-09-04 12:39:23 +04:00
|
|
|
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
|