Diff between ff983074f8970bd60ad003f7f2f270f7aff17d27 and cc9e4e7cae0379864ea06038d92bf7ecc192bba7

Changed Files

File Additions Deletions Status
Makefile.am +6 -12 modified
Makefile.plugins +1 -3 modified
Makefile.profiles +0 -8 modified
Makefile.tools +2 -2 modified
acinclude.m4 +20 -247 modified
bootstrap-configure +2 -7 modified
configure.ac +150 -15 modified

Full Patch

diff --git a/Makefile.am b/Makefile.am
index 72d26cd..1f9b9fe 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -109,18 +109,16 @@ builtin_nodist =
 include Makefile.plugins
 include Makefile.profiles
 
-if SAPPLUGIN
+if EXPERIMENTAL
 builtin_modules += sap
 builtin_sources += profiles/sap/main.c profiles/sap/manager.h \
 			profiles/sap/manager.c profiles/sap/server.h \
-			profiles/sap/server.c profiles/sap/sap.h
-
-builtin_nodist += profiles/sap/sap.c
+			profiles/sap/server.c profiles/sap/sap.h \
+			profiles/sap/sap-dummy.c
 
 noinst_LIBRARIES += profiles/sap/libsap.a
 
-profiles_sap_libsap_a_SOURCES = profiles/sap/sap.h profiles/sap/sap-dummy.c \
-				profiles/sap/sap-u8500.c
+profiles_sap_libsap_a_SOURCES = profiles/sap/sap.h profiles/sap/sap-u8500.c
 endif
 
 if MAINTAINER_MODE
@@ -184,8 +182,7 @@ endif
 EXTRA_DIST += src/genbuiltin src/bluetooth.conf src/org.bluez.service \
 			src/main.conf profiles/network/network.conf \
 			profiles/input/input.conf profiles/proximity/proximity.conf \
-			profiles/audio/audio.conf \
-			profiles/sap/sap-dummy.c profiles/sap/sap-u8500.c
+			profiles/audio/audio.conf
 
 include Makefile.tools
 include Makefile.obexd
@@ -263,7 +260,7 @@ pkgconfigdir = $(libdir)/pkgconfig
 
 pkgconfig_DATA = bluez.pc
 
-DISTCHECK_CONFIGURE_FLAGS = --disable-datafiles
+DISTCHECK_CONFIGURE_FLAGS = --disable-datafiles --disable-udev
 
 DISTCLEANFILES = $(pkgconfig_DATA)
 
@@ -281,9 +278,6 @@ SED_PROCESS = $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
 src/builtin.h: src/genbuiltin $(builtin_sources)
 	$(AM_V_GEN)$(srcdir)/src/genbuiltin $(builtin_modules) > $@
 
-profiles/sap/sap.c: profiles/sap/@SAP_DRIVER@
-	$(AM_V_GEN)$(LN_S) -f $(abs_top_srcdir)/$< $@
-
 scripts/%.rules:
 	$(AM_V_GEN)cp $(subst 97-,,$@) $@
 
diff --git a/Makefile.plugins b/Makefile.plugins
index c02f0d4..9052b3a 100644
--- a/Makefile.plugins
+++ b/Makefile.plugins
@@ -14,12 +14,10 @@ builtin_sources += plugins/gatt-example.c
 builtin_modules += wiimote
 builtin_sources += plugins/wiimote.c
 
-if DBUSOOBPLUGIN
+if EXPERIMENTAL
 builtin_modules += dbusoob
 builtin_sources += plugins/dbusoob.c
-endif
 
-if NEARDPLUGIN
 builtin_modules += neard
 builtin_sources += plugins/neard.c
 endif
diff --git a/Makefile.profiles b/Makefile.profiles
index 45fb4b9..5bd7ea2 100644
--- a/Makefile.profiles
+++ b/Makefile.profiles
@@ -1,5 +1,4 @@
 
-if AUDIOPLUGIN
 builtin_modules += audio
 builtin_sources += profiles/audio/main.c \
 			profiles/audio/manager.h profiles/audio/manager.c \
@@ -15,9 +14,7 @@ builtin_sources += profiles/audio/main.c \
 			profiles/audio/transport.h profiles/audio/transport.c \
 			profiles/audio/player.h profiles/audio/player.c \
 			profiles/audio/a2dp-codecs.h
-endif
 
