configure.ac 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. AC_PREREQ([2.63])
  2. AC_INIT([eSpeak NG], [1.49.3-dev], [https://github.com/espeak-ng/espeak-ng/issues], [espeak-ng], [https://github.com/espeak-ng/espeak-ng])
  3. AM_INIT_AUTOMAKE()
  4. LT_INIT
  5. m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES])
  6. AM_SILENT_RULES([yes])
  7. AC_CONFIG_SRCDIR([src])
  8. AC_CONFIG_MACRO_DIR([m4])
  9. AC_CONFIG_HEADERS([config.h])
  10. dnl ================================================================
  11. dnl configure arguments
  12. dnl ================================================================
  13. AC_ARG_ENABLE([rpath],
  14. [AS_HELP_STRING([--enable-rpath], [set hardcoded rpaths in the executable @<:@default=yes@:>@])],
  15. [],
  16. [enable_rpath=yes])
  17. AC_ARG_WITH([gradle],
  18. [AS_HELP_STRING([--with-gradle], [specify the gradle program to use @<:@default=gradle@:>@])],
  19. [GRADLE=$with_gradle],
  20. [GRADLE=gradle])
  21. AC_ARG_WITH([pcaudiolib],
  22. [AS_HELP_STRING([--with-pcaudiolib], [use the pcaudiolib library for audio output @<:@default=yes@:>@])],
  23. [])
  24. AC_ARG_WITH([klatt],
  25. [AS_HELP_STRING([--with-klatt], [enable the Klatt formant synthesizer @<:@default=yes@:>@])],
  26. [])
  27. AC_ARG_WITH([mbrola],
  28. [AS_HELP_STRING([--with-mbrola], [enable the MBROLA speech synthesizer @<:@default=yes@:>@])],
  29. [])
  30. AC_ARG_WITH([sonic],
  31. [AS_HELP_STRING([--with-sonic], [enable the sonic library to speed up the audio @<:@default=yes@:>@])],
  32. [])
  33. AC_ARG_WITH([async],
  34. [AS_HELP_STRING([--with-async], [enable support for async command processing @<:@default=yes@:>@])],
  35. [])
  36. AC_ARG_WITH([extdict-ru],
  37. [AS_HELP_STRING([--with-extdict-ru], [use the extended Russian Dictionary file @<:@default=no@:>@])],
  38. [])
  39. AC_ARG_WITH([extdict-zh],
  40. [AS_HELP_STRING([--with-extdict-zh], [use the extended Mandarin Chinese Dictionary file @<:@default=no@:>@])],
  41. [])
  42. AC_ARG_WITH([extdict-zhy],
  43. [AS_HELP_STRING([--with-extdict-zhy], [use the extended Cantonese Chinese Dictionary file @<:@default=no@:>@])],
  44. [])
  45. AC_ARG_WITH([libfuzzer],
  46. [AS_HELP_STRING([--with-libfuzzer], [enable libFuzzer in the fuzzer tests @<:@default=no@:>@])],
  47. [])
  48. dnl ================================================================
  49. dnl Program checks.
  50. dnl ================================================================
  51. AC_PROG_CC
  52. AC_PROG_MAKE_SET
  53. AC_PROG_LIBTOOL
  54. AC_PROG_LN_S
  55. AC_CHECK_PROG(NDKBUILD_CHECK,[ndk-build],yes)
  56. dnl ================================================================
  57. dnl gradle checks.
  58. dnl ================================================================
  59. AC_MSG_CHECKING([for gradle])
  60. if test -e ${GRADLE} ; then
  61. AC_MSG_RESULT([${GRADLE}])
  62. AM_CONDITIONAL(HAVE_GRADLE, [1])
  63. else
  64. AC_MSG_RESULT([no])
  65. AM_CONDITIONAL(HAVE_GRADLE, [0])
  66. fi
  67. AC_SUBST(GRADLE)
  68. dnl ================================================================
  69. dnl C99 compiler checks.
  70. dnl ================================================================
  71. AC_LANG_PUSH(C)
  72. AC_MSG_CHECKING([if $CC supports C99 without any flags])
  73. AC_COMPILE_IFELSE(
  74. [AC_LANG_PROGRAM(
  75. [[static inline int c99_restrict(int *restrict c99_restrict) {}]],
  76. [[]])],
  77. [AC_MSG_RESULT([yes])
  78. have_c99_native=yes],
  79. [AC_MSG_RESULT([no])
  80. have_c99_native=no])
  81. AC_LANG_POP(C)
  82. AC_LANG_PUSH(C)
  83. TEMP_CFLAGS="$CFLAGS"
  84. CFLAGS="$CFLAGS -std=c99"
  85. AC_MSG_CHECKING([if $CC supports C99 with the -std=c99 flag])
  86. AC_COMPILE_IFELSE(
  87. [AC_LANG_PROGRAM(
  88. [[static inline int c99_restrict(int *restrict c99_restrict) {}]],
  89. [[]])],
  90. [AC_MSG_RESULT([yes])
  91. have_c99_c99=yes],
  92. [AC_MSG_RESULT([no])
  93. have_c99_c99=no])
  94. CFLAGS="$TEMP_CFLAGS"
  95. AC_LANG_POP(C)
  96. AC_MSG_CHECKING([if $CC supports C99])
  97. if test "$have_c99_c99" = yes ; then
  98. AC_MSG_RESULT([-std=c99])
  99. CFLAGS="$CFLAGS -std=c99"
  100. elif test "$have_c99_native" = yes ; then
  101. AC_MSG_RESULT([yes])
  102. else
  103. AC_MSG_RESULT([no])
  104. AC_MSG_ERROR([C99 is not supported by $CC.])
  105. fi
  106. dnl ================================================================
  107. dnl FreeBSD check.
  108. dnl ================================================================
  109. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  110. #if ! defined(__FreeBSD__)
  111. #error macro not defined
  112. #endif
  113. ]])], [FREEBSD_FOUND="yes"], [FREEBSD_FOUND="no"])
  114. AC_MSG_CHECKING([if targeting FreeBSD])
  115. if test "$FREEBSD_FOUND" = "yes" ; then
  116. AC_MSG_RESULT([-D__BSD_VISIBLE])
  117. CFLAGS="$CFLAGS -D__BSD_VISIBLE"
  118. else
  119. AC_MSG_RESULT([no])
  120. fi
  121. dnl ================================================================
  122. dnl library checks.
  123. dnl ================================================================
  124. AC_CHECK_HEADERS([endian.h]) dnl Linux
  125. AC_CHECK_HEADERS([fcntl.h]) dnl POSIX
  126. AC_CHECK_HEADERS([getopt.h]) dnl POSIX
  127. AC_CHECK_HEADERS([locale.h]) dnl C89
  128. AC_CHECK_HEADERS([stddef.h]) dnl C89
  129. AC_CHECK_HEADERS([stdbool.h]) dnl C99
  130. AC_CHECK_HEADERS([sys/endian.h]) dnl BSD
  131. AC_CHECK_HEADERS([sys/time.h]) dnl POSIX
  132. AC_CHECK_HEADERS([wchar.h]) dnl C89
  133. AC_CHECK_HEADERS([wctype.h]) dnl C89
  134. AC_TYPE_SIZE_T
  135. AC_TYPE_SSIZE_T
  136. AC_TYPE_UINT16_T
  137. AC_TYPE_UINT32_T
  138. AC_TYPE_UINT64_T
  139. AC_FUNC_FORK
  140. AC_FUNC_STRCOLL
  141. AC_FUNC_ERROR_AT_LINE
  142. AC_CHECK_FUNCS([dup2])
  143. AC_CHECK_FUNCS([getopt_long])
  144. AC_CHECK_FUNCS([gettimeofday])
  145. AC_CHECK_FUNCS([malloc]) dnl Avoid "Undefined reference to rpl_malloc" when using AC_FUNC_MALLOC.
  146. AC_CHECK_FUNCS([memchr])
  147. AC_CHECK_FUNCS([memmove])
  148. AC_CHECK_FUNCS([memset])
  149. AC_CHECK_FUNCS([mkdir])
  150. AC_CHECK_FUNCS([mkstemp])
  151. AC_CHECK_FUNCS([pow])
  152. AC_CHECK_FUNCS([realloc]) dnl Avoid "Undefined reference to rpl_malloc" when using AC_FUNC_REALLOC.
  153. AC_CHECK_FUNCS([setlocale])
  154. AC_CHECK_FUNCS([sqrt])
  155. AC_CHECK_FUNCS([strchr])
  156. AC_CHECK_FUNCS([strdup])
  157. AC_CHECK_FUNCS([strerror])
  158. AC_CHECK_FUNCS([strrchr])
  159. AC_CHECK_FUNCS([strstr])
  160. dnl ================================================================
  161. dnl PCAudioLib checks.
  162. dnl ================================================================
  163. if test "$with_pcaudiolib" = "no"; then
  164. echo "Disabling audio output support via pcaudiolib"
  165. have_pcaudiolib=no
  166. else
  167. AC_CHECK_HEADERS([pcaudiolib/audio.h],
  168. [
  169. have_pcaudiolib=yes
  170. PCAUDIOLIB_CFLAGS=
  171. PCAUDIOLIB_LIBS=-lpcaudio
  172. ],[
  173. have_pcaudiolib=no
  174. ])
  175. fi
  176. AC_SUBST(PCAUDIOLIB_CFLAGS)
  177. AC_SUBST(PCAUDIOLIB_LIBS)
  178. dnl ================================================================
  179. dnl Optional compilation checks.
  180. dnl ================================================================
  181. if test "$with_klatt" = "no" ; then
  182. have_klatt=no
  183. else
  184. have_klatt=yes
  185. fi
  186. if test "$with_mbrola" = "no" ; then
  187. have_mbrola=no
  188. else
  189. have_mbrola=yes
  190. fi
  191. if test "$with_sonic" = "no" ; then
  192. have_sonic=no
  193. else
  194. AC_CHECK_HEADERS([sonic.h],
  195. [
  196. AC_CHECK_LIB([sonic], [sonicCreateStream])
  197. have_sonic=yes
  198. ],[
  199. have_sonic=no
  200. ])
  201. fi
  202. if test "$with_async" = "no" ; then
  203. have_async=no
  204. else
  205. have_async=yes
  206. fi
  207. AM_CONDITIONAL(OPT_KLATT, [test x"$have_klatt" = xyes])
  208. AM_CONDITIONAL(OPT_MBROLA, [test x"$have_mbrola" = xyes])
  209. AM_CONDITIONAL(OPT_ASYNC, [test x"$have_async" = xyes])
  210. dnl ================================================================
  211. dnl ronn checks.
  212. dnl ================================================================
  213. AC_CHECK_PROG(RONN, ronn, ronn, no)
  214. AM_CONDITIONAL(HAVE_RONN, [test ! x"$RONN" = xno])
  215. dnl ================================================================
  216. dnl Extended dictionary checks.
  217. dnl ================================================================
  218. if test "$with_extdict_ru" = "yes" ; then
  219. have_extdict_ru=yes
  220. else
  221. have_extdict_ru=no
  222. fi
  223. if test "$with_extdict_zh" = "yes" ; then
  224. have_extdict_zh=yes
  225. else
  226. have_extdict_zh=no
  227. fi
  228. if test "$with_extdict_zhy" = "yes" ; then
  229. have_extdict_zhy=yes
  230. else
  231. have_extdict_zhy=no
  232. fi
  233. AM_CONDITIONAL(HAVE_RU_EXTENDED_DICTIONARY, [test x"$have_extdict_ru" = xyes])
  234. AM_CONDITIONAL(HAVE_ZH_EXTENDED_DICTIONARY, [test x"$have_extdict_zh" = xyes])
  235. AM_CONDITIONAL(HAVE_ZHY_EXTENDED_DICTIONARY, [test x"$have_extdict_zhy" = xyes])
  236. dnl ================================================================
  237. dnl Compiler warnings.
  238. dnl
  239. dnl Reference: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
  240. dnl ================================================================
  241. AX_CHECK_COMPILE_FLAG([-Wimplicit], [CFLAGS="-Wimplicit $CFLAGS"])
  242. AX_CHECK_COMPILE_FLAG([-Wmissing-prototypes], [CFLAGS="-Wmissing-prototypes $CFLAGS"])
  243. AX_CHECK_COMPILE_FLAG([-Wreturn-type], [CFLAGS="-Wreturn-type $CFLAGS"])
  244. AX_CHECK_COMPILE_FLAG([-Wuninitialized], [CFLAGS="-Wuninitialized $CFLAGS"])
  245. AX_CHECK_COMPILE_FLAG([-Wunused], [CFLAGS="-Wunused $CFLAGS"])
  246. AX_CHECK_COMPILE_FLAG([-Wunused-parameter], [CFLAGS="-Wunused-parameter $CFLAGS"])
  247. dnl ================================================================
  248. dnl libFuzzer checks.
  249. dnl ================================================================
  250. if test "$with_libfuzzer" = "yes" ; then
  251. have_libfuzzer=yes
  252. else
  253. have_libfuzzer=no
  254. fi
  255. AM_CONDITIONAL(HAVE_LIBFUZZER, [test x"$have_libfuzzer" = xyes])
  256. dnl ================================================================
  257. dnl Generate output.
  258. dnl ================================================================
  259. AC_CONFIG_FILES([Makefile espeak-ng.pc])
  260. AC_OUTPUT
  261. if test "$enable_rpath" = "yes" ; then
  262. true
  263. else
  264. # See https://old-en.opensuse.org/openSUSE:Packaging_Guidelines#Removing_Rpath
  265. sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
  266. sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
  267. fi
  268. AC_MSG_NOTICE([
  269. Configuration for eSpeak NG complete.
  270. Source code location: ${srcdir}
  271. C99 Compiler: ${CC}
  272. C99 Compiler flags: ${CFLAGS}
  273. Sonic: ${have_sonic}
  274. PCAudioLib: ${have_pcaudiolib}
  275. gradle (Android): ${GRADLE}
  276. ndk-build (Android): ${NDKBUILD_CHECK}
  277. Klatt: ${have_klatt}
  278. MBROLA: ${have_mbrola}
  279. Async: ${have_async}
  280. Extended Dictionaries:
  281. Russian: ${have_extdict_ru}
  282. Chinese (Mandarin): ${have_extdict_zh}
  283. Chinese (Cantonese): ${have_extdict_zhy}
  284. ])