-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (38 loc) · 920 Bytes
/
Makefile
File metadata and controls
48 lines (38 loc) · 920 Bytes
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
# 项目配置
BINARY=ccmap-go
VERSION=1.0.0
BUILD_DIR=build
MAIN_FILE=cmd/main.go
# Go 编译参数
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
# 编译标记
LDFLAGS=-ldflags "-X main.VERSION=${VERSION}"
.PHONY: all build clean test deps install uninstall
all: clean build
build:
@echo "开始编译..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY) $(MAIN_FILE)
@echo "编译完成: $(BUILD_DIR)/$(BINARY)"
clean:
@echo "清理构建目录..."
@rm -rf $(BUILD_DIR)
$(GOCLEAN)
test:
@echo "运行测试..."
$(GOTEST) -v ./...
deps:
@echo "检查依赖..."
$(GOGET) -v -t -d ./...
install: build
@echo "安装到系统..."
@sudo cp $(BUILD_DIR)/$(BINARY) /usr/local/bin/
@echo "安装完成: /usr/local/bin/$(BINARY)"
uninstall:
@echo "从系统中卸载..."
@sudo rm -f /usr/local/bin/$(BINARY)
@echo "卸载完成"