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.

86 lines
2.1 KiB
Makefile

ifdef DEBUG
4 years ago
DBGCFLAGS=-fsanitize=address -fsanitize=undefined -fsanitize=leak
DBGLDFLAGS=-lasan -lubsan -llsan
endif
7 years ago
RM=rm -f
FIND=find
INCLUDES=-Ilibstrophe $(shell xml2-config --cflags)
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)
4 years ago
LDFLAGS+=$(DBGLDFLAGS) -shared -g $(DBGCFLAGS)
LDLIBS=-lstrophe -lpthread $(shell xml2-config --libs)
7 years ago
7 years ago
PREFIX ?= /usr/local
LIBDIR ?= $(PREFIX)/lib
INSTALL ?= /usr/bin/install
4 years ago
SRCS=plugin.c \
4 years ago
account.c \
buffer.c \
channel.c \
command.c \
config.c \
connection.c \
input.c \
message.c \
user.c \
DEPS=axc/build/libaxc.a
OBJS=$(subst .c,.o,$(SRCS))
4 years ago
all: weechat-xmpp
weechat-xmpp: $(DEPS) xmpp.so
7 years ago
4 years ago
xmpp.so: $(OBJS) $(DEPS)
$(CC) $(LDFLAGS) -o xmpp.so $(OBJS) $(DEPS) $(LDLIBS)
which patchelf >/dev/null && \
4 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
4 years ago
axc/build/libaxc.a:
$(MAKE) -C axc
axc: axc/build/libaxc.a
4 years ago
test: xmpp.so
env LD_PRELOAD=$(DEBUG) \
4 years ago
weechat -a -P 'alias,buflist,irc' -r '/plugin load ./xmpp.so'
4 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
4 years ago
.depend: $(SRCS)
7 years ago
$(RM) ./.depend
$(CC) $(CFLAGS) -MM $^>>./.depend
tidy:
$(FIND) . -name "*.o" -delete
7 years ago
clean:
$(RM) $(OBJS)
4 years ago
$(MAKE) -C axc clean
git submodule foreach --recursive git clean -xfd || true
git submodule foreach --recursive git reset --hard || true
git submodule update --init --recursive || true
7 years ago
distclean: clean
$(RM) *~ .depend
4 years ago
install: xmpp.so
7 years ago
ifeq ($(shell id -u),0)
4 years ago
$(INSTALL) -s -t $(DESTDIR)$(LIBDIR)/weechat/plugins -D -m 0644 xmpp.so
7 years ago
else
4 years ago
$(INSTALL) -s -t ~/.weechat/plugins -D -m 0755 xmpp.so
7 years ago
endif
.PHONY: tags cs
tags:
7 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 --extra=+fq
7 years ago
cs:
cscope -RUbq
7 years ago
include .depend