Makefile
3.8 KB
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
THRIFT_STATIC_DIR = thrift_static
ifdef THRIFT_STATIC
THRIFT = $(THRIFT_STATIC_DIR)/compiler/cpp/thrift
THRIFT_CXXFLAGS = -I$(THRIFT_STATIC_DIR)/lib/cpp/src
THRIFT_LIBS = -L$(THRIFT_STATIC_DIR)/lib/cpp/.libs -Wl,-Bstatic -lthrift -Wl,-Bdynamic
THRIFT_DEP = $(THRIFT)
else
THRIFT ?= thrift
THRIFT_CXXFLAGS = `pkg-config --cflags thrift`
THRIFT_LIBS = `pkg-config --libs thrift`
endif
CXX ?= g++
CXXFLAGS = -g -Wall -Wextra -Werror -pedantic -shared -fPIC \
-DHAVE_INTTYPES_H -DHAVE_CONFIG_H -DPURPLE_PLUGINS \
`pkg-config --cflags purple` `libgcrypt-config --cflags` `gpg-error-config --cflags` \
$(THRIFT_CXXFLAGS)
LIBS = `pkg-config --libs purple` `libgcrypt-config --libs` `gpg-error-config --libs` \
$(THRIFT_LIBS)
PURPLE_PLUGIN_DIR:=$(shell pkg-config --variable=plugindir purple)
PURPLE_DATA_ROOT_DIR:=$(shell pkg-config --variable=datarootdir purple)
MAIN = libline.so
GEN_SRCS = thrift_line/line_constants.cpp thrift_line/line_types.cpp \
thrift_line/TalkService.cpp
REAL_SRCS = pluginmain.cpp linehttptransport.cpp thriftclient.cpp httpclient.cpp \
purpleline.cpp purpleline_blist.cpp purpleline_chats.cpp purpleline_cmds.cpp \
purpleline_login.cpp purpleline_write.cpp \
poller.cpp pinverifier.cpp
SRCS += $(GEN_SRCS)
SRCS += $(REAL_SRCS)
OBJS = $(SRCS:.cpp=.o)
all: $(MAIN)
$(MAIN): $(OBJS) $(THRIFT_DEP)
$(CXX) $(CXXFLAGS) -Wl,-z,defs -o $(MAIN) $(OBJS) $(LIBS)
strip $(MAIN)
.cpp.o:
$(CXX) $(CXXFLAGS) -std=c++11 -c $< -o $@
# The Thrift generator generates three files at once, this file shall represent them.
thrift_line/TalkService.cpp: line.thrift $(THRIFT_DEP) $@
mkdir -p thrift_line
$(THRIFT) --gen cpp -out thrift_line line.thrift
# If the representative file exists, the others should too.
thrift_line/line_types.cpp thrift_line/line_constants.cpp: thrift_line/TalkService.cpp
$(THRIFT):
mkdir -p $(THRIFT_STATIC_DIR)
wget -P $(THRIFT_STATIC_DIR) \
http://mirror.netinch.com/pub/apache/thrift/0.9.2/thrift-0.9.2.tar.gz
tar xf $(THRIFT_STATIC_DIR)/thrift-0.9.2.tar.gz \
-C $(THRIFT_STATIC_DIR) --strip-components 1
cd $(THRIFT_STATIC_DIR); ./configure \
--with-pic \
--disable-tests --disable-tutorial \
--without-libevent --without-zlib --without-qt4 --without-c_glib --without-csharp \
--without-java --without-erlang --without-python --without-perl --without-php \
--without-php_extension --without-ruby --without-haskell --without-go --without-d \
--without-nodejs --without-lua --without-openssl
$(MAKE) -C $(THRIFT_STATIC_DIR)
.PHONY: clean
clean:
rm -f .depend
rm -f $(MAIN)
rm -f *.o
rm -rf thrift_line
rm -rf $(THRIFT_STATIC_DIR)
.PHONY: user-install
user-install: all
install -D $(MAIN) ~/.purple/plugins/$(MAIN)
.PHONY: user-uninstall
user-uninstall:
rm -f ~/.purple/plugins/$(MAIN)
.PHONY: install
install: all
install -D $(MAIN) $(DESTDIR)$(PURPLE_PLUGIN_DIR)/$(MAIN)
install -m 644 -D ../icons/16/line.png $(DESTDIR)$(PURPLE_DATA_ROOT_DIR)/pixmaps/pidgin/protocols/16/line.png
install -m 644 -D ../icons/22/line.png $(DESTDIR)$(PURPLE_DATA_ROOT_DIR)/pixmaps/pidgin/protocols/22/line.png
install -m 644 -D ../icons/48/line.png $(DESTDIR)$(PURPLE_DATA_ROOT_DIR)/pixmaps/pidgin/protocols/48/line.png
install -m 644 -D ../icons/scalable/line.svg $(DESTDIR)$(PURPLE_DATA_ROOT_DIR)/pixmaps/pidgin/protocols/scalable/line.svg
.PHONY: uninstall
uninstall:
rm -f $(DESTDIR)$(PURPLE_PLUGIN_DIR)/$(MAIN)
rm -f $(DESTDIR)$(PURPLE_DATA_ROOT_DIR)/pixmaps/pidgin/protocols/16/line.png
rm -f $(DESTDIR)$(PURPLE_DATA_ROOT_DIR)/pixmaps/pidgin/protocols/22/line.png
rm -f $(DESTDIR)$(PURPLE_DATA_ROOT_DIR)/pixmaps/pidgin/protocols/48/line.png
rm -f $(DESTDIR)$(PURPLE_DATA_ROOT_DIR)/pixmaps/pidgin/protocols/scalable/line.svg
depend: .depend
.depend: $(SRCS)
$(CXX) $(CXXFLAGS) -MM $(REAL_SRCS) >.depend
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),uninstall)
-include .depend
endif
endif