forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
389 lines (324 loc) · 11.9 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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
SHELL = /bin/bash
ifeq ($(TMPDIR),)
TMPDIR=/tmp
endif
export TMPDIR
PROTOC = @PROTOC@
GO = @GO@
GOFMT = @GOFMT@
GOROOT = @GOROOT@
AUTORECONF = @AUTORECONF@
# or 386, arm
arch = amd64
CGO_ENABLED = 1
ifneq ($(GOROOT),)
export GOROOT
endif
cflags =
ifeq ($(arch),386)
cflags = -m32
else
ifeq ($(arch),arm)
cflags = -fpic
endif
endif
ifneq ($(arch),)
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
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
# Storage engines libraries
# snappy variables
snappy_version = 1.1.0
snappy_dir = ${TMPDIR}/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 = ${TMPDIR}/leveldb.influxdb.$(arch)
leveldb_file = leveldb-$(leveldb_version).tar.gz
leveldb_deps = $(leveldb_dir)/libleveldb.a
cpp_47 = $(shell g++ -dumpversion | gawk '{print $$1>=4.7?"1":"0"}')
rocksdb = yes
ifneq ($(cpp_47),1)
rocksdb = no
endif
ifeq ($(rocksdb),yes)
# rocksdb variables
rocksdb_version = 3.1
rocksdb_dir = ${TMPDIR}/rocksdb.influxdb.$(arch)
rocksdb_file = rocksdb-$(rocksdb_version).tar.gz
rocksdb_deps = $(rocksdb_dir)/librocksdb.a
endif
# hyperleveldb variables
hyperleveldb_version = v1.0.3
hyperleveldb_dir = ${TMPDIR}/hyperleveldb.influxdb.$(arch)
hyperleveldb_file = $(hyperleveldb_version).tar.gz
hyperleveldb_deps = $(hyperleveldb_dir)/.libs/libhyperleveldb.a
profile=off
ifneq ($(profile),off)
CGO_LDFLAGS += -ltcmalloc -lprofiler
GO_BUILD_TAGS += profile
endif
# levigo flags
ifeq ($(uname_S),Linux)
storage_engines += src/$(hyperleveldb_dependency)
GO_BUILD_TAGS += hyperleveldb
ifeq ($(rocksdb),yes)
GO_BUILD_TAGS += rocksdb
storage_engines += src/$(rocksdb_dependency)
CGO_CFLAGS += -I$(rocksdb_dir)/include
CGO_LDFLAGS += $(rocksdb_deps)
endif
CGO_CFLAGS += -I$(leveldb_dir)/include -I$(hyperleveldb_dir)/include
CGO_LDFLAGS += $(leveldb_deps) $(hyperleveldb_deps) -L$(snappy_dir)/.libs -lsnappy
CGO_LDFLAGS += -lstdc++ -lm -lz -lbz2
export CGO_CFLAGS
export CGO_LDFLAGS
else
CGO_LDFLAGS += -lleveldb -lsnappy -lstdc++
export CGO_LDFLAGS
endif
ifneq ($(GO_BUILD_TAGS),)
GO_BUILD_OPTIONS += -tags '$(GO_BUILD_TAGS)'
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 --enable-shared=no $(cross_flags); \
$(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); \
CFLAGS='-I$(snappy_dir) $(cflags)' CXXFLAGS='-I$(snappy_dir) $(cflags)' LDFLAGS='-L$(snappy_dir)/.libs' $(MAKE) libleveldb.a"
endif
$(rocksdb_deps): $(snappy_deps)
ifeq ($(uname_S),Linux)
rm -rf $(rocksdb_dir)
mkdir -p $(rocksdb_dir)
bash -c "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' $(MAKE) librocksdb.a"
endif
$(hyperleveldb_deps): $(snappy_deps)
ifeq ($(uname_S),Linux)
rm -rf $(hyperleveldb_dir)
mkdir -p $(hyperleveldb_dir)
bash -c "cd $(hyperleveldb_dir); \
wget https://github.com/influxdb/HyperLevelDB/archive/$(hyperleveldb_file); \
tar --strip-components=1 -xvzf $(hyperleveldb_file); \
$(AUTORECONF) -i; \
CXXFLAGS='-I$(snappy_dir) $(cflags)' CFLAGS='-I$(snappy_dir) $(cflags)' LDFLAGS='-L$(snappy_dir)/.libs' ./configure --enable-shared=no; \
$(MAKE) V=1"
endif
levigo_dependency = github.com/jmhodges/levigo
rocksdb_dependency = github.com/influxdb/rocksdb
hyperleveldb_dependency = github.com/influxdb/hyperleveldb-go
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 \
github.com/influxdb/gomdb \
code.google.com/p/go.tools/cmd/vet \
$(proto_dependency)
dependencies_paths := $(addprefix src/,$(dependencies))
src/$(levigo_dependency): $(leveldb_deps)
$(GO) get -d $(levigo_dependency)
bash -c "pushd $@; find . -name \*.go | xargs sed -i 's/\/\/ #cgo LDFLAGS: -lleveldb\|#cgo LDFLAGS: -lleveldb//g'; popd"
src/$(rocksdb_dependency): $(rocksdb_deps)
$(GO) get -d $(rocksdb_dependency)
bash -c "pushd $@; find . -name \*.go | xargs sed -i 's/\/\/ #cgo LDFLAGS: -lrocksdb\|#cgo LDFLAGS: -lrocksdb//g'; popd"
src/$(hyperleveldb_dependency): $(hyperleveldb_deps)
$(GO) get -d $(hyperleveldb_dependency)
bash -c "pushd $@; find . -name \*.go | xargs sed -i 's/\/\/ #cgo LDFLAGS: -lhyperleveldb\|#cgo LDFLAGS: -lhyperleveldb//g'; popd"
$(dependencies_paths):
for i in $(dependencies); do $(GO) get -d $$i; done
storage_engines += src/$(levigo_dependency)
dependencies: $(storage_engines) $(dependencies_paths)
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 $(GO_BUILD_OPTIONS) tools/benchmark-storage
$(GO) build benchmark
clean:
git status --ignored | grep src\/ | xargs rm -rf
rm -rf ${TMPDIR}/influxdb
rm -rf ${TMPDIR}/admin.influxdb
rm -rf $(snappy_dir)
rm -rf $(leveldb_dir)
rm -rf $(hyperleveldb_dir)
rm -rf $(rocksdb_dir)
$(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)
bench:
$(GO) test coordinator -test.bench=. -test.benchmem
test: test_dependencies parser protobuf
$(GO) test $(packages) $(GOTEST_OPTS)
coverage: test_dependencies
for i in $(packages); do $(GO) test -coverprofile ${TMPDIR}/influxdb.$${i/\//}.coverage $$i $(GOTEST_OPTS); \
$(GO) tool cover -html=${TMPDIR}/influxdb.$${i/\//}.coverage; done
integration_test: test_dependencies build
$(GO) test integration $(GOTEST_OPTS)
package_version=$(subst -,_,$(version))
admin_dir = ${TMPDIR}/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)_i686.deb
arch_args = -a i686
else ifeq ($(arch),arm)
rpm_package = packages/influxdb-$(package_version)-1.armel.rpm
debian_package = packages/influxdb_$(version)_armel.deb
arch_args = -a armel
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; fpm -s dir -t rpm $(arch_args) --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 $(arch_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' > ${TMPDIR}/influxdb.ignored
echo "pkg/*" >> ${TMPDIR}/influxdb.ignored
echo "packages/*" >> ${TMPDIR}/influxdb.ignored
echo "build/*" >> ${TMPDIR}/influxdb.ignored
echo "out_rpm/*" >> ${TMPDIR}/influxdb.ignored
rm -rf admin
cp -R $(admin_dir)/build admin
tar -czf $(source_package) --exclude-vcs -X ${TMPDIR}/influxdb.ignored *
rm -rf ${TMPDIR}/influxdb
mkdir ${TMPDIR}/influxdb
tar -xzf $(source_package) -C ${TMPDIR}/influxdb
rm $(source_package)
bash -c "pushd ${TMPDIR}/; tar -czf `basename $(source_package)` influxdb; popd"
mv ${TMPDIR}/$(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/\${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
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
check:
./.hooks/pre-commit
vet:
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
format:
git ls-files | grep '.go$$' | xargs $(GOFMT) -w -s