-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
278 lines (219 loc) · 6.07 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
CC := $(CROSS_COMPILE)gcc
WINDRES := $(CROSS_COMPILE)windres
XGETTEXT := xgettext
MSGFMT := msgfmt
PLATFORM := $(shell $(CC) -dumpmachine | awk -F - '{ print $$NF }')
purple_name := purple
PURPLE_CFLAGS := $(shell pkg-config --cflags $(purple_name))
PURPLE_LIBS := $(shell pkg-config --libs $(purple_name))
PURPLE_LIBDIR := $(shell pkg-config --variable=libdir $(purple_name))
PURPLE_DATADIR := $(shell pkg-config --variable=datadir $(purple_name))
PURPLE_PLUGINDIR := $(shell pkg-config --variable=plugindir $(purple_name))
GIO_CFLAGS := $(shell pkg-config --cflags gio-2.0)
GIO_LIBS := $(shell pkg-config --libs gio-2.0)
# default configuration options
CVR := y
LIBSIREN := y
LIBMSPACK := y
PLUS_SOUNDS := y
DEBUG := y
DIRECTCONN := y
GIO := y
CFLAGS := -O2
EXTRA_WARNINGS := -Wall -Wextra -Wformat-nonliteral -Wcast-align -Wpointer-arith \
-Wbad-function-cast -Wmissing-prototypes -Wstrict-prototypes \
-Wmissing-declarations -Winline -Wundef -Wnested-externs -Wcast-qual \
-Wshadow -Wwrite-strings -Wno-unused-parameter -Wfloat-equal -std=c99
SIMPLE_WARNINGS := -Wall -Wextra -std=c99 -Wno-unused-parameter -Wmissing-prototypes
OTHER_WARNINGS := -D_FORTIFY_SOURCE=2 -fstack-protector -g3 -Wdisabled-optimization \
-Wendif-labels -Wformat=2 -Wstack-protector -Wswitch
CFLAGS += -Wall $(SIMPLE_WARNINGS)
ifdef DEBUG
override CFLAGS += -ggdb
endif
ifdef DEVEL
override CFLAGS += -DPECAN_DEVEL
endif
override CFLAGS += -D_XOPEN_SOURCE
override CFLAGS += -I. -DENABLE_NLS -DHAVE_LIBPURPLE -DPURPLE_DEBUG
ifdef CVR
override CFLAGS += -DPECAN_CVR
endif
ifndef DO_NOT_USE_PSM
override CFLAGS += -DPECAN_USE_PSM
endif
ifdef LIBSIREN
override CFLAGS += -DPECAN_LIBSIREN
LIBSIREN_LIBS := -lm
endif
ifdef LIBMSPACK
override CFLAGS += -DPECAN_LIBMSPACK
LIBMSPACK_LIBS := -lm
endif
ifdef PLUS_SOUNDS
override CFLAGS += -DRECEIVE_PLUS_SOUNDS
endif
ifdef GIO
override CFLAGS += -DUSE_GIO
endif
# extra debugging
override CFLAGS += -DPECAN_DEBUG_SLP
LDFLAGS := -Wl,--no-undefined
objects := msn.o \
nexus.o \
notification.o \
page.o \
session.o \
switchboard.o \
sync.o \
pn_log.o \
pn_printf.o \
pn_util.o \
pn_buffer.o \
pn_error.o \
pn_status.o \
pn_oim.o \
pn_dp_manager.o \
pn_auth.o \
cmd/cmdproc.o \
cmd/command.o \
cmd/msg.o \
cmd/table.o \
cmd/transaction.o \
io/pn_parser.o \
ab/pn_group.o \
ab/pn_contact.o \
ab/pn_contactlist.o \
io/pn_stream.o \
io/pn_node.o \
io/pn_cmd_server.o \
io/pn_http_server.o \
io/pn_ssl_conn.o \
fix_purple.o
ifdef CVR
objects += cvr/pn_peer_call.o \
cvr/pn_peer_link.o \
cvr/pn_peer_msg.o \
cvr/pn_msnobj.o
objects += libpurple/xfer.o
endif
ifdef DIRECTCONN
objects += cvr/pn_direct_conn.o
objects += io/pn_dc_conn.o
override CFLAGS += -DMSN_DIRECTCONN
endif
ifdef LIBSIREN
objects += ext/libsiren/common.o \
ext/libsiren/dct4.o \
ext/libsiren/decoder.o \
ext/libsiren/huffman.o \
ext/libsiren/rmlt.o \
pn_siren7.o
endif
ifdef LIBMSPACK
objects += ext/libmspack/cabd.o \
ext/libmspack/mszipd.o \
ext/libmspack/lzxd.o \
ext/libmspack/qtmd.o \
ext/libmspack/system.o
endif
sources := $(objects:.o=.c)
deps := $(objects:.o=.d)
CATALOGS := ar da de eo es fi fr tr hu it nb nl pt_BR pt sr sv tr zh_CN zh_TW
ifeq ($(PLATFORM),darwin)
SHLIBEXT := dylib
else
ifeq ($(PLATFORM),mingw32)
SHLIBEXT := dll
LDFLAGS += -Wl,--enable-auto-image-base -L./win32
objects += win32/resource.res
else
SHLIBEXT := so
endif
endif
ifdef STATIC
SHLIBEXT := a
override CFLAGS += -DSTATIC_PECAN
else
ifneq ($(PLATFORM),mingw32)
override CFLAGS += -fPIC
endif
endif
plugin := libmsn-pecan.$(SHLIBEXT)
.PHONY: clean
all: $(plugin)
version := $(shell ./get-version)
# pretty print
ifndef V
QUIET_CC = @echo ' CC '$@;
QUIET_LINK = @echo ' LINK '$@;
QUIET_CLEAN = @echo ' CLEAN '$@;
QUIET_MO = @echo ' MSGFMT '$@;
QUIET_WR = @echo ' WINDRES '$@;
endif
D = $(DESTDIR)
plugin_libs := $(PURPLE_LIBS) $(GIO_LIBS)
ifdef LIBSIREN
plugin_libs += $(LIBSIREN_LIBS)
endif
ifdef LIBMSPACK
plugin_libs += $(LIBMSPACK_LIBS)
endif
$(plugin): $(objects)
$(plugin): CFLAGS := $(CFLAGS) $(PURPLE_CFLAGS) $(GIO_CFLAGS) -D VERSION='"$(version)"'
$(plugin): LIBS := $(plugin_libs)
messages.pot: $(sources)
$(XGETTEXT) -m -c --keyword --keyword=_ --keyword=N_ -o $@ $^
%.dylib::
$(QUIET_LINK)$(CC) $(LDFLAGS) -dynamiclib -o $@ $^ $(LIBS)
%.so %.dll::
$(QUIET_LINK)$(CC) $(LDFLAGS) -shared -o $@ $^ $(LIBS)
%.a::
$(QUIET_LINK)$(AR) rcs $@ $^
%.o:: %.c
$(QUIET_CC)$(CC) $(CFLAGS) -MMD -o $@ -c $<
%.res:: %.rc
$(QUIET_WR)$(WINDRES) $< -O coff -o $@
clean:
$(QUIET_CLEAN)$(RM) $(plugin) $(objects) $(deps) `find -name '*.mo'`
%.mo:: %.po
$(QUIET_MO)$(MSGFMT) -c -o $@ $<
dist: base := msn-pecan-$(version)
dist:
echo $(version) > .version
git-changelog > ChangeLog
tar -cJf /tmp/$(base).tar.xz --transform='s#^#$(base)/#' -- `git ls-files` .version ChangeLog
rm -rf .version ChangeLog
install: $(plugin)
install -D $(plugin) $(D)$(PURPLE_PLUGINDIR)/$(plugin)
# chcon -t textrel_shlib_t $(D)$(PURPLE_PLUGINDIR)/$(plugin) # for selinux
uninstall:
rm -f $(D)$(PURPLE_PLUGINDIR)/$(plugin)
for x in $(CATALOGS); do \
rm -f $(D)$(PURPLE_DATADIR)/locale/$$x/LC_MESSAGES/libmsn-pecan.mo; \
done
update_locales: messages.pot
for x in $(CATALOGS); do \
msgmerge -N -U --backup=off po/$$x.po $<; \
done
locales: $(foreach e,$(CATALOGS),po/$(e).mo)
install_locales: locales
for x in $(CATALOGS); do \
install -m 644 -D po/$$x.mo $(D)$(PURPLE_DATADIR)/locale/$$x/LC_MESSAGES/libmsn-pecan.mo; \
done
install_all: install install_locales
win32-check:
test -f win32/libintl.dll.a
win32: D := win32/libmsn-pecan
win32: win32-check $(plugin) locales
mkdir -p $(D)/plugins
cp $(plugin) libmsn-pecan-$(version)-dbg.dll
$(CROSS_COMPILE)strip $(plugin)
cp $(plugin) $(D)/plugins/
for x in $(CATALOGS); do \
mkdir -p $(D)/locale/$$x/LC_MESSAGES/; \
cp po/$$x.mo $(D)/locale/$$x/LC_MESSAGES/libmsn-pecan.mo; \
done
cp COPYING $(D)
makensis win32/installer.nsi
-include $(deps)