Modified supported feature for Target role in AVRCP profile
[framework/connectivity/bluez.git] / acinclude.m4
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
5                         ac_cv_prog_cc_pie=yes
6                 else
7                         ac_cv_prog_cc_pie=no
8                 fi
9                 rm -rf conftest*
10         ])
11 ])
12
13 AC_DEFUN([COMPILER_FLAGS], [
14         with_cflags=""
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"
24         fi
25
26         AC_SUBST([WARNING_CFLAGS], $with_cflags)
27 ])
28
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.]))
32 ])
33
34 AC_DEFUN([AC_INIT_BLUEZ], [
35         AC_PREFIX_DEFAULT(/usr/local)
36
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'])
41                 fi
42
43                 dnl no prefix and no localstatedir, so default to /var
44                 if (test "$localstatedir" = '${prefix}/var'); then
45                         AC_SUBST([localstatedir], ['/var'])
46                 fi
47
48                 dnl no prefix and no libexecdir, so default to /lib
49                 if (test "$libexecdir" = '${exec_prefix}/libexec'); then
50                         AC_SUBST([libexecdir], ['/lib'])
51                 fi
52
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'])
56                 fi
57
58                 prefix="${ac_default_prefix}"
59         fi
60
61         if (test "${libdir}" = '${exec_prefix}/lib'); then
62                 libdir="${prefix}/lib"
63         fi
64
65         plugindir="${libdir}/bluetooth/plugins"
66
67         if (test "$sysconfdir" = '${prefix}/etc'); then
68                 configdir="${prefix}/etc/bluetooth"
69         else
70                 configdir="${sysconfdir}/bluetooth"
71         fi
72
73         if (test "$localstatedir" = '${prefix}/var'); then
74                 storagedir="${prefix}/var/lib/bluetooth"
75         else
76                 storagedir="${localstatedir}/lib/bluetooth"
77         fi
78
79         AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}",
80                                 [Directory for the configuration files])
81         AC_DEFINE_UNQUOTED(STORAGEDIR, "${storagedir}",
82                                 [Directory for the storage files])
83
84         AC_SUBST(CONFIGDIR, "${configdir}")
85         AC_SUBST(STORAGEDIR, "${storagedir}")
86
87         UDEV_DIR="`$PKG_CONFIG --variable=udevdir udev`"
88         if (test -z "${UDEV_DIR}"); then
89                 UDEV_DIR="/lib/udev"
90         fi
91         AC_SUBST(UDEV_DIR)
92 ])
93
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))
97         AC_SUBST(DBUS_CFLAGS)
98         AC_SUBST(DBUS_LIBS)
99 ])
100
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)
105         AC_SUBST(GLIB_LIBS)
106 ])
107
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)
115 ])
116
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)
121         AC_SUBST(ALSA_LIBS)
122 ])
123
124 AC_DEFUN([AC_PATH_USB], [
125         PKG_CHECK_MODULES(USB, libusb, usb_found=yes, usb_found=no)
126         AC_SUBST(USB_CFLAGS)
127         AC_SUBST(USB_LIBS)
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.]))
134 ])
135
136 AC_DEFUN([AC_PATH_UDEV], [
137         PKG_CHECK_MODULES(UDEV, libudev, udev_found=yes, udev_found=no)
138         AC_SUBST(UDEV_CFLAGS)
139         AC_SUBST(UDEV_LIBS)
140 ])
141
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)
146 ])
147
148 AC_DEFUN([AC_PATH_READLINE], [
149         AC_CHECK_HEADER(readline/readline.h,
150                 AC_CHECK_LIB(readline, main,
151                         [ readline_found=yes
152                         AC_SUBST(READLINE_LIBS, "-lreadline")
153                         ], readline_found=no),
154                 [])
155 ])
156
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)
160         AC_SUBST(CHECK_LIBS)
161 ])
162
163 AC_DEFUN([AC_PATH_OUI], [
164         AC_ARG_WITH(ouifile,
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])
169 ])
170
171 AC_DEFUN([AC_ARG_BLUEZ], [
172         debug_enable=no
173         optimization_enable=yes
174         fortify_enable=yes
175         pie_enable=yes
176         sndfile_enable=${sndfile_found}
177         hal_enable=no
178         usb_enable=${usb_found}
179         alsa_enable=${alsa_found}
180         gstreamer_enable=${gstreamer_found}
181         audio_enable=yes
182         input_enable=yes
183         serial_enable=yes
184         network_enable=yes
185         sap_enable=no
186         service_enable=yes
187         health_enable=no
188         pnat_enable=no
189         tools_enable=yes
190         hidd_enable=no
191         pand_enable=no
192         dund_enable=no
193         cups_enable=no
194         test_enable=no
195         bccmd_enable=no
196         pcmcia_enable=no
197         hid2hci_enable=no
198         dfutool_enable=no
199         datafiles_enable=yes
200         telephony_driver=dummy
201         maemo6_enable=no
202         sap_driver=dummy
203         dbusoob_enable=no
204         wiimote_enable=no
205         gatt_enable=no
206
207         AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization], [disable code optimization]), [
208                 optimization_enable=${enableval}
209         ])
210
211         AC_ARG_ENABLE(fortify, AC_HELP_STRING([--disable-fortify], [disable compile time buffer checks]), [
212                 fortify_enable=${enableval}
213         ])
214
215         AC_ARG_ENABLE(pie, AC_HELP_STRING([--disable-pie], [disable position independent executables flag]), [
216                 pie_enable=${enableval}
217         ])
218
219         AC_ARG_ENABLE(network, AC_HELP_STRING([--disable-network], [disable network plugin]), [
220                 network_enable=${enableval}
221         ])
222
223         AC_ARG_ENABLE(sap, AC_HELP_STRING([--enable-sap], [enable sap plugin]), [
224                 sap_enable=${enableval}
225         ])
226
227         AC_ARG_WITH(sap, AC_HELP_STRING([--with-sap=DRIVER], [select SAP driver]), [
228                 sap_driver=${withval}
229         ])
230         AC_SUBST([SAP_DRIVER], [sap-${sap_driver}.c])
231
232         AC_ARG_ENABLE(serial, AC_HELP_STRING([--disable-serial], [disable serial plugin]), [
233                 serial_enable=${enableval}
234         ])
235
236         AC_ARG_ENABLE(input, AC_HELP_STRING([--disable-input], [disable input plugin]), [
237                 input_enable=${enableval}
238         ])
239
240         AC_ARG_ENABLE(audio, AC_HELP_STRING([--disable-audio], [disable audio plugin]), [
241                 audio_enable=${enableval}
242         ])
243
244         AC_ARG_ENABLE(service, AC_HELP_STRING([--disable-service], [disable service plugin]), [
245                 service_enable=${enableval}
246         ])
247
248         AC_ARG_ENABLE(health, AC_HELP_STRING([--enable-health], [enable health plugin]), [
249                 health_enable=${enableval}
250         ])
251
252         AC_ARG_ENABLE(pnat, AC_HELP_STRING([--enable-pnat], [enable pnat plugin]), [
253                 pnat_enable=${enableval}
254         ])
255
256         AC_ARG_ENABLE(gstreamer, AC_HELP_STRING([--enable-gstreamer], [enable GStreamer support]), [
257                 gstreamer_enable=${enableval}
258         ])
259
260         AC_ARG_ENABLE(alsa, AC_HELP_STRING([--enable-alsa], [enable ALSA support]), [
261                 alsa_enable=${enableval}
262         ])
263
264         AC_ARG_ENABLE(usb, AC_HELP_STRING([--enable-usb], [enable USB support]), [
265                 usb_enable=${enableval}
266         ])
267
268         AC_ARG_ENABLE(tools, AC_HELP_STRING([--enable-tools], [install Bluetooth utilities]), [
269                 tools_enable=${enableval}
270         ])
271
272         AC_ARG_ENABLE(bccmd, AC_HELP_STRING([--enable-bccmd], [install BCCMD interface utility]), [
273                 bccmd_enable=${enableval}
274         ])
275
276         AC_ARG_ENABLE(pcmcia, AC_HELP_STRING([--enable-pcmcia], [install PCMCIA serial script]), [
277                 pcmcia_enable=${enableval}
278         ])
279
280         AC_ARG_ENABLE(hid2hci, AC_HELP_STRING([--enable-hid2hci], [install HID mode switching utility]), [
281                 hid2hci_enable=${enableval}
282         ])
283
284         AC_ARG_ENABLE(dfutool, AC_HELP_STRING([--enable-dfutool], [install DFU firmware upgrade utility]), [
285                 dfutool_enable=${enableval}
286         ])
287
288         AC_ARG_ENABLE(hidd, AC_HELP_STRING([--enable-hidd], [install HID daemon]), [
289                 hidd_enable=${enableval}
290         ])
291
292         AC_ARG_ENABLE(pand, AC_HELP_STRING([--enable-pand], [install PAN daemon]), [
293                 pand_enable=${enableval}
294         ])
295
296         AC_ARG_ENABLE(dund, AC_HELP_STRING([--enable-dund], [install DUN daemon]), [
297                 dund_enable=${enableval}
298         ])
299
300         AC_ARG_ENABLE(cups, AC_HELP_STRING([--enable-cups], [install CUPS backend support]), [
301                 cups_enable=${enableval}
302         ])
303
304         AC_ARG_ENABLE(test, AC_HELP_STRING([--enable-test], [install test programs]), [
305                 test_enable=${enableval}
306         ])
307
308         AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--enable-datafiles], [install Bluetooth configuration and data files]), [
309                 datafiles_enable=${enableval}
310         ])
311
312         AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [enable compiling with debugging information]), [
313                 debug_enable=${enableval}
314         ])
315
316         AC_ARG_WITH(telephony, AC_HELP_STRING([--with-telephony=DRIVER], [select telephony driver]), [
317                 telephony_driver=${withval}
318         ])
319
320         AC_SUBST([TELEPHONY_DRIVER], [telephony-${telephony_driver}.c])
321
322         AC_ARG_ENABLE(maemo6, AC_HELP_STRING([--enable-maemo6], [compile with maemo6 plugin]), [
323                 maemo6_enable=${enableval}
324         ])
325
326         AC_ARG_ENABLE(dbusoob, AC_HELP_STRING([--enable-dbusoob], [compile with D-Bus OOB plugin]), [
327                 dbusoob_enable=${enableval}
328         ])
329
330         AC_ARG_ENABLE(wiimote, AC_HELP_STRING([--enable-wiimote], [compile with Wii Remote plugin]), [
331                 wiimote_enable=${enableval}
332         ])
333
334         AC_ARG_ENABLE(hal, AC_HELP_STRING([--enable-hal], [Use HAL to determine adapter class]), [
335                 hal_enable=${enableval}
336         ])
337
338         AC_ARG_ENABLE(gatt, AC_HELP_STRING([--enable-gatt], [enable gatt module]), [
339                 gatt_enable=${enableval}
340         ])
341
342         misc_cflags=""
343         misc_ldflags=""
344
345         if (test "${fortify_enable}" = "yes"); then
346                 misc_cflags="$misc_cflags -D_FORTIFY_SOURCE=2"
347         fi
348
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"
352         fi
353
354         if (test "${debug_enable}" = "yes" && test "${ac_cv_prog_cc_g}" = "yes"); then
355                 misc_cflags="$misc_cflags -g"
356         fi
357
358         if (test "${optimization_enable}" = "no"); then
359                 misc_cflags="$misc_cflags -O0"
360         fi
361
362         AC_SUBST([MISC_CFLAGS], $misc_cflags)
363         AC_SUBST([MISC_LDFLAGS], $misc_ldflags)
364
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.])
367         fi
368
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")
401 ])