Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
49 lines (36 loc) · 1.37 KB
/
Copy pathMakefile
File metadata and controls
49 lines (36 loc) · 1.37 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
BINARY := truelist
MODULE := github.com/Truelist-io-Email-Validation/truelist-cli
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS := -s -w -X $(MODULE)/cmd.Version=$(VERSION)
BUILD_DIR := dist
.PHONY: build install clean test lint fmt vet all
all: fmt vet lint test build
build:
mkdir -p $(BUILD_DIR)
go build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY) .
install:
go install -ldflags "$(LDFLAGS)" .
clean:
rm -rf $(BUILD_DIR)
test:
go test -race -cover ./...
lint:
@which golangci-lint > /dev/null 2>&1 || echo "Install golangci-lint: https://golangci-lint.run/usage/install/"
golangci-lint run ./...
fmt:
gofmt -s -w .
vet:
go vet ./...
# Cross-compilation targets
build-all: build-linux build-darwin build-windows
build-linux:
mkdir -p $(BUILD_DIR)
GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY)-linux-amd64 .
GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY)-linux-arm64 .
build-darwin:
mkdir -p $(BUILD_DIR)
GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY)-darwin-amd64 .
GOOS=darwin GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY)-darwin-arm64 .
build-windows:
mkdir -p $(BUILD_DIR)
GOOS=windows GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY)-windows-amd64.exe .