-if NETWORKPLUGIN
 builtin_modules += network
 builtin_sources += profiles/network/main.c \
 			profiles/network/manager.h profiles/network/manager.c \
@@ -25,9 +22,7 @@ builtin_sources += profiles/network/main.c \
 			profiles/network/server.h profiles/network/server.c \
 			profiles/network/connection.h \
 			profiles/network/connection.c
-endif
 
-if INPUTPLUGIN
 builtin_modules += input
 builtin_sources += profiles/input/main.c \
 			profiles/input/manager.h profiles/input/manager.c \
@@ -38,9 +33,7 @@ builtin_modules += hog
 builtin_sources += profiles/input/hog_manager.c profiles/input/hog_device.h \
 			profiles/input/hog_device.c profiles/input/uhid_copy.h \
 			profiles/input/suspend.h profiles/input/suspend-dummy.c
-endif
 
-if HEALTHPLUGIN
 builtin_modules += health
 builtin_sources += profiles/health/mcap_lib.h profiles/health/mcap_internal.h \
 			profiles/health/mcap.h profiles/health/mcap.c \
@@ -50,7 +43,6 @@ builtin_sources += profiles/health/mcap_lib.h profiles/health/mcap_internal.h \
 			profiles/health/hdp_manager.c \
 			profiles/health/hdp.h profiles/health/hdp.c \
 			profiles/health/hdp_util.h profiles/health/hdp_util.c
-endif
 
 builtin_modules += thermometer
 builtin_sources += profiles/thermometer/main.c \
diff --git a/Makefile.tools b/Makefile.tools
index 36b43dc..8cb1203 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -77,13 +77,13 @@ attrib_gatttool_SOURCES = attrib/gatttool.c attrib/att.c attrib/gatt.c \
 				attrib/gattrib.c btio/btio.c \
 				attrib/gatttool.h attrib/interactive.c \
 				attrib/utils.c src/log.c
-attrib_gatttool_LDADD = lib/libbluetooth-private.la @GLIB_LIBS@ @READLINE_LIBS@
+attrib_gatttool_LDADD = lib/libbluetooth-private.la @GLIB_LIBS@ -lreadline
 
 noinst_PROGRAMS += tools/obex-client-tool
 tools_obex_client_tool_SOURCES = $(gobex_sources) $(btio_sources) \
 						tools/obex-client-tool.c
 tools_obex_client_tool_LDADD = lib/libbluetooth-private.la \
-						@GLIB_LIBS@ @READLINE_LIBS@
+						@GLIB_LIBS@ -lreadline
 
 noinst_PROGRAMS += tools/obex-server-tool
 tools_obex_server_tool_SOURCES = $(gobex_sources) $(btio_sources) \
diff --git a/acinclude.m4 b/acinclude.m4
index d821fb2..4357c00 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -26,257 +26,30 @@ AC_DEFUN([COMPILER_FLAGS], [
 	AC_SUBST([WARNING_CFLAGS], $with_cflags)
 ])
 
