configure: merge AC_CHECK_HEADERS calls
[platform/upstream/flac.git] / configure.ac
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 difference 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
21 AC_PREREQ(2.60)
22 AC_INIT([flac], [1.2.1])
23 AC_CONFIG_SRCDIR([src/flac/main.c])
24 AC_CONFIG_MACRO_DIR([m4])
25 AM_INIT_AUTOMAKE([foreign 1.7 -Wall tar-pax no-dist-gzip dist-xz subdir-objects])
26 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
27
28 user_cflags=$CFLAGS
29
30 #Prefer whatever the current ISO standard is.
31 AC_PROG_CC_STDC
32 AC_USE_SYSTEM_EXTENSIONS
33 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
34 LT_INIT([win32-dll disable-static pic-only])
35 AM_PROG_AS
36 AC_PROG_CXX
37 AC_PROG_MAKE_SET
38
39 AC_SYS_LARGEFILE
40 AC_FUNC_FSEEKO
41
42 AC_CHECK_SIZEOF(void*,0)
43 AC_SEARCH_LIBS([lround],[m], [AC_DEFINE(HAVE_LROUND,1,lround support)])
44 #@@@ new name is AC_CONFIG_HEADERS
45 AM_CONFIG_HEADER(config.h)
46
47 AC_LANG_PUSH(C++)
48 # c++ flavor first
49 AC_C_VARARRAYS
50 if test $ac_cv_c_vararrays = yes; then
51         AC_DEFINE([HAVE_CXX_VARARRAYS], 1, [Define to 1 if C++ supports variable-length arrays.])
52 fi
53 AC_LANG_POP(C++)
54
55 # c flavor
56 AC_HEADER_STDC
57 AM_PROG_CC_C_O
58 AC_C_INLINE
59 AC_C_VARARRAYS
60 AC_C_TYPEOF
61
62 AC_CHECK_HEADERS([stdint.h inttypes.h byteswap.h sys/param.h])
63
64 XIPH_C_BSWAP32
65
66 ac_cv_c_big_endian=0
67 ac_cv_c_little_endian=0
68 AC_C_BIGENDIAN([ac_cv_c_big_endian=1], [ac_cv_c_little_endian=1], [
69         AC_MSG_WARN([[*****************************************************************]])
70         AC_MSG_WARN([[*** Not able to determine endian-ness of target processor.       ]])
71         AC_MSG_WARN([[*** The constants CPU_IS_BIG_ENDIAN and CPU_IS_LITTLE_ENDIAN in  ]])
72         AC_MSG_WARN([[*** config.h may need to be hand editied.                        ]])
73         AC_MSG_WARN([[*****************************************************************]])
74 ])
75 AC_DEFINE_UNQUOTED(CPU_IS_BIG_ENDIAN, ${ac_cv_c_big_endian},
76                                         [Target processor is big endian.])
77 AC_DEFINE_UNQUOTED(CPU_IS_LITTLE_ENDIAN, ${ac_cv_c_little_endian},
78                                         [Target processor is little endian.])
79 AC_DEFINE_UNQUOTED(WORDS_BIGENDIAN, ${ac_cv_c_big_endian},
80                                         [Target processor is big endian.])
81
82 # For the XMMS plugin.
83 AC_CHECK_TYPES(socklen_t, [], [])
84
85 dnl check for getopt in standard library
86 dnl AC_CHECK_FUNCS(getopt_long , , [LIBOBJS="$LIBOBJS getopt.o getopt1.o"] )
87 AC_CHECK_FUNCS(getopt_long, [], [])
88
89 case "$host_cpu" in
90         i*86)
91                 cpu_ia32=true
92                 AC_DEFINE(FLAC__CPU_IA32)
93                 AH_TEMPLATE(FLAC__CPU_IA32, [define if building for ia32/i386])
94                 ;;
95         powerpc)
96                 cpu_ppc=true
97                 AC_DEFINE(FLAC__CPU_PPC)
98                 AH_TEMPLATE(FLAC__CPU_PPC, [define if building for PowerPC])
99                 ;;
100         sparc)
101                 cpu_sparc=true
102                 AC_DEFINE(FLAC__CPU_SPARC)
103                 AH_TEMPLATE(FLAC__CPU_SPARC, [define if building for SPARC])
104                 ;;
105 esac
106 AM_CONDITIONAL(FLaC__CPU_IA32, test "x$cpu_ia32" = xtrue)
107 AM_CONDITIONAL(FLaC__CPU_PPC, test "x$cpu_ppc" = xtrue)
108 AM_CONDITIONAL(FLaC__CPU_SPARC, test "x$cpu_sparc" = xtrue)
109
110 case "$host" in
111         i386-*-openbsd3.[[0-3]]) OBJ_FORMAT=aoutb ;;
112         *-*-cygwin|*mingw*) OBJ_FORMAT=win32 ;;
113         *-*-darwin*) OBJ_FORMAT=macho ;;
114         *emx*) OBJ_FORMAT=aout ;;
115         *) OBJ_FORMAT=elf ;;
116 esac
117 AC_SUBST(OBJ_FORMAT)
118 case "$host" in
119         *-gnuspe)
120                 abi_spe=true
121                 AC_DEFINE(FLAC__CPU_PPC_SPE)
122                 AH_TEMPLATE(FLAC__CPU_PPC_SPE, [define if building for PowerPC with SPE ABI])
123                 ;;
124 esac
125 AM_CONDITIONAL(FLaC__CPU_PPC_SPE, test "x$abi_spe" = xtrue)
126
127 case "$host" in
128         *-*-cygwin|*mingw*|*emx*)
129                 # define this variable for enabling strict exports with libtool; for now, it's supported by Win32 and OS/2
130                 LT_NO_UNDEFINED="-no-undefined"
131                 ;;
132         *)
133                 LT_NO_UNDEFINED=
134                 ;;
135 esac
136 AC_SUBST(LT_NO_UNDEFINED)
137
138 case "$host" in
139         *-pc-linux-gnu)
140                 sys_linux=true
141                 AC_DEFINE(FLAC__SYS_LINUX)
142                 AH_TEMPLATE(FLAC__SYS_LINUX, [define if building for Linux])
143                 ;;
144         *-*-darwin*)
145                 sys_darwin=true
146                 AC_DEFINE(FLAC__SYS_DARWIN)
147                 AH_TEMPLATE(FLAC__SYS_DARWIN, [define if building for Darwin / MacOS X])
148                 ;;
149 esac
150 AM_CONDITIONAL(FLaC__SYS_DARWIN, test "x$sys_darwin" = xtrue)
151 AM_CONDITIONAL(FLaC__SYS_LINUX, test "x$sys_linux" = xtrue)
152
153 if test "x$cpu_ia32" = xtrue ; then
154 AC_DEFINE(FLAC__ALIGN_MALLOC_DATA)
155 AH_TEMPLATE(FLAC__ALIGN_MALLOC_DATA, [define to align allocated memory on 32-byte boundaries])
156 fi
157
158 AC_ARG_ENABLE(asm-optimizations, AC_HELP_STRING([--disable-asm-optimizations], [Don't use any assembly optimization routines]), asm_opt=no, asm_opt=yes)
159 dnl ' Terminate the damn single quote
160 AM_CONDITIONAL(FLaC__NO_ASM, test "x$asm_opt" = xno)
161 if test "x$asm_opt" = xno ; then
162 AC_DEFINE(FLAC__NO_ASM)
163 AH_TEMPLATE(FLAC__NO_ASM, [define to disable use of assembly code])
164 fi
165
166 AC_ARG_ENABLE(debug,
167 AC_HELP_STRING([--enable-debug], [Turn on debugging]),
168 [case "${enableval}" in
169         yes) debug=true ;;
170         no)  debug=false ;;
171         *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
172 esac],[debug=false])
173 AM_CONDITIONAL(DEBUG, test "x$debug" = xtrue)
174
175 AC_ARG_ENABLE(sse,
176 AC_HELP_STRING([--enable-sse], [Enable SSE support by asserting that the OS supports SSE instructions]),
177 [case "${enableval}" in
178         yes) sse_os=true ;;
179         no)  sse_os=false ;;
180         *) AC_MSG_ERROR(bad value ${enableval} for --enable-sse) ;;
181 esac],[sse_os=false])
182 AM_CONDITIONAL(FLaC__SSE_OS, test "x$sse_os" = xtrue)
183 if test "x$sse_os" = xtrue ; then
184 AC_DEFINE(FLAC__SSE_OS)
185 AH_TEMPLATE(FLAC__SSE_OS, [define if your operating system supports SSE instructions])
186 fi
187
188 AC_ARG_ENABLE(3dnow,
189 AC_HELP_STRING([--disable-3dnow], [Disable 3DNOW! optimizations]),
190 [case "${enableval}" in
191         yes) use_3dnow=true ;;
192         no)  use_3dnow=false ;;
193         *) AC_MSG_ERROR(bad value ${enableval} for --enable-3dnow) ;;
194 esac],[use_3dnow=true])
195 AM_CONDITIONAL(FLaC__USE_3DNOW, test "x$use_3dnow" = xtrue)
196 if test "x$use_3dnow" = xtrue ; then
197 AC_DEFINE(FLAC__USE_3DNOW)
198 AH_TEMPLATE(FLAC__USE_3DNOW, [define to enable use of 3Dnow! instructions])
199 fi
200
201 AC_ARG_ENABLE(altivec,
202 AC_HELP_STRING([--disable-altivec], [Disable Altivec optimizations]),
203 [case "${enableval}" in
204         yes) use_altivec=true ;;
205         no)  use_altivec=false ;;
206         *) AC_MSG_ERROR(bad value ${enableval} for --enable-altivec) ;;
207 esac],[use_altivec=true])
208 AM_CONDITIONAL(FLaC__USE_ALTIVEC, test "x$use_altivec" = xtrue)
209 if test "x$use_altivec" = xtrue ; then
210 AC_DEFINE(FLAC__USE_ALTIVEC)
211 AH_TEMPLATE(FLAC__USE_ALTIVEC, [define to enable use of Altivec instructions])
212 fi
213
214 AC_ARG_ENABLE(thorough-tests,
215 AC_HELP_STRING([--disable-thorough-tests], [Disable thorough (long) testing, do only basic tests]),
216 [case "${enableval}" in
217         yes) thorough_tests=true ;;
218         no)  thorough_tests=false ;;
219         *) AC_MSG_ERROR(bad value ${enableval} for --enable-thorough-tests) ;;
220 esac],[thorough_tests=true])
221 AC_ARG_ENABLE(exhaustive-tests,
222 AC_HELP_STRING([--enable-exhaustive-tests], [Enable exhaustive testing (VERY long)]),
223 [case "${enableval}" in
224         yes) exhaustive_tests=true ;;
225         no)  exhaustive_tests=false ;;
226         *) AC_MSG_ERROR(bad value ${enableval} for --enable-exhaustive-tests) ;;
227 esac],[exhaustive_tests=false])
228 if test "x$thorough_tests" = xfalse ; then
229 FLAC__TEST_LEVEL=0
230 elif test "x$exhaustive_tests" = xfalse ; then
231 FLAC__TEST_LEVEL=1
232 else
233 FLAC__TEST_LEVEL=2
234 fi
235 AC_SUBST(FLAC__TEST_LEVEL)
236
237 AC_ARG_ENABLE(gcc-werror,
238         AC_HELP_STRING([--enable-gcc-werror], [enable -Werror in all Makefiles]))
239
240 AC_ARG_ENABLE(valgrind-testing,
241 AC_HELP_STRING([--enable-valgrind-testing], [Run all tests inside Valgrind]),
242 [case "${enableval}" in
243         yes) FLAC__TEST_WITH_VALGRIND=yes ;;
244         no)  FLAC__TEST_WITH_VALGRIND=no ;;
245         *) AC_MSG_ERROR(bad value ${enableval} for --enable-valgrind-testing) ;;
246 esac],[FLAC__TEST_WITH_VALGRIND=no])
247 AC_SUBST(FLAC__TEST_WITH_VALGRIND)
248
249 AC_ARG_ENABLE(doxygen-docs,
250 AC_HELP_STRING([--disable-doxygen-docs], [Disable API documentation building via Doxygen]),
251 [case "${enableval}" in
252         yes) enable_doxygen_docs=true ;;
253         no)  enable_doxygen_docs=false ;;
254         *) AC_MSG_ERROR(bad value ${enableval} for --enable-doxygen-docs) ;;
255 esac],[enable_doxygen_docs=true])
256 if test "x$enable_doxygen_docs" != xfalse ; then
257         AC_CHECK_PROGS(DOXYGEN, doxygen)
258 fi
259 AM_CONDITIONAL(FLaC__HAS_DOXYGEN, test -n "$DOXYGEN")
260
261 AC_ARG_ENABLE(local-xmms-plugin,
262 AC_HELP_STRING([--enable-local-xmms-plugin], [Install XMMS plugin to ~/.xmms/Plugins instead of system location]),
263 [case "${enableval}" in
264         yes) install_xmms_plugin_locally=true ;;
265         no)  install_xmms_plugin_locally=false ;;
266         *) AC_MSG_ERROR(bad value ${enableval} for --enable-local-xmms-plugin) ;;
267 esac],[install_xmms_plugin_locally=false])
268 AM_CONDITIONAL(FLaC__INSTALL_XMMS_PLUGIN_LOCALLY, test "x$install_xmms_plugin_locally" = xtrue)
269
270 AC_ARG_ENABLE(xmms-plugin,
271 AC_HELP_STRING([--disable-xmms-plugin], [Do not build XMMS plugin]),
272 [case "${enableval}" in
273         yes) enable_xmms_plugin=true ;;
274         no)  enable_xmms_plugin=false ;;
275         *) AC_MSG_ERROR(bad value ${enableval} for --enable-xmms-plugin) ;;
276 esac],[enable_xmms_plugin=true])
277 if test "x$enable_xmms_plugin" != xfalse ; then
278         AM_PATH_XMMS(0.9.5.1, , AC_MSG_WARN([*** XMMS >= 0.9.5.1 not installed - XMMS support will not be built]))
279 fi
280 AM_CONDITIONAL(FLaC__HAS_XMMS, test -n "$XMMS_INPUT_PLUGIN_DIR")
281
282 dnl build FLAC++ or not
283 AC_ARG_ENABLE([cpplibs],
284 AC_HELP_STRING([--disable-cpplibs], [Do not build libFLAC++]),
285 [case "${enableval}" in
286         yes) disable_cpplibs=false ;;
287         no)  disable_cpplibs=true ;;
288         *)   AC_MSG_ERROR(bad value ${enableval} for --enable-cpplibs) ;;
289 esac], [disable_cpplibs=false])
290 AM_CONDITIONAL(FLaC__WITH_CPPLIBS, [test "x$disable_cpplibs" != xtrue])
291
292 dnl check for ogg library
293 AC_ARG_ENABLE([ogg],
294         AC_HELP_STRING([--disable-ogg], [Disable ogg support (default: test for libogg)]),
295         [ want_ogg=$enableval ], [ want_ogg=yes ] )
296
297 if test "x$want_ogg" != "xno"; then
298         XIPH_PATH_OGG(have_ogg=yes, AC_MSG_WARN([*** Ogg development enviroment not installed - Ogg support will not be built]))
299 fi
300
301 AM_CONDITIONAL(FLaC__HAS_OGG, [test "x$have_ogg" = xyes])
302 if test "x$have_ogg" = xyes ; then
303         AC_DEFINE_UNQUOTED([FLAC__HAS_OGG],1,[define if you have the ogg library])
304 else
305         AC_DEFINE_UNQUOTED([FLAC__HAS_OGG],0)
306 fi
307
308 dnl check for i18n(internationalization); these are from libiconv/gettext
309 AM_ICONV
310 AM_LANGINFO_CODESET
311
312 AC_CHECK_PROGS(DOCBOOK_TO_MAN, docbook-to-man docbook2man)
313 AM_CONDITIONAL(FLaC__HAS_DOCBOOK_TO_MAN, test -n "$DOCBOOK_TO_MAN")
314 if test -n "$DOCBOOK_TO_MAN" ; then
315 AC_DEFINE(FLAC__HAS_DOCBOOK_TO_MAN)
316 AH_TEMPLATE(FLAC__HAS_DOCBOOK_TO_MAN, [define if you have docbook-to-man or docbook2man])
317 fi
318
319 # only matters for x86
320 AC_CHECK_PROGS(NASM, nasm)
321 AM_CONDITIONAL(FLaC__HAS_NASM, test -n "$NASM")
322 if test -n "$NASM" ; then
323 AC_DEFINE(FLAC__HAS_NASM)
324 AH_TEMPLATE(FLAC__HAS_NASM, [define if you are compiling for x86 and have the NASM assembler])
325 fi
326
327 # only matters for PowerPC
328 AC_CHECK_PROGS(AS, as, as)
329 AC_CHECK_PROGS(GAS, gas, gas)
330
331 # try -v (apple as) and --version (gas) at the same time
332 test "$AS" = "as" && as --version -v < /dev/null 2>&1 | grep Apple >/dev/null || AS=gas
333
334 AM_CONDITIONAL(FLaC__HAS_AS, test "$AS" = "as")
335 AM_CONDITIONAL(FLaC__HAS_GAS, test "$AS" = "gas")
336 if test "$AS" = "as" ; then
337 AC_DEFINE(FLAC__HAS_AS)
338 AH_TEMPLATE(FLAC__HAS_AS, [define if you are compiling for PowerPC and have the 'as' assembler])
339 fi
340 if test "$AS" = "gas" ; then
341 # funniest. macro. ever.
342 AC_DEFINE(FLAC__HAS_GAS)
343 AH_TEMPLATE(FLAC__HAS_GAS, [define if you are compiling for PowerPC and have the 'gas' assembler])
344 fi
345
346 if test "x$debug" = xtrue; then
347         CPPFLAGS="-DDEBUG $CPPFLAGS"
348         CFLAGS="-g $CFLAGS"
349 else
350         CPPFLAGS="-DNDEBUG $CPPFLAGS"
351         if test "x$GCC" = xyes; then
352                 if test "x$user_cflags" = x; then
353                         CFLAGS="-O3 -funroll-loops -Wall -W -Winline"
354                 fi
355         fi
356 fi
357
358 XIPH_GCC_VERSION
359
360 if test x$ac_cv_c_compiler_gnu = xyes ; then
361         if test x$enable_gcc_werror = "xyes" ; then
362                 CFLAGS="-Wall -Wextra -Werror $CFLAGS"
363                 CXXFLAGS="-Wall -Wextra -Werror $CXXFLAGS"
364         fi
365
366         if test "$GCC_MAJOR_VERSION" -ge 4 && test "$OBJ_FORMAT" = elf; then
367                 CPPFLAGS="$CPPFLAGS -DFLAC__USE_VISIBILITY_ATTR"
368                 CFLAGS="$CFLAGS -fvisibility=hidden"
369                 CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
370         fi
371 fi
372
373
374 #@@@
375 AM_CONDITIONAL(FLaC__HAS_AS__TEMPORARILY_DISABLED, test "yes" = "no")
376 AM_CONDITIONAL(FLaC__HAS_GAS__TEMPORARILY_DISABLED, test "yes" = "no")
377
378 AC_CONFIG_FILES([ \
379         Makefile \
380         src/Makefile \
381         src/libFLAC/Makefile \
382         src/libFLAC/flac.pc \
383         src/libFLAC/ia32/Makefile \
384         src/libFLAC/ppc/Makefile \
385         src/libFLAC/ppc/as/Makefile \
386         src/libFLAC/ppc/gas/Makefile \
387         src/libFLAC/include/Makefile \
388         src/libFLAC/include/private/Makefile \
389         src/libFLAC/include/protected/Makefile \
390         src/libFLAC++/Makefile \
391         src/libFLAC++/flac++.pc \
392         src/flac/Makefile \
393         src/metaflac/Makefile \
394         src/monkeys_audio_utilities/Makefile \
395         src/monkeys_audio_utilities/flac_mac/Makefile \
396         src/monkeys_audio_utilities/flac_ren/Makefile \
397         src/plugin_common/Makefile \
398         src/plugin_xmms/Makefile \
399         src/share/Makefile \
400         src/share/getopt/Makefile \
401         src/share/grabbag/Makefile \
402         src/share/replaygain_analysis/Makefile \
403         src/share/replaygain_synthesis/Makefile \
404         src/share/replaygain_synthesis/include/Makefile \
405         src/share/replaygain_synthesis/include/private/Makefile \
406         src/share/utf8/Makefile \
407         src/test_grabbag/Makefile \
408         src/test_grabbag/cuesheet/Makefile \
409         src/test_grabbag/picture/Makefile \
410         src/test_libs_common/Makefile \
411         src/test_libFLAC/Makefile \
412         src/test_libFLAC++/Makefile \
413         src/test_seeking/Makefile \
414         src/test_streams/Makefile \
415         src/utils/Makefile \
416         src/utils/flacdiff/Makefile \
417         src/utils/flactimer/Makefile \
418         examples/Makefile \
419         examples/c/Makefile \
420         examples/c/decode/Makefile \
421         examples/c/decode/file/Makefile \
422         examples/c/encode/Makefile \
423         examples/c/encode/file/Makefile \
424         examples/cpp/Makefile \
425         examples/cpp/decode/Makefile \
426         examples/cpp/decode/file/Makefile \
427         examples/cpp/encode/Makefile \
428         examples/cpp/encode/file/Makefile \
429         include/Makefile \
430         include/FLAC/Makefile \
431         include/FLAC++/Makefile \
432         include/share/Makefile \
433         include/share/grabbag/Makefile \
434         include/test_libs_common/Makefile \
435         doc/Makefile \
436         doc/html/Makefile \
437         doc/html/images/Makefile \
438         doc/html/images/hw/Makefile \
439         doc/html/ru/Makefile \
440         m4/Makefile \
441         man/Makefile \
442         test/Makefile \
443         test/cuesheets/Makefile \
444         test/flac-to-flac-metadata-test-files/Makefile \
445         test/metaflac-test-files/Makefile \
446         test/pictures/Makefile \
447         build/Makefile \
448         obj/Makefile \
449         obj/debug/Makefile \
450         obj/debug/bin/Makefile \
451         obj/debug/lib/Makefile \
452         obj/release/Makefile \
453         obj/release/bin/Makefile \
454         obj/release/lib/Makefile \
455 ])
456 AC_OUTPUT
457
458 AC_MSG_RESULT([
459 -=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=-
460
461   Configuration summary :
462
463     FLAC version : ........................ ${VERSION}
464
465     Host CPU : ............................ ${host_cpu}
466     Host Vendor : ......................... ${host_vendor}
467     Host OS : ............................. ${host_os}
468 ])
469
470         echo "    Compiler is GCC : ..................... ${ac_cv_c_compiler_gnu}"
471 if test x$ac_cv_c_compiler_gnu = xyes ; then
472         echo "    GCC version : ......................... ${GCC_VERSION}"
473 fi