• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#  FLAC - Free Lossless Audio Codec
2#  Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009  Josh Coalson
3#
4#  This file is part the FLAC project.  FLAC is comprised of several
5#  components distributed under different licenses.  The codec libraries
6#  are distributed under Xiph.Org's BSD-like license (see the file
7#  COPYING.Xiph in this distribution).  All other programs, libraries, and
8#  plugins are distributed under the GPL (see COPYING.GPL).  The documentation
9#  is distributed under the Gnu FDL (see COPYING.FDL).  Each file in the
10#  FLAC distribution contains at the top the terms under which it may be
11#  distributed.
12#
13#  Since this particular file is relevant to all components of FLAC,
14#  it may be distributed under the Xiph.Org license, which is the least
15#  restrictive of those mentioned above.  See the file COPYING.Xiph in this
16#  distribution.
17
18# NOTE that for many of the AM_CONDITIONALs we use the prefix FLaC__
19# instead of FLAC__ since autoconf triggers off 'AC_' in strings
20
21AC_PREREQ(2.60)
22AC_INIT([flac], [1.3.3], [flac-dev@xiph.org], [flac], [https://www.xiph.org/flac/])
23AC_CONFIG_HEADERS([config.h])
24AC_CONFIG_SRCDIR([src/flac/main.c])
25AC_CONFIG_MACRO_DIR([m4])
26AM_INIT_AUTOMAKE([foreign 1.10 -Wall tar-pax no-dist-gzip dist-xz subdir-objects])
27m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
28
29AC_MSG_CHECKING([whether configure should try to set CFLAGS/CXXFLAGS/CPPFLAGS/LDFLAGS])
30AS_IF([test "x${CFLAGS+set}" = "xset" || test "x${CXXFLAGS+set}" = "xset" || test "x${CPPFLAGS+set}" = "xset" || test "x${LDFLAGS+set}" = "xset"],
31	[enable_flags_setting=no],
32	[enable_flags_setting=yes]
33)
34AC_MSG_RESULT([${enable_flags_setting}])
35AX_CHECK_ENABLE_DEBUG
36user_cflags=$CFLAGS
37
38#Prefer whatever the current ISO standard is.
39AC_PROG_CC_STDC
40AC_USE_SYSTEM_EXTENSIONS
41m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
42LT_INIT([win32-dll disable-static pic-only])
43AM_PROG_AS
44AC_PROG_CXX
45XIPH_C_COMPILER_IS_CLANG
46XIPH_GCC_REALLY_IS_GCC
47AC_PROG_MAKE_SET
48AC_PROG_MKDIR_P
49
50AC_SYS_LARGEFILE
51AC_FUNC_FSEEKO
52
53AC_CHECK_SIZEOF(off_t,1)	# Fake default value.
54AC_CHECK_SIZEOF([void*])
55AC_SEARCH_LIBS([lround],[m], [AC_DEFINE(HAVE_LROUND,1,lround support)])
56
57AC_LANG_PUSH([C++])
58# c++ flavor first
59AC_C_VARARRAYS
60if test $ac_cv_c_vararrays = yes; then
61	AC_DEFINE([HAVE_CXX_VARARRAYS], 1, [Define to 1 if C++ supports variable-length arrays.])
62fi
63AC_LANG_POP([C++])
64
65# c flavor
66AC_HEADER_STDC
67AM_PROG_CC_C_O
68AC_C_INLINE
69AC_C_VARARRAYS
70AC_C_TYPEOF
71
72AC_CHECK_HEADERS([stdint.h inttypes.h byteswap.h sys/param.h sys/ioctl.h termios.h x86intrin.h cpuid.h])
73
74XIPH_C_BSWAP32
75XIPH_C_BSWAP16
76
77ac_cv_c_big_endian=0
78ac_cv_c_little_endian=0
79AC_C_BIGENDIAN([ac_cv_c_big_endian=1], [ac_cv_c_little_endian=1], [
80	AC_MSG_WARN([[*****************************************************************]])
81	AC_MSG_WARN([[*** Not able to determine endian-ness of target processor.       ]])
82	AC_MSG_WARN([[*** The constants CPU_IS_BIG_ENDIAN and CPU_IS_LITTLE_ENDIAN in  ]])
83	AC_MSG_WARN([[*** config.h may need to be hand editied.                        ]])
84	AC_MSG_WARN([[*****************************************************************]])
85])
86AC_DEFINE_UNQUOTED(CPU_IS_BIG_ENDIAN, ${ac_cv_c_big_endian},
87					[Target processor is big endian.])
88AC_DEFINE_UNQUOTED(CPU_IS_LITTLE_ENDIAN, ${ac_cv_c_little_endian},
89					[Target processor is little endian.])
90AC_DEFINE_UNQUOTED(WORDS_BIGENDIAN, ${ac_cv_c_big_endian},
91					[Target processor is big endian.])
92
93AC_ARG_ENABLE(asm-optimizations, AC_HELP_STRING([--disable-asm-optimizations], [Don't use any assembly optimization routines]), asm_opt=no, asm_opt=yes)
94dnl ' Terminate the damn single quote
95AM_CONDITIONAL(FLaC__NO_ASM, test "x$asm_opt" = xno)
96if test "x$asm_opt" = xno ; then
97AC_DEFINE(FLAC__NO_ASM)
98AH_TEMPLATE(FLAC__NO_ASM, [define to disable use of assembly code])
99fi
100
101# For the XMMS plugin.
102AC_CHECK_TYPES(socklen_t, [], [])
103
104dnl check for getopt in standard library
105dnl AC_CHECK_FUNCS(getopt_long , , [LIBOBJS="$LIBOBJS getopt.o getopt1.o"] )
106AC_CHECK_FUNCS(getopt_long, [], [])
107
108AC_CHECK_SIZEOF(void*,1)
109
110asm_optimisation=no
111case "$host_cpu" in
112	amd64|x86_64)
113		case "$host" in
114			*gnux32)
115				# x32 user space and 64 bit kernel.
116				cpu_x86_64=true
117				AC_DEFINE(FLAC__CPU_X86_64)
118				AH_TEMPLATE(FLAC__CPU_X86_64, [define if building for x86_64])
119				asm_optimisation=$asm_opt
120				;;
121			*)
122				if test $ac_cv_sizeof_voidp = 4 ; then
123					# This must be a 32 bit user space running on 64 bit kernel so treat
124					# this as ia32.
125					cpu_ia32=true
126					AC_DEFINE(FLAC__CPU_IA32)
127					AH_TEMPLATE(FLAC__CPU_IA32, [define if building for ia32/i386])
128			else
129					# x86_64 user space and kernel.
130					cpu_x86_64=true
131					AC_DEFINE(FLAC__CPU_X86_64)
132					AH_TEMPLATE(FLAC__CPU_X86_64, [define if building for x86_64])
133				fi
134				asm_optimisation=$asm_opt
135				;;
136		esac
137		;;
138	i*86)
139		cpu_ia32=true
140		AC_DEFINE(FLAC__CPU_IA32)
141		AH_TEMPLATE(FLAC__CPU_IA32, [define if building for ia32/i386])
142		asm_optimisation=$asm_opt
143		;;
144	powerpc64|powerpc64le)
145		cpu_ppc64=true
146		cpu_ppc=true
147		AC_DEFINE(FLAC__CPU_PPC)
148		AH_TEMPLATE(FLAC__CPU_PPC, [define if building for PowerPC])
149		AC_DEFINE(FLAC__CPU_PPC64)
150		AH_TEMPLATE(FLAC__CPU_PPC64, [define if building for PowerPC64])
151		asm_optimisation=$asm_opt
152		;;
153	powerpc|powerpcle)
154		cpu_ppc=true
155		AC_DEFINE(FLAC__CPU_PPC)
156		AH_TEMPLATE(FLAC__CPU_PPC, [define if building for PowerPC])
157		asm_optimisation=$asm_opt
158		;;
159	sparc)
160		cpu_sparc=true
161		AC_DEFINE(FLAC__CPU_SPARC)
162		AH_TEMPLATE(FLAC__CPU_SPARC, [define if building for SPARC])
163		asm_optimisation=$asm_opt
164		;;
165esac
166AM_CONDITIONAL(FLAC__CPU_X86_64, test "x$cpu_x86_64" = xtrue)
167AM_CONDITIONAL(FLaC__CPU_IA32, test "x$cpu_ia32" = xtrue)
168AM_CONDITIONAL(FLaC__CPU_PPC, test "x$cpu_ppc" = xtrue)
169AM_CONDITIONAL(FLaC__CPU_PPC64, test "x$cpu_ppc64" = xtrue)
170AM_CONDITIONAL(FLaC__CPU_SPARC, test "x$cpu_sparc" = xtrue)
171
172if test "x$ac_cv_header_x86intrin_h" = xyes; then
173AC_DEFINE([FLAC__HAS_X86INTRIN], 1, [Set to 1 if <x86intrin.h> is available.])
174else
175AC_DEFINE([FLAC__HAS_X86INTRIN], 0)
176fi
177
178if test x"$cpu_ppc64" = xtrue ; then
179
180AC_C_ATTRIBUTE([target("cpu=power8")],
181  [have_cpu_power8=yes],
182  [have_cpu_power8=no])
183if test x"$have_cpu_power8" = xyes ; then
184  AC_DEFINE(FLAC__HAS_TARGET_POWER8)
185  AH_TEMPLATE(FLAC__HAS_TARGET_POWER8, [define if compiler has __attribute__((target("cpu=power8"))) support])
186fi
187
188AC_C_ATTRIBUTE([target("cpu=power9")],
189  [have_cpu_power9=yes],
190  [have_cpu_power9=no])
191if test x"$have_cpu_power9" = xyes ; then
192  AC_DEFINE(FLAC__HAS_TARGET_POWER9)
193  AH_TEMPLATE(FLAC__HAS_TARGET_POWER9, [define if compiler has __attribute__((target("cpu=power9"))) support])
194fi
195
196fi
197
198case "$host" in
199	i386-*-openbsd3.[[0-3]]) OBJ_FORMAT=aoutb ;;
200	*-*-cygwin|*mingw*) OBJ_FORMAT=win32 ;;
201	*-*-darwin*) OBJ_FORMAT=macho ;;
202	*emx*) OBJ_FORMAT=aout ;;
203	*djgpp) OBJ_FORMAT=coff ;;
204	*) OBJ_FORMAT=elf ;;
205esac
206AC_SUBST(OBJ_FORMAT)
207
208os_is_windows=no
209case "$host" in
210	*mingw*)
211		CPPFLAGS="-D__MSVCRT_VERSION__=0x0601 $CPPFLAGS"
212		os_is_windows=yes
213		;;
214esac
215
216AM_CONDITIONAL(OS_IS_WINDOWS, test "x$os_is_windows" = xyes)
217
218case "$host" in
219	*-linux-*)
220		sys_linux=true
221		AC_DEFINE(FLAC__SYS_LINUX)
222		AH_TEMPLATE(FLAC__SYS_LINUX, [define if building for Linux])
223		;;
224	*-*-darwin*)
225		sys_darwin=true
226		AC_DEFINE(FLAC__SYS_DARWIN)
227		AH_TEMPLATE(FLAC__SYS_DARWIN, [define if building for Darwin / MacOS X])
228		;;
229esac
230AM_CONDITIONAL(FLaC__SYS_DARWIN, test "x$sys_darwin" = xtrue)
231AM_CONDITIONAL(FLaC__SYS_LINUX, test "x$sys_linux" = xtrue)
232
233if test "x$cpu_ia32" = xtrue || test "x$cpu_x86_64" = xtrue ; then
234AC_DEFINE(FLAC__ALIGN_MALLOC_DATA)
235AH_TEMPLATE(FLAC__ALIGN_MALLOC_DATA, [define to align allocated memory on 32-byte boundaries])
236fi
237
238AM_CONDITIONAL([DEBUG], [test "x${ax_enable_debug}" = "xyes" || test "x${ax_enable_debug}" = "xinfo"])
239
240AC_ARG_ENABLE(sse,
241AC_HELP_STRING([--disable-sse], [Disable passing of -msse2 to the compiler]),
242[case "${enableval}" in
243	yes) sse_os=yes ;;
244	no)  sse_os=no ;;
245	*) AC_MSG_ERROR(bad value ${enableval} for --enable-sse) ;;
246esac],[sse_os=yes])
247
248AC_ARG_ENABLE(altivec,
249AC_HELP_STRING([--disable-altivec], [Disable Altivec optimizations]),
250[case "${enableval}" in
251	yes) use_altivec=true ;;
252	no)  use_altivec=false ;;
253	*) AC_MSG_ERROR(bad value ${enableval} for --enable-altivec) ;;
254esac],[use_altivec=true])
255AM_CONDITIONAL(FLaC__USE_ALTIVEC, test "x$use_altivec" = xtrue)
256if test "x$use_altivec" = xtrue ; then
257AC_DEFINE(FLAC__USE_ALTIVEC)
258AH_TEMPLATE(FLAC__USE_ALTIVEC, [define to enable use of Altivec instructions])
259fi
260
261AC_ARG_ENABLE(vsx,
262AC_HELP_STRING([--disable-vsx], [Disable VSX optimizations]),
263[case "${enableval}" in
264	yes) use_vsx=true ;;
265	no)  use_vsx=false ;;
266	*) AC_MSG_ERROR(bad value ${enableval} for --enable-vsx) ;;
267esac],[use_vsx=true])
268AM_CONDITIONAL(FLaC__USE_VSX, test "x$use_vsx" = xtrue)
269if test "x$use_vsx" = xtrue ; then
270AC_DEFINE(FLAC__USE_VSX)
271AH_TEMPLATE(FLAC__USE_VSX, [define to enable use of VSX instructions])
272fi
273
274AC_ARG_ENABLE(avx,
275AC_HELP_STRING([--disable-avx], [Disable AVX, AVX2 optimizations]),
276[case "${enableval}" in
277	yes) use_avx=true ;;
278	no)  use_avx=false ;;
279	*) AC_MSG_ERROR(bad value ${enableval} for --enable-avx) ;;
280esac],[use_avx=true])
281AM_CONDITIONAL(FLaC__USE_AVX, test "x$use_avx" = xtrue)
282if test "x$use_avx" = xtrue ; then
283AC_DEFINE(FLAC__USE_AVX)
284AH_TEMPLATE(FLAC__USE_AVX, [define to enable use of AVX instructions])
285fi
286
287AC_ARG_ENABLE(thorough-tests,
288AC_HELP_STRING([--disable-thorough-tests], [Disable thorough (long) testing, do only basic tests]),
289[case "${enableval}" in
290	yes) thorough_tests=true ;;
291	no)  thorough_tests=false ;;
292	*) AC_MSG_ERROR(bad value ${enableval} for --enable-thorough-tests) ;;
293esac],[thorough_tests=true])
294AC_ARG_ENABLE(exhaustive-tests,
295AC_HELP_STRING([--enable-exhaustive-tests], [Enable exhaustive testing (VERY long)]),
296[case "${enableval}" in
297	yes) exhaustive_tests=true ;;
298	no)  exhaustive_tests=false ;;
299	*) AC_MSG_ERROR(bad value ${enableval} for --enable-exhaustive-tests) ;;
300esac],[exhaustive_tests=false])
301if test "x$thorough_tests" = xfalse ; then
302FLAC__TEST_LEVEL=0
303elif test "x$exhaustive_tests" = xfalse ; then
304FLAC__TEST_LEVEL=1
305else
306FLAC__TEST_LEVEL=2
307fi
308AC_SUBST(FLAC__TEST_LEVEL)
309
310AC_ARG_ENABLE(werror,
311	AC_HELP_STRING([--enable-werror], [Enable -Werror in all Makefiles]))
312
313AC_ARG_ENABLE([stack-smash-protection],
314    [AS_HELP_STRING([--disable-stack-smash-protection],[Disable GNU GCC stack smash protection])],,
315    [AS_IF([test "$ac_cv_c_compiler_gnu" = "yes" && test "$os_is_windows" = "no"],
316        [enable_stack_smash_protection=yes],[enable_stack_smash_protection=no])])
317
318AC_ARG_ENABLE(64-bit-words,
319	AC_HELP_STRING([--enable-64-bit-words], [Set FLAC__BYTES_PER_WORD to 8 (4 is the default)]))
320if test "x$enable_64_bit_words" = xyes ; then
321	AC_DEFINE_UNQUOTED([ENABLE_64_BIT_WORDS],1,[Set FLAC__BYTES_PER_WORD to 8 (4 is the default)])
322else
323	AC_DEFINE_UNQUOTED([ENABLE_64_BIT_WORDS],0)
324	fi
325AC_SUBST(ENABLE_64_BIT_WORDS)
326
327AC_ARG_ENABLE(valgrind-testing,
328AC_HELP_STRING([--enable-valgrind-testing], [Run all tests inside Valgrind]),
329[case "${enableval}" in
330	yes) FLAC__TEST_WITH_VALGRIND=yes ;;
331	no)  FLAC__TEST_WITH_VALGRIND=no ;;
332	*) AC_MSG_ERROR(bad value ${enableval} for --enable-valgrind-testing) ;;
333esac],[FLAC__TEST_WITH_VALGRIND=no])
334AC_SUBST(FLAC__TEST_WITH_VALGRIND)
335
336AC_ARG_ENABLE(doxygen-docs,
337AC_HELP_STRING([--disable-doxygen-docs], [Disable API documentation building via Doxygen]),
338[case "${enableval}" in
339	yes) enable_doxygen_docs=true ;;
340	no)  enable_doxygen_docs=false ;;
341	*) AC_MSG_ERROR(bad value ${enableval} for --enable-doxygen-docs) ;;
342esac],[enable_doxygen_docs=true])
343if test "x$enable_doxygen_docs" != xfalse ; then
344	AC_CHECK_PROGS(DOXYGEN, doxygen)
345fi
346AM_CONDITIONAL(FLaC__HAS_DOXYGEN, test -n "$DOXYGEN")
347
348AC_ARG_ENABLE(local-xmms-plugin,
349AC_HELP_STRING([--enable-local-xmms-plugin], [Install XMMS plugin to ~/.xmms/Plugins instead of system location]),
350[case "${enableval}" in
351	yes) install_xmms_plugin_locally=true ;;
352	no)  install_xmms_plugin_locally=false ;;
353	*) AC_MSG_ERROR(bad value ${enableval} for --enable-local-xmms-plugin) ;;
354esac],[install_xmms_plugin_locally=false])
355AM_CONDITIONAL(FLaC__INSTALL_XMMS_PLUGIN_LOCALLY, test "x$install_xmms_plugin_locally" = xtrue)
356
357AC_ARG_ENABLE(xmms-plugin,
358AC_HELP_STRING([--disable-xmms-plugin], [Do not build XMMS plugin]),
359[case "${enableval}" in
360	yes) enable_xmms_plugin=true ;;
361	no)  enable_xmms_plugin=false ;;
362	*) AC_MSG_ERROR(bad value ${enableval} for --enable-xmms-plugin) ;;
363esac],[enable_xmms_plugin=true])
364if test "x$enable_xmms_plugin" != xfalse ; then
365	AM_PATH_XMMS(0.9.5.1, , AC_MSG_WARN([*** XMMS >= 0.9.5.1 not installed - XMMS support will not be built]))
366fi
367AM_CONDITIONAL(FLaC__HAS_XMMS, test -n "$XMMS_INPUT_PLUGIN_DIR")
368
369dnl build FLAC++ or not
370AC_ARG_ENABLE([cpplibs],
371AC_HELP_STRING([--disable-cpplibs], [Do not build libFLAC++]),
372[case "${enableval}" in
373	yes) disable_cpplibs=false ;;
374	no)  disable_cpplibs=true ;;
375	*)   AC_MSG_ERROR(bad value ${enableval} for --enable-cpplibs) ;;
376esac], [disable_cpplibs=false])
377AM_CONDITIONAL(FLaC__WITH_CPPLIBS, [test "x$disable_cpplibs" != xtrue])
378
379AC_ARG_ENABLE([oss-fuzzers],
380  [AS_HELP_STRING([--enable-oss-fuzzers],
381    [Whether to generate the fuzzers for OSS-Fuzz (Clang only)])],
382  [have_oss_fuzzers=yes], [have_oss_fuzzers=no])
383
384if test "x$have_oss_fuzzers" = "xyes"; then
385  if test "x$xiph_cv_c_compiler_clang" = "xyes" ; then
386    AM_CONDITIONAL([USE_OSSFUZZERS], [test "x$have_oss_fuzzers" = "xyes"])
387    if test "x$LIB_FUZZING_ENGINE" = "x" ; then
388      # Only set this if it is empty.
389	  LIB_FUZZING_ENGINE=-fsanitize=fuzzer
390    fi
391  else
392    AM_CONDITIONAL([USE_OSSFUZZERS], [test "false" = "true"])
393    # Disable fuzzer if the compiler is not Clang.
394    AC_MSG_WARN([*** Ozz-Fuzz is disabled because that requres the  Clang compiler.])
395    have_oss_fuzzers="no (compiler is GCC)"
396  fi
397else
398  AM_CONDITIONAL([USE_OSSFUZZERS], [test "false" = "true"])
399fi
400
401AM_CONDITIONAL([USE_OSSFUZZ_FLAG], [test "x$LIB_FUZZING_ENGINE" = "x-fsanitize=fuzzer"])
402AM_CONDITIONAL([USE_OSSFUZZ_STATIC], [test -f "$LIB_FUZZING_ENGINE"])
403AC_SUBST([LIB_FUZZING_ENGINE])
404
405dnl check for ogg library
406AC_ARG_ENABLE([ogg],
407	AC_HELP_STRING([--disable-ogg], [Disable ogg support (default: test for libogg)]),
408	[ want_ogg=$enableval ], [ want_ogg=yes ] )
409
410if test "x$want_ogg" != "xno"; then
411	XIPH_PATH_OGG(have_ogg=yes, AC_MSG_WARN([*** Ogg development environment not installed - Ogg support will not be built]))
412fi
413
414FLAC__HAS_OGG=0
415AM_CONDITIONAL(FLaC__HAS_OGG, [test "x$have_ogg" = xyes])
416if test "x$have_ogg" = xyes ; then
417	FLAC__HAS_OGG=1
418	OGG_PACKAGE="ogg"
419else
420	have_ogg=no
421fi
422AC_DEFINE_UNQUOTED([FLAC__HAS_OGG],$FLAC__HAS_OGG,[define if you have the ogg library])
423AC_SUBST(FLAC__HAS_OGG)
424AC_SUBST(OGG_PACKAGE)
425
426dnl Build examples?
427AC_ARG_ENABLE([examples],
428	AS_HELP_STRING([--disable-examples], [Don't build and install examples]))
429AM_CONDITIONAL([EXAMPLES], [test "x$enable_examples" != "xno"])
430
431dnl check for i18n(internationalization); these are from libiconv/gettext
432AM_ICONV
433AM_LANGINFO_CODESET
434
435AC_CHECK_PROGS(DOCBOOK_TO_MAN, docbook-to-man docbook2man)
436AM_CONDITIONAL(FLaC__HAS_DOCBOOK_TO_MAN, test -n "$DOCBOOK_TO_MAN")
437if test -n "$DOCBOOK_TO_MAN" ; then
438AC_DEFINE(FLAC__HAS_DOCBOOK_TO_MAN)
439AH_TEMPLATE(FLAC__HAS_DOCBOOK_TO_MAN, [define if you have docbook-to-man or docbook2man])
440fi
441
442AC_CHECK_LIB(rt, clock_gettime,
443        LIB_CLOCK_GETTIME=-lrt
444        AC_DEFINE(HAVE_CLOCK_GETTIME)
445        AH_TEMPLATE(HAVE_CLOCK_GETTIME, [define if you have clock_gettime]))
446AC_SUBST(LIB_CLOCK_GETTIME)
447
448# only matters for x86
449AC_CHECK_PROGS(NASM, nasm)
450AM_CONDITIONAL(FLaC__HAS_NASM, test -n "$NASM")
451if test -n "$NASM" ; then
452AC_DEFINE(FLAC__HAS_NASM)
453AH_TEMPLATE(FLAC__HAS_NASM, [define if you are compiling for x86 and have the NASM assembler])
454fi
455
456dnl If debugging is disabled AND no CFLAGS/CXXFLAGS/CPPFLAGS/LDFLAGS
457dnl are provided, we can set defaults to our liking
458AS_IF([test "x${ax_enable_debug}" = "xno" && test "x${enable_flags_setting}" = "xyes"], [
459	CFLAGS="-O3 -funroll-loops"
460	CXXFLAGS="-O3"
461])
462
463XIPH_GCC_VERSION dnl Sets a non-zero GCC_XXX_VERSION for gcc, not clang. checks below rely on that..
464
465if test x$ac_cv_c_compiler_gnu = xyes -o x$xiph_cv_c_compiler_clang = xyes ; then
466	CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wnested-externs -Wshadow -Wundef -Wmissing-declarations -Winline " # -Wcast-qual -Wbad-function-cast -Wwrite-strings -Wconversion
467	CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wcast-align -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder -Wsign-promo -Wundef " # -Wcast-qual -Wbad-function-cast -Wwrite-strings -Woverloaded-virtual -Wmissing-declarations
468
469	XIPH_ADD_CFLAGS([-Wdeclaration-after-statement])
470
471	dnl some distributions (such as Gentoo) have _FORTIFY_SOURCE always
472	dnl enabled. We test for this situation in order to prevent polluting
473	dnl the console with messages of macro redefinitions.
474	AX_ADD_FORTIFY_SOURCE
475
476	AC_LANG_PUSH([C++])
477	XIPH_ADD_CXXFLAGS([-Weffc++])
478	AC_LANG_POP([C++])
479
480	if test x$xiph_cv_c_compiler_clang = xyes -a "$OBJ_FORMAT" = elf; then
481		CPPFLAGS="$CPPFLAGS -DFLAC__USE_VISIBILITY_ATTR"
482		CFLAGS="$CFLAGS -fvisibility=hidden"
483		CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
484	elif test "$GCC_MAJOR_VERSION" -ge 4 && test "$OBJ_FORMAT" = elf; then
485		CPPFLAGS="$CPPFLAGS -DFLAC__USE_VISIBILITY_ATTR"
486		CFLAGS="$CFLAGS -fvisibility=hidden"
487		CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
488		fi
489
490
491	if test x$xiph_cv_c_compiler_clang = xyes -a "$OBJ_FORMAT" = macho; then
492		CPPFLAGS="$CPPFLAGS -DFLAC__USE_VISIBILITY_ATTR"
493		CFLAGS="$CFLAGS -fvisibility=hidden"
494		CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
495	elif test "$GCC_MAJOR_VERSION" -ge 4 && test "$OBJ_FORMAT" = macho; then
496		CPPFLAGS="$CPPFLAGS -DFLAC__USE_VISIBILITY_ATTR"
497		CFLAGS="$CFLAGS -fvisibility=hidden"
498		CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
499		fi
500
501	if test "x$GCC_MAJOR_VERSION$GCC_MINOR_VERSION" = "x42" ; then
502		XIPH_ADD_CFLAGS([-fgnu89-inline])
503		fi
504
505	if test "x$GCC_MAJOR_VERSION$GCC_MINOR_VERSION" = "x47" ; then
506		XIPH_ADD_CFLAGS([-fno-inline-small-functions])
507		fi
508
509	if test "x$asm_optimisation$sse_os" = "xyesyes" ; then
510		XIPH_ADD_CFLAGS([-msse2])
511		fi
512
513	fi
514
515case "$host_os" in
516	"mingw32"|"os2")
517	if test "$host_cpu" = "i686"; then
518		XIPH_ADD_CFLAGS([-mstackrealign])
519		fi
520	esac
521
522if test x$enable_werror = "xyes" ; then
523	XIPH_ADD_CFLAGS([-Werror])
524	AC_LANG_PUSH([C++])
525	XIPH_ADD_CXXFLAGS([-Werror])
526	AC_LANG_POP([C++])
527	fi
528
529if test x$enable_stack_smash_protection = "xyes" ; then
530	XIPH_GCC_STACK_PROTECTOR
531	XIPH_GXX_STACK_PROTECTOR
532	fi
533
534AH_VERBATIM([FLAC_API_EXPORTS],
535[/* libtool defines DLL_EXPORT for windows dll builds,
536   but flac code relies on FLAC_API_EXPORTS instead. */
537#ifdef DLL_EXPORT
538#ifdef __cplusplus
539# define FLACPP_API_EXPORTS
540#else
541# define FLAC_API_EXPORTS
542#endif
543#endif])
544
545if test x$enable_shared != "xyes" ; then
546dnl for correct FLAC_API
547	CPPFLAGS="-DFLAC__NO_DLL $CPPFLAGS"
548	fi
549
550AC_CONFIG_FILES([ \
551	Makefile \
552	src/Makefile \
553	src/libFLAC/Makefile \
554	src/libFLAC/flac.pc \
555	src/libFLAC/ia32/Makefile \
556	src/libFLAC/include/Makefile \
557	src/libFLAC/include/private/Makefile \
558	src/libFLAC/include/protected/Makefile \
559	src/libFLAC++/Makefile \
560	src/libFLAC++/flac++.pc \
561	src/flac/Makefile \
562	src/metaflac/Makefile \
563	src/plugin_common/Makefile \
564	src/plugin_xmms/Makefile \
565	src/share/Makefile \
566	src/test_grabbag/Makefile \
567	src/test_grabbag/cuesheet/Makefile \
568	src/test_grabbag/picture/Makefile \
569	src/test_libs_common/Makefile \
570	src/test_libFLAC/Makefile \
571	src/test_libFLAC++/Makefile \
572	src/test_seeking/Makefile \
573	src/test_streams/Makefile \
574	src/utils/Makefile \
575	src/utils/flacdiff/Makefile \
576	src/utils/flactimer/Makefile \
577	examples/Makefile \
578	examples/c/Makefile \
579	examples/c/decode/Makefile \
580	examples/c/decode/file/Makefile \
581	examples/c/encode/Makefile \
582	examples/c/encode/file/Makefile \
583	examples/cpp/Makefile \
584	examples/cpp/decode/Makefile \
585	examples/cpp/decode/file/Makefile \
586	examples/cpp/encode/Makefile \
587	examples/cpp/encode/file/Makefile \
588	include/Makefile \
589	include/FLAC/Makefile \
590	include/FLAC++/Makefile \
591	include/share/Makefile \
592	include/share/grabbag/Makefile \
593	include/test_libs_common/Makefile \
594	doc/Doxyfile \
595	doc/Makefile \
596	doc/html/Makefile \
597	doc/html/images/Makefile \
598	m4/Makefile \
599	man/Makefile \
600	test/common.sh \
601	test/Makefile \
602	test/cuesheets/Makefile \
603	test/flac-to-flac-metadata-test-files/Makefile \
604	test/metaflac-test-files/Makefile \
605	test/pictures/Makefile \
606	build/Makefile \
607	microbench/Makefile \
608	oss-fuzz/Makefile
609])
610AC_OUTPUT
611
612AC_MSG_RESULT([
613-=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=-
614
615  Configuration summary :
616
617    FLAC version : ............................ ${VERSION}
618
619    Host CPU : ................................ ${host_cpu}
620    Host Vendor : ............................. ${host_vendor}
621    Host OS : ................................. ${host_os}
622])
623
624	echo "    Compiler is GCC : ......................... ${ac_cv_c_compiler_gnu}"
625if test x$ac_cv_c_compiler_gnu = xyes ; then
626	echo "    GCC version : ............................. ${GCC_VERSION}"
627fi
628	echo "    Compiler is Clang : ....................... ${xiph_cv_c_compiler_clang}"
629	echo "    SSE optimizations : ....................... ${sse_os}"
630	echo "    Asm optimizations : ....................... ${asm_optimisation}"
631	echo "    Ogg/FLAC support : ........................ ${have_ogg}"
632	echo "    Stack protector  : ........................ ${enable_stack_smash_protection}"
633	echo "    Fuzzing support (Clang only) : ............ ${have_oss_fuzzers}"
634echo
635