From 539b5df1816f91cdda24af415d688d9df49a534e Mon Sep 17 00:00:00 2001 From: siddontang Date: Mon, 28 Jul 2014 12:46:17 +0800 Subject: [PATCH] update build --- Makefile | 15 ++++++++++++- README.md | 13 ++++++------ build_tool/build_config.sh | 21 +++++++++++++++++++ .../build_leveldb.sh | 0 dev.sh | 8 ++++--- 5 files changed, 47 insertions(+), 10 deletions(-) create mode 100755 build_tool/build_config.sh rename build_leveldb.sh => build_tool/build_leveldb.sh (100%) diff --git a/Makefile b/Makefile index 9ad1cae..7d3778d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,18 @@ +INSTALL_PATH ?= $(CURDIR) + $(shell ./bootstrap.sh) +$(shell ./build_tool/build_config.sh build_config.mk $INSTALL_PATH) + +include build_config.mk + +export CGO_CFLAGS +export CGO_CXXFLAGS +export CGO_LDFLAGS +export LD_LIBRARY_PATH +export DYLD_LIBRARY_PATH +export GO_BUILD_TAGS + all: build build: @@ -9,4 +22,4 @@ clean: go clean -i ./... test: - go test -tags $(GO_BUILD_TAGS) ./... + go test -tags '$(GO_BUILD_TAGS)' ./... diff --git a/README.md b/README.md index e25c978..8e0a982 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,8 @@ Create a workspace and checkout ledisdb source cd src/github.com/siddontang/ledisdb - source dev.sh && make + make + make test ## LevelDB support @@ -34,7 +35,7 @@ Create a workspace and checkout ledisdb source LedisDB supplies a simple script to install leveldb and snappy: - sh build_leveldb.sh + sh build_tool/build_leveldb.sh It will default install leveldb at /usr/local/leveldb and snappy at /usr/local/snappy. @@ -42,17 +43,17 @@ Create a workspace and checkout ledisdb source + Set LEVELDB_DIR and SNAPPY_DIR to the actual install path in dev.sh. -+ ```source dev.sh && make``` ++ ```make``` ## RocksDB support -+ Install rocksdb and snappy first. ++ Install rocksdb(shared_lib) and snappy first. - LedisDB has not supplied a simple script to install, maybe it will later. + LedisDB has not supplied a simple script to install, maybe later. + Set ROCKSDB_DIR and SNAPPY_DIR to the actual install path in dev.sh. -+ ```source dev.sh && make``` ++ ```make``` ## Choose store database diff --git a/build_tool/build_config.sh b/build_tool/build_config.sh new file mode 100755 index 0000000..22b7bf2 --- /dev/null +++ b/build_tool/build_config.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +OUTPUT=$1 +PREFIX=$2 +if test -z "$OUTPUT" || test -z "$PREFIX"; then + echo "usage: $0 " >&2 + exit 1 +fi + +# Delete existing output, if it exists +rm -f $OUTPUT +touch $OUTPUT + +source ./dev.sh + +echo "CGO_CFLAGS=$CGO_CFLAGS" >> $OUTPUT +echo "CGO_CXXFLAGS=$CGO_CXXFLAGS" >> $OUTPUT +echo "CGO_LDFLAGS=$CGO_LDFLAGS" >> $OUTPUT +echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $OUTPUT +echo "DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH" >> $OUTPUT +echo "GO_BUILD_TAGS=$GO_BUILD_TAGS" >> $OUTPUT \ No newline at end of file diff --git a/build_leveldb.sh b/build_tool/build_leveldb.sh similarity index 100% rename from build_leveldb.sh rename to build_tool/build_leveldb.sh diff --git a/dev.sh b/dev.sh index 8bd378c..9709cc6 100644 --- a/dev.sh +++ b/dev.sh @@ -32,8 +32,10 @@ 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/lib/libsnappy.a ]; then +if [ -f $LEVELDB_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" @@ -42,7 +44,7 @@ if [ -f $SNAPPY_DIR/lib/libsnappy.a ]; then fi # check leveldb -if [ -f $LEVELDB_DIR/lib/libleveldb.a ]; then +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" @@ -52,7 +54,7 @@ if [ -f $LEVELDB_DIR/lib/libleveldb.a ]; then fi # check rocksdb -if [ -f $ROCKSDB_DIR/lib/librocksdb.a ]; then +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"