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