-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (50 loc) · 2.07 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
.PHONY=build
BUILDDIR=build
VER=0.0.4
BIN=$(BUILDDIR)/frequencmd-v$(VER)
UNAME=$(shell go env GOOS)
ARCH=$(shell go env GOARCH)
build-dev:
CGO_ENABLED=0 go build -v
mkbuilddir:
mkdir -p $(BUILDDIR)
build-prod: mkbuilddir
make build-$(UNAME)-$(ARCH)
rsync -avP $(BIN)-$(UNAME)-$(ARCH) ./frequencmd
run:
./$(BIN)
lint:
golangci-lint run ./...
compress-prod: mkbuilddir
rm -f $(BIN)-compressed
upx --best -o ./$(BIN)-compressed $(BIN)
# upx does not support mac currently
# rm -f $(BIN)-darwin-arm64-compressed
# note for mac m1 - this seems to taint the binary, it doesn't work;
# you'll probably have to do without upx for now
# upx --best -o ./$(BIN)-darwin-arm64-compressed $(BIN)-darwin-arm64
build-mac-arm64: mkbuilddir
CGO_ENABLED=0 GOARCH=arm64 GOOS=darwin go build -v -o $(BIN)-darwin-arm64 -ldflags="-w -s -buildid=" -trimpath
rm -f $(BIN)-darwin-arm64.xz
xz -9 -e -T 12 -vv $(BIN)-darwin-arm64
# rm -f $(BIN)-darwin-amd64-compressed
# upx --best -o ./$(BIN)-darwin-arm64-compressed $(BIN)-darwin-amd64
build-mac-amd64: mkbuilddir
CGO_ENABLED=0 GOARCH=amd64 GOOS=darwin go build -v -o $(BIN)-darwin-amd64 -ldflags="-w -s -buildid=" -trimpath
rm -f $(BIN)-darwin-amd64.xz
xz -9 -e -T 12 -vv $(BIN)-darwin-amd64
build-win-amd64: mkbuilddir
CGO_ENABLED=0 GOARCH=amd64 GOOS=windows go build -v -o $(BIN)-win-amd64-uncompressed -ldflags="-w -s -buildid=" -trimpath
rm -f $(BIN)-win-amd64
upx --best -o ./$(BIN)-win-amd64 $(BIN)-win-amd64-uncompressed
build-linux-arm64: mkbuilddir
CGO_ENABLED=0 GOARCH=arm64 GOOS=linux go build -v -o $(BIN)-linux-arm64-uncompressed -ldflags="-w -s -buildid=" -trimpath
rm -f $(BIN)-linux-arm64
upx --best -o ./$(BIN)-linux-arm64 $(BIN)-linux-arm64-uncompressed
build-linux-amd64: mkbuilddir
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -v -o $(BIN)-linux-amd64-uncompressed -ldflags="-w -s -buildid=" -trimpath
rm -f $(BIN)-linux-amd64
upx --best -o ./$(BIN)-linux-amd64 $(BIN)-linux-amd64-uncompressed
build-all: mkbuilddir build-linux-amd64 build-linux-arm64 build-win-amd64 build-mac-amd64 build-mac-arm64
delete-builds:
rm $(BUILDDIR)/*