-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
111 lines (88 loc) · 4.08 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
103
104
105
106
107
108
109
110
111
LIB=libmpsocket
LIBDIR=.libs
DEPSDIR=.deps
SRCS=http_parser.c mpsock_pool.c mpsock_connection.c mpsock_tcp.c mpsock_socket.c mpsock_collector.c mpsock_interface.c mpsock_dns.c mpsock_buffer.c mpsock_scheduler.c mpsock_scheduler_minimum_throughput_assurance.c mpsock_scheduler_algorithms.c mpsock_misc.c
HEADERS=$(SRCS:.c=.h) libmpsocket.h
OBJDIR=.obj
_OBJ=$(SRCS:.c=.o)
OBJ = $(patsubst %,$(OBJDIR)/%,$(_OBJ))
CC=gcc
CFLAGS=-g -c -Wall
AR=ar
RM=rm -rf
OPT=-O2 -lpthread
# INFO LOG LEVEL
#LIB_LOG_LVL=4
#OBJ_LOG_LVL=4
# WARN LOG LEVEL
#LIB_LOG_LVL=3
#OBJ_LOG_LVL=3
# ERROR LOG LEVEL
LIB_LOG_LVL=2
OBJ_LOG_LVL=2
# lib build
# ====================================================
all: $(LIBDIR) $(DEPSDIR) $(OBJDIR) $(LIB).so
$(LIBDIR):
mkdir $(LIBDIR)
$(OBJDIR):
mkdir $(OBJDIR)
$(DEPSDIR):
mkdir $(DEPSDIR)
$(LIB).so: $(LIB).o
$(CC) -g -shared $(LIBDIR)/$(LIB).o $(OBJ) -ldl -Wl,-soname -Wl,$(LIB).so.0 -o $(LIB).so -lpthread
$(AR) cr $(LIBDIR)/$(LIB).a $(LIB).o
ranlib $(LIBDIR)/$(LIB).a
$(LIB).o: $(LIB).c mpsock_http.h uthash.h $(OBJ)
$(CC) -I. -DLOG_LEVEL=$(LIB_LOG_LVL) -g $(OPT) -MT $(LIB).lo -MD -MP -MF $(DEPSDIR)/$(LIB).Tpo -c $(LIB).c -fPIC -DPIC -o $(LIBDIR)/$(LIB).o
$(CC) -I. -DLOG_LEVEL=$(LIB_LOG_LVL) -g $(OPT) -MT $(LIB).lo -MD -MP -MF $(DEPSDIR)/$(LIB).Tpo -c $(LIB).c -o $(LIB).o >/dev/null 2>&1
# ====================================================
# single object build
# ===================================================
$(OBJDIR)/%.o: %.c $(HEADERS)
$(CC) -DHTTP_PARSER_STRICT=0 -DLOG_LEVEL=$(OBJ_LOG_LVL) $(CFLAGS) $(OPT) $< -fPIC -o $@
# ==================================================
# others
# ===========================================================
sanity: $(LIB).so
@$(RM) 943451_423790771050103_1325449100_n.jpg*
@echo " ";
@echo "+----------------------------------------------------------+";
@echo "| Downloading a file using the legacy WGET ... |";
@echo "+----------------------------------------------------------+";
@wget -q -t 1 --no-cache --no-proxy --no-dns-cache --no-check-certificate http://sphotos-f.ak.fbcdn.net/hphotos-ak-ash3/943451_423790771050103_1325449100_n.jpg
@md5sum 943451_423790771050103_1325449100_n.jpg
@echo " ";
@echo "+----------------------------------------------------------+";
@echo "| Now, downloading the same file using WGET-over-mHTTP ... |";
@echo "| (Connection: 1, Interface: 1, chunk size: 10KB) |";
@echo "+----------------------------------------------------------+";
@sudo LD_PRELOAD=./libmpsocket.so CHUNK_SIZE_IN_KB=10 CONNECTIONS=1 INTERFACES=0 IPADDRS=0 wget -q -t 1 --no-cache --no-proxy --no-dns-cache --no-check-certificate http://sphotos-f.ak.fbcdn.net/hphotos-ak-ash3/943451_423790771050103_1325449100_n.jpg
@md5sum 943451_423790771050103_1325449100_n.jpg.1
@echo " ";
@$(RM) 943451_423790771050103_1325449100_n.jpg*
test-1M:
mkdir -p ./test
wget -O ./test/http-1M-result http://fishi.devtail.com/content-images/mhttp-blobs/1M
sudo LD_PRELOAD=./libmpsocket.so INITIAL_CHUNK_SIZE_IN_KB=64 CONNECTIONS=2 INTERFACES=eth0,eth0 IPADDRS=0 wget -e robots=off -E -H -K -v -t 1 --no-check-certificate --no-cache --no-proxy --no-dns-cache -O ./test/mhttp-1M-result http://fishi.devtail.com/content-images/mhttp-blobs/1M
diff ./test/mhttp-1M-result ./test/http-1M-result && (echo "Success" && exit 0) || (exit 1)
test-5M:
mkdir -p ./test
wget -O ./test/http-5M-result http://fishi.devtail.com/content-images/mhttp-blobs/5M
sudo LD_PRELOAD=./libmpsocket.so INITIAL_CHUNK_SIZE_IN_KB=64 CONNECTIONS=2 INTERFACES=eth0,eth0 IPADDRS=0 wget -e robots=off -E -H -K -v -t 1 --no-check-certificate --no-cache --no-proxy --no-dns-cache -O ./test/mhttp-5M-result http://fishi.devtail.com/content-images/mhttp-blobs/5M
diff ./test/mhttp-5M-result ./test/http-5M-result && (echo "Success" && exit 0) || (exit 1)
clean:
$(RM) $(LIB).o
$(RM) $(LIB).so
$(RM) $(OBJ)
$(RM) $(DEPSDIR)/$(LIB).Tpo
$(RM) $(LIBDIR)/$(LIB).a
$(RM) $(LIBDIR)/$(LIB).o
$(RM) $(LIBDIR)/$(LIB).so.0
$(RM) $(LIBDIR)/$(LIB).la
$(RM) $(LIBDIR)/$(LIB).so
$(RM) $(LIBDIR)/$(LIB).so.0.0.0
$(RM) $(LIBDIR)
$(RM) $(DEPSDIR)
$(RM) $(OBJDIR)
.PHONY: