forked from b-harvest/axelmon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
38 lines (29 loc) · 1.1 KB
/
Makefile
File metadata and controls
38 lines (29 loc) · 1.1 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
# Name of the output binary
BINARY := axelmon
# Derive version (strip leading “v”) and full commit hash from git
VERSION := $(shell git describe --tags --abbrev=0 | sed 's/^v//')
COMMIT := $(shell git rev-parse --verify HEAD)
# Linker flags to embed version + commit into the binary
LDFLAGS := \
-X 'bharvest.io/axelmon/version.Version=$(VERSION)' \
-X 'bharvest.io/axelmon/version.Commit=$(COMMIT)'
# Build flags: enforce module readonly mode and pass in our LDFLAGS
BUILD_FLAGS := -mod=readonly -ldflags "$(LDFLAGS)"
# Go command
GO := go
.PHONY: all tidy build install
# Default target: ensure deps are tidy, then build
all: tidy build
# Tidy up go.mod / go.sum to pull in the correct versions of all deps
tidy:
@echo "→ running go mod tidy"
$(GO) mod tidy
# Build the project; output goes to bin/$(BINARY)
build:
@echo "→ building $(BINARY) (version=$(VERSION) commit=$(COMMIT))"
@mkdir -p bin
$(GO) build $(BUILD_FLAGS) -o bin/$(BINARY) .
# Install into your GOBIN (or GOPATH/bin)
install:
@echo "→ installing $(BINARY) (version=$(VERSION) commit=$(COMMIT))"
$(GO) install $(BUILD_FLAGS) .