go/leveldb/build_deps.sh

56 lines
1.6 KiB
Bash
Raw Normal View History

2014-04-18 10:50:29 +04:00
#!/bin/bash
#refer https://github.com/norton/lets/blob/master/c_src/build_deps.sh
SNAPPY_DIR=/usr/local/snappy
LEVELDB_DIR=/usr/local/leveldb
2014-05-14 05:20:33 +04:00
ROOT_DIR=$(pwd)
2014-05-14 05:02:10 +04:00
2014-05-14 05:20:33 +04:00
BUILD_DIR=/tmp/build_leveldb
mkdir -p $BUILD_DIR
cd $BUILD_DIR
2014-05-14 05:02:10 +04:00
2014-04-18 10:50:29 +04:00
if [ ! -f $SNAPPY_DIR/lib/libsnappy.a ]; then
2014-05-14 05:02:10 +04:00
(git clone git@github.com:siddontang/snappy.git && \
cd ./snappy && \
2014-04-18 10:50:29 +04:00
./configure --prefix=$SNAPPY_DIR && \
make && \
2014-05-14 05:20:33 +04:00
make install && \
cd ..)
2014-04-18 10:50:29 +04:00
else
echo "skip install snappy"
fi
2014-05-14 05:20:33 +04:00
cd $BUILD_DIR
2014-04-18 10:50:29 +04:00
if [ ! -f $LEVELDB_DIR/lib/libleveldb.a ]; then
2014-05-14 05:02:10 +04:00
(git clone git@github.com:siddontang/leveldb.git && \
cd ./leveldb && \
2014-04-18 10:50:29 +04:00
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_LDFLAGS+=-L $SNAPPY_DIR/lib -lsnappy\" >> build_config.mk" >> build_detect_platform &&
make SNAPPY=1 && \
make && \
mkdir -p $LEVELDB_DIR/include/leveldb && \
install include/leveldb/*.h $LEVELDB_DIR/include/leveldb && \
mkdir -p $LEVELDB_DIR/lib && \
2014-05-14 05:20:33 +04:00
cp -f libleveldb.* $LEVELDB_DIR/lib &&\
cd ..)
2014-04-18 10:50:29 +04:00
else
echo "skip install leveldb"
fi
2014-05-14 05:20:33 +04:00
cd $ROOT_DIR
2014-04-18 10:50:29 +04:00
export CGO_CFLAGS="-I$LEVELDB_DIR/include -I$SNAPPY_DIR/include"
2014-05-14 05:02:10 +04:00
export CGO_CXXFLAGS="-I$LEVELDB_DIR/include -I$SNAPPY_DIR/include"
2014-04-18 10:50:29 +04:00
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 $LEVELDB_DIR/lib)
2014-04-18 10:50:29 +04:00
go get github.com/jmhodges/levigo