summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bluez.m435
1 files changed, 34 insertions, 1 deletions
diff --git a/bluez.m4 b/bluez.m4
index abcbaae2..c432a2fa 100644
--- a/bluez.m4
+++ b/bluez.m4
@@ -3,8 +3,41 @@ dnl $Id$
dnl
AC_DEFUN([AM_PATH_BLUEZ], [
+ if (test "${prefix}" = "NONE"); then
+ bluez_prefix=${ac_default_prefix}
+ else
+ bluez_prefix=${prefix}
+ fi
+
+ AC_ARG_WITH(bluez, AC_HELP_STRING([--with-bluez=DIR], [BlueZ library is installed in DIR]), [
+ if (test "${withval}" != "yes"); then
+ bluez_prefix=${withval}
+ fi
+ ])
+
+ ac_save_CPPFLAGS=$CPPFLAGS
+ ac_save_LDFLAGS=$LDFLAGS
+
BLUEZ_CFLAGS=""
- BLUEZ_LIBS="-lbluetooth"
+ test -d "${bluez_prefix}/include" && BLUEZ_CFLAGS="$BLUEZ_CFLAGS -I${bluez_prefix}/include"
+
+ CPPFLAGS="$CPPFLAGS $BLUEZ_CFLAGS"
+ AC_CHECK_HEADER(bluetooth/bluetooth.h,, AC_MSG_ERROR(Bluetooth header files not found))
+
+ BLUEZ_LIBS=""
+ if (test "${ac_default_prefix}" = "${bluez_prefix}"); then
+ test -d "${libdir}" && BLUEZ_LIBS="$BLUEZ_LIBS -L${libdir}"
+ else
+ test -d "${bluez_prefix}/lib64" && BLUEZ_LIBS="$BLUEZ_LIBS -L${bluez_prefix}/lib64"
+ test -d "${bluez_prefix}/lib" && BLUEZ_LIBS="$BLUEZ_LIBS -L${bluez_prefix}/lib"
+ fi
+
+ LDFLAGS="$LDFLAGS $BLUEZ_LIBS"
+ AC_CHECK_LIB(bluetooth, hci_open_dev, BLUEZ_LIBS="$BLUEZ_LIBS -lbluetooth", AC_MSG_ERROR(Bluetooth library not found))
+ AC_CHECK_LIB(bluetooth, sdp_connect,, AC_CHECK_LIB(sdp, sdp_connect, BLUEZ_LIBS="$BLUEZ_LIBS -lsdp"))
+
+ CPPFLAGS=$ac_save_CPPFLAGS
+ LDFLAGS=$ac_save_LDFLAGS
AC_SUBST(BLUEZ_CFLAGS)
AC_SUBST(BLUEZ_LIBS)