0ca65bbfbaf1f6334daaf117020746714856da1f
[platform/upstream/libvorbis.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script
2
3 dnl ------------------------------------------------
4 dnl Initialization and Versioning
5 dnl ------------------------------------------------
6
7
8 AC_INIT([libvorbis],[1.2.3],[vorbis-dev@xiph.org])
9
10 AC_CONFIG_SRCDIR([lib/mdct.c])
11
12 AC_CANONICAL_TARGET([])
13
14 AM_INIT_AUTOMAKE($PACKAGE_NAME,$PACKAGE_VERSION)
15 AM_MAINTAINER_MODE
16 AM_CONFIG_HEADER([config.h])
17
18 dnl Add parameters for aclocal
19 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
20
21 dnl Library versioning
22 dnl - library source changed -> increment REVISION
23 dnl - interfaces added/removed/changed -> increment CURRENT, REVISION = 0
24 dnl - interfaces added -> increment AGE
25 dnl - interfaces removed -> AGE = 0
26
27 V_LIB_CURRENT=4
28 V_LIB_REVISION=3
29 V_LIB_AGE=4
30
31 VF_LIB_CURRENT=6
32 VF_LIB_REVISION=2
33 VF_LIB_AGE=3
34
35 VE_LIB_CURRENT=2
36 VE_LIB_REVISION=6
37 VE_LIB_AGE=0
38
39 AC_SUBST(V_LIB_CURRENT)
40 AC_SUBST(V_LIB_REVISION)
41 AC_SUBST(V_LIB_AGE)
42 AC_SUBST(VF_LIB_CURRENT)
43 AC_SUBST(VF_LIB_REVISION)
44 AC_SUBST(VF_LIB_AGE)
45 AC_SUBST(VE_LIB_CURRENT)
46 AC_SUBST(VE_LIB_REVISION)
47 AC_SUBST(VE_LIB_AGE)
48
49 dnl --------------------------------------------------  
50 dnl Check for programs
51 dnl --------------------------------------------------  
52
53 dnl save $CFLAGS since AC_PROG_CC likes to insert "-g -O2"
54 dnl if $CFLAGS is blank
55 cflags_save="$CFLAGS"
56 AC_PROG_CC
57 AC_PROG_CPP
58 CFLAGS="$cflags_save"
59
60 AC_C_INLINE
61
62 AC_LIBTOOL_WIN32_DLL
63 AC_PROG_LIBTOOL
64 AM_PROG_CC_C_O
65
66 dnl Check for doxygen
67 if test "x$enable_docs" = xyes; then
68   AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false)
69   AM_CONDITIONAL(HAVE_DOXYGEN,$HAVE_DOXYGEN)
70   if test $HAVE_DOXYGEN = "false"; then
71     AC_MSG_WARN([*** doxygen not found, API documentation will not be built])
72   fi
73 fi
74
75 dnl latex tools for the specification document
76 AC_ARG_ENABLE(docs,
77         AC_HELP_STRING([--enable-docs], [build the documentation]))
78
79 if test "x$enable_docs" = xyes; then
80   AC_CHECK_PROGS([PDFLATEX], pdflatex, [/bin/false])
81   AC_CHECK_PROGS([HTLATEX], htlatex, [/bin/false])
82   if test "x$PDFLATEX" = x/bin/false || test "x$HTLATEX" = x/bin/false; then
83     enable_docs=no
84     AC_MSG_WARN([Documentation will not be built!])
85   fi
86 fi
87
88 AM_CONDITIONAL(BUILD_DOCS, [test "x$enable_docs" = xyes])
89
90 dnl --------------------------------------------------
91 dnl Set build flags based on environment
92 dnl --------------------------------------------------
93
94 dnl Set some target options
95
96 cflags_save="$CFLAGS"
97 if test -z "$GCC"; then
98         case $host in 
99         *-*-irix*)
100                 dnl If we're on IRIX, we wanna use cc even if gcc 
101                 dnl is there (unless the user has overriden us)...
102                 if test -z "$CC"; then
103                         CC=cc
104                 fi
105                 DEBUG="-g -signed" 
106                 CFLAGS="-O2 -w -signed"
107                 PROFILE="-p -g3 -O2 -signed" ;;
108         sparc-sun-solaris*)
109                 DEBUG="-v -g"
110                 CFLAGS="-xO4 -fast -w -fsimple -native -xcg92"
111                 PROFILE="-v -xpg -g -xO4 -fast -native -fsimple -xcg92 -Dsuncc" ;;
112         *)
113                 DEBUG="-g"
114                 CFLAGS="-O"
115                 PROFILE="-g -p" ;;
116         esac
117 else
118
119         AC_MSG_CHECKING([GCC version])
120         GCC_VERSION=`$CC -dumpversion`
121         AC_MSG_RESULT([$GCC_VERSION])
122         case $host in 
123         *86-*-linux*)
124                 DEBUG="-g -Wall -Wextra -D_REENTRANT -D__NO_MATH_INLINES -fsigned-char"
125                 CFLAGS="-O20 -ffast-math -mno-ieee-fp -D_REENTRANT -fsigned-char"
126 #               PROFILE="-Wall -Wextra -pg -g -O20 -ffast-math -D_REENTRANT -fsigned-char -fno-inline -static"
127                 PROFILE="-Wall -Wextra -pg -g -O20 -ffast-math -mno-ieee-fp -D_REENTRANT -fsigned-char -fno-inline"
128
129                 # glibc < 2.1.3 has a serious FP bug in the math inline header
130                 # that will cripple Vorbis.  Look to see if the magic FP stack
131                 # clobber is missing in the mathinline header, thus indicating
132                 # the buggy version
133
134                 AC_EGREP_CPP(log10.*fldlg2.*fxch,[
135                                 #define __LIBC_INTERNAL_MATH_INLINES 1
136                                 #define __OPTIMIZE__
137                                 #include <math.h>
138                                 ],bad=maybe,bad=no)
139                 if test ${bad} = "maybe" ;then
140                       AC_EGREP_CPP(log10.*fldlg2.*fxch.*st\([[0123456789]]*\),
141                                         [
142                                         #define __LIBC_INTERNAL_MATH_INLINES 1
143                                         #define __OPTIMIZE__
144                                         #include <math.h>
145                                         ],bad=no,bad=yes)
146                 fi
147                 if test ${bad} = "yes" ;then
148  AC_MSG_WARN([                                                        ])
149  AC_MSG_WARN([********************************************************])
150  AC_MSG_WARN([* The glibc headers on this machine have a serious bug *])
151  AC_MSG_WARN([* in /usr/include/bits/mathinline.h  This bug affects  *])
152  AC_MSG_WARN([* all floating point code, not just Ogg, built on this *])
153  AC_MSG_WARN([* machine.  Upgrading to glibc 2.1.3 is strongly urged *])
154  AC_MSG_WARN([* to correct the problem.  Note that upgrading glibc   *])
155  AC_MSG_WARN([* will not fix any previously built programs; this is  *])
156  AC_MSG_WARN([* a compile-time time bug.                             *])
157  AC_MSG_WARN([* To work around the problem for this build of Ogg,    *])
158  AC_MSG_WARN([* autoconf is disabling all math inlining.  This will  *])
159  AC_MSG_WARN([* hurt Ogg performace but is necessary for an Ogg that *])
160  AC_MSG_WARN([* will actually work.  Once glibc is upgraded, rerun   *])
161  AC_MSG_WARN([* configure and make to build with inlining.           *])
162  AC_MSG_WARN([********************************************************])
163  AC_MSG_WARN([                                                        ])
164
165                 CFLAGS=${OPT}" -D__NO_MATH_INLINES"
166                 PROFILE=${PROFILE}" -D__NO_MATH_INLINES"
167                 fi;;
168         powerpc-*-linux*)
169                 DEBUG="-g -Wall -Wextra -D_REENTRANT -D__NO_MATH_INLINES"
170                 CFLAGS="-O3 -Wall -Wextra -ffast-math -mfused-madd -mcpu=750 -D_REENTRANT"
171                 PROFILE="-pg -g -O3 -ffast-math -mfused-madd -mcpu=750 -D_REENTRANT";;
172         *-*-linux*)
173                 DEBUG="-g -Wall -Wextra -D_REENTRANT -D__NO_MATH_INLINES -fsigned-char"
174                 CFLAGS="-O20 -Wall -Wextra -ffast-math -D_REENTRANT -fsigned-char"
175                 PROFILE="-pg -g -O20 -ffast-math -D_REENTRANT -fsigned-char";;
176         sparc-sun-*)
177                 sparc_cpu=""
178                 AC_MSG_CHECKING([if gcc supports -mv8])
179                 old_cflags="$CFLAGS"
180                 CFLAGS="$CFLAGS -mv8"
181                 AC_TRY_COMPILE(, [return 0;], [
182                         AC_MSG_RESULT([yes])
183                         sparc_cpu="-mv8"
184                 ])
185                 CFLAGS="$old_cflags"
186                 DEBUG="-g -Wall -Wextra -D__NO_MATH_INLINES -fsigned-char $sparc_cpu"
187                 CFLAGS="-O20 -Wall -Wextra -ffast-math -D__NO_MATH_INLINES -fsigned-char $sparc_cpu"
188                 PROFILE="-pg -g -O20 -D__NO_MATH_INLINES -fsigned-char $sparc_cpu" ;;
189         *-*-darwin*)
190                 DEBUG="-DDARWIN -fno-common -force_cpusubtype_ALL -Wall -g -O0 -fsigned-char"
191                 CFLAGS="-DDARWIN -fno-common -force_cpusubtype_ALL -Wall -g -O4 -ffast-math -fsigned-char"
192                 PROFILE="-DDARWIN -fno-common -force_cpusubtype_ALL -Wall -g -pg -O4 -ffast-math -fsigned-char";;
193         *-*-os2*)
194                 # Use -W instead of -Wextra because gcc on OS/2 is an old version.
195                 DEBUG="-g -Wall -W -D_REENTRANT -D__NO_MATH_INLINES -fsigned-char"
196                 CFLAGS="-O20 -Wall -W -ffast-math -D_REENTRANT -fsigned-char"
197                 PROFILE="-pg -g -O20 -ffast-math -D_REENTRANT -fsigned-char";;
198         *)
199                 DEBUG="-g -Wall -Wextra -D__NO_MATH_INLINES -fsigned-char"
200                 CFLAGS="-O20 -Wall -Wextra -D__NO_MATH_INLINES -fsigned-char"
201                 PROFILE="-O20 -g -pg -D__NO_MATH_INLINES -fsigned-char" ;;
202         esac
203
204         AC_ADD_CFLAGS([-Wdeclaration-after-statement])
205 fi
206 CFLAGS="$CFLAGS $cflags_save"
207
208 dnl --------------------------------------------------
209 dnl Check for headers
210 dnl --------------------------------------------------
211
212 AC_CHECK_HEADER(memory.h,CFLAGS="$CFLAGS -DUSE_MEMORY_H",:)
213
214 dnl --------------------------------------------------
215 dnl Check for typedefs, structures, etc
216 dnl --------------------------------------------------
217
218 dnl none
219
220 dnl --------------------------------------------------
221 dnl Check for libraries
222 dnl --------------------------------------------------
223
224 AC_CHECK_LIB(m, cos, VORBIS_LIBS="-lm", VORBIS_LIBS="")
225 AC_CHECK_LIB(pthread, pthread_create, pthread_lib="-lpthread", :)
226
227 PKG_PROG_PKG_CONFIG
228
229 HAVE_OGG=no
230 if test "x$PKG_CONFIG" != "x"
231 then
232   PKG_CHECK_MODULES(OGG, ogg >= 1.0, HAVE_OGG=yes, HAVE_OGG=no)
233 fi
234 if test "x$HAVE_OGG" = "xno"
235 then
236   dnl fall back to the old school test
237   XIPH_PATH_OGG(, AC_MSG_ERROR(must have Ogg installed!))
238   libs_save=$LIBS
239   LIBS="$OGG_LIBS $VORBIS_LIBS"
240   AC_CHECK_FUNC(oggpack_writealign, , AC_MSG_ERROR(Ogg >= 1.0 required !))
241   LIBS=$libs_save
242 fi
243
244 dnl --------------------------------------------------
245 dnl Check for library functions
246 dnl --------------------------------------------------
247
248 AC_FUNC_ALLOCA
249 AC_FUNC_MEMCMP
250
251 dnl --------------------------------------------------
252 dnl Do substitutions
253 dnl --------------------------------------------------
254
255 AC_SUBST(VORBIS_LIBS)
256 AC_SUBST(DEBUG)
257 AC_SUBST(PROFILE)
258 AC_SUBST(pthread_lib)
259
260 dnl The following line causes the libtool distributed with the source
261 dnl to be replaced if the build system has a more recent version.
262 AC_SUBST(LIBTOOL_DEPS)
263
264 AC_OUTPUT([
265 Makefile
266 m4/Makefile
267 lib/Makefile
268 lib/modes/Makefile
269 lib/books/Makefile
270 lib/books/coupled/Makefile
271 lib/books/uncoupled/Makefile
272 lib/books/floor/Makefile
273 doc/Makefile doc/vorbisfile/Makefile doc/vorbisenc/Makefile
274 doc/Doxyfile
275 include/Makefile include/vorbis/Makefile
276 examples/Makefile
277 test/Makefile
278 vq/Makefile
279 libvorbis.spec
280 vorbis.pc
281 vorbisenc.pc
282 vorbisfile.pc
283 vorbis-uninstalled.pc
284 vorbisenc-uninstalled.pc
285 vorbisfile-uninstalled.pc
286 ])