-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
43 lines (34 loc) · 894 Bytes
/
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
VERSION ?= $(shell ./tools/get_version_from_git.sh)
DIRTY = ?= $(shell ./tools/get_dirty.sh)
LDFLAGS = -X github.com/trento-project/rodent/cmd.version="$(VERSION)"
BINARY_NAME=rodent
GO_BUILD = CGO_ENABLED=0 go build -o $(BINARY_NAME) -ldflags "$(LDFLAGS)"
.PHONY: default
default: clean mod-tidy fmt vet-check build
.PHONY: build
build:
$(info Building version $(VERSION))
$(info Checking that git is clean)
ifeq ($(DIRTY), dirty)
$(error There are uncomitted changes. Either commit and try again, or build manually)
else
$(GO_BUILD)
endif
.PHONY: clean
clean:
go clean
if [[ -f ${BINARY_NAME} ]] ; then rm ${BINARY_NAME} ; fi
.PHONY: mod-tidy
mod-tidy:
go mod tidy
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: vet-check
vet-check:
go vet ./...
.PHONY: cross-compile $(ARCHS)
cross-compile: $(ARCHS)
$(ARCHS):
@mkdir -p build/$@
GOOS=linux GOARCH=$@ go build -o build/$@/rodent