Changeset 858ea01


Ignore:
Timestamp:
2010-09-30T05:50:43Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
6ce2240
Parents:
2dcaf9a
Message:

Allow building OTR support as a plugin. Fairly simple, let's hope I can get
away with doing this without libtool (eep).

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    r2dcaf9a r858ea01  
    1010
    1111# Program variables
    12 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)
     12objects = 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)
    1313headers = 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
    1414subdirs = lib protocols
     
    2727subdirobjs = $(foreach dir,$(subdirs),$(dir)/$(dir).o)
    2828
    29 all: $(OUTFILE)
     29all: $(OUTFILE) $(OTR_PI)
    3030        $(MAKE) -C doc
    3131
     
    3333        @echo -e '\nmake uninstall does not remove files in '$(DESTDIR)$(ETCDIR)', you can use make uninstall-etc to do that.\n'
    3434
    35 install: install-bin install-doc
     35install: install-bin install-doc install-plugins
    3636        @if ! [ -d $(DESTDIR)$(CONFIG) ]; then echo -e '\nThe configuration directory $(DESTDIR)$(CONFIG) does not exist yet, don'\''t forget to create it!'; fi
    3737        @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
    3838        @echo
    3939
    40 .PHONY:   install   install-bin   install-etc   install-doc \
     40.PHONY:   install   install-bin   install-etc   install-doc install-plugins \
    4141        uninstall uninstall-bin uninstall-etc uninstall-doc \
    4242        all clean distclean tar $(subdirs)
     
    104104        -rmdir $(DESTDIR)$(ETCDIR)
    105105
     106install-plugins:
     107ifdef OTR_PI
     108        mkdir -p $(DESTDIR)$(PLUGINDIR)
     109        install -m 0755 otr.so $(DESTDIR)$(PLUGINDIR)
     110endif
     111
    106112tar:
    107113        fakeroot debian/rules clean || make distclean
     
    112118$(subdirs):
    113119        @$(MAKE) -C $@ $(MAKECMDGOALS)
     120
     121$(OTR_PI): %.so: $(SRCDIR)%.c
     122        @echo '*' Building plugin $@
     123        @$(CC) $(CFLAGS) $(OTRFLAGS) -fPIC -shared $< -o $@
    114124
    115125$(objects): %.o: $(SRCDIR)%.c
  • configure

    r2dcaf9a r858ea01  
    500500fi
    501501if [ "$otr" = 1 ]; then
    502         echo '#define WITH_OTR' >> config.h
     502        # BI == built-in
     503        echo '#define OTR_BI' >> config.h
    503504        echo "EFLAGS+=-L${otrprefix}/lib -lotr" >> Makefile.settings
    504505        echo "CFLAGS+=-I${otrprefix}/include" >> Makefile.settings
    505 else
    506         echo '#undef WITH_OTR' >> config.h
     506        echo 'OTR_BI=otr.o' >> Makefile.settings
     507elif [ "$otr" = "plugin" ]; then
     508        echo '#define OTR_PI' >> config.h
     509        echo "OTRFLAGS=-L${otrprefix}/lib -lotr" >> Makefile.settings
     510        echo "CFLAGS+=-I${otrprefix}/include" >> Makefile.settings
     511        echo 'OTR_PI=otr.so' >> Makefile.settings
    507512fi
    508513
     
    703708if [ "$otr" = "1" ]; then
    704709        echo '  Off-the-Record (OTR) Messaging enabled.'
     710elif [ "$otr" = "plugin" ]; then
     711        echo '  Off-the-Record (OTR) Messaging enabled (as a plugin).'
    705712else
    706713        echo '  Off-the-Record (OTR) Messaging disabled.'
  • otr.c

    r2dcaf9a r858ea01  
    3939
    4040#include "bitlbee.h"
    41 #ifdef WITH_OTR
    4241#include "irc.h"
    4342#include "otr.h"
     
    182181/*** routines declared in otr.h: ***/
    183182
    184 void otr_init(void)
     183#ifdef OTR_BI
     184#define init_plugin otr_init
     185#endif
     186
     187void init_plugin(void)
    185188{
    186189        OTRL_INIT;
     
    17161719        }
    17171720}
    1718 
    1719 
    1720 #else /* WITH_OTR undefined */
    1721 
    1722 void cmd_otr(irc_t *irc, char **args)
    1723 {
    1724         irc_usermsg(irc, "otr: n/a, compiled without OTR support");
    1725 }
    1726 
    1727 #endif
  • unix.c

    r2dcaf9a r858ea01  
    7777           uses the defaults. Therefore we initialize OTR after SSL. *sigh* */
    7878        ssl_init();
     79#ifdef OTR_BI
    7980        otr_init();
     81#endif
     82        /* And in case OTR is loaded as a plugin, it'll also get loaded after
     83           this point. */
    8084       
    8185        srand( time( NULL ) ^ getpid() );
Note: See TracChangeset for help on using the changeset viewer.