-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
65 lines (50 loc) · 1.45 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
BINDIR := $(CURDIR)/bin
BINNAME ?= inspektor
GOBIN = $(shell go env GOBIN)
ifeq ($(GOBIN),)
GOBIN = $(shell go env GOPATH)/bin
endif
ARCH = $(shell uname -p)
# Go Options
PKG := ./...
TAGS :=
TESTS := .
TESTFLAGS :=
LDFLAGS := -w
GOFLAGS :=
CGO_ENABLED ?= 0
# Rebuild the binary if any of these files change
SRC := $(shell find . -type f -name '*.go' -print) go.mod go.sum
.PHONY: all
all: build
.PHONY: build
build: $(BINDIR)/$(BINNAME)
$(BINDIR)/$(BINNAME): $(SRC)
mkdir -p $(BINDIR)
CGO_ENABLED=$(CGO_ENABLED) go build -o $(BINDIR) -ldflags $(LDFLAGS) $(PKG)
.PHONY: run
run: build ## Run the binary
$(BINDIR)/$(BINNAME)
# ------------------------------------------------------------------------------
# dependencies
.PHONY: download
download: ## Download dependencies
go mod download
.PHONY: tidy
tidy: download ## Update go.mod and go.sum
go mod tidy
# ------------------------------------------------------------------------------
# docker
.PHONY: docker-build
docker-build: ## Build docker image
docker build -t inspektor .
# ------------------------------------------------------------------------------
.PHONY: clean
clean: ## Remove build artifacts
rm -rf '$(BINDIR)'
.PHONY: help
help: ## Display this help screen
@echo "Usage: make [target] ..."
@echo
@echo "Targets:"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-20s %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort