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], [
14 if (test "${CFLAGS}" = ""); then
17 if (test "$USE_MAINTAINER_MODE" = "yes"); then
18 CFLAGS+=" -Werror -Wextra"
19 CFLAGS+=" -Wno-unused-parameter"
20 CFLAGS+=" -Wno-missing-field-initializers"
21 CFLAGS+=" -Wdeclaration-after-statement"
22 CFLAGS+=" -Wmissing-declarations"
23 CFLAGS+=" -Wredundant-decls"
24 CFLAGS+=" -Wcast-align"
28 AC_DEFUN([GTK_DOC_CHECK], [
29 AC_ARG_WITH([html-dir],
30 AS_HELP_STRING([--with-html-dir=PATH], [path to installed docs]),,
31 [with_html_dir='${datadir}/gtk-doc/html'])
32 HTML_DIR="$with_html_dir"
35 AC_ARG_ENABLE([gtk-doc],
36 AS_HELP_STRING([--enable-gtk-doc], [use gtk-doc to build documentation [[default=no]]]),,
39 if test x$enable_gtk_doc = xyes; then
41 [PKG_CHECK_EXISTS([gtk-doc],,
42 AC_MSG_ERROR([gtk-doc not installed and --enable-gtk-doc requested]))],
43 [PKG_CHECK_EXISTS([gtk-doc >= $1],,
44 AC_MSG_ERROR([You need to have gtk-doc >= $1 installed to build gtk-doc]))])
47 AC_MSG_CHECKING([whether to build gtk-doc documentation])
48 AC_MSG_RESULT($enable_gtk_doc)
50 AC_PATH_PROGS(GTKDOC_CHECK,gtkdoc-check,)
52 AM_CONDITIONAL([ENABLE_GTK_DOC], [test x$enable_gtk_doc = xyes])
53 AM_CONDITIONAL([GTK_DOC_USE_LIBTOOL], [test -n "$LIBTOOL"])
56 AC_DEFUN([AC_FUNC_PPOLL], [
57 AC_CHECK_FUNC(ppoll, dummy=yes, AC_DEFINE(NEED_PPOLL, 1,
58 [Define to 1 if you need the ppoll() function.]))
61 AC_DEFUN([AC_INIT_BLUEZ], [
62 AC_PREFIX_DEFAULT(/usr/local)
64 if (test "${prefix}" = "NONE"); then
65 dnl no prefix and no sysconfdir, so default to /etc
66 if (test "$sysconfdir" = '${prefix}/etc'); then
67 AC_SUBST([sysconfdir], ['/etc'])
70 dnl no prefix and no localstatedir, so default to /var
71 if (test "$localstatedir" = '${prefix}/var'); then
72 AC_SUBST([localstatedir], ['/var'])
75 dnl no prefix and no libexecdir, so default to /lib
76 if (test "$libexecdir" = '${exec_prefix}/libexec'); then
77 AC_SUBST([libexecdir], ['/lib'])
80 dnl no prefix and no mandir, so use ${prefix}/share/man as default
81 if (test "$mandir" = '${prefix}/man'); then
82 AC_SUBST([mandir], ['${prefix}/share/man'])
85 prefix="${ac_default_prefix}"
88 if (test "${libdir}" = '${exec_prefix}/lib'); then
89 libdir="${prefix}/lib"
92 plugindir="${libdir}/bluetooth/plugins"
94 if (test "$sysconfdir" = '${prefix}/etc'); then
95 configdir="${prefix}/etc/bluetooth"
97 configdir="${sysconfdir}/bluetooth"
100 if (test "$localstatedir" = '${prefix}/var'); then
101 storagedir="${prefix}/var/lib/bluetooth"
103 storagedir="${localstatedir}/lib/bluetooth"
106 AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}",
107 [Directory for the configuration files])
108 AC_DEFINE_UNQUOTED(STORAGEDIR, "${storagedir}",
109 [Directory for the storage files])
111 AC_SUBST(CONFIGDIR, "${configdir}")
112 AC_SUBST(STORAGEDIR, "${storagedir}")
114 UDEV_DATADIR="`$PKG_CONFIG --variable=udevdir udev`"
115 if (test -z "${UDEV_DATADIR}"); then
116 UDEV_DATADIR="${sysconfdir}/udev/rules.d"
118 UDEV_DATADIR="${UDEV_DATADIR}/rules.d"
120 AC_SUBST(UDEV_DATADIR)
123 AC_DEFUN([AC_PATH_DBUS], [
124 PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.0, dummy=yes,
125 AC_MSG_ERROR(D-Bus library is required))
126 AC_CHECK_LIB(dbus-1, dbus_watch_get_unix_fd, dummy=yes,
127 AC_DEFINE(NEED_DBUS_WATCH_GET_UNIX_FD, 1,
128 [Define to 1 if you need the dbus_watch_get_unix_fd() function.]))
129 AC_SUBST(DBUS_CFLAGS)
133 AC_DEFUN([AC_PATH_GLIB], [
134 PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.14, dummy=yes,
135 AC_MSG_ERROR(GLib library version 2.14 or later is required))
136 AC_SUBST(GLIB_CFLAGS)
140 AC_DEFUN([AC_PATH_GSTREAMER], [
141 PKG_CHECK_MODULES(GSTREAMER, gstreamer-0.10 gstreamer-plugins-base-0.10, gstreamer_found=yes, gstreamer_found=no)
142 AC_SUBST(GSTREAMER_CFLAGS)
143 AC_SUBST(GSTREAMER_LIBS)
144 GSTREAMER_PLUGINSDIR=`$PKG_CONFIG --variable=pluginsdir gstreamer-0.10`
145 AC_SUBST(GSTREAMER_PLUGINSDIR)
148 AC_DEFUN([AC_PATH_PULSE], [
149 PKG_CHECK_MODULES(PULSE, libpulse, pulse_found=yes, pulse_found=no)
150 AC_SUBST(PULSE_CFLAGS)
154 AC_DEFUN([AC_PATH_ALSA], [
155 PKG_CHECK_MODULES(ALSA, alsa, alsa_found=yes, alsa_found=no)
156 AC_CHECK_LIB(rt, clock_gettime, ALSA_LIBS="$ALSA_LIBS -lrt", alsa_found=no)
157 AC_SUBST(ALSA_CFLAGS)
161 AC_DEFUN([AC_PATH_USB], [
162 PKG_CHECK_MODULES(USB, libusb, usb_found=yes, usb_found=no)
165 AC_CHECK_LIB(usb, usb_get_busses, dummy=yes,
166 AC_DEFINE(NEED_USB_GET_BUSSES, 1,
167 [Define to 1 if you need the usb_get_busses() function.]))
168 AC_CHECK_LIB(usb, usb_interrupt_read, dummy=yes,
169 AC_DEFINE(NEED_USB_INTERRUPT_READ, 1,
170 [Define to 1 if you need the usb_interrupt_read() function.]))
173 AC_DEFUN([AC_PATH_NETLINK], [
174 PKG_CHECK_MODULES(NETLINK, libnl-1, netlink_found=yes, netlink_found=no)
175 AC_SUBST(NETLINK_CFLAGS)
176 AC_SUBST(NETLINK_LIBS)
179 AC_DEFUN([AC_PATH_SNDFILE], [
180 PKG_CHECK_MODULES(SNDFILE, sndfile, sndfile_found=yes, sndfile_found=no)
181 AC_SUBST(SNDFILE_CFLAGS)
182 AC_SUBST(SNDFILE_LIBS)
185 AC_DEFUN([AC_ARG_BLUEZ], [
187 optimization_enable=yes
190 sndfile_enable=${sndfile_found}
192 hal_enable=${hal_found}
193 usb_enable=${usb_found}
194 alsa_enable=${alsa_found}
195 gstreamer_enable=${gstreamer_found}
213 configfiles_enable=yes
214 telephony_driver=dummy
216 AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization], [disable code optimization]), [
217 optimization_enable=${enableval}
220 AC_ARG_ENABLE(fortify, AC_HELP_STRING([--disable-fortify], [disable compile time buffer checks]), [
221 fortify_enable=${enableval}
224 AC_ARG_ENABLE(pie, AC_HELP_STRING([--disable-pie], [disable position independent executables flag]), [
225 pie_enable=${enableval}
228 AC_ARG_ENABLE(network, AC_HELP_STRING([--disable-network], [disable network plugin]), [
229 network_enable=${enableval}
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(gstreamer, AC_HELP_STRING([--enable-gstreamer], [enable GStreamer support]), [
249 gstreamer_enable=${enableval}
252 AC_ARG_ENABLE(alsa, AC_HELP_STRING([--enable-alsa], [enable ALSA support]), [
253 alsa_enable=${enableval}
256 AC_ARG_ENABLE(usb, AC_HELP_STRING([--enable-usb], [enable USB support]), [
257 usb_enable=${enableval}
260 AC_ARG_ENABLE(netlink, AC_HELP_STRING([--enable-netlink], [enable NETLINK support]), [
261 netlink_enable=${enableval}
264 AC_ARG_ENABLE(tools, AC_HELP_STRING([--enable-tools], [install Bluetooth utilities]), [
265 tools_enable=${enableval}
268 AC_ARG_ENABLE(bccmd, AC_HELP_STRING([--enable-bccmd], [install BCCMD interface utility]), [
269 bccmd_enable=${enableval}
272 AC_ARG_ENABLE(pcmcia, AC_HELP_STRING([--enable-pcmcia], [install PCMCIA serial script]), [
273 pcmcia_enable=${enableval}
276 AC_ARG_ENABLE(hid2hci, AC_HELP_STRING([--enable-hid2hci], [install HID mode switching utility]), [
277 hid2hci_enable=${enableval}
280 AC_ARG_ENABLE(dfutool, AC_HELP_STRING([--enable-dfutool], [install DFU firmware upgrade utility]), [
281 dfutool_enable=${enableval}
284 AC_ARG_ENABLE(hidd, AC_HELP_STRING([--enable-hidd], [install HID daemon]), [
285 hidd_enable=${enableval}
288 AC_ARG_ENABLE(pand, AC_HELP_STRING([--enable-pand], [install PAN daemon]), [
289 pand_enable=${enableval}
292 AC_ARG_ENABLE(dund, AC_HELP_STRING([--enable-dund], [install DUN daemon]), [
293 dund_enable=${enableval}
296 AC_ARG_ENABLE(cups, AC_HELP_STRING([--enable-cups], [install CUPS backend support]), [
297 cups_enable=${enableval}
300 AC_ARG_ENABLE(test, AC_HELP_STRING([--enable-test], [install test programs]), [
301 test_enable=${enableval}
304 AC_ARG_ENABLE(manpages, AC_HELP_STRING([--enable-manpages], [install Bluetooth manual pages]), [
305 manpages_enable=${enableval}
308 AC_ARG_ENABLE(udevrules, AC_HELP_STRING([--enable-udevrules], [install Bluetooth udev rules]), [
309 udevrules_enable=${enableval}
312 AC_ARG_ENABLE(configfiles, AC_HELP_STRING([--enable-configfiles], [install Bluetooth configuration files]), [
313 configfiles_enable=${enableval}
316 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [enable compiling with debugging information]), [
317 debug_enable=${enableval}
320 AC_ARG_WITH(telephony, AC_HELP_STRING([--with-telephony=DRIVER], [select telephony driver]), [
321 telephony_driver=${withval}
324 AC_SUBST([TELEPHONY_DRIVER], [telephony-${telephony_driver}.c])
326 if (test "${fortify_enable}" = "yes"); then
327 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
330 if (test "${pie_enable}" = "yes" && test "${ac_cv_prog_cc_pie}" = "yes"); then
331 CFLAGS="$CFLAGS -fPIC"
332 LDFLAGS="$LDFLAGS -pie"
335 if (test "${debug_enable}" = "yes" && test "${ac_cv_prog_cc_g}" = "yes"); then
339 if (test "${optimization_enable}" = "no"); then
343 if (test "${usb_enable}" = "yes" && test "${usb_found}" = "yes"); then
344 AC_DEFINE(HAVE_LIBUSB, 1, [Define to 1 if you have USB library.])
347 AC_SUBST([BLUEZ_CFLAGS], ['-I$(top_builddir)/include'])
348 AC_SUBST([BLUEZ_LIBS], ['$(top_builddir)/lib/libbluetooth.la'])
350 AC_SUBST([GDBUS_CFLAGS], ['-I$(top_srcdir)/gdbus'])
351 AC_SUBST([GDBUS_LIBS], ['$(top_builddir)/gdbus/libgdbus.la'])
353 AC_SUBST([SBC_CFLAGS], ['-I$(top_srcdir)/sbc'])
354 AC_SUBST([SBC_LIBS], ['$(top_builddir)/sbc/libsbc.la'])
356 AM_CONDITIONAL(SNDFILE, test "${sndfile_enable}" = "yes" && test "${sndfile_found}" = "yes")
357 AM_CONDITIONAL(NETLINK, test "${netlink_enable}" = "yes" && test "${netlink_found}" = "yes")
358 AM_CONDITIONAL(USB, test "${usb_enable}" = "yes" && test "${usb_found}" = "yes")
359 AM_CONDITIONAL(SBC, test "${alsa_enable}" = "yes" || test "${gstreamer_enable}" = "yes")
360 AM_CONDITIONAL(ALSA, test "${alsa_enable}" = "yes" && test "${alsa_found}" = "yes")
361 AM_CONDITIONAL(GSTREAMER, test "${gstreamer_enable}" = "yes" && test "${gstreamer_found}" = "yes")
362 AM_CONDITIONAL(AUDIOPLUGIN, test "${audio_enable}" = "yes")
363 AM_CONDITIONAL(INPUTPLUGIN, test "${input_enable}" = "yes")
364 AM_CONDITIONAL(SERIALPLUGIN, test "${serial_enable}" = "yes")
365 AM_CONDITIONAL(NETWORKPLUGIN, test "${network_enable}" = "yes")
366 AM_CONDITIONAL(SERVICEPLUGIN, test "${service_enable}" = "yes")
367 AM_CONDITIONAL(HIDD, test "${hidd_enable}" = "yes")
368 AM_CONDITIONAL(PAND, test "${pand_enable}" = "yes")
369 AM_CONDITIONAL(DUND, test "${dund_enable}" = "yes")
370 AM_CONDITIONAL(CUPS, test "${cups_enable}" = "yes")
371 AM_CONDITIONAL(TEST, test "${test_enable}" = "yes")
372 AM_CONDITIONAL(TOOLS, test "${tools_enable}" = "yes")
373 AM_CONDITIONAL(BCCMD, test "${bccmd_enable}" = "yes")
374 AM_CONDITIONAL(PCMCIA, test "${pcmcia_enable}" = "yes")
375 AM_CONDITIONAL(HID2HCI, test "${hid2hci_enable}" = "yes" && test "${usb_found}" = "yes")
376 AM_CONDITIONAL(DFUTOOL, test "${dfutool_enable}" = "yes" && test "${usb_found}" = "yes")
377 AM_CONDITIONAL(MANPAGES, test "${manpages_enable}" = "yes")
378 AM_CONDITIONAL(UDEVRULES, test "${udevrules_enable}" = "yes")
379 AM_CONDITIONAL(CONFIGFILES, test "${configfiles_enable}" = "yes")