-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
47 lines (36 loc) · 1.29 KB
/
Copy pathMakefile
File metadata and controls
47 lines (36 loc) · 1.29 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
BINARY_NAME=gateshift
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILD_TIME=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)"
.PHONY: all build clean test install uninstall
# Default target
all: build
# Build binary
build:
go build $(LDFLAGS) -o bin/$(BINARY_NAME) ./cmd/gateshift
# Cross compile for all platforms
build-all: build-linux build-darwin build-windows
# Build for Linux
build-linux:
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-linux-amd64 ./cmd/gateshift
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-linux-arm64 ./cmd/gateshift
# Build for macOS
build-darwin:
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-darwin-amd64 ./cmd/gateshift
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-darwin-arm64 ./cmd/gateshift
# Build for Windows
build-windows:
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-windows-amd64.exe ./cmd/gateshift
# Run tests
test:
go test -v ./...
# Clean build files
clean:
rm -rf bin/
# Install the application locally
install: build
mkdir -p $(HOME)/bin
cp bin/$(BINARY_NAME) $(HOME)/bin/
# Uninstall the application
uninstall:
rm -f $(HOME)/bin/$(BINARY_NAME)