forked from uNetworking/uSockets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (47 loc) · 1.47 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
# WITH_OPENSSL=1 enables OpenSSL 1.1+ support
ifeq ($(WITH_OPENSSL),1)
override CFLAGS += -DLIBUS_USE_OPENSSL
# With problems on macOS, make sure to pass needed LDFLAGS required to find these
override LDFLAGS += -lssl -lcrypto
else
# WITH_WOLFSSL=1 enables WolfSSL 4.2.0 support (mutually exclusive with OpenSSL)
ifeq ($(WITH_WOLFSSL),1)
# todo: change these
override CFLAGS += -DLIBUS_USE_WOLFSSL -I/usr/local/include
override LDFLAGS += -L/usr/local/lib -lwolfssl
else
override CFLAGS += -DLIBUS_NO_SSL
endif
endif
# WITH_LIBUV=1 builds with libuv as event-loop
ifeq ($(WITH_LIBUV),1)
override CFLAGS += -DLIBUS_USE_LIBUV
override LDFLAGS += -luv
endif
# WITH_GCD=1 builds with libdispatch as event-loop
ifeq ($(WITH_GCD),1)
override CFLAGS += -DLIBUS_USE_GCD
override LDFLAGS += -framework CoreFoundation
endif
# WITH_ASAN builds with sanitizers
ifeq ($(WITH_ASAN),1)
override CFLAGS += -fsanitize=address
override LDFLAGS += -lasan
endif
override CFLAGS += -std=c11 -Isrc
override LDFLAGS += uSockets.a
# By default we build the uSockets.a static library
default:
rm -f *.o
$(CC) $(CFLAGS) -flto -O3 -c src/*.c src/eventing/*.c src/crypto/*.c
$(AR) rvs uSockets.a *.o
# Builds all examples
.PHONY: examples
examples: default
for f in examples/*.c; do $(CC) -flto -O3 $(CFLAGS) -o $$(basename "$$f" ".c") "$$f" $(LDFLAGS); done
swift_examples:
swiftc -O -I . examples/swift_http_server/main.swift uSockets.a -o swift_http_server
clean:
rm -f *.o
rm -f *.a
rm -rf .certs