summaryrefslogtreecommitdiff
path: root/configure.in
blob: c9f1e592d41fb1cd743d0e61264b73964904a6d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# $Id: $

AC_INIT([hfp4linux], [0.1.0], [samr7@cs.washington.edu])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_MACRO_DIR([m4])
AM_MAINTAINER_MODE

DX_HTML_FEATURE(ON)
DX_CHM_FEATURE(OFF)
DX_CHI_FEATURE(OFF)
DX_MAN_FEATURE(OFF)
DX_RTF_FEATURE(OFF)
DX_XML_FEATURE(OFF)
DX_PDF_FEATURE(OFF)
DX_PS_FEATURE(OFF)
DX_INIT_DOXYGEN([libhfp], [Doxyfile], [doc])

AM_INIT_AUTOMAKE

AC_PROG_CC
AC_PROG_CXX
AC_PROG_CXX_C_O
AC_PROG_LIBTOOL

dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([fcntl.h limits.h stdint.h stdlib.h string.h sys/ioctl.h sys/socket.h unistd.h])

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T

dnl Checks for library functions.
AC_FUNC_ALLOCA
AC_FUNC_FORK
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MALLOC
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([memmove memset socket strdup strncasecmp strtol])

dnl Append /usr/local/lib/pkgconfig to PKG_CONFIG_PATH
dnl Manually installed packages like libnghost will tend to go there
PKG_CONFIG_PATH="${PKG_CONFIG_PATH}${PKG_CONFIG_PATH:+:}/usr/local/lib/pkgconfig"

PKG_PROG_PKG_CONFIG([0.9.0])

dnl *******************
dnl Default debug level
dnl For now, verbose debugging is on by default
dnl Set to "yes" for more extreme measures, "partial" for simple
dnl measures, and "no" to turn off all measures.

default_want_debug=yes
dnl default_want_debug=maybe

dnl *******************

AC_ARG_ENABLE(debug,
	AC_HELP_STRING([--disable-debug], [Configure debugging measures]),
	want_debug=$enableval, want_debug=$default_want_debug)

dnl Add -Wall to the CFLAGS unconditionally
CFLAGS="$CFLAGS -Wall"
CXXFLAGS="$CXXFLAGS -Wall"

dnl If debugging is enabled, and the user didn't supply CFLAGS or CXXFLAGS,
dnl remove the autoconf default -O2.  This is kind of a pain in the @$$
if test $want_debug \!= "no"; then
	if test x${ac_test_CFLAGS} != xset; then
		CFLAGS=`echo $CFLAGS | sed -e 's,-O2,,g'`
	fi
	if test x${ac_test_CXXFLAGS} != xset; then
		CXXFLAGS=`echo $CXXFLAGS | sed -e 's,-O2,,g'`
	fi
else
	dnl Add -DNDEBUG to CFLAGS/CXXFLAGS in this case
	if test x${ac_test_CFLAGS} != xset; then
		CFLAGS="$CFLAGS -DNDEBUG"
	fi
	if test x${ac_test_CXXFLAGS} != xset; then
		CXXFLAGS="$CXXFLAGS -DNDEBUG"
	fi
fi

ACX_PTHREAD(use_pthread=yes, use_pthread=no)

AC_ARG_ENABLE(alsa,
	AC_HELP_STRING([--enable-alsa], [build ALSA backend]),
	want_alsa=$enableval, want_alsa=maybe)

AC_ARG_ENABLE(qt,
	AC_HELP_STRING([--enable-qt], [build Qt demonstration app]),
	want_qt=$enableval, want_qt=maybe)

AC_ARG_ENABLE(oss,
	AC_HELP_STRING([--enable-oss], [build OSS backend]),
	want_oss=$enableval, want_oss=yes)

AC_ARG_ENABLE(audiofile,
	AC_HELP_STRING([--enable-audiofile], [build audiofile backend]),
	want_audiofile=$enableval, want_audiofile=maybe)

AC_ARG_ENABLE(speexdsp,
	AC_HELP_STRING([--enable-speexdsp], [build the speexdsp AEC filter]),
	want_speexdsp=$enableval, want_speexdsp=maybe)

AC_ARG_ENABLE(dbus,
	AC_HELP_STRING([--enable-dbus], [build D-Bus components -- hfpd]),
	want_dbus=$enableval, want_dbus=maybe)

AC_ARG_ENABLE(dbus-service,
	AC_HELP_STRING([--disable-dbus-service], [Install D-Bus service file]),
	do_dbus_service=$enableval, do_dbus_service=yes)

AC_ARG_ENABLE(nghost,
	AC_HELP_STRING([--enable-nghost], [build the nhandsfree nGhost plugin]),
	want_nghost=$enableval, want_nghost=maybe)

dnl We can't build without libbluetooth
PKG_CHECK_MODULES([BLUEZ], [bluez >= 2.00])

dnl libasound is optional
use_alsa=no
if test $want_alsa != "no"; then
	PKG_CHECK_MODULES([ALSA], [alsa >= 0.9.0],
			[use_alsa="yes"], [use_alsa="no"])
	if test $use_alsa = "no" -a $want_alsa = "yes"; then
	        AC_MSG_ERROR([[
***
*** ALSA support has been requested, but was not found.
*** Check pkg_config_dir if this is in error.
*** Aborting.
***
]])
	fi
