mirror of https://github.com/bqv/weechat-xmpp
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.
171 lines
4.0 KiB
Makefile
171 lines
4.0 KiB
Makefile
3 years ago
|
ifdef DEBUG
|
||
|
DBGCFLAGS=-fsanitize=address -fsanitize=undefined -fsanitize=leak
|
||
|
DBGLDFLAGS=-lasan -lubsan -llsan
|
||
|
endif
|
||
|
|
||
|
RM=rm -f
|
||
|
FIND=find
|
||
|
|
||
|
INCLUDES=-Ilibstrophe \
|
||
|
$(shell xml2-config --cflags) \
|
||
|
$(shell pkg-config --cflags librnp-0) \
|
||
3 years ago
|
$(shell pkg-config --cflags libomemo-c)
|
||
3 years ago
|
CFLAGS+=$(DBGCFLAGS) \
|
||
|
-fno-omit-frame-pointer -fPIC \
|
||
|
-std=gnu99 -gdwarf-4 \
|
||
3 years ago
|
-Wall -Wextra -pedantic \
|
||
3 years ago
|
-Werror-implicit-function-declaration \
|
||
|
-Wno-missing-field-initializers \
|
||
|
-D_XOPEN_SOURCE=700 \
|
||
|
$(INCLUDES)
|
||
|
CPPFLAGS+=$(DBGCFLAGS) \
|
||
|
-fno-omit-frame-pointer -fPIC \
|
||
|
-std=c++17 -gdwarf-4 \
|
||
3 years ago
|
-Wall -Wextra -pedantic \
|
||
3 years ago
|
-Wno-missing-field-initializers \
|
||
|
$(INCLUDES)
|
||
3 years ago
|
# -DDOCTEST_CONFIG_DISABLE
|
||
3 years ago
|
LDFLAGS+=$(DBGLDFLAGS) \
|
||
|
-shared -gdwarf-4 \
|
||
|
$(DBGCFLAGS)
|
||
|
LDLIBS=-lstrophe \
|
||
3 years ago
|
-lpthread \
|
||
|
$(shell xml2-config --libs) \
|
||
|
$(shell pkg-config --libs librnp-0) \
|
||
3 years ago
|
$(shell pkg-config --libs libomemo-c) \
|
||
3 years ago
|
-lgcrypt \
|
||
|
-llmdb
|
||
3 years ago
|
|
||
|
PREFIX ?= /usr/local
|
||
|
LIBDIR ?= $(PREFIX)/lib
|
||
|
|
||
3 years ago
|
HDRS=plugin.hh \
|
||
3 years ago
|
weechat.hh \
|
||
3 years ago
|
strophe.hh \
|
||
3 years ago
|
account.hh \
|
||
|
config.hh \
|
||
|
#### plugin.h \
|
||
|
#### account.h \
|
||
|
#### buffer.h \
|
||
|
#### channel.h \
|
||
|
#### command.h \
|
||
|
#### completion.h \
|
||
|
#### config.h \
|
||
|
#### connection.h \
|
||
|
#### input.h \
|
||
|
#### message.h \
|
||
|
#### omemo.h \
|
||
|
#### pgp.h \
|
||
|
#### user.h \
|
||
|
#### util.h \
|
||
|
#### xmpp/stanza.h \
|
||
3 years ago
|
|
||
|
SRCS=plugin.cpp \
|
||
3 years ago
|
weechat.cpp \
|
||
3 years ago
|
strophe.cpp \
|
||
3 years ago
|
account.cpp \
|
||
|
config.cpp \
|
||
|
#### account.c \
|
||
|
#### buffer.c \
|
||
|
#### channel.c \
|
||
|
#### command.c \
|
||
|
#### completion.c \
|
||
|
#### config.c \
|
||
|
#### connection.c \
|
||
|
#### input.c \
|
||
|
#### message.c \
|
||
|
#### omemo.c \
|
||
|
#### pgp.c \
|
||
|
#### user.c \
|
||
|
#### util.c \
|
||
|
#### xmpp/presence.c \
|
||
|
#### xmpp/iq.c \
|
||
3 years ago
|
|
||
|
DEPS=deps/diff/libdiff.a \
|
||
|
|
||
|
OBJS=$(patsubst %.cpp,.%.o,$(patsubst %.c,.%.o,$(patsubst xmpp/%.c,xmpp/.%.o,$(SRCS))))
|
||
3 years ago
|
|
||
3 years ago
|
all:
|
||
|
make depend
|
||
|
make weechat-xmpp && make test
|
||
|
|
||
3 years ago
|
weechat-xmpp: $(DEPS) xmpp.so
|
||
|
|
||
|
xmpp.so: $(OBJS) $(DEPS) $(HDRS)
|
||
3 years ago
|
$(CXX) $(LDFLAGS) -o .$@ $(OBJS) $(DEPS) $(LDLIBS)
|
||
3 years ago
|
which patchelf >/dev/null && \
|
||
|
patchelf --set-rpath $(LIBRARY_PATH):$(shell realpath $(shell dirname $(shell gcc --print-libgcc-file-name))/../../../) xmpp.so && \
|
||
|
patchelf --shrink-rpath xmpp.so || true
|
||
|
|
||
|
.%.o: %.cpp
|
||
|
@$(CXX) $(CPPFLAGS) -c $< -o $@
|
||
|
|
||
3 years ago
|
.%.o: %.c
|
||
|
@$(CC) $(CFLAGS) -c $< -o $@
|
||
|
|
||
|
xmpp/.%.o: xmpp/%.c
|
||
|
@$(CC) $(CFLAGS) -c $< -o $@
|
||
|
|
||
3 years ago
|
deps/diff/libdiff.a:
|
||
|
git submodule update --init --recursive
|
||
3 years ago
|
cd deps/diff && env -u MAKEFLAGS ./configure
|
||
3 years ago
|
$(MAKE) -C deps/diff CFLAGS=-fPIC
|
||
|
diff: deps/diff/libdiff.a
|
||
|
|
||
3 years ago
|
tests/run: xmpp.so tests/main.cpp
|
||
|
$(CXX) $(CPPFLAGS) -o tests/run xmpp.so tests/main.cpp $(LDLIBS)
|
||
3 years ago
|
which patchelf >/dev/null && \
|
||
|
patchelf --set-rpath $(PWD):$(LIBRARY_PATH):$(shell realpath $(shell dirname $(shell gcc --print-libgcc-file-name))/../../../) tests/run && \
|
||
|
patchelf --shrink-rpath tests/run || true
|
||
|
|
||
|
test: tests/run
|
||
|
tests/run
|
||
|
|
||
|
debug: xmpp.so
|
||
|
env LD_PRELOAD=$(DEBUG) gdb -ex "handle SIGPIPE nostop noprint pass" --args \
|
||
|
weechat -a -P 'alias,buflist,exec,irc' -r '/plugin load ./xmpp.so'
|
||
|
|
||
3 years ago
|
depend: $(SRCS) $(HDRS)
|
||
|
$(RM) -f ./.depend
|
||
|
echo > ./.depend
|
||
|
for src in $(SRCS) ; do \
|
||
|
if [[ $$src == *.cpp ]]; then \
|
||
|
$(CXX) $(CPPFLAGS) -MM -MMD -MP -MF - \
|
||
|
-MT .$${src/.cpp/.o} $$src >> ./.depend ; \
|
||
|
elif [[ $$src == *.c ]]; then \
|
||
|
$(CC) $(CFLAGS) -MM -MMD -MP -MF - \
|
||
|
-MT .$${src/.c/.o} $$src >> ./.depend ; \
|
||
|
fi \
|
||
|
done
|
||
|
sed -i 's/\.\([a-z]*\/\)/\1./' .depend
|
||
3 years ago
|
|
||
|
tidy:
|
||
|
$(FIND) . -name "*.o" -delete
|
||
|
|
||
|
clean:
|
||
|
$(RM) -f $(OBJS)
|
||
|
$(MAKE) -C deps/diff clean || true
|
||
|
git submodule foreach --recursive git clean -xfd || true
|
||
|
git submodule foreach --recursive git reset --hard || true
|
||
|
|
||
|
distclean: clean
|
||
|
$(RM) *~ .depend
|
||
|
|
||
|
install: xmpp.so
|
||
|
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
|
||
|
else
|
||
|
mkdir -p ~/.weechat/plugins
|
||
|
cp xmpp.so ~/.weechat/plugins/xmpp.so
|
||
|
chmod 755 ~/.weechat/plugins/xmpp.so
|
||
|
endif
|
||
|
|
||
3 years ago
|
.PHONY: all weechat-xmpp test debug depend tidy clean distclean install check
|
||
3 years ago
|
|
||
|
check:
|
||
|
clang-check --analyze *.c *.cc *.cpp
|
||
|
|
||
|
include .depend
|