1 AC_DEFUN([AC_PROG_CC_PIE], [
2 AC_CACHE_CHECK([whether ${CC-cc} accepts -fPIE], ac_cv_prog_cc_pie, [
3 echo 'void f(){}' > conftest.c
4 if test -z "`${CC-cc} -fPIE -pie -c conftest.c 2>&1`"; then
13 AC_DEFUN([COMPILER_FLAGS], [
15 if (test "$USE_MAINTAINER_MODE" = "yes"); then
16 with_cflags="$with_cflags -Wall -Werror -Wextra"
17 with_cflags="$with_cflags -Wno-unused-parameter"
18 with_cflags="$with_cflags -Wno-missing-field-initializers"
19 with_cflags="$with_cflags -Wdeclaration-after-statement"
20 with_cflags="$with_cflags -Wmissing-declarations"
21 with_cflags="$with_cflags -Wredundant-decls"
22 with_cflags="$with_cflags -Wcast-align"
23 with_cflags="$with_cflags -DG_DISABLE_DEPRECATED"
26 AC_SUBST([WARNING_CFLAGS], $with_cflags)
29 AC_DEFUN([AC_FUNC_PPOLL], [
30 AC_CHECK_FUNC(ppoll, dummy=yes, AC_DEFINE(NEED_PPOLL, 1,
31 [Define to 1 if you need the ppoll() function.]))
34 AC_DEFUN([AC_INIT_BLUEZ], [
35 AC_PREFIX_DEFAULT(/usr/local)
37 if (test "${prefix}" = "NONE"); then
38 dnl no prefix and no sysconfdir, so default to /etc
39 if (test "$sysconfdir" = '${prefix}/etc'); then
40 AC_SUBST([sysconfdir], ['/etc'])
43 dnl no prefix and no localstatedir, so default to /var
44 if (test "$localstatedir" = '${prefix}/var'); then
45 AC_SUBST([localstatedir], ['/var'])
48 dnl no prefix and no libexecdir, so default to /lib
49 if (test "$libexecdir" = '${exec_prefix}/libexec'); then
50 AC_SUBST([libexecdir], ['/lib'])
53 dnl no prefix and no mandir, so use ${prefix}/share/man as default
54 if (test "$mandir" = '${prefix}/man'); then
55 AC_SUBST([mandir], ['${prefix}/share/man'])
58 prefix="${ac_default_prefix}"
61 if (test "${libdir}" = '${exec_prefix}/lib'); then
62 libdir="${prefix}/lib"
65 plugindir="${libdir}/bluetooth/plugins"
67 if (test "$sysconfdir" = '${prefix}/etc'); then
68 configdir="${prefix}/etc/bluetooth"
70 configdir="${sysconfdir}/bluetooth"
73 if (test "$localstatedir" = '${prefix}/var'); then
74 storagedir="${prefix}/var/lib/bluetooth"
76 storagedir="${localstatedir}/lib/bluetooth"
79 AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}",
80 [Directory for the configuration files])
81 AC_DEFINE_UNQUOTED(STORAGEDIR, "${storagedir}",
82 [Directory for the storage files])
84 AC_SUBST(CONFIGDIR, "${configdir}")
85 AC_SUBST(STORAGEDIR, "${storagedir}")
87 UDEV_DIR="`$PKG_CONFIG --variable=udevdir udev`"
88 if (test -z "${UDEV_DIR}"); then
94 AC_DEFUN([AC_PATH_DBUS], [
95 PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.4, dummy=yes,
96 AC_MSG_ERROR(D-Bus >= 1.4 is required))
101 AC_DEFUN([AC_PATH_GLIB], [
102 PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28, dummy=yes,
103 AC_MSG_ERROR(GLib >= 2.28 is required))
104 AC_SUBST(GLIB_CFLAGS)
108 AC_DEFUN([AC_PATH_GSTREAMER], [
109 PKG_CHECK_MODULES(GSTREAMER, gstreamer-0.10 >= 0.10.30 gstreamer-plugins-base-0.10, gstreamer_found=yes,
110 AC_MSG_WARN(GStreamer library version 0.10.30 or later is required);gstreamer_found=no)
111 AC_SUBST(GSTREAMER_CFLAGS)
112 AC_SUBST(GSTREAMER_LIBS)
113 GSTREAMER_PLUGINSDIR=`$PKG_CONFIG --variable=pluginsdir gstreamer-0.10`
114 AC_SUBST(GSTREAMER_PLUGINSDIR)
117 AC_DEFUN([AC_PATH_ALSA], [
118 PKG_CHECK_MODULES(ALSA, alsa, alsa_found=yes, alsa_found=no)
119 AC_CHECK_LIB(rt, clock_gettime, ALSA_LIBS="$ALSA_LIBS -lrt", alsa_found=no)
120 AC_SUBST(ALSA_CFLAGS)
124 AC_DEFUN([AC_PATH_USB], [
125 PKG_CHECK_MODULES(USB, libusb, usb_found=yes, usb_found=no)
128 AC_CHECK_LIB(usb, usb_get_busses, dummy=yes,
129 AC_DEFINE(NEED_USB_GET_BUSSES, 1,
130 [Define to 1 if you need the usb_get_busses() function.]))
131 AC_CHECK_LIB(usb, usb_interrupt_read, dummy=yes,
132 AC_DEFINE(NEED_USB_INTERRUPT_READ, 1,
133 [Define to 1 if you need the usb_interrupt_read() function.]))
136 AC_DEFUN([AC_PATH_UDEV], [
137 PKG_CHECK_MODULES(UDEV, libudev, udev_found=yes, udev_found=no)
138 AC_SUBST(UDEV_CFLAGS)
142 AC_DEFUN([AC_PATH_SNDFILE], [
143 PKG_CHECK_MODULES(SNDFILE, sndfile, sndfile_found=yes, sndfile_found=no)
144 AC_SUBST(SNDFILE_CFLAGS)
145 AC_SUBST(SNDFILE_LIBS)
148 AC_DEFUN([AC_PATH_READLINE], [
149 AC_CHECK_HEADER(readline/readline.h,
150 AC_CHECK_LIB(readline, main,
152 AC_SUBST(READLINE_LIBS, "-lreadline")
153 ], readline_found=no),
157 AC_DEFUN([AC_PATH_CHECK], [
158 PKG_CHECK_MODULES(CHECK, check >= 0.9.6, check_found=yes, check_found=no)
159 AC_SUBST(CHECK_CFLAGS)
163 AC_DEFUN([AC_PATH_OUI], [
165 AS_HELP_STRING([--with-ouifile=PATH],[Path to the oui.txt file @<:@auto@:>@]),
166 [ac_with_ouifile=$withval],
167 [ac_with_ouifile="/var/lib/misc/oui.txt"])
168 AC_DEFINE_UNQUOTED(OUIFILE, ["$ac_with_ouifile"], [Define the OUI file path])
171 AC_DEFUN([AC_ARG_BLUEZ], [
173 optimization_enable=yes
176 sndfile_enable=${sndfile_found}
178 usb_enable=${usb_found}
179 alsa_enable=${alsa_found}
180 gstreamer_enable=${gstreamer_found}
200 telephony_driver=dummy
207 AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization], [disable code optimization]), [
208 optimization_enable=${enableval}
211 AC_ARG_ENABLE(fortify, AC_HELP_STRING([--disable-fortify], [disable compile time buffer checks]), [
212 fortify_enable=${enableval}
215 AC_ARG_ENABLE(pie, AC_HELP_STRING([--disable-pie], [disable position independent executables flag]), [
216 pie_enable=${enableval}
219 AC_ARG_ENABLE(network, AC_HELP_STRING([--disable-network], [disable network plugin]), [
220 network_enable=${enableval}
223 AC_ARG_ENABLE(sap, AC_HELP_STRING([--enable-sap], [enable sap plugin]), [
224 sap_enable=${enableval}
227 AC_ARG_WITH(sap, AC_HELP_STRING([--with-sap=DRIVER], [select SAP driver]), [
228 sap_driver=${withval}
230 AC_SUBST([SAP_DRIVER], [sap-${sap_driver}.c])
232 AC_ARG_ENABLE(serial, AC_HELP_STRING([--disable-serial], [disable serial plugin]), [
233 serial_enable=${enableval}
236 AC_ARG_ENABLE(input, AC_HELP_STRING([--disable-input], [disable input plugin]), [
237 input_enable=${enableval}
240 AC_ARG_ENABLE(audio, AC_HELP_STRING([--disable-audio], [disable audio plugin]), [
241 audio_enable=${enableval}
244 AC_ARG_ENABLE(service, AC_HELP_STRING([--disable-service], [disable service plugin]), [
245 service_enable=${enableval}
248 AC_ARG_ENABLE(health, AC_HELP_STRING([--enable-health], [enable health plugin]), [
249 health_enable=${enableval}
252 AC_ARG_ENABLE(pnat, AC_HELP_STRING([--enable-pnat], [enable pnat plugin]), [
253 pnat_enable=${enableval}
256 AC_ARG_ENABLE(gstreamer, AC_HELP_STRING([--enable-gstreamer], [enable GStreamer support]), [
257 gstreamer_enable=${enableval}
260 AC_ARG_ENABLE(alsa, AC_HELP_STRING([--enable-alsa], [enable ALSA support]), [
261 alsa_enable=${enableval}
264 AC_ARG_ENABLE(usb, AC_HELP_STRING([--enable-usb], [enable USB support]), [
265 usb_enable=${enableval}
268 AC_ARG_ENABLE(tools, AC_HELP_STRING([--enable-tools], [install Bluetooth utilities]), [
269 tools_enable=${enableval}
272 AC_ARG_ENABLE(bccmd, AC_HELP_STRING([--enable-bccmd], [install BCCMD interface utility]), [
273 bccmd_enable=${enableval}
276 AC_ARG_ENABLE(pcmcia, AC_HELP_STRING([--enable-pcmcia], [install PCMCIA serial script]), [
277 pcmcia_enable=${enableval}
280 AC_ARG_ENABLE(hid2hci, AC_HELP_STRING([--enable-hid2hci], [install HID mode switching utility]), [
281 hid2hci_enable=${enableval}
284 AC_ARG_ENABLE(dfutool, AC_HELP_STRING([--enable-dfutool], [install DFU firmware upgrade utility]), [
285 dfutool_enable=${enableval}
288 AC_ARG_ENABLE(hidd, AC_HELP_STRING([--enable-hidd], [install HID daemon]), [
289 hidd_enable=${enableval}
292 AC_ARG_ENABLE(pand, AC_HELP_STRING([--enable-pand], [install PAN daemon]), [
293 pand_enable=${enableval}
296 AC_ARG_ENABLE(dund, AC_HELP_STRING([--enable-dund], [install DUN daemon]), [
297 dund_enable=${enableval}
300 AC_ARG_ENABLE(cups, AC_HELP_STRING([--enable-cups], [install CUPS backend support]), [
301 cups_enable=${enableval}
304 AC_ARG_ENABLE(test, AC_HELP_STRING([--enable-test], [install test programs]), [
305 test_enable=${enableval}
308 AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--enable-datafiles], [install Bluetooth configuration and data files]), [
309 datafiles_enable=${enableval}
312 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [enable compiling with debugging information]), [
313 debug_enable=${enableval}
316 AC_ARG_WITH(telephony, AC_HELP_STRING([--with-telephony=DRIVER], [select telephony driver]), [
317 telephony_driver=${withval}
320 AC_SUBST([TELEPHONY_DRIVER], [telephony-${telephony_driver}.c])
322 AC_ARG_ENABLE(maemo6, AC_HELP_STRING([--enable-maemo6], [compile with maemo6 plugin]), [
323 maemo6_enable=${enableval}
326 AC_ARG_ENABLE(dbusoob, AC_HELP_STRING([--enable-dbusoob], [compile with D-Bus OOB plugin]), [
327 dbusoob_enable=${enableval}
330 AC_ARG_ENABLE(wiimote, AC_HELP_STRING([--enable-wiimote], [compile with Wii Remote plugin]), [
331 wiimote_enable=${enableval}
334 AC_ARG_ENABLE(hal, AC_HELP_STRING([--enable-hal], [Use HAL to determine adapter class]), [
335 hal_enable=${enableval}
338 AC_ARG_ENABLE(gatt, AC_HELP_STRING([--enable-gatt], [enable gatt module]), [
339 gatt_enable=${enableval}
345 if (test "${fortify_enable}" = "yes"); then
346 misc_cflags="$misc_cflags -D_FORTIFY_SOURCE=2"
349 if (test "${pie_enable}" = "yes" && test "${ac_cv_prog_cc_pie}" = "yes"); then
350 misc_cflags="$misc_cflags -fPIC"
351 misc_ldflags="$misc_ldflags -pie"
354 if (test "${debug_enable}" = "yes" && test "${ac_cv_prog_cc_g}" = "yes"); then
355 misc_cflags="$misc_cflags -g"
358 if (test "${optimization_enable}" = "no"); then
359 misc_cflags="$misc_cflags -O0"
362 AC_SUBST([MISC_CFLAGS], $misc_cflags)
363 AC_SUBST([MISC_LDFLAGS], $misc_ldflags)
365 if (test "${usb_enable}" = "yes" && test "${usb_found}" = "yes"); then
366 AC_DEFINE(HAVE_LIBUSB, 1, [Define to 1 if you have USB library.])
369 AM_CONDITIONAL(SNDFILE, test "${sndfile_enable}" = "yes" && test "${sndfile_found}" = "yes")
370 AM_CONDITIONAL(USB, test "${usb_enable}" = "yes" && test "${usb_found}" = "yes")
371 AM_CONDITIONAL(SBC, test "${alsa_enable}" = "yes" || test "${gstreamer_enable}" = "yes" ||
372 test "${test_enable}" = "yes")
373 AM_CONDITIONAL(ALSA, test "${alsa_enable}" = "yes" && test "${alsa_found}" = "yes")
374 AM_CONDITIONAL(GSTREAMER, test "${gstreamer_enable}" = "yes" && test "${gstreamer_found}" = "yes")
375 AM_CONDITIONAL(AUDIOPLUGIN, test "${audio_enable}" = "yes")
376 AM_CONDITIONAL(INPUTPLUGIN, test "${input_enable}" = "yes")
377 AM_CONDITIONAL(SERIALPLUGIN, test "${serial_enable}" = "yes")
378 AM_CONDITIONAL(NETWORKPLUGIN, test "${network_enable}" = "yes")
379 AM_CONDITIONAL(SAPPLUGIN, test "${sap_enable}" = "yes")
380 AM_CONDITIONAL(SERVICEPLUGIN, test "${service_enable}" = "yes")
381 AM_CONDITIONAL(HEALTHPLUGIN, test "${health_enable}" = "yes")
382 AM_CONDITIONAL(MCAP, test "${health_enable}" = "yes")
383 AM_CONDITIONAL(HAL, test "${hal_enable}" = "yes")
384 AM_CONDITIONAL(READLINE, test "${readline_found}" = "yes")
385 AM_CONDITIONAL(PNATPLUGIN, test "${pnat_enable}" = "yes")
386 AM_CONDITIONAL(HIDD, test "${hidd_enable}" = "yes")
387 AM_CONDITIONAL(PAND, test "${pand_enable}" = "yes")
388 AM_CONDITIONAL(DUND, test "${dund_enable}" = "yes")
389 AM_CONDITIONAL(CUPS, test "${cups_enable}" = "yes")
390 AM_CONDITIONAL(TEST, test "${test_enable}" = "yes" && test "${check_found}" = "yes")
391 AM_CONDITIONAL(TOOLS, test "${tools_enable}" = "yes")
392 AM_CONDITIONAL(BCCMD, test "${bccmd_enable}" = "yes")
393 AM_CONDITIONAL(PCMCIA, test "${pcmcia_enable}" = "yes")
394 AM_CONDITIONAL(HID2HCI, test "${hid2hci_enable}" = "yes" && test "${usb_found}" = "yes" && test "${udev_found}" = "yes")
395 AM_CONDITIONAL(DFUTOOL, test "${dfutool_enable}" = "yes" && test "${usb_found}" = "yes")
396 AM_CONDITIONAL(DATAFILES, test "${datafiles_enable}" = "yes")
397 AM_CONDITIONAL(MAEMO6PLUGIN, test "${maemo6_enable}" = "yes")
398 AM_CONDITIONAL(DBUSOOBPLUGIN, test "${dbusoob_enable}" = "yes")
399 AM_CONDITIONAL(WIIMOTEPLUGIN, test "${wiimote_enable}" = "yes")
400 AM_CONDITIONAL(GATTMODULES, test "${gatt_enable}" = "yes")