-AC_DEFUN([AC_INIT_BLUEZ], [
-	AC_PREFIX_DEFAULT(/usr/local)
-
-	if (test "${prefix}" = "NONE"); then
-		dnl no prefix and no sysconfdir, so default to /etc
-		if (test "$sysconfdir" = '${prefix}/etc'); then
-			AC_SUBST([sysconfdir], ['/etc'])
-		fi
-
-		dnl no prefix and no localstatedir, so default to /var
-		if (test "$localstatedir" = '${prefix}/var'); then
-			AC_SUBST([localstatedir], ['/var'])
-		fi
-
-		dnl no prefix and no libexecdir, so default to /lib
-		if (test "$libexecdir" = '${exec_prefix}/libexec'); then
-			AC_SUBST([libexecdir], ['/lib'])
-		fi
-
-		dnl no prefix and no mandir, so use ${prefix}/share/man as default
-		if (test "$mandir" = '${prefix}/man'); then
-			AC_SUBST([mandir], ['${prefix}/share/man'])
+AC_DEFUN([MISC_FLAGS], [
+	misc_cflags=""
+	misc_ldflags=""
+	AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization],
+			[disable code optimization through compiler]), [
+		if (test "${enableval}" = "no"); then
+			misc_cflags="$misc_cflags -D_FORTIFY_SOURCE=2"
 		fi
-
-		prefix="${ac_default_prefix}"
-	fi
-
-	if (test "${libdir}" = '${exec_prefix}/lib'); then
-		libdir="${prefix}/lib"
-	fi
-
-	plugindir="${libdir}/bluetooth/plugins"
-
-	if (test "$sysconfdir" = '${prefix}/etc'); then
-		configdir="${prefix}/etc/bluetooth"
-	else
-		configdir="${sysconfdir}/bluetooth"
-	fi
-
-	if (test "$localstatedir" = '${prefix}/var'); then
-		storagedir="${prefix}/var/lib/bluetooth"
-	else
-		storagedir="${localstatedir}/lib/bluetooth"
-	fi
-
-	AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}",
-				[Directory for the configuration files])
-	AC_DEFINE_UNQUOTED(STORAGEDIR, "${storagedir}",
-				[Directory for the storage files])
-
-	AC_SUBST(CONFIGDIR, "${configdir}")
-	AC_SUBST(STORAGEDIR, "${storagedir}")
-
-	UDEV_DIR="`$PKG_CONFIG --variable=udevdir udev`"
-	if (test -z "${UDEV_DIR}"); then
-		UDEV_DIR="/lib/udev"
-	fi
-	AC_SUBST(UDEV_DIR)
-])
-
-AC_DEFUN([AC_PATH_DBUS], [
-	PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.4, dummy=yes,
-				AC_MSG_ERROR(D-Bus >= 1.4 is required))
-	AC_SUBST(DBUS_CFLAGS)
-	AC_SUBST(DBUS_LIBS)
-])
-
-AC_DEFUN([AC_PATH_GLIB], [
-	PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.32, dummy=yes,
-				AC_MSG_ERROR(GLib >= 2.32 is required))
-	AC_SUBST(GLIB_CFLAGS)
-	AC_SUBST(GLIB_LIBS)
-])
-
-AC_DEFUN([AC_PATH_USB], [
-	PKG_CHECK_MODULES(USB, libusb, usb_found=yes, usb_found=no)
-	AC_SUBST(USB_CFLAGS)
-	AC_SUBST(USB_LIBS)
-	AC_CHECK_LIB(usb, usb_get_busses, dummy=yes,
-		AC_DEFINE(NEED_USB_GET_BUSSES, 1,
-			[Define to 1 if you need the usb_get_busses() function.]))
-	AC_CHECK_LIB(usb, usb_interrupt_read, dummy=yes,
-		AC_DEFINE(NEED_USB_INTERRUPT_READ, 1,
-			[Define to 1 if you need the usb_interrupt_read() function.]))
-])
-
-AC_DEFUN([AC_PATH_UDEV], [
-	PKG_CHECK_MODULES(UDEV, libudev, udev_found=yes, udev_found=no)
-	AC_SUBST(UDEV_CFLAGS)
-	AC_SUBST(UDEV_LIBS)
-	AC_CHECK_LIB(udev, udev_hwdb_new,
-		AC_DEFINE(HAVE_UDEV_HWDB_NEW, 1,
-			[Define to 1 if you have the udev_hwdb_new() function.]))
-])
-
-AC_DEFUN([AC_PATH_READLINE], [
-	AC_CHECK_HEADER(readline/readline.h,
-		AC_CHECK_LIB(readline, main,
-			[ readline_found=yes
-			AC_SUBST(READLINE_LIBS, "-lreadline")
-			], readline_found=no),
-		[])
-])
-
-AC_DEFUN([AC_PATH_OUI], [
-	AC_ARG_WITH(ouifile,
-		    AS_HELP_STRING([--with-ouifile=PATH],[Path to the oui.txt file @<:@auto@:>@]),
-		    [ac_with_ouifile=$withval],
-		    [ac_with_ouifile="/var/lib/misc/oui.txt"])
-	AC_DEFINE_UNQUOTED(OUIFILE, ["$ac_with_ouifile"], [Define the OUI file path])
-])
-
-AC_DEFUN([AC_ARG_BLUEZ], [
-	debug_enable=no
-	optimization_enable=yes
-	fortify_enable=yes
-	pie_enable=yes
-	usb_enable=${usb_found}
-	audio_enable=yes
-	input_enable=yes
-	network_enable=yes
-	sap_enable=no
-	service_enable=yes
-	health_enable=no
-	tools_enable=yes
-	cups_enable=no
-	test_enable=no
-	hid2hci_enable=no
-	datafiles_enable=yes
-	sap_driver=dummy
-	dbusoob_enable=no
-	neard_enable=no
-
-	AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization], [disable code optimization]), [
-		optimization_enable=${enableval}
-	])
-
-	AC_ARG_ENABLE(fortify, AC_HELP_STRING([--disable-fortify], [disable compile time buffer checks]), [
-		fortify_enable=${enableval}
-	])
-
-	AC_ARG_ENABLE(pie, AC_HELP_STRING([--disable-pie], [disable position independent executables flag]), [
-		pie_enable=${enableval}
-	])
-
-	AC_ARG_ENABLE(network, AC_HELP_STRING([--disable-network], [disable network plugin]), [
-		network_enable=${enableval}
-	])
-
-	AC_ARG_ENABLE(sap, AC_HELP_STRING([--enable-sap], [enable sap plugin]), [
-		sap_enable=${enableval}
 	])
