-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
88 lines (70 loc) · 2.35 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
### User defined variables ######################################################
DEBUG := y
SSL_ENABLE := y
### Should not need to change below this line ###################################
BIN := mb
PWD := $(shell pwd)
USR_DIR := $(PWD)/usr
DEP_DIR := $(PWD)/deps
CFLAGS += -Wall -Wno-parentheses -Wno-switch-enum -Wno-unused-value -Wno-error
LIBS := -L$(USR_DIR)/lib -lpthread -lm
VERSION_H := version.h
GIT_VERSION := $(shell git describe 2>/dev/null || git rev-parse --short=6 HEAD 2>/dev/null)
ifeq ($(DEBUG),y)
CFLAGS += -g
endif
ifeq ($(SSL_ENABLE),y)
CFLAGS += -DHAVE_SSL -I$(USR_DIR)/include
LIBS += -Wl,-Bstatic -lwolfssl -Wl,-Bdynamic
WOLFSSL_ARCHIVE := v4.7.0-stable.tar.gz
WOLFSSL_URL := https://github.com/wolfSSL/wolfssl/archive/$(WOLFSSL_ARCHIVE)
WOLFSSL_DIR := wolfssl
WOLFSSL_LIB := $(USR_DIR)/lib/libwolfssl.a
endif
SRC := $(wildcard src/*.c)
OBJ := ${SRC:.c=.o}
LIBAE_SRC = libae/ae.c libae/anet.c
LIBAE_OBJ = ${LIBAE_SRC:.c=.o}
LIBAE_LIB = libae/libae.a
LIBJSON_SRC = json/json.c
LIBJSON_OBJ = ${LIBJSON_SRC:.c=.o}
LIBJSON_LIB = json/libjson.a
all: deps $(BIN)
deps: $(WOLFSSL_LIB) $(LIBAE_LIB) $(LIBJSON_LIB)
$(DEP_DIR)/$(WOLFSSL_ARCHIVE):
curl --create-dirs -Ls $(WOLFSSL_URL) -o "$(DEP_DIR)/$(WOLFSSL_ARCHIVE)"
$(WOLFSSL_LIB): $(DEP_DIR)/$(WOLFSSL_ARCHIVE)
mkdir -p $(WOLFSSL_DIR)
tar zxvf $(DEP_DIR)/$(WOLFSSL_ARCHIVE) --strip=1 -C $(WOLFSSL_DIR)
(cd $(WOLFSSL_DIR) && \
mkdir -p .git && \
./autogen.sh && \
./configure CFLAGS="-w" \
--disable-examples \
--enable-fastmath \
--enable-hugecache \
--enable-oldtls \
--enable-secure-renegotiation \
--enable-session-ticket \
--enable-sni \
--enable-sslv3 \
--enable-static \
--enable-tlsv10 \
--enable-truncatedhmac \
$(WOLFSSL_CONFIG_EXTRA) && \
make install prefix=$(USR_DIR))
$(LIBAE_LIB): $(LIBAE_OBJ)
$(AR) -rc $@ $(LIBAE_OBJ)
$(LIBJSON_LIB): $(LIBJSON_OBJ)
$(AR) -rc $@ $(LIBJSON_OBJ)
%.o: %.c %.h $(VERSION_H) Makefile
$(CC) $(CFLAGS) -c $< -o $@
$(VERSION_H):
@echo "#define MB_VERSION \"$(GIT_VERSION)\"" > $(VERSION_H)
$(BIN): nginx/http_parser.o $(OBJ) libae/libae.a json/libjson.a
$(CC) $^ $(LIBS) -o $@
clean:
rm -f $(BIN) $(OBJ) libae/*.o libae/*.a json/*.o json/*.a nginx/*.o $(VERSION_H)
distclean: clean
rm -rf $(USR_DIR) $(DEP_DIR) $(WOLFSSL_DIR)
.PHONY: clean distclean