-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
117 lines (84 loc) · 3.32 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
112
113
114
115
116
117
CXX:=$(shell sh -c 'type $(CXX) >/dev/null 2>/dev/null && echo $(CXX) || echo g++')
#CXX = clang++-3.8
INSTALL = install
INSTALL_INCLUDE_PATH = /usr/local/include
INSTALL_LIB_PATH = /usr/local/lib
OPTIMIZATION = -O0
WARNINGS = \
-Wall \
-Wno-sign-compare \
-Wno-deprecated-register \
-Wno-unused-function \
-Winline
DEBUG = -g
STDC = -std=c++1y
LDFLAGS = -lstdc++ -pthread
CXXFLAGS = $(OPTIMIZATION) -fPIC -fstack-protector $(CFLAGS) $(WARNINGS) $(DEBUG) $(STDC) -DUSE_CXX0X
STDLIB =
ifeq ($(shell uname -s), FreeBSD)
STDLIB += -stdlib=libstdc++
endif
CXXFLAGS += $(STDLIB)
CFLAGS=-c -Wall
LIB_ASIO_STATIC_INC = -Wl,-Bstatic -l asioredis -Wl,-Bdynamic
LIB_ASIO_DYNAMIC_INC = -Wl,-Bdynamic -l asioredis
LIB_ASIO_DYN_INCLUDE = -l asioredis
LIB_SOURCES = src/client.cpp \
src/conn_pool.cpp \
src/pipeline.cpp \
src/serial.cpp \
src/proto.cpp \
src/query.cpp \
src/io_buffers.cpp \
src/buff_abstract.cpp \
src/cmd_traits.cpp \
src/h_net.cpp \
src/h_strings.cpp \
src/proc_abstract.cpp
LIB_NAME = libasioredis.so
LIB_OBJECTS=$(LIB_SOURCES:.cpp=.o)
EX_BASE_SOURCES = examples/example.cpp
EX_BASE_EXEC = examples/base-example
EX_BASE_OBJ=$(EX_BASE_SOURCES:.cpp=.o)
EX_HIREDIS_SOURCES = examples/hiredis_test.cpp
EX_HIREDIS_EXEC = examples/hiredis-test
EX_HIREDIS_OBJ=$(EX_HIREDIS_SOURCES:.cpp=.o)
EX_DBUF_SOURCES = examples/direct_buff.cpp
EX_DBUF_EXEC = examples/direct-buf-example
EX_DBUF_OBJ=$(EX_DBUF_SOURCES:.cpp=.o)
EX_MULT_SOURCES = examples/multithread.cpp
EX_MULT_EXEC = examples/multithread
EX_MULT_OBJ=$(EX_MULT_SOURCES:.cpp=.o)
STAT_LIB_NAME=libasioredis.a
all: $(LIB_SOURCES) $(LIB_NAME) $(STAT_LIB_NAME)
examples: $(EX_BASE_SOURCES) $(EX_BASE_EXEC) $(EX_DBUF_SOURCES) $(EX_DBUF_EXEC) $(EX_HIREDIS_SOURCES) $(EX_HIREDIS_EXEC) $(EX_MULT_SOURCES) $(EX_MULT_EXEC)
install: $(LIB_NAME) $(STAT_LIB_NAME)
$(INSTALL) $(LIB_NAME) $(INSTALL_LIB_PATH)
$(INSTALL) $(STAT_LIB_NAME) $(INSTALL_LIB_PATH)
$(INSTALL) asio-redis.hpp $(INSTALL_INCLUDE_PATH)
mkdir -p $(INSTALL_INCLUDE_PATH)/asio-redis
cp -r include/* $(INSTALL_INCLUDE_PATH)/asio-redis/
reinstall: $(LIB_NAME) $(STAT_LIB_NAME)
rm -f $(INSTALL_LIB_PATH)/$(LIB_NAME) $(INSTALL_LIB_PATH)/$(STAT_LIB_NAME)
rm -rf $(INSTALL_INCLUDE_PATH)/asio-redis/
$(INSTALL) $(LIB_NAME) $(INSTALL_LIB_PATH)
$(INSTALL) $(STAT_LIB_NAME) $(INSTALL_LIB_PATH)
$(INSTALL) asio-redis.hpp $(INSTALL_INCLUDE_PATH)
mkdir -p $(INSTALL_INCLUDE_PATH)/asio-redis
cp -r include/* $(INSTALL_INCLUDE_PATH)/asio-redis/
$(EX_BASE_EXEC): $(EX_BASE_OBJ)
$(CXX) $(LDFLAGS) $(EX_BASE_OBJ) -o $@ $(LIB_ASIO_STATIC_INC)
$(EX_HIREDIS_EXEC): $(EX_HIREDIS_OBJ)
$(CXX) $(LDFLAGS) $(EX_HIREDIS_OBJ) -o $@ -lhiredis -lev
$(EX_DBUF_EXEC): $(EX_DBUF_OBJ)
$(CXX) $(LDFLAGS) $(EX_DBUF_OBJ) -o $@ $(LIB_ASIO_STATIC_INC)
$(EX_MULT_EXEC): $(EX_MULT_OBJ)
$(CXX) $(LDFLAGS) $(EX_MULT_OBJ) -o $@ $(LIB_ASIO_STATIC_INC)
$(LIB_NAME): $(LIB_OBJECTS)
$(CXX) -fPIC -shared $(LDFLAGS) $(LIB_OBJECTS) -o $@
$(STAT_LIB_NAME): $(LIB_OBJECTS)
ar -rs $@ $(LIB_OBJECTS)
.cpp.o:
$(CXX) $(CXXFLAGS) $< -o $@
clean:
rm -f $(LIB_OBJECTS) $(LIB_NAME) $(EX_BASE_OBJ) $(EX_DBUF_OBJ) $(EX_MULT_OBJ) $(EX_BASE_EXEC) $(EX_DBUF_EXEC) $(EX_MULT_EXEC) $(STAT_LIB_NAME)