-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
139 lines (110 loc) · 3.5 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
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
#
# Makefile for juju-core.
#
ifndef GOPATH
$(warning You need to set up a GOPATH. See the README file.)
endif
PROJECT := github.com/juju/juju
PROJECT_DIR := $(shell go list -e -f '{{.Dir}}' $(PROJECT))
# Allow the tests to take longer on arm platforms.
ifeq ($(shell uname -p | sed -r 's/.*(armel|armhf|aarch64).*/golang/'), golang)
TEST_TIMEOUT := 2400s
else
TEST_TIMEOUT := 1500s
endif
ifeq ($(shell uname -p | sed -r 's/.*(86|armel|armhf|aarch64|ppc64le|s390x).*/golang/'), golang)
GO_C = golang-1.8
INSTALL_FLAGS =
else
GO_C = gccgo-4.9 gccgo-go
INSTALL_FLAGS = -gccgoflags=-static-libgo
endif
define DEPENDENCIES
ca-certificates
bzip2
bzr
distro-info-data
git
zip
endef
default: build
# Start of GOPATH-dependent targets. Some targets only make sense -
# and will only work - when this tree is found on the GOPATH.
ifeq ($(CURDIR),$(PROJECT_DIR))
ifeq ($(JUJU_MAKE_GODEPS),true)
$(GOPATH)/bin/godeps:
go get github.com/rogpeppe/godeps
godeps: $(GOPATH)/bin/godeps
$(GOPATH)/bin/godeps -u dependencies.tsv
else
godeps:
@echo "skipping godeps"
endif
build: godeps
go build $(PROJECT)/...
check: godeps
go test -test.timeout=$(TEST_TIMEOUT) $(PROJECT)/...
install: godeps
go install $(INSTALL_FLAGS) -v $(PROJECT)/...
clean:
go clean $(PROJECT)/...
else # --------------------------------
build:
$(error Cannot $@; $(CURDIR) is not on GOPATH)
check:
$(error Cannot $@; $(CURDIR) is not on GOPATH)
install:
$(error Cannot $@; $(CURDIR) is not on GOPATH)
clean:
$(error Cannot $@; $(CURDIR) is not on GOPATH)
endif
# End of GOPATH-dependent targets.
# Reformat source files.
format:
gofmt -w -l .
# Reformat and simplify source files.
simplify:
gofmt -w -l -s .
rebuild-dependencies.tsv: godeps
# godeps invoked this way includes 'github.com/juju/juju' as part of
# the content, which we want to filter out.
# '-t' is not needed on newer versions of godeps, but is still supported.
godeps -t ./... | grep -v "^github.com/juju/juju\s" > dependencies.tsv
# Install packages required to develop Juju and run tests. The stable
# PPA includes the required mongodb-server binaries.
install-dependencies:
@echo Adding juju PPAs for golang and juju
@sudo apt-add-repository --yes ppa:juju/stable
@sudo apt-get update
@echo Installing dependencies
@sudo apt-get --yes install \
$(strip $(DEPENDENCIES)) \
$(shell apt-cache madison juju-mongodb3.2 juju-mongodb mongodb-server | head -1 | cut -d '|' -f1)
# Install bash_completion
install-etc:
@echo Installing bash completion
@sudo install -o root -g root -m 644 etc/bash_completion.d/juju-2.0 /usr/share/bash-completion/completions
@sudo install -o root -g root -m 644 etc/bash_completion.d/juju-version /usr/share/bash-completion/completions
setup-lxd:
ifeq ($(shell ifconfig lxdbr0 2>&1 | grep -q "inet addr" && echo true),true)
@echo IPv4 networking is already setup for LXD.
@echo run "sudo scripts/setup-lxd.sh" to reconfigure IPv4 networking
else
@echo Setting up IPv4 networking for LXD
@sudo scripts/setup-lxd.sh || true
endif
GOCHECK_COUNT="$(shell go list -f '{{join .Deps "\n"}}' github.com/juju/juju/... | grep -c "gopkg.in/check.v*")"
check-deps:
@echo "$(GOCHECK_COUNT) instances of gocheck not in test code"
install-go:
@echo Adding juju PPAs for golang and juju
@sudo apt-add-repository -y ppa:juju/golang
@sudo apt-get update
@echo Installing $(GO_C)
@sudo apt-get -y install $(GO_C)
.PHONY: build check install
.PHONY: clean format simplify
.PHONY: install-dependencies
.PHONY: rebuild-dependencies.tsv
.PHONY: check-deps
.PHONY: install-go