-
-	AC_ARG_WITH(sap, AC_HELP_STRING([--with-sap=DRIVER], [select SAP driver]), [
-		sap_driver=${withval}
-	])
-	AC_SUBST([SAP_DRIVER], [sap-${sap_driver}.c])
-
-	AC_ARG_ENABLE(input, AC_HELP_STRING([--disable-input], [disable input plugin]), [
-		input_enable=${enableval}
-	])
-
-	AC_ARG_ENABLE(audio, AC_HELP_STRING([--disable-audio], [disable audio plugin]), [
-		audio_enable=${enableval}
-	])
-
-	AC_ARG_ENABLE(service, AC_HELP_STRING([--disable-service], [disable service plugin]), [
-		service_enable=${enableval}
-	])
-
-	AC_ARG_ENABLE(health, AC_HELP_STRING([--enable-health], [enable health plugin]), [
-		health_enable=${enableval}
-	])
-
-	AC_ARG_ENABLE(usb, AC_HELP_STRING([--enable-usb], [enable USB support]), [
-		usb_enable=${enableval}
-	])
-
-	AC_ARG_ENABLE(tools, AC_HELP_STRING([--enable-tools], [install Bluetooth utilities]), [
-		tools_enable=${enableval}
-	])
-
-	AC_ARG_ENABLE(hid2hci, AC_HELP_STRING([--enable-hid2hci], [install HID mode switching utility]), [
-		hid2hci_enable=${enableval}
-	])
-
-	AC_ARG_ENABLE(cups, AC_HELP_STRING([--enable-cups], [install CUPS backend support]), [
-		cups_enable=${enableval}
-	])
-
-	AC_ARG_ENABLE(test, AC_HELP_STRING([--enable-test], [install test programs]), [
-		test_enable=${enableval}
-	])
-
-	AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--enable-datafiles], [install Bluetooth configuration and data files]), [
-		datafiles_enable=${enableval}
-	])
-
-	AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [enable compiling with debugging information]), [
-		debug_enable=${enableval}
-	])
-
-	AC_ARG_ENABLE(dbusoob, AC_HELP_STRING([--enable-dbusoob], [compile with D-Bus OOB plugin]), [
-		dbusoob_enable=${enableval}
+	AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],
+			[enable compiling with debugging information]), [
+		if (test "${enableval}" = "yes" &&
+				test "${ac_cv_prog_cc_g}" = "yes"); then
+			misc_cflags="$misc_cflags -g"
+		fi
 	])
