Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Makefile.in - github.com/majn/telegram-purple.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fdeddb4f846e24cab332c54fb1014fe2c807042e (plain)
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
# 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 2014-2015

srcdir=@srcdir@
prefix=@prefix@
datarootdir=@datarootdir@
localedir=@localedir@
gettext_package=@GETTEXT_PACKAGE@

CFLAGS=@CFLAGS@ @PURPLE_CFLAGS@ @DEFS@ -DENABLE_NLS -DLOCALEDIR='"$(localedir)"' -Wall -Wextra -Wno-deprecated-declarations -Wno-unused-parameter -I${srcdir} -I. -fno-strict-aliasing -fPIC -D_FORTIFY_SOURCE=2
LDFLAGS=@LDFLAGS@ @OPENSSL_LIBS@ @PURPLE_LIBS@ @LIBS@ -rdynamic -ggdb
DIR_PERM=0755
FILE_PERM=0644

CC=@CC@
PKG_CONFIG=@PKG_CONFIG@
MSGFMT_PATH=@MSGFMT_PATH@

# Check if -fstack-protector-strong is supported before enabling it
SPUNSUPPORTED = $(shell $(CC) -fstack-protector-strong 2>&1 | grep -c 'stack-protector-strong')
ifeq "$(SPUNSUPPORTED)" "0"
	CFLAGS += -fstack-protector-strong
endif

DEP=dep
EXE=bin
OBJ=objs
DIR_LIST=${DEP} ${EXE} ${OBJ}

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}/tgp-info.o
ALL_OBJS=${PLUGIN_OBJECTS}

ifdef MSGFMT_PATH
LOCALES=$(shell cat po/LINGUAS)
LOCALE_MOS=$(addprefix po/,$(addsuffix .mo,$(LOCALES)))
endif

.SUFFIXES:

.SUFFIXES: .c .h .o

PRPL_NAME=telegram-purple.so
PRPL_LIBNAME=${EXE}/${PRPL_NAME}
all: ${PRPL_LIBNAME} $(LOCALE_MOS)

PLUGIN_DIR_PURPLE=$(shell ${PKG_CONFIG} --variable=plugindir purple)
DATA_ROOT_DIR_PURPLE=$(shell ${PKG_CONFIG} --variable=datarootdir purple)
CRYPTO_FLAG=@CRYPTO_FLAG@


### == 'Magic' targets and infrastructure. == ###
# Here be dragons! See https://github.com/majn/telegram-purple/issues/242
# For the full list of requirements, goals, and rationale.

.PHONY: create_dirs
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}

tgl/Makefile.in:
	@echo "tgl/Makefile.in not found. Maybe you need to 'git submodule update --init --recursive' ?" && exit 1

tgl/Makefile: tgl/Makefile.in Makefile
	cd tgl && ./configure -q ${CRYPTO_FLAG} --disable-extf CFLAGS="@CFLAGS@" LDFLAGS="@LDFLAGS@"

tgl/libs/libtgl.a: tgl/Makefile
	+${MAKE} -C tgl libs/libtgl.a

.PHONY: commit
commit:

# The *commands* for commit.h shall always be executed, but the
# *file* commit.h should only be considered to have changed in rare cases.
GIT_COMMIT=$(shell git rev-parse HEAD | cut -c1-10)
commit.h: commit
	@./commit.h.gen

# Ugly, but necessary, because otherwise commit.h would not get generated:
test/loadtest.c: commit.h

# Ugly, but necessary, because otherwise commit.h would not get generated:
telegram-purple.c: commit.h


### == 'Normal' build. == ###

${PLUGIN_OBJECTS}: ${OBJ}/%.o: ${srcdir}/%.c tgl/libs/libtgl.a | create_dirs
	echo $@ && ${CC} ${CFLAGS} ${CPPFLAGS} -I ${srcdir}/tgl -c -MP -MD -MF ${DEP}/$*.d -MQ ${OBJ}/$*.o -o $@ $<

po/%.mo: po/%.po
	${MSGFMT_PATH} -cf -o $@ $< >/dev/null 2>&1

${PRPL_LIBNAME}: ${PLUGIN_OBJECTS} tgl/libs/libtgl.a | create_dirs
	${CC} -shared -o $@ $^ ${LDFLAGS}


### == noicon_{,un}install targets. Use only if you know that you don't need icons. Note that pidgin uses those files. == ###

