forked from mirrors2/opencatd-open
-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
61 lines (53 loc) · 1.58 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
GOPATH:=$(shell go env GOPATH)
VERSION=$(shell git describe --tags --always)
# 获取源码最近一次 git commit log,包含 commit sha 值,以及 commit message
GitCommitLog=$(shell git log)
# 检查源码在最近一次 git commit 基础上,是否有本地修改,且未提交的文件
GitStatus=$(shell git status -s)
# 获取当前时间
BuildTime=$(shell date +'%Y.%m.%d %H:%M:%S')
# 获取Go的版本
BuildGoVersion=$(shell go version)
LDFlags=" \
-X 'main.Version=$(VERSION)' \
-X 'main.GitCommitLog=$(GitCommitLog)' \
-X 'main.BuildTime=$(BuildTime)' \
-X 'main.BuildGoVersion=$(BuildGoVersion)'"
.PHONY: build
# build
build:
# mkdir -p bin/ && go build -ldflags $(LDFlags) -o ./bin/ ./...
rm -rf qq.tgz /bin/qq
mkdir -p bin/ && go build -ldflags "-s -w" -o ./bin/opencatd .
upx -9 bin/opencatd
.PHONY:docker
docker:
docker run --privileged --rm tonistiigi/binfmt --install all
docker buildx create --use --name xbuilder
docker buildx inspect xbuilder --bootstrap
docker buildx build --platform linux/amd64,linux/arm64 -t mirrors2/opencatd:latest . --push
.PHONY: clean
# clean
clean:
rm -rf bin/
.PHONY: all
# generate all
all:
make build;
# show help
help:
@echo ''
@echo 'Usage:'
@echo ' make [target]'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^# (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \
printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
.DEFAULT_GOAL := help