Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
34 lines (31 loc) · 1.45 KB
/
Copy pathMakefile
File metadata and controls
34 lines (31 loc) · 1.45 KB
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
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOMOD=$(GOCMD) mod
GOTEST=$(GOCMD) test
# -trimpath: reproducible builds, no build-machine paths in the binary.
GOFLAGS := -v -trimpath
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS := -s -w -X main.Version=$(VERSION)
# CGO is disabled across the board: Mzack9999/gopacket dlopens libpcap at
# runtime via purego, so neither libpcap headers nor a C toolchain are needed
# to build. Cross-compiles are plain GOOS/GOARCH go build.
export CGO_ENABLED=0
.PHONY: all build build-linux-amd64 build-linux-arm64 build-darwin-amd64 build-darwin-arm64 build-windows-amd64 test tidy
all: build
build:
$(GOBUILD) $(GOFLAGS) -ldflags '$(LDFLAGS)' -o "pd-agent" ./cmd/pd-agent/
build-linux-amd64:
GOOS=linux GOARCH=amd64 $(GOBUILD) $(GOFLAGS) -ldflags '$(LDFLAGS)' -o "pd-agent-linux-amd64" ./cmd/pd-agent/
build-linux-arm64:
GOOS=linux GOARCH=arm64 $(GOBUILD) $(GOFLAGS) -ldflags '$(LDFLAGS)' -o "pd-agent-linux-arm64" ./cmd/pd-agent/
build-darwin-amd64:
GOOS=darwin GOARCH=amd64 $(GOBUILD) $(GOFLAGS) -ldflags '$(LDFLAGS)' -o "pd-agent-darwin-amd64" ./cmd/pd-agent/
build-darwin-arm64:
GOOS=darwin GOARCH=arm64 $(GOBUILD) $(GOFLAGS) -ldflags '$(LDFLAGS)' -o "pd-agent-darwin-arm64" ./cmd/pd-agent/
build-windows-amd64:
GOOS=windows GOARCH=amd64 $(GOBUILD) $(GOFLAGS) -ldflags '$(LDFLAGS)' -o "pd-agent-windows-amd64.exe" ./cmd/pd-agent/
test:
$(GOTEST) $(GOFLAGS) ./...
tidy:
$(GOMOD) tidy