.PHONY: noicon_install
noicon_install: $(PRPL_LIBNAME) $(LOCALE_MOS)
	mkdir -m $(DIR_PERM) -p $(DESTDIR)$(PLUGIN_DIR_PURPLE)
	install -m $(FILE_PERM) $(PRPL_LIBNAME) $(DESTDIR)$(PLUGIN_DIR_PURPLE)/$(PRPL_NAME)
	mkdir -m $(DIR_PERM) -p $(DESTDIR)/etc/telegram-purple
	install -m $(FILE_PERM) tg-server.tglpub $(DESTDIR)/etc/telegram-purple/server.tglpub
# Assume that the user does not use AppStream if she doesn't want icons
	@for lang in $(LOCALES); do \
		mkdir -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES; \
		echo "installing po/$$lang.mo to $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(gettext_package).mo"; \
		install -m $(FILE_PERM) po/$$lang.mo $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(gettext_package).mo; \
	done

.PHONY: noicon_uninstall
noicon_uninstall:
	rm -f $(DESTDIR)$(PLUGIN_DIR_PURPLE)/$(PRPL_NAME)
	rm -f $(DESTDIR)/etc/telegram-purple/server.pub # TODO: Remove this in later versions
	rm -f $(DESTDIR)/etc/telegram-purple/server.tglpub
# TODO: Delete all installed .mo's, no matter what LINGUAS says.
	@for lang in $(LOCALES); do \
		echo "removing $(localedir)/$$lang/LC_MESSAGES/$(gettext_package).mo"; \
		rm -f $(localedir)/$$lang/LC_MESSAGES/$(gettext_package).mo; \
	done


### == Main {,un}install targets. This should satisfy most needs. == ###

.PHONY: install
install: noicon_install
	mkdir -m $(DIR_PERM) -p $(DESTDIR)$(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/16
	install -m $(FILE_PERM) imgs/telegram16.png $(DESTDIR)$(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/16/telegram.png
	mkdir -m $(DIR_PERM) -p $(DESTDIR)$(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/22
	install -m $(FILE_PERM) imgs/telegram22.png $(DESTDIR)$(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/22/telegram.png
	mkdir -m $(DIR_PERM) -p $(DESTDIR)$(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/48
	install -m $(FILE_PERM) imgs/telegram48.png $(DESTDIR)$(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/48/telegram.png
	mkdir -m $(DIR_PERM) -p $(DESTDIR)$(datarootdir)/appdata
	install -m $(FILE_PERM) AppStream/telegram-purple.metainfo.xml $(DESTDIR)$(datarootdir)/appdata/telegram-purple.metainfo.xml

.PHONY: uninstall
uninstall: noicon_uninstall
	rm -f $(DESTDIR)$(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/16/telegram.png
	rm -f $(DESTDIR)$(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/22/telegram.png
	rm -f $(DESTDIR)$(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/48/telegram.png
	rm -f $(DESTDIR)$(datarootdir)/appdata/telegram-purple.metainfo.xml


### == The local_{,un}install targets, in case you're not root. == ###

.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


### == Handling and maintenance. Subject to rapid change, shouldn't be used in scripts. == ###

.PHONY: plugin
plugin: $(PRPL_LIBNAME)

.PHONY: strip
strip: $(PRPL_LIBNAME)
	$(STRIP) --strip-unneeded $(PRPL_LIBNAME)

.PHONY: build-nsi
build-nsi: telegram-purple.nsi.awk telegram-purple.nsi.awk-in
	awk -f telegram-purple.nsi.awk telegram-purple.nsi.awk-in > telegram-purple.nsi

.PHONY: run
run:
	pidgin -d | grep 'telegram\|plugin\|proxy'

.PHONY: debug
debug: install
	ddd pidgin

DIST_ERR_MSG="Working directory is not git clean.\
Run 'git status' to show what files are causing this.\
Please note that 'make dist' packages the state in git, not the one on your disk."

SUBMOD_ERR_MSG="Couldn't find tgl/tl-parser/tl-parser.c\
Are all submodules properly initialized and updated?"

# Not PHONY
.git:
	@echo "Not in a git folder. Features that require git are disabled."; exit 1

.PHONY: check-clean
check-clean: .git
	@test "x" = x"`git status --porcelain`" || (echo ${DIST_ERR_MSG}; exit 1)
	@test -r tgl/tl-parser/.git || (echo ${SUBMOD_ERR_MSG}; exit 1)

# Feel free to remove the "check-clean" dependency if you know what you're doing.
.PHONY: dist
dist: check-clean commit.h .git create_dirs
	./gen-origtar


### == Cleaning in various flavors == ###

.PHONY: clean-here
clean-here:
	rm -rf ${DIR_LIST} $(PRPL_LIBNAME) po/*.mo autom4te.cache AppStream/po/*.mo

-include test/Makefile

.PHONY: clean
clean: clean-here clean-test tgl/Makefile
	+${MAKE} -C tgl clean