2015-12-30 15:04:18 +01:00
|
|
|
# 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
|
|
|
|
#
|
2017-06-17 14:26:31 +02:00
|
|
|
# Copyright Matthias Jentsch, Vitaly Valtman, Christopher Althaus, Markus Endres 2014-2017
|
2015-12-30 15:04:18 +01:00
|
|
|
|
2014-11-12 21:23:01 +03:00
|
|
|
srcdir=@srcdir@
|
2015-10-07 03:28:37 +02:00
|
|
|
prefix=@prefix@
|
2015-10-07 01:32:23 +02:00
|
|
|
datarootdir=@datarootdir@
|
|
|
|
localedir=@localedir@
|
|
|
|
gettext_package=@GETTEXT_PACKAGE@
|
2014-11-12 21:23:01 +03:00
|
|
|
|
2017-06-16 20:54:24 +02:00
|
|
|
CFLAGS_INTL=-DENABLE_NLS -DLOCALEDIR='"$(localedir)"'
|
|
|
|
CFLAGS_WARN=-Wall -Wextra -Wno-deprecated-declarations -Wno-unused-parameter
|
|
|
|
CFLAGS_EXTRA=-I${srcdir} -I. -fno-strict-aliasing -fPIC -D_FORTIFY_SOURCE=2
|
|
|
|
CFLAGS=@CFLAGS@ @PURPLE_CFLAGS@ @DEFS@ ${CFLAGS_INTL} ${CFLAGS_WARN} ${CFLAGS_EXTRA}
|
|
|
|
|
|
|
|
LDFLAGS_EXTRA=-rdynamic -ggdb
|
|
|
|
LDFLAGS=@LDFLAGS@ @OPENSSL_LIBS@ @PURPLE_LIBS@ @LIBS@ ${LDFLAGS_EXTRA}
|
|
|
|
|
2015-03-04 23:32:29 +01:00
|
|
|
DIR_PERM=0755
|
|
|
|
FILE_PERM=0644
|
2014-11-12 21:23:01 +03:00
|
|
|
|
|
|
|
CC=@CC@
|
2015-08-29 18:37:02 +02:00
|
|
|
PKG_CONFIG=@PKG_CONFIG@
|
2015-12-05 20:31:08 +01:00
|
|
|
MSGFMT_PATH=@MSGFMT_PATH@
|
2014-11-12 21:23:01 +03:00
|
|
|
|
2016-10-13 15:41:22 +02:00
|
|
|
# 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"
|
2016-10-13 13:48:06 +02:00
|
|
|
CFLAGS += -fstack-protector-strong
|
|
|
|
endif
|
|
|
|
|
2014-11-12 21:23:01 +03:00
|
|
|
DEP=dep
|
|
|
|
EXE=bin
|
|
|
|
OBJ=objs
|
2016-01-07 10:40:34 +01:00
|
|
|
DIR_LIST=${DEP} ${EXE} ${OBJ}
|
2014-11-12 21:23:01 +03:00
|
|
|
|
2016-01-03 23:55:45 +01:00
|
|
|
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
|
2014-11-17 16:27:01 +03:00
|
|
|
ALL_OBJS=${PLUGIN_OBJECTS}
|
2014-11-12 21:23:01 +03:00
|
|
|
|
2015-12-05 20:31:08 +01:00
|
|
|
ifdef MSGFMT_PATH
|
2015-12-30 14:17:42 +01:00
|
|
|
LOCALES=$(shell cat po/LINGUAS)
|
|
|
|
LOCALE_MOS=$(addprefix po/,$(addsuffix .mo,$(LOCALES)))
|
2015-12-05 20:31:08 +01:00
|
|
|
endif
|
2015-10-07 01:32:23 +02:00
|
|
|
|
2014-11-12 21:23:01 +03:00
|
|
|
.SUFFIXES:
|
|
|
|
|
|
|
|
.SUFFIXES: .c .h .o
|
|
|
|
|
2014-11-17 16:27:01 +03:00
|
|
|
PRPL_NAME=telegram-purple.so
|
|
|
|
PRPL_LIBNAME=${EXE}/${PRPL_NAME}
|
2015-12-30 14:17:42 +01:00
|
|
|
all: ${PRPL_LIBNAME} $(LOCALE_MOS)
|
2014-11-12 21:23:01 +03:00
|
|
|
|
2015-08-29 18:37:02 +02:00
|
|
|
PLUGIN_DIR_PURPLE=$(shell ${PKG_CONFIG} --variable=plugindir purple)
|
|
|
|
DATA_ROOT_DIR_PURPLE=$(shell ${PKG_CONFIG} --variable=datarootdir purple)
|
2015-12-31 16:31:16 +01:00
|
|
|
CRYPTO_FLAG=@CRYPTO_FLAG@
|
2014-11-12 21:23:01 +03:00
|
|
|
|
2016-01-03 15:46:15 +01:00
|
|
|
|
2016-02-19 01:12:31 +01:00
|
|
|
### == '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.
|
2016-01-03 15:46:15 +01:00
|
|
|
|
2016-01-03 15:59:32 +01:00
|
|
|
.PHONY: create_dirs
|
2014-11-12 21:23:01 +03:00
|
|
|
create_dirs: ${DIR_LIST}
|
|
|
|
|
|
|
|
${DIR_LIST}:
|
|
|
|
@test -d $@ || mkdir -p $@
|
|
|
|
|
2014-11-17 16:27:01 +03:00
|
|
|
DEPENDENCE=$(subst ${OBJ}/,${DEP}/,$(patsubst %.o,%.d,${ALL_OBJS}))
|
|
|
|
DEPENDENCE_LIST=${DEPENDENCE}
|
|
|
|
-include ${DEPENDENCE_LIST}
|
2014-11-12 21:23:01 +03:00
|
|
|
|
2015-10-02 17:02:03 +02:00
|
|
|
tgl/Makefile.in:
|
|
|
|
@echo "tgl/Makefile.in not found. Maybe you need to 'git submodule update --init --recursive' ?" && exit 1
|
|
|
|
|
2016-02-19 01:12:31 +01:00
|
|
|
tgl/Makefile: tgl/Makefile.in Makefile
|
2015-12-31 16:31:16 +01:00
|
|
|
cd tgl && ./configure -q ${CRYPTO_FLAG} --disable-extf CFLAGS="@CFLAGS@" LDFLAGS="@LDFLAGS@"
|
2015-10-02 17:02:03 +02:00
|
|
|
|
2016-08-30 00:39:29 +02:00
|
|
|
tgl/libs/libtgl.a: tgl/Makefile
|
2016-08-22 22:20:18 +02:00
|
|
|
+${MAKE} -C tgl libs/libtgl.a
|
2015-10-02 17:02:03 +02:00
|
|
|
|
2016-02-19 01:12:31 +01:00
|
|
|
.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)
|
2016-03-03 17:15:42 +01:00
|
|
|
commit.h: commit
|
|
|
|
@./commit.h.gen
|
2016-02-19 01:12:31 +01:00
|
|
|
|
|
|
|
# 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 $@ $<
|
|
|
|
|
2015-10-07 01:32:23 +02:00
|
|
|
po/%.mo: po/%.po
|
2017-04-10 22:17:54 +02:00
|
|
|
${MSGFMT_PATH} -cf -o $@ $< >/dev/null 2>&1
|
2015-10-07 01:32:23 +02:00
|
|
|
|
2016-08-30 00:39:29 +02:00
|
|
|
${PRPL_LIBNAME}: ${PLUGIN_OBJECTS} tgl/libs/libtgl.a | create_dirs
|
2014-11-22 22:39:33 +01:00
|
|
|
${CC} -shared -o $@ $^ ${LDFLAGS}
|
2014-11-12 21:23:01 +03:00
|
|
|
|
|
|
|
|
2016-01-03 15:59:32 +01:00
|
|
|
### == noicon_{,un}install targets. Use only if you know that you don't need icons. Note that pidgin uses those files. == ###
|
2014-11-12 21:23:01 +03:00
|
|
|
|
2016-01-03 15:59:32 +01:00
|
|
|
.PHONY: noicon_install
|
|
|
|
noicon_install: $(PRPL_LIBNAME) $(LOCALE_MOS)
|
2015-03-04 23:32:29 +01:00
|
|
|
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
|
2016-07-07 18:53:53 +02:00
|
|
|
# Assume that the user does not use AppStream if she doesn't want icons
|
2015-12-30 14:17:42 +01:00
|
|
|
@for lang in $(LOCALES); do \
|
2015-10-07 17:28:05 +02:00
|
|
|
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; \
|
2015-10-07 01:32:23 +02:00
|
|
|
done
|
2014-11-12 21:23:01 +03:00
|
|
|
|
2016-01-03 15:59:32 +01:00
|
|
|
.PHONY: noicon_uninstall
|
|
|
|
noicon_uninstall:
|
2014-11-17 16:27:01 +03:00
|
|
|
rm -f $(DESTDIR)$(PLUGIN_DIR_PURPLE)/$(PRPL_NAME)
|
2015-10-01 17:11:33 +02:00
|
|
|
rm -f $(DESTDIR)/etc/telegram-purple/server.pub # TODO: Remove this in later versions
|
2017-04-10 22:49:21 +02:00
|
|
|
rm -f $(DESTDIR)/etc/telegram-purple/server.tglpub # TODO: Remove this in later versions
|
2015-10-10 10:16:05 +02:00
|
|
|
# TODO: Delete all installed .mo's, no matter what LINGUAS says.
|
2015-12-30 14:17:42 +01:00
|
|
|
@for lang in $(LOCALES); do \
|
2015-10-07 01:32:23 +02:00
|
|
|
echo "removing $(localedir)/$$lang/LC_MESSAGES/$(gettext_package).mo"; \
|
|
|
|
rm -f $(localedir)/$$lang/LC_MESSAGES/$(gettext_package).mo; \
|
|
|
|
done
|
2014-11-12 21:23:01 +03:00
|
|
|
|
2016-01-03 15:46:15 +01:00
|
|
|
|
2016-01-03 15:59:32 +01:00
|
|
|
### == 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
|
2016-01-06 11:57:11 +01:00
|
|
|
install -m $(FILE_PERM) AppStream/telegram-purple.metainfo.xml $(DESTDIR)$(datarootdir)/appdata/telegram-purple.metainfo.xml
|
2016-01-03 15:59:32 +01:00
|
|
|
|
|
|
|
.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
|
|
|
|
|
|
|
|
|
2016-01-03 15:46:15 +01:00
|
|
|
### == The local_{,un}install targets, in case you're not root. == ###
|
|
|
|
|
2015-10-11 14:50:16 +02:00
|
|
|
.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)
|
|
|
|
|
|
|
|
.PHONY: local_uninstall
|
|
|
|
local_uninstall:
|
|
|
|
rm -f $(DESTDIR)$(HOME)/.purple/plugins/$(PRPL_NAME)
|
2017-04-12 00:50:03 +02:00
|
|
|
rm -f $(DESTDIR)$(HOME)/.purple/telegram-purple/server.tglpub # TODO: Remove this in later versions
|
2015-10-11 14:50:16 +02:00
|
|
|
|
2016-01-03 15:46:15 +01:00
|
|
|
|
|
|
|
### == 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)
|
|
|
|
|
2016-01-01 22:59:10 +01:00
|
|
|
.PHONY: build-nsi
|
2017-06-19 21:17:57 +02:00
|
|
|
build-nsi: telegram-purple.nsi
|
|
|
|
|
|
|
|
telegram-purple.nsi: telegram-purple.nsi.awk telegram-purple.nsi.awk-in po/LINGUAS
|
2016-01-01 22:59:10 +01:00
|
|
|
awk -f telegram-purple.nsi.awk telegram-purple.nsi.awk-in > telegram-purple.nsi
|
|
|
|
|
2014-11-12 21:23:01 +03:00
|
|
|
.PHONY: run
|
2015-01-26 23:06:04 +01:00
|
|
|
run:
|
2014-11-12 21:23:01 +03:00
|
|
|
pidgin -d | grep 'telegram\|plugin\|proxy'
|
|
|
|
|
|
|
|
.PHONY: debug
|
|
|
|
debug: install
|
|
|
|
ddd pidgin
|
|
|
|
|
2016-01-07 18:10:54 +01:00
|
|
|
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."
|
|
|
|
|
2016-01-07 20:00:26 +01:00
|
|
|
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
|
|
|
|
|
2016-01-07 18:10:54 +01:00
|
|
|
.PHONY: check-clean
|
2016-01-07 20:00:26 +01:00
|
|
|
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)
|
2016-01-07 18:10:54 +01:00
|
|
|
|
2016-01-07 20:00:26 +01:00
|
|
|
# Feel free to remove the "check-clean" dependency if you know what you're doing.
|
2016-01-07 18:10:54 +01:00
|
|
|
.PHONY: dist
|
2016-03-03 17:18:27 +01:00
|
|
|
dist: check-clean commit.h .git create_dirs
|
2016-03-04 14:36:50 +01:00
|
|
|
./gen-origtar
|
2016-01-07 18:10:54 +01:00
|
|
|
|
2016-01-03 15:46:15 +01:00
|
|
|
|
|
|
|
### == Cleaning in various flavors == ###
|
|
|
|
|
2015-10-08 00:02:23 +02:00
|
|
|
.PHONY: clean-here
|
|
|
|
clean-here:
|
2016-08-08 10:44:09 +02:00
|
|
|
rm -rf ${DIR_LIST} $(PRPL_LIBNAME) po/*.mo autom4te.cache AppStream/po/*.mo
|
2015-10-08 00:02:23 +02:00
|
|
|
|
2016-01-01 13:57:25 +01:00
|
|
|
-include test/Makefile
|
|
|
|
|
2016-08-08 10:44:09 +02:00
|
|
|
.PHONY: clean
|
|
|
|
clean: clean-here clean-test tgl/Makefile
|
2016-08-08 10:43:53 +02:00
|
|
|
+${MAKE} -C tgl clean
|