configure.ac 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. dnl Copyright (C) 1999-2022 Erik de Castro Lopo <[email protected]>.
  2. dnl Require autoconf version >= 2.69
  3. AC_PREREQ([2.69])
  4. AC_INIT([libsndfile],[1.2.2],[[email protected]],
  5. [libsndfile],[http://libsndfile.github.io/libsndfile/])
  6. dnl Check whether we want to set defaults for CFLAGS, CXXFLAGS, CPPFLAGS and LDFLAGS
  7. AC_MSG_CHECKING([whether configure should try to set CFLAGS/CXXFLAGS/CPPFLAGS/LDFLAGS])
  8. AS_IF([test "x${CFLAGS+set}" = "xset" || test "x${CXXFLAGS+set}" = "xset" || test "x${CPPFLAGS+set}" = "xset" || test "x${LDFLAGS+set}" = "xset"], [
  9. enable_flags_setting=no
  10. : ${CFLAGS=""}
  11. : ${CXXFLAGS=""}
  12. ], [
  13. enable_flags_setting=yes
  14. dnl Set to empty flags so AC_PROG_CC and
  15. dnl AC_PROG_CXX do not add -g -O2
  16. CFLAGS=""
  17. CXXFLAGS=""
  18. ])
  19. AC_MSG_RESULT([${enable_flags_setting}])
  20. dnl Put config stuff in 'build-aux'.
  21. AC_CONFIG_AUX_DIR([build-aux])
  22. AC_CONFIG_SRCDIR([src/sndfile.c])
  23. AC_CANONICAL_HOST
  24. AC_CONFIG_MACRO_DIR([m4])
  25. AC_CONFIG_HEADERS([src/config.h])
  26. AM_INIT_AUTOMAKE([1.14 foreign dist-xz no-dist-gzip serial-tests subdir-objects])
  27. AM_SILENT_RULES([yes])
  28. dnl ====================================================================================
  29. AC_PROG_CC
  30. AC_PROG_CC_C99
  31. AS_IF([test "x$ac_cv_prog_cc_c99" = "xno"], [
  32. AC_MSG_ERROR([libsndfile requires a C99 capable compiler!])
  33. ])
  34. AC_USE_SYSTEM_EXTENSIONS
  35. AC_PROG_CXX
  36. AC_LANG([C])
  37. AX_COMPILER_VENDOR
  38. AX_COMPILER_VERSION
  39. AC_LANG_PUSH([C++])
  40. AX_COMPILER_VENDOR
  41. AX_COMPILER_VERSION
  42. AC_LANG_POP([C++])
  43. AC_PROG_SED
  44. AM_PROG_AR
  45. LT_INIT([disable-static win32-dll])
  46. LT_PROG_RC
  47. AC_PROG_INSTALL
  48. AC_PROG_LN_S
  49. AM_PATH_PYTHON
  50. AC_CHECK_PROG([HAVE_AUTOGEN], [autogen], [yes], [no])
  51. AC_CHECK_PROG([HAVE_WINE], [wine], [yes], [no])
  52. AC_CHECK_PROG([HAVE_XCODE_SELECT], [xcode-select], [yes], [no])
  53. dnl ------------------------------------------------------------------------------------
  54. dnl Rules for library version information:
  55. dnl
  56. dnl 1. Start with version information of `0:0:0' for each libtool library.
  57. dnl 2. Update the version information only immediately before a public release of
  58. dnl your software. More frequent updates are unnecessary, and only guarantee
  59. dnl that the current interface number gets larger faster.
  60. dnl 3. If the library source code has changed at all since the last update, then
  61. dnl increment revision (`c:r:a' becomes `c:r+1:a').
  62. dnl 4. If any interfaces have been added, removed, or changed since the last update,
  63. dnl increment current, and set revision to 0.
  64. dnl 5. If any interfaces have been added since the last public release, then increment
  65. dnl age.
  66. dnl 6. If any interfaces have been removed since the last public release, then set age
  67. dnl to 0.
  68. dnl This is libtool version of library, we add it to `--version-info` property.
  69. m4_define([lt_current], [1])
  70. m4_define([lt_revision], [37])
  71. m4_define([lt_age], [0])
  72. dnl This is ABI version for linker scripts, CMake uses the same format for
  73. dnl VERSION property of shared library.
  74. dnl The formula is: c:r:a -> c-a:a:r
  75. m4_define([abi_version_major], [m4_eval(lt_current - lt_age)])
  76. m4_define([abi_version_minor], [lt_age])
  77. m4_define([abi_version_patch], [lt_revision])
  78. dnl ------------------------------------------------------------------------------------
  79. AC_CHECK_HEADERS([endian.h])
  80. AC_CHECK_HEADERS([byteswap.h])
  81. AC_CHECK_HEADERS([locale.h])
  82. AC_CHECK_HEADERS([sys/time.h])
  83. AC_CHECK_HEADERS([immintrin.h])
  84. AC_CHECK_HEADERS([stdbool.h])
  85. AC_HEADER_SYS_WAIT
  86. AC_CHECK_DECLS([S_IRGRP])
  87. AS_IF([test "x$ac_cv_have_decl_S_IRGRP" = "xyes"], [
  88. AC_DEFINE_UNQUOTED([HAVE_DECL_S_IRGRP], [1], [Set to 1 if S_IRGRP is defined.])
  89. ], [
  90. AC_DEFINE_UNQUOTED([HAVE_DECL_S_IRGRP], [0], [Set to 0 if S_IRGRP is not defined.])
  91. ])
  92. AM_CONDITIONAL([LINUX_MINGW_CROSS_TEST],
  93. [test "x${build_os}:${host_os}:${HAVE_WINE}" = "xlinux-gnu:mingw32msvc:yes"])
  94. dnl ====================================================================================
  95. dnl Couple of initializations here. Fill in real values later.
  96. SHLIB_VERSION_ARG=""
  97. dnl ====================================================================================
  98. dnl Finished checking, handle options.
  99. AC_ARG_ENABLE(experimental,
  100. AS_HELP_STRING([--enable-experimental], [enable experimental code]))
  101. AS_IF([test "x$enable_experimental" = "xyes"], [
  102. EXPERIMENTAL_CODE=1
  103. ], [
  104. EXPERIMENTAL_CODE=0
  105. ])
  106. AC_DEFINE_UNQUOTED([ENABLE_EXPERIMENTAL_CODE], [${EXPERIMENTAL_CODE}], [Set to 1 to enable experimental code.])
  107. AC_ARG_ENABLE([werror],
  108. [AS_HELP_STRING([--enable-werror], [enable -Werror in all Makefiles])])
  109. AC_ARG_ENABLE([cpu-clip],
  110. [AS_HELP_STRING([--disable-cpu-clip], [disable tricky cpu specific clipper])])
  111. AC_ARG_ENABLE([bow-docs],
  112. [AS_HELP_STRING([--enable-bow-docs], [enable black-on-white html docs])])
  113. AC_ARG_ENABLE([sqlite],
  114. [AS_HELP_STRING([--disable-sqlite], [disable use of sqlite])])
  115. AC_ARG_ENABLE([alsa],
  116. [AS_HELP_STRING([--disable-alsa], [disable ALSA support (default=autodetect)])], [], [enable_alsa=auto])
  117. AC_ARG_ENABLE([external-libs],
  118. [AS_HELP_STRING([--disable-external-libs], [disable use of FLAC, Ogg and Vorbis [[default=no]]])])
  119. AC_ARG_ENABLE([mpeg],
  120. [AS_HELP_STRING([--disable-mpeg], [disable use of LAME/MPG123 for MPEG (MP3) [[defaults=no]]])])
  121. AC_ARG_ENABLE(octave,
  122. [AS_HELP_STRING([--enable-octave], [enable building of GNU Octave module])])
  123. AC_ARG_ENABLE([full-suite],
  124. [AS_HELP_STRING([--disable-full-suite], [disable building and installing programs, documentation, only build library [[default=no]]])])
  125. AM_CONDITIONAL([FULL_SUITE], [test "x$enable_full_suite" != "xno"])
  126. AC_ARG_ENABLE([test-coverage],
  127. [AS_HELP_STRING([--enable-test-coverage], [enable test coverage])])
  128. AM_CONDITIONAL([ENABLE_TEST_COVERAGE], [test "x$enable_test_coverage" = "xyes"])
  129. AC_ARG_ENABLE([ossfuzzers],
  130. [AS_HELP_STRING([--enable-ossfuzzers], [Whether to generate the fuzzers for OSS-Fuzz])])
  131. AM_CONDITIONAL([USE_OSSFUZZERS], [test "x$enable_ossfuzzers" = "xyes"])
  132. AC_SUBST([LIB_FUZZING_ENGINE])
  133. AM_CONDITIONAL([USE_OSSFUZZ_FLAG], [test "x$LIB_FUZZING_ENGINE" = "x-fsanitize=fuzzer"])
  134. AM_CONDITIONAL([USE_OSSFUZZ_STATIC], [test -f "$LIB_FUZZING_ENGINE"])
  135. dnl ====================================================================================
  136. dnl Check types and their sizes.
  137. AC_CHECK_SIZEOF([wchar_t], [4])
  138. AC_CHECK_SIZEOF([short], [2])
  139. AC_CHECK_SIZEOF([int], [4])
  140. AC_CHECK_SIZEOF([long], [4])
  141. AC_CHECK_SIZEOF([float], [4])
  142. AC_CHECK_SIZEOF([double], [4])
  143. AC_CHECK_SIZEOF([void*], [8])
  144. AC_CHECK_SIZEOF([size_t], [4])
  145. AC_CHECK_SIZEOF([int64_t], [8])
  146. AC_CHECK_SIZEOF([long long], [8])
  147. dnl Check for common 64 bit file offset types.
  148. AC_CHECK_SIZEOF([off_t], [1])
  149. AS_IF([test "x$enable_largefile:$ac_cv_sizeof_off_t" = "xno:8"], [
  150. AC_MSG_ERROR(["Error : Cannot disable large file support because sizeof (off_t) == 8."])
  151. ])
  152. AS_CASE([$host_os],
  153. [mingw32*], [
  154. AC_DEFINE([__USE_MINGW_ANSI_STDIO], [1], [Set to 1 to use C99 printf/snprintf in MinGW.])
  155. ],
  156. [
  157. AS_IF([test "x$ac_cv_sizeof_off_t" = "x8"], [
  158. dnl If sizeof (off_t) is 8, no further checking is needed.
  159. ], [
  160. dnl Save the old sizeof (off_t) value and then unset it to see if it
  161. dnl changes when Large File Support is enabled.
  162. pre_largefile_sizeof_off_t=$ac_cv_sizeof_off_t
  163. unset ac_cv_sizeof_off_t
  164. AC_SYS_LARGEFILE
  165. AS_IF([test "x$ac_cv_sys_largefile_CFLAGS" = "xno"], [
  166. ac_cv_sys_largefile_CFLAGS=""
  167. ])
  168. AS_IF([test "x$ac_cv_sys_largefile_LDFLAGS" = "xno"], [
  169. ac_cv_sys_largefile_LDFLAGS=""
  170. ])
  171. AS_IF([test "x$ac_cv_sys_largefile_LIBS" = "xno"], [
  172. ac_cv_sys_largefile_LIBS=""
  173. ])
  174. AC_CHECK_SIZEOF(off_t,1)
  175. ])
  176. ])
  177. AC_TYPE_SSIZE_T
  178. dnl ====================================================================================
  179. dnl Determine endian-ness of host processor.
  180. AC_C_BIGENDIAN([
  181. dnl big-endian
  182. ac_cv_c_big_endian=1
  183. ac_cv_c_little_endian=0
  184. ], [
  185. dnl little-endian
  186. ac_cv_c_big_endian=0
  187. ac_cv_c_little_endian=1
  188. ])
  189. AC_DEFINE_UNQUOTED([CPU_IS_BIG_ENDIAN], [${ac_cv_c_big_endian}], [Host processor is big endian.])
  190. AC_DEFINE_UNQUOTED([CPU_IS_LITTLE_ENDIAN], [${ac_cv_c_little_endian}], [Host processor is little endian.])
  191. dnl ====================================================================================
  192. dnl Check for functions.
  193. AC_CHECK_FUNCS([malloc calloc realloc free])
  194. AC_CHECK_FUNCS([open read write lseek lseek64])
  195. AC_CHECK_FUNCS([fstat fstat64 ftruncate fsync])
  196. AC_CHECK_FUNCS([snprintf vsnprintf])
  197. AC_CHECK_FUNCS([gmtime gmtime_r localtime localtime_r gettimeofday])
  198. AC_CHECK_FUNCS([mmap getpagesize])
  199. AC_CHECK_FUNCS([setlocale])
  200. AC_CHECK_FUNCS([pipe waitpid])
  201. AC_SEARCH_LIBS([floor], [m], [], [
  202. AC_MSG_ERROR([unable to find the floor() function!])
  203. ])
  204. AC_CHECK_FUNCS([floor ceil fmod lrint lrintf])
  205. dnl ====================================================================================
  206. dnl Check for requirements for building plugins for other languages/enviroments.
  207. dnl Octave maths environment http://www.octave.org/
  208. AS_IF([test "x$cross_compiling" = "xno"], [
  209. AS_IF([test "x$enable_octave" = "xno"], [
  210. AM_CONDITIONAL(BUILD_OCTAVE_MOD, false)
  211. ], [
  212. AC_OCTAVE_BUILD
  213. ])
  214. ], [
  215. AM_CONDITIONAL(BUILD_OCTAVE_MOD, false)
  216. ])
  217. dnl ====================================================================================
  218. dnl Check for Ogg, Vorbis and FLAC.
  219. HAVE_EXTERNAL_XIPH_LIBS=0
  220. EXTERNAL_XIPH_CFLAGS=""
  221. EXTERNAL_XIPH_LIBS=""
  222. EXTERNAL_XIPH_REQUIRE=""
  223. dnl Check for pkg-config outside the if statement.
  224. PKG_PROG_PKG_CONFIG
  225. AX_REQUIRE_DEFINED([PKG_INSTALLDIR])
  226. PKG_INSTALLDIR
  227. AS_IF([test -n "$PKG_CONFIG"], [
  228. AS_IF([test "x$enable_external_libs" = "xno"], [
  229. AC_MSG_WARN([[*** External libs (FLAC, Ogg, Vorbis) disabled. ***]])
  230. ], [
  231. PKG_CHECK_MOD_VERSION(FLAC, flac >= 1.3.1, ac_cv_flac=yes, ac_cv_flac=no)
  232. dnl Make sure the FLAC_CFLAGS value is sane.
  233. FLAC_CFLAGS=`echo $FLAC_CFLAGS | $SED "s|include/FLAC|include|"`
  234. PKG_CHECK_MOD_VERSION(OGG, ogg >= 1.3.0, ac_cv_ogg=yes, ac_cv_ogg=no)
  235. AS_IF([test "x$enable_experimental" = "xyes"], [
  236. PKG_CHECK_MOD_VERSION(SPEEX, speex >= 1.2, ac_cv_speex=yes, ac_cv_speex=no)
  237. ], [
  238. SPEEX_CFLAGS=""
  239. SPEEX_LIBS=""
  240. ])
  241. dnl Vorbis versions earlier than 1.2.3 have bugs that cause the libsndfile
  242. dnl test suite to fail on MIPS, PowerPC and others.
  243. dnl See: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=549899
  244. PKG_CHECK_MOD_VERSION(VORBIS, vorbis >= 1.2.3, ac_cv_vorbis=yes, ac_cv_vorbis=no)
  245. PKG_CHECK_MOD_VERSION(VORBISENC, vorbisenc >= 1.2.3, ac_cv_vorbisenc=yes, ac_cv_vorbisenc=no)
  246. PKG_CHECK_MOD_VERSION(OPUS, opus >= 1.1, ac_cv_opus=yes, ac_cv_opus=no)
  247. enable_external_libs=yes
  248. ])
  249. AS_IF([test "x$ac_cv_flac$ac_cv_ogg$ac_cv_vorbis$ac_cv_vorbisenc$ac_cv_opus" = "xyesyesyesyesyes"], [
  250. HAVE_EXTERNAL_XIPH_LIBS=1
  251. enable_external_libs=yes
  252. EXTERNAL_XIPH_CFLAGS="$FLAC_CFLAGS $VORBIS_CFLAGS $VORBISENC_CFLAGS $SPEEX_CFLAGS $OPUS_CFLAGS $OGG_CFLAGS "
  253. EXTERNAL_XIPH_LIBS="$FLAC_LIBS $VORBIS_LIBS $VORBISENC_LIBS $SPEEX_LIBS $OPUS_LIBS $OGG_LIBS "
  254. EXTERNAL_XIPH_REQUIRE="flac ogg vorbis vorbisenc opus"
  255. if test x$ac_cv_speex = "xyes" ; then
  256. EXTERNAL_XIPH_REQUIRE="$EXTERNAL_XIPH_REQUIRE speex"
  257. fi
  258. ], [
  259. AS_ECHO([""])
  260. AC_MSG_WARN([[*** One or more of the external libraries (ie libflac, libogg,]])
  261. AC_MSG_WARN([[*** libvorbis and libopus) is either missing (possibly only the development]])
  262. AC_MSG_WARN([[*** headers) or is of an unsupported version.]])
  263. AC_MSG_WARN([[***]])
  264. AC_MSG_WARN([[*** Unfortunately, for ease of maintenance, the external libs]])
  265. AC_MSG_WARN([[*** are an all or nothing affair.]])
  266. AS_ECHO([""])
  267. enable_external_libs=no
  268. ])
  269. ])
  270. AC_DEFINE_UNQUOTED([HAVE_EXTERNAL_XIPH_LIBS], [$HAVE_EXTERNAL_XIPH_LIBS], [Will be set to 1 if flac, ogg, vorbis, and opus are available.])
  271. dnl ====================================================================================
  272. dnl Check for MPEG libraris liblame
  273. ac_cv_lame="no"
  274. ac_cv_mpg123="no"
  275. HAVE_MPEG=0
  276. EXTERNAL_MPEG_REQUIRE=""
  277. EXTERNAL_MPEG_LIBS=""
  278. AS_IF([test -n "$PKG_CONFIG"], [
  279. AS_IF([test "x$enable_mpeg" = "xno"], [
  280. AC_MSG_WARN([[*** MPEG (Lame/MPG123) disabled. ***]])
  281. ], [
  282. AC_CHECK_HEADER(lame/lame.h,
  283. lame_header_found="yes",
  284. lame_header_found="no")
  285. AC_SEARCH_LIBS(lame_set_VBR_q, [lame mp3lame], [lame_lib_found="yes"], [lame_lib_found="no"])
  286. AS_IF([test "x$lame_lib_found$lame_header_found" = "xyesyes"], [
  287. ac_cv_lame="yes"
  288. ], [
  289. AC_MSG_WARN([["MPEG support selected but external Lame library cannot be found.]])
  290. ])
  291. PKG_CHECK_MOD_VERSION([MPG123], [libmpg123 >= 1.25.10], [
  292. ac_cv_mpg123="yes"
  293. ], [
  294. AC_MSG_WARN([["MPEG support selected but external MPG123 library cannot be found.]])
  295. ])
  296. AS_IF([test "x$ac_cv_lame$ac_cv_mpg123" = "xyesyes"], [
  297. enable_mpeg="yes"
  298. HAVE_MPEG=1
  299. EXTERNAL_MPEG_REQUIRE="libmpg123"
  300. EXTERNAL_MPEG_LIBS="-lmp3lame"
  301. MPEG_CFLAGS="$MPG123_CFLAGS"
  302. MPEG_LIBS="$MPG123_LIBS"
  303. ], [
  304. enable_mpeg="no"
  305. AS_ECHO([""])
  306. AC_MSG_WARN([[*** MPEG support disabled.]])
  307. AS_ECHO([""])
  308. ])
  309. ])
  310. ])
  311. AC_DEFINE_UNQUOTED([HAVE_MPEG], [$HAVE_MPEG], [Will be set to 1 if lame, mpg123 mpeg support is available.])
  312. dnl ====================================================================================
  313. dnl Check for libsqlite3 (only used in regtest).
  314. ac_cv_sqlite3=0
  315. AS_IF([test "x$enable_sqlite" != "xno"], [
  316. PKG_CHECK_MOD_VERSION([SQLITE3], [sqlite3 >= 3.2], [ac_cv_sqlite3=1], [ac_cv_sqlite3=0])
  317. ])
  318. AC_DEFINE_UNQUOTED([HAVE_SQLITE3], [${ac_cv_sqlite3}], [Set to 1 if you have libsqlite3.])
  319. AM_CONDITIONAL([HAVE_SQLITE3], [test "x$ac_cv_sqlite3" = "x1"])
  320. dnl ====================================================================================
  321. dnl Determine if the processor can do clipping on float to int conversions.
  322. AS_IF([test "x$enable_cpu_clip" != "xno"], [
  323. MN_C_CLIP_MODE
  324. ], [
  325. AS_ECHO(["checking processor clipping capabilities... disabled"])
  326. ac_cv_c_clip_positive=0
  327. ac_cv_c_clip_negative=0
  328. ])
  329. AC_DEFINE_UNQUOTED([CPU_CLIPS_POSITIVE], [${ac_cv_c_clip_positive}],
  330. [Host processor clips on positive float to int conversion.])
  331. AC_DEFINE_UNQUOTED([CPU_CLIPS_NEGATIVE], [${ac_cv_c_clip_negative}],
  332. [Host processor clips on negative float to int conversion.])
  333. dnl ====================================================================================
  334. dnl Host OS specific stuff.
  335. OS_SPECIFIC_CFLAGS=""
  336. OS_SPECIFIC_LINKS=""
  337. os_is_win32=0
  338. os_is_openbsd=0
  339. use_windows_api=0
  340. AS_CASE([$host_os],
  341. [darwin* | rhapsody*], [
  342. AS_IF([test "x$HAVE_XCODE_SELECT" = "xyes"], [
  343. developer_path=`xcode-select --print-path`
  344. ], [
  345. developer_path="/Developer"
  346. ])
  347. OS_SPECIFIC_LINKS="-framework CoreAudio -framework AudioToolbox -framework CoreFoundation"],
  348. [mingw*], [
  349. os_is_win32=1
  350. use_windows_api=1
  351. OS_SPECIFIC_LINKS="-lwinmm"],
  352. [openbsd*], [
  353. os_is_openbsd=1
  354. ])
  355. AC_DEFINE_UNQUOTED([OS_IS_WIN32], [${os_is_win32}], [Set to 1 if compiling for Win32])
  356. AC_DEFINE_UNQUOTED([OS_IS_OPENBSD], [${os_is_openbsd}], [Set to 1 if compiling for OpenBSD])
  357. AC_DEFINE_UNQUOTED([USE_WINDOWS_API], [${use_windows_api}], [Set to 1 to use the native windows API])
  358. AM_CONDITIONAL(USE_WIN_VERSION_FILE, test ${use_windows_api} -eq 1)
  359. dnl ====================================================================================
  360. dnl Check for ALSA.
  361. AS_IF([test "x$enable_alsa" != "xno"], [
  362. PKG_CHECK_MODULES([ALSA], [alsa], [
  363. dnl actually test whether ALSA really works, in
  364. dnl order to dodge wrong cross-compilation pickups
  365. save_CFLAGS="${CFLAGS}"
  366. save_LIBS="${LIBS}"
  367. CFLAGS="${CFLAGS} ${ALSA_CFLAGS}"
  368. LIBS="${LIBS} ${ALSA_LIBS}"
  369. AC_CHECK_HEADERS([alsa/asoundlib.h])
  370. AS_IF([test "x$ac_cv_header_alsa_asoundlib_h" = "xyes"], [
  371. dnl ALSA definitely works
  372. AC_DEFINE([HAVE_ALSA], [1], [Set to 1 if you have alsa])
  373. alsa_works="yes"
  374. ], [
  375. dnl picked up wrong ALSA
  376. alsa_works="no"
  377. dnl reset flags
  378. ALSA_CFLAGS=""
  379. ALSA_LIBS=""
  380. ])
  381. CFLAGS="${save_CFLAGS}"
  382. LIBS="${save_LIBS}"
  383. ], [
  384. dnl could not find ALSA
  385. alsa_works="no"
  386. ])
  387. AS_IF([test "x$alsa_works" = "xno"], [
  388. AS_IF([test "x$enable_alsa" = "xyes"], [
  389. dnl explicitly passed --enable-alsa, hence error out loud and clearly
  390. AC_MSG_ERROR([You explicitly requested alsa support, but alsa could not be found!])
  391. ], [
  392. dnl did not explicitly pass --enable-alsa, relying on default automagic on
  393. enable_alsa="no (auto)"
  394. ])
  395. ])
  396. ])
  397. dnl ====================================================================================
  398. dnl Check for OpenBSD's sndio.
  399. SNDIO_LIBS=""
  400. HAVE_SNDIO_H=0
  401. AS_CASE([$host_os],
  402. [openbsd*], [
  403. AC_CHECK_HEADERS(sndio.h)
  404. AS_IF([test "x$ac_cv_header_sndio_h" = "xyes"], [
  405. SNDIO_LIBS="-lsndio"
  406. HAVE_SNDIO_H=1
  407. ])
  408. ])
  409. AC_DEFINE_UNQUOTED([HAVE_SNDIO_H], [${HAVE_SNDIO_H}], [Set to 1 if <sndio.h> is available.])
  410. dnl ====================================================================================
  411. dnl Test for sanity when cross-compiling.
  412. AS_IF([test "x$ac_cv_sizeof_short" != "x2"], [
  413. AC_MSG_WARN([[******************************************************************]])
  414. AC_MSG_WARN([[*** sizeof (short) != 2. ]])
  415. AC_MSG_WARN([[******************************************************************]])
  416. ])
  417. AS_IF([test "x$ac_cv_sizeof_int" != "x4"], [
  418. AC_MSG_WARN([[******************************************************************]])
  419. AC_MSG_WARN([[*** sizeof (int) != 4 ]])
  420. AC_MSG_WARN([[******************************************************************]])
  421. ])
  422. AS_IF([test "x$ac_cv_sizeof_float" != "x4"], [
  423. AC_MSG_WARN([[******************************************************************]])
  424. AC_MSG_WARN([[*** sizeof (float) != 4. ]])
  425. AC_MSG_WARN([[******************************************************************]])
  426. ])
  427. AS_IF([test "x$ac_cv_sizeof_double" != "x8"], [
  428. AC_MSG_WARN([[******************************************************************]])
  429. AC_MSG_WARN([[*** sizeof (double) != 8. ]])
  430. AC_MSG_WARN([[******************************************************************]])
  431. ])
  432. AS_IF([test "x$ac_cv_prog_HAVE_AUTOGEN" = "xno"], [
  433. AC_MSG_WARN([[Touching files in directory tests/.]])
  434. touch tests/*.c tests/*.h
  435. ])
  436. dnl ====================================================================================
  437. dnl Settings for the HTML documentation.
  438. AS_IF([test "x$enable_bow_docs" = "xyes"], [
  439. HTML_BGCOLOUR="white"
  440. HTML_FGCOLOUR="black"
  441. ], [
  442. HTML_BGCOLOUR="black"
  443. HTML_FGCOLOUR="white"
  444. ])
  445. dnl ====================================================================================
  446. dnl Now use the information from the checking stage.
  447. win32_target_dll=0
  448. COMPILER_IS_GCC=0
  449. AS_IF([test "x$enable_flags_setting" = "xyes"], [
  450. AX_APPEND_COMPILE_FLAGS([-O2 -pipe], [CFLAGS])
  451. AC_LANG_PUSH([C++])
  452. AX_APPEND_COMPILE_FLAGS([-O2 -pipe], [CXXFLAGS])
  453. AC_LANG_POP([C++])
  454. AS_CASE([${host_os}],
  455. [darwin*], [
  456. ldflags_test="-Wl,-dead_strip_dylibs"],
  457. [linux*], [
  458. ldflags_test="-Wl,-O1 -Wl,--as-needed -Wl,--no-undefined -Wl,--gc-sections"]
  459. )
  460. AX_APPEND_LINK_FLAGS([${ldflags_test}], [LDFLAGS])
  461. ])
  462. AS_IF([test "x$enable_werror" = "xyes"], [
  463. AX_APPEND_COMPILE_FLAGS([-Werror], [CFLAGS])
  464. AC_LANG_PUSH([C++])
  465. AX_APPEND_COMPILE_FLAGS([-Werror], [CXXFLAGS])
  466. AC_LANG_POP([C++])
  467. ])
  468. common_flags="-Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wundef -Wuninitialized -Winit-self"
  469. common_cflags="${common_flags}"
  470. dnl Clang doesn't know about -Wno-format-truncation
  471. dnl and would spew tons of warnings otherwise.
  472. AS_IF([test "x$ax_cv_c_compiler_vendor" = "xgnu"], [
  473. common_cflags+=" -Wno-format-truncation"
  474. ])
  475. common_cxxflags="${common_flags}"
  476. AS_IF([test "x$ax_cv_cxx_compiler_vendor" = "xgnu"], [
  477. common_cxxflags+=" -Wno-format-truncation"
  478. ])
  479. AX_APPEND_COMPILE_FLAGS([${common_cflags} -Wvla -Wbad-function-cast -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Waggregate-return], [CFLAGS])
  480. AC_LANG_PUSH([C++])
  481. AX_APPEND_COMPILE_FLAGS([${common_cxxflags} -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wreorder -Wsign-promo], [CXXFLAGS])
  482. AC_LANG_POP([C++])
  483. AS_IF([test "x$enable_test_coverage" = "xyes"], [
  484. AX_APPEND_COMPILE_FLAGS([-coverage], [CFLAGS])
  485. ])
  486. dnl some distributions (such as Gentoo) have _FORTIFY_SOURCE always
  487. dnl enabled. We test for this situation in order to prevent polluting
  488. dnl the console with messages of macro redefinitions.
  489. AX_ADD_FORTIFY_SOURCE
  490. AS_IF([test "x$ax_cv_c_compiler_vendor" = "xgnu"], [
  491. dnl OS specific tweaks.
  492. AS_CASE([$host_os],
  493. [darwin* | rhapsody*], [
  494. dnl Disable -Wall, -pedantic and -Wshadow for Apple Darwin/Rhapsody.
  495. dnl System headers on these systems are broken.
  496. temp_CFLAGS=`echo $CFLAGS | $SED "s/-Wall -pedantic//" | $SED "s/-Wshadow//" | $SED "s/-Waggregate-return//"`
  497. CFLAGS=$temp_CFLAGS
  498. SHLIB_VERSION_ARG="-Wl,-exported_symbols_list -Wl,\$(top_srcdir)/src/Symbols.darwin"],
  499. [mingw*], [
  500. SHLIB_VERSION_ARG="-Wc,-static-libgcc -Wl,\$(top_srcdir)/src/libsndfile-1.def"
  501. win32_target_dll=1
  502. AS_IF([test "x$enable_shared" = "xno"], [
  503. win32_target_dll=0
  504. ])
  505. AX_APPEND_COMPILE_FLAGS([-mstackrealign], [CFLAGS])
  506. ],
  507. [os2*], [
  508. SHLIB_VERSION_ARG="-Wl,-export-symbols \$(top_srcdir)/src/Symbols.os2"
  509. ])
  510. COMPILER_IS_GCC=1
  511. ])
  512. AS_CASE([$host_os], [linux*|kfreebsd*-gnu*|gnu*], [SHLIB_VERSION_ARG="-Wl,--version-script=\$(top_srcdir)/src/Symbols.gnu-binutils"])
  513. AC_DEFINE_UNQUOTED([WIN32_TARGET_DLL], [${win32_target_dll}], [Set to 1 if windows DLL is being built.])
  514. AC_DEFINE_UNQUOTED([COMPILER_IS_GCC], [${COMPILER_IS_GCC}], [Set to 1 if the compile is GNU GCC.])
  515. CFLAGS="$CFLAGS $OS_SPECIFIC_CFLAGS"
  516. AS_IF([test "x$CFLAGS" = "x"], [
  517. AC_MSG_ERROR(["Error in configure script. CFLAGS has been screwed up."])
  518. ])
  519. HOST_TRIPLET="${host_cpu}-${host_vendor}-${host_os}"
  520. AC_DEFINE_UNQUOTED([HOST_TRIPLET], [${HOST_TRIPLET}], [The host triplet of the compiled binary.])
  521. AS_IF([test "$HOST_TRIPLET" = "x86_64-w64-mingw32"], [
  522. OS_SPECIFIC_LINKS=" -static-libgcc $OS_SPECIFIC_LINKS"
  523. ])
  524. WIN_RC_VERSION=`echo $PACKAGE_VERSION | $SED -e "s/pre.*//" -e "s/beta.*//" -e "s/\./,/g"`
  525. AS_IF([test "x$enable_static" = "xno"], [
  526. SRC_BINDIR=src/.libs/
  527. TEST_BINDIR=tests/.libs/
  528. ], [
  529. SRC_BINDIR=src/
  530. TEST_BINDIR=tests/
  531. ])
  532. dnl -------------------------------------------------------------------------------
  533. AC_SUBST(HOST_TRIPLET)
  534. AC_SUBST(HTML_BGCOLOUR)
  535. AC_SUBST(HTML_FGCOLOUR)
  536. AC_SUBST(SHLIB_VERSION_ARG)
  537. AC_SUBST([SHARED_VERSION_INFO], [lt_current:lt_revision:lt_age])
  538. AC_SUBST([ABI_VERSION], [abi_version_major.abi_version_minor.abi_version_patch])
  539. AC_SUBST(CLEAN_VERSION)
  540. AC_SUBST(VERSION_MAJOR)
  541. AC_SUBST(GEN_TOOL)
  542. AC_SUBST(WIN_RC_VERSION)
  543. AC_SUBST(HAVE_EXTERNAL_XIPH_LIBS)
  544. AC_SUBST(HAVE_MPEG)
  545. AC_SUBST(OS_SPECIFIC_CFLAGS)
  546. AC_SUBST(OS_SPECIFIC_LINKS)
  547. AC_SUBST(SNDIO_LIBS)
  548. AC_SUBST(EXTERNAL_XIPH_CFLAGS)
  549. AC_SUBST(EXTERNAL_XIPH_LIBS)
  550. AC_SUBST(EXTERNAL_XIPH_REQUIRE)
  551. AC_SUBST(EXTERNAL_MPEG_LIBS)
  552. AC_SUBST(EXTERNAL_MPEG_REQUIRE)
  553. AC_SUBST(MPG123_CFLAGS)
  554. AC_SUBST(MPG123_LIBS)
  555. AC_SUBST(MPEG_CFLAGS)
  556. AC_SUBST(MPEG_LIBS)
  557. AC_SUBST(SRC_BINDIR)
  558. AC_SUBST(TEST_BINDIR)
  559. AC_CONFIG_FILES([
  560. Makefile Octave/Makefile
  561. src/version-metadata.rc
  562. tests/test_wrapper.sh tests/pedantic-header-test.sh
  563. sndfile.pc
  564. Scripts/build-test-tarball.mk
  565. ])
  566. AC_OUTPUT
  567. dnl ====================================================================================
  568. AS_IF([test -z "$PKG_CONFIG"], [
  569. AS_ECHO([" *****************************************************************"])
  570. AS_ECHO([" *** The pkg-config program is missing. ***"])
  571. AS_ECHO([" *** External FLAC/Ogg/Vorbis libs cannot be found without it. ***"])
  572. AS_ECHO([" *** http://pkg-config.freedesktop.org/wiki/ ***"])
  573. AS_ECHO([" *****************************************************************"])
  574. ])
  575. AX_RECURSIVE_EVAL([$libdir], [full_absolute_libdir])
  576. AX_RECURSIVE_EVAL([$bindir], [full_absolute_bindir])
  577. AX_RECURSIVE_EVAL([$pkgconfigdir], [full_absolute_pkgconfigdir])
  578. AX_RECURSIVE_EVAL([$htmldir], [full_absolute_htmldir])
  579. AC_MSG_RESULT([
  580. -=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=-=-
  581. Configuration summary :
  582. libsndfile version : .................. ${VERSION}
  583. Host CPU : ............................ ${host_cpu}
  584. Host Vendor : ......................... ${host_vendor}
  585. Host OS : ............................. ${host_os}
  586. CFLAGS : .............................. ${CFLAGS}
  587. CXXFLAGS : ............................ ${CXXFLAGS}
  588. CPPFLAGS : ............................ ${CPPFLAGS}
  589. LDFLAGS : ............................. ${LDFLAGS}
  590. Experimental code : ................... ${enable_experimental:-no}
  591. Using ALSA in example programs : ...... ${enable_alsa:-no}
  592. External FLAC/Ogg/Vorbis/Opus : ....... ${enable_external_libs:-no}
  593. External MPEG Lame/MPG123 : ........... ${enable_mpeg:-no}
  594. Building Octave interface : ........... ${OCTAVE_BUILD}
  595. Tools :
  596. C Compiler Vendor is : ................ ${ax_cv_c_compiler_vendor} (${ax_cv_c_compiler_version})
  597. CXX Compiler Vendor is : .............. ${ax_cv_cxx_compiler_vendor} (${ax_cv_cxx_compiler_version})
  598. Sanitizer enabled : ................... ${enable_sanitizer:-no}
  599. Installation directories :
  600. Library directory : ................... ${full_absolute_libdir}
  601. Program directory : ................... ${full_absolute_bindir}
  602. Pkgconfig directory : ................. ${full_absolute_pkgconfigdir}
  603. HTML docs directory : ................. ${full_absolute_htmldir}
  604. Compiling some other packages against libsndfile may require
  605. the addition of '$full_absolute_pkgconfigdir' to the
  606. PKG_CONFIG_PATH environment variable.
  607. ])
  608. dnl Remove symlink created by Scripts/android-configure.sh.
  609. rm -f gdbclient