-
-	AC_ARG_ENABLE(neard, AC_HELP_STRING([--enable-neard], [compile with neard plugin]), [
-		neard_enable=${enableval}
+	AC_ARG_ENABLE(pie, AC_HELP_STRING([--enable-pie],
+			[enable position independent executables flag]), [
+		if (test "${enableval}" = "yes" &&
+				test "${ac_cv_prog_cc_pie}" = "yes"); then
+			misc_cflags="$misc_cflags -fPIC"
+			misc_ldflags="$misc_ldflags -pie"
+		fi
 	])
-
-	misc_cflags=""
-	misc_ldflags=""
-
-	if (test "${fortify_enable}" = "yes"); then
-		misc_cflags="$misc_cflags -D_FORTIFY_SOURCE=2"
-	fi
-
-	if (test "${pie_enable}" = "yes" && test "${ac_cv_prog_cc_pie}" = "yes"); then
-		misc_cflags="$misc_cflags -fPIC"
-		misc_ldflags="$misc_ldflags -pie"
-	fi
-
-	if (test "${debug_enable}" = "yes" && test "${ac_cv_prog_cc_g}" = "yes"); then
-		misc_cflags="$misc_cflags -g"
-	fi
-
-	if (test "${optimization_enable}" = "no"); then
-		misc_cflags="$misc_cflags -O0"
-	fi
-
 	AC_SUBST([MISC_CFLAGS], $misc_cflags)
 	AC_SUBST([MISC_LDFLAGS], $misc_ldflags)
-
-	if (test "${usb_enable}" = "yes" && test "${usb_found}" = "yes"); then
-		AC_DEFINE(HAVE_LIBUSB, 1, [Define to 1 if you have USB library.])
-	fi
-
-	AM_CONDITIONAL(USB, test "${usb_enable}" = "yes" && test "${usb_found}" = "yes")
-
-	AM_CONDITIONAL(AUDIOPLUGIN, test "${audio_enable}" = "yes")
-	AM_CONDITIONAL(INPUTPLUGIN, test "${input_enable}" = "yes")
-	AM_CONDITIONAL(NETWORKPLUGIN, test "${network_enable}" = "yes")
-	AM_CONDITIONAL(SAPPLUGIN, test "${sap_enable}" = "yes")
-	AM_CONDITIONAL(SERVICEPLUGIN, test "${service_enable}" = "yes")
-	AM_CONDITIONAL(HEALTHPLUGIN, test "${health_enable}" = "yes")
-	AM_CONDITIONAL(READLINE, test "${readline_found}" = "yes")
-	AM_CONDITIONAL(CUPS, test "${cups_enable}" = "yes")
-	AM_CONDITIONAL(TEST, test "${test_enable}" = "yes")
-	AM_CONDITIONAL(TOOLS, test "${tools_enable}" = "yes")
-	AM_CONDITIONAL(HID2HCI, test "${hid2hci_enable}" = "yes" && test "${usb_found}" = "yes" && test "${udev_found}" = "yes")
-	AM_CONDITIONAL(DATAFILES, test "${datafiles_enable}" = "yes")
-	AM_CONDITIONAL(DBUSOOBPLUGIN, test "${dbusoob_enable}" = "yes")
-	AM_CONDITIONAL(NEARDPLUGIN, test "${neard_enable}" = "yes")
 ])
diff --git a/bootstrap-configure b/bootstrap-configure
index 23f6c00..9735856 100755
--- a/bootstrap-configure
+++ b/bootstrap-configure
@@ -15,12 +15,7 @@ fi
 		--mandir=/usr/share/man \
 		--sysconfdir=/etc \
 		--localstatedir=/var \
-		--enable-health \
-		--enable-tools \
-		--enable-hid2hci \
 		--enable-test \
-		--enable-cups \
-		--enable-dbusoob \
-		--enable-neard \
-		--enable-sap \
+		--enable-tools \
+		--enable-experimental \
 		--disable-datafiles $*
diff --git a/configure.ac b/configure.ac
index 0fc5c65..54b1806 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,19 +9,21 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
 AM_MAINTAINER_MODE
 
-PKG_PROG_PKG_CONFIG
+AC_PREFIX_DEFAULT(/usr/local)
 
-AC_INIT_BLUEZ
+PKG_PROG_PKG_CONFIG
 
 COMPILER_FLAGS
 
 AC_LANG_C
 
+AC_C_RESTRICT
+
 AC_PROG_CC
 AM_PROG_CC_C_O
 AC_PROG_CC_PIE
 AC_PROG_INSTALL
-AC_PROG_MKDIR_P
+AM_PROG_MKDIR_P
 
 m4_define([_LT_AC_TAGCONFIG], [])
 m4_ifdef([AC_LIBTOOL_TAGS], [AC_LIBTOOL_TAGS([])])
@@ -29,24 +31,57 @@ m4_ifdef([AC_LIBTOOL_TAGS], [AC_LIBTOOL_TAGS([])])
 AC_DISABLE_STATIC
 AC_PROG_LIBTOOL
 
