Add missing <csting> include.
[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_INIT(src/flac/main.c)
22 AM_INIT_AUTOMAKE(flac, 1.2.1)
23 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
24
25 # Enable the generation of shared libraries under Win32
26 AC_LIBTOOL_WIN32_DLL
27
28 # We need two libtools, one that builds both shared and static, and
29 # one that builds only static.  This is because the resulting libtool
30 # does not allow us to choose which to build at runtime.
31 AM_PROG_LIBTOOL
32 sed -e 's/^build_old_libs=yes/build_old_libs=no/' libtool > libtool-disable-static
33 chmod +x libtool-disable-static
34
35 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
36
37 AM_PROG_AS
38 AC_PROG_CXX
39 AC_PROG_MAKE_SET
40
41 AC_SYS_LARGEFILE
42 AC_FUNC_FSEEKO
43
44 AC_CHECK_SIZEOF(void*,0)
45
46 #@@@ new name is AC_CONFIG_HEADERS
47 AM_CONFIG_HEADER(config.h)
48
49 AC_LANG_PUSH(C++)
50 # c++ flavor first
51 AC_C_VARARRAYS
52 if test $ac_cv_c_vararrays = yes; then
53         AC_DEFINE([HAVE_CXX_VARARRAYS], 1, [Define to 1 if C++ supports variable-length arrays.])
54 fi
55 AC_LANG_POP(C++)
56
57 # c flavor
58 AC_HEADER_STDC
59 AC_C_INLINE
60 AC_C_VARARRAYS
61
62 AC_CHECK_HEADERS(stdint.h)
63 AC_SUBST(HAVE_STDINT_H)
64 AC_CHECK_HEADERS(inttypes.h)
65 AC_SUBST(HAVE_INTTYPES_H)
66 AC_CHECK_HEADERS(byteswap.h)
67 AC_SUBST(HAVE_BYTESWAP_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
116 case "$host" in
117         *-*-cygwin|*mingw*|*emx*)
118                 # define this variable for enabling strict exports with libtool; for now, it's supported by Win32 and OS/2
119                 LT_NO_UNDEFINED="-no-undefined"
120                 ;;
121         *)
122                 LT_NO_UNDEFINED=
123                 ;;
124 esac
125 AC_SUBST(LT_NO_UNDEFINED)
126
127 case "$host" in
128         *-pc-linux-gnu)
129                 sys_linux=true
130                 AC_DEFINE(FLAC__SYS_LINUX)
131                 AH_TEMPLATE(FLAC__SYS_LINUX, [define if building for Linux])
132                 ;;
133         *-*-darwin*)
134                 sys_darwin=true
135                 AC_DEFINE(FLAC__SYS_DARWIN)
136                 AH_TEMPLATE(FLAC__SYS_DARWIN, [define if building for Darwin / MacOS X])
137                 ;;
138 esac
139 AM_CONDITIONAL(FLaC__SYS_DARWIN, test "x$sys_darwin" = xtrue)
140 AM_CONDITIONAL(FLaC__SYS_LINUX, test "x$sys_linux" = xtrue)
141
142 if test "x$cpu_ia32" = xtrue ; then
143 AC_DEFINE(FLAC__ALIGN_MALLOC_DATA)
144 AH_TEMPLATE(FLAC__ALIGN_MALLOC_DATA, [define to align allocated memory on 32-byte boundaries])
145 fi
146
147 AC_ARG_ENABLE(asm-optimizations, AC_HELP_STRING([--disable-asm-optimizations], [Don't use any assembly optimization routines]), asm_opt=no, asm_opt=yes)
148 dnl ' Terminate the damn single quote
149 AM_CONDITIONAL(FLaC__NO_ASM, test "x$asm_opt" = xno)
150 if test "x$asm_opt" = xno ; then
151 AC_DEFINE(FLAC__NO_ASM)
152 AH_TEMPLATE(FLAC__NO_ASM, [define to disable use of assembly code])
153 fi
154
155 AC_ARG_ENABLE(debug,
156 AC_HELP_STRING([--enable-debug], [Turn on debugging]),
157 [case "${enableval}" in
158         yes) debug=true ;;
159         no)  debug=false ;;
160         *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
161 esac],[debug=false])
162 AM_CONDITIONAL(DEBUG, test "x$debug" = xtrue)
163
164 AC_ARG_ENABLE(sse,
165 AC_HELP_STRING([--enable-sse], [Enable SSE support by asserting that the OS supports SSE instructions]),
166 [case "${enableval}" in
167         yes) sse_os=true ;;
168         no)  sse_os=false ;;
169         *) AC_MSG_ERROR(bad value ${enableval} for --enable-sse) ;;
170 esac],[sse_os=false])
171 AM_CONDITIONAL(FLaC__SSE_OS, test "x$sse_os" = xtrue)
172 if test "x$sse_os" = xtrue ; then
173 AC_DEFINE(FLAC__SSE_OS)
174 AH_TEMPLATE(FLAC__SSE_OS, [define if your operating system supports SSE instructions])
175 fi
176
177 AC_ARG_ENABLE(3dnow,
178 AC_HELP_STRING([--disable-3dnow], [Disable 3DNOW! optimizations]),
179 [case "${enableval}" in
180         yes) use_3dnow=true ;;
181         no)  use_3dnow=false ;;
182         *) AC_MSG_ERROR(bad value ${enableval} for --enable-3dnow) ;;
183 esac],[use_3dnow=true])
184 AM_CONDITIONAL(FLaC__USE_3DNOW, test "x$use_3dnow" = xtrue)
185 if test "x$use_3dnow" = xtrue ; then
186 AC_DEFINE(FLAC__USE_3DNOW)
187 AH_TEMPLATE(FLAC__USE_3DNOW, [define to enable use of 3Dnow! instructions])
188 fi
189
190 AC_ARG_ENABLE(altivec,
191 AC_HELP_STRING([--disable-altivec], [Disable Altivec optimizations]),
192 [case "${enableval}" in
193         yes) use_altivec=true ;;
194         no)  use_altivec=false ;;
195         *) AC_MSG_ERROR(bad value ${enableval} for --enable-altivec) ;;
196 esac],[use_altivec=true])
197 AM_CONDITIONAL(FLaC__USE_ALTIVEC, test "x$use_altivec" = xtrue)
198 if test "x$use_altivec" = xtrue ; then
199 AC_DEFINE(FLAC__USE_ALTIVEC)
200 AH_TEMPLATE(FLAC__USE_ALTIVEC, [define to enable use of Altivec instructions])
201 fi
202
203 AC_ARG_ENABLE(thorough-tests,
204 AC_HELP_STRING([--disable-thorough-tests], [Disable thorough (long) testing, do only basic tests]),
205 [case "${enableval}" in
206         yes) thorough_tests=true ;;
207         no)  thorough_tests=false ;;
208         *) AC_MSG_ERROR(bad value ${enableval} for --enable-thorough-tests) ;;
209 esac],[thorough_tests=true])
210 AC_ARG_ENABLE(exhaustive-tests,
211 AC_HELP_STRING([--enable-exhaustive-tests], [Enable exhaustive testing (VERY long)]),
212 [case "${enableval}" in
213         yes) exhaustive_tests=true ;;
214         no)  exhaustive_tests=false ;;
215         *) AC_MSG_ERROR(bad value ${enableval} for --enable-exhaustive-tests) ;;
216 esac],[exhaustive_tests=false])
217 if test "x$thorough_tests" = xfalse ; then
218 FLAC__TEST_LEVEL=0
219 elif test "x$exhaustive_tests" = xfalse ; then
220 FLAC__TEST_LEVEL=1
221 else
222 FLAC__TEST_LEVEL=2
223 fi
224 AC_SUBST(FLAC__TEST_LEVEL)
225
226 AC_ARG_ENABLE(gcc-werror,
227         AC_HELP_STRING([--enable-gcc-werror], [enable -Werror in all Makefiles]))
228
229 AC_ARG_ENABLE(valgrind-testing,
230 AC_HELP_STRING([--enable-valgrind-testing], [Run all tests inside Valgrind]),
231 [case "${enableval}" in
232         yes) FLAC__TEST_WITH_VALGRIND=yes ;;
233         no)  FLAC__TEST_WITH_VALGRIND=no ;;
234         *) AC_MSG_ERROR(bad value ${enableval} for --enable-valgrind-testing) ;;
235 esac],[FLAC__TEST_WITH_VALGRIND=no])
236 AC_SUBST(FLAC__TEST_WITH_VALGRIND)
237
238 AC_ARG_ENABLE(doxygen-docs,
239 AC_HELP_STRING([--disable-doxygen-docs], [Disable API documentation building via Doxygen]),
240 [case "${enableval}" in
241         yes) enable_doxygen_docs=true ;;
242         no)  enable_doxygen_docs=false ;;
243         *) AC_MSG_ERROR(bad value ${enableval} for --enable-doxygen-docs) ;;
244 esac],[enable_doxygen_docs=true])
245 if test "x$enable_doxygen_docs" != xfalse ; then
246         AC_CHECK_PROGS(DOXYGEN, doxygen)
247 fi
248 AM_CONDITIONAL(FLaC__HAS_DOXYGEN, test -n "$DOXYGEN")
249
250 AC_ARG_ENABLE(local-xmms-plugin,
251 AC_HELP_STRING([--enable-local-xmms-plugin], [Install XMMS plugin to ~/.xmms/Plugins instead of system location]),
252 [case "${enableval}" in
253         yes) install_xmms_plugin_locally=true ;;
254         no)  install_xmms_plugin_locally=false ;;
255         *) AC_MSG_ERROR(bad value ${enableval} for --enable-local-xmms-plugin) ;;
256 esac],[install_xmms_plugin_locally=false])
257 AM_CONDITIONAL(FLaC__INSTALL_XMMS_PLUGIN_LOCALLY, test "x$install_xmms_plugin_locally" = xtrue)
258
259 AC_ARG_ENABLE(xmms-plugin,
260 AC_HELP_STRING([--disable-xmms-plugin], [Do not build XMMS plugin]),
261 [case "${enableval}" in
262         yes) enable_xmms_plugin=true ;;
263         no)  enable_xmms_plugin=false ;;
264         *) AC_MSG_ERROR(bad value ${enableval} for --enable-xmms-plugin) ;;
265 esac],[enable_xmms_plugin=true])
266 if test "x$enable_xmms_plugin" != xfalse ; then
267         AM_PATH_XMMS(0.9.5.1, , AC_MSG_WARN([*** XMMS >= 0.9.5.1 not installed - XMMS support will not be built]))
268 fi
269 AM_CONDITIONAL(FLaC__HAS_XMMS, test -n "$XMMS_INPUT_PLUGIN_DIR")
270
271 dnl build FLAC++ or not
272 AC_ARG_ENABLE([cpplibs],
273 AC_HELP_STRING([--disable-cpplibs], [Do not build libFLAC++]),
274 [case "${enableval}" in
275         yes) disable_cpplibs=false ;;
276         no)  disable_cpplibs=true ;;
277         *)   AC_MSG_ERROR(bad value ${enableval} for --enable-cpplibs) ;;
278 esac], [disable_cpplibs=false])
279 AM_CONDITIONAL(FLaC__WITH_CPPLIBS, [test "x$disable_cpplibs" != xtrue])
280
281 dnl check for ogg library
282 AC_ARG_ENABLE([ogg],
283         AC_HELP_STRING([--disable-ogg], [Disable ogg support (default: test for libogg)]),
284         [ want_ogg=$enableval ], [ want_ogg=yes ] )
285
286 if test "x$want_ogg" != "xno"; then
287         XIPH_PATH_OGG(have_ogg=yes, AC_MSG_WARN([*** Ogg development enviroment not installed - Ogg support will not be built]))
288 fi
289
290 AM_CONDITIONAL(FLaC__HAS_OGG, [test "x$have_ogg" = xyes])
291 if test "x$have_ogg" = xyes ; then
292 AC_DEFINE(FLAC__HAS_OGG)
293 AH_TEMPLATE(FLAC__HAS_OGG, [define if you have the ogg library])
294 fi
295
296 dnl check for i18n(internationalization); these are from libiconv/gettext
297 AM_ICONV
298 AM_LANGINFO_CODESET
299
300 AC_CHECK_PROGS(DOCBOOK_TO_MAN, docbook-to-man docbook2man)
301 AM_CONDITIONAL(FLaC__HAS_DOCBOOK_TO_MAN, test -n "$DOCBOOK_TO_MAN")
302 if test -n "$DOCBOOK_TO_MAN" ; then
303 AC_DEFINE(FLAC__HAS_DOCBOOK_TO_MAN)
304 AH_TEMPLATE(FLAC__HAS_DOCBOOK_TO_MAN, [define if you have docbook-to-man or docbook2man])
305 fi
306
307 # only matters for x86
308 AC_CHECK_PROGS(NASM, nasm)
309 AM_CONDITIONAL(FLaC__HAS_NASM, test -n "$NASM")
310 if test -n "$NASM" ; then
311 AC_DEFINE(FLAC__HAS_NASM)
312 AH_TEMPLATE(FLAC__HAS_NASM, [define if you are compiling for x86 and have the NASM assembler])
313 fi
314
315 # only matters for PowerPC
316 AC_CHECK_PROGS(AS, as, as)
317 AC_CHECK_PROGS(GAS, gas, gas)
318
319 # try -v (apple as) and --version (gas) at the same time
320 test "$AS" = "as" && as --version -v < /dev/null 2>&1 | grep Apple >/dev/null || AS=gas
321
322 AM_CONDITIONAL(FLaC__HAS_AS, test "$AS" = "as")
323 AM_CONDITIONAL(FLaC__HAS_GAS, test "$AS" = "gas")
324 if test "$AS" = "as" ; then
325 AC_DEFINE(FLAC__HAS_AS)
326 AH_TEMPLATE(FLAC__HAS_AS, [define if you are compiling for PowerPC and have the 'as' assembler])
327 fi
328 if test "$AS" = "gas" ; then
329 # funniest. macro. ever.
330 AC_DEFINE(FLAC__HAS_GAS)
331 AH_TEMPLATE(FLAC__HAS_GAS, [define if you are compiling for PowerPC and have the 'gas' assembler])
332 fi
333
334 CPPFLAGS='-I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include'" $CPPFLAGS"
335 if test "x$debug" = xtrue; then
336         CPPFLAGS="-DDEBUG -DFLaC__INLINE= $CPPFLAGS"
337         CFLAGS="-g $CFLAGS"
338 else
339         CPPFLAGS="-DNDEBUG $CPPFLAGS"
340         # $ac_cv_c_inline from AC_C_INLINE
341         if test "x$ac_cv_c_inline" != xno ; then
342                 CPPFLAGS="-DFLaC__INLINE=$ac_cv_c_inline $CPPFLAGS"
343         fi
344         if test "x$GCC" = xyes; then
345                 CFLAGS="-O3 -funroll-loops -finline-functions -Wall -W -Winline $CFLAGS"
346         fi
347 fi
348
349
350 if test x$ac_cv_c_compiler_gnu = xyes ; then
351         if test x$enable_gcc_werror = "xyes" ; then
352                 CFLAGS="-Werror $CFLAGS"
353                 CXXFLAGS="-Werror $CXXFLAGS"
354                 fi
355         fi
356
357
358 #@@@
359 AM_CONDITIONAL(FLaC__HAS_AS__TEMPORARILY_DISABLED, test "yes" = "no")
360 AM_CONDITIONAL(FLaC__HAS_GAS__TEMPORARILY_DISABLED, test "yes" = "no")
361
362 AC_CONFIG_FILES([ \
363         Makefile \
364         src/Makefile \
365         src/libFLAC/Makefile \
366         src/libFLAC/flac.pc \
367         src/libFLAC/ia32/Makefile \
368         src/libFLAC/ppc/Makefile \
369         src/libFLAC/ppc/as/Makefile \
370         src/libFLAC/ppc/gas/Makefile \
371         src/libFLAC/include/Makefile \
372         src/libFLAC/include/private/Makefile \
373         src/libFLAC/include/protected/Makefile \
374         src/libFLAC++/Makefile \
375         src/libFLAC++/flac++.pc \
376         src/flac/Makefile \
377         src/metaflac/Makefile \
378         src/monkeys_audio_utilities/Makefile \
379         src/monkeys_audio_utilities/flac_mac/Makefile \
380         src/monkeys_audio_utilities/flac_ren/Makefile \
381         src/plugin_common/Makefile \
382         src/plugin_winamp2/Makefile \
383         src/plugin_winamp2/include/Makefile \
384         src/plugin_winamp2/include/winamp2/Makefile \
385         src/plugin_xmms/Makefile \
386         src/share/Makefile \
387         src/share/getopt/Makefile \
388         src/share/grabbag/Makefile \
389         src/share/replaygain_analysis/Makefile \
390         src/share/replaygain_synthesis/Makefile \
391         src/share/replaygain_synthesis/include/Makefile \
392         src/share/replaygain_synthesis/include/private/Makefile \
393         src/share/utf8/Makefile \
394         src/test_grabbag/Makefile \
395         src/test_grabbag/cuesheet/Makefile \
396         src/test_grabbag/picture/Makefile \
397         src/test_libs_common/Makefile \
398         src/test_libFLAC/Makefile \
399         src/test_libFLAC++/Makefile \
400         src/test_seeking/Makefile \
401         src/test_streams/Makefile \
402         src/utils/Makefile \
403         src/utils/flacdiff/Makefile \
404         src/utils/flactimer/Makefile \
405         examples/Makefile \
406         examples/c/Makefile \
407         examples/c/decode/Makefile \
408         examples/c/decode/file/Makefile \
409         examples/c/encode/Makefile \
410         examples/c/encode/file/Makefile \
411         examples/cpp/Makefile \
412         examples/cpp/decode/Makefile \
413         examples/cpp/decode/file/Makefile \
414         examples/cpp/encode/Makefile \
415         examples/cpp/encode/file/Makefile \
416         include/Makefile \
417         include/FLAC/Makefile \
418         include/FLAC++/Makefile \
419         include/share/Makefile \
420         include/share/grabbag/Makefile \
421         include/test_libs_common/Makefile \
422         doc/Makefile \
423         doc/html/Makefile \
424         doc/html/images/Makefile \
425         doc/html/images/hw/Makefile \
426         doc/html/ru/Makefile \
427         m4/Makefile \
428         man/Makefile \
429         test/Makefile \
430         test/cuesheets/Makefile \
431         test/flac-to-flac-metadata-test-files/Makefile \
432         test/metaflac-test-files/Makefile \
433         test/pictures/Makefile \
434         build/Makefile \
435         obj/Makefile \
436         obj/debug/Makefile \
437         obj/debug/bin/Makefile \
438         obj/debug/lib/Makefile \
439         obj/release/Makefile \
440         obj/release/bin/Makefile \
441         obj/release/lib/Makefile \
442 ])
443 AC_OUTPUT