2018-05-09 12:40:23 +00:00
|
|
|
ifdef DEBUG
|
2021-06-30 06:26:06 +00:00
|
|
|
DBGCFLAGS=-fsanitize=address -fsanitize=undefined -fsanitize=leak
|
|
|
|
DBGLDFLAGS=-lasan -lubsan -llsan
|
2018-05-09 12:40:23 +00:00
|
|
|
endif
|
2018-05-10 14:40:10 +00:00
|
|
|
RM=rm -f
|
2018-05-13 14:31:23 +00:00
|
|
|
FIND=find
|
2021-07-22 04:04:15 +00:00
|
|
|
INCLUDES=-Ilibstrophe $(shell xml2-config --cflags) $(shell pkg-config --cflags librnp-0) $(shell pkg-config --cflags libsignal-protocol-c)
|
2021-07-25 08:15:12 +00:00
|
|
|
CFLAGS+=$(DBGCFLAGS) -fno-omit-frame-pointer -fPIC -std=gnu99 -gdwarf-4 -Wall -Wextra -Werror-implicit-function-declaration -Wno-missing-field-initializers -D_XOPEN_SOURCE=700 $(INCLUDES)
|
2021-06-30 06:26:06 +00:00
|
|
|
LDFLAGS+=$(DBGLDFLAGS) -shared -g $(DBGCFLAGS)
|
2021-07-22 04:04:15 +00:00
|
|
|
LDLIBS=-lstrophe -lpthread $(shell xml2-config --libs) $(shell pkg-config --libs librnp-0) $(shell pkg-config --libs libsignal-protocol-c) -lgcrypt
|
2018-04-29 21:26:14 +00:00
|
|
|
|
2018-05-10 14:40:10 +00:00
|
|
|
PREFIX ?= /usr/local
|
|
|
|
LIBDIR ?= $(PREFIX)/lib
|
|
|
|
|
2021-06-28 01:17:02 +00:00
|
|
|
SRCS=plugin.c \
|
2021-07-05 00:31:57 +00:00
|
|
|
account.c \
|
|
|
|
buffer.c \
|
|
|
|
channel.c \
|
|
|
|
command.c \
|
|
|
|
completion.c \
|
|
|
|
config.c \
|
|
|
|
connection.c \
|
|
|
|
input.c \
|
|
|
|
message.c \
|
|
|
|
omemo.c \
|
2021-07-22 04:04:15 +00:00
|
|
|
pgp.c \
|
2021-07-05 00:31:57 +00:00
|
|
|
user.c \
|
2021-07-13 03:03:34 +00:00
|
|
|
util.c \
|
2021-07-05 00:31:57 +00:00
|
|
|
xmpp/presence.c \
|
2021-07-05 21:50:38 +00:00
|
|
|
xmpp/iq.c \
|
2021-07-01 23:13:15 +00:00
|
|
|
|
2021-07-16 02:44:46 +00:00
|
|
|
DEPS=diff/libdiff.a
|
2021-06-27 22:51:05 +00:00
|
|
|
OBJS=$(subst .c,.o,$(SRCS))
|
|
|
|
|
2021-06-30 06:26:06 +00:00
|
|
|
all: weechat-xmpp
|
|
|
|
weechat-xmpp: $(DEPS) xmpp.so
|
2018-04-29 21:26:14 +00:00
|
|
|
|
2021-07-01 23:13:15 +00:00
|
|
|
xmpp.so: $(OBJS) $(DEPS)
|
|
|
|
$(CC) $(LDFLAGS) -o xmpp.so $(OBJS) $(DEPS) $(LDLIBS)
|
2021-06-27 22:51:05 +00:00
|
|
|
which patchelf >/dev/null && \
|
2021-06-30 06:26:06 +00:00
|
|
|
patchelf --set-rpath $(LIBRARY_PATH):$(shell realpath $(shell dirname $(shell gcc --print-libgcc-file-name))/../../../) xmpp.so && \
|
|
|
|
patchelf --shrink-rpath xmpp.so || true
|
|
|
|
|
2021-07-12 17:01:04 +00:00
|
|
|
diff/libdiff.a:
|
2021-07-22 04:04:15 +00:00
|
|
|
git submodule update --init --recursive
|
2021-07-12 17:01:04 +00:00
|
|
|
cd diff && ./configure
|
|
|
|
$(MAKE) -C diff CFLAGS=-fPIC
|
|
|
|
diff: diff/libdiff.a
|
|
|
|
|
2021-06-30 06:26:06 +00:00
|
|
|
test: xmpp.so
|
|
|
|
env LD_PRELOAD=$(DEBUG) \
|
2021-07-01 20:37:43 +00:00
|
|
|
weechat -a -P 'alias,buflist,irc' -r '/plugin load ./xmpp.so'
|
2021-06-30 06:26:06 +00:00
|
|
|
|
|
|
|
debug: xmpp.so
|
|
|
|
gdb -ex "handle SIGPIPE nostop noprint pass" --args \
|
|
|
|
weechat -a -r '/plugin load ./xmpp.so'
|
2018-04-29 21:26:14 +00:00
|
|
|
|
|
|
|
depend: .depend
|
|
|
|
|
2021-06-28 01:18:05 +00:00
|
|
|
.depend: $(SRCS)
|
2018-04-29 21:26:14 +00:00
|
|
|
$(RM) ./.depend
|
2018-05-13 14:31:23 +00:00
|
|
|
$(CC) $(CFLAGS) -MM $^>>./.depend
|
|
|
|
|
|
|
|
tidy:
|
|
|
|
$(FIND) . -name "*.o" -delete
|
2018-04-29 21:26:14 +00:00
|
|
|
|
|
|
|
clean:
|
2021-07-02 22:10:40 +00:00
|
|
|
$(RM) -f $(OBJS)
|
2021-07-12 17:01:04 +00:00
|
|
|
$(MAKE) -C diff clean || true
|
2021-07-01 23:13:15 +00:00
|
|
|
git submodule foreach --recursive git clean -xfd || true
|
|
|
|
git submodule foreach --recursive git reset --hard || true
|
2018-04-29 21:26:14 +00:00
|
|
|
|
|
|
|
distclean: clean
|
|
|
|
$(RM) *~ .depend
|
|
|
|
|
2021-06-25 22:20:49 +00:00
|
|
|
install: xmpp.so
|
2018-05-10 14:40:10 +00:00
|
|
|
ifeq ($(shell id -u),0)
|
2021-07-02 22:10:40 +00:00
|
|
|
mkdir -p $(DESTDIR)$(LIBDIR)/weechat/plugins
|
|
|
|
cp xmpp.so $(DESTDIR)$(LIBDIR)/weechat/plugins/xmpp.so
|
|
|
|
chmod 644 $(DESTDIR)$(LIBDIR)/weechat/plugins/xmpp.so
|
2018-05-10 14:40:10 +00:00
|
|
|
else
|
2021-07-02 22:10:40 +00:00
|
|
|
mkdir -p ~/.weechat/plugins
|
|
|
|
cp xmpp.so ~/.weechat/plugins/xmpp.so
|
|
|
|
chmod 755 ~/.weechat/plugins/xmpp.so
|
2018-05-10 14:40:10 +00:00
|
|
|
endif
|
|
|
|
|
2018-05-04 00:31:06 +00:00
|
|
|
.PHONY: tags cs
|
|
|
|
|
|
|
|
tags:
|
2021-07-22 04:04:15 +00:00
|
|
|
$(CC) $(CFLAGS) -M $(SRCS) | sed -e "s/[\\ ]/\n/g" | sed -e "/^$$/d" -e "/\.o:[ \t]*$$/d" | sort | uniq | ctags -e -L - -f .git/tags -R --c-kinds=+px --c++-kinds=+px --fields=+iaS --extras=+fq
|
2018-05-08 21:02:17 +00:00
|
|
|
|
2018-05-04 00:31:06 +00:00
|
|
|
cs:
|
|
|
|
cscope -RUbq
|
|
|
|
|
2018-04-29 21:26:14 +00:00
|
|
|
include .depend
|