[b7d3cc34] | 1 | #!/bin/sh |
---|
| 2 | |
---|
| 3 | ############################## |
---|
| 4 | ## Configurer for BitlBee ## |
---|
| 5 | ## ## |
---|
| 6 | ## Copyright 2004 Lintux ## |
---|
| 7 | ## Copyright 2002 Lucumo ## |
---|
| 8 | ############################## |
---|
| 9 | |
---|
[59c9fa4d] | 10 | prefix='/usr/local/' |
---|
| 11 | bindir='$prefix/bin/' |
---|
| 12 | sbindir='$prefix/sbin/' |
---|
| 13 | etcdir='$prefix/etc/bitlbee/' |
---|
| 14 | mandir='$prefix/share/man/' |
---|
| 15 | datadir='$prefix/share/bitlbee/' |
---|
| 16 | config='/var/lib/bitlbee/' |
---|
| 17 | libdir='$prefix/lib/' |
---|
| 18 | plugindir='$prefix/lib/bitlbee/' |
---|
| 19 | includedir='$prefix/include/bitlbee/' |
---|
| 20 | systemdsystemunitdir='' |
---|
| 21 | sysusersdir='' |
---|
| 22 | libevent='/usr/' |
---|
| 23 | pidfile='/var/run/bitlbee.pid' |
---|
| 24 | ipcsocket='' |
---|
| 25 | pcdir='$prefix/lib/pkgconfig' |
---|
[25b80e9c] | 26 | systemlibdirs="/lib64 /usr/lib64 /usr/local/lib64 /lib /usr/lib /usr/local/lib" |
---|
[59c9fa4d] | 27 | sysroot='' |
---|
[b7d3cc34] | 28 | |
---|
[59c9fa4d] | 29 | configure_args="$@" |
---|
[2f8e3ca] | 30 | |
---|
[04e2a05] | 31 | # Set these to default-on to let it be overriden by either the user or purple |
---|
| 32 | # |
---|
| 33 | # If the user sets one of these to 1, purple won't disable them. |
---|
| 34 | # Otherwise, if it's still default-on, it gets included in normal builds, |
---|
| 35 | # but not purple ones. |
---|
| 36 | jabber="default-on" |
---|
| 37 | |
---|
[1b221e0] | 38 | twitter=1 |
---|
[04dc563] | 39 | purple=0 |
---|
[b7d3cc34] | 40 | |
---|
[65d0dfd] | 41 | verbose=0 |
---|
[a85a8ab] | 42 | doc=1 |
---|
[b7d3cc34] | 43 | debug=0 |
---|
[2a1c27f] | 44 | strip=0 |
---|
[66b9e86e] | 45 | gcov=0 |
---|
[e2472dd] | 46 | asan=0 |
---|
[2abfbc5] | 47 | plugins=1 |
---|
[04f0c10] | 48 | otr=0 |
---|
[85cf37f] | 49 | |
---|
| 50 | events=glib |
---|
[da0202a] | 51 | external_json_parser=auto |
---|
[b7d3cc34] | 52 | ssl=auto |
---|
| 53 | |
---|
[a6005da] | 54 | pam=0 |
---|
[50bb490] | 55 | ldap=0 |
---|
[a6005da] | 56 | |
---|
[7281ad1] | 57 | pie=1 |
---|
| 58 | |
---|
[8ca172f] | 59 | systemd=auto |
---|
| 60 | |
---|
[21f450c] | 61 | arch=$(uname -s) |
---|
[0d753ff] | 62 | arch_rel=$(uname -r) |
---|
[21f450c] | 63 | |
---|
[3a547ee] | 64 | GLIB_MIN_VERSION=2.32 |
---|
[670204f] | 65 | |
---|
[0d753ff] | 66 | # Cygwin, Darwin and SunOS < 5.11 do not support PIC/PIE |
---|
[25c4c78] | 67 | case "$arch" in |
---|
[a85a8ab] | 68 | CYGWIN* ) |
---|
| 69 | pie=0;; |
---|
| 70 | Darwin ) |
---|
| 71 | pie=0;; |
---|
[0d753ff] | 72 | SunOS ) |
---|
| 73 | if [ "$arch_rel" = "5.10" ]; then |
---|
[cc0ad0a] | 74 | pie=0 |
---|
[0d753ff] | 75 | fi |
---|
[cc0ad0a] | 76 | ;; |
---|
[25c4c78] | 77 | esac |
---|
| 78 | |
---|
[70ec7ab] | 79 | get_version() { |
---|
[59c9fa4d] | 80 | REAL_BITLBEE_VERSION=$(grep '^#define BITLBEE_VERSION ' $srcdir/bitlbee.h | sed 's/.*\"\(.*\)\".*/\1/') |
---|
[041777e] | 81 | |
---|
| 82 | if [ -n "$BITLBEE_VERSION" ]; then |
---|
| 83 | # environment variable already set to something to spoof it |
---|
| 84 | # don't replace it with the git stuff |
---|
| 85 | return |
---|
| 86 | fi |
---|
| 87 | |
---|
[70ec7ab] | 88 | BITLBEE_VERSION=$REAL_BITLBEE_VERSION |
---|
| 89 | |
---|
[59c9fa4d] | 90 | if [ -d $srcdir/.git ] && type git > /dev/null 2> /dev/null; then |
---|
| 91 | timestamp=$(cd $srcdir; git show -s --format=%ci HEAD | sed 's/ .*$//; s/-//g') |
---|
| 92 | branch=$(cd $srcdir; git rev-parse --abbrev-ref HEAD) |
---|
[70ec7ab] | 93 | |
---|
[1d8cbc9] | 94 | search='\(.*\)-\([0-9]*\)-\(g[0-9a-f]*\)' |
---|
[70ec7ab] | 95 | replace="\1+$timestamp+$branch+\2-\3-git" |
---|
| 96 | |
---|
[59c9fa4d] | 97 | describe=$(cd $srcdir; git describe --long --tags 2>/dev/null) |
---|
| 98 | if [ $? -ne 0 ]; then |
---|
| 99 | describe=${REAL_BITLBEE_VERSION}-0-g$(cd $srcdir; git rev-parse --short HEAD) |
---|
[e28c449] | 100 | fi |
---|
[70ec7ab] | 101 | |
---|
[59c9fa4d] | 102 | BITLBEE_VERSION=$(echo $describe | sed "s#$search#$replace#") |
---|
[e28c449] | 103 | |
---|
| 104 | unset timestamp branch search replace describe |
---|
[70ec7ab] | 105 | fi |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | if [ "$1" = "--dump-version" ]; then |
---|
[59c9fa4d] | 109 | srcdir=$(cd $(dirname $0);pwd) |
---|
[70ec7ab] | 110 | get_version |
---|
[59c9fa4d] | 111 | echo $BITLBEE_VERSION |
---|
[70ec7ab] | 112 | exit |
---|
| 113 | fi |
---|
| 114 | |
---|
| 115 | echo BitlBee configure |
---|
| 116 | |
---|
[b7d3cc34] | 117 | while [ -n "$1" ]; do |
---|
[4966712a] | 118 | e="$(expr "X$1" : 'X--\(.*=.*\)')" |
---|
[b7d3cc34] | 119 | if [ -z "$e" ]; then |
---|
| 120 | cat<<EOF |
---|
| 121 | |
---|
| 122 | Usage: $0 [OPTIONS] |
---|
| 123 | |
---|
| 124 | Option Description Default |
---|
| 125 | |
---|
| 126 | --prefix=... Directories to put files in $prefix |
---|
| 127 | --bindir=... $bindir |
---|
[57da960] | 128 | --sbindir=... $sbindir |
---|
[b7d3cc34] | 129 | --etcdir=... $etcdir |
---|
| 130 | --mandir=... $mandir |
---|
| 131 | --datadir=... $datadir |
---|
[7b23afd] | 132 | --plugindir=... $plugindir |
---|
[417002e] | 133 | --systemdsystemunitdir=... $systemdsystemunitdir |
---|
[50d0a72] | 134 | --sysusersdir=... $sysusersdir |
---|
[34b17d9] | 135 | --pidfile=... $pidfile |
---|
[b7d3cc34] | 136 | --config=... $config |
---|
| 137 | |
---|
[65d0dfd] | 138 | --verbose=0/1 Disable/enable verbose build $verbose |
---|
| 139 | |
---|
[b7d3cc34] | 140 | --jabber=0/1 Disable/enable Jabber part $jabber |
---|
[4aa0f6b] | 141 | --twitter=0/1 Disable/enable Twitter part $twitter |
---|
[b7d3cc34] | 142 | |
---|
[796da03] | 143 | --purple=0/1 Disable/enable libpurple support $purple |
---|
[04f0c10] | 144 | (automatically disables other protocol modules) |
---|
[b7d3cc34] | 145 | |
---|
[a6005da] | 146 | --pam=0/1 Disable/enable PAM authentication $pam |
---|
[50bb490] | 147 | --ldap=0/1 Disable/enable LDAP authentication $ldap |
---|
[a6005da] | 148 | |
---|
[a85a8ab] | 149 | --doc=0/1 Disable/enable help.txt generation $doc |
---|
[b7d3cc34] | 150 | --debug=0/1 Disable/enable debugging $debug |
---|
| 151 | --strip=0/1 Disable/enable binary stripping $strip |
---|
[7281ad1] | 152 | --pie=0/1 Build position independent executable $pie |
---|
[66b9e86e] | 153 | --gcov=0/1 Disable/enable test coverage reporting $gcov |
---|
[e2472dd] | 154 | --asan=0/1 Disable/enable AddressSanitizer $asan |
---|
[2abfbc5] | 155 | --plugins=0/1 Disable/enable plugins support $plugins |
---|
[04f0c10] | 156 | --otr=0/1/auto/plugin |
---|
| 157 | Disable/enable OTR encryption support $otr |
---|
[b7d3cc34] | 158 | |
---|
[85cf37f] | 159 | --events=... Event handler (glib, libevent) $events |
---|
[e1d3f98] | 160 | --ssl=... SSL library to use (gnutls, nss, openssl, auto) |
---|
[b7d3cc34] | 161 | $ssl |
---|
[da0202a] | 162 | --external_json_parser=0/1/auto Use External JSON parser $external_json_parser |
---|
[bea6db0] | 163 | --systemd=0/1 Enable/disable systemd $systemd |
---|
[aec56b0] | 164 | |
---|
[7281ad1] | 165 | |
---|
[f1e7407] | 166 | --target=... Cross compilation target same as host |
---|
[f5bbaba] | 167 | --sysroot=... Cross compilation sysroot $sysroot |
---|
[b7d3cc34] | 168 | EOF |
---|
| 169 | exit; |
---|
| 170 | fi |
---|
| 171 | eval "$e" |
---|
| 172 | shift; |
---|
| 173 | done |
---|
| 174 | |
---|
| 175 | # Expand $prefix and get rid of double slashes |
---|
[4966712a] | 176 | bindir=$(eval echo "$bindir/" | sed 's/\/\{1,\}/\//g') |
---|
| 177 | sbindir=$(eval echo "$sbindir/" | sed 's/\/\{1,\}/\//g') |
---|
| 178 | etcdir=$(eval echo "$etcdir/" | sed 's/\/\{1,\}/\//g') |
---|
| 179 | mandir=$(eval echo "$mandir/" | sed 's/\/\{1,\}/\//g') |
---|
| 180 | datadir=$(eval echo "$datadir/" | sed 's/\/\{1,\}/\//g') |
---|
| 181 | config=$(eval echo "$config/" | sed 's/\/\{1,\}/\//g') |
---|
[54b2a36] | 182 | libdir=$(eval echo "$libdir/" | sed 's/\/\{1,\}/\//g') |
---|
[4966712a] | 183 | plugindir=$(eval echo "$plugindir/" | sed 's/\/\{1,\}/\//g') |
---|
| 184 | includedir=$(eval echo "$includedir"/ | sed 's/\/\{1,\}/\//g') |
---|
| 185 | libevent=$(eval echo "$libevent"/ | sed 's/\/\{1,\}/\//g') |
---|
| 186 | |
---|
| 187 | pidfile=$(eval echo "$pidfile" | sed 's/\/\{1,\}/\//g') |
---|
| 188 | ipcsocket=$(eval echo "$ipcsocket" | sed 's/\/\{1,\}/\//g') |
---|
| 189 | pcdir=$(eval echo "$pcdir" | sed 's/\/\{1,\}/\//g') |
---|
[b7d3cc34] | 190 | |
---|
[17f6079] | 191 | protocols_mods="" |
---|
| 192 | |
---|
[b95b0c8] | 193 | cat <<EOF >Makefile.settings |
---|
[b7d3cc34] | 194 | ## BitlBee settings, generated by configure |
---|
[2f8e3ca] | 195 | |
---|
| 196 | # ./configure $configure_args |
---|
| 197 | |
---|
[b7d3cc34] | 198 | PREFIX=$prefix |
---|
| 199 | BINDIR=$bindir |
---|
[57da960] | 200 | SBINDIR=$sbindir |
---|
[b7d3cc34] | 201 | ETCDIR=$etcdir |
---|
| 202 | MANDIR=$mandir |
---|
| 203 | DATADIR=$datadir |
---|
[7b23afd] | 204 | PLUGINDIR=$plugindir |
---|
[b7d3cc34] | 205 | CONFIG=$config |
---|
[54b2a36] | 206 | LIBDIR=$libdir |
---|
[e506d6c] | 207 | INCLUDEDIR=$includedir |
---|
| 208 | PCDIR=$pcdir |
---|
[b7d3cc34] | 209 | |
---|
[1bf9492] | 210 | TARGET=$target |
---|
[b7d3cc34] | 211 | |
---|
[25b80e9c] | 212 | INSTALL=install -p |
---|
| 213 | |
---|
[b7d3cc34] | 214 | DESTDIR= |
---|
| 215 | LFLAGS= |
---|
[7a80925] | 216 | EFLAGS=-lm |
---|
[b7d3cc34] | 217 | EOF |
---|
| 218 | |
---|
[59c9fa4d] | 219 | srcdir=$(cd $(dirname $0);pwd) |
---|
[1074806] | 220 | currdir=$(pwd) |
---|
[59c9fa4d] | 221 | if [ "$srcdir" != "$currdir" ]; then |
---|
[f60079b] | 222 | echo |
---|
| 223 | echo "configure script run from a different directory. Will create some symlinks..." |
---|
[59c9fa4d] | 224 | if [ ! -e Makefile -o -L Makefile ]; then |
---|
[04dc563] | 225 | COPYDIRS="doc lib protocols tests utils" |
---|
[59c9fa4d] | 226 | mkdir -p $(cd "$srcdir"; find $COPYDIRS -type d) |
---|
[f60079b] | 227 | find . -name Makefile -type l -print0 | xargs -0 rm 2> /dev/null |
---|
| 228 | dst="$PWD" |
---|
[59c9fa4d] | 229 | cd "$srcdir" |
---|
| 230 | for i in $(find . -name Makefile -type f); do |
---|
[f60079b] | 231 | ln -s "$PWD${i#.}" "$dst/$i"; |
---|
| 232 | done |
---|
[59c9fa4d] | 233 | cd "$dst" |
---|
[f60079b] | 234 | rm -rf .bzr |
---|
| 235 | fi |
---|
| 236 | |
---|
[7fa5c19] | 237 | echo "_SRCDIR_=$srcdir/" >> Makefile.settings |
---|
[f60079b] | 238 | CFLAGS="$CFLAGS -I${dst}" |
---|
| 239 | else |
---|
| 240 | srcdir=$PWD |
---|
| 241 | fi |
---|
| 242 | |
---|
[b95b0c8] | 243 | cat<<EOF >config.h |
---|
[b7d3cc34] | 244 | /* BitlBee settings, generated by configure |
---|
| 245 | |
---|
| 246 | Do *NOT* use any of these defines in your code without thinking twice, most |
---|
| 247 | of them can/will be overridden at run-time */ |
---|
| 248 | |
---|
[2f8e3ca] | 249 | #define BITLBEE_CONFIGURE_ARGS "$configure_args" |
---|
| 250 | |
---|
[b7d3cc34] | 251 | #define CONFIG "$config" |
---|
| 252 | #define ETCDIR "$etcdir" |
---|
| 253 | #define VARDIR "$datadir" |
---|
[7b23afd] | 254 | #define PLUGINDIR "$plugindir" |
---|
[ad66dcd] | 255 | #define DATADIR "$datadir" |
---|
[34b17d9] | 256 | #define PIDFILE "$pidfile" |
---|
[6dff9d4] | 257 | #define IPCSOCKET "$ipcsocket" |
---|
[b7d3cc34] | 258 | EOF |
---|
| 259 | |
---|
[1bf9492] | 260 | |
---|
| 261 | |
---|
[f1e7407] | 262 | if [ -n "$target" ]; then |
---|
[f5bbaba] | 263 | # prepend sysroot to system lib dirs |
---|
| 264 | |
---|
| 265 | systemlibdirs_cross='' |
---|
| 266 | for i in $systemlibdirs; do |
---|
| 267 | systemlibdirs_cross="$systemlibdirs_cross $sysroot$i" |
---|
| 268 | done |
---|
| 269 | systemlibdirs=$systemlibdirs_cross |
---|
| 270 | unset systemlibdirs_cross |
---|
| 271 | |
---|
| 272 | # backward compatibility |
---|
| 273 | |
---|
| 274 | if [ -z "$PKG_CONFIG_LIBDIR" ]; then |
---|
[59c9fa4d] | 275 | PKG_CONFIG_LIBDIR=/usr/$target/lib/pkgconfig |
---|
[f5bbaba] | 276 | export PKG_CONFIG_LIBDIR |
---|
| 277 | fi |
---|
| 278 | |
---|
[59c9fa4d] | 279 | if [ -d /usr/$target/bin ]; then |
---|
| 280 | PATH=/usr/$target/bin:$PATH |
---|
[f5bbaba] | 281 | fi |
---|
| 282 | |
---|
[59c9fa4d] | 283 | if [ -d /usr/$target/lib ]; then |
---|
[f5bbaba] | 284 | systemlibdirs="$systemlibdirs /usr/$target/lib" |
---|
| 285 | fi |
---|
| 286 | |
---|
[f1e7407] | 287 | CC=$target-cc |
---|
| 288 | LD=$target-ld |
---|
[f5bbaba] | 289 | STRIP=$target-strip |
---|
[f1e7407] | 290 | fi |
---|
| 291 | |
---|
[e2472dd] | 292 | if [ "$asan" = "1" ]; then |
---|
| 293 | CFLAGS="$CFLAGS -fsanitize=address" |
---|
| 294 | LDFLAGS="$LDFLAGS -fsanitize=address" |
---|
| 295 | debug=1 |
---|
| 296 | fi |
---|
[1bf9492] | 297 | |
---|
[65d0dfd] | 298 | if [ "$verbose" = "0" ]; then |
---|
| 299 | echo 'VERBOSE=@' >> Makefile.settings |
---|
| 300 | else |
---|
| 301 | echo 'VERBOSE=' >> Makefile.settings |
---|
| 302 | fi |
---|
| 303 | |
---|
[08b0ed8] | 304 | cat <<EOF >>Makefile.settings |
---|
| 305 | |
---|
| 306 | # Enable/disable output verbosity |
---|
| 307 | ifdef V |
---|
| 308 | ifeq (\$(V),1) |
---|
| 309 | VERBOSE= |
---|
| 310 | else |
---|
| 311 | VERBOSE=@ |
---|
| 312 | endif |
---|
| 313 | endif |
---|
| 314 | |
---|
| 315 | EOF |
---|
| 316 | |
---|
[b7d3cc34] | 317 | if [ "$debug" = "1" ]; then |
---|
| 318 | echo 'DEBUG=1' >> Makefile.settings |
---|
[e2472dd] | 319 | CFLAGS="$CFLAGS -g3 -DDEBUG -O0" |
---|
[b7d3cc34] | 320 | else |
---|
[e9eee04] | 321 | [ -z "$CFLAGS" ] && CFLAGS="-g -O2" |
---|
[b7d3cc34] | 322 | fi |
---|
| 323 | |
---|
[7281ad1] | 324 | if [ "$pie" = "1" ]; then |
---|
| 325 | echo 'CFLAGS_BITLBEE=-fPIE' >> Makefile.settings |
---|
| 326 | echo 'LDFLAGS_BITLBEE=-pie' >> Makefile.settings |
---|
| 327 | fi |
---|
| 328 | |
---|
[59c9fa4d] | 329 | echo LDFLAGS=$LDFLAGS >> Makefile.settings |
---|
[d203495] | 330 | |
---|
[59c9fa4d] | 331 | echo CFLAGS=$CFLAGS $CPPFLAGS >> Makefile.settings |
---|
| 332 | echo CFLAGS+=-I${srcdir} -I${srcdir}/lib -I${srcdir}/protocols -I. >> Makefile.settings |
---|
[b7d3cc34] | 333 | |
---|
[41a94dd] | 334 | echo CFLAGS+=-DHAVE_CONFIG_H -D_GNU_SOURCE >> Makefile.settings |
---|
[f712188] | 335 | |
---|
[59c9fa4d] | 336 | if [ -n "$CC" ]; then |
---|
| 337 | CC=$CC |
---|
| 338 | elif type gcc > /dev/null 2> /dev/null; then |
---|
[5973412] | 339 | CC=gcc |
---|
[b7d3cc34] | 340 | elif type cc > /dev/null 2> /dev/null; then |
---|
[5973412] | 341 | CC=cc |
---|
[b7d3cc34] | 342 | else |
---|
| 343 | echo 'Cannot find a C compiler, aborting.' |
---|
| 344 | exit 1; |
---|
| 345 | fi |
---|
| 346 | |
---|
[5973412] | 347 | echo "CC=$CC" >> Makefile.settings; |
---|
[1de945b] | 348 | if echo $CC | grep -qw 'gcc\|clang'; then |
---|
[daae10f] | 349 | # Apparently -Wall is gcc-specific? |
---|
[1de945b] | 350 | echo CFLAGS+=-Wall -Wformat -Werror=format-security >> Makefile.settings |
---|
[daae10f] | 351 | fi |
---|
[5973412] | 352 | |
---|
[f1e7407] | 353 | if [ -z "$LD" ]; then |
---|
| 354 | if type ld > /dev/null 2> /dev/null; then |
---|
| 355 | LD=ld |
---|
| 356 | else |
---|
| 357 | echo 'Cannot find ld, aborting.' |
---|
| 358 | exit 1; |
---|
| 359 | fi |
---|
[b7d3cc34] | 360 | fi |
---|
| 361 | |
---|
[f1e7407] | 362 | echo "LD=$LD" >> Makefile.settings |
---|
| 363 | |
---|
[32c632f] | 364 | if [ -z "$PKG_CONFIG" ]; then |
---|
| 365 | PKG_CONFIG=pkg-config |
---|
| 366 | fi |
---|
| 367 | |
---|
[9ae8f82] | 368 | if ! $PKG_CONFIG --version > /dev/null 2>/dev/null; then |
---|
| 369 | echo |
---|
| 370 | echo 'Cannot find pkg-config, aborting.' |
---|
| 371 | exit 1 |
---|
| 372 | fi |
---|
| 373 | |
---|
| 374 | if $PKG_CONFIG glib-2.0; then |
---|
[670204f] | 375 | if $PKG_CONFIG glib-2.0 --atleast-version=$GLIB_MIN_VERSION; then |
---|
[b95b0c8] | 376 | cat<<EOF >>Makefile.settings |
---|
[4966712a] | 377 | EFLAGS+=$($PKG_CONFIG --libs glib-2.0 gmodule-2.0) |
---|
| 378 | CFLAGS+=$($PKG_CONFIG --cflags glib-2.0 gmodule-2.0) |
---|
[b7d3cc34] | 379 | EOF |
---|
[670204f] | 380 | else |
---|
| 381 | echo |
---|
[59c9fa4d] | 382 | echo 'Found glib2 '$($PKG_CONFIG glib-2.0 --modversion)', but version '$GLIB_MIN_VERSION' or newer is required.' |
---|
[670204f] | 383 | exit 1 |
---|
| 384 | fi |
---|
[b7d3cc34] | 385 | else |
---|
[670204f] | 386 | echo |
---|
[574af7e] | 387 | echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)' |
---|
[670204f] | 388 | exit 1 |
---|
[b7d3cc34] | 389 | fi |
---|
| 390 | |
---|
[85cf37f] | 391 | if [ "$events" = "libevent" ]; then |
---|
[003553b] | 392 | if ! [ -f "${libevent}include/event.h" ]; then |
---|
[85cf37f] | 393 | echo |
---|
| 394 | echo 'Warning: Could not find event.h, you might have to install it and/or specify' |
---|
| 395 | echo 'its location using the --libevent= argument. (Example: If event.h is in' |
---|
| 396 | echo '/usr/local/include and binaries are in /usr/local/lib: --libevent=/usr/local)' |
---|
| 397 | fi |
---|
| 398 | |
---|
| 399 | echo '#define EVENTS_LIBEVENT' >> config.h |
---|
[b95b0c8] | 400 | cat <<EOF >>Makefile.settings |
---|
[85cf37f] | 401 | EFLAGS+=-levent -L${libevent}lib |
---|
| 402 | CFLAGS+=-I${libevent}include |
---|
| 403 | EOF |
---|
| 404 | elif [ "$events" = "glib" ]; then |
---|
| 405 | ## We already use glib anyway, so this is all we need (and in fact not even this, but just to be sure...): |
---|
| 406 | echo '#define EVENTS_GLIB' >> config.h |
---|
[b7d3cc34] | 407 | else |
---|
| 408 | echo |
---|
[85cf37f] | 409 | echo 'ERROR: Unknown event handler specified.' |
---|
| 410 | exit 1 |
---|
[b7d3cc34] | 411 | fi |
---|
[85cf37f] | 412 | echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings |
---|
[b7d3cc34] | 413 | |
---|
[da0202a] | 414 | if [ "$external_json_parser" = "auto" ]; then |
---|
| 415 | if pkg-config --exists json-parser; then |
---|
| 416 | external_json_parser=1 |
---|
| 417 | else |
---|
| 418 | external_json_parser=0 |
---|
| 419 | fi |
---|
| 420 | fi |
---|
| 421 | echo "EXTERNAL_JSON_PARSER=$external_json_parser" >> Makefile.settings |
---|
| 422 | if [ "$external_json_parser" = "1" ]; then |
---|
| 423 | echo "CFLAGS+=$(pkg-config --cflags json-parser)" >> Makefile.settings |
---|
[82149f4] | 424 | echo "CFLAGS+=-DUSE_EXTERNAL_JSON_PARSER" >> Makefile.settings |
---|
[da0202a] | 425 | echo "LDFLAGS_BITLBEE+=$(pkg-config --libs json-parser)" >> Makefile.settings |
---|
| 426 | echo "LDFLAGS_TESTS+=$(pkg-config --libs json-parser)" >> Makefile.settings |
---|
| 427 | fi |
---|
| 428 | |
---|
[82149f4] | 429 | echo CFLAGS+=-I"${srcdir}" -I"${srcdir}"/lib -I"${srcdir}"/protocols -I. >> Makefile.settings |
---|
[da0202a] | 430 | |
---|
[b7d3cc34] | 431 | detect_gnutls() |
---|
| 432 | { |
---|
[4af7b4f] | 433 | if $PKG_CONFIG --exists gnutls; then |
---|
[b95b0c8] | 434 | cat <<EOF >>Makefile.settings |
---|
[4966712a] | 435 | EFLAGS+=$($PKG_CONFIG --libs gnutls) $(libgcrypt-config --libs) |
---|
| 436 | CFLAGS+=$($PKG_CONFIG --cflags gnutls) $(libgcrypt-config --cflags) |
---|
[4af7b4f] | 437 | EOF |
---|
| 438 | ssl=gnutls |
---|
[a59bd11] | 439 | if ! $PKG_CONFIG gnutls --atleast-version=2.8; then |
---|
[5513f3e] | 440 | echo |
---|
| 441 | echo 'Warning: With GnuTLS versions <2.8, certificate expire dates are not verified.' |
---|
| 442 | fi |
---|
[4af7b4f] | 443 | ret=1 |
---|
| 444 | elif libgnutls-config --version > /dev/null 2> /dev/null; then |
---|
[b95b0c8] | 445 | cat <<EOF >>Makefile.settings |
---|
[4966712a] | 446 | EFLAGS+=$(libgnutls-config --libs) $(libgcrypt-config --libs) |
---|
| 447 | CFLAGS+=$(libgnutls-config --cflags) $(libgcrypt-config --cflags) |
---|
[b7d3cc34] | 448 | EOF |
---|
| 449 | |
---|
| 450 | ssl=gnutls |
---|
| 451 | ret=1; |
---|
| 452 | else |
---|
| 453 | ret=0; |
---|
| 454 | fi; |
---|
| 455 | } |
---|
| 456 | |
---|
| 457 | detect_nss() |
---|
| 458 | { |
---|
[ef043d3] | 459 | if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG nss; then |
---|
[b95b0c8] | 460 | cat<<EOF >>Makefile.settings |
---|
[4966712a] | 461 | EFLAGS+=$($PKG_CONFIG --libs nss) |
---|
| 462 | CFLAGS+=$($PKG_CONFIG --cflags nss) |
---|
[b7d3cc34] | 463 | EOF |
---|
| 464 | |
---|
| 465 | ssl=nss |
---|
| 466 | ret=1; |
---|
| 467 | else |
---|
| 468 | ret=0; |
---|
| 469 | fi; |
---|
| 470 | } |
---|
| 471 | |
---|
[36cf9fd] | 472 | RESOLV_TESTCODE=' |
---|
[aee8c19] | 473 | #include <sys/types.h> |
---|
| 474 | #include <netinet/in.h> |
---|
[36cf9fd] | 475 | #include <arpa/nameser.h> |
---|
| 476 | #include <resolv.h> |
---|
| 477 | |
---|
[632627e] | 478 | int main() |
---|
| 479 | { |
---|
| 480 | |
---|
| 481 | res_query( NULL, 0, 0, NULL, 0); |
---|
| 482 | dn_expand( NULL, NULL, NULL, NULL, 0); |
---|
| 483 | dn_skipname( NULL, NULL); |
---|
| 484 | } |
---|
| 485 | ' |
---|
| 486 | RESOLV_NS_TESTCODE=' |
---|
| 487 | #include <sys/types.h> |
---|
| 488 | #include <netinet/in.h> |
---|
| 489 | #include <arpa/nameser.h> |
---|
| 490 | #include <resolv.h> |
---|
| 491 | |
---|
[36cf9fd] | 492 | int main() |
---|
| 493 | { |
---|
| 494 | ns_initparse( NULL, 0, NULL ); |
---|
| 495 | ns_parserr( NULL, ns_s_an, 0, NULL ); |
---|
| 496 | } |
---|
| 497 | ' |
---|
[632627e] | 498 | RESOLV_NS_TYPES_TESTCODE=' |
---|
| 499 | #include <sys/types.h> |
---|
| 500 | #include <netinet/in.h> |
---|
| 501 | #include <arpa/nameser.h> |
---|
| 502 | |
---|
| 503 | int main() |
---|
| 504 | { |
---|
| 505 | ns_msg nsh; |
---|
| 506 | ns_rr rr; |
---|
| 507 | |
---|
[fb87924] | 508 | /* Not all platforms we want to work on have |
---|
| 509 | ns_* routines, so use this to make sure |
---|
| 510 | the compiler uses it.*/ |
---|
| 511 | return (int)(sizeof(nsh) + sizeof(rr)); |
---|
[632627e] | 512 | } |
---|
| 513 | ' |
---|
[36cf9fd] | 514 | |
---|
[0d2cd10] | 515 | BACKTRACE_TESTCODE=' |
---|
| 516 | #include <execinfo.h> |
---|
| 517 | |
---|
| 518 | int main() |
---|
| 519 | { |
---|
| 520 | void *trace[16]; |
---|
| 521 | return backtrace(trace, 16); |
---|
| 522 | } |
---|
| 523 | ' |
---|
| 524 | |
---|
[36cf9fd] | 525 | detect_resolv_dynamic() |
---|
| 526 | { |
---|
[aee8c19] | 527 | case "$arch" in |
---|
[632627e] | 528 | OpenBSD ) |
---|
| 529 | # In FreeBSD res_*/dn_* routines are present in libc.so |
---|
| 530 | LIBRESOLV=;; |
---|
[aee8c19] | 531 | FreeBSD ) |
---|
[632627e] | 532 | # In FreeBSD res_*/dn_* routines are present in libc.so |
---|
| 533 | LIBRESOLV=;; |
---|
| 534 | CYGWIN* ) |
---|
| 535 | # In Cygwin res_*/dn_* routines are present in libc.so |
---|
[aee8c19] | 536 | LIBRESOLV=;; |
---|
| 537 | * ) |
---|
| 538 | LIBRESOLV=-lresolv;; |
---|
| 539 | esac |
---|
[4fca1db] | 540 | TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) |
---|
[8462239] | 541 | ret=1 |
---|
[59c9fa4d] | 542 | echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null |
---|
| 543 | if [ "$?" = "0" ]; then |
---|
[aee8c19] | 544 | echo "EFLAGS+=$LIBRESOLV" >> Makefile.settings |
---|
[8462239] | 545 | ret=0 |
---|
[36cf9fd] | 546 | fi |
---|
| 547 | |
---|
[59c9fa4d] | 548 | rm -f $TMPFILE |
---|
[8462239] | 549 | return $ret |
---|
[36cf9fd] | 550 | } |
---|
| 551 | |
---|
| 552 | detect_resolv_static() |
---|
| 553 | { |
---|
[4fca1db] | 554 | TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) |
---|
[8462239] | 555 | ret=1 |
---|
[36cf9fd] | 556 | for i in $systemlibdirs; do |
---|
[59c9fa4d] | 557 | if [ -f $i/libresolv.a ]; then |
---|
| 558 | echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null |
---|
| 559 | if [ "$?" = "0" ]; then |
---|
| 560 | echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings |
---|
[8462239] | 561 | ret=0 |
---|
[36cf9fd] | 562 | fi |
---|
| 563 | fi |
---|
| 564 | done |
---|
| 565 | |
---|
[59c9fa4d] | 566 | rm -f $TMPFILE |
---|
[8462239] | 567 | return $ret |
---|
[36cf9fd] | 568 | } |
---|
| 569 | |
---|
[632627e] | 570 | detect_resolv_ns_dynamic() |
---|
| 571 | { |
---|
| 572 | case "$arch" in |
---|
| 573 | FreeBSD ) |
---|
| 574 | # In FreeBSD ns_ routines are present in libc.so |
---|
| 575 | LIBRESOLV=;; |
---|
| 576 | * ) |
---|
| 577 | LIBRESOLV=-lresolv;; |
---|
| 578 | esac |
---|
| 579 | TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) |
---|
| 580 | ret=1 |
---|
[59c9fa4d] | 581 | echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null |
---|
| 582 | if [ "$?" = "0" ]; then |
---|
[a67e781] | 583 | ret=0 |
---|
| 584 | fi |
---|
[632627e] | 585 | |
---|
[59c9fa4d] | 586 | rm -f $TMPFILE |
---|
[632627e] | 587 | return $ret |
---|
| 588 | } |
---|
| 589 | |
---|
| 590 | detect_resolv_ns_static() |
---|
| 591 | { |
---|
| 592 | TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) |
---|
| 593 | ret=1 |
---|
| 594 | for i in $systemlibdirs; do |
---|
[59c9fa4d] | 595 | if [ -f $i/libresolv.a ]; then |
---|
| 596 | echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null |
---|
| 597 | if [ "$?" = "0" ]; then |
---|
[a67e781] | 598 | ret=0 |
---|
| 599 | fi |
---|
[632627e] | 600 | fi |
---|
| 601 | done |
---|
| 602 | |
---|
[59c9fa4d] | 603 | rm -f $TMPFILE |
---|
[632627e] | 604 | return $ret |
---|
| 605 | } |
---|
| 606 | |
---|
| 607 | detect_nameser_has_ns_types() |
---|
| 608 | { |
---|
[a67e781] | 609 | TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) |
---|
| 610 | ret=1 |
---|
| 611 | # since we aren't actually linking with ns_* routines |
---|
| 612 | # we can just compile the test code |
---|
[59c9fa4d] | 613 | echo "$RESOLV_NS_TYPES_TESTCODE" | $CC -o $TMPFILE -x c - >/dev/null 2>/dev/null |
---|
| 614 | if [ "$?" = "0" ]; then |
---|
[a67e781] | 615 | ret=0 |
---|
| 616 | fi |
---|
| 617 | |
---|
[59c9fa4d] | 618 | rm -f $TMPFILE |
---|
[a67e781] | 619 | return $ret |
---|
[632627e] | 620 | } |
---|
| 621 | |
---|
[0d2cd10] | 622 | detect_backtrace() |
---|
| 623 | { |
---|
| 624 | TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) |
---|
| 625 | ret=1 |
---|
[59c9fa4d] | 626 | echo "$BACKTRACE_TESTCODE" | $CC -o $TMPFILE -x c - >/dev/null 2>/dev/null |
---|
| 627 | if [ "$?" = "0" ]; then |
---|
[0d2cd10] | 628 | ret=0 |
---|
| 629 | fi |
---|
| 630 | |
---|
[59c9fa4d] | 631 | rm -f $TMPFILE |
---|
[0d2cd10] | 632 | return $ret |
---|
| 633 | } |
---|
| 634 | |
---|
[b3c467b] | 635 | if [ "$ssl" = "auto" ]; then |
---|
| 636 | detect_gnutls |
---|
[b7d3cc34] | 637 | if [ "$ret" = "0" ]; then |
---|
[c5920df] | 638 | # Disable NSS for now as it's known to not work very well ATM. |
---|
| 639 | #detect_nss |
---|
[191cfb1] | 640 | : |
---|
[b7d3cc34] | 641 | fi |
---|
[b3c467b] | 642 | elif [ "$ssl" = "gnutls" ]; then |
---|
| 643 | detect_gnutls |
---|
| 644 | elif [ "$ssl" = "nss" ]; then |
---|
| 645 | detect_nss |
---|
| 646 | elif [ "$ssl" = "openssl" ]; then |
---|
| 647 | echo |
---|
| 648 | echo 'No detection code exists for OpenSSL. Make sure that you have a complete' |
---|
[b3eee9b] | 649 | echo 'installation of OpenSSL (including devel/header files) before reporting' |
---|
[b3c467b] | 650 | echo 'compilation problems.' |
---|
| 651 | echo |
---|
| 652 | echo 'Also, keep in mind that the OpenSSL is, according to some people, not' |
---|
[b3eee9b] | 653 | echo 'completely GPL-compatible. Using GnuTLS is recommended and better supported' |
---|
| 654 | echo 'by us. However, on many BSD machines, OpenSSL can be considered part of the' |
---|
| 655 | echo 'operating system, which makes it GPL-compatible.' |
---|
[b3c467b] | 656 | echo |
---|
| 657 | echo 'For more info, see: http://www.openssl.org/support/faq.html#LEGAL2' |
---|
| 658 | echo ' http://www.gnome.org/~markmc/openssl-and-the-gpl.html' |
---|
| 659 | echo |
---|
| 660 | echo 'Please note that distributing a BitlBee binary which links to OpenSSL is' |
---|
| 661 | echo 'probably illegal. If you want to create and distribute a binary BitlBee' |
---|
[b3eee9b] | 662 | echo 'package, you really should use GnuTLS instead.' |
---|
[b3c467b] | 663 | echo |
---|
| 664 | echo 'Also, the OpenSSL license requires us to say this:' |
---|
| 665 | echo ' * "This product includes software developed by the OpenSSL Project' |
---|
| 666 | echo ' * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"' |
---|
[b7d3cc34] | 667 | |
---|
[b3c467b] | 668 | echo 'EFLAGS+=-lssl -lcrypto' >> Makefile.settings |
---|
| 669 | |
---|
| 670 | ret=1 |
---|
| 671 | else |
---|
| 672 | echo |
---|
| 673 | echo 'ERROR: Unknown SSL library specified.' |
---|
| 674 | exit 1 |
---|
[b7d3cc34] | 675 | fi |
---|
| 676 | |
---|
[b3c467b] | 677 | if [ "$ret" = "0" ]; then |
---|
| 678 | echo |
---|
| 679 | echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).' |
---|
| 680 | echo ' Please note that this script doesn'\''t have detection code for OpenSSL,' |
---|
[e1d3f98] | 681 | echo ' so if you want to use that, you have to select it by hand.' |
---|
[b7d3cc34] | 682 | |
---|
[b3c467b] | 683 | exit 1 |
---|
| 684 | fi; |
---|
| 685 | |
---|
| 686 | echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings |
---|
| 687 | |
---|
[632627e] | 688 | if detect_nameser_has_ns_types; then |
---|
| 689 | echo '#define NAMESER_HAS_NS_TYPES' >> config.h |
---|
| 690 | fi |
---|
[36cf9fd] | 691 | if detect_resolv_dynamic || detect_resolv_static; then |
---|
| 692 | echo '#define HAVE_RESOLV_A' >> config.h |
---|
[a67e781] | 693 | if detect_resolv_ns_dynamic || detect_resolv_ns_static; then |
---|
| 694 | echo '#define HAVE_RESOLV_A_WITH_NS' >> config.h |
---|
| 695 | fi |
---|
[632627e] | 696 | else |
---|
[a67e781] | 697 | echo 'Insufficient resolv routines. Jabber server must be set explicitly' |
---|
[36cf9fd] | 698 | fi |
---|
[36e9f62] | 699 | |
---|
[0d2cd10] | 700 | if detect_backtrace; then |
---|
| 701 | echo '#define HAVE_BACKTRACE' >> config.h |
---|
[59c9fa4d] | 702 | echo '#define CRASHFILE "'$config'crash.log"' >> config.h |
---|
[0d2cd10] | 703 | fi |
---|
[632627e] | 704 | |
---|
[ba7d16f] | 705 | STORAGES="xml" |
---|
[b3c467b] | 706 | |
---|
| 707 | for i in $STORAGES; do |
---|
| 708 | STORAGE_OBJS="$STORAGE_OBJS storage_$i.o" |
---|
| 709 | done |
---|
[59c9fa4d] | 710 | echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings |
---|
[b3c467b] | 711 | |
---|
[8e6ecfe] | 712 | authobjs= |
---|
| 713 | authlibs= |
---|
[59c9fa4d] | 714 | if [ "$pam" = 0 ]; then |
---|
[a6005da] | 715 | echo '#undef WITH_PAM' >> config.h |
---|
| 716 | else |
---|
| 717 | if ! echo '#include <security/pam_appl.h>' | $CC -E - >/dev/null 2>/dev/null; then |
---|
| 718 | echo 'Cannot find libpam development libraries, aborting. (Install libpam0g-dev?)' |
---|
| 719 | exit 1 |
---|
| 720 | fi |
---|
| 721 | echo '#define WITH_PAM' >> config.h |
---|
| 722 | authobjs=$authobjs'auth_pam.o ' |
---|
| 723 | authlibs=$authlibs'-lpam ' |
---|
| 724 | fi |
---|
[59c9fa4d] | 725 | if [ "$ldap" = 0 ]; then |
---|
[50bb490] | 726 | echo '#undef WITH_LDAP' >> config.h |
---|
| 727 | else |
---|
| 728 | if ! echo '#include <ldap.h>' | $CC -E - >/dev/null 2>/dev/null; then |
---|
| 729 | echo 'Cannot find libldap development libraries, aborting. (Install libldap2-dev?)' |
---|
| 730 | exit 1 |
---|
| 731 | fi |
---|
| 732 | echo '#define WITH_LDAP' >> config.h |
---|
| 733 | authobjs=$authobjs'auth_ldap.o ' |
---|
| 734 | authlibs=$authlibs'-lldap ' |
---|
| 735 | fi |
---|
[59c9fa4d] | 736 | echo AUTH_OBJS=$authobjs >> Makefile.settings |
---|
| 737 | echo EFLAGS+=$authlibs >> Makefile.settings |
---|
[8e6ecfe] | 738 | |
---|
[59c9fa4d] | 739 | if [ "$strip" = 0 ]; then |
---|
[b7d3cc34] | 740 | echo "STRIP=\# skip strip" >> Makefile.settings; |
---|
| 741 | else |
---|
[59c9fa4d] | 742 | if [ "$debug" = 1 ]; then |
---|
[b7d3cc34] | 743 | echo |
---|
| 744 | echo 'Stripping binaries does not make sense when debugging. Stripping disabled.' |
---|
| 745 | echo 'STRIP=\# skip strip' >> Makefile.settings |
---|
| 746 | strip=0; |
---|
| 747 | elif [ -n "$STRIP" ]; then |
---|
| 748 | echo "STRIP=$STRIP" >> Makefile.settings; |
---|
| 749 | elif type strip > /dev/null 2> /dev/null; then |
---|
| 750 | echo "STRIP=strip" >> Makefile.settings; |
---|
| 751 | else |
---|
| 752 | echo |
---|
| 753 | echo 'No strip utility found, cannot remove unnecessary parts from executable.' |
---|
| 754 | echo 'STRIP=\# skip strip' >> Makefile.settings |
---|
| 755 | strip=0; |
---|
| 756 | fi; |
---|
| 757 | fi |
---|
| 758 | |
---|
[59c9fa4d] | 759 | if [ ! "$systemd" = 0 ]; then |
---|
[8ca172f] | 760 | if ! $PKG_CONFIG --exists systemd ; then |
---|
[bea6db0] | 761 | if [ $systemd -eq 1 ]; then |
---|
[8ca172f] | 762 | echo "systemd requested but not found" |
---|
| 763 | exit 1 |
---|
| 764 | else |
---|
| 765 | systemd=0 |
---|
| 766 | fi |
---|
[bea6db0] | 767 | elif [ $systemd = "auto" ]; then |
---|
| 768 | systemd=1 |
---|
[8ca172f] | 769 | fi |
---|
[417002e] | 770 | fi |
---|
[8ca172f] | 771 | |
---|
| 772 | pkgconf_systemd_var() { |
---|
| 773 | # First try deprecated variable, use newer variable if not found |
---|
[59c9fa4d] | 774 | if $PKG_CONFIG --print-variables systemd | grep -q $1 ; then |
---|
| 775 | $PKG_CONFIG --variable=$1 systemd |
---|
[8ca172f] | 776 | else |
---|
[59c9fa4d] | 777 | $PKG_CONFIG --variable=$2 systemd |
---|
[8ca172f] | 778 | fi |
---|
| 779 | } |
---|
| 780 | |
---|
[59c9fa4d] | 781 | if [ "$systemd" -eq 1 ]; then |
---|
[8ca172f] | 782 | if [ -z "$systemdsystemunitdir" ]; then |
---|
| 783 | systemdsystemunitdir=$(pkgconf_systemd_var systemdsystemunitdir systemd_system_unit_dir) |
---|
[417002e] | 784 | fi |
---|
[50d0a72] | 785 | if [ -z "$sysusersdir" ] ; then |
---|
| 786 | sysusersdir=$(pkgconf_systemd_var sysusersdir sysusers_dir) |
---|
| 787 | fi |
---|
| 788 | fi |
---|
[8ca172f] | 789 | |
---|
[50d0a72] | 790 | if [ -n "$systemdsystemunitdir" ]; then |
---|
[8ca172f] | 791 | echo "SYSTEMDSYSTEMUNITDIR=$systemdsystemunitdir" >> Makefile.settings |
---|
[50d0a72] | 792 | fi |
---|
| 793 | if [ -n "$sysusersdir" ]; then |
---|
| 794 | echo "SYSUSERSDIR=$sysusersdir" >> Makefile.settings |
---|
[417002e] | 795 | fi |
---|
| 796 | |
---|
[66b9e86e] | 797 | if [ "$gcov" = "1" ]; then |
---|
[31fc3970] | 798 | echo "CFLAGS+=--coverage" >> Makefile.settings |
---|
| 799 | echo "EFLAGS+=--coverage" >> Makefile.settings |
---|
[66b9e86e] | 800 | fi |
---|
| 801 | |
---|
[59c9fa4d] | 802 | if [ "$plugins" = 0 ]; then |
---|
[489847f] | 803 | plugindir="" |
---|
[2abfbc5] | 804 | echo '#undef WITH_PLUGINS' >> config.h |
---|
| 805 | else |
---|
| 806 | echo '#define WITH_PLUGINS' >> config.h |
---|
| 807 | fi |
---|
| 808 | |
---|
[59c9fa4d] | 809 | otrprefix="" |
---|
[764c7d1] | 810 | if [ "$otr" = "auto" ]; then |
---|
[a59bd11] | 811 | ! $PKG_CONFIG --exists libotr |
---|
| 812 | otr=$? |
---|
| 813 | fi |
---|
| 814 | |
---|
[59c9fa4d] | 815 | if [ "$otr" != 0 ] && ! $PKG_CONFIG --atleast-version=4.0 --print-errors libotr; then |
---|
[a59bd11] | 816 | exit 1 |
---|
[764c7d1] | 817 | fi |
---|
[a59bd11] | 818 | |
---|
[59c9fa4d] | 819 | if [ "$otr" = 1 ]; then |
---|
[858ea01] | 820 | # BI == built-in |
---|
| 821 | echo '#define OTR_BI' >> config.h |
---|
[872e017] | 822 | echo "EFLAGS+=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings |
---|
| 823 | echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings |
---|
[858ea01] | 824 | echo 'OTR_BI=otr.o' >> Makefile.settings |
---|
| 825 | elif [ "$otr" = "plugin" ]; then |
---|
[a59bd11] | 826 | # for some mysterious reason beyond the comprehension of my mortal mind, |
---|
| 827 | # the libgcrypt flags aren't needed when building as plugin. add them anyway. |
---|
[858ea01] | 828 | echo '#define OTR_PI' >> config.h |
---|
[872e017] | 829 | echo "OTRFLAGS=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings |
---|
| 830 | echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings |
---|
[858ea01] | 831 | echo 'OTR_PI=otr.so' >> Makefile.settings |
---|
[764c7d1] | 832 | fi |
---|
| 833 | |
---|
[1cef55f] | 834 | if [ -z "$PYTHON" ]; then |
---|
[f18209a] | 835 | for pp in python python3 python2; do |
---|
| 836 | if which $pp > /dev/null; then |
---|
| 837 | PYTHON=$pp |
---|
| 838 | break |
---|
| 839 | fi |
---|
| 840 | done |
---|
[1cef55f] | 841 | fi |
---|
| 842 | |
---|
[a85a8ab] | 843 | if [ "$doc" = "1" ]; then |
---|
[beb0f54] | 844 | # check this here just in case someone tries to install it in python2.4... |
---|
[59c9fa4d] | 845 | if [ ! -e $srcdir/doc/user-guide/help.txt ] && ! $PYTHON -m xml.etree.ElementTree > /dev/null 2>&1; then |
---|
[a85a8ab] | 846 | echo |
---|
[beb0f54] | 847 | echo 'ERROR: Python (>=2.5 or 3.x) is required to generate docs' |
---|
[1cef55f] | 848 | echo "(Use the PYTHON environment variable if it's in a weird location)" |
---|
[beb0f54] | 849 | exit 1 |
---|
[a85a8ab] | 850 | fi |
---|
[beb0f54] | 851 | echo "DOC=1" >> Makefile.settings |
---|
[1cef55f] | 852 | echo "PYTHON=$PYTHON" >> Makefile.settings |
---|
[ceebeb1] | 853 | fi |
---|
| 854 | |
---|
[70ec7ab] | 855 | get_version |
---|
[e26aa72] | 856 | |
---|
[2bd8f39] | 857 | if [ ! "$BITLBEE_VERSION" = "$REAL_BITLBEE_VERSION" ]; then |
---|
| 858 | echo "Spoofing version number: $BITLBEE_VERSION" |
---|
| 859 | echo "#undef BITLBEE_VERSION" >> config.h |
---|
[b6df23d] | 860 | echo '#define BITLBEE_VERSION "'$BITLBEE_VERSION'"' >> config.h |
---|
[ffea9b9] | 861 | echo |
---|
[b7d3cc34] | 862 | fi |
---|
| 863 | |
---|
[4fca1db] | 864 | if ! make helloworld > /dev/null 2>&1; then |
---|
| 865 | echo "WARNING: Your version of make (BSD make?) does not support BitlBee's makefiles." |
---|
| 866 | echo "BitlBee needs GNU make to build properly. On most systems GNU make is available" |
---|
| 867 | echo "under the name 'gmake'." |
---|
| 868 | echo |
---|
| 869 | if gmake helloworld > /dev/null 2>&1; then |
---|
| 870 | echo "gmake seems to be available on your machine, great." |
---|
| 871 | echo |
---|
| 872 | else |
---|
| 873 | echo "gmake is not installed (or not working). Please try to install it." |
---|
| 874 | echo |
---|
| 875 | fi |
---|
| 876 | fi |
---|
| 877 | |
---|
[54b2a36] | 878 | pkgconfiglibs='' |
---|
| 879 | case "$arch" in |
---|
| 880 | CYGWIN* ) |
---|
[59c9fa4d] | 881 | pkgconfiglibs='-L${libdir} -lbitlbee -no-undefined' |
---|
[54b2a36] | 882 | esac |
---|
| 883 | |
---|
[82149f4] | 884 | pkgconfigrequires='glib-2.0' |
---|
| 885 | if [ "$external_json_parser" = '1' ]; then |
---|
| 886 | pkgconfigrequires="$pkgconfigrequires json-parser" |
---|
| 887 | fi |
---|
| 888 | |
---|
[b95b0c8] | 889 | cat <<EOF >bitlbee.pc |
---|
[e506d6c] | 890 | prefix=$prefix |
---|
| 891 | includedir=$includedir |
---|
[489847f] | 892 | plugindir=$plugindir |
---|
[54b2a36] | 893 | libdir=$libdir |
---|
[ad66dcd] | 894 | datadir=$datadir |
---|
[e506d6c] | 895 | |
---|
| 896 | Name: bitlbee |
---|
| 897 | Description: IRC to IM gateway |
---|
[82149f4] | 898 | Requires: $pkgconfigrequires |
---|
[e506d6c] | 899 | Version: $BITLBEE_VERSION |
---|
[54b2a36] | 900 | Libs: $pkgconfiglibs |
---|
[e506d6c] | 901 | Cflags: -I\${includedir} |
---|
| 902 | |
---|
| 903 | EOF |
---|
| 904 | |
---|
[b7d3cc34] | 905 | protocols='' |
---|
| 906 | protoobjs='' |
---|
| 907 | |
---|
[59c9fa4d] | 908 | if [ "$purple" = 0 ]; then |
---|
[e248c7f] | 909 | echo '#undef WITH_PURPLE' >> config.h |
---|
| 910 | else |
---|
[e08e53c] | 911 | if ! $PKG_CONFIG purple; then |
---|
| 912 | echo |
---|
| 913 | echo 'Cannot find libpurple development libraries, aborting. (Install libpurple-dev?)' |
---|
| 914 | exit 1 |
---|
| 915 | fi |
---|
[e248c7f] | 916 | echo '#define WITH_PURPLE' >> config.h |
---|
[b95b0c8] | 917 | cat<<EOF >>Makefile.settings |
---|
[e08e53c] | 918 | EFLAGS += $($PKG_CONFIG purple --libs) |
---|
| 919 | PURPLE_CFLAGS += $($PKG_CONFIG purple --cflags) |
---|
| 920 | EOF |
---|
[e248c7f] | 921 | protocols=$protocols'purple ' |
---|
| 922 | protoobjs=$protoobjs'purple_mod.o ' |
---|
| 923 | |
---|
[04e2a05] | 924 | # only disable these if the user didn't enable them explicitly |
---|
| 925 | [ "$jabber" = "default-on" ] && jabber=0 |
---|
[18e1f3b] | 926 | |
---|
| 927 | echo '#undef PACKAGE' >> config.h |
---|
| 928 | echo '#define PACKAGE "BitlBee-LIBPURPLE"' >> config.h |
---|
[bda2975] | 929 | |
---|
| 930 | if [ "$events" = "libevent" ]; then |
---|
| 931 | echo 'Warning: Some libpurple modules (including msn-pecan) do their event handling' |
---|
| 932 | echo 'outside libpurple, talking to GLib directly. At least for now the combination' |
---|
| 933 | echo 'libpurple + libevent is *not* recommended!' |
---|
[c775a58] | 934 | echo |
---|
[bda2975] | 935 | fi |
---|
[e248c7f] | 936 | fi |
---|
| 937 | |
---|
[b0a89cc] | 938 | case "$CC" in |
---|
| 939 | *gcc* ) |
---|
[e371011] | 940 | echo CFLAGS+=-MMD -MF .depend/\$@.d >> Makefile.settings |
---|
[fe92921] | 941 | for i in . lib tests protocols protocols/*/; do |
---|
[59c9fa4d] | 942 | mkdir -p $i/.depend |
---|
[b0a89cc] | 943 | done |
---|
| 944 | esac |
---|
| 945 | |
---|
[59c9fa4d] | 946 | if [ "$jabber" = 0 ]; then |
---|
[b7d3cc34] | 947 | echo '#undef WITH_JABBER' >> config.h |
---|
| 948 | else |
---|
| 949 | echo '#define WITH_JABBER' >> config.h |
---|
| 950 | protocols=$protocols'jabber ' |
---|
[b5a22e3] | 951 | protoobjs=$protoobjs'jabber_mod.o ' |
---|
[b7d3cc34] | 952 | fi |
---|
| 953 | |
---|
[59c9fa4d] | 954 | if [ "$twitter" = 0 ]; then |
---|
[1b221e0] | 955 | echo '#undef WITH_TWITTER' >> config.h |
---|
| 956 | else |
---|
| 957 | echo '#define WITH_TWITTER' >> config.h |
---|
| 958 | protocols=$protocols'twitter ' |
---|
| 959 | protoobjs=$protoobjs'twitter_mod.o ' |
---|
| 960 | fi |
---|
| 961 | |
---|
[b7d3cc34] | 962 | if [ "$protocols" = "PROTOCOLS = " ]; then |
---|
[43462708] | 963 | echo "Warning: You haven't selected any communication protocol to compile!" |
---|
[b3c467b] | 964 | echo " BitlBee will run, but you will be unable to connect to IM servers!" |
---|
[b7d3cc34] | 965 | fi |
---|
| 966 | |
---|
| 967 | echo "PROTOCOLS = $protocols" >> Makefile.settings |
---|
| 968 | echo "PROTOOBJS = $protoobjs" >> Makefile.settings |
---|
| 969 | |
---|
[59c9fa4d] | 970 | echo Architecture: $arch |
---|
[b7d3cc34] | 971 | case "$arch" in |
---|
| 972 | Linux ) |
---|
| 973 | ;; |
---|
| 974 | GNU/* ) |
---|
| 975 | ;; |
---|
| 976 | *BSD ) |
---|
| 977 | ;; |
---|
| 978 | Darwin ) |
---|
[caceb06] | 979 | echo 'STRIP=\# skip strip' >> Makefile.settings |
---|
[b7d3cc34] | 980 | ;; |
---|
| 981 | IRIX ) |
---|
| 982 | ;; |
---|
| 983 | SunOS ) |
---|
| 984 | echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings |
---|
| 985 | echo 'STRIP=\# skip strip' >> Makefile.settings |
---|
[70d7795] | 986 | echo '#define NO_FD_PASSING' >> config.h |
---|
[ea3f90f] | 987 | if [ "$arch_rel" = "5.10" ]; then |
---|
| 988 | echo '#define NO_STRCASESTR' >> config.h |
---|
| 989 | fi |
---|
[b7d3cc34] | 990 | ;; |
---|
[8de63c3] | 991 | AIX ) |
---|
| 992 | echo 'EFLAGS+=-Wl,-brtl' >> Makefile.settings |
---|
[b7d3cc34] | 993 | ;; |
---|
| 994 | CYGWIN* ) |
---|
[54b2a36] | 995 | echo 'EFLAGS+=-Wl,--export-all,--out-implib,libbitlbee.dll.a' >> Makefile.settings |
---|
| 996 | echo 'IMPLIB=libbitlbee.dll.a' >> Makefile.settings |
---|
[b7d3cc34] | 997 | ;; |
---|
[aec56b0] | 998 | Windows ) |
---|
[e252d8c] | 999 | echo 'Native windows compilation is not supported anymore, use cygwin instead.' |
---|
[aec56b0] | 1000 | ;; |
---|
[b7d3cc34] | 1001 | * ) |
---|
[8d6c4b1] | 1002 | echo 'We haven'\''t tested BitlBee on many platforms yet, yours is untested. YMMV.' |
---|
[92a03a0] | 1003 | echo 'Please report any problems at https://bugs.bitlbee.org/.' |
---|
[b7d3cc34] | 1004 | ;; |
---|
| 1005 | esac |
---|
| 1006 | |
---|
[f1e7407] | 1007 | if [ -n "$target" ]; then |
---|
| 1008 | echo "Cross-compiling for: $target" |
---|
| 1009 | fi |
---|
| 1010 | |
---|
[b7d3cc34] | 1011 | echo |
---|
| 1012 | echo 'Configuration done:' |
---|
| 1013 | |
---|
| 1014 | if [ "$debug" = "1" ]; then |
---|
[b3c467b] | 1015 | echo ' Debugging enabled.' |
---|
[b7d3cc34] | 1016 | else |
---|
[b3c467b] | 1017 | echo ' Debugging disabled.' |
---|
[b7d3cc34] | 1018 | fi |
---|
| 1019 | |
---|
[e2472dd] | 1020 | if [ "$asan" = "1" ]; then |
---|
| 1021 | echo ' AddressSanitizer (ASAN) enabled.' |
---|
| 1022 | else |
---|
| 1023 | echo ' AddressSanitizer (ASAN) disabled.' |
---|
| 1024 | fi |
---|
| 1025 | |
---|
[7281ad1] | 1026 | if [ "$pie" = "1" ]; then |
---|
| 1027 | echo ' Building PIE executable' |
---|
| 1028 | else |
---|
| 1029 | echo ' Building non-PIE executable' |
---|
| 1030 | fi |
---|
| 1031 | |
---|
[b7d3cc34] | 1032 | if [ "$strip" = "1" ]; then |
---|
[b3c467b] | 1033 | echo ' Binary stripping enabled.' |
---|
[b7d3cc34] | 1034 | else |
---|
[b3c467b] | 1035 | echo ' Binary stripping disabled.' |
---|
[b7d3cc34] | 1036 | fi |
---|
| 1037 | |
---|
[764c7d1] | 1038 | if [ "$otr" = "1" ]; then |
---|
| 1039 | echo ' Off-the-Record (OTR) Messaging enabled.' |
---|
[858ea01] | 1040 | elif [ "$otr" = "plugin" ]; then |
---|
| 1041 | echo ' Off-the-Record (OTR) Messaging enabled (as a plugin).' |
---|
[764c7d1] | 1042 | else |
---|
| 1043 | echo ' Off-the-Record (OTR) Messaging disabled.' |
---|
| 1044 | fi |
---|
| 1045 | |
---|
[2bd8f39] | 1046 | if [ "$systemd" = "1" ]; then |
---|
[bea6db0] | 1047 | echo ' systemd enabled.' |
---|
[417002e] | 1048 | else |
---|
[bea6db0] | 1049 | echo ' systemd disabled.' |
---|
[417002e] | 1050 | fi |
---|
| 1051 | |
---|
[f18209a] | 1052 | echo ' Using python: '$PYTHON |
---|
[da0202a] | 1053 | |
---|
| 1054 | if [ "$external_json_parser" = "1" ]; then |
---|
| 1055 | echo ' Using system JSON parser.' |
---|
| 1056 | else |
---|
| 1057 | echo ' Using bundled JSON parser.' |
---|
| 1058 | fi |
---|
| 1059 | |
---|
[b3c467b] | 1060 | echo ' Using event handler: '$events |
---|
| 1061 | echo ' Using SSL library: '$ssl |
---|
[4e3df8a] | 1062 | #echo ' Building with these storage backends: '$STORAGES |
---|
[b7d3cc34] | 1063 | |
---|
| 1064 | if [ -n "$protocols" ]; then |
---|
[59c9fa4d] | 1065 | echo ' Building with these protocols:' $protocols$protocols_mods |
---|
[4e3df8a] | 1066 | case "$protocols" in |
---|
| 1067 | *purple*) |
---|
| 1068 | echo " Note that BitlBee-libpurple is supported on a best-effort basis. It's" |
---|
| 1069 | echo " not *fully* compatible with normal BitlBee. Don't use it unless you" |
---|
| 1070 | echo " absolutely need it (i.e. support for a certain protocol or feature)." |
---|
| 1071 | esac |
---|
[b7d3cc34] | 1072 | else |
---|
[b3c467b] | 1073 | echo ' Building without IM-protocol support. We wish you a lot of fun...' |
---|
[b7d3cc34] | 1074 | fi |
---|