-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (59 loc) · 1.35 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Variables
APP_NAME = mkv-cli
# Go parameters
GOCMD = go
GOBUILD = $(GOCMD) build
GOCLEAN = $(GOCMD) clean
GOINSTALL = $(GOCMD) install
GOTEST = $(GOCMD) test
# Determine the installation directory
GOBIN_DIR = $(shell go env GOBIN)
ifeq ($(GOBIN_DIR),)
GOBIN_DIR = $(shell go env GOPATH)/bin
endif
# Build flags to strip debug information and reduce binary size
LDFLAGS = -w -s
.PHONY: all
all: build
# Build the project
.PHONY: build
build:
$(GOBUILD) -ldflags="$(LDFLAGS)" -o $(APP_NAME) main.go
# Build and install the project
.PHONY: install
install:
$(GOINSTALL) -ldflags="$(LDFLAGS)" ./...
# Run the tests
.PHONY: test
test:
$(GOTEST) -v ./...
# Uninstall the project
.PHONY: uninstall
uninstall:
rm -f $(GOBIN_DIR)/$(APP_NAME)
# Clean the build directory
.PHONY: clean
clean:
$(GOCLEAN)
rm -f $(APP_NAME)
# Format the code
.PHONY: fmt
fmt:
gofmt -s -w .
# Display help
.PHONY: help
help:
@echo "Makefile for $(APP_NAME)"
@echo
@echo "Usage:"
@echo " make [target]"
@echo
@echo "Targets:"
@echo " all Default target: build"
@echo " build Build the project"
@echo " install Install the binary"
@echo " uninstall Uninstall the binary"
@echo " clean Clean the build directory"
@echo " fmt Format the code"
@echo " test Run tests"
@echo " help Display this help message"