-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (36 loc) · 1.17 KB
/
Makefile
File metadata and controls
48 lines (36 loc) · 1.17 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
GO ?= go
GOOS ?= $(shell $(GO) env GOOS)
GIT_TAG := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
MAKEFILE := $(realpath $(lastword $(MAKEFILE_LIST)))
SOURCES := $(shell find . -name '*.go') $(MAKEFILE)
BUILD_FLAGS := -a -ldflags="-s -w -X github.com/NitorCreations/tai/internal/cli.Version=$(GIT_TAG)" -trimpath
BINARY64 := tai_$(GOOS)_amd64
BINARYARM8 := tai_$(GOOS)_arm8
# https://en.wikipedia.org/wiki/Uname
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M),x86_64)
BINARY := $(BINARY64)
else ifeq ($(UNAME_M),amd64)
BINARY := $(BINARY64)
else ifeq ($(UNAME_M),arm64)
BINARY := $(BINARYARM8)
else ifeq ($(UNAME_M),aarch64)
BINARY := $(BINARYARM8)
else
$(error Build on $(UNAME_M) is not supported, yet.)
endif
all: dist/$(BINARY)
fmt:
$(GO) fmt ./...
clean:
$(RM) -r dist
install: all
install -Dm755 dist/$(BINARY) $(HOME)/.local/share/tai/tai
dist/$(BINARY64): $(SOURCES)
GOARCH=amd64 $(GO) build $(BUILD_FLAGS) -o $@ ./cmd/tai/
dist/$(BINARYARM8): $(SOURCES)
GOARCH=arm64 $(GO) build $(BUILD_FLAGS) -o $@ ./cmd/tai/
update:
$(GO) get -u ./...
$(GO) mod tidy
.PHONY: all clean install update