forked from noironetworks/aci-containers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
215 lines (193 loc) · 8.07 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
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
BASE=github.com/noironetworks/aci-containers
METADATA_SRC=$(wildcard pkg/metadata/*.go)
IPAM_SRC=$(wildcard pkg/ipam/*.go)
INDEX_SRC=$(wildcard pkg/index/*.go)
APICAPI_SRC=$(wildcard pkg/apicapi/*.go)
EPRPCCLIENT_SRC=$(wildcard pkg/eprpcclient/*.go)
HOSTAGENT_SRC=$(wildcard cmd/hostagent/*.go pkg/hostagent/*.go)
AGENTCNI_SRC=$(wildcard cmd/opflexagentcni/*.go)
CONTROLLER_SRC=$(wildcard cmd/controller/*.go pkg/controller/*.go)
GBPSERVER_SRC=$(wildcard cmd/gbpserver/*.go pkg/apiserver/*.go)
ACIKUBECTL_SRC=$(wildcard cmd/acikubectl/*.go cmd/acikubectl/cmd/*.go)
OVSRESYNC_SRC=$(wildcard cmd/ovsresync/*.go)
SIMPLESERVICE_SRC=$(wildcard cmd/simpleservice/*.go)
CFAPI_SRC=$(wildcard pkg/cfapi/*.go)
KEYVALUESVC_SRC=$(wildcard pkg/keyvalueservice/*.go)
CF_COMMON_SRC=$(wildcard pkg/cf_common/*.go)
UTIL_SRC=$(wildcard pkg/util/*.go)
DEBIAN_FILES=$(wildcard debian/*)
GOPKG_FILES=$(wildcard Gopkg.*)
HOSTAGENT_DEPS=${METADATA_SRC} ${IPAM_SRC} ${HOSTAGENT_SRC} \
${CF_ETCD_SRC} ${CF_COMMON_SRC} ${KEYVALUESVC_SRC}
AGENTCNI_DEPS=${METADATA_SRC} ${EPRPCCLIENT_SRC} ${AGENTCNI_SRC}
CONTROLLER_DEPS= \
${METADATA_SRC} ${IPAM_SRC} ${INDEX_SRC} \
${APICAPI_SRC} ${CONTROLLER_SRC} \
${CFAPI_SRC} ${CF_COMMON_SRC} ${KEYVALUESVC_SRC}
ACIKUBECTL_DEPS=${METADATA_SRC} ${ACIKUBECTL_SRC}
OVSRESYNC_DEPS=${METADATA_SRC} ${OVSRESYNC_SRC}
SIMPLESERVICE_DEPS=${SIMPLESERVICE_SRC}
DIST_FILE=aci-containers.tgz
DOCKER_HUB_ID ?= noiro
DOCKER_TAG ?=
BUILD_CMD ?= go build -v
TEST_CMD ?= go test -cover
TEST_ARGS ?=
INSTALL_CMD ?= go install -v
GIT_COMMIT=$(shell scripts/getGitCommit.sh)
PKG_NAME_CONTROLLER=github.com/noironetworks/aci-containers/pkg/controller
PKG_NAME_HOSTAGENT=github.com/noironetworks/aci-containers/pkg/hostagent
STATIC_BUILD_CMD ?= CGO_ENABLED=0 GOOS=linux ${BUILD_CMD} \
-ldflags="\
-X ${PKG_NAME_CONTROLLER}.buildTime=$(shell date -u +%m-%d-%Y.%H:%M:%S.UTC) \
-X ${PKG_NAME_CONTROLLER}.gitCommit=${GIT_COMMIT} \
-X ${PKG_NAME_HOSTAGENT}.buildTime=$(shell date -u +%m-%d-%Y.%H:%M:%S.UTC) \
-X ${PKG_NAME_HOSTAGENT}.gitCommit=${GIT_COMMIT} \
-s -w" -a -installsuffix cgo
DOCKER_BUILD_CMD ?= docker build
VENDOR_BUILD_CMD ?= dep ensure -v
.PHONY: clean goinstall check all
all: vendor dist/aci-containers-host-agent dist/opflex-agent-cni \
dist/aci-containers-controller dist/acikubectl dist/ovsresync \
dist/gbpserver
all-static: vendor dist-static/aci-containers-host-agent \
dist-static/opflex-agent-cni dist-static/aci-containers-controller \
dist-static/ovsresync dist-static/gbpserver
go-targets: nodep-opflex-agent-cni nodep-aci-containers-host-agent nodep-aci-containers-controller gbpserver
go-build:
docker run --rm -m 16g -v ${PWD}:/go/src/github.com/noironetworks/aci-containers -w /go/src/github.com/noironetworks/aci-containers --network=host -it noirolabs/gobuild make go-targets
vendor-rebuild: Gopkg.toml
${VENDOR_BUILD_CMD}
vendor: Gopkg.toml
${VENDOR_BUILD_CMD}
# fix etcd repo issue
@rm -f vendor/github.com/coreos/etcd/client/keys.generated.go
clean-dist-static:
rm -rf dist-static/*
clean-dist:
rm -rf dist
clean-vendor:
rm -rf vendor
clean: clean-dist clean-vendor
PACKAGE = aci-containers
VERSION_BASE ?= 1.9.0
VERSION_SUFFIX ?=
VERSION = ${VERSION_BASE}${VERSION_SUFFIX}
BUILD_NUMBER ?= 0
PACKAGE_DIR = ${PACKAGE}-${VERSION}
GOSRC_PATH = ${PACKAGE_DIR}/src/github.com/noironetworks/aci-containers
dist: ${METADATA_SRC} \
${IPAM_SRC} \
${INDEX_SRC} \
${APICAPI_SRC} \
${EPRPCCLIENT_SRC} \
${HOSTAGENT_SRC} \
${AGENTCNI_SRC} \
${CONTROLLER_SRC} \
${ACIKUBECTL_SRC} \
${OVSRESYNC_SRC} \
${SIMPLESERVICE} \
${CF_COMMON_SRC} \
${UTIL_SRC} \
${CFAPI_SRC} \
${KEYVALUESVC_SRC} \
${DEBIAN_FILES} ${GOPKG_FILES} Makefile
- rm -rf ${PACKAGE_DIR}
mkdir -p ${GOSRC_PATH}
cp --parents -r $^ ${GOSRC_PATH}/
mv ${GOSRC_PATH}/debian ${PACKAGE_DIR}/
sed -e "s/@PACKAGE_VERSION@/${VERSION}/" \
-e "s/@BUILD_NUMBER@/${BUILD_NUMBER}/" \
${PACKAGE_DIR}/debian/changelog.in \
> ${PACKAGE_DIR}/debian/changelog
tar cvzf ${DIST_FILE} ${PACKAGE_DIR}
rm -rf ${PACKAGE_DIR}
goinstall:
${INSTALL_CMD} ${BASE}/cmd/opflexagentcni
${INSTALL_CMD} ${BASE}/cmd/controller
${INSTALL_CMD} ${BASE}/cmd/hostagent
${INSTALL_CMD} ${BASE}/cmd/acikubectl
dist/opflex-agent-cni: ${AGENTCNI_DEPS}
${BUILD_CMD} -o $@ ${BASE}/cmd/opflexagentcni
dist-static/opflex-agent-cni: ${AGENTCNI_DEPS}
${STATIC_BUILD_CMD} -o $@ ${BASE}/cmd/opflexagentcni
dist/aci-containers-host-agent: ${HOSTAGENT_DEPS}
${BUILD_CMD} -o $@ ${BASE}/cmd/hostagent
dist-static/aci-containers-host-agent: ${HOSTAGENT_DEPS}
${STATIC_BUILD_CMD} -o $@ ${BASE}/cmd/hostagent
dist/aci-containers-controller: ${CONTROLLER_DEPS}
${BUILD_CMD} -o $@ ${BASE}/cmd/controller
dist-static/aci-containers-controller: ${CONTROLLER_DEPS}
${STATIC_BUILD_CMD} -o $@ ${BASE}/cmd/controller
dist-static/gbpserver:
${STATIC_BUILD_CMD} -o $@ ${BASE}/cmd/gbpserver
dist/gbpserver:
${BUILD_CMD} -o $@ ${BASE}/cmd/gbpserver
gbpserver:
${STATIC_BUILD_CMD} -o dist-static/gbpserver ${BASE}/cmd/gbpserver
nodep-aci-containers-controller:
${STATIC_BUILD_CMD} -o dist-static/aci-containers-controller ${BASE}/cmd/controller
nodep-aci-containers-host-agent:
${STATIC_BUILD_CMD} -o dist-static/aci-containers-host-agent ${BASE}/cmd/hostagent
nodep-opflex-agent-cni:
${STATIC_BUILD_CMD} -o dist-static/opflex-agent-cni ${BASE}/cmd/opflexagentcni
dist/acikubectl: ${ACIKUBECTL_DEPS}
${BUILD_CMD} -o $@ ${BASE}/cmd/acikubectl
dist-static/acikubectl: ${ACIKUBECTL_DEPS}
${STATIC_BUILD_CMD} -o $@ ${BASE}/cmd/acikubectl
dist/ovsresync: ${OVSRESYNC_DEPS}
${BUILD_CMD} -o $@ ${BASE}/cmd/ovsresync
dist-static/ovsresync: ${OVSRESYNC_DEPS}
${STATIC_BUILD_CMD} -o $@ ${BASE}/cmd/ovsresync
dist/simpleservice: ${SIMPLESERVICE_DEPS}
${BUILD_CMD} -o $@ ${BASE}/cmd/simpleservice
dist-static/simpleservice: ${SIMPLESERVICE_DEPS}
${STATIC_BUILD_CMD} -o $@ ${BASE}/cmd/simpleservice
container-gbpserver: dist-static/gbpserver
${DOCKER_BUILD_CMD} -t ${DOCKER_HUB_ID}/gbp-server${DOCKER_TAG} -f ./docker/Dockerfile-gbpserver .
container-host: dist-static/aci-containers-host-agent dist-static/opflex-agent-cni
${DOCKER_BUILD_CMD} -t ${DOCKER_HUB_ID}/aci-containers-host${DOCKER_TAG} -f ./docker/Dockerfile-host .
container-controller: dist-static/aci-containers-controller
${DOCKER_BUILD_CMD} -t ${DOCKER_HUB_ID}/aci-containers-controller${DOCKER_TAG} -f ./docker/Dockerfile-controller .
container-opflex-build-base:
${DOCKER_BUILD_CMD} -t ${DOCKER_HUB_ID}/opflex-build-base${DOCKER_TAG} -f ./docker/Dockerfile-opflex-build-base docker
container-openvswitch: dist-static/ovsresync
${DOCKER_BUILD_CMD} -t ${DOCKER_HUB_ID}/openvswitch${DOCKER_TAG} -f ./docker/Dockerfile-openvswitch .
container-cnideploy:
${DOCKER_BUILD_CMD} -t ${DOCKER_HUB_ID}/cnideploy${DOCKER_TAG} -f ./docker/Dockerfile-cnideploy docker
container-simpleservice: dist-static/simpleservice
${DOCKER_BUILD_CMD} -t ${DOCKER_HUB_ID}/simpleservice${DOCKER_TAG} -f ./docker/Dockerfile-simpleservice .
check: check-ipam check-index check-apicapi check-controller check-hostagent check-keyvalueservice
check-ipam:
${TEST_CMD} ${BASE}/pkg/ipam ${TEST_ARGS}
check-index:
${TEST_CMD} ${BASE}/pkg/index ${TEST_ARGS}
check-apicapi:
${TEST_CMD} ${BASE}/pkg/apicapi ${TEST_ARGS}
check-hostagent:
${TEST_CMD} ${BASE}/pkg/hostagent ${TEST_ARGS}
check-controller:
${TEST_CMD} ${BASE}/pkg/controller ${TEST_ARGS}
check-keyvalueservice:
${TEST_CMD} ${BASE}/pkg/keyvalueservice ${TEST_ARGS}
gometalintercheck:
@bash ./golang_checks.sh
DEB_PKG_DIR=build-deb-pkg
dsc: dist
- rm -rf ${DEB_PKG_DIR}
mkdir -p ${DEB_PKG_DIR}
cp ${DIST_FILE} ${DEB_PKG_DIR}/
tar -C $(DEB_PKG_DIR)/ -xf $(DEB_PKG_DIR)/$(DIST_FILE)
mv $(DEB_PKG_DIR)/$(DIST_FILE) $(DEB_PKG_DIR)/$(PACKAGE)_$(VERSION).orig.tar.gz
cd $(DEB_PKG_DIR)/$(PACKAGE)-$(VERSION)/; \
dpkg-buildpackage -d -us -uc -rfakeroot -S
deb: dist
- rm -rf ${DEB_PKG_DIR}
mkdir -p ${DEB_PKG_DIR}
cp ${DIST_FILE} ${DEB_PKG_DIR}/
tar -C $(DEB_PKG_DIR)/ -xf $(DEB_PKG_DIR)/$(DIST_FILE)
mv $(DEB_PKG_DIR)/$(DIST_FILE) $(DEB_PKG_DIR)/$(PACKAGE)_$(VERSION).orig.tar.gz
cd $(DEB_PKG_DIR)/$(PACKAGE)-$(VERSION)/; \
dpkg-buildpackage -us -uc -rfakeroot -b
cp $(DEB_PKG_DIR)/*.deb .
rm -rf $(DEB_PKG_DIR)