blob: 6efefaf5c49326b40e2b208fd513c7176a090c87 [file] [log] [blame]
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +11001# 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
Ulrich Klauercd4ddab2013-05-26 22:53:43 +02005# components distributed under different licenses. The codec libraries
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +11006# 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
Cristian Rodríguez9b7cb222012-04-07 19:24:21 -030021AC_PREREQ(2.60)
Erik de Castro Lopof7644342019-07-13 18:29:43 +100022AC_INIT([flac], [1.3.3], [flac-dev@xiph.org], [flac], [https://www.xiph.org/flac/])
Max Horn0b47ede2012-12-12 21:33:55 +010023AC_CONFIG_HEADERS([config.h])
Cristian Rodríguez9b7cb222012-04-07 19:24:21 -030024AC_CONFIG_SRCDIR([src/flac/main.c])
25AC_CONFIG_MACRO_DIR([m4])
Erik de Castro Lopo723cfa32014-12-01 05:28:02 +110026AM_INIT_AUTOMAKE([foreign 1.10 -Wall tar-pax no-dist-gzip dist-xz subdir-objects])
Erik de Castro Lopo886b9602012-02-03 05:52:01 +110027m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +110028
David Seifertb3ece712017-01-15 10:37:02 +010029AC_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
Miroslav Lichvar18e01542012-12-03 21:04:56 +010036user_cflags=$CFLAGS
37
Cristian Rodríguezf0296252012-04-05 19:39:37 -030038#Prefer whatever the current ISO standard is.
39AC_PROG_CC_STDC
40AC_USE_SYSTEM_EXTENSIONS
Cristian Rodríguez63c874f2012-06-02 17:00:56 -040041m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
Cristian Rodríguez9b7cb222012-04-07 19:24:21 -030042LT_INIT([win32-dll disable-static pic-only])
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +110043AM_PROG_AS
44AC_PROG_CXX
Erik de Castro Lopoa6a4b6f2013-11-22 18:13:36 +110045XIPH_C_COMPILER_IS_CLANG
46XIPH_GCC_REALLY_IS_GCC
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +110047AC_PROG_MAKE_SET
Erik de Castro Lopo95bc23a2014-03-21 18:27:37 +110048AC_PROG_MKDIR_P
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +110049
50AC_SYS_LARGEFILE
51AC_FUNC_FSEEKO
52
Erik de Castro Lopo6497ce12013-03-13 21:54:15 +110053AC_CHECK_SIZEOF(off_t,1) # Fake default value.
Max Horn0b47ede2012-12-12 21:33:55 +010054AC_CHECK_SIZEOF([void*])
Cristian Rodríguez9b7cb222012-04-07 19:24:21 -030055AC_SEARCH_LIBS([lround],[m], [AC_DEFINE(HAVE_LROUND,1,lround support)])
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +110056
Max Horn0b47ede2012-12-12 21:33:55 +010057AC_LANG_PUSH([C++])
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +110058# 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
Max Horn0b47ede2012-12-12 21:33:55 +010063AC_LANG_POP([C++])
Erik de Castro Lopo3abb6c92012-02-05 18:58:11 +110064
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +110065# c flavor
66AC_HEADER_STDC
Erik de Castro Lopoafedee12012-04-04 20:08:52 +100067AM_PROG_CC_C_O
Erik de Castro Lopo3abb6c92012-02-05 18:58:11 +110068AC_C_INLINE
69AC_C_VARARRAYS
Cristian Rodríguezf0296252012-04-05 19:39:37 -030070AC_C_TYPEOF
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +110071
Erik de Castro Lopo74117242016-01-26 13:35:10 +110072AC_CHECK_HEADERS([stdint.h inttypes.h byteswap.h sys/param.h sys/ioctl.h termios.h x86intrin.h cpuid.h])
Cristian Rodríguezf0296252012-04-05 19:39:37 -030073
Erik de Castro Lopod7bfc772012-02-06 07:15:48 +110074XIPH_C_BSWAP32
Ralph Giles7a671e72014-11-04 11:58:45 -080075XIPH_C_BSWAP16
Erik de Castro Lopod7bfc772012-02-06 07:15:48 +110076
Max Hornf20164e2012-12-12 21:33:51 +010077ac_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])
Erik de Castro Lopo3abb6c92012-02-05 18:58:11 +110086AC_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.])
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +110092
Erik de Castro Lopo1ec41a92013-08-11 21:46:18 +100093AC_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
Erik de Castro Lopo3abb6c92012-02-05 18:58:11 +1100101# For the XMMS plugin.
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100102AC_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
Erik de Castro Lopo1ec41a92013-08-11 21:46:18 +1000108AC_CHECK_SIZEOF(void*,1)
109
110asm_optimisation=no
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100111case "$host_cpu" in
Christian Weisgerberb5a10e72015-01-09 22:37:37 +0000112 amd64|x86_64)
Erik de Castro Lopo7566d3d2015-03-11 20:51:42 +1100113 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
Erik de Castro Lopo1ec41a92013-08-11 21:46:18 +1000137 ;;
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100138 i*86)
139 cpu_ia32=true
140 AC_DEFINE(FLAC__CPU_IA32)
141 AH_TEMPLATE(FLAC__CPU_IA32, [define if building for ia32/i386])
Erik de Castro Lopo1ec41a92013-08-11 21:46:18 +1000142 asm_optimisation=$asm_opt
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100143 ;;
Anton Blanchardf3015182018-07-08 14:56:31 +1000144 powerpc64|powerpc64le)
145 cpu_ppc64=true
146 cpu_ppc=true
Peter Seiderer44036c92019-09-19 21:18:04 +0200147 AC_CHECK_HEADER(sys/auxv.h, AC_DEFINE(FLAC__CPU_PPC))
Anton Blanchardf3015182018-07-08 14:56:31 +1000148 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)
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100154 cpu_ppc=true
Peter Seiderer44036c92019-09-19 21:18:04 +0200155 AC_CHECK_HEADER(sys/auxv.h, AC_DEFINE(FLAC__CPU_PPC))
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100156 AH_TEMPLATE(FLAC__CPU_PPC, [define if building for PowerPC])
Erik de Castro Lopo1ec41a92013-08-11 21:46:18 +1000157 asm_optimisation=$asm_opt
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100158 ;;
159 sparc)
160 cpu_sparc=true
161 AC_DEFINE(FLAC__CPU_SPARC)
162 AH_TEMPLATE(FLAC__CPU_SPARC, [define if building for SPARC])
Erik de Castro Lopo1ec41a92013-08-11 21:46:18 +1000163 asm_optimisation=$asm_opt
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100164 ;;
165esac
Erik de Castro Lopob8d58e32014-06-15 20:29:34 +1000166AM_CONDITIONAL(FLAC__CPU_X86_64, test "x$cpu_x86_64" = xtrue)
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100167AM_CONDITIONAL(FLaC__CPU_IA32, test "x$cpu_ia32" = xtrue)
168AM_CONDITIONAL(FLaC__CPU_PPC, test "x$cpu_ppc" = xtrue)
Anton Blanchardf3015182018-07-08 14:56:31 +1000169AM_CONDITIONAL(FLaC__CPU_PPC64, test "x$cpu_ppc64" = xtrue)
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100170AM_CONDITIONAL(FLaC__CPU_SPARC, test "x$cpu_sparc" = xtrue)
171
Erik de Castro Lopo336f6a52015-02-25 06:40:53 +1100172if test "x$ac_cv_header_x86intrin_h" = xyes; then
173AC_DEFINE([FLAC__HAS_X86INTRIN], 1, [Set to 1 if <x86intrin.h> is available.])
Erik de Castro Lopo36a0ab12016-06-20 20:29:59 +1000174else
175AC_DEFINE([FLAC__HAS_X86INTRIN], 0)
Erik de Castro Lopo336f6a52015-02-25 06:40:53 +1100176fi
Erik de Castro Lopob72540b2013-09-15 09:42:29 +1000177
Amitay Isaacsc0215fc2018-07-09 12:38:47 +1000178if 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
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100198case "$host" in
199 i386-*-openbsd3.[[0-3]]) OBJ_FORMAT=aoutb ;;
200 *-*-cygwin|*mingw*) OBJ_FORMAT=win32 ;;
201 *-*-darwin*) OBJ_FORMAT=macho ;;
Erik de Castro Lopo0fe97672012-02-05 16:29:43 +1100202 *emx*) OBJ_FORMAT=aout ;;
sezero31b219f2017-01-13 17:51:06 +0300203 *djgpp) OBJ_FORMAT=coff ;;
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100204 *) OBJ_FORMAT=elf ;;
205esac
206AC_SUBST(OBJ_FORMAT)
207
Erik de Castro Lopo2199d082013-04-01 19:57:13 +1100208os_is_windows=no
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100209case "$host" in
Rosen Penevc6692492017-02-08 19:42:42 -0800210 *mingw*)
Erik de Castro Lopof44c3532013-04-02 06:27:07 +1100211 CPPFLAGS="-D__MSVCRT_VERSION__=0x0601 $CPPFLAGS"
Erik de Castro Lopo2199d082013-04-01 19:57:13 +1100212 os_is_windows=yes
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100213 ;;
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100214esac
Cristian Rodríguez355f4aa2013-07-21 01:28:51 -0400215
Erik de Castro Lopo2199d082013-04-01 19:57:13 +1100216AM_CONDITIONAL(OS_IS_WINDOWS, test "x$os_is_windows" = xyes)
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100217
218case "$host" in
Peter Korsgaard55721552017-01-09 22:19:01 +0100219 *-linux-*)
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100220 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
Erik de Castro Lopo899599e2013-09-25 23:26:49 +1000233if test "x$cpu_ia32" = xtrue || test "x$cpu_x86_64" = xtrue ; then
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100234AC_DEFINE(FLAC__ALIGN_MALLOC_DATA)
235AH_TEMPLATE(FLAC__ALIGN_MALLOC_DATA, [define to align allocated memory on 32-byte boundaries])
236fi
237
David Seifertb3ece712017-01-15 10:37:02 +0100238AM_CONDITIONAL([DEBUG], [test "x${ax_enable_debug}" = "xyes" || test "x${ax_enable_debug}" = "xinfo"])
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100239
240AC_ARG_ENABLE(sse,
Erik de Castro Lopof39a0ea2016-12-05 05:37:44 +1100241AC_HELP_STRING([--disable-sse], [Disable passing of -msse2 to the compiler]),
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100242[case "${enableval}" in
Erik de Castro Lopo98639982014-03-15 16:47:49 +1100243 yes) sse_os=yes ;;
244 no) sse_os=no ;;
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100245 *) AC_MSG_ERROR(bad value ${enableval} for --enable-sse) ;;
Erik de Castro Lopo98639982014-03-15 16:47:49 +1100246esac],[sse_os=yes])
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100247
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100248AC_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
Anton Blanchard5e0d4182018-07-08 14:55:03 +1000261AC_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
Dave Yeo0435a232016-01-24 22:09:50 -0800274AC_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
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100287AC_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
Erik de Castro Lopo2c455372014-04-08 20:48:13 +1000310AC_ARG_ENABLE(werror,
311 AC_HELP_STRING([--enable-werror], [Enable -Werror in all Makefiles]))
Erik de Castro Lopo195470f2013-03-13 18:58:16 +1100312
313AC_ARG_ENABLE(stack-smash-protection,
314 AC_HELP_STRING([--enable-stack-smash-protection], [Enable GNU GCC stack smash protection]))
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100315
Erik de Castro Lopoa3224c02016-01-04 11:29:03 +1100316AC_ARG_ENABLE(64-bit-words,
317 AC_HELP_STRING([--enable-64-bit-words], [Set FLAC__BYTES_PER_WORD to 8 (4 is the default)]))
318if test "x$enable_64_bit_words" = xyes ; then
319 AC_DEFINE_UNQUOTED([ENABLE_64_BIT_WORDS],1,[Set FLAC__BYTES_PER_WORD to 8 (4 is the default)])
320else
321 AC_DEFINE_UNQUOTED([ENABLE_64_BIT_WORDS],0)
322 fi
323AC_SUBST(ENABLE_64_BIT_WORDS)
324
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100325AC_ARG_ENABLE(valgrind-testing,
326AC_HELP_STRING([--enable-valgrind-testing], [Run all tests inside Valgrind]),
327[case "${enableval}" in
328 yes) FLAC__TEST_WITH_VALGRIND=yes ;;
329 no) FLAC__TEST_WITH_VALGRIND=no ;;
330 *) AC_MSG_ERROR(bad value ${enableval} for --enable-valgrind-testing) ;;
331esac],[FLAC__TEST_WITH_VALGRIND=no])
332AC_SUBST(FLAC__TEST_WITH_VALGRIND)
333
334AC_ARG_ENABLE(doxygen-docs,
335AC_HELP_STRING([--disable-doxygen-docs], [Disable API documentation building via Doxygen]),
336[case "${enableval}" in
337 yes) enable_doxygen_docs=true ;;
338 no) enable_doxygen_docs=false ;;
339 *) AC_MSG_ERROR(bad value ${enableval} for --enable-doxygen-docs) ;;
340esac],[enable_doxygen_docs=true])
341if test "x$enable_doxygen_docs" != xfalse ; then
342 AC_CHECK_PROGS(DOXYGEN, doxygen)
343fi
344AM_CONDITIONAL(FLaC__HAS_DOXYGEN, test -n "$DOXYGEN")
345
346AC_ARG_ENABLE(local-xmms-plugin,
347AC_HELP_STRING([--enable-local-xmms-plugin], [Install XMMS plugin to ~/.xmms/Plugins instead of system location]),
348[case "${enableval}" in
349 yes) install_xmms_plugin_locally=true ;;
350 no) install_xmms_plugin_locally=false ;;
351 *) AC_MSG_ERROR(bad value ${enableval} for --enable-local-xmms-plugin) ;;
352esac],[install_xmms_plugin_locally=false])
353AM_CONDITIONAL(FLaC__INSTALL_XMMS_PLUGIN_LOCALLY, test "x$install_xmms_plugin_locally" = xtrue)
354
355AC_ARG_ENABLE(xmms-plugin,
356AC_HELP_STRING([--disable-xmms-plugin], [Do not build XMMS plugin]),
357[case "${enableval}" in
358 yes) enable_xmms_plugin=true ;;
359 no) enable_xmms_plugin=false ;;
360 *) AC_MSG_ERROR(bad value ${enableval} for --enable-xmms-plugin) ;;
361esac],[enable_xmms_plugin=true])
362if test "x$enable_xmms_plugin" != xfalse ; then
363 AM_PATH_XMMS(0.9.5.1, , AC_MSG_WARN([*** XMMS >= 0.9.5.1 not installed - XMMS support will not be built]))
364fi
365AM_CONDITIONAL(FLaC__HAS_XMMS, test -n "$XMMS_INPUT_PLUGIN_DIR")
366
367dnl build FLAC++ or not
368AC_ARG_ENABLE([cpplibs],
369AC_HELP_STRING([--disable-cpplibs], [Do not build libFLAC++]),
370[case "${enableval}" in
371 yes) disable_cpplibs=false ;;
372 no) disable_cpplibs=true ;;
373 *) AC_MSG_ERROR(bad value ${enableval} for --enable-cpplibs) ;;
374esac], [disable_cpplibs=false])
375AM_CONDITIONAL(FLaC__WITH_CPPLIBS, [test "x$disable_cpplibs" != xtrue])
376
377dnl check for ogg library
378AC_ARG_ENABLE([ogg],
379 AC_HELP_STRING([--disable-ogg], [Disable ogg support (default: test for libogg)]),
380 [ want_ogg=$enableval ], [ want_ogg=yes ] )
381
382if test "x$want_ogg" != "xno"; then
luz.paz01eb1972018-05-22 10:17:53 -0400383 XIPH_PATH_OGG(have_ogg=yes, AC_MSG_WARN([*** Ogg development environment not installed - Ogg support will not be built]))
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100384fi
385
Erik de Castro Lopo9548d4b2016-03-20 20:14:01 +1100386FLAC__HAS_OGG=0
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100387AM_CONDITIONAL(FLaC__HAS_OGG, [test "x$have_ogg" = xyes])
388if test "x$have_ogg" = xyes ; then
Erik de Castro Lopo9548d4b2016-03-20 20:14:01 +1100389 FLAC__HAS_OGG=1
Ulrich Klauer5da86632013-04-06 20:41:12 +0200390 OGG_PACKAGE="ogg"
Erik de Castro Lopo3e2cd272012-07-04 19:53:31 +1000391else
Erik de Castro Lopoe21237a2013-09-15 19:58:05 +1000392 have_ogg=no
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100393fi
Erik de Castro Lopo9548d4b2016-03-20 20:14:01 +1100394AC_DEFINE_UNQUOTED([FLAC__HAS_OGG],$FLAC__HAS_OGG,[define if you have the ogg library])
395AC_SUBST(FLAC__HAS_OGG)
Ulrich Klauer5da86632013-04-06 20:41:12 +0200396AC_SUBST(OGG_PACKAGE)
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100397
David Seifertcc08beb2017-01-13 18:42:29 +0100398dnl Build examples?
399AC_ARG_ENABLE([examples],
400 AS_HELP_STRING([--disable-examples], [Don't build and install examples]))
401AM_CONDITIONAL([EXAMPLES], [test "x$enable_examples" != "xno"])
402
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100403dnl check for i18n(internationalization); these are from libiconv/gettext
404AM_ICONV
405AM_LANGINFO_CODESET
406
407AC_CHECK_PROGS(DOCBOOK_TO_MAN, docbook-to-man docbook2man)
408AM_CONDITIONAL(FLaC__HAS_DOCBOOK_TO_MAN, test -n "$DOCBOOK_TO_MAN")
409if test -n "$DOCBOOK_TO_MAN" ; then
410AC_DEFINE(FLAC__HAS_DOCBOOK_TO_MAN)
411AH_TEMPLATE(FLAC__HAS_DOCBOOK_TO_MAN, [define if you have docbook-to-man or docbook2man])
412fi
413
Dagobert Michelsenfcabd812019-07-16 13:36:12 +0200414AC_CHECK_LIB(rt, clock_gettime,
415 LIB_CLOCK_GETTIME=-lrt
Dave Yeo50e7aea2016-02-02 20:19:59 -0800416 AC_DEFINE(HAVE_CLOCK_GETTIME)
Dagobert Michelsenfcabd812019-07-16 13:36:12 +0200417 AH_TEMPLATE(HAVE_CLOCK_GETTIME, [define if you have clock_gettime]))
418AC_SUBST(LIB_CLOCK_GETTIME)
Dave Yeo50e7aea2016-02-02 20:19:59 -0800419
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100420# only matters for x86
421AC_CHECK_PROGS(NASM, nasm)
422AM_CONDITIONAL(FLaC__HAS_NASM, test -n "$NASM")
423if test -n "$NASM" ; then
424AC_DEFINE(FLAC__HAS_NASM)
425AH_TEMPLATE(FLAC__HAS_NASM, [define if you are compiling for x86 and have the NASM assembler])
426fi
427
David Seifertb3ece712017-01-15 10:37:02 +0100428dnl If debugging is disabled AND no CFLAGS/CXXFLAGS/CPPFLAGS/LDFLAGS
429dnl are provided, we can set defaults to our liking
430AS_IF([test "x${ax_enable_debug}" = "xno" && test "x${enable_flags_setting}" = "xyes"], [
Erik de Castro Lopod2cb0d12017-02-06 19:54:13 +1100431 CFLAGS="-O3 -funroll-loops"
David Seifertb3ece712017-01-15 10:37:02 +0100432])
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100433
Erik de Castro Lopocaef93e2012-02-26 22:41:44 +1100434XIPH_GCC_VERSION
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100435
436if test x$ac_cv_c_compiler_gnu = xyes ; then
Erik de Castro Lopod6c774c2016-01-26 12:33:01 +1100437 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
438 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
Erik de Castro Lopo06f38122013-03-10 22:34:18 +1100439
Erik de Castro Lopo24a64472013-09-15 18:09:48 +1000440 XIPH_ADD_CFLAGS([-Wdeclaration-after-statement])
David Seifertb3ece712017-01-15 10:37:02 +0100441
442 dnl some distributions (such as Gentoo) have _FORTIFY_SOURCE always
443 dnl enabled. We test for this situation in order to prevent polluting
444 dnl the console with messages of macro redefinitions.
Erik de Castro Lopod2cb0d12017-02-06 19:54:13 +1100445 AX_ADD_FORTIFY_SOURCE
Erik de Castro Lopo24a64472013-09-15 18:09:48 +1000446
447 AC_LANG_PUSH([C++])
448 XIPH_ADD_CXXFLAGS([-Weffc++])
449 AC_LANG_POP([C++])
450
Miroslav Lichvar19c78e52012-12-03 21:04:57 +0100451 if test "$GCC_MAJOR_VERSION" -ge 4 && test "$OBJ_FORMAT" = elf; then
452 CPPFLAGS="$CPPFLAGS -DFLAC__USE_VISIBILITY_ATTR"
453 CFLAGS="$CFLAGS -fvisibility=hidden"
454 CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
Erik de Castro Lopo2860f172013-03-09 19:42:26 +1100455 fi
456
Erik de Castro Lopobe0a8942014-05-25 19:42:53 +1000457 if test "$GCC_MAJOR_VERSION" -ge 4 && test "$OBJ_FORMAT" = macho; then
458 CPPFLAGS="$CPPFLAGS -DFLAC__USE_VISIBILITY_ATTR"
459 CFLAGS="$CFLAGS -fvisibility=hidden"
460 CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
461 fi
462
Erik de Castro Lopo2860f172013-03-09 19:42:26 +1100463 if test "x$GCC_MAJOR_VERSION$GCC_MINOR_VERSION" = "x42" ; then
464 XIPH_ADD_CFLAGS([-fgnu89-inline])
465 fi
Erik de Castro Lopo24a64472013-09-15 18:09:48 +1000466
Mario Sanchez Prada5ff15bd2015-06-08 17:25:27 +0100467 if test "x$GCC_MAJOR_VERSION$GCC_MINOR_VERSION" = "x47" ; then
468 XIPH_ADD_CFLAGS([-fno-inline-small-functions])
469 fi
470
Erik de Castro Lopo1930ae12014-07-27 21:18:08 +1000471 if test "x$asm_optimisation$sse_os" = "xyesyes" ; then
Erik de Castro Lopoae4d7202013-09-15 20:34:40 +1000472 XIPH_ADD_CFLAGS([-msse2])
473 fi
474
Miroslav Lichvar19c78e52012-12-03 21:04:57 +0100475 fi
Miroslav Lichvar19c78e52012-12-03 21:04:57 +0100476
Tristan Matthewsa8458702015-04-11 01:05:30 -0400477case "$host_os" in
478 "mingw32"|"os2")
479 if test "$host_cpu" = "i686"; then
480 XIPH_ADD_CFLAGS([-mstackrealign])
481 fi
482 esac
483
Erik de Castro Lopo2c455372014-04-08 20:48:13 +1000484if test x$enable_werror = "xyes" ; then
485 XIPH_ADD_CFLAGS([-Werror])
486 AC_LANG_PUSH([C++])
487 XIPH_ADD_CXXFLAGS([-Werror])
488 AC_LANG_POP([C++])
489 fi
490
Erik de Castro Lopo195470f2013-03-13 18:58:16 +1100491if test x$enable_stack_smash_protection = "xyes" ; then
492 XIPH_GCC_STACK_PROTECTOR
493 XIPH_GXX_STACK_PROTECTOR
494 fi
Erik de Castro Lopod5b03bc2013-03-09 08:55:37 +1100495
sezerob917d452019-10-08 15:10:20 +0300496AH_VERBATIM([FLAC_API_EXPORTS],
497[/* libtool defines DLL_EXPORT for windows dll builds,
498 but flac code relies on FLAC_API_EXPORTS instead. */
499#ifdef DLL_EXPORT
500#ifdef __cplusplus
501# define FLACPP_API_EXPORTS
502#else
503# define FLAC_API_EXPORTS
504#endif
505#endif])
506
507if test x$enable_shared != "xyes" ; then
508dnl for correct FLAC_API
509 CPPFLAGS="-DFLAC__NO_DLL $CPPFLAGS"
510 fi
511
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100512AC_CONFIG_FILES([ \
513 Makefile \
514 src/Makefile \
515 src/libFLAC/Makefile \
516 src/libFLAC/flac.pc \
517 src/libFLAC/ia32/Makefile \
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100518 src/libFLAC/include/Makefile \
519 src/libFLAC/include/private/Makefile \
520 src/libFLAC/include/protected/Makefile \
521 src/libFLAC++/Makefile \
522 src/libFLAC++/flac++.pc \
523 src/flac/Makefile \
524 src/metaflac/Makefile \
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100525 src/plugin_common/Makefile \
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100526 src/plugin_xmms/Makefile \
527 src/share/Makefile \
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100528 src/test_grabbag/Makefile \
529 src/test_grabbag/cuesheet/Makefile \
530 src/test_grabbag/picture/Makefile \
531 src/test_libs_common/Makefile \
532 src/test_libFLAC/Makefile \
533 src/test_libFLAC++/Makefile \
534 src/test_seeking/Makefile \
535 src/test_streams/Makefile \
536 src/utils/Makefile \
537 src/utils/flacdiff/Makefile \
538 src/utils/flactimer/Makefile \
539 examples/Makefile \
540 examples/c/Makefile \
541 examples/c/decode/Makefile \
542 examples/c/decode/file/Makefile \
543 examples/c/encode/Makefile \
544 examples/c/encode/file/Makefile \
545 examples/cpp/Makefile \
546 examples/cpp/decode/Makefile \
547 examples/cpp/decode/file/Makefile \
548 examples/cpp/encode/Makefile \
549 examples/cpp/encode/file/Makefile \
550 include/Makefile \
551 include/FLAC/Makefile \
552 include/FLAC++/Makefile \
553 include/share/Makefile \
554 include/share/grabbag/Makefile \
555 include/test_libs_common/Makefile \
Olivier Blinf6997882012-12-28 19:58:46 +0100556 doc/Doxyfile \
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100557 doc/Makefile \
558 doc/html/Makefile \
559 doc/html/images/Makefile \
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100560 m4/Makefile \
561 man/Makefile \
Erik de Castro Lopoa9712a22013-09-16 19:55:11 +1000562 test/common.sh \
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100563 test/Makefile \
564 test/cuesheets/Makefile \
565 test/flac-to-flac-metadata-test-files/Makefile \
566 test/metaflac-test-files/Makefile \
567 test/pictures/Makefile \
568 build/Makefile \
Erik de Castro Lopo95fc3bf2015-09-01 03:38:43 +1000569 microbench/Makefile
Erik de Castro Lopo06ed05e2012-02-01 17:55:50 +1100570])
571AC_OUTPUT
Erik de Castro Lopocaef93e2012-02-26 22:41:44 +1100572
573AC_MSG_RESULT([
574-=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=-
575
576 Configuration summary :
577
578 FLAC version : ........................ ${VERSION}
579
580 Host CPU : ............................ ${host_cpu}
581 Host Vendor : ......................... ${host_vendor}
582 Host OS : ............................. ${host_os}
583])
584
Erik de Castro Lopocaef93e2012-02-26 22:41:44 +1100585 echo " Compiler is GCC : ..................... ${ac_cv_c_compiler_gnu}"
Max Horncdcb88b2012-12-12 21:33:53 +0100586if test x$ac_cv_c_compiler_gnu = xyes ; then
Erik de Castro Lopocaef93e2012-02-26 22:41:44 +1100587 echo " GCC version : ......................... ${GCC_VERSION}"
Max Horncdcb88b2012-12-12 21:33:53 +0100588fi
Erik de Castro Lopoa6a4b6f2013-11-22 18:13:36 +1100589 echo " Compiler is Clang : ................... ${xiph_cv_c_compiler_clang}"
Erik de Castro Lopo98639982014-03-15 16:47:49 +1100590 echo " SSE optimizations : ................... ${sse_os}"
Erik de Castro Lopo899599e2013-09-25 23:26:49 +1000591 echo " Asm optimizations : ................... ${asm_optimisation}"
Erik de Castro Lopoe21237a2013-09-15 19:58:05 +1000592 echo " Ogg/FLAC support : .................... ${have_ogg}"
Erik de Castro Lopo592021e2012-12-28 09:49:50 +1100593echo