• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1AC_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
13AC_DEFUN([COMPILER_FLAGS], [
14	if (test "${CFLAGS}" = ""); then
15		CFLAGS="-Wall -O2"
16	fi
17	if (test "$USE_MAINTAINER_MODE" = "yes"); then
18		CFLAGS="$CFLAGS -Werror -Wextra"
19		CFLAGS="$CFLAGS -Wno-unused-parameter"
20		CFLAGS="$CFLAGS -Wno-missing-field-initializers"
21		CFLAGS="$CFLAGS -Wdeclaration-after-statement"
22		CFLAGS="$CFLAGS -Wmissing-declarations"
23		CFLAGS="$CFLAGS -Wredundant-decls"
24		CFLAGS="$CFLAGS -Wcast-align"
25		CFLAGS="$CFLAGS -DG_DISABLE_DEPRECATED"
26	fi
27])
28
29AC_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
34AC_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
94AC_DEFUN([AC_PATH_DBUS], [
95	PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.0, dummy=yes,
96				AC_MSG_ERROR(D-Bus library is required))
97	AC_CHECK_LIB(dbus-1, dbus_watch_get_unix_fd, dummy=yes,
98		AC_DEFINE(NEED_DBUS_WATCH_GET_UNIX_FD, 1,
99			[Define to 1 if you need the dbus_watch_get_unix_fd() function.]))
100	AC_CHECK_LIB(dbus-1, dbus_connection_can_send_type, dummy=yes,
101		AC_DEFINE(NEED_DBUS_CONNECTION_CAN_SEND_TYPE, 1,
102			[Define to 1 if you need the dbus_connection_can_send_type() function.]
103))
104	AC_SUBST(DBUS_CFLAGS)
105	AC_SUBST(DBUS_LIBS)
106])
107
108AC_DEFUN([AC_PATH_GLIB], [
109	PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,
110				AC_MSG_ERROR(GLib library version 2.16 or later is required))
111	AC_SUBST(GLIB_CFLAGS)
112	AC_SUBST(GLIB_LIBS)
113])
114
115AC_DEFUN([AC_PATH_GSTREAMER], [
116	PKG_CHECK_MODULES(GSTREAMER, gstreamer-0.10 >= 0.10.30 gstreamer-plugins-base-0.10, gstreamer_found=yes,
117				AC_MSG_WARN(GStreamer library version 0.10.30 or later is required);gstreamer_found=no)
118	AC_SUBST(GSTREAMER_CFLAGS)
119	AC_SUBST(GSTREAMER_LIBS)
120	GSTREAMER_PLUGINSDIR=`$PKG_CONFIG --variable=pluginsdir gstreamer-0.10`
121	AC_SUBST(GSTREAMER_PLUGINSDIR)
122])
123
124AC_DEFUN([AC_PATH_PULSE], [
125	PKG_CHECK_MODULES(PULSE, libpulse, pulse_found=yes, pulse_found=no)
126	AC_SUBST(PULSE_CFLAGS)
127	AC_SUBST(PULSE_LIBS)
128])
129
130AC_DEFUN([AC_PATH_ALSA], [
131	PKG_CHECK_MODULES(ALSA, alsa, alsa_found=yes, alsa_found=no)
132	AC_CHECK_LIB(rt, clock_gettime, ALSA_LIBS="$ALSA_LIBS -lrt", alsa_found=no)
133	AC_SUBST(ALSA_CFLAGS)
134	AC_SUBST(ALSA_LIBS)
135])
136
137AC_DEFUN([AC_PATH_USB], [
138	PKG_CHECK_MODULES(USB, libusb, usb_found=yes, usb_found=no)
139	AC_SUBST(USB_CFLAGS)
140	AC_SUBST(USB_LIBS)
141	AC_CHECK_LIB(usb, usb_get_busses, dummy=yes,
142		AC_DEFINE(NEED_USB_GET_BUSSES, 1,
143			[Define to 1 if you need the usb_get_busses() function.]))
144	AC_CHECK_LIB(usb, usb_interrupt_read, dummy=yes,
145		AC_DEFINE(NEED_USB_INTERRUPT_READ, 1,
146			[Define to 1 if you need the usb_interrupt_read() function.]))
147])
148
149AC_DEFUN([AC_PATH_UDEV], [
150	PKG_CHECK_MODULES(UDEV, libudev, udev_found=yes, udev_found=no)
151	AC_SUBST(UDEV_CFLAGS)
152	AC_SUBST(UDEV_LIBS)
153])
154
155AC_DEFUN([AC_PATH_SNDFILE], [
156	PKG_CHECK_MODULES(SNDFILE, sndfile, sndfile_found=yes, sndfile_found=no)
157	AC_SUBST(SNDFILE_CFLAGS)
158	AC_SUBST(SNDFILE_LIBS)
159])
160
161AC_DEFUN([AC_PATH_READLINE], [
162	AC_CHECK_HEADER(readline/readline.h,
163		AC_CHECK_LIB(readline, main,
164			[ readline_found=yes
165			AC_SUBST(READLINE_LIBS, "-lreadline")
166			], readline_found=no),
167		[])
168])
169
170AC_DEFUN([AC_PATH_OUI], [
171	AC_ARG_WITH(ouifile,
172		    AS_HELP_STRING([--with-ouifile=PATH],[Path to the oui.txt file @<:@auto@:>@]),
173		    [ac_with_ouifile=$withval],
174		    [ac_with_ouifile="/var/lib/misc/oui.txt"])
175	AC_DEFINE_UNQUOTED(OUIFILE, ["$ac_with_ouifile"], [Define the OUI file path])
176])
177
178AC_DEFUN([AC_ARG_BLUEZ], [
179	debug_enable=no
180	optimization_enable=yes
181	fortify_enable=yes
182	pie_enable=yes
183	sndfile_enable=${sndfile_found}
184	hal_enable=no
185	usb_enable=${usb_found}
186	alsa_enable=${alsa_found}
187	gstreamer_enable=${gstreamer_found}
188	audio_enable=yes
189	input_enable=yes
190	serial_enable=yes
191	network_enable=yes
192	sap_enable=no
193	service_enable=yes
194	health_enable=no
195	pnat_enable=no
196	gatt_example_enable=no
197	tracer_enable=no
198	tools_enable=yes
199	hidd_enable=no
200	pand_enable=no
201	dund_enable=no
202	cups_enable=no
203	test_enable=no
204	bccmd_enable=no
205	pcmcia_enable=no
206	hid2hci_enable=no
207	dfutool_enable=no
208	udevrules_enable=yes
209	configfiles_enable=yes
210	telephony_driver=dummy
211	maemo6_enable=no
212	sap_driver=dummy
213	dbusoob_enable=no
214
215	AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization], [disable code optimization]), [
216		optimization_enable=${enableval}
217	])
218
219	AC_ARG_ENABLE(fortify, AC_HELP_STRING([--disable-fortify], [disable compile time buffer checks]), [
220		fortify_enable=${enableval}
221	])
222
223	AC_ARG_ENABLE(pie, AC_HELP_STRING([--disable-pie], [disable position independent executables flag]), [
224		pie_enable=${enableval}
225	])
226
227	AC_ARG_ENABLE(network, AC_HELP_STRING([--disable-network], [disable network plugin]), [
228		network_enable=${enableval}
229	])
230
231	AC_ARG_ENABLE(sap, AC_HELP_STRING([--enable-sap], [enable sap plugin]), [
232		sap_enable=${enableval}
233	])
234
235	AC_ARG_WITH(sap, AC_HELP_STRING([--with-sap=DRIVER], [select SAP driver]), [
236		sap_driver=${withval}
237	])
238	AC_SUBST([SAP_DRIVER], [sap-${sap_driver}.c])
239
240	AC_ARG_ENABLE(serial, AC_HELP_STRING([--disable-serial], [disable serial plugin]), [
241		serial_enable=${enableval}
242	])
243
244	AC_ARG_ENABLE(input, AC_HELP_STRING([--disable-input], [disable input plugin]), [
245		input_enable=${enableval}
246	])
247
248	AC_ARG_ENABLE(audio, AC_HELP_STRING([--disable-audio], [disable audio plugin]), [
249		audio_enable=${enableval}
250	])
251
252	AC_ARG_ENABLE(service, AC_HELP_STRING([--disable-service], [disable service plugin]), [
253		service_enable=${enableval}
254	])
255
256	AC_ARG_ENABLE(health, AC_HELP_STRING([--enable-health], [enable health plugin]), [
257		health_enable=${enableval}
258	])
259
260	AC_ARG_ENABLE(pnat, AC_HELP_STRING([--enable-pnat], [enable pnat plugin]), [
261		pnat_enable=${enableval}
262	])
263
264	AC_ARG_ENABLE(gatt-example, AC_HELP_STRING([--enable-gatt-example], [enable GATT example plugin]), [
265		gatt_example_enable=${enableval}
266	])
267
268	AC_ARG_ENABLE(gstreamer, AC_HELP_STRING([--enable-gstreamer], [enable GStreamer support]), [
269		gstreamer_enable=${enableval}
270	])
271
272	AC_ARG_ENABLE(alsa, AC_HELP_STRING([--enable-alsa], [enable ALSA support]), [
273		alsa_enable=${enableval}
274	])
275
276	AC_ARG_ENABLE(usb, AC_HELP_STRING([--enable-usb], [enable USB support]), [
277		usb_enable=${enableval}
278	])
279
280	AC_ARG_ENABLE(tracer, AC_HELP_STRING([--enable-tracer], [install Tracing daemon]), [
281		tracer_enable=${enableval}
282	])
283
284	AC_ARG_ENABLE(tools, AC_HELP_STRING([--enable-tools], [install Bluetooth utilities]), [
285		tools_enable=${enableval}
286	])
287
288	AC_ARG_ENABLE(bccmd, AC_HELP_STRING([--enable-bccmd], [install BCCMD interface utility]), [
289		bccmd_enable=${enableval}
290	])
291
292	AC_ARG_ENABLE(pcmcia, AC_HELP_STRING([--enable-pcmcia], [install PCMCIA serial script]), [
293		pcmcia_enable=${enableval}
294	])
295
296	AC_ARG_ENABLE(hid2hci, AC_HELP_STRING([--enable-hid2hci], [install HID mode switching utility]), [
297		hid2hci_enable=${enableval}
298	])
299
300	AC_ARG_ENABLE(dfutool, AC_HELP_STRING([--enable-dfutool], [install DFU firmware upgrade utility]), [
301		dfutool_enable=${enableval}
302	])
303
304	AC_ARG_ENABLE(hidd, AC_HELP_STRING([--enable-hidd], [install HID daemon]), [
305		hidd_enable=${enableval}
306	])
307
308	AC_ARG_ENABLE(pand, AC_HELP_STRING([--enable-pand], [install PAN daemon]), [
309		pand_enable=${enableval}
310	])
311
312	AC_ARG_ENABLE(dund, AC_HELP_STRING([--enable-dund], [install DUN daemon]), [
313		dund_enable=${enableval}
314	])
315
316	AC_ARG_ENABLE(cups, AC_HELP_STRING([--enable-cups], [install CUPS backend support]), [
317		cups_enable=${enableval}
318	])
319
320	AC_ARG_ENABLE(test, AC_HELP_STRING([--enable-test], [install test programs]), [
321		test_enable=${enableval}
322	])
323
324	AC_ARG_ENABLE(udevrules, AC_HELP_STRING([--enable-udevrules], [install Bluetooth udev rules]), [
325		udevrules_enable=${enableval}
326	])
327
328	AC_ARG_ENABLE(configfiles, AC_HELP_STRING([--enable-configfiles], [install Bluetooth configuration files]), [
329		configfiles_enable=${enableval}
330	])
331
332	AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [enable compiling with debugging information]), [
333		debug_enable=${enableval}
334	])
335
336	AC_ARG_WITH(telephony, AC_HELP_STRING([--with-telephony=DRIVER], [select telephony driver]), [
337		telephony_driver=${withval}
338	])
339
340	AC_SUBST([TELEPHONY_DRIVER], [telephony-${telephony_driver}.c])
341
342	AC_ARG_ENABLE(maemo6, AC_HELP_STRING([--enable-maemo6], [compile with maemo6 plugin]), [
343		maemo6_enable=${enableval}
344	])
345
346	AC_ARG_ENABLE(dbusoob, AC_HELP_STRING([--enable-dbusoob], [compile with D-Bus OOB plugin]), [
347		dbusoob_enable=${enableval}
348	])
349
350	AC_ARG_ENABLE(hal, AC_HELP_STRING([--enable-hal], [Use HAL to determine adapter class]), [
351		hal_enable=${enableval}
352	])
353
354	if (test "${fortify_enable}" = "yes"); then
355		CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
356	fi
357
358	if (test "${pie_enable}" = "yes" && test "${ac_cv_prog_cc_pie}" = "yes"); then
359		CFLAGS="$CFLAGS -fPIC"
360		LDFLAGS="$LDFLAGS -pie"
361	fi
362
363	if (test "${debug_enable}" = "yes" && test "${ac_cv_prog_cc_g}" = "yes"); then
364		CFLAGS="$CFLAGS -g"
365	fi
366
367	if (test "${optimization_enable}" = "no"); then
368		CFLAGS="$CFLAGS -O0"
369	fi
370
371	if (test "${usb_enable}" = "yes" && test "${usb_found}" = "yes"); then
372		AC_DEFINE(HAVE_LIBUSB, 1, [Define to 1 if you have USB library.])
373	fi
374
375	AM_CONDITIONAL(SNDFILE, test "${sndfile_enable}" = "yes" && test "${sndfile_found}" = "yes")
376	AM_CONDITIONAL(USB, test "${usb_enable}" = "yes" && test "${usb_found}" = "yes")
377	AM_CONDITIONAL(SBC, test "${alsa_enable}" = "yes" || test "${gstreamer_enable}" = "yes" ||
378									test "${test_enable}" = "yes")
379	AM_CONDITIONAL(ALSA, test "${alsa_enable}" = "yes" && test "${alsa_found}" = "yes")
380	AM_CONDITIONAL(GSTREAMER, test "${gstreamer_enable}" = "yes" && test "${gstreamer_found}" = "yes")
381	AM_CONDITIONAL(AUDIOPLUGIN, test "${audio_enable}" = "yes")
382	AM_CONDITIONAL(INPUTPLUGIN, test "${input_enable}" = "yes")
383	AM_CONDITIONAL(SERIALPLUGIN, test "${serial_enable}" = "yes")
384	AM_CONDITIONAL(NETWORKPLUGIN, test "${network_enable}" = "yes")
385	AM_CONDITIONAL(SAPPLUGIN, test "${sap_enable}" = "yes")
386	AM_CONDITIONAL(SERVICEPLUGIN, test "${service_enable}" = "yes")
387	AM_CONDITIONAL(HEALTHPLUGIN, test "${health_enable}" = "yes")
388	AM_CONDITIONAL(MCAP, test "${health_enable}" = "yes")
389	AM_CONDITIONAL(HAL, test "${hal_enable}" = "yes")
390	AM_CONDITIONAL(READLINE, test "${readline_found}" = "yes")
391	AM_CONDITIONAL(GATT_EXAMPLE_PLUGIN, test "${gatt_example_enable}" = "yes")
392	AM_CONDITIONAL(ECHOPLUGIN, test "no" = "yes")
393	AM_CONDITIONAL(PNATPLUGIN, test "${pnat_enable}" = "yes")
394	AM_CONDITIONAL(TRACER, test "${tracer_enable}" = "yes")
395	AM_CONDITIONAL(HIDD, test "${hidd_enable}" = "yes")
396	AM_CONDITIONAL(PAND, test "${pand_enable}" = "yes")
397	AM_CONDITIONAL(DUND, test "${dund_enable}" = "yes")
398	AM_CONDITIONAL(CUPS, test "${cups_enable}" = "yes")
399	AM_CONDITIONAL(TEST, test "${test_enable}" = "yes")
400	AM_CONDITIONAL(TOOLS, test "${tools_enable}" = "yes")
401	AM_CONDITIONAL(BCCMD, test "${bccmd_enable}" = "yes")
402	AM_CONDITIONAL(PCMCIA, test "${pcmcia_enable}" = "yes")
403	AM_CONDITIONAL(HID2HCI, test "${hid2hci_enable}" = "yes" && test "${usb_found}" = "yes")
404	AM_CONDITIONAL(DFUTOOL, test "${dfutool_enable}" = "yes" && test "${usb_found}" = "yes")
405	AM_CONDITIONAL(UDEVRULES, test "${udevrules_enable}" = "yes")
406	AM_CONDITIONAL(CONFIGFILES, test "${configfiles_enable}" = "yes")
407	AM_CONDITIONAL(MAEMO6PLUGIN, test "${maemo6_enable}" = "yes")
408	AM_CONDITIONAL(DBUSOOBPLUGIN, test "${dbusoob_enable}" = "yes")
409])
410