-
Notifications
You must be signed in to change notification settings - Fork 106
/
Makefile
67 lines (49 loc) · 1.37 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
NAME=good-mitm
BINDIR=bin
VERSION=$(shell git describe --tags || echo "unknown version")
UPX=upx --best
STRIP=llvm-strip -s
CROSS_BUILD=cross build --release --target
all: fmt clippy build
build:
cargo build
clean:
cargo clean
deps:
cargo install cargo-strip xargo cross
a: fmt clippy
fmt:
cargo fmt --all
fix:
cargo fix
check:
cargo check
clippy:
cargo clippy
prepare: fmt check clippy fix
CROSS_TARGET_LIST = \
x86_64-unknown-linux-musl \
i686-unknown-linux-musl \
aarch64-unknown-linux-musl \
armv7-unknown-linux-musleabihf \
x86_64-apple-darwin \
aarch64-apple-darwin \
$(CROSS_TARGET_LIST):
$(CROSS_BUILD) $@
cp "target/$@/release/$(NAME)" "$(BINDIR)/$(NAME)-$@"
$(STRIP) "$(BINDIR)/$(NAME)-$@"
$(UPX) "$(BINDIR)/$(NAME)-$@"
windows:
cargo build --target x86_64-pc-windows-gnu --release
cp "target/x86_64-pc-windows-gnu/release/$(NAME).exe" "$(BINDIR)/$(NAME)-x86_64-pc-windows-gnu-$(VERSION).exe"
$(STRIP) "$(BINDIR)/$(NAME)-x86_64-pc-windows-gnu-$(VERSION).exe"
zip -q -m $(BINDIR)/$(NAME)-x86_64-pc-windows-gnu-$(VERSION).zip "$(BINDIR)/$(NAME)-x86_64-pc-windows-gnu-$(VERSION).exe"
bindir:
rm -rf $(BINDIR)
mkdir $(BINDIR)
bin_gz=$(addsuffix .gz, $(CROSS_TARGET_LIST))
$(bin_gz): %.gz : %
chmod +x $(BINDIR)/$(NAME)-$(basename $@)
gzip -f -S -$(VERSION).gz $(BINDIR)/$(NAME)-$(basename $@)
gz_release: $(bin_gz)
release: bindir gz_release windows