This repository has been archived by the owner on Feb 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Makefile
162 lines (128 loc) · 3.84 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
GIT_HOST = github.com/ovirt
PWD := $(shell pwd)
BASE_DIR := $(shell basename $(PWD))
TESTARGS_DEFAULT := "-v"
export TESTARGS ?= $(TESTARGS_DEFAULT)
HAS_LINT := $(shell command -v golint;)
HAS_GOX := $(shell command -v gox;)
GOX_PARALLEL ?= 3
TARGETS ?= darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le
GOOS ?= $(shell go env GOOS)
VERSION ?= $(shell git describe --exact-match 2> /dev/null || \
git describe --match=$(git rev-parse --short=8 HEAD) --always --dirty --abbrev=8)
GOFLAGS = -mod=vendor
TAGS :=
LDFLAGS := "-w -s -X 'main.version=${VERSION}'"
REGISTRY ?= quay.io/ovirt
VERSION?=$(shell git describe --tags --always --match "v[0-9]*" | awk -F'-' '{print substr($$1,2) }')
RELEASE?=$(shell git describe --tags --always --match "v[0-9]*" | awk -F'-' '{if ($$2 != "") {print $$2 "." $$3} else {print 1}}')
VERSION_RELEASE=$(VERSION)$(if $(RELEASE),-$(RELEASE))
CLUSTER_API ?= github.com/openshift/cluster-api
.PHONY: vendor
vendor:
go mod tidy
go mod vendor
go mod verify
$(GOBIN):
echo "create gobin"
mkdir -p $(GOBIN)
work: $(GOBIN)
#build: export BUILDAH_LAYERS=true
build:
CGO_ENABLED=0 GOOS=$(GOOS) go build \
-ldflags $(LDFLAGS) \
-o bin/manager \
vendor/$(CLUSTER_API)/cmd/manager/main.go
CGO_ENABLED=0 GOOS=$(GOOS) go build \
-ldflags $(LDFLAGS) \
-o bin/machine-controller-manager \
cmd/manager/main.go
test: unit functional
check: depend fmt vet lint
unit: depend
go test -tags=unit $(shell go list ./...) $(TESTARGS)
functional:
@echo "$@ not yet implemented"
fmt:
hack/verify-gofmt.sh
lint:
ifndef HAS_LINT
go get -u golang.org/x/lint/golint
echo "installing golint"
endif
hack/verify-golint.sh
vet:
go vet ./...
cover: depend
go test -tags=unit $(shell go list ./...) -cover
docs:
@echo "$@ not yet implemented"
godoc:
@echo "$@ not yet implemented"
releasenotes:
@echo "Reno not yet implemented for this repo"
translation:
@echo "$@ not yet implemented"
# Do the work here
# Set up the development environment
env:
@echo "PWD: $(PWD)"
@echo "BASE_DIR: $(BASE_DIR)"
@echo "GOPATH: $(GOPATH)"
@echo "GOROOT: $(GOROOT)"
@echo "DEST: $(DEST)"
@echo "PKG: $(PKG)"
go version
go env
clean:
rm -rf _dist bin/manager bin/clusterctl
realclean: clean
rm -rf vendor
if [ "$(GOPATH)" = "$(GOPATH_DEFAULT)" ]; then \
rm -rf $(GOPATH); \
fi
shell:
$(SHELL) -i
# Generate code
generate:
go generate ./pkg/... ./cmd/...
DOCKERFILE=Dockerfile
images:
podman build \
-t $(REGISTRY)/origin-ovirt-machine-controllers:$(VERSION_RELEASE) \
--build-arg version=$(VERSION) \
--build-arg release=$(RELEASE) \
-f $(DOCKERFILE) \
$(DIR)
ovirt-cluster-api-controller: manager
ifeq ($(GOOS),linux)
cp bin/manager cmd/manager
docker build -t $(REGISTRY)/ovirt-cluster-api-controller:$(VERSION) cmd/manager
rm cmd/manager/manager
else
$(error Please set GOOS=linux for building the image)
endif
upload-images: images
@echo "push images to $(REGISTRY)"
docker login -u="$(DOCKER_USERNAME)" -p="$(DOCKER_PASSWORD)";
docker push $(REGISTRY)/ovirt-cluster-api-controller:$(VERSION)
version:
@echo ${VERSION}
.PHONY: build-cross
build-cross: LDFLAGS += -extldflags "-static"
build-cross: depend
ifndef HAS_GOX
go get -u github.com/mitchellh/gox
endif
CGO_ENABLED=0 gox -parallel=$(GOX_PARALLEL) -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(LDFLAGS)' $(GIT_HOST)/$(BASE_DIR)/cmd/ovirt-machine-controller/
.PHONY: dist
dist: build-cross
( \
cd _dist && \
$(DIST_DIRS) cp ../LICENSE {} \; && \
$(DIST_DIRS) cp ../README.md {} \; && \
$(DIST_DIRS) tar -zcf cluster-api-provider-ovirt-$(VERSION)-{}.tar.gz {} \; && \
$(DIST_DIRS) zip -r cluster-api-provider-ovirt-$(VERSION)-{}.zip {} \; \
)
.PHONY: build clean cover depend docs fmt functional lint realclean \
relnotes test translation version build-cross dist