sphinx: fix a few incorrect mrp_debug usages.
[profile/ivi/speech-recognition.git] / configure.ac
1
2 #                                               -*- Autoconf -*-
3 # Process this file with autoconf to produce a configure script.
4
5 AC_PREREQ(2.59)
6
7 AC_INIT([speech-recognition],
8         m4_esyscmd([build-aux/git-version-gen .tarball-version]),
9         [krisztian.litkey at intel.com])
10
11 AC_CONFIG_SRCDIR([src])
12 AC_CONFIG_MACRO_DIR([m4])
13 AC_CONFIG_HEADER([src/config.h])
14 AM_INIT_AUTOMAKE([subdir-objects])
15
16 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
17
18 m4_define(version_major, `echo $VERSION | cut -d. -f1 | cut -d- -f1`)
19 m4_define(version_minor, `echo $VERSION | cut -d. -f2 | cut -d- -f1`)
20 m4_define(version_patch, `echo $VERSION | cut -d. -f3 | cut -d- -f1`)
21
22 AC_SUBST(VERSION)
23 AC_SUBST(VERSION_MAJOR, version_major)
24 AC_SUBST(VERSION_MINOR, version_minor)
25 AC_SUBST(VERSION_PATCH, version_patch)
26 AC_SUBST(VERSION_FULL, version_major.version_minor.version_patch)
27
28 SRS_VERSION_INFO="0:0:0"
29 AC_SUBST(SRS_VERSION_INFO)
30
31 # Disable static libraries.
32 AC_DISABLE_STATIC
33
34 # Checks for programs.
35 AC_PROG_CC
36 AC_PROG_CC_C99
37 # We need AC_PROG_CXX if Qt support is enabled but (at least some
38 # versions of autotools) cannot handle conditional use of this.
39 AC_PROG_CXX
40 AC_PROG_AWK
41 AC_PROG_INSTALL
42 AM_PROG_CC_C_O
43 AM_PROG_LIBTOOL
44
45 # Checks for libraries.
46 AC_CHECK_LIB([dl], [dlopen dlclose dlsym dlerror])
47
48 # Checks for header files.
49 AC_PATH_X
50 AC_CHECK_HEADERS([fcntl.h stddef.h stdint.h stdlib.h string.h sys/statvfs.h sys/vfs.h syslog.h unistd.h])
51
52 # Checks for typedefs, structures, and compiler characteristics.
53 AC_HEADER_STDBOOL
54 AC_C_INLINE
55 AC_TYPE_INT16_T
56 AC_TYPE_INT32_T
57 AC_TYPE_INT64_T
58 AC_TYPE_MODE_T
59 AC_TYPE_PID_T
60 AC_TYPE_SIZE_T
61 AC_TYPE_SSIZE_T
62 AC_CHECK_MEMBERS([struct stat.st_rdev])
63 AC_TYPE_UINT16_T
64 AC_TYPE_UINT32_T
65 AC_TYPE_UINT64_T
66 AC_TYPE_UINT8_T
67 AC_CHECK_TYPES([ptrdiff_t])
68
69 # Checks for library functions.
70 AC_FUNC_ERROR_AT_LINE
71 AC_HEADER_MAJOR
72 AC_FUNC_MALLOC
73 AC_FUNC_STRTOD
74 AC_CHECK_FUNCS([memmove memset])
75
76 # Check and enable extra compiler warnings if they are supported.
77 AC_ARG_ENABLE(extra-warnings,
78               [  --enable-extra-warnings enable extra compiler warnings],
79               [extra_warnings=$enableval], [extra_warnings=auto])
80
81 WARNING_CFLAGS=""
82 warncflags="-Wall -Wextra"
83 if test "$extra_warnings" != "no"; then
84     save_CPPFLAGS="$CPPFLAGS"
85     for opt in $warncflags; do
86         AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
87                           [WARNING_CFLAGS="$WARNING_CFLAGS $opt"])
88     done
89     CPPFLAGS="$save_CPPFLAGS"
90 fi
91
92 AC_SUBST(WARNING_CFLAGS)
93
94 # Check for the necessary Murphy components.
95 PKG_CHECK_MODULES(MURPHY_COMMON,    murphy-common)
96 PKG_CHECK_MODULES(MURPHY_PULSE,     murphy-pulse)
97 PKG_CHECK_MODULES(MURPHY_GLIB,      murphy-glib)
98 PKG_CHECK_MODULES(MURPHY_RESOURCE,  murphy-resource)
99 PKG_CHECK_MODULES(MURPHY_BREEDLINE, breedline-murphy)
100 AC_SUBST(MURPHY_COMMON_CFLAGS)
101 AC_SUBST(MURPHY_COMMON_LIBS)
102 AC_SUBST(MURPHY_PULSE_CFLAGS)
103 AC_SUBST(MURPHY_PULSE_LIBS)
104 AC_SUBST(MURPHY_GLIB_CFLAGS)
105 AC_SUBST(MURPHY_GLIB_LIBS)
106 AC_SUBST(MURPHY_RESOURCE_CFLAGS)
107 AC_SUBST(MURPHY_RESOURCE_LIBS)
108 AC_SUBST(MURPHY_BREEDLINE_CFLAGS)
109 AC_SUBST(MURPHY_BREEDLINE_LIBS)
110
111 # Check for PulseAudio.
112 PKG_CHECK_MODULES(PULSE, libpulse >= 0.9.22)
113 PKG_CHECK_MODULES(PULSE_GLIB, libpulse-mainloop-glib >= 0.922)
114 AC_SUBST(PULSE_CFLAGS)
115 AC_SUBST(PULSE_LIBS)
116 AC_SUBST(PULSE_GLIB_CFLAGS)
117 AC_SUBST(PULSE_GLIB_LIBS)
118
119 # Check if potentially GPL bits are allowed to be enabled.
120 AC_ARG_ENABLE(gpl,
121               [  --enable-gpl            enable linking against GPL code],
122               [enable_gpl=$enableval], [enable_gpl=no])
123
124 # Check if DBUS was enabled.
125 AC_ARG_ENABLE(dbus,
126               [  --enable-dbus           enable D-BUS support],
127               [enable_dbus=$enableval], [enable_dbus=no])
128
129 if test "$enable_dbus" = "yes"; then
130     if test "$enable_gpl" = "no"; then
131         AC_MSG_ERROR([D-Bus support requires the --enable-gpl option.])
132     fi
133     PKG_CHECK_MODULES(DBUS, dbus-1 >= 0.70)
134     DBUS_SESSION_DIR="`pkg-config --variable session_bus_services_dir dbus-1`"
135     AC_SUBST(DBUS_SESSION_DIR)
136
137     PKG_CHECK_MODULES(MURPHY_DBUS, murphy-dbus-libdbus)
138 else
139     AC_MSG_NOTICE([D-Bus support is disabled.])
140 fi
141
142 if test "$enable_dbus" = "yes"; then
143     AC_DEFINE([DBUS_ENABLED], 1, [Enable D-BUS support ?])
144 fi
145
146 AM_CONDITIONAL(DBUS_ENABLED, [test "$enable_dbus" = "yes"])
147 AC_SUBST(DBUS_ENABLED)
148 AC_SUBST(MURPHY_DBUS_CFLAGS)
149 AC_SUBST(MURPHY_DBUS_LIBS)
150 AC_SUBST(DBUS_CFLAGS)
151 AC_SUBST(DBUS_LIBS)
152
153 # Set up common SRS compilation and linking flags.
154 SRS_CFLAGS=""
155 SRS_LIBS=""
156 AC_SUBST(SRS_CFLAGS)
157 AC_SUBST(SRS_LIBS)
158
159 # Add LIBDIR to config.h.
160 AC_MSG_CHECKING([libdir])
161 AC_MSG_RESULT([$libdir])
162 AC_SUBST(LIBDIR, [$libdir])
163
164 # Check if bluetooth plugin was enabled
165 AC_ARG_ENABLE(bluetooth,
166               [  --enable-bluetooth      enable bluetooth voice recognition support],
167               [enable_bluetooth=$enableval], [enable_bluetooth=auto])
168 AM_CONDITIONAL(BLUETOOTH_ENABLED, [test "$enable_bluetooth" = "yes"])
169 AC_SUBST(BLUETOOTH_ENABLED)
170
171 # Check if mpris plugin was enabled
172 AC_ARG_ENABLE(mpris,
173               [  --enable-mpris          enable mpris support],
174               [enable_mpris=$enableval], [enable_mpris=auto])
175 AM_CONDITIONAL(MPRIS2_ENABLED, [test "$enable_mpris" = "yes"])
176 AC_SUBST(MPRIS2_ENABLED)
177
178 # Check if sphinx was enabled.
179 AC_ARG_ENABLE(sphinx,
180               [  --enable-sphinx         enable pocketsphinx support in SRS],
181               [enable_sphinx=$enableval], [enable_sphinx=auto])
182
183 if test "$enable_sphinx" != "no"; then
184     PKG_CHECK_MODULES(SPHINX, [sphinxbase pocketsphinx],
185                       [have_sphinx=yes], [have_sphinx=no])
186     if test "$have_sphinx" = "no" -a "$enable_sphinx" = "yes"; then
187         AC_MSG_ERROR([Sphinx development libraries not found.])
188     fi
189
190     # sphinxbase is packetised in wrong way in Fedora
191     # and pkg-config reports libraries what we really
192     # do not need; so as a temporary hack here we get
193     # rid of them
194     SPHINX_LIBS=`echo $SPHINX_LIBS                      | \
195                       sed -e "s/ -lpulse-simple//g"     | \
196                       sed -e "s/ -lblas//g"             | \
197                       sed -e "s/ -llapack//g"           | \
198                       sed -e "s/ -lsamplerate//g"       | \
199                       sed -e "s/ -lsndfile//g"          | \
200                       sed -e "s/ -lpthread//g"`
201
202     enable_sphinx="$have_sphinx"
203 else
204     AC_MSG_NOTICE([Sphinx support disabled])
205 fi
206
207 AM_CONDITIONAL(SPHINX_ENABLED, [test "$enable_sphinx" = "yes"])
208 AC_SUBST(SPHINX_ENABLED)
209 AC_SUBST(SPHINX_CFLAGS)
210 AC_SUBST(SPHINX_LIBS)
211
212 # Check for libudev.
213 PKG_CHECK_MODULES(UDEV, libudev)
214
215 # Check for glib et al that we need temporarily to allow plugins use gdbus.
216 PKG_CHECK_MODULES(GLIB, glib-2.0 gobject-2.0)
217 PKG_CHECK_MODULES(MURPHY_GLIB, murphy-glib)
218 AC_SUBST(GLIB_CFLAGS)
219 AC_SUBST(GLIB_LIBS)
220 AC_SUBST(MURPHY_GLIB_CFLAGS)
221 AC_SUBST(MURPHY_GLIB_LIBS)
222
223 # Check if WRT media client should be enabled.
224 AC_ARG_ENABLE(wrt-client,
225               [  --enable-wrt-client     enable WRT media client plugin],
226               [enable_wrtc=$enableval], [enable_wrtc=yes])
227
228 if test "$enable_wrtc" = "yes"; then
229     PKG_CHECK_MODULES(GIO, gio-2.0)
230 else
231     AC_MSG_NOTICE([WRT media client plugin is disabled.])
232 fi
233
234 AM_CONDITIONAL(WRTC_ENABLED, [test "$enable_wrtc" = "yes"])
235 AC_SUBST(GIO_CFLAGS)
236 AC_SUBST(GIO_LIBS)
237
238 # Check if festival support should be enabled.
239 AC_ARG_ENABLE(festival,
240               [  --enable-festival          enable festival support],
241               [enable_festival=$enableval], [enable_festival=auto])
242
243 if test "$enable_festival" != "no"; then
244     enable_festival=yes
245     AC_MSG_NOTICE([festival support is enabled.])
246 else
247     AC_MSG_NOTICE([festival support is disabled.])
248 fi
249
250 if test "$enable_festival" = "yes"; then
251     AC_DEFINE([FESTIVAL_ENABLED], 1, [Enable festival support ?])
252 fi
253
254 if test -f $prefix/include/festival/festival.h; then
255     FESTIVAL_INCLUDES="-I$prefix/include \
256                        -I$prefix/include/festival \
257                        -I$prefix/include/speech_tools"
258 else
259     FESTIVAL_INCLUDES="-I$prefix/include"
260 fi
261
262 FESTIVAL_CXXFLAGS="$FESTIVAL_INCLUDES"
263 FESTIVAL_LIBS=""
264
265 AM_CONDITIONAL(FESTIVAL_ENABLED, [test "$enable_festival" = "yes"])
266 AC_SUBST(FESTIVAL_ENABLED)
267 AC_SUBST(FESTIVAL_CXXFLAGS)
268 AC_SUBST(FESTIVAL_LIBS)
269
270 # Check if espeak support should be enabled.
271 AC_ARG_ENABLE(espeak,
272               [  --enable-espeak           enable espeak synthesizer support],
273               [enable_espeak=$enableval], [enable_espeak=auto])
274
275 if test "$enable_espeak" != "no"; then
276     AC_CHECK_HEADERS([espeak/speak_lib.h], [have_espeak=yes], [have_espeak=no])
277
278     if test "$have_espeak" = "no" -a "$enable_espeak" = "yes"; then
279         AC_MSG_ERROR([espeak development libraries not found.])
280     fi
281
282     enable_espeak=$have_espeak
283 fi
284
285 if test "$enable_espeak" = "yes"; then
286     AC_MSG_NOTICE([espeak synthesizer support is enabled.])
287     AC_DEFINE([ESPEAK_ENABLED], 1, [Enable espeak support ?])
288     ESPEAK_INCLUDES="-I$prefix/include"
289     ESPEAK_CFLAGS="$ESPEAK_INCLUDES"
290     ESPEAK_LIBS="-lespeak"
291 else
292     AC_MSG_NOTICE([espeak synthesizer support is disabled.])
293 fi
294
295 AM_CONDITIONAL(ESPEAK_ENABLED, [test "$enable_espeak" = "yes"])
296 AC_SUBST(ESPEAK_ENABLED)
297 AC_SUBST(ESPEAK_CFLAGS)
298 AC_SUBST(ESPEAK_LIBS)
299
300 # Check if W3C Speech API plugin was enabled.
301 AC_ARG_ENABLE(w3c-speech,
302               [  --enable-w3c-speech enable W3C Speech API plugin],
303               [enable_w3cspeech=$enableval], [enable_w3cspeech=no])
304
305 if test "$enable_w3cspeech" = "yes"; then
306     AC_MSG_NOTICE([W3C Speech API plugin is enabled.])
307     AC_DEFINE([W3C_SPEECH_ENABLED], 1, [Enable W3C Speech API plugin ?])
308 else
309     AC_MSG_NOTICE([W3C Speech API plugin is disabled.])
310 fi
311
312 AM_CONDITIONAL(W3C_SPEECH_ENABLED, [test "$enable_w3cspeech" = "yes"])
313
314 # Check if systemd socket-based activation was enabled.
315 AC_ARG_ENABLE(systemd,
316               [  --enable-systemd       enable systemd socket-based activation],
317               [enable_systemd=$enableval], [enable_systemd=no])
318
319 if test "$enable_systemd" = "yes"; then
320     PKG_CHECK_MODULES(SYSTEMD, libsystemd-daemon)
321 else
322     AC_MSG_NOTICE([systemd support is disabled.])
323 fi
324
325 if test "$enable_systemd" = "yes"; then
326     AC_DEFINE([SYSTEMD_ENABLED], 1, [Enable systemd socket-based activation ?])
327 fi
328
329 AM_CONDITIONAL(SYSTEMD_ENABLED, [test "$enable_systemd" = "yes"])
330 AC_SUBST(SYSTEMD_CFLAGS)
331 AC_SUBST(SYSTEMD_LIBS)
332
333 # Shave by default.
334 SHAVE_INIT([build-aux], [enable])
335
336 # Create murphy symlink to src.
337 if test ! -L srs; then
338     AC_MSG_NOTICE([Symlinking src to srs...])
339     ln -s src srs
340 fi
341
342 # Generate output.
343 AC_CONFIG_FILES([build-aux/shave
344                  build-aux/shave-libtool
345                  Makefile
346                  utils/Makefile
347                  src/Makefile
348                  src/plugins/client-api/native/srs-native-client.pc
349                  ])
350 AC_OUTPUT
351
352
353 # Display the configuration.
354 echo "----- configuration -----"
355 echo "Extra C warnings flags: $WARNING_CFLAGS"
356 echo "D-Bus support: $enable_dbus"
357 echo "Sphinx support: $enable_sphinx"
358 echo "Festival support: $enable_festival"
359 echo "Espeak support: $enable_espeak"
360 echo "W3C Speech API: $enable_w3cspeech"
361 echo "systemd socket-based activation: $enable_systemd"
362 echo "Bluetooth voice recording support: $enable_bluetooth"
363 echo "Mediaplayer remote interface support: $enable_mpris"
364
365 if test "$DUMP_LIB_FLAGS" = "yes"; then
366     echo "MURPHY_COMMON:"
367     echo "  CFLAGS: $MURPHY_COMMON_CFLAGS"
368     echo "  LIBS  : $MURPHY_COMMON_LIBS"
369
370     echo "MURPHY_DBUS:"
371     echo "  CFLAGS: $MURPHY_DBUS_CFLAGS"
372     echo "  LIBS  : $MURPHY_DBUS_LIBS"
373
374     echo "MURPHY_PULSE:"
375     echo "  CFLAGS: $MURPHY_PULSE_CFLAGS"
376     echo "  LIBS  : $MURPHY_PULSE_LIBS"
377
378     echo "MURPHY_RESOURCE:"
379     echo "  CFLAGS: $MURPHY_RESOURCE_CFLAGS"
380     echo "  LIBS  : $MURPHY_RESOURCE_LIBS"
381
382     echo "MURPHY_BREEDLINE:"
383     echo "  CFLAGS: $MURPHY_BREEDLINE_CFLAGS"
384     echo "  LIBS  : $MURPHY_BREEDLINE_LIBS"
385 fi