aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile18
-rwxr-xr-xconfigure13
-rw-r--r--otr.c17
-rw-r--r--unix.c4
4 files changed, 33 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index 3754bb4b..682500ec 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@
-include Makefile.settings
# Program variables
-objects = bitlbee.o dcc.o help.o ipc.o irc.o irc_im.o irc_channel.o irc_commands.o irc_send.o irc_user.o irc_util.o nick.o otr.o query.o root_commands.o set.o storage.o $(STORAGE_OBJS)
+objects = bitlbee.o dcc.o help.o ipc.o irc.o irc_im.o irc_channel.o irc_commands.o irc_send.o irc_user.o irc_util.o nick.o $(OTR_BI) query.o root_commands.o set.o storage.o $(STORAGE_OBJS)
headers = bitlbee.h commands.h conf.h config.h help.h ipc.h irc.h log.h nick.h query.h set.h sock.h storage.h lib/events.h lib/ftutil.h lib/http_client.h lib/ini.h lib/md5.h lib/misc.h lib/proxy.h lib/sha1.h lib/ssl_client.h lib/url.h protocols/account.h protocols/bee.h protocols/ft.h protocols/nogaim.h
subdirs = lib protocols
@@ -26,18 +26,18 @@ endif
# Expansion of variables
subdirobjs = $(foreach dir,$(subdirs),$(dir)/$(dir).o)
-all: $(OUTFILE)
+all: $(OUTFILE) $(OTR_PI)
$(MAKE) -C doc
uninstall: uninstall-bin uninstall-doc
@echo -e '\nmake uninstall does not remove files in '$(DESTDIR)$(ETCDIR)', you can use make uninstall-etc to do that.\n'
-install: install-bin install-doc
+install: install-bin install-doc install-plugins
@if ! [ -d $(DESTDIR)$(CONFIG) ]; then echo -e '\nThe configuration directory $(DESTDIR)$(CONFIG) does not exist yet, don'\''t forget to create it!'; fi
@if ! [ -e $(DESTDIR)$(ETCDIR)/bitlbee.conf ]; then echo -e '\nNo files are installed in '$(DESTDIR)$(ETCDIR)' by make install. Run make install-etc to do that.'; fi
@echo
-.PHONY: install install-bin install-etc install-doc \
+.PHONY: install install-bin install-etc install-doc install-plugins \
uninstall uninstall-bin uninstall-etc uninstall-doc \
all clean distclean tar $(subdirs)
@@ -103,6 +103,12 @@ uninstall-etc:
rm -f $(DESTDIR)$(ETCDIR)/bitlbee.conf
-rmdir $(DESTDIR)$(ETCDIR)
+install-plugins:
+ifdef OTR_PI
+ mkdir -p $(DESTDIR)$(PLUGINDIR)
+ install -m 0755 otr.so $(DESTDIR)$(PLUGINDIR)
+endif
+
tar:
fakeroot debian/rules clean || make distclean
x=$$(basename $$(pwd)); \
@@ -112,6 +118,10 @@ tar:
$(subdirs):
@$(MAKE) -C $@ $(MAKECMDGOALS)
+$(OTR_PI): %.so: $(SRCDIR)%.c
+ @echo '*' Building plugin $@
+ @$(CC) $(CFLAGS) $(OTRFLAGS) -fPIC -shared $< -o $@
+
$(objects): %.o: $(SRCDIR)%.c
@echo '*' Compiling $<
@$(CC) -c $(CFLAGS) $< -o $@
diff --git a/configure b/configure
index 811f829e..f7c81cba 100755
--- a/configure
+++ b/configure
@@ -499,11 +499,16 @@ if [ "$otr" = "auto" ]; then
fi
fi
if [ "$otr" = 1 ]; then
- echo '#define WITH_OTR' >> config.h
+ # BI == built-in
+ echo '#define OTR_BI' >> config.h
echo "EFLAGS+=-L${otrprefix}/lib -lotr" >> Makefile.settings
echo "CFLAGS+=-I${otrprefix}/include" >> Makefile.settings
-else
- echo '#undef WITH_OTR' >> config.h
+ echo 'OTR_BI=otr.o' >> Makefile.settings
+elif [ "$otr" = "plugin" ]; then
+ echo '#define OTR_PI' >> config.h
+ echo "OTRFLAGS=-L${otrprefix}/lib -lotr" >> Makefile.settings
+ echo "CFLAGS+=-I${otrprefix}/include" >> Makefile.settings
+ echo 'OTR_PI=otr.so' >> Makefile.settings
fi
if [ ! -e doc/user-guide/help.txt ] && ! type xmlto > /dev/null 2> /dev/null; then
@@ -702,6 +707,8 @@ fi
if [ "$otr" = "1" ]; then
echo ' Off-the-Record (OTR) Messaging enabled.'
+elif [ "$otr" = "plugin" ]; then
+ echo ' Off-the-Record (OTR) Messaging enabled (as a plugin).'
else
echo ' Off-the-Record (OTR) Messaging disabled.'
fi
diff --git a/otr.c b/otr.c
index ad59d5b0..a9da9850 100644
--- a/otr.c
+++ b/otr.c
@@ -38,7 +38,6 @@
*/
#include "bitlbee.h"
-#ifdef WITH_OTR
#include "irc.h"
#include "otr.h"
#include <sys/types.h>
@@ -181,7 +180,11 @@ static const struct irc_plugin otr_plugin;
/*** routines declared in otr.h: ***/
-void otr_init(void)
+#ifdef OTR_BI
+#define init_plugin otr_init
+#endif
+
+void init_plugin(void)
{
OTRL_INIT;
@@ -1715,13 +1718,3 @@ void yes_keygen(void *data)
otr_keygen(irc, acc->user, acc->prpl->name);
}
}
-
-
-#else /* WITH_OTR undefined */
-
-void cmd_otr(irc_t *irc, char **args)
-{
- irc_usermsg(irc, "otr: n/a, compiled without OTR support");
-}
-
-#endif
diff --git a/unix.c b/unix.c
index 11997732..4869e9f9 100644
--- a/unix.c
+++ b/unix.c
@@ -76,7 +76,11 @@ int main( int argc, char *argv[] )
memory management functions for libgcrypt while our gnutls module
uses the defaults. Therefore we initialize OTR after SSL. *sigh* */
ssl_init();
+#ifdef OTR_BI
otr_init();
+#endif
+ /* And in case OTR is loaded as a plugin, it'll also get loaded after
+ this point. */
srand( time( NULL ) ^ getpid() );