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-02 18:46:58 +00:00
|
|
|
INCLUDES=-Ilibstrophe $(shell xml2-config --cflags) $(shell pkg-config --cflags glib-2.0) $(shell pkg-config --cflags libsignal-protocol-c)
|
2021-07-02 16:26:23 +00:00
|
|
|
CFLAGS+=$(DBGCFLAGS) -fno-omit-frame-pointer -fPIC -std=gnu99 -g -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-07 17:27:06 +00:00
|
|
|
LDLIBS=-lstrophe -lpthread $(shell xml2-config --libs) $(shell pkg-config --libs glib-2.0) $(shell pkg-config --libs libsignal-protocol-c) -lmxml
|
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 \
|
|
|
|
user.c \
|
|
|
|
xmpp/presence.c \
|
2021-07-05 21:50:38 +00:00
|
|
|
xmpp/iq.c \
|
2021-07-01 23:13:15 +00:00
|
|
|
|
2021-07-07 17:27:06 +00:00
|
|
|
DEPS=omemo/build/libomemo-conversations.a axc/build/libaxc.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-07 17:27:06 +00:00
|
|
|
omemo/build/libomemo-conversations.a:
|
|
|
|
$(MAKE) -C omemo
|
|
|
|
omemo: omemo/build/libomemo-conversations.a
|
|
|
|
|
2021-07-01 23:13:15 +00:00
|
|
|
axc/build/libaxc.a:
|
|
|
|
$(MAKE) -C axc
|
|
|
|
axc: axc/build/libaxc.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-07 17:27:06 +00:00
|
|
|
$(MAKE) -C omemo clean || true
|
2021-07-02 22:10:40 +00:00
|
|
|
$(MAKE) -C axc 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
|
|
|
|
git submodule update --init --recursive || 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:
|
2018-05-09 00:57:17 +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 --extra=+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
|