-
Notifications
You must be signed in to change notification settings - Fork 8
/
configure.ac
529 lines (434 loc) · 16.2 KB
/
configure.ac
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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
AC_PREREQ([2.65])
AC_INIT([Cainteoir Text-to-Speech], [0.12.2], [https://github.com/rhdunn/cainteoir-engine/issues], [cainteoir-engine], [https://github.com/rhdunn/cainteoir-engine])
AM_INIT_AUTOMAKE()
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES])
AM_SILENT_RULES([yes])
AC_CONFIG_SRCDIR([src])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION(0.17)
LT_INIT
dnl ================================================================
dnl Program checks.
dnl ================================================================
AC_PROG_CPP
AC_PROG_CXX
AC_PROG_MAKE_SET
AC_PROG_LIBTOOL
dnl ================================================================
dnl Python checks.
dnl ================================================================
AC_DEFUN([PYTHON2_CHECK],
[
AC_MSG_CHECKING([for $1])
AS_IF([which $1 > /dev/null],
[
VERSION=`$1 --version 2>&1 | sed -e 's/Python //g'`
MAJOR_VERSION=`echo ${VERSION} | sed -e 's/\..*//g'`
AC_MSG_RESULT([${VERSION}])
AC_MSG_CHECKING([if $1 is a Python 2 interpreter])
AS_IF([test ${MAJOR_VERSION} -eq 2],
[
AC_MSG_RESULT([yes])
PYTHON=$1
],[
AC_MSG_RESULT([no])
PYTHON=no
])
],[
AC_MSG_RESULT([no])
PYTHON=no
])
])
AC_ARG_VAR([PYTHON], [the python interpreter to use @<:@default=auto@:>@])
if test "x${PYTHON}" == "x" ; then
# autodetect Python version ...
PYTHON2_CHECK(python)
if test "x${PYTHON}" == "xno" ; then
PYTHON2_CHECK(python2)
fi
else
PYTHON2_CHECK(${PYTHON})
fi
if test "x${PYTHON}" == "xno" ; then
AC_MSG_ERROR([unable to find a Python 2 interpreter (use ./configure PYTHON=... to point to the correct Python program)])
fi
AC_SUBST(PYTHON)
dnl ================================================================
dnl documentation generator checks.
dnl ================================================================
AC_ARG_WITH([docgen],
[AS_HELP_STRING([--with-docgen], [the path to document generator (for api docs) @<:@default=disabled@:>@])],
[])
if test "x$with_docgen" = "x"; then
have_docgen=no
else
DOCGEN=$with_docgen
have_docgen=$with_docgen
fi
AC_SUBST(DOCGEN)
dnl ================================================================
dnl C++11 support
dnl ================================================================
CXX11_CHECK_CXX11_SUPPORT
CXX11_NULLPTR
CXX11_DECLTYPE
CXX11_AUTO
CXX11_RANGE_BASED_FOR
CXX11_BRACE_INITIALIZATION
CXX11_SCOPED_ENUMS
CXX11_CONSTEXPR
CXX11_LAMBDA
CXX11_LAMBDA_CAPTURE
CXX11_REQUIRE_STD_INITIALIZER_LIST
CXX11_REQUIRE_STD_SHARED_PTR
CXX11_REQUIRE_STD_BEGIN
CXX11_REQUIRE_STD_END
dnl ================================================================
dnl stopwatch checks.
dnl ================================================================
AC_CHECK_HEADERS([sys/time.h])
AC_CHECK_FUNCS([gettimeofday])
AC_CHECK_HEADERS([time.h])
AC_CHECK_FUNCS([time])
dnl ================================================================
dnl getopt checks.
dnl ================================================================
AC_CHECK_HEADERS([getopt.h])
AC_CHECK_FUNCS([getopt_long])
dnl ================================================================
dnl iconv checks.
dnl ================================================================
AC_CHECK_HEADERS([iconv.h])
AC_CHECK_FUNCS([iconv_open])
dnl ================================================================
dnl stdlib checks.
dnl ================================================================
AC_CHECK_HEADERS([stdlib.h])
AC_CHECK_FUNCS([setenv])
AC_CHECK_FUNCS([mkstemp])
dnl ================================================================
dnl stdio checks.
dnl ================================================================
AC_CHECK_HEADERS([stdio.h])
AC_CHECK_FUNCS([open_memstream])
AC_CHECK_FUNCS([tmpfile])
dnl ================================================================
dnl pthread checks.
dnl ================================================================
AC_CHECK_HEADERS([pthread.h])
AC_CHECK_LIB( pthread, pthread_create, [],
[LDFLAGS="-pthread $LDFLAGS"
AC_TRY_LINK([char pthread_create();],
pthread_create();,
[], [AC_MSG_ERROR([Missing pthread])])
])
dnl ================================================================
dnl zlib checks.
dnl ================================================================
PKG_CHECK_MODULES(ZLIB, [zlib >= 1.2.3], [])
AC_SUBST(ZLIB_CFLAGS)
AC_SUBST(ZLIB_LIBS)
dnl ================================================================
dnl espeak tts engine checks.
dnl ================================================================
AC_ARG_WITH([espeak],
[AS_HELP_STRING([--with-espeak], [support for espeak text-to-speech @<:@default=yes@:>@])],
[])
if test "$with_espeak" = "no"; then
echo "Disabling espeak support"
have_espeak=no
else
AC_CHECK_HEADERS(espeak/speak_lib.h,
[
ESPEAK_CFLAGS="-DHAVE_ESPEAK"
ESPEAK_LIBS="-lespeak"
have_espeak=yes
# espeak_TextToPhonemes is implemented in eSpeak 1.47.07b and
# declared in speak_lib.h since 1.47.08 for revision 8 of the
# eSpeak API, but ESPEAK_API_REVISION was not updated. In
# 1.47.11c, the method signature changed and ESPEAK_API_REVISION
# was updated, but the declaration in speak_lib.h was not
# updated.
AC_MSG_CHECKING([for espeak_TextToPhonemes])
AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include "espeak/speak_lib.h"]],
[[const char * (*ptr)(const void **textptr, int textmode, int phonememode);]
[ptr = espeak_TextToPhonemes;]])
],[
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_ESPEAK_TEXTTOPHONEMES, [], [Does eSpeak have espeak_TextToPhonemes])
],[
AC_MSG_RESULT([no])
])
AC_LANG_POP(C++)
],[
have_espeak=no
])
fi
AC_SUBST(ESPEAK_CFLAGS)
AC_SUBST(ESPEAK_LIBS)
dnl ================================================================
dnl pico tts engine checks.
dnl ================================================================
AC_ARG_WITH([pico],
[AS_HELP_STRING([--with-pico], [support for pico text-to-speech @<:@default=yes@:>@])],
[])
AC_MSG_CHECKING([location of Pico voices])
if test "$with_pico" = "no"; then
echo "Disabling pico support"
have_pico=no
PICO_LANG_DIR=
AC_MSG_RESULT([disabled])
else
AC_CHECK_HEADERS(picoapi.h,
[
PICO_CFLAGS="-DHAVE_PICO"
PICO_LIBS="-lttspico"
have_pico=yes
if test "$with_pico" = "yes" -o "$with_pico" = "" ; then
PICO_LANG_DIR=/usr/share/pico/lang
AC_MSG_RESULT([${PICO_LANG_DIR} (default location)])
else
PICO_LANG_DIR=$with_pico
AC_MSG_RESULT([${PICO_LANG_DIR}])
fi
],[
have_pico=no
PICO_LANG_DIR=
AC_MSG_RESULT([disabled])
])
fi
AC_SUBST(PICO_CFLAGS)
AC_SUBST(PICO_LIBS)
AC_SUBST(PICO_LANG_DIR)
dnl ================================================================
dnl MBROLA tts synthesizer checks.
dnl ================================================================
AC_ARG_WITH([mbrola],
[AS_HELP_STRING([--with-mbrola], [support MBROLA text-to-speech voices where applicable @<:@default=yes@:>@])],
[])
AC_MSG_CHECKING([location of MBROLA voices])
if test "$with_mbrola" = "no"; then
echo "Disabling MBROLA support"
have_mbrola=no
MBROLA_DIR=
AC_MSG_RESULT([disabled])
else
AC_DEFINE([HAVE_MBROLA], [1], [Define if support for the MBROLA speech synthesizer and voices is enabled.])
have_mbrola=yes
if test "$with_mbrola" = "yes" -o "$with_mbrola" = "" ; then
MBROLA_DIR=/usr/share/mbrola
AC_MSG_RESULT([${MBROLA_DIR} (default location)])
else
MBROLA_DIR=$with_mbrola
AC_MSG_RESULT([${MBROLA_DIR}])
fi
fi
AC_SUBST(MBROLA_DIR)
dnl ================================================================
dnl PulseAudio checks.
dnl ================================================================
AC_ARG_WITH([pulseaudio],
[AS_HELP_STRING([--with-pulseaudio], [support for PulseAudio output @<:@default=yes@:>@])],
[])
if test "$with_pulseaudio" = "no"; then
echo "Disabling PulseAudio output support"
have_pulseaudio=no
else
PKG_CHECK_MODULES(PULSE, [libpulse-simple >= 0.9],
[
AC_DEFINE(HAVE_PULSEAUDIO, [], [Do we have pulseaudio])
have_pulseaudio=yes
],[
have_pulseaudio=no
])
fi
AC_SUBST(PULSE_CFLAGS)
AC_SUBST(PULSE_LIBS)
dnl ================================================================
dnl ALSA checks.
dnl ================================================================
AC_ARG_WITH([alsa],
[AS_HELP_STRING([--with-alsa], [support for ALSA audio output @<:@default=yes@:>@])],
[])
if test "$with_alsa" = "no"; then
echo "Disabling ALSA audio output support"
have_alsa=no
else
PKG_CHECK_MODULES(ALSA, [alsa],
[
AC_DEFINE(HAVE_ALSA, [], [Do we have ALSA])
have_alsa=yes
],[
have_alsa=no
])
fi
AC_SUBST(ALSA_CFLAGS)
AC_SUBST(ALSA_LIBS)
dnl ================================================================
dnl Ogg/Vorbis checks.
dnl ================================================================
AC_ARG_WITH([vorbisenc],
[AS_HELP_STRING([--with-vorbisenc], [support for vorbisenc Ogg/Vorbis encoder @<:@default=yes@:>@])],
[])
if test "$with_vorbisenc" = "no"; then
echo "Disabling Ogg/Vorbis support via vorbisenc"
have_vorbisenc=no
else
PKG_CHECK_MODULES(VORBIS, [vorbisenc >= 1.2],
[
AC_DEFINE(HAVE_VORBISENC, [], [Do we have vorbisenc])
have_vorbisenc=yes
],[
have_vorbisenc=no
])
fi
AC_SUBST(VORBIS_CFLAGS)
AC_SUBST(VORBIS_LIBS)
dnl ================================================================
dnl Poppler checks.
dnl ================================================================
AC_ARG_WITH([poppler],
[AS_HELP_STRING([--with-poppler], [support for PDF files using Poppler @<:@default=yes@:>@])],
[])
if test "$with_poppler" = "no"; then
echo "Disabling PDF support via poppler"
have_poppler=no
else
PKG_CHECK_MODULES(POPPLER, [poppler-glib >= 0.16],
[
AC_DEFINE(HAVE_POPPLER_GLIB, [], [Do we have poppler glib bindings])
have_poppler=yes
],[
have_poppler=no
])
fi
AC_SUBST(POPPLER_CFLAGS)
AC_SUBST(POPPLER_LIBS)
dnl ================================================================
dnl FFmpeg/libav checks.
dnl ================================================================
AC_ARG_WITH([ffmpeg],
[AS_HELP_STRING([--with-ffmpeg], [support ePub Media Overlay audio using FFmpeg/libav @<:@default=yes@:>@])],
[])
if test "$with_ffmpeg" = "no"; then
echo "Disabling ePub Media Overlay support via the FFmpeg/libav library"
have_ffmpeg=no
else
PKG_CHECK_MODULES(FFMPEG, [libavformat >= 0.9 libavcodec >= 0.9 libavutil >= 0.9],
[
AC_DEFINE(HAVE_FFMPEG, [], [Do we have the FFmpeg libraries])
have_ffmpeg=yes
# API compatibility checks ...
CFLAGS="$CFLAGS $FFMPEG_CFLAGS"
LIBS="$LIBS $FFMPEG_LIBS"
AC_CHECK_FUNCS([av_frame_alloc])
AC_CHECK_FUNCS([avcodec_alloc_frame])
],[
have_ffmpeg=no
])
PKG_CHECK_MODULES(AVRESAMPLE, [libavresample],
[
AC_DEFINE(HAVE_LIBAVRESAMPLE, [], [Do we have the libavresample library])
have_avresample=yes
],[
have_avresample=no
])
fi
AC_SUBST(FFMPEG_CFLAGS)
AC_SUBST(FFMPEG_LIBS)
AC_SUBST(AVRESAMPLE_CFLAGS)
AC_SUBST(AVRESAMPLE_LIBS)
dnl ================================================================
dnl MIME Type Integration.
dnl ================================================================
AC_ARG_WITH([xdgdatadir],
[AS_HELP_STRING([--with-xdgdatadir=path], [Change where the theme icons and mime registrations are installed [DATADIR]])],
[opt_xdgdatadir=$withval])
if test x$opt_xdgdatadir = x; then
XDGDATADIR='${datadir}'
else
XDGDATADIR="$opt_xdgdatadir"
fi
AC_SUBST(XDGDATADIR)
AC_ARG_ENABLE(update-mime-database,
AC_HELP_STRING([--disable-update-mime-database],[do not update mime database after installation]),,
enable_update_mime_database=yes)
AM_CONDITIONAL(ENABLE_UPDATE_MIME_DATABASE, test x$enable_update_mime_database = xyes)
# update-mime-info is required to run the tests, so always look for it ...
AC_PATH_PROG(UPDATE_MIME_DATABASE, [update-mime-database], no)
if test $UPDATE_MIME_DATABASE = no; then
AC_MSG_ERROR([Cannot find update-mime-database, make sure it is installed and in your PATH])
fi
dnl ================================================================
dnl Doxygen documentation
dnl ================================================================
AC_CHECK_PROG(HAVE_DOT,dot,yes,no)
AC_SUBST(HAVE_DOT)
dnl ================================================================
dnl Compiler/linker hardening and security
dnl ================================================================
AC_ARG_ENABLE([all-warnings],
AS_HELP_STRING([--enable-all-warnings], [Turn on all compiler warnings]),
[if test x$enableval == xyes ; then
CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wconversion"
fi])
AC_ARG_ENABLE([format-security],
AS_HELP_STRING([--format-security], [Turn on printf format security checks]),
[if test x$enableval == xyes ; then
CXXFLAGS="$CXXFLAGS -Wformat -Wformat-security -Werror=format-security"
fi])
AC_ARG_ENABLE([stack-protection],
AS_HELP_STRING([--enable-stack-protection], [Use stack protection to protect against stack smashing]),
[if test x$enableval == xyes ; then
CXXFLAGS="$CXXFLAGS -fstack-protector-all -Wstack-protector --param ssp-buffer-size=4"
fi])
AC_ARG_ENABLE([pie],
AS_HELP_STRING([--enable-pie], [Generate a Position Independent Executable (PIE)]),
[if test x$enableval == xyes ; then
CXXFLAGS="$CXXFLAGS -pie -fPIE"
fi])
AC_ARG_ENABLE([signed-overflow-checks],
AS_HELP_STRING([--enable-signed-overflow-checks], [Generate traps for signed overflows]),
[if test x$enableval == xyes ; then
CXXFLAGS="$CXXFLAGS -ftrapv"
fi])
AC_ARG_ENABLE([buffer-checks],
AS_HELP_STRING([--enable-buffer-checks], [Generate checks for buffer overflows]),
[if test x$enableval == xyes ; then
CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2 -O2"
fi])
AC_ARG_ENABLE([relro],
AS_HELP_STRING([--enable-relro], [Prevent certain ELF sections being written to by the application]),
[if test x$enableval == xyes ; then
CXXFLAGS="$CXXFLAGS -Wl,-z,relro,-z,now"
fi])
dnl ================================================================
dnl Generate output.
dnl ================================================================
AC_CONFIG_FILES([
Makefile
po/Makefile.in])
AC_OUTPUT
AC_MSG_NOTICE([
Configuration for Cainteoir Text-to-Speech engine complete.
Source code location: ${srcdir}
XDG data location: ${XDGDATADIR}
Compiler: ${CXX}
Compiler flags: ${CXXFLAGS}
Python interpreter: ${PYTHON}
Documentation Generator: ${have_docgen}
eSpeak support: ${have_espeak}
MBROLA support: ${have_mbrola} (voice directory: ${MBROLA_DIR})
Pico support: ${have_pico} (voice directory: ${PICO_LANG_DIR})
PulseAudio support: ${have_pulseaudio}
ALSA support: ${have_alsa}
Ogg/Vorbis support: ${have_vorbisenc}
PDF support: ${have_poppler}
FFmpeg/libav support: ${have_ffmpeg}
libavresample support: ${have_avresample}
])