-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (46 loc) · 1.62 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
#!/usr/bin/env make
.DEFAULT_GOAL := help
.DEFAULT_SHELL := /bin/sh
GOCOMMAND := go
GOBUILD := $(GOCOMMAND) build
GOCLEAN := $(GOCOMMAND) clean
GOTEST := $(GOCOMMAND) test
GOLINT := $(shell command -v golangci-lint 2>/dev/null)
EXECUTABLE := ikscc
INSTALL_PATH := /usr/local/bin
INSTALL := $(INSTALL_PATH)/$(EXECUTABLE)
PROJECT_CHANGESET := $(shell git rev-parse --verify HEAD 2>/dev/null)
define assert-command
@$(if $(shell command -v $1 2>/dev/null),,$(error $(1) command not found))
endef
.PHONY: help
help:
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make <target>\n\nTargets:\n"} /^[a-z0-9\/_-]+:.*?##/ { printf " %-15s %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
.PHONY: lint
lint: ## Lint
$(call assert-command,$(GOLINT))
@$(GOLINT) --verbose run ./...
./bin/$(EXECUTABLE):
ifdef PROJECT_VERSION
@$(GOBUILD) -v -ldflags="-s -w -X github.com/jjuarez/iks-ctx-cleaner/cmd.Version='v$(PROJECT_VERSION)'" -o ./bin/$(EXECUTABLE) main.go
else
@$(GOBUILD) -v -ldflags="-s -w -X github.com/jjuarez/iks-ctx-cleaner/cmd.Version='nightly:$(PROJECT_CHANGESET)'" -o ./bin/$(EXECUTABLE) main.go
endif
.PHONY: build
build: ./bin/$(EXECUTABLE) ## Builds the binary
.PHONY: test
test: ## Testing all the things
@$(GOTEST) -v ./...
.PHONY: clean
clean: ## Clean the generated products
@$(GOCLEAN)
@rm -fr ./bin/$(EXECUTABLE) ./dist/*
$(INSTALL):
@install -m 0755 ./bin/$(EXECUTABLE) $(INSTALL_PATH)
.PHONY: build install
install: $(INSTALL) ## Installs the program in the system
.PHONY: uninstall
uninstall: ## Uninstalls the program from the system
@rm -f $(INSTALL)
.PHONY: all
all: lint build test install