fi

dnl libaudiofile is optional
use_audiofile=no
if test $want_audiofile != "no"; then
	PKG_CHECK_MODULES([AUDIOFILE], [audiofile],
			[use_audiofile="yes"], [use_audiofile="no"])

	if test $use_audiofile = "no" -a $want_audiofile = "yes"; then
	        AC_MSG_ERROR([[
***
*** libaudiofile support has been requested, but was not found.
*** Check pkg_config_dir if this is in error.
*** Aborting.
***
]])
	fi
fi

dnl libspeexdsp is optional
use_speexdsp=no
if test $want_speexdsp != "no"; then
	PKG_CHECK_MODULES([SPEEXDSP], [speexdsp >= 1.2beta2],
			[use_speexdsp="yes"], [use_speexdsp="no"])

	if test $use_speexdsp = "no" -a $want_speexdsp = "yes"; then
	        AC_MSG_ERROR([[
***
*** libspeexdsp support has been requested, but was not found.
*** Check pkg_config_dir if this is in error.
*** Aborting.
***
]])
	fi
fi

dnl dbus is optional
use_dbus=no
if test $want_dbus != "no"; then
	PKG_CHECK_MODULES([DBUS], [dbus-1],
			[use_dbus="yes"], [use_dbus="no"])

	if test $use_dbus = "no" -a $want_dbus = "yes"; then
	        AC_MSG_ERROR([[
***
*** D-Bus support has been requested, but was not found.
*** Check pkg_config_dir if this is in error.
*** Aborting.
***
]])
	fi
fi

dnl Find the D-Bus service path from pkgconfig
dnl This may be a different directory than we would expect
dnl based on our chosen prefix!
if test $use_dbus = "yes"; then
	if test $do_dbus_service = "yes"; then
		AC_ARG_VAR([DBUS_SERVICE_PATH],
	           [Path for D-Bus .service files, overriding pkg-config])
		_PKG_CONFIG([DBUS_SERVICE_PATH],
			    [variable=session_bus_services_dir],
			    [dbus-1])
		DBUS_SERVICE_PATH=$pkg_cv_DBUS_SERVICE_PATH
		AC_SUBST(DBUS_SERVICE_PATH)
	fi

	DBUS_VERSION=`$PKG_CONFIG --modversion dbus-1`
	DBUS_VERSION_MAJOR=`echo $DBUS_VERSION | cut -d. -f 1`
	DBUS_VERSION_MINOR=`echo $DBUS_VERSION | cut -d. -f 2`
	DBUS_VERSION_MICRO=`echo $DBUS_VERSION | cut -d. -f 3`

	AC_DEFINE_UNQUOTED(DBUS_VERSION_MAJOR, $DBUS_VERSION_MAJOR,
			   [D-BUS major version.])
	AC_DEFINE_UNQUOTED(DBUS_VERSION_MINOR, $DBUS_VERSION_MINOR,
			   [D-BUS minor version.])
	AC_DEFINE_UNQUOTED(DBUS_VERSION_MICRO, $DBUS_VERSION_MICRO,
			   [D-BUS micro version.])
fi


use_nghost=no
if test $want_nghost != "no"; then
	PKG_CHECK_MODULES([NGHOSTCORE], [nghostcore],
			[use_nghost="yes"], [use_nghost="no"])
	if test $use_nghost = "no" -a $want_nghost = "yes"; then
	        AC_MSG_ERROR([[
***
*** libnghost support has been requested, but was not found.
*** Check pkg_config_dir if this is in error.
*** Aborting.
***
]])
	fi
fi

if test $use_nghost = "yes"; then
	PKG_CHECK_MODULES([NGHOSTDAO], [nghostdao])
	PKG_CHECK_MODULES([NGHOSTGUI2], [nghostgui2])
	PKG_CHECK_MODULES([NGHOSTLOG], [nghostlog])
	PKG_CHECK_MODULES([NGHOSTNET], [nghostnet])
	PKG_CHECK_MODULES([NGHOSTPLUGINS], [nghostplugins])
	use_nghost=yes
	AC_SUBST([pkglibdir], [${libdir}/nghost])
fi


have_qt=maybe
if test $want_qt != no; then
	AC_PATH_X
	if test "$no_x" = yes; then
		have_qt=no
 	fi
fi
if test $have_qt = "maybe"; then
	QT_CHECK_COMPILERS
	QT_PATH
fi
if test $have_qt = "no" -a $want_qt = "maybe"; then
	want_qt=no
