-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
28 lines (21 loc) · 1020 Bytes
/
Makefile
File metadata and controls
28 lines (21 loc) · 1020 Bytes
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
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS = -s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)
.PHONY: build install clean test lint
build:
CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o bin/gpulab ./cmd/gpulab
install: build
cp bin/gpulab /usr/local/bin/gpulab
clean:
rm -rf bin/
test:
go test ./...
lint:
go vet ./...
# Cross-compile for all platforms
build-all:
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o bin/gpulab-darwin-amd64 ./cmd/gpulab
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o bin/gpulab-darwin-arm64 ./cmd/gpulab
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o bin/gpulab-linux-amd64 ./cmd/gpulab
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -o bin/gpulab-linux-arm64 ./cmd/gpulab