-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
82 lines (68 loc) · 1.79 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
71
72
73
74
75
76
77
78
79
80
81
82
PROJECT_NAME := web-replay
ifdef OUTDIR
OUTDIR := ${OUTDIR}
else
OUTDIR := ./build
endif
ifeq (${PROD},true)
LD_FLAGS := ${LD_FLAGS} -s -w
OUTDIR := ${OUTDIR}/release
else
LD_FLAGS := ${LD_FLAGS}
OUTDIR := ${OUTDIR}/debug
endif
ifdef GOOS
BUILD_TARGET := ${GOOS}
else
BUILD_TARGET := $(shell go env GOOS)
endif
ifdef GOARCH
BUILD_TARGET := ${BUILD_TARGET}-${GOARCH}
else
BUILD_TARGET := ${BUILD_TARGET}-$(shell go env GOARCH)
endif
OUTDIR := ${OUTDIR}/${BUILD_TARGET}
ifeq (${GOOS},windows)
BIN_NAME := $(PROJECT_NAME).exe
else ifeq ($(shell go env GOOS),windows)
BIN_NAME := $(PROJECT_NAME).exe
else
BIN_NAME := $(PROJECT_NAME)
endif
default: build
.PHONY: clean
clean:
rm -r -f ./build
.PHONY: build
build:
rm -rf ${OUTDIR}
mkdir -p ${OUTDIR}
mkdir -p ${OUTDIR}/bin
cp -r commands/web-replay/patches ${OUTDIR}
cp -r commands/web-replay-pack/web-replay-pack ${OUTDIR}/bin
cp -r commands/web-replay-unpack/web-replay-unpack ${OUTDIR}/bin
cd commands/web-replay && \
env CGO_ENABLED=0 \
go build -ldflags="$(LD_FLAGS)" -o "../../$(OUTDIR)/bin/$(BIN_NAME)" ./src/cmd/*.go
.PHONY: package
package:
cd ${OUTDIR} && \
tar -czvf "../${BUILD_TARGET}.tar.gz" *
.PHONY: build-all
build-all:
env GOOS=linux GOARCH=arm make build
env GOOS=linux GOARCH=arm64 make build
env GOOS=linux GOARCH=amd64 make build
env GOOS=darwin GOARCH=amd64 make build
env GOOS=darwin GOARCH=arm64 make build
env GOOS=windows GOARCH=amd64 make build
env GOOS=windows GOARCH=arm64 make build
.PHONY: package-all
package-all:
env GOOS=linux GOARCH=arm make package
env GOOS=linux GOARCH=arm64 make package
env GOOS=linux GOARCH=amd64 make package
env GOOS=darwin GOARCH=amd64 make package
env GOOS=darwin GOARCH=arm64 make package
env GOOS=windows GOARCH=amd64 make package
env GOOS=windows GOARCH=arm64 make package