influxdb/Makefile.in

393 lines
12 KiB
Makefile
Raw Normal View History

2013-11-20 20:53:43 +00:00
SHELL = /bin/bash
ifeq ($(TMPDIR),)
TMPDIR=/tmp
endif
export TMPDIR
2013-11-20 20:53:43 +00:00
PROTOC = @PROTOC@
GO = @GO@
2014-06-23 18:43:49 +00:00
GOFMT = @GOFMT@
2013-11-26 21:04:07 +00:00
GOROOT = @GOROOT@
AUTORECONF = @AUTORECONF@
LRT_LDFLAG = @LRT_LDFLAG@
ROCKSDB_LIB = @ROCKSDB_LIB@
# or 386, arm
2013-11-20 20:53:43 +00:00
arch = amd64
CGO_ENABLED = 1
2013-11-26 21:04:07 +00:00
ifneq ($(GOROOT),)
export GOROOT
endif
2013-11-20 20:53:43 +00:00
cflags =
ifeq ($(arch),386)
cflags = -m32
else
ifeq ($(arch),arm)
cflags = -fpic
endif
endif
ifneq ($(arch),)
2013-11-20 20:53:43 +00:00
GOARCH = $(arch)
endif
ifneq ($(CROSS_COMPILE),)
export CXX=$(CROSS_COMPILE)-g++
export CC=$(CROSS_COMPILE)-gcc
export AS=$(CROSS_COMPILE)-as
export AR=$(CROSS_COMPILE)-ar
export NM=$(CROSS_COMPILE)-nm
export LD=$(CROSS_COMPILE)-ld
export OBJDUMP=$(CROSS_COMPILE)-objdump
export OBJCOPY=$(CROSS_COMPILE)-objcopy
export RANLIB=$(CROSS_COMPILE)-ranlib
export STRIP=$(CROSS_COMPILE)-strip
export CXX_FOR_TARGET=$(CROSS_COMPILE)-g++
export CC_FOR_TARGET=$(CROSS_COMPILE)-gcc
GO_BUILD_OPTIONS += -ldflags="-extld=$(CC)"
cross_flags = --host=$(arch)
endif
2013-11-20 20:53:43 +00:00
export GOARCH
export CGO_ENABLED
2014-10-21 16:07:40 +00:00
.PHONY: all valgrind parser package replace_version_string build build_binary build_benchmark binary_package dependencies clean
2013-11-20 20:53:43 +00:00
2014-10-21 16:07:40 +00:00
all: | parser valgrind test integration_test
2013-12-04 17:35:41 +00:00
parser:
$(MAKE) -C parser
2013-11-20 20:53:43 +00:00
2014-07-22 16:31:35 +00:00
root := $(shell pwd)/../../../..
ifeq ($(GOPATH),)
2014-07-22 16:31:35 +00:00
GOPATH := $(root)
2013-11-20 20:53:43 +00:00
export GOPATH
endif
2013-11-20 20:53:43 +00:00
uname_S = $(shell sh -c "uname -s 2>/dev/null || echo not")
2013-12-18 20:28:53 +00:00
valgrind:
ifeq ($(uname_S),Linux)
$(MAKE) -C parser valgrind
2013-12-18 20:28:53 +00:00
endif
2013-11-20 20:53:43 +00:00
# packages
2014-10-27 22:08:45 +00:00
test_packages = $(shell sh -c "go list github.com/influxdb/influxdb/... | egrep -v 'integration|tools'")
ifneq ($(packages),)
test_packages = $(addprefix github.com/influxdb/influxdb/,$(packages))
endif
2013-11-20 20:53:43 +00:00
# Storage engines libraries
2013-11-20 20:53:43 +00:00
# snappy variables
snappy_version = 1.1.0
snappy_dir = ${TMPDIR}/snappy.influxdb.$(arch)
2013-11-20 20:53:43 +00:00
snappy_file = snappy-$(snappy_version).tar.gz
snappy_deps = $(snappy_dir)/.libs/libsnappy.a
# leveldb variables
2014-04-01 15:48:07 +00:00
leveldb_version = 1.15.0
leveldb_dir = ${TMPDIR}/leveldb.influxdb.$(arch)
2013-11-20 20:53:43 +00:00
leveldb_file = leveldb-$(leveldb_version).tar.gz
leveldb_deps = $(leveldb_dir)/libleveldb.a
2014-06-19 14:27:54 +00:00
cpp_47 = $(shell g++ -dumpversion | gawk '{print $$1>=4.7?"1":"0"}')
ifneq ($(ROCKSDB_LIB),yes)
rocksdb = yes
ifneq ($(cpp_47),1)
rocksdb = no
endif
endif
ifeq ($(rocksdb),yes)
2014-06-17 15:26:33 +00:00
# rocksdb variables
2014-10-10 18:10:07 +00:00
rocksdb_version = rocksdb-3.5.1
rocksdb_dir = ${TMPDIR}/rocksdb.influxdb.$(arch)
rocksdb_file = $(rocksdb_version).tar.gz
2014-06-17 15:26:33 +00:00
rocksdb_deps = $(rocksdb_dir)/librocksdb.a
endif
2014-06-17 15:26:33 +00:00
2014-06-17 19:00:47 +00:00
# hyperleveldb variables
hyperleveldb_version = v1.0.3
hyperleveldb_dir = ${TMPDIR}/hyperleveldb.influxdb.$(arch)
2014-06-17 19:00:47 +00:00
hyperleveldb_file = $(hyperleveldb_version).tar.gz
hyperleveldb_deps = $(hyperleveldb_dir)/.libs/libhyperleveldb.a
profile=off
ifneq ($(profile),off)
2014-06-21 21:43:02 +00:00
GO_BUILD_TAGS += profile
endif
2013-11-20 20:53:43 +00:00
# levigo flags
2013-11-26 19:08:51 +00:00
ifeq ($(uname_S),Linux)
storage_engines += $(hyperleveldb_deps)
2014-06-21 21:43:02 +00:00
GO_BUILD_TAGS += hyperleveldb
ifeq ($(rocksdb),yes)
2014-06-21 21:43:02 +00:00
GO_BUILD_TAGS += rocksdb
storage_engines += $(rocksdb_deps)
CGO_CFLAGS += -I$(rocksdb_dir)/include
CGO_LDFLAGS += -L$(rocksdb_dir) -lrocksdb $(LRT_LDFLAG)
else
ifeq ($(ROCKSDB_LIB),yes)
GO_BUILD_TAGS += rocksdb
CGO_LDFLAGS += -lrocksdb $(LRT_LDFLAG)
endif
endif
CGO_CFLAGS += -I$(leveldb_dir)/include -I$(hyperleveldb_dir)/include
CGO_LDFLAGS += -L$(leveldb_dir) -L$(hyperleveldb_dir)/.libs -L$(snappy_dir)/.libs -lleveldb -lhyperleveldb -lsnappy
CPPLIB = $(shell g++ $(cflags) --print-file-name=libstdc++.a)
CGO_LDFLAGS += -lm -lz -lbz2 $(CPPLIB)
2013-11-20 20:53:43 +00:00
export CGO_CFLAGS
export CGO_LDFLAGS
2013-11-26 19:08:51 +00:00
else
2014-06-19 14:27:54 +00:00
CGO_LDFLAGS += -lleveldb -lsnappy -lstdc++
2013-11-26 19:08:51 +00:00
export CGO_LDFLAGS
endif
2014-06-21 21:43:02 +00:00
ifneq ($(GO_BUILD_TAGS),)
GO_BUILD_OPTIONS += -tags '$(GO_BUILD_TAGS)'
endif
race = off
ifneq ($(race),off)
GO_BUILD_OPTIONS += -race
endif
2014-06-21 21:43:02 +00:00
2014-09-04 19:16:21 +00:00
benchmark = off
ifneq ($(benchmark),off)
GOTEST_OPTS += --gocheck.b --gocheck.btime=30s
endif
2013-11-26 19:08:51 +00:00
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)
2014-10-24 21:22:07 +00:00
( cd $(snappy_dir); wget https://snappy.googlecode.com/files/$(snappy_file); \
2013-11-20 20:53:43 +00:00
tar --strip-components=1 -xvzf $(snappy_file); \
2014-10-24 21:22:07 +00:00
CFLAGS='$(cflags)' CXXFLAGS='$(cflags)' ./configure --enable-shared=no $(cross_flags) )
$(MAKE) -C $(snappy_dir)
2013-11-20 20:53:43 +00:00
endif
$(leveldb_deps): $(snappy_deps)
ifeq ($(uname_S),Linux)
rm -rf $(leveldb_dir)
mkdir -p $(leveldb_dir)
2014-10-24 21:22:07 +00:00
( cd $(leveldb_dir); wget https://leveldb.googlecode.com/files/$(leveldb_file); tar --strip-components=1 -xvzf $(leveldb_file); )
CFLAGS='-I$(snappy_dir) $(cflags)' CXXFLAGS='-I$(snappy_dir) $(cflags)' LDFLAGS='-L$(snappy_dir)/.libs' $(MAKE) -C $(leveldb_dir) libleveldb.a
2014-06-17 15:26:33 +00:00
endif
$(rocksdb_deps): $(snappy_deps)
2014-06-17 15:26:33 +00:00
ifeq ($(uname_S),Linux)
rm -rf $(rocksdb_dir)
mkdir -p $(rocksdb_dir)
2014-10-24 21:22:07 +00:00
( cd $(rocksdb_dir); wget -O $(rocksdb_file) https://github.com/facebook/rocksdb/archive/$(rocksdb_file); \
tar --strip-components=1 -xvzf $(rocksdb_file); )
CFLAGS='-I$(snappy_dir) $(cflags)' CXXFLAGS='-I$(snappy_dir) $(cflags)' LDFLAGS='-L$(snappy_dir)/.libs $(LRT_LDFLAG)' $(MAKE) -C $(rocksdb_dir) librocksdb.a
2013-11-20 20:53:43 +00:00
endif
$(hyperleveldb_deps): $(snappy_deps)
2014-06-17 19:00:47 +00:00
ifeq ($(uname_S),Linux)
rm -rf $(hyperleveldb_dir)
mkdir -p $(hyperleveldb_dir)
2014-10-24 21:22:07 +00:00
( cd $(hyperleveldb_dir); wget https://github.com/influxdb/HyperLevelDB/archive/$(hyperleveldb_file) -O $(hyperleveldb_file); \
2014-06-17 19:00:47 +00:00
tar --strip-components=1 -xvzf $(hyperleveldb_file); \
2014-10-24 21:22:07 +00:00
$(AUTORECONF) -i; CXXFLAGS='-I$(snappy_dir) $(cflags)' CFLAGS='-I$(snappy_dir) $(cflags)' LDFLAGS='-L$(snappy_dir)/.libs' ./configure --enable-shared=no )
$(MAKE) -C $(hyperleveldb_dir) V=1
2014-06-17 19:00:47 +00:00
endif
storage_engines += $(leveldb_deps)
2014-10-20 17:27:03 +00:00
dependencies: $(storage_engines)
$(GO) get $(GO_BUILD_OPTIONS) -d -t github.com/influxdb/influxdb/...
2013-11-20 20:53:43 +00:00
2014-07-22 16:31:35 +00:00
$(root)/bin/protoc-gen-go:
2014-10-20 17:27:03 +00:00
$(GO) get code.google.com/p/goprotobuf/protoc-gen-go
2014-07-22 16:31:35 +00:00
protobuf: $(root)/bin/protoc-gen-go
rm -f protocol/*.pb.go
2014-07-22 16:31:35 +00:00
PATH=$(root)/bin:$$PATH $(PROTOC) --go_out=. protocol/*.proto
2013-11-20 20:53:43 +00:00
2014-10-21 16:07:40 +00:00
pre_build: dependencies protobuf parser build_version_string
build_benchmark: pre_build
$(GO) build -o benchmark-storage $(GO_BUILD_OPTIONS) github.com/influxdb/influxdb/tools/benchmark-storage
$(GO) build -o benchmark-tool github.com/influxdb/influxdb/tools/benchmark
2013-11-20 20:53:43 +00:00
2014-10-21 16:07:40 +00:00
build_binary: pre_build
$(GO) build -o influxdb $(GO_BUILD_OPTIONS) github.com/influxdb/influxdb/daemon
build: build_binary build_benchmark
2013-11-20 20:53:43 +00:00
clean:
2014-06-27 14:57:40 +00:00
git status --ignored | grep src\/ | grep -v Makefile | xargs rm -rf
rm -rf ${TMPDIR}/influxdb
rm -rf $(snappy_dir)
rm -rf $(leveldb_dir)
rm -rf $(hyperleveldb_dir)
rm -rf $(rocksdb_dir)
$(MAKE) -C parser clean
$(GO) get -u $(GO_BUILD_OPTIONS) -d -t github.com/influxdb/influxdb/...
2013-11-20 20:53:43 +00:00
rebuild_static_assets:
$(GO) get github.com/rakyll/statik
$(GOPATH)/bin/statik -src=./shared/admin
$(MAKE) format
2013-11-20 20:53:43 +00:00
only =
verbose = off
ifneq ($(only),)
2014-09-04 19:16:21 +00:00
GOTEST_OPTS += -gocheck.f '$(only)'
2013-11-20 20:53:43 +00:00
endif
ifneq ($(verbose),off)
2013-12-23 22:30:21 +00:00
GOTEST_OPTS += -v -gocheck.v -gocheck.vv
2013-11-20 20:53:43 +00:00
endif
version=
ifeq ($(version),)
version = "dev"
endif
2014-09-24 20:26:11 +00:00
timeout = 20m
GOTEST_OPTS += -test.timeout=$(timeout)
2014-10-20 17:27:03 +00:00
test: dependencies parser protobuf
$(GO) test $(test_packages) $(GOTEST_OPTS)
2013-11-20 20:53:43 +00:00
2014-10-20 17:27:03 +00:00
coverage: dependencies
2014-10-27 22:08:45 +00:00
for i in $(test_packages); do $(GO) test -coverprofile ${TMPDIR}/influxdb.$${i/\//}.coverage $$i $(GOTEST_OPTS); \
$(GO) tool cover -html=${TMPDIR}/influxdb.$${i/\//}.coverage; done
2013-11-20 20:53:43 +00:00
2014-10-21 16:07:40 +00:00
integration_test: dependencies build_binary
$(GO) test github.com/influxdb/influxdb/integration $(GOTEST_OPTS)
2013-11-20 20:53:43 +00:00
package_version=$(subst -,_,$(version))
2013-11-26 22:23:47 +00:00
2014-02-25 22:57:54 +00:00
source_package = packages/influxdb-$(version).src.tar.gz
binary_package = packages/influxdb-$(version).$(arch).tar.gz
2014-10-24 21:54:01 +00:00
rpm_args =
2013-11-26 22:23:47 +00:00
ifeq ($(arch),386)
rpm_package = packages/influxdb-$(package_version)-1.i686.rpm
debian_package = packages/influxdb_$(version)_i686.deb
deb_args = -a i686
rpm_args = setarch i686
else ifeq ($(arch),arm)
2014-05-28 23:33:45 +00:00
rpm_package = packages/influxdb-$(package_version)-1.armel.rpm
debian_package = packages/influxdb_$(version)_armel.deb
2013-11-26 22:23:47 +00:00
else
rpm_package = packages/influxdb-$(package_version)-1.x86_64.rpm
2014-02-25 22:57:54 +00:00
debian_package = packages/influxdb_$(version)_amd64.deb
2013-11-26 22:23:47 +00:00
endif
2014-10-21 16:07:40 +00:00
package_files = $(binary_package) $(debian_package) $(rpm_package) $(source_package)
2014-05-13 20:59:21 +00:00
sha1 = $(shell sh -c "git rev-list --max-count=1 --abbrev-commit HEAD")
2013-11-26 22:23:47 +00:00
build_version_string:
2014-10-21 16:07:40 +00:00
echo "package main" > daemon/version.go
echo "const version = \"$(version)\"" >> daemon/version.go
echo "const gitSha = \"$(sha1)\"" >> daemon/version.go
package_version_string: build_version_string
2013-11-26 22:23:47 +00:00
sed -i.bak -e "s/REPLACE_VERSION/$(version)/" scripts/post_install.sh
2014-10-21 16:07:40 +00:00
$(rpm_package): $(binary_package)
2013-11-26 22:23:47 +00:00
rm -rf out_rpm
mkdir -p out_rpm/opt/influxdb/versions/$(version)
cp -r build/* out_rpm/opt/influxdb/versions/$(version)
2014-10-24 22:37:11 +00:00
# `$(rpm_args)` has to follow the command directory. `rpm_args` gets set to setarch
# which changes the output of `uname -m` to the desired architecture and runs the
# following command. Without any commands to follow `setarch` will start an interactive
# shell and pause the package process
2014-10-24 21:54:01 +00:00
( rvm use 1.9.3@influxdb && cd out_rpm && $(rpm_args) fpm -s dir -t rpm --after-install ../scripts/post_install.sh -n influxdb -v $(version) . )
2013-11-26 22:23:47 +00:00
mv out_rpm/$(shell basename $(rpm_package)) packages/
2014-10-21 16:07:40 +00:00
$(debian_package): $(binary_package)
2013-11-26 22:23:47 +00:00
rm -rf out_rpm
mkdir -p out_rpm/opt/influxdb/versions/$(version)
cp -r build/* out_rpm/opt/influxdb/versions/$(version)
( rvm use 1.9.3@influxdb && cd out_rpm && fpm -s dir -t deb $(deb_args) --after-install ../scripts/post_install.sh -n influxdb -v $(version) . )
2013-11-26 22:23:47 +00:00
mv out_rpm/$(shell basename $(debian_package)) packages/
$(source_package): dependencies
rm -f influxdb
git ls-files --others | egrep -v 'version.go' > ${TMPDIR}/influxdb.ignored
echo "pkg/*" >> ${TMPDIR}/influxdb.ignored
echo "bin/*" >> ${TMPDIR}/influxdb.ignored
echo "packages/*" >> ${TMPDIR}/influxdb.ignored
echo "build/*" >> ${TMPDIR}/influxdb.ignored
echo "out_rpm/*" >> ${TMPDIR}/influxdb.ignored
rm -rf ${TMPDIR}/influxdb.gopath
mkdir -p ${TMPDIR}/influxdb.gopath/src/github.com/influxdb/
cp -R $(shell pwd) ${TMPDIR}/influxdb.gopath/src/github.com/influxdb/
GOPATH=${TMPDIR}/influxdb.gopath $(MAKE) -C ${TMPDIR}/influxdb.gopath/src/github.com/influxdb/influxdb build
tar -hcvzf $(source_package) -C ${TMPDIR}/influxdb.gopath -X ${TMPDIR}/influxdb.ignored .
2013-11-26 22:23:47 +00:00
$(binary_package): build packages
2013-11-26 22:23:47 +00:00
rm -rf build
mkdir build
2014-07-15 14:52:07 +00:00
mv influxdb build/
mv benchmark-tool build/influxdb-benchmark
cp tools/benchmark/benchmark_config.sample.toml build/benchmark_config.toml
2013-11-26 22:23:47 +00:00
cp -R scripts/ build/
cp config.sample.toml build/config.toml
2013-12-12 16:27:00 +00:00
sed -i 's/influxdb.log/\/opt\/influxdb\/shared\/log.txt/g' build/config.toml
sed -i 's:${TMPDIR}/influxdb/development/db:/opt/influxdb/shared/data/db:g' build/config.toml
sed -i 's:${TMPDIR}/influxdb/development/raft:/opt/influxdb/shared/data/raft:g' build/config.toml
sed -i 's:${TMPDIR}/influxdb/development/wal:/opt/influxdb/shared/data/wal:g' build/config.toml
2013-11-26 22:23:47 +00:00
rm -f build/scripts/post_install.sh.bak
tar -czf $(binary_package) build/*
binary_package: $(binary_package)
2014-10-21 16:07:40 +00:00
source_package: $(source_package)
distro_packages: $(rpm_package) $(debian_package)
2013-11-26 22:23:47 +00:00
packages:
mkdir $@
2014-08-15 17:47:01 +00:00
flymake:
for i in $(packages); do $(GO) build $$i; done
flymake_test:
for i in $(packages); do $(GO) test -c $$i; done
2014-10-21 16:07:40 +00:00
package: | packages build package_version_string $(package_files)
2013-11-26 22:23:47 +00:00
mv -f scripts/post_install.sh.bak scripts/post_install.sh
2014-06-23 16:52:39 +00:00
install: binary_package
rm -rf /opt/influxdb/versions/dev
mkdir -p /opt/influxdb/versions/dev
mkdir -p /opt/influxdb/shared
ln -sfn /opt/influxdb/versions/dev /opt/influxdb/current
cp -r build/* /opt/influxdb/current/
cp /opt/influxdb/current/config.toml /opt/influxdb/shared
ln -sfn /opt/influxdb/current/influxdb /usr/bin/influxdb
ln -sfn /opt/influxdb/current/influxdb-daemon.sh /usr/bin/influxdb-daemon
ln -sfn /opt/influxdb/current/scripts/init.sh /etc/init.d/influxdb
touch /opt/influxdb/shared/log.txt
chown -R -L influxdb:influxdb /opt/influxdb
chmod -R a+rX /opt/influxdb
uninstall:
rm -rf /opt/influxdb
rm -f /usr/bin/influxdb
rm -f /usr/bin/influxdb-daemon
rm -f /etc/init.d/influxdb
2014-06-23 16:53:50 +00:00
check:
./.hooks/pre-commit
2014-06-23 16:52:39 +00:00
vet:
2014-06-23 18:43:49 +00:00
git ls-files | grep '.go$$' | while read i; do $(GO) vet $$i 2>&1; done | grep -v exit\ status | grep -v pb.go | grep -v Error\ call
2014-06-23 16:52:39 +00:00
format:
2014-06-23 18:43:49 +00:00
git ls-files | grep '.go$$' | xargs $(GOFMT) -w -s
2014-09-18 15:48:52 +00:00
oracle:
$$GOPATH/bin/oracle $(oracle_args)