source: configure @ f60079b

Last change on this file since f60079b was f60079b, checked in by Wilmer van der Gaast <wilmer@…>, at 2010-05-25T22:26:54Z

Allow one to run the configure script from a different directory and put all
build files in there. I need this to properly make Debian package variants
(i.e. libpurple and native).

  • Property mode set to 100755
File size: 15.9 KB
Line 
1#!/bin/sh
2
3##############################
4##  Configurer for BitlBee  ##
5##                          ##
6##  Copyright 2004 Lintux   ##
7##  Copyright 2002 Lucumo   ##
8##############################
9
10prefix='/usr/local/'
11bindir='$prefix/sbin/'
12etcdir='$prefix/etc/bitlbee/'
13mandir='$prefix/share/man/'
14datadir='$prefix/share/bitlbee/'
15config='/var/lib/bitlbee/'
16plugindir='$prefix/lib/bitlbee/'
17includedir='$prefix/include/bitlbee/'
18libevent='/usr/'
19pidfile='/var/run/bitlbee.pid'
20ipcsocket='/var/run/bitlbee.sock'
21pcdir='$prefix/lib/pkgconfig'
22systemlibdirs="/lib /lib64 /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64"
23
24msn=1
25jabber=1
26oscar=1
27yahoo=1
28twitter=1
29purple=1
30
31debug=0
32strip=1
33gcov=0
34plugins=1
35
36events=glib
37ldap=0
38ssl=auto
39
40arch=`uname -s`
41cpu=`uname -m`
42
43GLIB_MIN_VERSION=2.4
44
45echo BitlBee configure
46
47while [ -n "$1" ]; do
48        e="`expr "X$1" : 'X--\(.*=.*\)'`"
49        if [ -z "$e" ]; then
50                cat<<EOF
51
52Usage: $0 [OPTIONS]
53
54Option          Description                             Default
55
56--prefix=...    Directories to put files in             $prefix
57--bindir=...                                            $bindir
58--etcdir=...                                            $etcdir
59--mandir=...                                            $mandir
60--datadir=...                                           $datadir
61--plugindir=...                                         $plugindir
62--pidfile=...                                           $pidfile
63--config=...                                            $config
64--ipcsocket=...                                         $ipcsocket
65
66--msn=0/1       Disable/enable MSN part                 $msn
67--jabber=0/1    Disable/enable Jabber part              $jabber
68--oscar=0/1     Disable/enable Oscar part (ICQ, AIM)    $oscar
69--yahoo=0/1     Disable/enable Yahoo part               $yahoo
70--twitter=0/1 Disable/enable Twitter part               $twitter
71
72--purple=0/1    Disable/enable libpurple support        $purple
73
74--debug=0/1     Disable/enable debugging                $debug
75--strip=0/1     Disable/enable binary stripping         $strip
76--gcov=0/1      Disable/enable test coverage reporting  $gcov
77--plugins=0/1   Disable/enable plugins support          $plugins
78
79--events=...    Event handler (glib, libevent)          $events
80--ssl=...       SSL library to use (gnutls, nss, openssl, bogus, auto)
81                                                        $ssl
82
83--target=...    Cross compilation target                same as host
84EOF
85                exit;
86        fi
87        eval "$e"
88        shift;
89done
90
91# Expand $prefix and get rid of double slashes
92bindir=`eval echo "$bindir/" | sed 's/\/\{1,\}/\//g'`
93etcdir=`eval echo "$etcdir/" | sed 's/\/\{1,\}/\//g'`
94mandir=`eval echo "$mandir/" | sed 's/\/\{1,\}/\//g'`
95datadir=`eval echo "$datadir/" | sed 's/\/\{1,\}/\//g'`
96config=`eval echo "$config/" | sed 's/\/\{1,\}/\//g'`
97plugindir=`eval echo "$plugindir/" | sed 's/\/\{1,\}/\//g'`
98includedir=`eval echo "$includedir"/ | sed 's/\/\{1,\}/\//g'`
99libevent=`eval echo "$libevent"/ | sed 's/\/\{1,\}/\//g'`
100
101pidfile=`eval echo "$pidfile" | sed 's/\/\{1,\}/\//g'`
102ipcsocket=`eval echo "$ipcsocket" | sed 's/\/\{1,\}/\//g'`
103pcdir=`eval echo "$pcdir" | sed 's/\/\{1,\}/\//g'`
104
105cat<<EOF>Makefile.settings
106## BitlBee settings, generated by configure
107PREFIX=$prefix
108BINDIR=$bindir
109ETCDIR=$etcdir
110MANDIR=$mandir
111DATADIR=$datadir
112PLUGINDIR=$plugindir
113CONFIG=$config
114INCLUDEDIR=$includedir
115PCDIR=$pcdir
116
117TARGET=$target
118ARCH=$arch
119CPU=$cpu
120
121DESTDIR=
122LFLAGS=
123EFLAGS=
124EOF
125
126srcdir="$(dirname $0)"
127if [ "$srcdir" != "." ]; then
128        echo
129        echo "configure script run from a different directory. Will create some symlinks..."
130        if [ ! -e Makefile -o -L Makefile ]; then
131                mkdir -p $(cd "$srcdir"; find . -type d)
132                find . -name Makefile -type l -print0 | xargs -0 rm 2> /dev/null
133                dst="$PWD"
134                cd "$srcdir"
135                for i in $(find . -name Makefile); do
136                        ln -s "$PWD${i#.}" "$dst/$i";
137                done
138                cd "$dst"
139                rm -rf .bzr
140        fi
141       
142        echo "SRCDIR=$srcdir/" >> Makefile.settings
143        CFLAGS="$CFLAGS -I${dst}"
144else
145        srcdir=$PWD
146fi
147
148cat<<EOF>config.h
149/* BitlBee settings, generated by configure
150   
151   Do *NOT* use any of these defines in your code without thinking twice, most
152   of them can/will be overridden at run-time */
153
154#define CONFIG "$config"
155#define ETCDIR "$etcdir"
156#define VARDIR "$datadir"
157#define PLUGINDIR "$plugindir"
158#define PIDFILE "$pidfile"
159#define IPCSOCKET "$ipcsocket"
160#define ARCH "$arch"
161#define CPU "$cpu"
162EOF
163
164
165
166if [ -n "$target" ]; then
167        PKG_CONFIG_LIBDIR=/usr/$target/lib/pkgconfig
168        export PKG_CONFIG_LIBDIR
169        PATH=/usr/$target/bin:$PATH
170        CC=$target-cc
171        LD=$target-ld
172        systemlibdirs="/usr/$target/lib"
173fi
174
175
176if [ "$debug" = "1" ]; then
177        [ -z "$CFLAGS" ] && CFLAGS=-g
178        echo 'DEBUG=1' >> Makefile.settings
179        CFLAGS="$CFLAGS -DDEBUG"
180else
181        [ -z "$CFLAGS" ] && CFLAGS="-O2 -fno-strict-aliasing"
182fi
183
184echo CFLAGS=$CFLAGS >> Makefile.settings
185echo CFLAGS+=-I${srcdir} -I${srcdir}/lib -I${srcdir}/protocols -I. >> Makefile.settings
186
187echo CFLAGS+=-DHAVE_CONFIG_H >> Makefile.settings
188
189if [ -n "$CC" ]; then
190        CC=$CC
191elif type gcc > /dev/null 2> /dev/null; then
192        CC=gcc
193elif type cc > /dev/null 2> /dev/null; then
194        CC=cc
195else
196        echo 'Cannot find a C compiler, aborting.'
197        exit 1;
198fi
199
200echo "CC=$CC" >> Makefile.settings;
201
202if [ -z "$LD" ]; then
203        if type ld > /dev/null 2> /dev/null; then
204                LD=ld
205        else
206                echo 'Cannot find ld, aborting.'
207                exit 1;
208        fi
209fi
210
211echo "LD=$LD" >> Makefile.settings
212
213if [ -z "$PKG_CONFIG" ]; then
214        PKG_CONFIG=pkg-config
215fi
216
217if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG glib-2.0; then
218        if $PKG_CONFIG glib-2.0 --atleast-version=$GLIB_MIN_VERSION; then
219                cat<<EOF>>Makefile.settings
220EFLAGS+=`$PKG_CONFIG --libs glib-2.0 gmodule-2.0`
221CFLAGS+=`$PKG_CONFIG --cflags glib-2.0 gmodule-2.0`
222EOF
223        else
224                echo
225                echo 'Found glib2 '`$PKG_CONFIG glib-2.0 --modversion`', but version '$GLIB_MIN_VERSION' or newer is required.'
226                exit 1
227        fi
228else
229        echo
230        echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)'
231        exit 1
232fi
233
234if [ "$events" = "libevent" ]; then
235        if ! [ -f "${libevent}include/event.h" ]; then
236                echo
237                echo 'Warning: Could not find event.h, you might have to install it and/or specify'
238                echo 'its location using the --libevent= argument. (Example: If event.h is in'
239                echo '/usr/local/include and binaries are in /usr/local/lib: --libevent=/usr/local)'
240        fi
241       
242        echo '#define EVENTS_LIBEVENT' >> config.h
243        cat <<EOF>>Makefile.settings
244EFLAGS+=-levent -L${libevent}lib
245CFLAGS+=-I${libevent}include
246EOF
247elif [ "$events" = "glib" ]; then
248        ## We already use glib anyway, so this is all we need (and in fact not even this, but just to be sure...):
249        echo '#define EVENTS_GLIB' >> config.h
250else
251        echo
252        echo 'ERROR: Unknown event handler specified.'
253        exit 1
254fi
255echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings
256
257detect_gnutls()
258{
259        if $PKG_CONFIG --exists gnutls; then
260                cat <<EOF>>Makefile.settings
261EFLAGS+=`$PKG_CONFIG --libs gnutls`
262CFLAGS+=`$PKG_CONFIG --cflags gnutls`
263EOF
264                ssl=gnutls
265                ret=1
266        elif libgnutls-config --version > /dev/null 2> /dev/null; then
267                cat <<EOF>>Makefile.settings
268EFLAGS+=`libgnutls-config --libs`
269CFLAGS+=`libgnutls-config --cflags`
270EOF
271               
272                ssl=gnutls
273                ret=1;
274        else
275                ret=0;
276        fi;
277}
278
279detect_nss()
280{
281        if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG mozilla-nss; then
282                cat<<EOF>>Makefile.settings
283EFLAGS+=`$PKG_CONFIG --libs mozilla-nss`
284CFLAGS+=`$PKG_CONFIG --cflags mozilla-nss`
285EOF
286               
287                ssl=nss
288                ret=1;
289        else
290                ret=0;
291        fi;
292}
293
294detect_ldap()
295{
296        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
297        if $CC -o $TMPFILE -shared -lldap 2>/dev/null >/dev/null; then
298                cat<<EOF>>Makefile.settings
299EFLAGS+=-lldap
300CFLAGS+=
301EOF
302                ldap=1
303                rm -f $TMPFILE
304                ret=1
305        else
306                ldap=0
307                ret=0
308        fi
309}
310
311RESOLV_TESTCODE='
312#include <arpa/nameser.h>
313#include <resolv.h>
314
315int main()
316{
317        ns_initparse( NULL, 0, NULL );
318        ns_parserr( NULL, ns_s_an, 0, NULL );
319}
320'
321
322detect_resolv_dynamic()
323{
324        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
325        ret=1
326        echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -lresolv >/dev/null 2>/dev/null
327        if [ "$?" = "0" ]; then
328                echo 'EFLAGS+=-lresolv' >> Makefile.settings
329                ret=0
330        fi
331
332        rm -f $TMPFILE
333        return $ret
334}
335
336detect_resolv_static()
337{
338        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
339        ret=1
340        for i in $systemlibdirs; do
341                if [ -f $i/libresolv.a ]; then
342                        echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null
343                        if [ "$?" = "0" ]; then
344                                echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings
345                                ret=0
346                        fi
347                fi
348        done
349
350        rm -f $TMPFILE
351        return $ret
352}
353
354if [ "$ssl" = "auto" ]; then
355        detect_gnutls
356        if [ "$ret" = "0" ]; then
357                detect_nss
358        fi
359elif [ "$ssl" = "gnutls" ]; then
360        detect_gnutls
361elif [ "$ssl" = "nss" ]; then
362        detect_nss
363elif [ "$ssl" = "sspi" ]; then
364        echo
365elif [ "$ssl" = "openssl" ]; then
366        echo
367        echo 'No detection code exists for OpenSSL. Make sure that you have a complete'
368        echo 'install of OpenSSL (including devel/header files) before reporting'
369        echo 'compilation problems.'
370        echo
371        echo 'Also, keep in mind that the OpenSSL is, according to some people, not'
372        echo 'completely GPL-compatible. Using GnuTLS or NSS is recommended and better'
373        echo 'supported by us. However, on many BSD machines, OpenSSL can be considered'
374        echo 'part of the operating system, which makes it GPL-compatible.'
375        echo
376        echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2'
377        echo '                    http://www.gnome.org/~markmc/openssl-and-the-gpl.html'
378        echo
379        echo 'Please note that distributing a BitlBee binary which links to OpenSSL is'
380        echo 'probably illegal. If you want to create and distribute a binary BitlBee'
381        echo 'package, you really should use GnuTLS or NSS instead.'
382        echo
383        echo 'Also, the OpenSSL license requires us to say this:'
384        echo ' *    "This product includes software developed by the OpenSSL Project'
385        echo ' *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"'
386       
387        echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings
388       
389        ret=1
390elif [ "$ssl" = "bogus" ]; then
391        echo
392        echo 'Using bogus SSL code. This means some features will not work properly.'
393       
394        ## Yes, you, at the console! How can you authenticate if you don't have any SSL!?
395        if [ "$msn" = "1" -o "$yahoo" = "1" ]; then
396                echo
397                echo 'WARNING: The MSN and Yahoo! modules will not work without SSL. Disabling.'
398                msn=0
399                yahoo=0
400        fi
401       
402        ret=1
403else
404        echo
405        echo 'ERROR: Unknown SSL library specified.'
406        exit 1
407fi
408
409if [ "$ret" = "0" ]; then
410        echo
411        echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).'
412        echo '       Please note that this script doesn'\''t have detection code for OpenSSL,'
413        echo '       so if you want to use that, you have to select it by hand. If you don'\''t'
414        echo '       need SSL support, you can select the "bogus" SSL library. (--ssl=bogus)'
415       
416        exit 1
417fi;
418
419echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings
420
421if detect_resolv_dynamic || detect_resolv_static; then
422        echo '#define HAVE_RESOLV_A' >> config.h
423fi
424
425STORAGES="xml"
426
427if [ "$ldap" = "auto" ]; then
428        detect_ldap
429fi
430
431if [ "$ldap" = 0 ]; then
432        echo "#undef WITH_LDAP" >> config.h
433elif [ "$ldap" = 1 ]; then
434        echo
435        echo 'LDAP support is a work in progress and does NOT work AT ALL right now.'
436        echo
437        exit 1
438       
439        echo "#define WITH_LDAP 1" >> config.h
440        STORAGES="$STORAGES ldap"
441fi
442
443for i in $STORAGES; do
444        STORAGE_OBJS="$STORAGE_OBJS storage_$i.o"
445done
446echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings
447
448if [ "$strip" = 0 ]; then
449        echo "STRIP=\# skip strip" >> Makefile.settings;
450else
451        if [ "$debug" = 1 ]; then
452                echo
453                echo 'Stripping binaries does not make sense when debugging. Stripping disabled.'
454                echo 'STRIP=\# skip strip' >> Makefile.settings
455                strip=0;
456        elif [ -n "$STRIP" ]; then
457                echo "STRIP=$STRIP" >> Makefile.settings;
458        elif type strip > /dev/null 2> /dev/null; then
459                echo "STRIP=strip" >> Makefile.settings;
460        else
461                echo
462                echo 'No strip utility found, cannot remove unnecessary parts from executable.'
463                echo 'STRIP=\# skip strip' >> Makefile.settings
464                strip=0;
465        fi;
466fi
467
468if [ "$gcov" = "1" ]; then
469        echo "CFLAGS+=--coverage" >> Makefile.settings
470        echo "EFLAGS+=--coverage" >> Makefile.settings
471fi
472
473if [ "$plugins" = 0 ]; then
474        echo '#undef WITH_PLUGINS' >> config.h
475else
476        echo '#define WITH_PLUGINS' >> config.h
477fi
478
479if [ ! -e doc/user-guide/help.txt ] && ! type xmlto > /dev/null 2> /dev/null; then
480        echo
481        echo 'WARNING: Building from an unreleased source tree without prebuilt helpfile.'
482        echo 'Install xmlto if you want online help to work.'
483fi
484
485echo
486if [ -z "$BITLBEE_VERSION" -a -d .bzr ] && type bzr > /dev/null 2> /dev/null; then
487        nick=`bzr nick`
488        if [ -n "$nick" -a "$nick" != "bitlbee" ]; then
489                nick="-$nick"
490        else
491                nick=""
492        fi
493        rev=`bzr revno`
494        echo 'Using bzr revision #'$rev' as version number'
495        BITLBEE_VERSION=\"bzr$nick-$rev\"
496fi
497
498if [ -n "$BITLBEE_VERSION" ]; then
499        echo 'Spoofing version number: '$BITLBEE_VERSION
500        echo '#undef BITLBEE_VERSION' >> config.h
501        echo '#define BITLBEE_VERSION '$BITLBEE_VERSION >> config.h
502        echo
503fi
504
505if ! make helloworld > /dev/null 2>&1; then
506        echo "WARNING: Your version of make (BSD make?) does not support BitlBee's makefiles."
507        echo "BitlBee needs GNU make to build properly. On most systems GNU make is available"
508        echo "under the name 'gmake'."
509        echo
510        if gmake helloworld > /dev/null 2>&1; then
511                echo "gmake seems to be available on your machine, great."
512                echo
513        else
514                echo "gmake is not installed (or not working). Please try to install it."
515                echo
516        fi
517fi
518
519cat <<EOF>bitlbee.pc
520prefix=$prefix
521includedir=$includedir
522
523Name: bitlbee
524Description: IRC to IM gateway
525Requires: glib-2.0
526Version: $BITLBEE_VERSION
527Libs:
528Cflags: -I\${includedir}
529
530EOF
531
532protocols=''
533protoobjs=''
534
535if [ "$purple" = 0 ]; then
536        echo '#undef WITH_PURPLE' >> config.h
537else
538        if ! $PKG_CONFIG purple; then
539                echo
540                echo 'Cannot find libpurple development libraries, aborting. (Install libpurple-dev?)'
541                exit 1
542        fi
543        echo '#define WITH_PURPLE' >> config.h
544        cat<<EOF>>Makefile.settings
545EFLAGS += $($PKG_CONFIG purple --libs)
546PURPLE_CFLAGS += $($PKG_CONFIG purple --cflags)
547EOF
548        protocols=$protocols'purple '
549        protoobjs=$protoobjs'purple_mod.o '
550
551        # Having both libpurple and native IM modules in one binary may
552        # do strange things. Let's not do that.
553        msn=0
554        jabber=0
555        oscar=0
556        yahoo=0
557        twitter=0
558       
559        if [ "$events" = "libevent" ]; then
560                echo
561                echo 'Warning: Some libpurple modules (including msn-pecan) do their event handling'
562                echo 'outside libpurple, talking to GLib directly. At least for now the combination'
563                echo 'libpurple + libevent is *not* recommended!'
564        fi
565fi
566
567if [ "$msn" = 0 ]; then
568        echo '#undef WITH_MSN' >> config.h
569else
570        echo '#define WITH_MSN' >> config.h
571        protocols=$protocols'msn '
572        protoobjs=$protoobjs'msn_mod.o '
573fi
574
575if [ "$jabber" = 0 ]; then
576        echo '#undef WITH_JABBER' >> config.h
577else
578        echo '#define WITH_JABBER' >> config.h
579        protocols=$protocols'jabber '
580        protoobjs=$protoobjs'jabber_mod.o '
581fi
582
583if [ "$oscar" = 0 ]; then
584        echo '#undef WITH_OSCAR' >> config.h
585else
586        echo '#define WITH_OSCAR' >> config.h
587        protocols=$protocols'oscar '
588        protoobjs=$protoobjs'oscar_mod.o '
589fi
590
591if [ "$yahoo" = 0 ]; then
592        echo '#undef WITH_YAHOO' >> config.h
593else
594        echo '#define WITH_YAHOO' >> config.h
595        protocols=$protocols'yahoo '
596        protoobjs=$protoobjs'yahoo_mod.o '
597fi
598
599if [ "$twitter" = 0 ]; then
600        echo '#undef WITH_TWITTER' >> config.h
601else
602        echo '#define WITH_TWITTER' >> config.h
603        protocols=$protocols'twitter '
604        protoobjs=$protoobjs'twitter_mod.o '
605fi
606
607if [ "$protocols" = "PROTOCOLS = " ]; then
608        echo "Warning: You haven't selected any communication protocol to compile!"
609        echo "         BitlBee will run, but you will be unable to connect to IM servers!"
610fi
611
612echo "PROTOCOLS = $protocols" >> Makefile.settings
613echo "PROTOOBJS = $protoobjs" >> Makefile.settings
614
615echo Architecture: $arch
616case "$arch" in
617Linux )
618;;
619GNU/* )
620;;
621*BSD )
622;;
623Darwin )
624        echo 'STRIP=\# skip strip' >> Makefile.settings
625;;
626IRIX )
627;;
628SunOS )
629        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
630        echo 'STRIP=\# skip strip' >> Makefile.settings
631;;
632AIX )
633        echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings
634;;
635CYGWIN* )
636        echo 'Cygwin is not officially supported.'
637;;
638Windows )
639;;
640* )
641        echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.'
642        echo 'Please report any problems at http://bugs.bitlbee.org/.'
643;;
644esac
645
646if [ -n "$target" ]; then
647        echo "Cross-compiling for: $target"
648fi
649
650echo
651echo 'Configuration done:'
652
653if [ "$debug" = "1" ]; then
654        echo '  Debugging enabled.'
655else
656        echo '  Debugging disabled.'
657fi
658
659if [ "$strip" = "1" ]; then
660        echo '  Binary stripping enabled.'
661else
662        echo '  Binary stripping disabled.'
663fi
664
665echo '  Using event handler: '$events
666echo '  Using SSL library: '$ssl
667echo '  Building with these storage backends: '$STORAGES
668
669if [ -n "$protocols" ]; then
670        echo '  Building with these protocols:' $protocols
671else
672        echo '  Building without IM-protocol support. We wish you a lot of fun...'
673fi
Note: See TracBrowser for help on using the repository browser.