source: configure @ ef53ba8

Last change on this file since ef53ba8 was f712188, checked in by Jelmer Vernooij <jelmer@…>, at 2005-11-28T22:00:51Z

Add HAVE_CONFIG_H define so other platforms can build without config.h

  • Property mode set to 100755
File size: 9.5 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/'
16
17msn=1
18jabber=1
19oscar=1
20yahoo=1
21
22debug=0
23strip=1
24flood=0
25ipv6=1
26ssl=auto
27
28arch=`uname -s`
29cpu=`uname -m`
30
31echo BitlBee configure
32
33while [ -n "$1" ]; do
34        e="`expr "X$1" : 'X--\(.*=.*\)'`"
35        if [ -z "$e" ]; then
36                cat<<EOF
37
38Usage: $0 [OPTIONS]
39
40Option          Description                             Default
41
42--prefix=...    Directories to put files in             $prefix
43--bindir=...                                            $bindir
44--etcdir=...                                            $etcdir
45--mandir=...                                            $mandir
46--datadir=...                                           $datadir
47--config=...                                            $config
48
49--msn=0/1       Disable/enable MSN part                 $msn
50--jabber=0/1    Disable/enable Jabber part              $jabber
51--oscar=0/1     Disable/enable Oscar part (ICQ, AIM)    $oscar
52--yahoo=0/1     Disable/enable Yahoo part               $yahoo
53
54--debug=0/1     Disable/enable debugging                $debug
55--strip=0/1     Disable/enable binary stripping         $strip
56
57--flood=0/1     Flood protection                        $flood
58--ipv6=0/1      IPv6 socket support                     $ipv6
59
60--ssl=...       SSL library to use (gnutls, nss, openssl, bogus, auto)
61                                                        $ssl
62EOF
63                exit;
64        fi
65        eval "$e"
66        shift;
67done
68
69# Expand $prefix and get rid of double slashes
70bindir=`eval echo "$bindir/" | sed 's/\/\{1,\}/\//g'`
71etcdir=`eval echo "$etcdir/" | sed 's/\/\{1,\}/\//g'`
72mandir=`eval echo "$mandir/" | sed 's/\/\{1,\}/\//g'`
73datadir=`eval echo "$datadir/" | sed 's/\/\{1,\}/\//g'`
74config=`eval echo "$config/" | sed 's/\/\{1,\}/\//g'`
75
76cat<<EOF>Makefile.settings
77## BitlBee settings, generated by configure
78PREFIX=$prefix
79BINDIR=$bindir
80ETCDIR=$etcdir
81MANDIR=$mandir
82DATADIR=$datadir
83CONFIG=$config
84
85ARCH=$arch
86CPU=$cpu
87OUTFILE=bitlbee
88
89DESTDIR=
90LFLAGS=
91EFLAGS=
92EOF
93
94cat<<EOF>config.h
95/* BitlBee settings, generated by configure
96   
97   Do *NOT* use any of these defines in your code without thinking twice, most
98   of them can/will be overridden at run-time */
99
100#define CONFIG "$config"
101#define ETCDIR "$etcdir"
102#define VARDIR "$datadir"
103#define ARCH "$arch"
104#define CPU "$cpu"
105EOF
106
107if [ "$ipv6" = "1" ]; then
108        echo '#define IPV6' >> config.h
109fi
110
111if [ "$debug" = "1" ]; then
112        echo 'CFLAGS=-g' >> Makefile.settings
113        echo 'DEBUG=1' >> Makefile.settings
114        echo '#define DEBUG' >> config.h
115else
116        echo 'CFLAGS=-O3' >> Makefile.settings
117fi
118
119echo CFLAGS+=-I`pwd` -I`pwd`/protocols -I. >> Makefile.settings
120
121echo CFLAGS+=-DHAVE_CONFIG_H >> Makefile.settings
122
123if [ -n "$CC" ]; then
124        echo "CC=$CC" >> Makefile.settings;
125elif type gcc > /dev/null 2> /dev/null; then
126        echo "CC=gcc" >> Makefile.settings;
127elif type cc > /dev/null 2> /dev/null; then
128        echo "CC=cc" >> Makefile.settings;
129else
130        echo 'Cannot find a C compiler, aborting.'
131        exit 1;
132fi
133
134if [ -n "$LD" ]; then
135        echo "LD=$LD" >> Makefile.settings;
136elif type ld > /dev/null 2> /dev/null; then
137        echo "LD=ld" >> Makefile.settings;
138else
139        echo 'Cannot find ld, aborting.'
140        exit 1;
141fi
142
143if type pkg-config > /dev/null 2>/dev/null && pkg-config glib-2.0; then
144        cat<<EOF>>Makefile.settings
145EFLAGS+=`pkg-config --libs glib-2.0`
146CFLAGS+=`pkg-config --cflags glib-2.0`
147EOF
148        echo '#define GLIB2' >> config.h
149elif type glib-config > /dev/null 2> /dev/null; then
150        cat<<EOF>>Makefile.settings
151EFLAGS+=`glib-config --libs`
152CFLAGS+=`glib-config --cflags`
153EOF
154        echo '#define GLIB1' >> config.h
155else
156        echo 'Cannot find glib development libraries, aborting. (Install libglib-dev?)'
157        exit 1;
158fi
159
160if [ -r /usr/include/iconv.h ]; then
161        :;
162elif [ -r /usr/local/include/iconv.h ]; then
163        echo CFLAGS+=-I/usr/local/include >> Makefile.settings;
164else
165        echo
166        echo 'Warning: Could not find iconv.h, you might have to install it and/or modify'
167        echo 'Makefile.settings to tell where this file is.';
168fi
169
170
171detect_gnutls()
172{
173        if libgnutls-config --version > /dev/null 2> /dev/null; then
174                cat <<EOF>>Makefile.settings
175EFLAGS+=`libgnutls-config --libs`
176CFLAGS+=`libgnutls-config --cflags`
177EOF
178               
179                ssl=gnutls
180                ret=1;
181        else
182                ret=0;
183        fi;
184}
185
186detect_nss()
187{
188        if type pkg-config > /dev/null 2>/dev/null && pkg-config mozilla-nss; then
189                cat<<EOF>>Makefile.settings
190EFLAGS+=`pkg-config --libs mozilla-nss`
191CFLAGS+=`pkg-config --cflags mozilla-nss`
192EOF
193               
194                ssl=nss
195                ret=1;
196        else
197                ret=0;
198        fi;
199}
200
201if [ "$msn" = 1 -o "$jabber" = 1 ]; then
202        if [ "$ssl" = "auto" ]; then
203                detect_gnutls
204                if [ "$ret" = "0" ]; then
205                        detect_nss
206                fi;
207        elif [ "$ssl" = "gnutls" ]; then
208                detect_gnutls;
209        elif [ "$ssl" = "nss" ]; then
210                detect_nss;
211        elif [ "$ssl" = "openssl" ]; then
212                echo
213                echo 'No detection code exists for OpenSSL. Make sure that you have a complete'
214                echo 'install of OpenSSL (including devel/header files) before reporting'
215                echo 'compilation problems.'
216                echo
217                echo 'Also, keep in mind that the OpenSSL is, according to some people, not'
218                echo 'completely GPL-compatible. Using GnuTLS or NSS is recommended and better'
219                echo 'supported by us. However, on many BSD machines, OpenSSL can be considered'
220                echo 'part of the operating system, which makes it GPL-compatible.'
221                echo
222                echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2'
223                echo '                    http://www.gnome.org/~markmc/openssl-and-the-gpl.html'
224                echo
225                echo 'Please note that distributing a BitlBee binary which links to OpenSSL is'
226                echo 'probably illegal. If you want to create and distribute a binary BitlBee'
227                echo 'package, you really should use GnuTLS or NSS instead.'
228                echo
229                echo 'Also, the OpenSSL license requires us to say this:'
230                echo ' *    "This product includes software developed by the OpenSSL Project'
231                echo ' *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"'
232               
233                echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings
234               
235                ret=1;
236        elif [ "$ssl" = "bogus" ]; then
237                echo
238                echo 'Using bogus SSL code. This will not make the MSN module work, but it will'
239                echo 'allow you to use the Jabber module - although without working SSL support.'
240               
241                ret=1;
242        else
243                echo
244                echo 'ERROR: Unknown SSL library specified.'
245                exit 1;
246        fi
247       
248        if [ "$ret" = "0" ]; then
249                echo
250                echo 'WARNING: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).'
251                echo '         This is necessary for MSN and full Jabber support. To continue,'
252                echo '         install a suitable SSL library or disable MSN support (--msn=0).'
253                echo '         If you want Jabber without SSL support you can try --ssl=bogus.'
254               
255                exit 1;
256        fi;
257       
258        echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings
259fi
260
261if [ "$strip" = 0 ]; then
262        echo "STRIP=\# skip strip" >> Makefile.settings;
263else
264        if [ "$debug" = 1 ]; then
265                echo
266                echo 'Stripping binaries does not make sense when debugging. Stripping disabled.'
267                echo 'STRIP=\# skip strip' >> Makefile.settings
268                strip=0;
269        elif [ -n "$STRIP" ]; then
270                echo "STRIP=$STRIP" >> Makefile.settings;
271        elif type strip > /dev/null 2> /dev/null; then
272                echo "STRIP=strip" >> Makefile.settings;
273        elif /bin/test -x /usr/ccs/bin/strip; then
274                echo "STRIP=/usr/ccs/bin/strip" >> Makefile.settings;
275        else
276                echo
277                echo 'No strip utility found, cannot remove unnecessary parts from executable.'
278                echo 'STRIP=\# skip strip' >> Makefile.settings
279                strip=0;
280        fi;
281fi
282
283if [ "$flood" = 1 ]; then
284        echo '#define FLOOD_SEND' >> config.h
285fi
286
287if [ -n "$BITLBEE_VERSION" ]; then
288        echo
289        echo 'Spoofing version number: '$BITLBEE_VERSION
290        echo '#undef BITLBEE_VERSION' >> config.h
291        echo '#define BITLBEE_VERSION '$BITLBEE_VERSION >> config.h;
292fi
293
294protocols=''
295protoobjs=''
296
297if [ "$msn" = 0 ]; then
298        echo '#undef WITH_MSN' >> config.h
299else
300        echo '#define WITH_MSN' >> config.h
301        protocols=$protocols'msn '
302        protoobjs=$protoobjs'msnn.o '
303fi
304
305if [ "$jabber" = 0 ]; then
306        echo '#undef WITH_JABBER' >> config.h
307else
308        echo '#define WITH_JABBER' >> config.h
309        protocols=$protocols'jabber '
310        protoobjs=$protoobjs'jabberr.o '
311fi
312
313if [ "$oscar" = 0 ]; then
314        echo '#undef WITH_OSCAR' >> config.h
315else
316        echo '#define WITH_OSCAR' >> config.h
317        protocols=$protocols'oscar '
318        protoobjs=$protoobjs'oscarr.o '
319fi
320
321if [ "$yahoo" = 0 ]; then
322        echo '#undef WITH_YAHOO' >> config.h
323else
324        echo '#define WITH_YAHOO' >> config.h
325        protocols=$protocols'yahoo '
326        protoobjs=$protoobjs'yahooo.o '
327fi
328
329if [ "$protocols" = "PROTOCOLS = " ]; then
330        echo
331        echo "WARNING: You haven't selected any communication protocol to compile!"
332        echo "         Bitlbee will run, but you will be unable to connect to IM servers!"
333fi
334
335echo "PROTOCOLS = $protocols" >> Makefile.settings
336echo "PROTOOBJS = $protoobjs" >> Makefile.settings
337
338echo
339echo Architecture: $arch
340case "$arch" in
341Linux )
342        echo 'Linux.'
343;;
344GNU/* )
345        echo 'Debian with non-Linux kernel?'
346;;
347*BSD )
348        echo '*BSD.'
349        echo 'EFLAGS+=-liconv' >> Makefile.settings;
350;;
351SunOS )
352        echo 'Solaris.'
353        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
354        echo 'STRIP=\# skip strip' >> Makefile.settings
355        echo 'EFLAGS+=-liconv' >> Makefile.settings;
356;;
357Darwin )
358        echo 'Darwin/Mac OS X.'
359        echo 'EFLAGS+=-liconv' >> Makefile.settings;
360;;
361IRIX )
362        echo 'IRIX.'
363;;
364CYGWIN* )
365        echo 'Cygwin is not officially supported.'
366;;
367* )
368        echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV. Please report any problems to <wilmer@gaast.net>.'
369;;
370esac
371
372echo
373echo 'Configuration done:'
374
375if [ "$debug" = "1" ]; then
376        echo '  Debugging enabled.';
377else
378        echo '  Debugging disabled.';
379fi
380
381if [ "$strip" = "1" ]; then
382        echo '  Binary stripping enabled.';
383else
384        echo '  Binary stripping disabled.';
385fi
386
387if [ "$msn" = "1" ]; then
388        echo '  Using SSL library: '$ssl;
389fi
390
391if [ "$flood" = "0" ]; then
392        echo '  Flood protection disabled.';
393else
394        echo '  Flood protection enabled.';
395fi
396
397if [ -n "$protocols" ]; then
398        echo '  Building with these protocols:' $protocols;
399else
400        echo '  Building without IM-protocol support. We wish you a lot of fun...';
401fi
Note: See TracBrowser for help on using the repository browser.