You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.5 KiB
Makefile

ifdef DEBUG
3 years ago
DBGCFLAGS=-fsanitize=address -fsanitize=undefined -fsanitize=leak
DBGLDFLAGS=-lasan -lubsan -llsan
endif
7 years ago
RM=rm -f
FIND=find
3 years ago
INCLUDES=-Ilibstrophe $(shell xml2-config --cflags) $(shell pkg-config --cflags librnp-0) $(shell pkg-config --cflags libsignal-protocol-c)
3 years ago
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)
3 years ago
LDFLAGS+=$(DBGLDFLAGS) -shared -g $(DBGCFLAGS)
3 years ago
LDLIBS=-lstrophe -lpthread $(shell xml2-config --libs) $(shell pkg-config --libs librnp-0) $(shell pkg-config --libs libsignal-protocol-c) -lgcrypt -llmdb
7 years ago
7 years ago
PREFIX ?= /usr/local
LIBDIR ?= $(PREFIX)/lib
3 years ago
SRCS=plugin.c \
account.c \
buffer.c \
channel.c \
command.c \
completion.c \
config.c \
connection.c \
input.c \
message.c \
omemo.c \
3 years ago
pgp.c \
user.c \
3 years ago
util.c \
xmpp/presence.c \
xmpp/iq.c \
3 years ago
3 years ago
DEPS=diff/libdiff.a
OBJS=$(subst .c,.o,$(SRCS))
3 years ago
all: weechat-xmpp
weechat-xmpp: $(DEPS) xmpp.so
7 years ago
3 years ago
xmpp.so: $(OBJS) $(DEPS)
$(CC) $(LDFLAGS) -o xmpp.so $(OBJS) $(DEPS) $(LDLIBS)
which patchelf >/dev/null && \
3 years ago
patchelf --set-rpath $(LIBRARY_PATH):$(shell realpath $(shell dirname $(shell gcc --print-libgcc-file-name))/../../../) xmpp.so && \
patchelf --shrink-rpath xmpp.so || true
3 years ago
diff/libdiff.a:
3 years ago
git submodule update --init --recursive
3 years ago
cd diff && ./configure
$(MAKE) -C diff CFLAGS=-fPIC
diff: diff/libdiff.a
3 years ago
test: xmpp.so
env LD_PRELOAD=$(DEBUG) \
3 years ago
weechat -a -P 'alias,buflist,irc' -r '/plugin load ./xmpp.so'
3 years ago
debug: xmpp.so
gdb -ex "handle SIGPIPE nostop noprint pass" --args \
weechat -a -r '/plugin load ./xmpp.so'
7 years ago
depend: .depend
3 years ago
.depend: $(SRCS)
7 years ago
$(RM) ./.depend
$(CC) $(CFLAGS) -MM $^>>./.depend
tidy:
$(FIND) . -name "*.o" -delete
7 years ago
clean:
$(RM) -f $(OBJS)
3 years ago
$(MAKE) -C diff clean || true
3 years ago
git submodule foreach --recursive git clean -xfd || true
git submodule foreach --recursive git reset --hard || true
7 years ago
distclean: clean
$(RM) *~ .depend
3 years ago
install: xmpp.so
7 years ago
ifeq ($(shell id -u),0)
mkdir -p $(DESTDIR)$(LIBDIR)/weechat/plugins
cp xmpp.so $(DESTDIR)$(LIBDIR)/weechat/plugins/xmpp.so
chmod 644 $(DESTDIR)$(LIBDIR)/weechat/plugins/xmpp.so
7 years ago
else
mkdir -p ~/.weechat/plugins
cp xmpp.so ~/.weechat/plugins/xmpp.so
chmod 755 ~/.weechat/plugins/xmpp.so
7 years ago
endif
.PHONY: tags cs
tags:
3 years ago
$(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
7 years ago
cs:
cscope -RUbq
7 years ago
include .depend