weechat-xmpp/Makefile

78 lines
1.8 KiB
Makefile
Raw Normal View History

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
FIND=find
2021-06-30 20:39:08 +00:00
INCLUDES=-Ilibstrophe $(shell xml2-config --cflags)
2021-06-27 22:51:05 +00:00
CFLAGS+=$(DBGCFLAGS) -fno-omit-frame-pointer -fPIC -std=gnu99 -g -Wall -Wextra -Werror-implicit-function-declaration -Wno-missing-field-initializers $(INCLUDES)
2021-06-30 06:26:06 +00:00
LDFLAGS+=$(DBGLDFLAGS) -shared -g $(DBGCFLAGS)
2021-06-30 20:39:08 +00:00
LDLIBS=-lstrophe -lpthread $(shell xml2-config --libs)
2018-04-29 21:26:14 +00:00
2018-05-10 14:40:10 +00:00
PREFIX ?= /usr/local
LIBDIR ?= $(PREFIX)/lib
INSTALL ?= /usr/bin/install
2021-06-28 01:17:02 +00:00
SRCS=plugin.c \
2021-06-30 06:26:06 +00:00
account.c \
buffer.c \
channel.c \
command.c \
config.c \
connection.c \
input.c \
message.c \
user.c \
2021-06-25 22:20:49 +00:00
2021-06-28 01:18:05 +00:00
DEPS=
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-06-30 06:26:06 +00:00
xmpp.so: $(OBJS)
2021-06-26 01:31:45 +00:00
$(CC) $(LDFLAGS) -o xmpp.so $(OBJS) $(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
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
$(CC) $(CFLAGS) -MM $^>>./.depend
tidy:
$(FIND) . -name "*.o" -delete
2018-04-29 21:26:14 +00:00
clean:
$(RM) $(OBJS)
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-06-25 22:20:49 +00:00
$(INSTALL) -s -t $(DESTDIR)$(LIBDIR)/weechat/plugins -D -m 0644 xmpp.so
2018-05-10 14:40:10 +00:00
else
2021-06-25 22:20:49 +00:00
$(INSTALL) -s -t ~/.weechat/plugins -D -m 0755 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