-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
73 lines (57 loc) · 2.2 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
.PHONY=build
BUILDDIR=build
# make sure to update constants.go's version here too
VER=0.1.1
FILE=finance-planner-tui
BIN=$(BUILDDIR)/$(FILE)-v$(VER)
OUT_BIN_DIR=~/.local/bin
UNAME=$(shell go env GOOS)
ARCH=$(shell go env GOARCH)
BUILD_ENV=CGO_ENABLED=0
BUILD_FLAGS=-ldflags="-w -s -buildid= -X main.version=$(VER)" -trimpath
build-dev:
CGO_ENABLED=0 go build -v
mkbuilddir:
mkdir -p $(BUILDDIR)
build-prod: mkbuilddir
make build-$(UNAME)-$(ARCH)
run:
./$(BIN)
lint:
golangci-lint run ./...
install:
rsync -avP ./$(BIN)-$(UNAME)-$(ARCH) $(OUT_BIN_DIR)/$(FILE)
chmod +x $(OUT_BIN_DIR)/$(FILE)
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
$(BUILD_ENV) GOARCH=arm64 GOOS=darwin go build -v -o $(BIN)-darwin-arm64 $(BUILD_FLAGS)
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
$(BUILD_ENV) GOARCH=amd64 GOOS=darwin go build -v -o $(BIN)-darwin-amd64 $(BUILD_FLAGS)
rm -f $(BIN)-darwin-amd64.xz
xz -9 -e -T 12 -vv $(BIN)-darwin-amd64
build-win-amd64: mkbuilddir
$(BUILD_ENV) GOARCH=amd64 GOOS=windows go build -v -o $(BIN)-win-amd64-uncompressed $(BUILD_FLAGS)
rm -f $(BIN)-win-amd64
upx --best -o ./$(BIN)-win-amd64 $(BIN)-win-amd64-uncompressed
build-linux-arm64: mkbuilddir
$(BUILD_ENV) GOARCH=arm64 GOOS=linux go build -v -o $(BIN)-linux-arm64-uncompressed $(BUILD_FLAGS)
rm -f $(BIN)-linux-arm64
upx --best -o ./$(BIN)-linux-arm64 $(BIN)-linux-arm64-uncompressed
build-linux-amd64: mkbuilddir
$(BUILD_ENV) GOARCH=amd64 GOOS=linux go build -v -o $(BIN)-linux-amd64-uncompressed $(BUILD_FLAGS)
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)/*