-
Notifications
You must be signed in to change notification settings - Fork 31
/
Makefile
executable file
·90 lines (73 loc) · 2.34 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
83
84
85
86
87
88
89
90
NAME=srun
BINDIR=bin
VERSION=$(shell git describe --tags || echo "unknown version")
STRIP=llvm-strip -s
CARGO_BUILD=cargo build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --release --target
CROSS_BUILD=cross build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --release --target
UPX=-upx --best --lzma
TLS=FALSE
CROSS_TARGET_LIST = \
i686-unknown-linux-musl \
x86_64-unknown-linux-musl \
armv7-unknown-linux-musleabihf \
arm-unknown-linux-musleabi \
arm-unknown-linux-musleabihf \
aarch64-unknown-linux-musl
$(CROSS_TARGET_LIST):
ifeq ($(TLS),TRUE)
$(CROSS_BUILD) $@ --features tls
cp "target/$@/release/$(NAME)" "$(BINDIR)/$(NAME)-tls-$@"
$(STRIP) "$(BINDIR)/$(NAME)-tls-$@"
$(UPX) "$(BINDIR)/$(NAME)-tls-$@"
else
$(CROSS_BUILD) $@
cp "target/$@/release/$(NAME)" "$(BINDIR)/$(NAME)-$@"
$(STRIP) "$(BINDIR)/$(NAME)-$@"
$(UPX) "$(BINDIR)/$(NAME)-$@"
endif
WINDOWS_TARGET_LIST = \
x86_64-pc-windows-msvc \
aarch64-pc-windows-msvc
$(WINDOWS_TARGET_LIST):
ifeq ($(TLS),TRUE)
$(CARGO_BUILD) $@ --features tls
cp "target/$@/release/$(NAME).exe" "$(BINDIR)/$(NAME)-tls-$@.exe"
$(STRIP) "$(BINDIR)/$(NAME)-tls-$@.exe"
zip -m -j "$(BINDIR)/$(NAME)-tls-$@-$(VERSION).zip" "$(BINDIR)/$(NAME)-tls-$@.exe"
else
$(CARGO_BUILD) $@
cp "target/$@/release/$(NAME).exe" "$(BINDIR)/$(NAME)-$@.exe"
$(STRIP) "$(BINDIR)/$(NAME)-$@.exe"
zip -m -j "$(BINDIR)/$(NAME)-$@-$(VERSION).zip" "$(BINDIR)/$(NAME)-$@.exe"
endif
all: fmt clippy cbuild
cbuild:
cargo build
clean:
cargo clean
deps:
cargo install cargo-strip xargo cross
fmt:
cargo fmt --all
clippy:
cargo clippy
windows: $(WINDOWS_TARGET_LIST)
bindir:
rm -rf $(BINDIR)
mkdir $(BINDIR)
bin_gz=$(addsuffix .gz, $(CROSS_TARGET_LIST))
$(bin_gz): %.gz : %
ifeq ($(TLS),TRUE)
chmod +x $(BINDIR)/$(NAME)-tls-$(basename $@)
gzip -f -S -$(VERSION).gz $(BINDIR)/$(NAME)-tls-$(basename $@)
else
chmod +x $(BINDIR)/$(NAME)-$(basename $@)
gzip -f -S -$(VERSION).gz $(BINDIR)/$(NAME)-$(basename $@)
endif
gz_release: $(bin_gz)
release: bindir gz_release
minsize:
rustup toolchain install nightly
rustup component add rust-src --toolchain nightly
cargo +nightly build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target x86_64-unknown-linux-gnu --release
upx --best --lzma ./target/x86_64-unknown-linux-gnu/release/srun