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