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