fi
if test $want_qt = "yes"; then
	if test $have_qt = "no"; then
	        AC_MSG_ERROR([[
***
*** Qt ($qt_minversion) $ac_qt_notfound not found. Please check your
*** installation!  For more details about this problem, look at the
*** end of config.log.$missing_qt_mt
***]])
	fi
	if test $have_moc = "no"; then
	        AC_MSG_ERROR([[
***
*** No Qt meta object compiler (moc) found!
*** Please check whether you installed Qt correctly.
*** You need to have a running moc binary.
*** configure tried to run $ac_cv_path_moc and the test didn't
*** succeed. If configure shouldn't have tried this one, set
*** the environment variable MOC to the right one before running
*** configure.
***]])
	fi
	if test $have_uic = "no"; then
	        AC_MSG_ERROR([[
***
*** No Qt user interface compiler (uic) found!
*** Please check whether you installed Qt correctly.
*** You need to have a running moc binary.
*** configure tried to run $ac_cv_path_uic and the test didn't
*** succeed. If configure shouldn't have tried this one, set
*** the environment variable UIC to the right one before running
*** configure.
***]])
	fi
fi


dnl BlueZ libraries are unconditional

libhfp_CXXFLAGS="$libhfp_CXXFLAGS $BLUEZ_CFLAGS"
libhfp_LIBS="$libhfp_LIBS $BLUEZ_LIBS"
AC_SUBST(libhfp_CXXFLAGS)
AC_SUBST(libhfp_LIBS)


dnl Other options are set here and have their cflags/libs added
dnl to libhfp_CXXFLAGS and libhfp_LIBS.

if test $want_debug = "yes"; then
	AC_DEFINE([USE_VERBOSE_DEBUG], [], [Enable extreme debug measures])
fi

if test $use_pthread = "yes"; then
	AC_DEFINE([USE_PTHREADS], [], [Enable thread support])
	libhfp_CXXFLAGS="$libhfp_CXXFLAGS $PTHREAD_CFLAGS"
	libhfp_LIBS="$libhfp_LIBS $PTHREAD_LIBS"
fi

if test $use_alsa = "yes"; then
	AC_DEFINE([USE_ALSA_SOUNDIO], [], [Enable support for libasound])
	libhfp_CXXFLAGS="$libhfp_CXXFLAGS $ALSA_CFLAGS"
	libhfp_LIBS="$libhfp_LIBS $ALSA_LIBS"
else
	if test $want_alsa != "no"; then
		echo "***"
		echo "***"
		echo "*** WARNING: Support for ALSA is being omitted"
		echo "*** WARNING: This probably isn't what you want"
		echo "*** WARNING: Install libasound development package"
		echo "***"
		echo "***"
		echo -n -e "\a"
		sleep 1
		echo -n -e "\a"
		sleep 1
		echo -n -e "\a"
	fi
fi
if test $want_oss = "yes"; then
	AC_DEFINE([USE_OSS_SOUNDIO], [], [Enable support for OSS])
fi
if test $use_audiofile = "yes"; then
	AC_DEFINE([USE_AUDIOFILE], [], [Enable support for libaudiofile])
	libhfp_CXXFLAGS="$libhfp_CXXFLAGS $AUDIOFILE_CFLAGS"
	libhfp_LIBS="$libhfp_LIBS $AUDIOFILE_LIBS"
fi
if test $use_speexdsp = "yes"; then
	AC_DEFINE([USE_SPEEXDSP], [], [Enable support for libspeexdsp])
	libhfp_CXXFLAGS="$libhfp_CXXFLAGS $SPEEXDSP_CFLAGS"
	libhfp_LIBS="$libhfp_LIBS $SPEEXDSP_LIBS"
else
	if test $want_speexdsp != "no"; then
		echo "***"
		echo "***"
		echo "*** WARNING: Support for libspeexdsp is being omitted"
		echo "*** WARNING: This probably isn't what you want"
		echo "*** WARNING: Install libspeexdsp development package"
		echo "***"
		echo "***"
		echo -n -e "\a"
		sleep 1
		echo -n -e "\a"
		sleep 1
		echo -n -e "\a"
	fi
fi

if test $use_nghost = "yes"; then
	libnghost_CFLAGS="$NGHOSTCORE_CFLAGS $NGHOSTDAO_CFLAGS $NGHOSTGUI2_CFLAGS $NGHOSTLOG_CFLAGS $NGHOSTNET_CFLAGS $NGHOSTPLUGINS_CFLAGS"
	libnghost_LIBS="$NGHOSTCORE_LIBS $NGHOSTDAO_LIBS $NGHOSTGUI2_LIBS $NGHOSTLOG_LIBS $NGHOSTNET_LIBS $NGHOSTPLUGINS_LIBS"
fi
AC_SUBST(libnghost_CFLAGS)
AC_SUBST(libnghost_LIBS)
AM_CONDITIONAL(BUILD_DBUS, [test $use_dbus = "yes"])
AM_CONDITIONAL(BUILD_DBUS_SERVICE, [test $use_dbus = "yes" -a $do_dbus_service = "yes"])
AM_CONDITIONAL(BUILD_QT, [test $have_qt = "yes"])
AM_CONDITIONAL(BUILD_NGHOST, [test $use_nghost = "yes"])

AC_CONFIG_FILES([Makefile libhfp/Makefile include/Makefile include/libhfp/Makefile qt/Makefile nhandsfree/Makefile hfpd/Makefile test/Makefile data/Makefile])
AC_OUTPUT