2013-11-20 20:53:43 +00:00
|
|
|
SHELL = /bin/bash
|
|
|
|
|
|
|
|
PROTOC = @PROTOC@
|
|
|
|
GO = @GO@
|
|
|
|
# or 386
|
|
|
|
arch = amd64
|
|
|
|
CGO_ENABLED = 1
|
|
|
|
|
|
|
|
cflags =
|
|
|
|
ifeq ($(arch),386)
|
|
|
|
cflags = -m32
|
|
|
|
GOARCH = $(arch)
|
|
|
|
endif
|
|
|
|
|
|
|
|
export GOARCH
|
|
|
|
export CGO_ENABLED
|
|
|
|
|
|
|
|
.PHONY: all valgrind parser
|
|
|
|
|
|
|
|
all: build test
|
|
|
|
|
|
|
|
valgrind:
|
|
|
|
|
|
|
|
GOPATH := $(shell pwd)
|
|
|
|
export GOPATH
|
|
|
|
uname_S = $(shell sh -c "uname -s 2>/dev/null || echo not")
|
|
|
|
|
|
|
|
# packages
|
|
|
|
packages = admin api/http common configuration \
|
|
|
|
checkers coordinator datastore engine parser \
|
|
|
|
protocol server
|
|
|
|
|
|
|
|
# snappy variables
|
|
|
|
snappy_version = 1.1.0
|
|
|
|
snappy_dir = /tmp/snappy.influxdb.$(arch)
|
|
|
|
snappy_file = snappy-$(snappy_version).tar.gz
|
|
|
|
snappy_deps = $(snappy_dir)/.libs/libsnappy.a
|
|
|
|
|
|
|
|
# leveldb variables
|
|
|
|
leveldb_version = 1.12.0
|
|
|
|
leveldb_dir = /tmp/leveldb.influxdb.$(arch)
|
|
|
|
leveldb_file = leveldb-$(leveldb_version).tar.gz
|
|
|
|
leveldb_deps = $(leveldb_dir)/libleveldb.a
|
|
|
|
|
|
|
|
# levigo flags
|
2013-11-26 19:08:51 +00:00
|
|
|
ifeq ($(uname_S),Linux)
|
2013-11-20 20:53:43 +00:00
|
|
|
CGO_CFLAGS += -I$(leveldb_dir)/include
|
|
|
|
CGO_LDFLAGS += $(leveldb_dir)/libleveldb.a $(snappy_dir)/.libs/libsnappy.a -lstdc++
|
|
|
|
export CGO_CFLAGS
|
|
|
|
export CGO_LDFLAGS
|
2013-11-26 19:08:51 +00:00
|
|
|
else
|
|
|
|
CGO_LDFLAGS = -lleveldb -lsnappy -lstdc++
|
|
|
|
export CGO_LDFLAGS
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(uname_S),Linux)
|
|
|
|
PYTHONPATH ?= /usr/local/lib/python2.7/site-packages/
|
|
|
|
export PYTHONPATH
|
|
|
|
endif
|
2013-11-20 20:53:43 +00:00
|
|
|
|
|
|
|
$(snappy_deps):
|
|
|
|
ifeq ($(uname_S),Linux)
|
|
|
|
rm -rf $(snappy_dir)
|
|
|
|
mkdir -p $(snappy_dir)
|
|
|
|
bash -c "cd $(snappy_dir); \
|
|
|
|
wget https://snappy.googlecode.com/files/$(snappy_file); \
|
|
|
|
tar --strip-components=1 -xvzf $(snappy_file); \
|
|
|
|
CFLAGS=$(cflags) CXXFLAGS=$(cflags) ./configure; \
|
|
|
|
$(MAKE)"
|
|
|
|
endif
|
|
|
|
|
|
|
|
$(leveldb_deps): $(snappy_deps)
|
|
|
|
ifeq ($(uname_S),Linux)
|
|
|
|
rm -rf $(leveldb_dir)
|
|
|
|
mkdir -p $(leveldb_dir)
|
|
|
|
bash -c "cd $(leveldb_dir); \
|
|
|
|
wget https://leveldb.googlecode.com/files/$(leveldb_file); \
|
|
|
|
tar --strip-components=1 -xvzf $(leveldb_file); \
|
|
|
|
CXXFLAGS='-I$(snappy_dir) $(cflags)' LDFLAGS='-L$(snappy_dir)/.libs' make"
|
|
|
|
endif
|
|
|
|
|
2013-11-26 20:32:09 +00:00
|
|
|
dependencies = code.google.com/p/go.crypto/bcrypt \
|
|
|
|
code.google.com/p/goprotobuf/proto \
|
|
|
|
code.google.com/p/goprotobuf/protoc-gen-go \
|
|
|
|
code.google.com/p/log4go \
|
|
|
|
github.com/bmizerany/pat \
|
|
|
|
github.com/fitstar/falcore \
|
|
|
|
github.com/fitstar/falcore/filter \
|
|
|
|
github.com/gorilla/mux \
|
|
|
|
github.com/influxdb/raft \
|
|
|
|
github.com/pmylund/go-cache
|
2013-11-20 20:53:43 +00:00
|
|
|
|
2013-11-26 20:32:09 +00:00
|
|
|
levigo_dependency = github.com/jmhodges/levigo
|
|
|
|
|
|
|
|
dependencies_paths := $(addprefix src/,$(dependencies))
|
|
|
|
|
|
|
|
src/$(levigo_dependency):
|
|
|
|
$(GO) get -d $(levigo_dependency)
|
|
|
|
bash -c "pushd $@; find . -name \*.go | xargs sed -i 's/\/\/ #cgo LDFLAGS: -lleveldb\|#cgo LDFLAGS: -lleveldb//g'; popd"
|
|
|
|
|
|
|
|
|
|
|
|
$(dependencies_paths):
|
|
|
|
for i in $(dependencies); do $(GO) get $$i; done
|
|
|
|
|
|
|
|
dependencies: src/$(levigo_dependency) $(dependencies_paths)
|
2013-11-20 20:53:43 +00:00
|
|
|
|
|
|
|
test_dependencies: dependencies
|
|
|
|
$(GO) get launchpad.net/gocheck
|
|
|
|
|
|
|
|
protobuf:
|
|
|
|
rm -f src/protocol/*.pb.go
|
|
|
|
PATH=$$PWD/bin:$$PATH $(PROTOC) --go_out=. src/protocol/*.proto
|
|
|
|
|
|
|
|
parser:
|
|
|
|
$(MAKE) -C src/parser
|
|
|
|
|
|
|
|
build: dependencies protobuf parser
|
|
|
|
# TODO: build all packages, otherwise we won't know
|
|
|
|
# if there's an error
|
|
|
|
$(GO) build server
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf pkg/
|
|
|
|
rm -rf packages/
|
|
|
|
|
|
|
|
valgrind: build
|
|
|
|
$(MAKE) -C src/parser test
|
|
|
|
|
|
|
|
only =
|
|
|
|
verbose = off
|
|
|
|
ifneq ($(only),)
|
|
|
|
GOTEST_OPTS = -gocheck.f $(only)
|
|
|
|
endif
|
|
|
|
ifneq ($(verbose),off)
|
|
|
|
GOTEST_OPTS += -v -gocheck.v
|
|
|
|
endif
|
|
|
|
|
|
|
|
test: test_dependencies parser
|
|
|
|
$(GO) test $(packages) $(GOTEST_OPTS)
|
|
|
|
|
|
|
|
coverage: test_dependencies
|
|
|
|
for i in $(packages); do $(GO) test -coverprofile /tmp/influxdb.$${i/\//}.coverage $$i $(GOTEST_OPTS); \
|
|
|
|
$(GO) tool cover -html=/tmp/influxdb.$${i/\//}.coverage; done
|
|
|
|
|
|
|
|
|
|
|
|
integration_test: test_dependencies
|
|
|
|
$(GO) test src/integration
|
|
|
|
|
|
|
|
package:
|
|
|
|
@echo not implemented yet
|