-
Notifications
You must be signed in to change notification settings - Fork 30
/
Makefile
102 lines (79 loc) · 2.51 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
91
92
93
94
95
96
97
98
99
100
101
102
ifeq ($(shell uname),Darwin)
LDFLAGS := -Wl,-dead_strip -framework Security -framework Foundation
else
LDFLAGS := -Wl,--gc-sections -lpthread -ldl
endif
CARGO ?= cargo
CARGOFLAGS += --locked
CFLAGS := -Werror -Wall -Wextra -Wpedantic -g -I src/
PROFILE := release
CRYPTO_PROVIDER := aws-lc-rs
COMPRESSION := false
DESTDIR=/usr/local
ifeq ($(PROFILE), debug)
CFLAGS += -fsanitize=address -fsanitize=undefined
LDFLAGS += -fsanitize=address -fsanitize=undefined
endif
ifeq ($(PROFILE), release)
CFLAGS += -O3
CARGOFLAGS += --release
endif
ifneq (,$(TARGET))
PROFILE := $(TARGET)/$(PROFILE)
CARGOFLAGS += --target $(TARGET)
endif
ifeq ($(CRYPTO_PROVIDER), aws-lc-rs)
CFLAGS += -D DEFINE_AWS_LC_RS
CARGOFLAGS += --no-default-features --features aws-lc-rs
else ifeq ($(CRYPTO_PROVIDER), ring)
CFLAGS += -D DEFINE_RING
CARGOFLAGS += --no-default-features --features ring
endif
ifeq ($(COMPRESSION), true)
CARGOFLAGS += --features cert_compression
LDFLAGS += -lm
endif
default: target/$(PROFILE)/librustls_ffi.a
all: default test integration connect-test
test: target/client target/server
${CARGO} test ${CARGOFLAGS}
integration: test
${CARGO} test ${CARGOFLAGS} -- --ignored
connect-test: target/client
RUSTLS_PLATFORM_VERIFIER=1 target/client example.com 443 /
target:
mkdir -p $@
src/rustls.h: src/*.rs cbindgen.toml
cbindgen > $@
target/$(PROFILE)/librustls_ffi.a: src/*.rs Cargo.toml
RUSTFLAGS="-C metadata=rustls-ffi" ${CARGO} build $(CARGOFLAGS)
target/%.o: tests/%.c tests/common.h | target
$(CC) -o $@ -c $< $(CFLAGS)
target/client: target/client.o target/common.o target/$(PROFILE)/librustls_ffi.a
$(CC) -o $@ $^ $(LDFLAGS)
target/server: target/server.o target/common.o target/$(PROFILE)/librustls_ffi.a
$(CC) -o $@ $^ $(LDFLAGS)
install: target/$(PROFILE)/librustls_ffi.a
mkdir -p $(DESTDIR)/lib
install target/$(PROFILE)/librustls_ffi.a $(DESTDIR)/lib/librustls.a
mkdir -p $(DESTDIR)/include
install src/rustls.h $(DESTDIR)/include/
clean:
rm -rf target
format:
find src tests \
-name '*.[c|h]' \
! -wholename 'src/rustls.h' | \
xargs clang-format -i
sed -i -e 's/ffi_panic_boundary! {/if true {/g' src/*.rs
cargo fmt
sed -i -e 's/if true {/ffi_panic_boundary! {/g' src/*.rs
format-check:
find src tests \
-name '*.[c|h]' \
! -wholename 'src/rustls.h' | \
xargs clang-format --dry-run -Werror -i
sed -i -e 's/ffi_panic_boundary! {/if true {/g' src/*.rs
cargo fmt --check
sed -i -e 's/if true {/ffi_panic_boundary! {/g' src/*.rs
.PHONY: default all clean test integration format format-check