diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2010-01-27 15:54:48 +0100 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2010-01-27 15:54:48 +0100 |
commit | a8b73bd5f95c7f28bbb33d77a860130233007812 (patch) | |
tree | 845ad26d1818efc3bea934510475933b7d33b8bb | |
parent | 2307bf5c0f017618f00b86c044b26e24afe99403 (diff) |
autotools: fixed Bluetooth checks (MB #9260)syncevolution-1-0-beta-1
--disable-bluetooth had no effect. The code depends on libbluetooth
and failed to compile when only libopenobex was available. Now
configure aborts in that case.
-rw-r--r-- | configure-pre.in | 74 |
1 files changed, 56 insertions, 18 deletions
diff --git a/configure-pre.in b/configure-pre.in index f323a02f..e24185cc 100644 --- a/configure-pre.in +++ b/configure-pre.in @@ -153,16 +153,11 @@ PKG_CHECK_MODULES(LIBSOUP, libsoup-gnome-2.4, PKG_CHECK_MODULES(LIBOPENOBEX, openobex, have_obex="yes", have_obex="no") have_bluetooth="no" if test $have_obex = "yes"; then -AC_DEFINE(ENABLE_OBEX, 1, [define if openobex library is available]) PKG_CHECK_MODULES(BLUEZ, bluez, have_bluez="yes", have_bluez="no") if test $have_bluez = "yes"; then - AC_DEFINE(ENABLE_BLUETOOTH, 1, [define if bluez library is available]) - have_bluetooth="yes" + have_bluetooth="yes" fi fi - -AM_CONDITIONAL([ENABLE_OBEX], [test "$have_obex" = "yes"]) -AM_CONDITIONAL([ENABLE_BLUETOOTH], [test "$have_bluez" = "yes"]) AC_SUBST(LIBOPENOBEX_CFLAGS) AC_SUBST(LIBOPENOBEX_LIBS) AC_SUBST(BLUEZ_CFLAGS) @@ -226,16 +221,64 @@ AC_ARG_ENABLE(libsoup, AC_DEFINE(ENABLE_LIBSOUP, 1, [enable libsoup transport]) fi ]) +bluetooth_disabled=no AC_ARG_ENABLE(bluetooth, AC_HELP_STRING([--enable-bluetooth], [enable bluetooth transport support]), - [ if test "$enableval" = "yes"; then - bluetooth_disabled="no" - test "$have_bluetooth" = "yes" || AC_MSG_ERROR([openobex or bluez not found]) - else - have_bluetooth="no" - bluetooth_disabled="yes" - fi ]) + [ enable_bluetooth="$enableval" + if test "$enableval" = "no"; then + bluetooth_disabled=yes + fi + ], + [ enable_bluetooth="$have_bluetooth" ]) + +if test "$enable_bluetooth" = "yes"; then + # currently we need Bluetooth and OBEX support + test "$have_bluetooth" = "yes" || AC_MSG_ERROR([openobex or bluez not found]) + + AC_LANG(C) + CFLAGS_old="$CFLAGS" + CFLAGS="$CPPFLAGS $BLUEZ_CFLAGS" + # test in this order: + # - recent libbluetooth (no _safe variant, base function has bufsize) + # - intermediate with _safe + # - else assume old-style (no bufsize, no _safe) + # + # The source code checks the signature both by via pointer assignment and calling + # it (better safe than sorry). One these should fail if the signature is not right. + AC_COMPILE_IFELSE([#include <bluetooth/sdp.h> + #include <bluetooth/sdp_lib.h> + sdp_record_t *(*extract_pdu)(const uint8_t *pdata, int bufsize, int *scanned) = + sdp_extract_pdu; + void foo(void) { + uint8_t *pdata = NULL; + int scanned; + sdp_extract_pdu(pdata, 100, &scanned); + } + ], + AC_DEFINE(HAVE_BLUEZ_BUFSIZE, 1, [base libbluetooth functions accept bufsize parameter]), + AC_COMPILE_IFELSE([#include <bluetooth/sdp.h> + #include <bluetooth/sdp_lib.h> + sdp_record_t *(*extract_pdu)(const uint8_t *pdata, int bufsize, int *scanned) = + sdp_extract_pdu_safe; + void foo(void) { + uint8_t *pdata = NULL; + int scanned; + sdp_extract_pdu_safe(pdata, 100, &scanned); + } + ], + AC_DEFINE(HAVE_BLUEZ_SAFE, 1, [libbluetooth has _safe variants]))) + CFLAGS="$CFLAGS_old" + + if test "$have_obex" = "yes"; then + AC_DEFINE(ENABLE_OBEX, 1, [define if openobex library is available]) + fi + if test "$have_bluez" = "yes"; then + AC_DEFINE(ENABLE_BLUETOOTH, 1, [define if bluez library is available]) + fi +fi +AM_CONDITIONAL([ENABLE_OBEX], [test "$have_obex" = "yes" && test "$enable_bluetooth" = "yes"]) +AM_CONDITIONAL([ENABLE_BLUETOOTH], [test "$have_bluetooth" = "yes" && test "$enable_bluetooth" = "yes"]) if test "$have_bluetooth"; then AC_LANG(C) @@ -282,11 +325,6 @@ if test ! "$TRANSPORT" && AC_ERROR([no transport library found, configure with --disable-libcurl --disable-libsoup --disable-bluetooth to continue anyway (only useful if users of libsyncevolution provide transport implementation)]) fi -if test "$have_bluetooth" != "yes" && - test "$bluetooth_disabled" !="yes" ; then - AC_ERROR([no bluetooth library found libopenobex or bluez, please check your installation]) -fi - # for libsoup we must specify the SSL certificate file outself if test "$libsoup_disabled" != "yes" && test -z "$CA_CERTIFICATES"; then # Debian and Red Hat paths |