This repository has been archived by the owner on Mar 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
84 lines (71 loc) · 2.21 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
# Makefile for the project
# tools
CUR_DIR=$(shell pwd)
INSTALL_PREFIX=$(CUR_DIR)/bin
VENDOR_DIR=vendor
BINARY_NAME=osio
ifeq ($(OS),Windows_NT)
BINARY_PATH=$(INSTALL_PREFIX)/$(BINARY_NAME).exe
else
BINARY_PATH=$(INSTALL_PREFIX)/$(BINARY_NAME)
endif
# Call this function with $(call log-info,"Your message")
define log-info =
@echo "INFO: $(1)"
endef
.PHONY: help
# Based on https://gist.github.com/rcmachado/af3db315e31383502660
## Display this help text.
help:/
$(info Available targets)
$(info -----------------)
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
if (helpMessage) { \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
gsub(/##/, "\n ", helpMessage); \
} else { \
helpMessage = "(No documentation)"; \
} \
printf "%-35s - %s\n", helpCommand, helpMessage; \
lastLine = "" \
} \
{ hasComment = match(lastLine, /^## (.*)/); \
if(hasComment) { \
lastLine=lastLine$$0; \
} \
else { \
lastLine = $$0 \
} \
}' $(MAKEFILE_LIST)
.PHONY: deps
## Download build dependencies.
deps: $(VENDOR_DIR)
$(VENDOR_DIR):
dep ensure
$(INSTALL_PREFIX):
# Build artifacts dir
@mkdir -p $(INSTALL_PREFIX)
.PHONY: prebuild-checks
## Check that all tools where found
prebuild-checks: $(INSTALL_PREFIX)
.PHONY: build
## build the binary executable from CLI
build: $(INSTALL_PREFIX) deps
$(eval BUILD_COMMIT:=$(shell git rev-parse --short HEAD))
$(eval BUILD_TAG:=$(shell git tag --contains $(BUILD_COMMIT)))
@echo "building $(BINARY_PATH) (commit:$(BUILD_COMMIT) / tag:$(BUILD_TAG))"
@go build -ldflags \
" -X github.com/fabric8-services/fabric8-auth-cli/cmd.BinaryName=$(BINARY_NAME)\
-X github.com/fabric8-services/fabric8-auth-cli/cmd.BuildCommit=$(BUILD_COMMIT) \
-X github.com/fabric8-services/fabric8-auth-cli/cmd.BuildTag=$(BUILD_TAG)" \
-o $(BINARY_PATH) \
main*.go
lint:
@go get -v github.com/golangci/golangci-lint/cmd/golangci-lint
@golangci-lint run -E gofmt,golint,megacheck,misspell ./...
.PHONY: install
## installs the binary executable in the $GOPATH/bin directory
install: build
@cp $(BINARY_PATH) $(GOPATH)/bin