+MISC_FLAGS
+
+AC_ARG_ENABLE(threads, AC_HELP_STRING([--enable-threads],
+		[enable threading support]), [enable_threads=${enableval}])
+
+AC_CHECK_FUNC(signalfd, dummy=yes,
+			AC_MSG_ERROR(signalfd support is required))
+
 AC_CHECK_LIB(dl, dlopen, dummy=yes,
 			AC_MSG_ERROR(dynamic linking loader is required))
 
-AC_CHECK_HEADER([sys/inotify.h],
-		[AC_DEFINE([HAVE_SYS_INOTIFY_H], 1,
-			[Define to 1 if you have <sys/inotify.h>.])],
-			[AC_MSG_ERROR(inotify headers are required and missing)])
-AC_PATH_DBUS
-AC_PATH_GLIB
-AC_PATH_USB
-AC_PATH_UDEV
-AC_PATH_OUI
-AC_PATH_READLINE
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28, dummy=yes,
+				AC_MSG_ERROR(GLib >= 2.28 is required))
+AC_SUBST(GLIB_CFLAGS)
+AC_SUBST(GLIB_LIBS)
+
+if (test "${enable_threads}" = "yes"); then
+	AC_DEFINE(NEED_THREADS, 1, [Define if threading support is required])
+	PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
+				AC_MSG_ERROR(GThread >= 2.16 is required))
+	GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS"
+	GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS"
+fi
 
-AC_ARG_BLUEZ
+PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.4, dummy=yes,
+				AC_MSG_ERROR(D-Bus >= 1.4 is required))
+AC_SUBST(DBUS_CFLAGS)
+AC_SUBST(DBUS_LIBS)
+
+AC_ARG_WITH(dbusconfdir, AC_HELP_STRING([--with-dbusconfdir=PATH],
+	[path to D-Bus config directory]), [path_dbusconf=${withval}],
+		[path_dbusconf="`$PKG_CONFIG --variable=sysconfdir dbus-1`"])
+if (test -z "${path_dbusconf}"); then
+	DBUS_CONFDIR="${sysconfdir}/dbus-1/system.d"
+else
+	DBUS_CONFDIR="${path_dbusconf}/dbus-1/system.d"
+fi
+AC_SUBST(DBUS_CONFDIR)
+
+AC_ARG_WITH(dbusdatadir, AC_HELP_STRING([--with-dbusdatadir=PATH],
+	[path to D-Bus data directory]), [path_dbusdata=${withval}],
+		[path_dbusdata="`$PKG_CONFIG --variable=datadir dbus-1`"])
+if (test -z "${path_dbusdata}"); then
+	DBUS_DATADIR="${datadir}/dbus-1/system-services"
+else
+	DBUS_DATADIR="${path_dbusdata}/dbus-1/system-services"
+fi
+AC_SUBST(DBUS_DATADIR)
 
 AC_ARG_WITH([systemdunitdir], AC_HELP_STRING([--with-systemdunitdir=DIR],
-	[path to systemd system service directory]), [path_systemdunit=${withval}],
+	[path to systemd service directory]), [path_systemdunit=${withval}],
 		[path_systemdunit="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`"])
 if (test -n "${path_systemdunit}"); then
 	SYSTEMD_UNITDIR="${path_systemdunit}"
@@ -54,4 +89,104 @@ if (test -n "${path_systemdunit}"); then
 fi
 AM_CONDITIONAL(SYSTEMD, test -n "${path_systemdunit}")
 
