close Warning: Failed to sync with repository "(default)": [Errno 12] Cannot allocate memory; repository information may be out of date. Look in the Trac log for more information including mitigation strategies.

source: configure @ 76c85b4c

Last change on this file since 76c85b4c was 36cf9fd, checked in by Wilmer van der Gaast <wilmer@…>, at 2009-11-12T11:41:54Z

Proper detection of a usable libresolv.so or libresolv.a. glibc 2.9 and
later are no longer retarded and support SRV record lookups without having
to link against a static library.

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