-
Notifications
You must be signed in to change notification settings - Fork 136
/
Makefile
173 lines (131 loc) · 5.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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
COMMON_NAME := libopen-trade-common.so
CTP_NAME := open-trade-ctp
CTP_SOPT_NAME := open-trade-ctpsopt
CTPSE15_NAME := open-trade-ctpse15
SIM_NAME := open-trade-sim
KS_NAME := open-trade-kingstar
MD_NAME := open-trade-mdservice
GATEWAY_NAME := open-trade-gateway
GATEWAYMS_NAME := open-trade-gateway-ms
COMMON_SRCS := $(wildcard open-trade-common/*.cpp)
CTP_SRCS:= $(wildcard open-trade-ctp/*.cpp)
CTP_SOPT_SRCS:= $(wildcard open-trade-ctpsopt/*.cpp)
CTPSE15_SRCS:= $(wildcard open-trade-ctpse15/*.cpp)
SIM_SRCS:= $(wildcard open-trade-sim/*.cpp)
KS_SRCS:= $(wildcard open-trade-kingstar/*.cpp)
MD_SRCS:= $(wildcard open-trade-mdservice/*.cpp)
GATEWAY_SRCS:= $(wildcard open-trade-gateway/*.cpp)
GATEWAYMS_SRCS:= $(wildcard open-trade-gateway-ms/*.cpp)
COMMON_OBJS := $(patsubst open-trade-common/%,obj/common/%,$(COMMON_SRCS:.cpp=.o))
CTP_OBJS := $(patsubst open-trade-ctp/%,obj/ctp/%,$(CTP_SRCS:.cpp=.o))
CTP_SOPT_OBJS := $(patsubst open-trade-ctpsopt/%,obj/ctpsopt/%,$(CTP_SOPT_SRCS:.cpp=.o))
CTPSE15_OBJS := $(patsubst open-trade-ctpse15/%,obj/ctpse15/%,$(CTPSE15_SRCS:.cpp=.o))
SIM_OBJS := $(patsubst open-trade-sim/%,obj/sim/%,$(SIM_SRCS:.cpp=.o))
KS_OBJS := $(patsubst open-trade-kingstar/%,obj/ks/%,$(KS_SRCS:.cpp=.o))
MD_OBJS := $(patsubst open-trade-mdservice/%,obj/md/%,$(MD_SRCS:.cpp=.o))
GATEWAY_OBJS := $(patsubst open-trade-gateway/%,obj/gateway/%,$(GATEWAY_SRCS:.cpp=.o))
GATEWAYMS_OBJS := $(patsubst open-trade-gateway-ms/%,obj/gatewayms/%,$(GATEWAYMS_SRCS:.cpp=.o))
COMMON_DEPS := $(COMMON_OBJS:%.o=%.d)
CTP_DEPS := $(CTP_OBJS:%.o=%.d)
CTP_SOPT_DEPS := $(CTP_SOPT_OBJS:%.o=%.d)
CTPSE15_DEPS := $(CTPSE15_OBJS:%.o=%.d)
SIM_DEPS := $(SIM_OBJS:%.o=%.d)
KS_DEPS := $(KS_OBJS:%.o=%.d)
MD_DEPS := $(MD_OBJS:%.o=%.d)
GATEWAY_DEPS := $(GATEWAY_OBJS:%.o=%.d)
GATEWAYMS_DEPS := $(GATEWAYMS_OBJS:%.o=%.d)
CXXFLAGS += -std=c++17 -pthread -g -O2 -flto -Icontrib/include/ \
-Iopen-trade-common/
LDFLAGS += -Lcontrib/lib
LDFLAGS += -Lcontrib/lib/ks
LDLIBS += -lssl -lcrypto -lcurl -lboost_system -lstdc++fs -lrt
.PHONY: all clean install
all: bin/$(COMMON_NAME) bin/$(CTP_NAME) bin/$(CTP_SOPT_NAME) bin/$(CTPSE15_NAME) bin/$(SIM_NAME) bin/$(KS_NAME) bin/$(MD_NAME) bin/$(GATEWAY_NAME) bin/$(GATEWAYMS_NAME)
bin/$(COMMON_NAME): $(COMMON_OBJS)
@mkdir -p $(@D)
$(CXX) -fPIC -shared -o $@ $^
obj/common/%.o: open-trade-common/%.cpp
@mkdir -p $(@D)
$(CXX) -o $@ -MMD -MP $(CPPFLAGS) $(CXXFLAGS) -c $<
-include $(COMMON_DEPS)
LDFLAGS += -Lbin/
LDLIBS +=-lopen-trade-common
LDLIBS +=-lboost_thread -lboost_filesystem -lboost_regex -lboost_chrono
LDLIBS_CTP = $(LDLIBS) -lthosttraderapi
LDLIBS_CTP_SOPT = $(LDLIBS) -lthosttraderapisopt
LDLIBS_CTPSE15 = $(LDLIBS) -lthosttraderapise15
LDLIBS_KS = $(LDLIBS) -lkcc -lkslkc64r -lkstradeapi
bin/$(CTP_NAME):$(CTP_OBJS)
@mkdir -p $(@D)
$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $^ $(LDLIBS_CTP)
obj/ctp/%.o: open-trade-ctp/%.cpp
@mkdir -p $(@D)
$(CXX) -o $@ -MMD -MP $(CPPFLAGS) $(CXXFLAGS) -c $<
-include $(CTP_DEPS)
bin/$(CTP_SOPT_NAME):$(CTP_SOPT_OBJS)
@mkdir -p $(@D)
$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $^ $(LDLIBS_CTP_SOPT)
obj/ctpsopt/%.o: open-trade-ctpsopt/%.cpp
@mkdir -p $(@D)
$(CXX) -o $@ -MMD -MP $(CPPFLAGS) $(CXXFLAGS) -c $<
-include $(CTP_SOPT_DEPS)
bin/$(CTPSE15_NAME):$(CTPSE15_OBJS)
@mkdir -p $(@D)
$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $^ $(LDLIBS_CTPSE15)
obj/ctpse15/%.o: open-trade-ctpse15/%.cpp
@mkdir -p $(@D)
$(CXX) -o $@ -MMD -MP $(CPPFLAGS) $(CXXFLAGS) -c $<
-include $(CTPSE15_DEPS)
bin/$(SIM_NAME):$(SIM_OBJS)
@mkdir -p $(@D)
$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $^ $(LDLIBS)
obj/sim/%.o: open-trade-sim/%.cpp
@mkdir -p $(@D)
$(CXX) -o $@ -MMD -MP $(CPPFLAGS) $(CXXFLAGS) -c $<
-include $(SIM_DEPS)
bin/$(KS_NAME):$(KS_OBJS)
@mkdir -p $(@D)
$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $^ $(LDLIBS_KS)
obj/ks/%.o: open-trade-kingstar/%.cpp
@mkdir -p $(@D)
$(CXX) -o $@ -MMD -MP $(CPPFLAGS) $(CXXFLAGS) -c $<
-include $(KS_DEPS)
bin/$(MD_NAME):$(MD_OBJS)
@mkdir -p $(@D)
$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $^ $(LDLIBS)
obj/md/%.o: open-trade-mdservice/%.cpp
@mkdir -p $(@D)
$(CXX) -o $@ -MMD -MP $(CPPFLAGS) $(CXXFLAGS) -c $<
-include $(MD_DEPS)
bin/$(GATEWAY_NAME):$(GATEWAY_OBJS)
@mkdir -p $(@D)
$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $^ $(LDLIBS)
obj/gateway/%.o: open-trade-gateway/%.cpp
@mkdir -p $(@D)
$(CXX) -o $@ -MMD -MP $(CPPFLAGS) $(CXXFLAGS) -c $<
-include $(GATEWAY_DEPS)
bin/$(GATEWAYMS_NAME):$(GATEWAYMS_OBJS)
@mkdir -p $(@D)
$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $^ $(LDLIBS)
obj/gatewayms/%.o: open-trade-gateway-ms/%.cpp
@mkdir -p $(@D)
$(CXX) -o $@ -MMD -MP $(CPPFLAGS) $(CXXFLAGS) -c $<
-include $(GATEWAYMS_DEPS)
clean:
@$(RM) -rf bin obj
install: all
install -d /etc/$(GATEWAY_NAME)
install -m 777 -d /var/local/lib/$(GATEWAY_NAME)
install -m 777 -d /var/log/$(GATEWAY_NAME)
install -m 755 bin/$(COMMON_NAME) /usr/local/bin/
install -m 755 bin/$(CTP_NAME) /usr/local/bin/
install -m 755 bin/$(CTP_SOPT_NAME) /usr/local/bin/
install -m 755 bin/$(CTPSE15_NAME) /usr/local/bin/
install -m 755 bin/$(SIM_NAME) /usr/local/bin/
install -m 755 bin/$(KS_NAME) /usr/local/bin/
install -m 755 bin/$(MD_NAME) /usr/local/bin/
install -m 755 bin/$(GATEWAY_NAME) /usr/local/bin/
install -m 755 bin/$(GATEWAYMS_NAME) /usr/local/bin/
install -m 755 contrib/lib/*.so /usr/local/lib/
install -m 755 contrib/lib/ks/*.* /usr/local/bin/
install -m 644 conf/* /etc/$(GATEWAY_NAME)/