This repository has been archived by the owner on May 15, 2021. It is now read-only.
forked from Levak/warfacebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·316 lines (289 loc) · 9.89 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
CC=gcc
CFLAGS+= -Wall -Wextra -Wno-unused-parameter
CFLAGS+= -std=gnu99 -D_GNU_SOURCE -O2 -MMD
CFLAGS+= -Iinclude -Ithird_party -DZLIB
LDLIBS+= -lz -lreadline
LDLIBS_DEBUG+=
DBGFLAGS= -O0 -ggdb3 -g -DDEBUG
RELEASE= wb
# Compile with TLS libraries
# (disable if not needed for third-party XMPP server)
USE_TLS?=1
ifeq ($(USE_TLS),1)
CFLAGS+= -DUSE_TLS
LDLIBS+= -lssl -lcrypto
endif
# Reset lib search path
LDLIBS+= -L=
# Specific flags for build systems
OSTYPE?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
ifneq (,$(findstring cygwin,$(OSTYPE))) # CYGWIN
LDLIBS+= -lpthread
else ifneq (,$(findstring mingw,$(OSTYPE))) # MINGW
LDLIBS+= -Wl,-Bstatic -lpthread -Wl,-Bdynamic -lws2_32 -lgdi32
CFLAGS+= -DNOCRYPT
LOADLIBES+= -Llib
else ifneq (,$(findstring linux,$(OSTYPE))) # LINUX
LDLIBS+= -pthread
CFLAGS+= -pthread
endif
# If possible, suppress valgrind warning comming from OpenSSL
VALGRIND_API= $(shell $(CC) -E -x c third_party/check_valgrind.c > /dev/null 2> /dev/null && echo '-DVALGRIND_API' || echo ' ')
# Some OS don't provide standard strndup
HAVE_STRNDUP= $(shell echo 'extern char*strndup(const char*,int);main(){strndup("",0);}' | $(CC) -x c -D_GNU_SOURCE -> /dev/null 2> /dev/null && rm -f a.exe a.out && echo '-DHAVE_STRNDUP' || echo ' ')
all: $(RELEASE)
options:
echo $(VALGRIND_API) $(HAVE_STRNDUP) > .opt
.PHONY: options
CFLAGS+=$(shell test -f .opt && cat .opt)
# Object file list
OBJ = \
./src/clanmate.o \
./src/cmd/complete.o \
./src/cmd/cmd_add.o \
./src/cmd/cmd_change.o \
./src/cmd/cmd_channel.o \
./src/cmd/cmd_clan_create.o \
./src/cmd/cmd_clan_leave.o \
./src/cmd/cmd_clan_invite.o \
./src/cmd/cmd_create.o \
./src/cmd/cmd_exec.o \
./src/cmd/cmd_follow.o \
./src/cmd/cmd_friends.o \
./src/cmd/cmd_invite.o \
./src/cmd/cmd_last.o \
./src/cmd/cmd_leave.o \
./src/cmd/cmd_master.o \
./src/cmd/cmd_missions.o \
./src/cmd/cmd_name.o \
./src/cmd/cmd_open.o \
./src/cmd/cmd_quit.o \
./src/cmd/cmd_randombox.o \
./src/cmd/cmd_ready.o \
./src/cmd/cmd_remove.o \
./src/cmd/cmd_removeall.o \
./src/cmd/cmd_safe.o \
./src/cmd/cmd_say.o \
./src/cmd/cmd_sleep.o \
./src/cmd/cmd_sponsor.o \
./src/cmd/cmd_start.o \
./src/cmd/cmd_stats.o \
./src/cmd/cmd_stay.o \
./src/cmd/cmd_switch.o \
./src/cmd/cmd_unready.o \
./src/cmd/cmd_whisper.o \
./src/cmd/cmd_whois.o \
./src/cmd/cmd_quickplay.o \
./src/cvar.o \
./src/friend.o \
./src/gameroom.o \
./src/item.o \
./src/lang.o \
./src/offer.o \
./src/option.o \
./src/masterserver.o \
./src/mission.o \
./src/querycache.o \
./src/querydump.o \
./src/quickplay.o \
./src/pvp_maps.o \
./src/session.o \
./src/status.o \
./src/stream/connect.o \
./src/stream/crypt.o \
./src/stream/recv.o \
./src/stream/send.o \
./src/stream/tls.o \
./src/threads/threads.o \
./src/threads/thread_dispatch.o \
./src/threads/thread_ping.o \
./src/threads/thread_sendstream.o \
./src/threads/thread_readstream.o \
./src/threads/thread_readline.o \
./third_party/rl_fprintf.o \
./third_party/stub-getline.o \
./third_party/stub-strcasestr.o \
./third_party/stub-strndup.o \
./third_party/stub-strtok_r.o \
./third_party/wake.o \
./src/tools/base64.o \
./src/tools/geoip.o \
./src/tools/get_info.o \
./src/tools/list.o \
./src/tools/uuid.o \
./src/tools/zlibb64.o \
./src/wb.o \
./src/xml/serializer.o \
./src/xmpp/get/xmpp_bind.o \
./src/xmpp/get/xmpp_iq_ping.o \
./src/xmpp/get/xmpp_iq_session.o \
./src/xmpp/get/xmpp_presence.o \
./src/xmpp/get/xmpp_room_message.o \
./src/xmpp/get/xmpp_sasl.o \
./src/xmpp/get/xmpp_starttls.o \
./src/xmpp/get/xmpp_stream.o \
./src/xmpp/id_handler.o \
./src/xmpp/query_handler.o \
./src/xmpp/result/xmpp_iq_ping.o \
./src/xmpp/result/xmpp_presence.o \
./src/xmpp/room.o \
./src/xmpp/sasl.o \
./src/xmpp/send.o \
./src/xmpp/tools.o \
./src/xmpp_wf/close.o \
./src/xmpp_wf/connect.o \
./src/xmpp_wf/get/xmpp_iq_account.o \
./src/xmpp_wf/get/xmpp_iq_clan_create.o \
./src/xmpp_wf/get/xmpp_iq_clan_leave.o \
./src/xmpp_wf/get/xmpp_iq_confirm_notification.o \
./src/xmpp_wf/get/xmpp_iq_create_profile.o \
./src/xmpp_wf/get/xmpp_iq_follow_send.o \
./src/xmpp_wf/get/xmpp_iq_gameroom_askserver.o \
./src/xmpp_wf/get/xmpp_iq_gameroom_get.o \
./src/xmpp_wf/get/xmpp_iq_gameroom_join.o \
./src/xmpp_wf/get/xmpp_iq_gameroom_kick.o \
./src/xmpp_wf/get/xmpp_iq_gameroom_leave.o \
./src/xmpp_wf/get/xmpp_iq_gameroom_open.o \
./src/xmpp_wf/get/xmpp_iq_gameroom_quickplay.o \
./src/xmpp_wf/get/xmpp_iq_gameroom_quickplay_cancel.o \
./src/xmpp_wf/get/xmpp_iq_preinvite_cancel.o \
./src/xmpp_wf/get/xmpp_iq_preinvite_invite.o \
./src/xmpp_wf/get/xmpp_iq_gameroom_promote_to_host.o \
./src/xmpp_wf/get/xmpp_iq_gameroom_setinfo.o \
./src/xmpp_wf/get/xmpp_iq_gameroom_setname.o \
./src/xmpp_wf/get/xmpp_iq_gameroom_setplayer.o \
./src/xmpp_wf/get/xmpp_iq_gameroom_update_pvp.o \
./src/xmpp_wf/get/xmpp_iq_get_account_profiles.o \
./src/xmpp_wf/get/xmpp_iq_get_achievements.o \
./src/xmpp_wf/get/xmpp_iq_get_configs.o \
./src/xmpp_wf/get/xmpp_iq_get_last_seen_date.o \
./src/xmpp_wf/get/xmpp_iq_get_master_servers.o \
./src/xmpp_wf/get/xmpp_iq_get_master_server.o \
./src/xmpp_wf/get/xmpp_iq_get_player_stats.o \
./src/xmpp_wf/get/xmpp_iq_get_reward_multipliers.o \
./src/xmpp_wf/get/xmpp_iq_invitation_send.o \
./src/xmpp_wf/get/xmpp_iq_items.o \
./src/xmpp_wf/get/xmpp_iq_join_channel.o \
./src/xmpp_wf/get/xmpp_iq_missions_get_list.o \
./src/xmpp_wf/get/xmpp_iq_p2p_ping.o \
./src/xmpp_wf/get/xmpp_iq_peer_clan_member_update.o \
./src/xmpp_wf/get/xmpp_iq_peer_player_info.o \
./src/xmpp_wf/get/xmpp_iq_peer_status_update.o \
./src/xmpp_wf/get/xmpp_iq_player_status.o \
./src/xmpp_wf/get/xmpp_iq_profile_info_get_status.o \
./src/xmpp_wf/get/xmpp_iq_querycache.o \
./src/xmpp_wf/get/xmpp_iq_quickplay_maplist.o \
./src/xmpp_wf/get/xmpp_iq_remove_friend.o \
./src/xmpp_wf/get/xmpp_iq_resync_profile.o \
./src/xmpp_wf/get/xmpp_iq_shop_get_offers.o \
./src/xmpp_wf/get/xmpp_iq_send_invitation.o \
./src/xmpp_wf/get/xmpp_print_number_of_occupants.o \
./src/xmpp_wf/get/xmpp_send_message.o \
./src/xmpp_wf/result/xmpp_iq_autorotate.o\
./src/xmpp_wf/result/xmpp_iq_broadcast_session_result.o\
./src/xmpp_wf/result/xmpp_iq_clan_info.o \
./src/xmpp_wf/result/xmpp_iq_clan_masterbanner_update.o \
./src/xmpp_wf/result/xmpp_iq_clan_members_updated.o \
./src/xmpp_wf/result/xmpp_iq_follow_send.o \
./src/xmpp_wf/result/xmpp_iq_friend_list.o \
./src/xmpp_wf/result/xmpp_iq_gameroom_loosemaster.o \
./src/xmpp_wf/result/xmpp_iq_gameroom_offer.o \
./src/xmpp_wf/result/xmpp_iq_gameroom_on_expired.o \
./src/xmpp_wf/result/xmpp_iq_gameroom_on_kicked.o \
./src/xmpp_wf/result/xmpp_iq_gameroom_quickplay_started.o \
./src/xmpp_wf/result/xmpp_iq_gameroom_quickplay_succeeded.o \
./src/xmpp_wf/result/xmpp_iq_gameroom_quickplay_canceled.o \
./src/xmpp_wf/result/xmpp_iq_gameroom_sync.o \
./src/xmpp_wf/result/xmpp_iq_invitation_request.o \
./src/xmpp_wf/result/xmpp_iq_invitation_result.o \
./src/xmpp_wf/result/xmpp_iq_notification_broadcast.o \
./src/xmpp_wf/result/xmpp_iq_p2p_ping.o \
./src/xmpp_wf/result/xmpp_iq_peer_clan_member_update.o \
./src/xmpp_wf/result/xmpp_iq_peer_player_info.o \
./src/xmpp_wf/result/xmpp_iq_peer_status_update.o \
./src/xmpp_wf/result/xmpp_iq_preinvite_cancel.o \
./src/xmpp_wf/result/xmpp_iq_preinvite_invite.o \
./src/xmpp_wf/result/xmpp_iq_preinvite_response.o \
./src/xmpp_wf/result/xmpp_iq_shop_sync_consummables.o\
./src/xmpp_wf/result/xmpp_iq_sponsor_info_updated.o\
./src/xmpp_wf/result/xmpp_iq_sync_notifications.o \
./src/xmpp_wf/result/xmpp_iq_update_cry_money.o\
./src/xmpp_wf/result/xmpp_message.o \
./src/xmpp_wf/tools.o \
$(RELEASE): | options
$(RELEASE): $(OBJ)
$(RELEASE):
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
debug-wb: CFLAGS+= $(DBGFLAGS)
debug-wb: LDLIBS+= $(LDLIBS_DEBUG)
debug-wb: wb
debug-manager: CFLAGS+= $(DBGFLAGS)
debug-manager: LDLIBS+= $(LDLIBS_DEBUG)
debug-manager: manager
DBUS_API= ./src/dbus/org.levak.Warfacebot.xml
DBUS_API_PREFIX= org.levak
DBUS_API_GENERATED= generated-wb-api
DBUS_CFLAGS=$(shell pkg-config --cflags glib-2.0 gio-unix-2.0)
DBUS_CFLAGS+= -I.
DBUS_LDLIBS=$(shell pkg-config --libs glib-2.0 gio-unix-2.0)
manager: CFLAGS+= -DDBUS_API
DBUS_OBJ= \
./src/dbus/wbd.o \
./src/dbus/methods/buddies.o \
./src/dbus/methods/buddy_add.o \
./src/dbus/methods/buddy_follow.o \
./src/dbus/methods/buddy_invite.o \
./src/dbus/methods/buddy_last_seen.o \
./src/dbus/methods/buddy_remove.o \
./src/dbus/methods/buddy_remove_all.o \
./src/dbus/methods/buddy_whisper.o \
./src/dbus/methods/buddy_whois.o \
./src/dbus/methods/channel_stats.o \
./src/dbus/methods/channel_switch.o \
./src/dbus/methods/chat_room_join.o \
./src/dbus/methods/chat_room_leave.o \
./src/dbus/methods/crown_challenge.o \
./src/dbus/methods/player_peer_info.o \
./src/dbus/methods/quickplay_cancel.o \
./src/dbus/methods/quickplay_invite.o \
./src/dbus/methods/quickplay_open.o \
./src/dbus/methods/quickplay_start.o \
./src/dbus/methods/quit.o \
./src/dbus/methods/room_change_map.o \
./src/dbus/methods/room_change_team.o \
./src/dbus/methods/room_give_master.o \
./src/dbus/methods/room_leave.o \
./src/dbus/methods/room_open.o \
./src/dbus/methods/room_participants.o \
./src/dbus/methods/room_ready.o \
./src/dbus/methods/room_rename.o \
./src/dbus/methods/room_say.o \
./src/dbus/methods/room_start.o \
./src/dbus/methods/room_take_class.o \
./src/dbus/methods/room_get.o \
./src/dbus/methods/clan_leave.o \
./src/dbus/methods/shop_offers.o \
$(DBUS_API_GENERATED).o
manager: | options
manager: $(OBJ) wbm wbd
$(DBUS_API_GENERATED).o: CFLAGS+= -Wno-unused-variable
$(DBUS_API_GENERATED).c: $(DBUS_API)
gdbus-codegen \
--interface-prefix $(DBUS_API_PREFIX) \
--generate-c-code $(DBUS_API_GENERATED) \
--c-generate-object-manager \
$?
wbd: CFLAGS+=$(DBUS_CFLAGS)
wbd: LDLIBS+=$(DBUS_LDLIBS)
wbd: $(DBUS_API_GENERATED).o $(DBUS_OBJ) $(OBJ)
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
wbm: CFLAGS+=$(DBUS_CFLAGS)
wbm: LDLIBS+=$(DBUS_LDLIBS)
wbm: $(DBUS_API_GENERATED).o ./src/dbus/wbm.o
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
clean:
$(RM) wb wbs $(OBJ)
$(RM) wbm wbd $(DBUS_API_GENERATED).[cho] ./src/dbus/wbm.o $(DBUS_OBJ)
$(RM) .opt $(DEPS)
DEPS=$(OBJ:.o=.d) $(DBUS_OBJ:.o=.d)
-include $(DEPS)