• 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+=" -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"
25	fi
26])
27
28AC_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"
33	AC_SUBST([HTML_DIR])
34
35	AC_ARG_ENABLE([gtk-doc],
36		AS_HELP_STRING([--enable-gtk-doc], [use gtk-doc to build documentation [[default=no]]]),,
37					[enable_gtk_doc=no])
38
39	if test x$enable_gtk_doc = xyes; then
40		ifelse([$1],[],
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]))])
45	fi
46
47	AC_MSG_CHECKING([whether to build gtk-doc documentation])
48	AC_MSG_RESULT($enable_gtk_doc)
49
50	AC_PATH_PROGS(GTKDOC_CHECK,gtkdoc-check,)
51
52	AM_CONDITIONAL([ENABLE_GTK_DOC], [test x$enable_gtk_doc = xyes])
53	AM_CONDITIONAL([GTK_DOC_USE_LIBTOOL], [test -n "$LIBTOOL"])
54])
55
56AC_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.]))
59])
60
61AC_DEFUN([AC_INIT_BLUEZ], [
62	AC_PREFIX_DEFAULT(/usr/local)
63
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'])
68		fi
69
70		dnl no prefix and no localstatedir, so default to /var
71		if (test "$localstatedir" = '${prefix}/var'); then
72			AC_SUBST([localstatedir], ['/var'])
73		fi
74
75		dnl no prefix and no libexecdir, so default to /lib
76		if (test "$libexecdir" = '${exec_prefix}/libexec'); then
77			AC_SUBST([libexecdir], ['/lib'])
78		fi
79
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'])
83		fi
84
85		prefix="${ac_default_prefix}"
86	fi
87
88	if (test "${libdir}" = '${exec_prefix}/lib'); then
89		libdir="${prefix}/lib"
90	fi
91
92	plugindir="${libdir}/bluetooth/plugins"
93
94	if (test "$sysconfdir" = '${prefix}/etc'); then
95		configdir="${prefix}/etc/bluetooth"
96	else
97		configdir="${sysconfdir}/bluetooth"
98	fi
99
100	if (test "$localstatedir" = '${prefix}/var'); then
101		storagedir="${prefix}/var/lib/bluetooth"
102	else
103		storagedir="${localstatedir}/lib/bluetooth"
104	fi
105
106	AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}",
107				[Directory for the configuration files])
108	AC_DEFINE_UNQUOTED(STORAGEDIR, "${storagedir}",
109				[Directory for the storage files])
110
111	AC_SUBST(CONFIGDIR, "${configdir}")
112	AC_SUBST(STORAGEDIR, "${storagedir}")
113
114	UDEV_DATADIR="`$PKG_CONFIG --variable=udevdir udev`"
115	if (test -z "${UDEV_DATADIR}"); then
116		UDEV_DATADIR="${sysconfdir}/udev/rules.d"
117	else
118		UDEV_DATADIR="${UDEV_DATADIR}/rules.d"
119	fi
120	AC_SUBST(UDEV_DATADIR)
121])
122
123AC_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)
130	AC_SUBST(DBUS_LIBS)
131])
132
133AC_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)
137	AC_SUBST(GLIB_LIBS)
138])
139
140AC_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)
146])
147
148AC_DEFUN([AC_PATH_PULSE], [
149	PKG_CHECK_MODULES(PULSE, libpulse, pulse_found=yes, pulse_found=no)
150	AC_SUBST(PULSE_CFLAGS)
151	AC_SUBST(PULSE_LIBS)
152])
153
154AC_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)
158	AC_SUBST(ALSA_LIBS)
159])
160
161AC_DEFUN([AC_PATH_USB], [
162	PKG_CHECK_MODULES(USB, libusb, usb_found=yes, usb_found=no)
163	AC_SUBST(USB_CFLAGS)
164	AC_SUBST(USB_LIBS)
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.]))
171])
172
173AC_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)
177])
178
179AC_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)
183])
184
185AC_DEFUN([AC_ARG_BLUEZ], [
186	debug_enable=no
187	optimization_enable=yes
188	fortify_enable=yes
189	pie_enable=yes
190	sndfile_enable=${sndfile_found}
191	netlink_enable=no
192	hal_enable=${hal_found}
193	usb_enable=${usb_found}
194	alsa_enable=${alsa_found}
195	gstreamer_enable=${gstreamer_found}
196	audio_enable=yes
197	input_enable=yes
198	serial_enable=yes
199	network_enable=yes
200	service_enable=yes
201	tools_enable=yes
202	hidd_enable=no
203	pand_enable=no
204	dund_enable=no
205	cups_enable=no
206	test_enable=no
207	bccmd_enable=no
208	pcmcia_enable=no
209	hid2hci_enable=no
210	dfutool_enable=no
211	manpages_enable=yes
212	udevrules_enable=yes
213	configfiles_enable=yes
214	telephony_driver=dummy
215
216	AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization], [disable code optimization]), [
217		optimization_enable=${enableval}
218	])
219
220	AC_ARG_ENABLE(fortify, AC_HELP_STRING([--disable-fortify], [disable compile time buffer checks]), [
221		fortify_enable=${enableval}
222	])
223
224	AC_ARG_ENABLE(pie, AC_HELP_STRING([--disable-pie], [disable position independent executables flag]), [
225		pie_enable=${enableval}
226	])
227
228	AC_ARG_ENABLE(network, AC_HELP_STRING([--disable-network], [disable network plugin]), [
229		network_enable=${enableval}
230	])
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(gstreamer, AC_HELP_STRING([--enable-gstreamer], [enable GStreamer support]), [
249		gstreamer_enable=${enableval}
250	])
251
252	AC_ARG_ENABLE(alsa, AC_HELP_STRING([--enable-alsa], [enable ALSA support]), [
253		alsa_enable=${enableval}
254	])
255
256	AC_ARG_ENABLE(usb, AC_HELP_STRING([--enable-usb], [enable USB support]), [
257		usb_enable=${enableval}
258	])
259
260	AC_ARG_ENABLE(netlink, AC_HELP_STRING([--enable-netlink], [enable NETLINK support]), [
261		netlink_enable=${enableval}
262	])
263
264	AC_ARG_ENABLE(tools, AC_HELP_STRING([--enable-tools], [install Bluetooth utilities]), [
265		tools_enable=${enableval}
266	])
267
268	AC_ARG_ENABLE(bccmd, AC_HELP_STRING([--enable-bccmd], [install BCCMD interface utility]), [
269		bccmd_enable=${enableval}
270	])
271
272	AC_ARG_ENABLE(pcmcia, AC_HELP_STRING([--enable-pcmcia], [install PCMCIA serial script]), [
273		pcmcia_enable=${enableval}
274	])
275
276	AC_ARG_ENABLE(hid2hci, AC_HELP_STRING([--enable-hid2hci], [install HID mode switching utility]), [
277		hid2hci_enable=${enableval}
278	])
279
280	AC_ARG_ENABLE(dfutool, AC_HELP_STRING([--enable-dfutool], [install DFU firmware upgrade utility]), [
281		dfutool_enable=${enableval}
282	])
283
284	AC_ARG_ENABLE(hidd, AC_HELP_STRING([--enable-hidd], [install HID daemon]), [
285		hidd_enable=${enableval}
286	])
287
288	AC_ARG_ENABLE(pand, AC_HELP_STRING([--enable-pand], [install PAN daemon]), [
289		pand_enable=${enableval}
290	])
291
292	AC_ARG_ENABLE(dund, AC_HELP_STRING([--enable-dund], [install DUN daemon]), [
293		dund_enable=${enableval}
294	])
295
296	AC_ARG_ENABLE(cups, AC_HELP_STRING([--enable-cups], [install CUPS backend support]), [
297		cups_enable=${enableval}
298	])
299
300	AC_ARG_ENABLE(test, AC_HELP_STRING([--enable-test], [install test programs]), [
301		test_enable=${enableval}
302	])
303
304	AC_ARG_ENABLE(manpages, AC_HELP_STRING([--enable-manpages], [install Bluetooth manual pages]), [
305		manpages_enable=${enableval}
306	])
307
308	AC_ARG_ENABLE(udevrules, AC_HELP_STRING([--enable-udevrules], [install Bluetooth udev rules]), [
309		udevrules_enable=${enableval}
310	])
311
312	AC_ARG_ENABLE(configfiles, AC_HELP_STRING([--enable-configfiles], [install Bluetooth configuration files]), [
313		configfiles_enable=${enableval}
314	])
315
316	AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [enable compiling with debugging information]), [
317		debug_enable=${enableval}
318	])
319
320	AC_ARG_WITH(telephony, AC_HELP_STRING([--with-telephony=DRIVER], [select telephony driver]), [
321		telephony_driver=${withval}
322	])
323
324	AC_SUBST([TELEPHONY_DRIVER], [telephony-${telephony_driver}.c])
325
326	if (test "${fortify_enable}" = "yes"); then
327		CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
328	fi
329
330	if (test "${pie_enable}" = "yes" && test "${ac_cv_prog_cc_pie}" = "yes"); then
331		CFLAGS="$CFLAGS -fPIC"
332		LDFLAGS="$LDFLAGS -pie"
333	fi
334
335	if (test "${debug_enable}" = "yes" && test "${ac_cv_prog_cc_g}" = "yes"); then
336		CFLAGS="$CFLAGS -g"
337	fi
338
339	if (test "${optimization_enable}" = "no"); then
340		CFLAGS="$CFLAGS -O0"
341	fi
342
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.])
345	fi
346
347	AC_SUBST([BLUEZ_CFLAGS], ['-I$(top_builddir)/include'])
348	AC_SUBST([BLUEZ_LIBS], ['$(top_builddir)/lib/libbluetooth.la'])
349
350	AC_SUBST([GDBUS_CFLAGS], ['-I$(top_srcdir)/gdbus'])
351	AC_SUBST([GDBUS_LIBS], ['$(top_builddir)/gdbus/libgdbus.la'])
352
353	AC_SUBST([SBC_CFLAGS], ['-I$(top_srcdir)/sbc'])
354	AC_SUBST([SBC_LIBS], ['$(top_builddir)/sbc/libsbc.la'])
355
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")
380])
381