forked from blinklabs-io/txtop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
38 lines (27 loc) · 920 Bytes
/
Makefile
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
# Determine root directory
ROOT_DIR=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
# Gather all .go files for use in dependencies below
GO_FILES=$(shell find $(ROOT_DIR) -name '*.go')
# Gather list of expected binaries
BINARIES=txtop
# Set version strings based on git tag and current ref
GO_LDFLAGS=-ldflags "-s -w -X 'main.Version=$(shell git describe --tags --exact-match 2>/dev/null)' -X 'main.CommitHash=$(shell git rev-parse --short HEAD)'"
.PHONY: build mod-tidy clean test
all: format build
# Alias for building program binary
build: $(BINARIES)
tidy:
# Needed to fetch new dependencies and add them to go.mod
go mod tidy
clean:
rm -f $(BINARIES)
format: tidy
go fmt ./...
test: tidy
go test -v -race ./...
# Build our program binaries
# Depends on GO_FILES to determine when rebuild is needed
$(BINARIES): mod-tidy $(GO_FILES)
CGO_ENABLED=0 go build \
$(GO_LDFLAGS) \
-o $(@) .