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