forked from majn/telegram-purple
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.mingw
173 lines (138 loc) · 6.78 KB
/
Makefile.mingw
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
# This file is part of telegram-purple
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
#
# Copyright Matthias Jentsch, Vitaly Valtman, Christopher Althaus, Markus Endres, Eion Robb 2014-2015
srcdir=.
gettext_package=telegram-purple
PURPLE_VERSION = 2.10.11
PIDGIN_TREE_TOP := ../pidgin-$(PURPLE_VERSION)
WIN32_DEV_TOP = $(PIDGIN_TREE_TOP)/../win32-dev
MAKENSIS ?= "$(PROGRAMFILES)/NSIS/makensis.exe"
PLUGIN_VERSION ?= 1.2.2
GMSGFMT ?= $(WIN32_DEV_TOP)/gettext-0.17/bin/msgfmt
CFLAGS=-I$(WIN32_DEV_TOP)/libgcrypt-1.6.3/include -I$(WIN32_DEV_TOP)/libgpg-error-1.12-2/include -I$(WIN32_DEV_TOP)/glib-2.28.8/include -I$(WIN32_DEV_TOP)/glib-2.28.8/include/glib-2.0 -I$(WIN32_DEV_TOP)/glib-2.28.8/lib/glib-2.0/include -I$(PIDGIN_TREE_TOP)/libpurple -I$(WIN32_DEV_TOP)/libwebp-0.4.3-1/include -DHAVE_CONFIG_H -DENABLE_NLS -DPACKAGE_VERSION='"$(PLUGIN_VERSION)"' -Wall -Wextra -Werror -Wno-deprecated-declarations -Wno-unused-parameter -I${srcdir} -I. -fno-strict-aliasing
LDFLAGS=-L$(WIN32_DEV_TOP)/libgcrypt-1.6.3/lib -L$(WIN32_DEV_TOP)/libwebp-0.4.3-1/lib -L$(WIN32_DEV_TOP)/gettext-0.18/bin -L$(PIDGIN_TREE_TOP)/libpurple -L$(WIN32_DEV_TOP)/glib-2.28.8/lib -lpurple -lintl -lglib-2.0 -lwebp -lz -lgcrypt -Wl,--export-all-symbols -ggdb -lws2_32 -static-libgcc
DIR_PERM=0755
FILE_PERM=0644
CC = $(WIN32_DEV_TOP)/mingw/bin/gcc
PKG_CONFIG=
DEP=dep
EXE=bin
OBJ=objs
LIB=libs
DIR_LIST=${DEP} ${EXE} ${OBJ} ${LIB} ${DEP}/lodepng ${OBJ}/lodepng
PLUGIN_OBJECTS=${OBJ}/tgp-net.o ${OBJ}/tgp-timers.o ${OBJ}/msglog.o ${OBJ}/telegram-base.o ${OBJ}/telegram-purple.o ${OBJ}/tgp-2prpl.o ${OBJ}/tgp-structs.o ${OBJ}/tgp-utils.o ${OBJ}/tgp-chat.o ${OBJ}/tgp-ft.o ${OBJ}/tgp-msg.o ${OBJ}/tgp-request.o ${OBJ}/tgp-blist.o ${OBJ}/lodepng/lodepng.o
ALL_OBJS=${PLUGIN_OBJECTS}
LOCALES=$(patsubst %.po, %.mo, $(wildcard po/*.po))
.SUFFIXES:
.SUFFIXES: .c .h .o
PRPL_NAME=libtelegram.dll
PRPL_LIBNAME=${EXE}/${PRPL_NAME}
all: ${PRPL_LIBNAME} ${LOCALES}
PLUGIN_DIR_PURPLE="$(PROGRAMFILES)/Pidgin/plugins"
DATA_ROOT_DIR_PURPLE="$(PROGRAMFILES)/Pidgin"
COPY_ICONS=yes
localedir=$(DATA_ROOT_DIR_PURPLE)/locale
create_dirs: ${DIR_LIST}
${DIR_LIST}:
@test -d $@ || mkdir -p $@
DEPENDENCE=$(subst ${OBJ}/,${DEP}/,$(patsubst %.o,%.d,${ALL_OBJS}))
DEPENDENCE_LIST=${DEPENDENCE}
-include ${DEPENDENCE_LIST}
# The dependency on tgl/libs/libtgl.a ensures that "make -C tgl" was called,
# and most importantly: It ensures that all automatic headers exist.
${PLUGIN_OBJECTS}: ${OBJ}/%.o: ${srcdir}/%.c ${LIB}/libtgl.a | create_dirs
echo $@ && ${CC} ${CFLAGS} ${CPPFLAGS} -I ${srcdir}/tgl -I ${srcdir}/lodepng -c -MP -MD -MF ${DEP}/$*.d -MQ ${OBJ}/$*.o -o $@ $<
tgl/Makefile.mingw: ${srcdir}/Makefile.tgl.mingw
cp $< $@
tgl/libs/libtgl.a: tgl/Makefile.mingw
+make -C tgl -f Makefile.mingw
tgl/config.h: ${srcdir}/config.h.tgl.mingw
cp $< $@
config.h: ${srcdir}/config.h.mingw
cp $< $@
po/%.mo: po/%.po
$(GMSGFMT) -cf -o $@ $<
${LIB}/libtgl.a: tgl/libs/libtgl.a | create_dirs
cp $< $@
${PRPL_LIBNAME}: ${PLUGIN_OBJECTS} ${LIB}/libtgl.a | create_dirs
${CC} -shared -o $@ $^ ${LDFLAGS}
.PHONY: plugin
plugin: $(PRPL_LIBNAME)
.PHONY: strip
strip: $(PRPL_LIBNAME)
$(STRIP) --strip-unneeded $(PRPL_LIBNAME)
.PHONY: install
install: $(PRPL_LIBNAME) $(LOCALES)
mkdir -m $(DIR_PERM) -p $(PLUGIN_DIR_PURPLE)
install -m $(FILE_PERM) $(PRPL_LIBNAME) $(PLUGIN_DIR_PURPLE)/$(PRPL_NAME)
install -m $(FILE_PERM) tg-server.tglpub $(DATA_ROOT_DIR_PURPLE)/server.tglpub
ifeq ($(COPY_ICONS),no)
@echo "Not copying icons due to configure-option --disable-icons."
@echo " If you're using Finch, Empathy, or Telepathy, then this is a good idea."
@echo " If you're using Pidgin, then this is a bad idea."
@echo " If you're using Adium, read the README.md: You're using the wrong build system!"
else
mkdir -m $(DIR_PERM) -p $(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/16
install -m $(FILE_PERM) imgs/telegram16.png $(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/16/telegram.png
mkdir -m $(DIR_PERM) -p $(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/22
install -m $(FILE_PERM) imgs/telegram22.png $(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/22/telegram.png
mkdir -m $(DIR_PERM) -p $(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/48
install -m $(FILE_PERM) imgs/telegram48.png $(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/48/telegram.png
endif
@for lang in $(shell cat po/LINGUAS); do \
mkdir -p $(localedir)/$$lang/LC_MESSAGES; \
echo "installing po/$$lang.mo to $(localedir)/$$lang/LC_MESSAGES/$(gettext_package).mo"; \
install -m $(FILE_PERM) po/$$lang.mo $(localedir)/$$lang/LC_MESSAGES/$(gettext_package).mo; \
done
.PHONY: uninstall
uninstall:
rm -f $(PLUGIN_DIR_PURPLE)/$(PRPL_NAME)
rm -f $(DATA_ROOT_DIR_PURPLE)/server.tglpub
rm -f $(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/16/telegram.png
rm -f $(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/22/telegram.png
rm -f $(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/48/telegram.png
# TODO: Delete all installed .mo's, no matter what LINGUAS says.
@for lang in $(shell cat po/LINGUAS); do \
echo "removing $(localedir)/$$lang/LC_MESSAGES/$(gettext_package).mo"; \
rm -f $(localedir)/$$lang/LC_MESSAGES/$(gettext_package).mo; \
done
.PHONY: local_install
local_install:
mkdir -m $(DIR_PERM) -p $(DESTDIR)$(HOME)/.purple/plugins
install -m $(FILE_PERM) $(PRPL_LIBNAME) $(DESTDIR)$(HOME)/.purple/plugins/$(PRPL_NAME)
# See telegram-base.c, function get_user_pk_path for justification:
mkdir -m $(DIR_PERM) -p $(DESTDIR)$(HOME)/.purple/telegram-purple
install -m $(FILE_PERM) tg-server.tglpub $(DESTDIR)$(HOME)/.purple/telegram-purple/server.tglpub
.PHONY: local_uninstall
local_uninstall:
rm -f $(DESTDIR)$(HOME)/.purple/plugins/$(PRPL_NAME)
rm -f $(DESTDIR)$(HOME)/.purple/telegram-purple/server.tglpub
.PHONY: run
run:
pidgin -d | grep 'telegram\|plugin\|proxy'
.PHONY: debug
debug: install
ddd pidgin
.PHONY: clean-here
clean-here:
rm -rf ${DIR_LIST} $(PRPL_C_OBJS) $(PRPL_LIBNAME) po/*.mo
.PHONY: clean
clean: clean-here tgl/Makefile.mingw
+make -C tgl -f Makefile.mingw clean
.PHONY: installer
installer: telegram-purple.nsi $(PRPL_LIBNAME) $(LOCALES)
$(MAKENSIS) -DPLUGIN_VERSION="$(PLUGIN_VERSION)" -DPRPL_NAME="$(PRPL_NAME)" -DWIN32_DEV_TOP="$(WIN32_DEV_TOP)" telegram-purple.nsi