forked from rustls/rustls-ffi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
63 lines (46 loc) · 1.42 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
ifeq ($(shell uname),Darwin)
LDFLAGS := -Wl,-dead_strip -framework Security -framework Foundation
else
LDFLAGS := -Wl,--gc-sections -lpthread -ldl
endif
CARGO ?= cargo
CFLAGS := -Werror -Wall -Wextra -Wpedantic -g -I src/
PROFILE := release
DESTDIR=/usr/local
ifeq ($(CC), clang)
CFLAGS += -fsanitize=address -fsanitize=undefined
LDFLAGS += -fsanitize=address
endif
ifeq ($(PROFILE), release)
CFLAGS += -O3
CARGOFLAGS += --release
endif
ifneq (,$(TARGET))
PROFILE := $(TARGET)/$(PROFILE)
CARGOFLAGS += --target $(TARGET)
endif
all: target/client target/server
test: all test-rust
./tests/verify-static-libraries.py
./tests/client-server.py ./target/client ./target/server
test-rust:
${CARGO} test
target:
mkdir -p $@
src/rustls.h: src/*.rs cbindgen.toml
cbindgen --lang C > $@
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