#!/bin/sh ############################## ## Configurer for BitlBee ## ## ## ## Copyright 2004 Lintux ## ## Copyright 2002 Lucumo ## ############################## prefix='/usr/local/' bindir='$prefix/bin/' sbindir='$prefix/sbin/' etcdir='$prefix/etc/bitlbee/' mandir='$prefix/share/man/' datadir='$prefix/share/bitlbee/' config='/var/lib/bitlbee/' plugindir='$prefix/lib/bitlbee/' includedir='$prefix/include/bitlbee/' systemdsystemunitdir='' libevent='/usr/' pidfile='/var/run/bitlbee.pid' ipcsocket='' pcdir='$prefix/lib/pkgconfig' systemlibdirs="/lib64 /usr/lib64 /usr/local/lib64 /lib /usr/lib /usr/local/lib" msn=1 jabber=1 oscar=1 yahoo=1 twitter=1 purple=0 debug=0 strip=1 gcov=0 plugins=1 otr=0 skype=0 events=glib ldap=0 ssl=auto arch=`uname -s` cpu=`uname -m` GLIB_MIN_VERSION=2.14 echo BitlBee configure while [ -n "$1" ]; do e="`expr "X$1" : 'X--\(.*=.*\)'`" if [ -z "$e" ]; then cat<Makefile.settings ## BitlBee settings, generated by configure PREFIX=$prefix BINDIR=$bindir SBINDIR=$sbindir ETCDIR=$etcdir MANDIR=$mandir DATADIR=$datadir PLUGINDIR=$plugindir CONFIG=$config INCLUDEDIR=$includedir PCDIR=$pcdir TARGET=$target ARCH=$arch CPU=$cpu INSTALL=install -p DESTDIR= LFLAGS= EFLAGS= EOF srcdir=$(cd $(dirname $0);pwd) currdir=$(pwd) if [ "$srcdir" != "$currdir" ]; then echo echo "configure script run from a different directory. Will create some symlinks..." if [ ! -e Makefile -o -L Makefile ]; then COPYDIRS="doc lib protocols tests utils" mkdir -p $(cd "$srcdir"; find $COPYDIRS -type d) find . -name Makefile -type l -print0 | xargs -0 rm 2> /dev/null dst="$PWD" cd "$srcdir" for i in $(find . -name Makefile -type f); do ln -s "$PWD${i#.}" "$dst/$i"; done cd "$dst" rm -rf .bzr fi echo "_SRCDIR_=$srcdir/" >> Makefile.settings CFLAGS="$CFLAGS -I${dst}" else srcdir=$PWD fi cat<config.h /* BitlBee settings, generated by configure Do *NOT* use any of these defines in your code without thinking twice, most of them can/will be overridden at run-time */ #define CONFIG "$config" #define ETCDIR "$etcdir" #define VARDIR "$datadir" #define PLUGINDIR "$plugindir" #define PIDFILE "$pidfile" #define IPCSOCKET "$ipcsocket" #define ARCH "$arch" #define CPU "$cpu" EOF if [ -n "$target" ]; then PKG_CONFIG_LIBDIR=/usr/$target/lib/pkgconfig export PKG_CONFIG_LIBDIR PATH=/usr/$target/bin:$PATH CC=$target-cc LD=$target-ld systemlibdirs="/usr/$target/lib" fi if [ "$debug" = "1" ]; then [ -z "$CFLAGS" ] && CFLAGS=-g echo 'DEBUG=1' >> Makefile.settings CFLAGS="$CFLAGS -DDEBUG" else [ -z "$CFLAGS" ] && CFLAGS="-O2 -fno-strict-aliasing" fi echo CFLAGS=$CFLAGS $CPPFLAGS >> Makefile.settings echo CFLAGS+=-I${srcdir} -I${srcdir}/lib -I${srcdir}/protocols -I. >> Makefile.settings echo CFLAGS+=-DHAVE_CONFIG_H >> Makefile.settings if [ -n "$CC" ]; then CC=$CC elif type gcc > /dev/null 2> /dev/null; then CC=gcc elif type cc > /dev/null 2> /dev/null; then CC=cc else echo 'Cannot find a C compiler, aborting.' exit 1; fi echo "CC=$CC" >> Makefile.settings; if echo $CC | grep -qw gcc; then # Apparently -Wall is gcc-specific? echo CFLAGS+=-Wall >> Makefile.settings fi if [ -z "$LD" ]; then if type ld > /dev/null 2> /dev/null; then LD=ld else echo 'Cannot find ld, aborting.' exit 1; fi fi echo "LD=$LD" >> Makefile.settings if [ -z "$PKG_CONFIG" ]; then PKG_CONFIG=pkg-config fi if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG glib-2.0; then if $PKG_CONFIG glib-2.0 --atleast-version=$GLIB_MIN_VERSION; then cat<>Makefile.settings EFLAGS+=`$PKG_CONFIG --libs glib-2.0 gmodule-2.0` CFLAGS+=`$PKG_CONFIG --cflags glib-2.0 gmodule-2.0` EOF else echo echo 'Found glib2 '`$PKG_CONFIG glib-2.0 --modversion`', but version '$GLIB_MIN_VERSION' or newer is required.' exit 1 fi else echo echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)' exit 1 fi if [ "$events" = "libevent" ]; then if ! [ -f "${libevent}include/event.h" ]; then echo echo 'Warning: Could not find event.h, you might have to install it and/or specify' echo 'its location using the --libevent= argument. (Example: If event.h is in' echo '/usr/local/include and binaries are in /usr/local/lib: --libevent=/usr/local)' fi echo '#define EVENTS_LIBEVENT' >> config.h cat <>Makefile.settings EFLAGS+=-levent -L${libevent}lib CFLAGS+=-I${libevent}include EOF elif [ "$events" = "glib" ]; then ## We already use glib anyway, so this is all we need (and in fact not even this, but just to be sure...): echo '#define EVENTS_GLIB' >> config.h else echo echo 'ERROR: Unknown event handler specified.' exit 1 fi echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings detect_gnutls() { if $PKG_CONFIG --exists gnutls; then cat <>Makefile.settings EFLAGS+=`$PKG_CONFIG --libs gnutls` `libgcrypt-config --libs` CFLAGS+=`$PKG_CONFIG --cflags gnutls` `libgcrypt-config --cflags` EOF ssl=gnutls if ! pkg-config gnutls --atleast-version=2.8; then echo echo 'Warning: With GnuTLS versions <2.8, certificate expire dates are not verified.' fi ret=1 elif libgnutls-config --version > /dev/null 2> /dev/null; then cat <>Makefile.settings EFLAGS+=`libgnutls-config --libs` `libgcrypt-config --libs` CFLAGS+=`libgnutls-config --cflags` `libgcrypt-config --cflags` EOF ssl=gnutls ret=1; else ret=0; fi; } detect_nss() { if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG nss; then cat<>Makefile.settings EFLAGS+=`$PKG_CONFIG --libs nss` CFLAGS+=`$PKG_CONFIG --cflags nss` EOF ssl=nss ret=1; else ret=0; fi; } detect_ldap() { TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) if $CC -o $TMPFILE -shared -lldap 2>/dev/null >/dev/null; then cat<>Makefile.settings EFLAGS+=-lldap CFLAGS+= EOF ldap=1 rm -f $TMPFILE ret=1 else ldap=0 ret=0 fi } RESOLV_TESTCODE=' #include #include #include #include int main() { ns_initparse( NULL, 0, NULL ); ns_parserr( NULL, ns_s_an, 0, NULL ); } ' detect_resolv_dynamic() { case "$arch" in FreeBSD ) # In FreeBSD res_* routines are present in libc.so LIBRESOLV=;; * ) LIBRESOLV=-lresolv;; esac TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) ret=1 echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null if [ "$?" = "0" ]; then echo "EFLAGS+=$LIBRESOLV" >> Makefile.settings ret=0 fi rm -f $TMPFILE return $ret } detect_resolv_static() { TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) ret=1 for i in $systemlibdirs; do if [ -f $i/libresolv.a ]; then echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null if [ "$?" = "0" ]; then echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings ret=0 fi fi done rm -f $TMPFILE return $ret } if [ "$ssl" = "auto" ]; then detect_gnutls if [ "$ret" = "0" ]; then # Disable NSS for now as it's known to not work very well ATM. #detect_nss : fi elif [ "$ssl" = "gnutls" ]; then detect_gnutls elif [ "$ssl" = "nss" ]; then detect_nss elif [ "$ssl" = "sspi" ]; then echo elif [ "$ssl" = "openssl" ]; then echo echo 'No detection code exists for OpenSSL. Make sure that you have a complete' echo 'install of OpenSSL (including devel/header files) before reporting' echo 'compilation problems.' echo echo 'Also, keep in mind that the OpenSSL is, according to some people, not' echo 'completely GPL-compatible. Using GnuTLS or NSS is recommended and better' echo 'supported by us. However, on many BSD machines, OpenSSL can be considered' echo 'part of the operating system, which makes it GPL-compatible.' echo echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2' echo ' http://www.gnome.org/~markmc/openssl-and-the-gpl.html' echo echo 'Please note that distributing a BitlBee binary which links to OpenSSL is' echo 'probably illegal. If you want to create and distribute a binary BitlBee' echo 'package, you really should use GnuTLS or NSS instead.' echo echo 'Also, the OpenSSL license requires us to say this:' echo ' * "This product includes software developed by the OpenSSL Project' echo ' * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"' echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings ret=1 elif [ "$ssl" = "bogus" ]; then echo echo 'Using bogus SSL code. This means some features will not work properly.' ## Yes, you, at the console! How can you authenticate if you don't have any SSL!? if [ "$msn" = "1" -o "$yahoo" = "1" ]; then echo echo 'WARNING: The MSN and Yahoo! modules will not work without SSL. Disabling.' msn=0 yahoo=0 fi ret=1 else echo echo 'ERROR: Unknown SSL library specified.' exit 1 fi if [ "$ret" = "0" ]; then echo echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).' echo ' Please note that this script doesn'\''t have detection code for OpenSSL,' echo ' so if you want to use that, you have to select it by hand. If you don'\''t' echo ' need SSL support, you can select the "bogus" SSL library. (--ssl=bogus)' exit 1 fi; echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings if detect_resolv_dynamic || detect_resolv_static; then echo '#define HAVE_RESOLV_A' >> config.h fi STORAGES="xml" if [ "$ldap" = "auto" ]; then detect_ldap fi if [ "$ldap" = 0 ]; then echo "#undef WITH_LDAP" >> config.h elif [ "$ldap" = 1 ]; then echo echo 'LDAP support is a work in progress and does NOT work AT ALL right now.' echo exit 1 echo "#define WITH_LDAP 1" >> config.h STORAGES="$STORAGES ldap" fi for i in $STORAGES; do STORAGE_OBJS="$STORAGE_OBJS storage_$i.o" done echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings if [ "$strip" = 0 ]; then echo "STRIP=\# skip strip" >> Makefile.settings; else if [ "$debug" = 1 ]; then echo echo 'Stripping binaries does not make sense when debugging. Stripping disabled.' echo 'STRIP=\# skip strip' >> Makefile.settings strip=0; elif [ -n "$STRIP" ]; then echo "STRIP=$STRIP" >> Makefile.settings; elif type strip > /dev/null 2> /dev/null; then echo "STRIP=strip" >> Makefile.settings; else echo echo 'No strip utility found, cannot remove unnecessary parts from executable.' echo 'STRIP=\# skip strip' >> Makefile.settings strip=0; fi; fi if [ -z "$systemdsystemunitdir" ]; then if $PKG_CONFIG --exists systemd; then systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd` fi fi if [ -n "$systemdsystemunitdir" ]; then if [ "$systemdsystemunitdir" != "no" ]; then echo "SYSTEMDSYSTEMUNITDIR=$systemdsystemunitdir" >> Makefile.settings fi fi if [ "$gcov" = "1" ]; then echo "CFLAGS+=--coverage" >> Makefile.settings echo "EFLAGS+=--coverage" >> Makefile.settings fi if [ "$plugins" = 0 ]; then echo '#undef WITH_PLUGINS' >> config.h else echo '#define WITH_PLUGINS' >> config.h fi otrprefix="" for i in / /usr /usr/local; do if [ -f ${i}/lib/libotr.a ]; then otrprefix=${i} break fi done if [ "$otr" = "auto" ]; then if [ -n "$otrprefix" ]; then otr=1 else otr=0 fi fi if [ "$otr" = 1 ]; then # BI == built-in echo '#define OTR_BI' >> config.h echo "EFLAGS+=-L${otrprefix}/lib -lotr" >> Makefile.settings echo "CFLAGS+=-I${otrprefix}/include" >> Makefile.settings 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 [ "$skype" = "1" -o "$skype" = "plugin" ]; then echo 'SKYPE_PI=skype.so' >> Makefile.settings protocols_mods="$protocol_mods skype(plugin)" fi if [ ! -e doc/user-guide/help.txt ] && ! type xmlto > /dev/null 2> /dev/null; then echo echo 'WARNING: Building from an unreleased source tree without prebuilt helpfile.' echo 'Install xmlto if you want online help to work.' fi echo if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then nick=`bzr nick` if [ -n "$nick" -a "$nick" != "bitlbee" ]; then nick="-$nick" else nick="" fi rev=`bzr revno` echo 'Using bzr revision #'$rev' as version number' BITLBEE_VERSION=\"bzr$nick-$rev\" fi if [ -n "$BITLBEE_VERSION" ]; then echo 'Spoofing version number: '$BITLBEE_VERSION echo '#undef BITLBEE_VERSION' >> config.h echo '#define BITLBEE_VERSION '$BITLBEE_VERSION >> config.h echo fi if ! make helloworld > /dev/null 2>&1; then echo "WARNING: Your version of make (BSD make?) does not support BitlBee's makefiles." echo "BitlBee needs GNU make to build properly. On most systems GNU make is available" echo "under the name 'gmake'." echo if gmake helloworld > /dev/null 2>&1; then echo "gmake seems to be available on your machine, great." echo else echo "gmake is not installed (or not working). Please try to install it." echo fi fi cat <bitlbee.pc prefix=$prefix includedir=$includedir Name: bitlbee Description: IRC to IM gateway Requires: glib-2.0 Version: $BITLBEE_VERSION Libs: Cflags: -I\${includedir} EOF protocols='' protoobjs='' if [ "$purple" = 0 ]; then echo '#undef WITH_PURPLE' >> config.h else if ! $PKG_CONFIG purple; then echo echo 'Cannot find libpurple development libraries, aborting. (Install libpurple-dev?)' exit 1 fi echo '#define WITH_PURPLE' >> config.h cat<>Makefile.settings EFLAGS += $($PKG_CONFIG purple --libs) PURPLE_CFLAGS += $($PKG_CONFIG purple --cflags) EOF protocols=$protocols'purple ' protoobjs=$protoobjs'purple_mod.o ' # Having both libpurple and native IM modules in one binary may # do strange things. Let's not do that. msn=0 jabber=0 oscar=0 yahoo=0 echo '#undef PACKAGE' >> config.h echo '#define PACKAGE "BitlBee-LIBPURPLE"' >> config.h if [ "$events" = "libevent" ]; then echo 'Warning: Some libpurple modules (including msn-pecan) do their event handling' echo 'outside libpurple, talking to GLib directly. At least for now the combination' echo 'libpurple + libevent is *not* recommended!' echo fi fi case "$CC" in *gcc* ) echo CFLAGS+=-MMD -MF .depend/\$@.d >> Makefile.settings for i in . lib protocols protocols/*/; do mkdir -p $i/.depend done esac if [ "$msn" = 0 ]; then echo '#undef WITH_MSN' >> config.h else echo '#define WITH_MSN' >> config.h protocols=$protocols'msn ' protoobjs=$protoobjs'msn_mod.o ' fi if [ "$jabber" = 0 ]; then echo '#undef WITH_JABBER' >> config.h else echo '#define WITH_JABBER' >> config.h protocols=$protocols'jabber ' protoobjs=$protoobjs'jabber_mod.o ' fi if [ "$oscar" = 0 ]; then echo '#undef WITH_OSCAR' >> config.h else echo '#define WITH_OSCAR' >> config.h protocols=$protocols'oscar ' protoobjs=$protoobjs'oscar_mod.o ' fi if [ "$yahoo" = 0 ]; then echo '#undef WITH_YAHOO' >> config.h else echo '#define WITH_YAHOO' >> config.h protocols=$protocols'yahoo ' protoobjs=$protoobjs'yahoo_mod.o ' fi if [ "$twitter" = 0 ]; then echo '#undef WITH_TWITTER' >> config.h else echo '#define WITH_TWITTER' >> config.h protocols=$protocols'twitter ' protoobjs=$protoobjs'twitter_mod.o ' fi if [ "$protocols" = "PROTOCOLS = " ]; then echo "Warning: You haven't selected any communication protocol to compile!" echo " BitlBee will run, but you will be unable to connect to IM servers!" fi echo "PROTOCOLS = $protocols" >> Makefile.settings echo "PROTOOBJS = $protoobjs" >> Makefile.settings echo Architecture: $arch case "$arch" in Linux ) ;; GNU/* ) ;; *BSD ) ;; Darwin ) echo 'STRIP=\# skip strip' >> Makefile.settings ;; IRIX ) ;; SunOS ) echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings echo 'STRIP=\# skip strip' >> Makefile.settings echo '#define NO_FD_PASSING' >> config.h ;; AIX ) echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings ;; CYGWIN* ) echo 'Cygwin is not officially supported.' ;; Windows ) ;; * ) echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.' echo 'Please report any problems at http://bugs.bitlbee.org/.' ;; esac if [ -n "$target" ]; then echo "Cross-compiling for: $target" fi echo echo 'Configuration done:' if [ "$debug" = "1" ]; then echo ' Debugging enabled.' else echo ' Debugging disabled.' fi if [ "$strip" = "1" ]; then echo ' Binary stripping enabled.' else echo ' Binary stripping disabled.' 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 if [ -n "$systemdsystemunitdir" ]; then echo ' systemd enabled.' else echo ' systemd disabled.' fi echo ' Using event handler: '$events echo ' Using SSL library: '$ssl #echo ' Building with these storage backends: '$STORAGES if [ -n "$protocols" ]; then echo ' Building with these protocols:' $protocols$protocols_mods case "$protocols" in *purple*) echo " Note that BitlBee-libpurple is supported on a best-effort basis. It's" echo " not *fully* compatible with normal BitlBee. Don't use it unless you" echo " absolutely need it (i.e. support for a certain protocol or feature)." esac else echo ' Building without IM-protocol support. We wish you a lot of fun...' fi