This check is broken (doesn't respect --with-ogg=/foo), we're better off
[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 AM_INIT_AUTOMAKE(libvorbis,1.0)
9
10 dnl Library versioning
11
12 V_LIB_CURRENT=2
13 V_LIB_REVISION=0
14 V_LIB_AGE=2
15 VF_LIB_CURRENT=3
16 VF_LIB_REVISION=0
17 VF_LIB_AGE=0
18 VE_LIB_CURRENT=2
19 VE_LIB_REVISION=0
20 VE_LIB_AGE=0
21 AC_SUBST(V_LIB_CURRENT)
22 AC_SUBST(V_LIB_REVISION)
23 AC_SUBST(V_LIB_AGE)
24 AC_SUBST(VF_LIB_CURRENT)
25 AC_SUBST(VF_LIB_REVISION)
26 AC_SUBST(VF_LIB_AGE)
27 AC_SUBST(VE_LIB_CURRENT)
28 AC_SUBST(VE_LIB_REVISION)
29 AC_SUBST(VE_LIB_AGE)
30
31 dnl --------------------------------------------------  
32 dnl Check for programs
33 dnl --------------------------------------------------  
34
35 dnl save $CFLAGS since AC_PROG_CC likes to insert "-g -O2"
36 dnl if $CFLAGS is blank
37 cflags_save="$CFLAGS"
38 AC_PROG_CC
39 AC_PROG_CPP
40 CFLAGS="$cflags_save"
41
42 AM_PROG_LIBTOOL
43
44 dnl --------------------------------------------------
45 dnl Set build flags based on environment
46 dnl --------------------------------------------------
47
48 AC_CANONICAL_HOST
49
50 dnl Set some target options
51
52 cflags_save="$CFLAGS"
53 ldflags_save="$LDFLAGS"
54 if test -z "$GCC"; then
55         case $host in 
56         *-*-irix*)
57                 dnl If we're on IRIX, we wanna use cc even if gcc 
58                 dnl is there (unless the user has overriden us)...
59                 if test -z "$CC"; then
60                         CC=cc
61                 fi
62                 DEBUG="-g -signed" 
63                 CFLAGS="-O2 -w -signed"
64                 PROFILE="-p -g3 -O2 -signed" ;;
65         sparc-sun-solaris*)
66                 DEBUG="-v -g"
67                 CFLAGS="-xO4 -fast -w -fsimple -native -xcg92"
68                 PROFILE="-v -xpg -g -xO4 -fast -native -fsimple -xcg92 -Dsuncc" ;;
69         *)
70                 DEBUG="-g"
71                 CFLAGS="-O"
72                 PROFILE="-g -p" ;;
73         esac
74 else
75
76         case $host in 
77         *86-*-linux*)
78                 DEBUG="-g -Wall -W -D_REENTRANT -D__NO_MATH_INLINES -fsigned-char"
79                 CFLAGS="-O20 -ffast-math -mno-ieee-fp -D_REENTRANT -fsigned-char"
80 #               PROFILE="-Wall -W -pg -g -O20 -ffast-math -D_REENTRANT -fsigned-char -fno-inline -static"
81                 PROFILE="-Wall -W -pg -g -O20 -ffast-math -mno-ieee-fp -D_REENTRANT -fsigned-char -fno-inline"
82
83                 # glibc < 2.1.3 has a serious FP bug in the math inline header
84                 # that will cripple Vorbis.  Look to see if the magic FP stack
85                 # clobber is missing in the mathinline header, thus indicating
86                 # the buggy version
87
88                 AC_EGREP_CPP(log10.*fldlg2.*fxch,[
89                                 #define __LIBC_INTERNAL_MATH_INLINES 1
90                                 #define __OPTIMIZE__
91                                 #include <math.h>
92                                 ],bad=maybe,bad=no)
93                 if test ${bad} = "maybe" ;then
94                       AC_EGREP_CPP(log10.*fldlg2.*fxch.*st\([[0123456789]]*\),
95                                         [
96                                         #define __LIBC_INTERNAL_MATH_INLINES 1
97                                         #define __OPTIMIZE__
98                                         #include <math.h>
99                                         ],bad=no,bad=yes)
100                 fi
101                 if test ${bad} = "yes" ;then
102  AC_MSG_WARN([                                                        ])
103  AC_MSG_WARN([********************************************************])
104  AC_MSG_WARN([* The glibc headers on this machine have a serious bug *])
105  AC_MSG_WARN([* in /usr/include/bits/mathinline.h  This bug affects  *])
106  AC_MSG_WARN([* all floating point code, not just Ogg, built on this *])
107  AC_MSG_WARN([* machine.  Upgrading to glibc 2.1.3 is strongly urged *])
108  AC_MSG_WARN([* to correct the problem.  Note that upgrading glibc   *])
109  AC_MSG_WARN([* will not fix any previously built programs; this is  *])
110  AC_MSG_WARN([* a compile-time time bug.                             *])
111  AC_MSG_WARN([* To work around the problem for this build of Ogg,    *])
112  AC_MSG_WARN([* autoconf is disabling all math inlining.  This will  *])
113  AC_MSG_WARN([* hurt Ogg performace but is necessary for an Ogg that *])
114  AC_MSG_WARN([* will actually work.  Once glibc is upgraded, rerun   *])
115  AC_MSG_WARN([* configure and make to build with inlining.           *])
116  AC_MSG_WARN([********************************************************])
117  AC_MSG_WARN([                                                        ])
118
119                 CFLAGS=${OPT}" -D__NO_MATH_INLINES"
120                 PROFILE=${PROFILE}" -D__NO_MATH_INLINES"
121                 fi;;
122         powerpc-*-linux*)
123                 DEBUG="-g -Wall -W -D_REENTRANT -D__NO_MATH_INLINES"
124                 CFLAGS="-O3 -ffast-math -mfused-madd -mcpu=750 -D_REENTRANT"
125                 PROFILE="-pg -g -O3 -ffast-math -mfused-madd -mcpu=750 -D_REENTRANT";;
126         *-*-linux*)
127                 DEBUG="-g -Wall -W -D_REENTRANT -D__NO_MATH_INLINES -fsigned-char"
128                 CFLAGS="-O20 -ffast-math -D_REENTRANT -fsigned-char"
129                 PROFILE="-pg -g -O20 -ffast-math -D_REENTRANT -fsigned-char";;
130         sparc-sun-*)
131                 DEBUG="-g -Wall -W -D__NO_MATH_INLINES -fsigned-char -mv8"
132                 CFLAGS="-O20 -ffast-math -D__NO_MATH_INLINES -fsigned-char -mv8"
133                 PROFILE="-pg -g -O20 -D__NO_MATH_INLINES -fsigned-char -mv8" ;;
134         *-*-darwin*)
135                 DEBUG="-DDARWIN -fno-common -force_cpusubtype_ALL -Wall -g -O0 -fsigned-char"
136                 CFLAGS="-DDARWIN -fno-common -force_cpusubtype_ALL -Wall -g -O4 -ffast-math -fsigned-char"
137                 PROFILE="-DDARWIN -fno-common -force_cpusubtype_ALL -Wall -g -pg -O4 -ffast-math -fsigned-char";;
138         *)
139                 DEBUG="-g -Wall -W -D__NO_MATH_INLINES -fsigned-char"
140                 CFLAGS="-O20 -D__NO_MATH_INLINES -fsigned-char"
141                 PROFILE="-O20 -g -pg -D__NO_MATH_INLINES -fsigned-char" ;;
142         esac
143 fi
144 CFLAGS="$CFLAGS $cflags_save"
145 LDFLAGS="$LDFLAGS $ldflags_save"
146
147 dnl --------------------------------------------------
148 dnl Check for headers
149 dnl --------------------------------------------------
150
151 AC_CHECK_HEADER(memory.h,CFLAGS="$CFLAGS -DUSE_MEMORY_H",:)
152
153 dnl --------------------------------------------------
154 dnl Check for typedefs, structures, etc
155 dnl --------------------------------------------------
156
157 dnl none
158
159 dnl --------------------------------------------------
160 dnl Check for libraries
161 dnl --------------------------------------------------
162
163 AC_CHECK_LIB(m, cos, LIBS="-lm", LIBS="")
164 AC_CHECK_LIB(pthread, pthread_create, pthread_lib="-lpthread", :)
165
166 XIPH_PATH_OGG(, AC_MSG_ERROR(must have Ogg installed!))
167 dnl AC_CHECK_LIB(ogg, oggpack_writealign, , AC_MSG_ERROR(Ogg >= 1.0 required !))
168
169 dnl --------------------------------------------------
170 dnl Check for library functions
171 dnl --------------------------------------------------
172
173 AC_FUNC_ALLOCA
174 AC_FUNC_MEMCMP
175
176 AC_CHECK_FUNCS(sqrtf)
177 AC_CHECK_FUNCS(logf)
178 AC_CHECK_FUNCS(expf)
179 AC_CHECK_FUNCS(acosf)
180 AC_CHECK_FUNCS(atanf)
181 AC_CHECK_FUNCS(frexpf)
182 AC_CHECK_FUNCS(rintf)
183 AC_CHECK_FUNCS(floorf)
184
185 dnl --------------------------------------------------
186 dnl Do substitutions
187 dnl --------------------------------------------------
188
189 LIBS="$LIBS $OGG_LIBS"
190
191 AC_SUBST(LIBS)
192 AC_SUBST(DEBUG)
193 AC_SUBST(PROFILE)
194 AC_SUBST(pthread_lib)
195
196 AC_OUTPUT(Makefile lib/Makefile lib/modes/Makefile lib/books/Makefile lib/books/coupled/Makefile lib/books/uncoupled/Makefile lib/books/floor/Makefile doc/Makefile doc/vorbisfile/Makefile doc/vorbisenc/Makefile include/Makefile include/vorbis/Makefile examples/Makefile win32/Makefile debian/Makefile vq/Makefile)