-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
36 lines (28 loc) · 858 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
# SPDX-FileCopyrightText: 2024 Christoph Mewes
# SPDX-License-Identifier: MIT
GIT_VERSION = $(shell git describe --tags --always)
GIT_HEAD ?= $(shell git log -1 --format=%H)
NOW_GO_RFC339 = $(shell date --utc +'%Y-%m-%dT%H:%M:%SZ')
export CGO_ENABLED ?= 0
export GOFLAGS ?= -mod=readonly -trimpath
OUTPUT_DIR ?= _build
GO_DEFINES ?= -X main.BuildTag=$(GIT_VERSION) -X main.BuildCommit=$(GIT_HEAD) -X main.BuildDate=$(NOW_GO_RFC339)
GO_LDFLAGS += -w -extldflags '-static' $(GO_DEFINES)
GO_BUILD_FLAGS ?= -v -ldflags '$(GO_LDFLAGS)'
GO_TEST_FLAGS ?= -v -race
default: build
.PHONY: build
build:
go build $(GO_BUILD_FLAGS) -o $(OUTPUT_DIR)/ .
.PHONY: install
install:
go install $(GO_BUILD_FLAGS) .
.PHONY: test
test:
CGO_ENABLED=1 go test $(GO_TEST_FLAGS) ./...
.PHONY: clean
clean:
rm -rf $(OUTPUT_DIR)
.PHONY: lint
lint:
golangci-lint run ./...