-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathMakefile
More file actions
103 lines (83 loc) · 4.34 KB
/
Makefile
File metadata and controls
103 lines (83 loc) · 4.34 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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Makefile for Go Project
# 使用方法:
# make # 默认编译所有平台(版本号来自 config/version)
# make VERSION=v1.2.3 # 手动指定版本号
# make clean # 清理 build 目录
MODULE := github.com/qist/tvgate
OUT_DIR := build
# 如果没有指定 VERSION,就从 config/version 文件读取
VERSION ?= $(shell cat config/version 2>/dev/null || echo latest)
LDFLAGS := -s -w -extldflags '-static' -X '$(MODULE)/config.Version=$(VERSION)'
GCFLAGS := -trimpath
ASMFLAGS := -trimpath
# 目标列表
TARGETS := \
$(OUT_DIR)/TVGate-linux-amd64 \
$(OUT_DIR)/TVGate-linux-arm64 \
$(OUT_DIR)/TVGate-linux-armv7 \
$(OUT_DIR)/TVGate-linux-386 \
$(OUT_DIR)/TVGate-linux-ppc64 \
$(OUT_DIR)/TVGate-linux-ppc64le \
$(OUT_DIR)/TVGate-linux-s390x \
$(OUT_DIR)/TVGate-windows-amd64.exe \
$(OUT_DIR)/TVGate-windows-arm64.exe \
$(OUT_DIR)/TVGate-windows-386.exe \
$(OUT_DIR)/TVGate-darwin-amd64 \
$(OUT_DIR)/TVGate-darwin-arm64 \
$(OUT_DIR)/TVGate-android-arm64
all: $(TARGETS)
@echo "全部编译完成,版本号: $(VERSION),文件在 $(OUT_DIR)/"
# Linux amd64
$(OUT_DIR)/TVGate-linux-amd64:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" -o $@ .
@if command -v upx >/dev/null 2>&1; then upx -9 $@ >/dev/null 2>&1 || true; fi
# Linux arm64
$(OUT_DIR)/TVGate-linux-arm64:
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" -o $@ .
@if command -v upx >/dev/null 2>&1; then upx -9 $@ >/dev/null 2>&1 || true; fi
# Linux armv7
$(OUT_DIR)/TVGate-linux-armv7:
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags "$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" -o $@ .
@if command -v upx >/dev/null 2>&1; then upx -9 $@ >/dev/null 2>&1 || true; fi
# Linux 386
$(OUT_DIR)/TVGate-linux-386:
CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" -o $@ .
@if command -v upx >/dev/null 2>&1; then upx -9 $@ >/dev/null 2>&1 || true; fi
# Linux ppc64
$(OUT_DIR)/TVGate-linux-ppc64:
CGO_ENABLED=0 GOOS=linux GOARCH=ppc64 go build -ldflags "$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" -o $@ .
@if command -v upx >/dev/null 2>&1; then upx -9 $@ >/dev/null 2>&1 || true; fi
# Linux ppc64le
$(OUT_DIR)/TVGate-linux-ppc64le:
CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build -ldflags "$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" -o $@ .
@if command -v upx >/dev/null 2>&1; then upx -9 $@ >/dev/null 2>&1 || true; fi
# Linux s390x
$(OUT_DIR)/TVGate-linux-s390x:
CGO_ENABLED=0 GOOS=linux GOARCH=s390x go build -ldflags "$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" -o $@ .
@if command -v upx >/dev/null 2>&1; then upx -9 $@ >/dev/null 2>&1 || true; fi
# Windows amd64
$(OUT_DIR)/TVGate-windows-amd64.exe:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" -o $@ .
@if command -v upx >/dev/null 2>&1; then upx -9 $@ >/dev/null 2>&1 || true; fi
# Windows arm64
$(OUT_DIR)/TVGate-windows-arm64.exe:
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" -o $@ .
@if command -v upx >/dev/null 2>&1; then upx -9 $@ >/dev/null 2>&1 || true; fi
# Windows 386
$(OUT_DIR)/TVGate-windows-386.exe:
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" -o $@ .
@if command -v upx >/dev/null 2>&1; then upx -9 $@ >/dev/null 2>&1 || true; fi
# macOS amd64
$(OUT_DIR)/TVGate-darwin-amd64:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" -o $@ .
@if command -v upx >/dev/null 2>&1; then upx -9 $@ >/dev/null 2>&1 || true; fi
# macOS arm64
$(OUT_DIR)/TVGate-darwin-arm64:
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" -o $@ .
@if command -v upx >/dev/null 2>&1; then upx -9 $@ >/dev/null 2>&1 || true; fi
# Android arm64
$(OUT_DIR)/TVGate-android-arm64:
CGO_ENABLED=0 GOOS=android GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" -o $@ .
@if command -v upx >/dev/null 2>&1; then upx -9 $@ >/dev/null 2>&1 || true; fi
clean:
rm -rf $(OUT_DIR)/TVGate-*-*