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