+AC_ARG_ENABLE(test, AC_HELP_STRING([--enable-test],
+		[enable test/example scripts]), [enable_test=${enableval}])
+AM_CONDITIONAL(TEST, test "${enable_test}" = "yes")
+
+AC_ARG_ENABLE(tools, AC_HELP_STRING([--enable-tools],
+		[enable testing tools]), [enable_tools=${enableval}])
+AM_CONDITIONAL(TOOLS, test "${enable_tools}" = "yes")
+
+AC_ARG_ENABLE(readline, AC_HELP_STRING([--disable-readline],
+		[disable readline support]), [enable_readline=${enableval}])
+if (test "${enable_tools}" != "no" && test "${enable_readline}" != "no"  ); then
+	AC_CHECK_HEADERS(readline/readline.h, dummy=yes,
+		AC_MSG_ERROR(readline header files are required))
+fi
+AM_CONDITIONAL(READLINE, test "${enable_readline}" != "no")
+
+AC_ARG_ENABLE(usb, AC_HELP_STRING([--disable-usb],
+			[disable USB support]), [enable_usb=${enableval}])
+if (test "${enable_tools}" != "no" && test "${enable_usb}" != "no"  ); then
+	PKG_CHECK_MODULES(USB, libusb, dummy=yes,
+			AC_MSG_ERROR(USB library support is required))
+	AC_SUBST(USB_CFLAGS)
+	AC_SUBST(USB_LIBS)
+	AC_CHECK_LIB(usb, usb_get_busses, dummy=yes,
+		AC_DEFINE(NEED_USB_GET_BUSSES, 1,
+			[Define to 1 if you need the usb_get_busses() function.]
+))
+	AC_CHECK_LIB(usb, usb_interrupt_read, dummy=yes,
+		AC_DEFINE(NEED_USB_INTERRUPT_READ, 1,
+			[Define to 1 if you need the usb_interrupt_read() functi
+on.]))
+	AC_DEFINE(HAVE_LIBUSB, 1, [Define to 1 if you have USB library.])
+fi
+AM_CONDITIONAL(USB, test "${enable_usb}" != "no")
+
+AC_ARG_ENABLE(udev, AC_HELP_STRING([--disable-udev],
+			[disable udev device support]),
+						[enable_udev=${enableval}])
+if (test "${enable_udev}" != "no"); then
+	PKG_CHECK_MODULES(UDEV, libudev >= 143, [enable_udev="yes"],
+				AC_MSG_ERROR(libudev >= 143 is required))
+	AC_CHECK_LIB(udev, udev_hwdb_new,
+		AC_DEFINE(HAVE_UDEV_HWDB_NEW, 1,
+			[Define to 1 if you have the udev_hwdb_new() function.]))
+	UDEV_DATADIR="`$PKG_CONFIG --variable=udevdir udev`"
+	if (test -z "${UDEV_DATADIR}"); then
+		UDEV_DATADIR="${sysconfdir}/udev/rules.d"
+	else
+		UDEV_DATADIR="${UDEV_DATADIR}/rules.d"
+	fi
+	AC_SUBST(UDEV_DATADIR)
+	UDEV_DIR="`$PKG_CONFIG --variable=udevdir udev`"
+	if (test -z "${UDEV_DIR}"); then
+		UDEV_DIR="${libdir}/udev"
+	fi
+	AC_SUBST(UDEV_DIR)
+fi
+AC_SUBST(UDEV_CFLAGS)
+AC_SUBST(UDEV_LIBS)
+AM_CONDITIONAL(UDEV, test "${enable_udev}" != "no")
+
+AM_CONDITIONAL(HID2HCI, test "${enable_udev}" != "no" &&
+						test "${enable_usb}" != "no")
+AM_CONDITIONAL(CUPS, test "${enable_tools}" = "yes")
+
+AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--disable-datafiles],
+			[do not install configuration and data files]),
+					[enable_datafiles=${enableval}])
+AM_CONDITIONAL(DATAFILES, test "${enable_datafiles}" != "no")
+
+AC_ARG_ENABLE(experimental, AC_HELP_STRING([--enable-experimental],
+			[enable experimental plugins (SAP, NFC, ...)]),
+					[enable_experimental=${enableval}])
+AM_CONDITIONAL(EXPERIMENTAL, test "${enable_experimental}" = "yes")
+
+if (test "${prefix}" = "NONE"); then
+	dnl no prefix and no localstatedir, so default to /var
+	if (test "$localstatedir" = '${prefix}/var'); then
+		AC_SUBST([localstatedir], ['/var'])
+	fi
+
+	prefix="${ac_default_prefix}"
+fi
+
+if (test "$localstatedir" = '${prefix}/var'); then
+	storagedir="${prefix}/var/lib/bluetooth"
+else
+	storagedir="${localstatedir}/lib/bluetooth"
+fi
+AC_DEFINE_UNQUOTED(STORAGEDIR, "${storagedir}",
+			[Directory for the storage files])
+
+if (test "$sysconfdir" = '${prefix}/etc'); then
+	configdir="${prefix}/etc/bluetooth"
+else
+	configdir="${sysconfdir}/bluetooth"
+fi
+AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}",
+			[Directory for the configuration files])
+
 AC_OUTPUT(Makefile doc/version.xml src/bluetoothd.8 bluez.pc)