source: configure @ 31fc3970

Last change on this file since 31fc3970 was 31fc3970, checked in by Jelmer Vernooij <jelmer@…>, at 2025-12-27T02:21:03Z

Use simpler flags for gcov.

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