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