-
Notifications
You must be signed in to change notification settings - Fork 22
/
Makefile
95 lines (68 loc) · 2.66 KB
/
Makefile
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
#Copyright (c) 2014 Megam Systems.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
# Makefile to compile cib.
# lists all the dependencies for test, prod and we can run a go build aftermath.
###############################################################################
GOPATH := $(GOPATH):$(shell pwd)/../../../../
define HG_ERROR
FATAL: you need mercurial (hg) to download vertice dependencies.
Check README.md for details
endef
define GIT_ERROR
FATAL: you need git to download vertice dependencies.
Check README.md for details
endef
define BZR_ERROR
FATAL: you need bazaar (bzr) to download vertice dependencies.
Check README.md for details
endef
.PHONY: all check-path get hg git bzr get-code test
all: check-path get test
build: check-path get _go_test _vertice
# It does not support GOPATH with multiple paths.
check-path:
ifndef GOPATH
@echo "FATAL: you must declare GOPATH environment variable, for more"
@echo " details, please check README.md file and/or"
@echo " http://golang.org/cmd/go/#GOPATH_environment_variable"
@exit 1
endif
@exit 0
get: hg git bzr get-code godep
hg:
$(if $(shell hg), , $(error $(HG_ERROR)))
git:
$(if $(shell git), , $(error $(GIT_ERROR)))
bzr:
$(if $(shell bzr), , $(error $(BZR_ERROR)))
get-code:
rm -rf ~/.go
go get $(GO_EXTRAFLAGS) -u -d -t -insecure ./...
godep:
go get $(GO_EXTRAFLAGS) github.com/tools/godep
godep restore ./...
_go_test:
go clean $(GO_EXTRAFLAGS) ./...
go test $(GO_EXTRAFLAGS) ./...
_vertice:
rm -f vertice
go build $(GO_EXTRAFLAGS) -ldflags="-X main.date=$(shell date +%Y-%m-%d_%H:%M:%S%Z) -X main.commit=$(shell commit=`git rev-parse HEAD`; cd $$HOME/.go/src/github.com/megamsys/libgo && libcommit=`git rev-parse HEAD`; echo $$commit"_lib_"$$libcommit)" -o vertice ./cmd/vertice
_verticer:
./vertice -v start --config $(MEGAM_HOME)/vertice/vertice.conf
test: _go_test _vertice _verticer
_install_deadcode: git
go get $(GO_EXTRAFLAGS) github.com/remyoudompheng/go-misc/deadcode
deadcode: _install_deadcode
@go list ./... | sed -e 's;github.com/megamsys/vertice/;;' | xargs deadcode