add host checks to try and divine whether we're on a darwin or linux system
[platform/upstream/flac.git] / configure.in
1 #  FLAC - Free Lossless Audio Codec
2 #  Copyright (C) 2001,2002,2003,2004  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.1.1)
23
24 # Don't automagically regenerate autoconf/automake generated files unless
25 # explicitly requested.  Eases autobuilding -mdz
26 AM_MAINTAINER_MODE
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 AM_PROG_AS
36 AC_PROG_CXX
37 AC_PROG_MAKE_SET
38
39 dnl check for getopt in standard library
40 dnl AC_CHECK_FUNCS(getopt_long , , [LIBOBJS="$LIBOBJS getopt.o getopt1.o"] )
41 AC_CHECK_FUNCS(getopt_long, [], [])
42
43 AC_CANONICAL_HOST
44 case "$host_cpu" in
45         i*86)   cpu_ia32=true ; AC_DEFINE(FLAC__CPU_IA32) ;;
46         powerpc)        cpu_ppc=true ; AC_DEFINE(FLAC__CPU_PPC) ;;
47         sparc)  cpu_sparc=true ; AC_DEFINE(FLAC__CPU_SPARC) ;;
48 esac
49 AM_CONDITIONAL(FLaC__CPU_IA32, test x$cpu_ia32 = xtrue)
50 AM_CONDITIONAL(FLaC__CPU_PPC, test x$cpu_ppc = xtrue)
51 AM_CONDITIONAL(FLaC__CPU_SPARC, test x$cpu_sparc = xtrue)
52 case "$host" in
53         *-pc-linux-gnu) sys_linux=true ; AC_DEFINE(FLAC__SYS_LINUX) ;;
54         *-*-darwin*) sys_darwin=true ; AC_DEFINE(FLAC__SYS_DARWIN) ;;
55         i386-*-openbsd3.[[0-3]]) OBJ_FORMAT=aoutb ;;
56         *) OBJ_FORMAT=elf ;;
57 esac
58 AM_CONDITIONAL(FLaC__SYS_DARWIN, test x$sys_darwin = xtrue)
59 AM_CONDITIONAL(FLaC__SYS_LINUX, test x$sys_linux = xtrue)
60 AC_SUBST(OBJ_FORMAT)
61
62 if test x$cpu_ia32 = xtrue ; then
63 AC_DEFINE(FLAC__ALIGN_MALLOC_DATA)
64 fi
65
66 AC_ARG_ENABLE(asm-optimizations, [  --disable-asm-optimizations    Don't use any assembly optimization routines], asm_opt=no, asm_opt=yes)
67 AM_CONDITIONAL(FLaC__NO_ASM, test x$asm_opt = xno)
68 if test x$asm_opt = xno ; then
69 AC_DEFINE(FLAC__NO_ASM)
70 fi
71
72 AC_ARG_ENABLE(debug,
73 [  --enable-debug                 Turn on debugging],
74 [case "${enableval}" in
75         yes) debug=true ;;
76         no)  debug=false ;;
77         *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
78 esac],[debug=false])
79 AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
80
81 AC_ARG_ENABLE(sse,
82 [  --enable-sse                   Enable SSE support by asserting that the OS supports SSE instructions],
83 [case "${enableval}" in
84         yes) sse_os=true ;;
85         no)  sse_os=false ;;
86         *) AC_MSG_ERROR(bad value ${enableval} for --enable-sse) ;;
87 esac],[sse_os=false])
88 AM_CONDITIONAL(FLaC__SSE_OS, test x$sse_os = xtrue)
89 if test x$sse_os = xtrue ; then
90 AC_DEFINE(FLAC__SSE_OS)
91 fi
92
93 AC_ARG_ENABLE(3dnow,
94 [  --disable-3dnow                Disable 3DNOW! optimizations],
95 [case "${enableval}" in
96         yes) use_3dnow=true ;;
97         no)  use_3dnow=false ;;
98         *) AC_MSG_ERROR(bad value ${enableval} for --enable-3dnow) ;;
99 esac],[use_3dnow=true])
100 AM_CONDITIONAL(FLaC__USE_3DNOW, test x$use_3dnow = xtrue)
101 if test x$use_3dnow = xtrue ; then
102 AC_DEFINE(FLAC__USE_3DNOW)
103 fi
104
105 AC_ARG_ENABLE(altivec,
106 [  --disable-altivec              Disable Altivec optimizations],
107 [case "${enableval}" in
108         yes) use_altivec=true ;;
109         no)  use_altivec=false ;;
110         *) AC_MSG_ERROR(bad value ${enableval} for --enable-altivec) ;;
111 esac],[use_altivec=true])
112 AM_CONDITIONAL(FLaC__USE_ALTIVEC, test x$use_altivec = xtrue)
113 if test x$use_altivec = xtrue ; then
114 AC_DEFINE(FLAC__USE_ALTIVEC)
115 fi
116
117 AC_ARG_ENABLE(local-xmms-plugin,
118 [  --enable-local-xmms-plugin     Install XMMS plugin to ~/.xmms/Plugins instead of system location],
119 [case "${enableval}" in
120         yes) install_xmms_plugin_locally=true ;;
121         no)  install_xmms_plugin_locally=false ;;
122         *) AC_MSG_ERROR(bad value ${enableval} for --enable-local-xmms-plugin) ;;
123 esac],[install_xmms_plugin_locally=false])
124 AM_CONDITIONAL(FLaC__INSTALL_XMMS_PLUGIN_LOCALLY, test x$install_xmms_plugin_locally = xtrue)
125
126 AC_ARG_ENABLE(exhaustive-tests,
127 [  --enable-exhaustive-tests      Enable exhaustive testing],
128 [case "${enableval}" in
129         yes) exhaustive_tests=true ;;
130         no)  exhaustive_tests=false ;;
131         *) AC_MSG_ERROR(bad value ${enableval} for --enable-exhaustive-tests) ;;
132 esac],[exhaustive_tests=false])
133 AM_CONDITIONAL(FLaC__EXHAUSTIVE_TESTS, test x$exhaustive_tests = xtrue)
134 if test x$exhaustive_tests = xtrue ; then
135 AC_DEFINE(FLAC__EXHAUSTIVE_TESTS)
136 fi
137
138 AC_ARG_ENABLE(valgrind-testing,
139 [  --enable-valgrind-testing      Run all tests inside Valgrind],
140 [case "${enableval}" in
141         yes) valgrind_testing=true ;;
142         no)  valgrind_testing=false ;;
143         *) AC_MSG_ERROR(bad value ${enableval} for --enable-valgrind-testing) ;;
144 esac],[valgrind_testing=false])
145 AM_CONDITIONAL(FLaC__VALGRIND_TESTING, test x$valgrind_testing = xtrue)
146 if test x$valgrind_testing = xtrue ; then
147 AC_DEFINE(FLAC__VALGRIND_TESTING)
148 fi
149
150 dnl check for ogg library
151 XIPH_PATH_OGG(have_ogg=yes, AC_MSG_WARN([*** Ogg development enviroment not installed - Ogg support will not be built]))
152 AM_CONDITIONAL(FLaC__HAS_OGG, [test x$have_ogg = xyes])
153 if test x$have_ogg = xyes ; then
154 AC_DEFINE(FLAC__HAS_OGG)
155 fi
156
157 AM_PATH_XMMS(0.9.5.1, , AC_MSG_WARN([*** XMMS >= 0.9.5.1 not installed - xmms support will not be built]))
158 AM_CONDITIONAL(FLaC__HAS_XMMS, test x$XMMS_INPUT_PLUGIN_DIR != x)
159
160 dnl check for i18n(internationalization); these are from libiconv/gettext
161 AM_ICONV
162 AM_LANGINFO_CODESET
163
164 AC_CHECK_PROGS(DOXYGEN, doxygen)
165 AM_CONDITIONAL(FLaC__HAS_DOXYGEN, test -n "$DOXYGEN")
166 if test -n "$DOXYGEN" ; then
167 AC_DEFINE(FLAC__HAS_DOXYGEN)
168 fi
169
170 AC_CHECK_PROGS(DOCBOOK_TO_MAN, docbook-to-man docbook2man)
171 AM_CONDITIONAL(FLaC__HAS_DOCBOOK_TO_MAN, test -n "$DOCBOOK_TO_MAN")
172 if test -n "$DOCBOOK_TO_MAN" ; then
173 AC_DEFINE(FLAC__HAS_DOCBOOK_TO_MAN)
174 fi
175
176 # only matters for x86
177 AC_CHECK_PROGS(NASM, nasm)
178 AM_CONDITIONAL(FLaC__HAS_NASM, test -n "$NASM")
179 if test -n "$NASM" ; then
180 AC_DEFINE(FLAC__HAS_NASM)
181 fi
182
183 # only matters for PowerPC
184 AC_CHECK_PROGS(AS, as)
185 AC_CHECK_PROGS(GAS, gas)
186 AM_CONDITIONAL(FLaC__HAS_AS, test -n "$AS")
187 AM_CONDITIONAL(FLaC__HAS_GAS, test -n "$GAS")
188 if test -n "$AS" ; then
189 AC_DEFINE(FLAC__HAS_AS)
190 fi
191 if test -n "$GAS" ; then
192 # funniest. macro. ever.
193 AC_DEFINE(FLAC__HAS_GAS)
194 fi
195
196 OUR_CFLAGS_HEAD='-I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include'
197 if test x$debug = xtrue; then
198         OUR_CFLAGS_HEAD="$OUR_CFLAGS_HEAD -g -O0 -DDEBUG"
199 else
200         OUR_CFLAGS_HEAD="$OUR_CFLAGS_HEAD -O2 -DNDEBUG"
201         if test x$GCC = xyes; then
202                 OUR_CFLAGS_HEAD="$OUR_CFLAGS_HEAD -O3 -fomit-frame-pointer -funroll-loops -finline-functions -Wall -W -Winline -DFLaC__INLINE=__inline__"
203         fi
204 fi
205 CFLAGS="$OUR_CFLAGS_HEAD $CFLAGS"
206 CXXFLAGS="$OUR_CFLAGS_HEAD $CXXFLAGS"
207
208 AM_CONFIG_HEADER(config.h)
209 AH_TEMPLATE(FLAC__ALIGN_MALLOC_DATA,  [define to align allocated memory on 32-byte boundaries])
210 AH_TEMPLATE(FLAC__CPU_IA32,  [define if building for ia32/i386])
211 AH_TEMPLATE(FLAC__CPU_PPC,  [define if building for PowerPC])
212 AH_TEMPLATE(FLAC__CPU_SPARC,  [define if building for SPARC])
213 AH_TEMPLATE(FLAC__SYS_DARWIN,  [define if building for Darwin / MacOS X])
214 AH_TEMPLATE(FLAC__SYS_LINUX,  [define if building for Linux])
215 AH_TEMPLATE(FLAC__EXHAUSTIVE_TESTS,  [define to run even more tests])
216 AH_TEMPLATE(FLAC__VALGRIND_TESTING,  [define to enable use of Valgrind in testers])
217 AH_TEMPLATE(FLAC__HAS_DOXYGEN,  [define if you have Doxygen])
218 AH_TEMPLATE(FLAC__HAS_DOCBOOK_TO_MAN,  [define if you have docbook-to-man or docbook2man])
219 AH_TEMPLATE(FLAC__HAS_NASM,  [define if you are compiling for x86 and have the NASM assembler])
220 AH_TEMPLATE(FLAC__HAS_AS,  [define if you are compiling for PowerPC and have the 'as' assembler])
221 AH_TEMPLATE(FLAC__HAS_GAS,  [define if you are compiling for PowerPC and have the 'gas' assembler])
222 AH_TEMPLATE(FLAC__HAS_OGG,  [define if you have the ogg library])
223 AH_TEMPLATE(FLAC__NO_ASM,  [define to disable use of assembly code])
224 AH_TEMPLATE(FLAC__SSE_OS,  [define if your operating system supports SSE instructions])
225 AH_TEMPLATE(FLAC__USE_3DNOW,  [define to enable use of 3Dnow! instructions])
226 AH_TEMPLATE(FLAC__USE_ALTIVEC,  [define to enable use of Altivec instructions])
227
228 AC_OUTPUT( \
229         Makefile \
230         src/Makefile \
231         src/libFLAC/Makefile \
232         src/libFLAC/ia32/Makefile \
233         src/libFLAC/ppc/Makefile \
234         src/libFLAC/ppc/as/Makefile \
235         src/libFLAC/ppc/gas/Makefile \
236         src/libFLAC/include/Makefile \
237         src/libFLAC/include/private/Makefile \
238         src/libFLAC/include/protected/Makefile \
239         src/libFLAC++/Makefile \
240         src/libOggFLAC/Makefile \
241         src/libOggFLAC/include/Makefile \
242         src/libOggFLAC/include/private/Makefile \
243         src/libOggFLAC/include/protected/Makefile \
244         src/libOggFLAC++/Makefile \
245         src/flac/Makefile \
246         src/metaflac/Makefile \
247         src/monkeys_audio_utilities/Makefile \
248         src/monkeys_audio_utilities/flac_mac/Makefile \
249         src/monkeys_audio_utilities/flac_ren/Makefile \
250         src/plugin_common/Makefile \
251         src/plugin_winamp2/Makefile \
252         src/plugin_winamp2/include/Makefile \
253         src/plugin_winamp2/include/winamp2/Makefile \
254         src/plugin_xmms/Makefile \
255         src/share/Makefile \
256         src/share/getopt/Makefile \
257         src/share/grabbag/Makefile \
258         src/share/replaygain_analysis/Makefile \
259         src/share/replaygain_synthesis/Makefile \
260         src/share/replaygain_synthesis/include/Makefile \
261         src/share/replaygain_synthesis/include/private/Makefile \
262         src/share/utf8/Makefile \
263         src/test_grabbag/Makefile \
264         src/test_grabbag/cuesheet/Makefile \
265         src/test_libFLAC/Makefile \
266         src/test_libFLAC++/Makefile \
267         src/test_libOggFLAC/Makefile \
268         src/test_libOggFLAC++/Makefile \
269         src/test_seeking/Makefile \
270         src/test_streams/Makefile \
271         include/Makefile \
272         include/FLAC/Makefile \
273         include/FLAC++/Makefile \
274         include/OggFLAC/Makefile \
275         include/OggFLAC++/Makefile \
276         include/share/Makefile \
277         include/share/grabbag/Makefile \
278         doc/Makefile \
279         doc/html/Makefile \
280         doc/html/images/Makefile \
281         doc/html/ru/Makefile \
282         man/Makefile \
283         test/Makefile \
284         test/cuesheets/Makefile \
285         build/Makefile \
286         obj/Makefile \
287         obj/debug/Makefile \
288         obj/debug/bin/Makefile \
289         obj/debug/lib/Makefile \
290         obj/release/Makefile \
291         obj/release/bin/Makefile \
292         obj/release/lib/Makefile \
293         flac.pbproj/Makefile \
294 )