forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
271 lines (223 loc) · 8.03 KB
/
Makefile.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
SHELL = /bin/bash
PROTOC = @PROTOC@
GO = @GO@
GOROOT = @GOROOT@
# or 386
arch = amd64
CGO_ENABLED = 1
ifneq ($(GOROOT),)
export GOROOT
endif
cflags =
ifeq ($(arch),386)
cflags = -m32
GOARCH = $(arch)
endif
export GOARCH
export CGO_ENABLED
.PHONY: all valgrind parser package replace_version_string build binary_package dependencies
all: | parser valgrind build test integration_test
parser:
$(MAKE) -C src/parser
GOPATH := $(shell pwd)
export GOPATH
uname_S = $(shell sh -c "uname -s 2>/dev/null || echo not")
valgrind:
ifeq ($(uname_S),Linux)
$(MAKE) -C src/parser valgrind
endif
# packages
packages = admin api/http api/graphite cluster common configuration \
checkers coordinator datastore engine parser protocol wal
# 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.15.0
leveldb_dir = /tmp/leveldb.influxdb.$(arch)
leveldb_file = leveldb-$(leveldb_version).tar.gz
leveldb_deps = $(leveldb_dir)/libleveldb.a
profile=off
ifneq ($(profile),off)
CGO_LDFLAGS += -ltcmalloc -lprofiler
GO_BUILD_OPTIONS = -tags profile
endif
# levigo flags
ifeq ($(uname_S),Linux)
CGO_CFLAGS += -I$(leveldb_dir)/include
CGO_LDFLAGS += $(leveldb_dir)/libleveldb.a $(snappy_dir)/.libs/libsnappy.a -lstdc++
export CGO_CFLAGS
export CGO_LDFLAGS
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
$(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
levigo_dependency = github.com/jmhodges/levigo
proto_dependency = code.google.com/p/goprotobuf/protoc-gen-go
dependencies = code.google.com/p/go.crypto/bcrypt \
code.google.com/p/goprotobuf/proto \
code.google.com/p/log4go \
github.com/bmizerany/pat \
github.com/fitstar/falcore \
github.com/fitstar/falcore/filter \
github.com/gorilla/mux \
github.com/goraft/raft \
github.com/influxdb/go-cache \
github.com/BurntSushi/toml \
github.com/influxdb/influxdb-go \
code.google.com/p/gogoprotobuf/proto \
$(proto_dependency)
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 -d $$i; done
dependencies: src/$(levigo_dependency) $(dependencies_paths) $(leveldb_deps) $(snappy_deps)
test_dependencies: dependencies
$(GO) get launchpad.net/gocheck
protobuf:
$(GO) get $(proto_dependency)
rm -f src/protocol/*.pb.go
PATH=$$PWD/bin:$$PATH $(PROTOC) --go_out=. src/protocol/*.proto
build: | dependencies protobuf parser build_version_string
# TODO: build all packages, otherwise we won't know
# if there's an error
$(GO) build $(GO_BUILD_OPTIONS) daemon
$(GO) build benchmark
clean:
rm -f daemon
rm -f benchmark
rm -rf pkg/
rm -rf packages/
rm -rf src/$(levigo_dependency)
rm -rf /tmp/influxdb
rm -rf /tmp/admin.influxdb
$(MAKE) -C src/parser clean
only =
verbose = off
ifneq ($(only),)
GOTEST_OPTS = -gocheck.f '$(only)'
endif
ifneq ($(verbose),off)
GOTEST_OPTS += -v -gocheck.v -gocheck.vv
endif
version=
ifeq ($(version),)
version = "dev"
endif
timeout = 10m
GOTEST_OPTS += -test.timeout=$(timeout)
test: test_dependencies parser protobuf
$(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 build
$(GO) test integration $(GOTEST_OPTS)
package_version=$(subst -,_,$(version))
admin_dir = /tmp/admin.influxdb
source_package = packages/influxdb-$(version).src.tar.gz
binary_package = packages/influxdb-$(version).$(arch).tar.gz
ifeq ($(arch),386)
rpm_package = packages/influxdb-$(package_version)-1.i686.rpm
debian_package = packages/influxdb_$(version)_i386.deb
rpm_args = setarch i386
deb_args = -a i386
else
rpm_package = packages/influxdb-$(package_version)-1.x86_64.rpm
debian_package = packages/influxdb_$(version)_amd64.deb
endif
files = $(binary_package) $(debian_package) $(rpm_package) $(source_package)
sha1 = $(shell sh -c "git rev-list --max-count=1 --abbrev-commit HEAD")
build_version_string:
@echo "package main" > src/daemon/version.go
@echo "const version = \"$(version)\"" >> src/daemon/version.go
@echo "const gitSha = \"$(sha1)\"" >> src/daemon/version.go
package_version_string: build_version_string
sed -i.bak -e "s/REPLACE_VERSION/$(version)/" scripts/post_install.sh
$(admin_dir)/build:
rm -rf $(admin_dir)
rvm 1.9.3 do rvm gemset create influxdb
git clone https://github.com/influxdb/influxdb-admin.git $(admin_dir)
rvm 1.9.3@influxdb do bash -c "pushd $(admin_dir); bundle install; middleman build; popd"
$(rpm_package): $(admin_dir)/build build
rm -rf out_rpm
mkdir -p out_rpm/opt/influxdb/versions/$(version)
cp -r build/* out_rpm/opt/influxdb/versions/$(version)
rvm 1.9.3@influxdb do bash -c "pushd out_rpm; $(rpm_args) fpm -s dir -t rpm --after-install ../scripts/post_install.sh -n influxdb -v $(version) .; popd"
mv out_rpm/$(shell basename $(rpm_package)) packages/
$(debian_package): $(admin_dir)/build build
rm -rf out_rpm
mkdir -p out_rpm/opt/influxdb/versions/$(version)
cp -r build/* out_rpm/opt/influxdb/versions/$(version)
rvm 1.9.3@influxdb do bash -c "pushd out_rpm; fpm -s dir -t deb $(deb_args) --after-install ../scripts/post_install.sh -n influxdb -v $(version) .; popd"
mv out_rpm/$(shell basename $(debian_package)) packages/
$(source_package): dependencies
rm -rf src/$(levigo_dependency)
$(GO) get -d $(levigo_dependency)
rm -f daemon
rm -f benchmark
git ls-files --others | egrep -v 'github|launchpad|code.google|version.go' > /tmp/influxdb.ignored
echo "pkg/*" >> /tmp/influxdb.ignored
echo "packages/*" >> /tmp/influxdb.ignored
echo "build/*" >> /tmp/influxdb.ignored
echo "out_rpm/*" >> /tmp/influxdb.ignored
rm -rf admin
cp -R $(admin_dir)/build admin
tar -czf $(source_package) --exclude-vcs -X /tmp/influxdb.ignored *
rm -rf /tmp/influxdb
mkdir /tmp/influxdb
tar -xzf $(source_package) -C /tmp/influxdb
rm $(source_package)
bash -c "pushd /tmp/; tar -czf `basename $(source_package)` influxdb; popd"
mv /tmp/$(shell basename $(source_package)) $(source_package)
rm -rf src/$(levigo_dependency)
rm -rf admin
$(binary_package): $(admin_dir)/build build packages
rm -rf build
mkdir build
mv daemon build/influxdb
mv benchmark build/influxdb-benchmark
cp src/benchmark/benchmark_config.sample.toml build/benchmark_config.toml
mkdir build/admin
cp -R $(admin_dir)/build/* build/admin/
cp -R scripts/ build/
cp config.sample.toml build/config.toml
sed -i 's/.\/admin/\/opt\/influxdb\/current\/admin/g' build/config.toml
sed -i 's/influxdb.log/\/opt\/influxdb\/shared\/log.txt/g' build/config.toml
sed -i 's/\/tmp\/influxdb\/development\/db/\/opt\/influxdb\/shared\/data\/db/g' build/config.toml
sed -i 's/\/tmp\/influxdb\/development\/raft/\/opt\/influxdb\/shared\/data\/raft/g' build/config.toml
sed -i 's/\/tmp\/influxdb\/development\/wal/\/opt\/influxdb\/shared\/data\/wal/g' build/config.toml
rm -f build/scripts/post_install.sh.bak
tar -czf $(binary_package) build/*
binary_package: $(binary_package)
packages:
mkdir $@
package: | packages build package_version_string $(files)
mv -f scripts/post_install.sh.bak scripts/post_install.sh