update leveled build_deps.sh

This commit is contained in:
siddontang 2014-05-14 09:02:10 +08:00
parent 81840c211c
commit 3dfdf380f2
1 changed files with 9 additions and 21 deletions

View File

@ -2,19 +2,16 @@
#refer https://github.com/norton/lets/blob/master/c_src/build_deps.sh #refer https://github.com/norton/lets/blob/master/c_src/build_deps.sh
#install leveldb and snappy
#you must set your own snappy and leveldb source directory
#snappy https://drive.google.com/file/d/0B0xs9kK-b5nMOWIxWGJhMXd6aGs/edit?usp=sharing
#leveldb https://leveldb.googlecode.com/files/leveldb-1.15.0.tar.gz
SNAPPY_SRC=./snappy
LEVELDB_SRC=./leveldb
SNAPPY_DIR=/usr/local/snappy SNAPPY_DIR=/usr/local/snappy
LEVELDB_DIR=/usr/local/leveldb LEVELDB_DIR=/usr/local/leveldb
mkdir -p ./build
cd ./build
if [ ! -f $SNAPPY_DIR/lib/libsnappy.a ]; then if [ ! -f $SNAPPY_DIR/lib/libsnappy.a ]; then
(cd $SNAPPY_SRC && \ (git clone git@github.com:siddontang/snappy.git && \
cd ./snappy && \
./configure --prefix=$SNAPPY_DIR && \ ./configure --prefix=$SNAPPY_DIR && \
make && \ make && \
make install) make install)
@ -23,7 +20,8 @@ else
fi fi
if [ ! -f $LEVELDB_DIR/lib/libleveldb.a ]; then if [ ! -f $LEVELDB_DIR/lib/libleveldb.a ]; then
(cd $LEVELDB_SRC && \ (git clone git@github.com:siddontang/leveldb.git && \
cd ./leveldb && \
echo "echo \"PLATFORM_CFLAGS+=-I$SNAPPY_DIR/include\" >> build_config.mk" >> build_detect_platform && echo "echo \"PLATFORM_CFLAGS+=-I$SNAPPY_DIR/include\" >> build_config.mk" >> build_detect_platform &&
echo "echo \"PLATFORM_CXXFLAGS+=-I$SNAPPY_DIR/include\" >> build_config.mk" >> build_detect_platform && echo "echo \"PLATFORM_CXXFLAGS+=-I$SNAPPY_DIR/include\" >> build_config.mk" >> build_detect_platform &&
echo "echo \"PLATFORM_LDFLAGS+=-L $SNAPPY_DIR/lib -lsnappy\" >> build_config.mk" >> build_detect_platform && echo "echo \"PLATFORM_LDFLAGS+=-L $SNAPPY_DIR/lib -lsnappy\" >> build_config.mk" >> build_detect_platform &&
@ -37,18 +35,8 @@ else
echo "skip install leveldb" echo "skip install leveldb"
fi 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 CGO_CFLAGS="-I$LEVELDB_DIR/include -I$SNAPPY_DIR/include" export CGO_CFLAGS="-I$LEVELDB_DIR/include -I$SNAPPY_DIR/include"
export CGO_CXXFLAGS="-I$LEVELDB_DIR/include -I$SNAPPY_DIR/include"
export CGO_LDFLAGS="-L$LEVELDB_DIR/lib -L$SNAPPY_DIR/lib -lsnappy" export CGO_LDFLAGS="-L$LEVELDB_DIR/lib -L$SNAPPY_DIR/lib -lsnappy"
export LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $SNAPPY_DIR/lib) export LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $SNAPPY_DIR/lib)
export LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $LEVELDB_DIR/lib) export LD_LIBRARY_PATH=$(add_path $LD_LIBRARY_PATH $LEVELDB_DIR/lib)