i knew there had to be a reason for that :)
[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.0)
9
10 dnl Library versioning
11
12 V_LIB_CURRENT=0
13 V_LIB_REVISION=0
14 V_LIB_AGE=0
15 VF_LIB_CURRENT=0
16 VF_LIB_REVISION=0
17 VF_LIB_AGE=0
18 AC_SUBST(V_LIB_CURRENT)
19 AC_SUBST(V_LIB_REVISION)
20 AC_SUBST(V_LIB_AGE)
21 AC_SUBST(VF_LIB_CURRENT)
22 AC_SUBST(VF_LIB_REVISION)
23 AC_SUBST(VF_LIB_AGE)
24
25 dnl --------------------------------------------------  
26 dnl Check for programs
27 dnl --------------------------------------------------  
28
29 dnl save $CFLAGS since AC_PROG_CC likes to insert "-g -O2"
30 dnl if $CFLAGS is blank
31 cflags_save="$CFLAGS"
32 AC_PROG_CC
33 CFLAGS="$cflags_save"
34
35 AM_PROG_LIBTOOL
36
37 dnl --------------------------------------------------  
38 dnl Additional arguments
39 dnl --------------------------------------------------  
40
41 AC_ARG_WITH(ogg, [  --with-ogg=DIR          Set where the Ogg library is located]) 
42
43 dnl --------------------------------------------------
44 dnl Set build flags based on environment
45 dnl --------------------------------------------------
46
47 AC_CANONICAL_HOST
48
49 dnl Set some target options
50 if test -z "$GCC"; then
51         case $host in 
52         *-*-irix*)
53                 dnl If we're on IRIX, we wanna use cc even if gcc 
54                 dnl is there (unless the user has overriden us)...
55                 if test -z "$CC"; then
56                         CC=cc
57                 fi
58                 DEBUG="-g -signed" 
59                 CFLAGS="-O2 -w -signed"
60                 PROFILE="-p -g3 -O2 -signed" ;;
61         sparc-sun-solaris*)
62                 DEBUG="-v -g"
63                 CFLAGS="-xO4 -fast -w -fsimple -native -xcg92"
64                 PROFILE="-v -xpg -g -xO4 -fast -native -fsimple -xcg92 -Dsuncc" ;;
65         *)
66                 DEBUG="-g"
67                 CFLAGS="-O"
68                 PROFILE="-g -p" ;;
69         esac
70 else
71
72         case $host in 
73         *86-*-linux*)
74                 DEBUG="-g -Wall -D_REENTRANT -D__NO_MATH_INLINES -fsigned-char"
75                 CFLAGS="-O20 -ffast-math -mno-ieee-fp -D_REENTRANT -fsigned-char"
76 #               PROFILE="-Wall -W -pg -O20 -ffast-math -D_REENTRANT -fsigned-char -fno-inline -static"
77                 PROFILE="-Wall -W -pg -O20 -ffast-math -mno-ieee-fp -D_REENTRANT -fsigned-char -fno-inline -static"
78
79                 # glibc < 2.1.3 has a serious FP bug in the math inline header
80                 # that will cripple Vorbis.  Look to see if the magic FP stack
81                 # clobber is missing in the mathinline header, thus indicating
82                 # the buggy version
83
84                 AC_EGREP_CPP(log10.*fldlg2.*fxch,[
85                                 #define __LIBC_INTERNAL_MATH_INLINES 1
86                                 #define __OPTIMIZE__
87                                 #include <math.h>
88                                 ],bad=maybe,bad=no)
89                 if test ${bad} = "maybe" ;then
90                       AC_EGREP_CPP(log10.*fldlg2.*fxch.*st\([[0123456789]]*\),
91                                         [
92                                         #define __LIBC_INTERNAL_MATH_INLINES 1
93                                         #define __OPTIMIZE__
94                                         #include <math.h>
95                                         ],bad=no,bad=yes)
96                 fi
97                 if test ${bad} = "yes" ;then
98  AC_MSG_WARN([                                                        ])
99  AC_MSG_WARN([********************************************************])
100  AC_MSG_WARN([* The glibc headers on this machine have a serious bug *])
101  AC_MSG_WARN([* in /usr/include/bits/mathinline.h  This bug affects  *])
102  AC_MSG_WARN([* all floating point code, not just Ogg, built on this *])
103  AC_MSG_WARN([* machine.  Upgrading to glibc 2.1.3 is strongly urged *])
104  AC_MSG_WARN([* to correct the problem.  Note that upgrading glibc   *])
105  AC_MSG_WARN([* will not fix any previously built programs; this is  *])
106  AC_MSG_WARN([* a compile-time time bug.                             *])
107  AC_MSG_WARN([* To work around the problem for this build of Ogg,    *])
108  AC_MSG_WARN([* autoconf is disabling all math inlining.  This will  *])
109  AC_MSG_WARN([* hurt Ogg performace but is necessary for an Ogg that *])
110  AC_MSG_WARN([* will actually work.  Once glibc is upgraded, rerun   *])
111  AC_MSG_WARN([* configure and make to build with inlining.           *])
112  AC_MSG_WARN([********************************************************])
113  AC_MSG_WARN([                                                        ])
114
115                 CFLAGS=${OPT}" -D__NO_MATH_INLINES"
116                 PROFILE=${PROFILE}" -D__NO_MATH_INLINES"
117                 fi;;
118         *-*-linux*)
119                 DEBUG="-g -Wall -D_REENTRANT -D__NO_MATH_INLINES -fsigned-char"
120                 CFLAGS="-O20 -ffast-math -D_REENTRANT -fsigned-char"
121                 PROFILE="-pg -g -O20 -ffast-math -D_REENTRANT -fsigned-char";;
122         sparc-sun-*)
123                 DEBUG="-g -Wall -D__NO_MATH_INLINES -fsigned-char -mv8"
124                 CFLAGS="-O20 -ffast-math -D__NO_MATH_INLINES -fsigned-char -mv8"
125                 PROFILE="-pg -g -O20 -D__NO_MATH_INLINES -fsigned-char -mv8" ;;
126         *)
127                 DEBUG="-g -Wall -D__NO_MATH_INLINES -fsigned-char"
128                 CFLAGS="-O20 -D__NO_MATH_INLINES -fsigned-char"
129                 PROFILE="-O20 -g -pg -D__NO_MATH_INLINES -fsigned-char" ;;
130         esac
131 fi
132
133 AC_HEADER_STDC
134
135 dnl AC_PATH_X
136 dnl AC_PATH_XTRA
137
138 #AC_CHECK_LIB(pthread, pthread_create, 
139 #       pthread_lib="-lpthread"; AC_DEFINE(HAVE_LIBPTHREAD), :)
140 # We no longer use config.h
141 AC_CHECK_LIB(pthread, pthread_create, pthread_lib="-lpthread", :)
142
143 #dnl Linuxthreads require you to define _REENTRANT in all threaded
144 #dnl code.  Bogus, bogus...
145 #
146 #if test -n "$pthread_lib"; then
147 #       case $host in 
148 #       i?86-*-linux*)
149 #               AC_DEFINE(_REENTRANT)
150 #               ;;
151 #       esac
152 #fi
153 # We no longer use config.h
154
155 #if test -n "$x_libraries"; then
156 #       XOGG="yes"
157 #
158 #       dnl If we find libgtk installed, great; otherwise assume we have
159 #       dnl to build it ourselves.
160 #
161 #       AC_CHECK_LIB(gtk, gtk_main, :, LIBGTKDIR="libgtk", $X_LIBS -lglib -lgdk -lX11 -lXext -lm)
162 #
163 #       dnl libpthread is required for xogg.
164 #
165 #       if test -z "$pthread_lib"; then XOGG=""; fi
166 #
167 #       dnl If we don't have libgtk installed, and we don't have a libgtk 
168 #       dnl  subdirectory to build the library ourself, we can't build xogg.
169 #
170 #       if test -n "$LIBGTKDIR" -a ! -d "$LIBGTKDIR"; then
171 #               XOGG=""
172 #               LIBGTKDIR=""
173 #       fi
174 #fi
175
176 dnl This seems to be the only way to make autoconf only *sometimes* configure
177 dnl a subdirectory with AC_CONFIG_SUBDIRS.  "__noconf" is assumed to not 
178 dnl exist as a directory, so configure won't try to recursively enter it, unless
179 dnl the shell variable $dummy is reset to an existing directory inside the
180 dnl if clause.
181
182 dummy="__noconf"
183
184 #if test -d "$LIBGTKDIR"; then
185 #       enable_shared="no"; export enable_shared
186 #       dummy="libgtk"
187 #       AC_CONFIG_SUBDIRS("$dummy")
188 #       X_LIBS="-L${srcdir}/libgtk/gtk/.libs -L${srcdir}/libgtk/gdk/.libs -L${srcdir}/libgtk/glib/.libs $X_LIBS"
189 #fi
190
191 # check macro modified from Jon Shiring's to compensate for autoconf's lagging
192 # behind the times on type madness
193
194 AC_MSG_CHECKING(for int16_t)
195 AC_CACHE_VAL(has_int16_t,
196 [AC_TRY_RUN([
197 #ifdef __BEOS__
198 #include <inttypes.h>
199 #endif
200 #include <sys/types.h>
201 int16_t foo;
202 int main() {return 0;}
203 ],
204 has_int16_t=yes,
205 has_int16_t=no,
206 has_int16_t=no
207 )])
208 AC_MSG_RESULT($has_int16_t)
209
210 AC_MSG_CHECKING(for int32_t)
211 AC_CACHE_VAL(has_int32_t,
212 [AC_TRY_RUN([
213 #ifdef __BEOS__
214 #include <inttypes.h>
215 #endif
216 #include <sys/types.h>
217 int32_t foo;
218 int main() {return 0;}
219 ],
220 has_int32_t=yes,
221 has_int32_t=no,
222 has_int32_t=no
223 )])
224 AC_MSG_RESULT($has_int32_t)
225
226 AC_MSG_CHECKING(for uint32_t)
227 AC_CACHE_VAL(has_uint32_t,
228 [AC_TRY_RUN([
229 #ifdef __BEOS__
230 #include <inttypes.h>
231 #endif
232 #include <sys/types.h>
233 uint32_t foo;
234 int main() {return 0;}
235 ],
236 has_uint32_t=yes,
237 has_uint32_t=no,
238 has_uint32_t=no
239 )])
240 AC_MSG_RESULT($has_uint32_t)
241
242 AC_MSG_CHECKING(for u_int32_t)
243 AC_CACHE_VAL(has_u_int32_t,
244 [AC_TRY_RUN([
245 #ifdef __BEOS__
246 #include <inttypes.h>
247 #endif
248 #include <sys/types.h>
249 u_int32_t foo;
250 int main() {return 0;}
251 ],
252 has_u_int32_t=yes,
253 has_u_int32_t=no,
254 has_u_int32_t=no
255 )])
256 AC_MSG_RESULT($has_u_int32_t)
257
258 AC_MSG_CHECKING(for int64_t)
259 AC_CACHE_VAL(has_int64_t,
260 [AC_TRY_RUN([
261 #ifdef __BEOS__
262 #include <inttypes.h>
263 #endif
264 #include <sys/types.h>
265 int64_t foo;
266 int main() {return 0;}
267 ],
268 has_int64_t=yes,
269 has_int64_t=no,
270 has_int64_t=no
271 )])
272 AC_MSG_RESULT($has_int64_t)
273
274 AC_CHECK_SIZEOF(short)
275 AC_CHECK_SIZEOF(int)
276 AC_CHECK_SIZEOF(long)
277 AC_CHECK_SIZEOF(long long)
278
279
280 if test x$has_int16_t = "xyes" ; then
281         SIZE16="int16_t"
282 else
283         case 2 in
284                 $ac_cv_sizeof_short) SIZE16="short";;
285                 $ac_cv_sizeof_int) SIZE16="int";;
286         esac
287 fi
288
289 dnl --------------------------------------------------
290 dnl Check for headers
291 dnl --------------------------------------------------
292
293 AC_CHECK_HEADER(memory.h,CFLAGS="$CFLAGS -DUSE_MEMORY_H",:)
294
295 dnl --------------------------------------------------
296 dnl Check for typedefs, structures, etc
297 dnl --------------------------------------------------
298
299 dnl none
300
301 dnl --------------------------------------------------
302 dnl Check for libraries
303 dnl --------------------------------------------------
304
305 AC_CHECK_LIB(m, cos, LIBS="-lm", LIBS="")
306 AC_CHECK_LIB(pthread, pthread_create, pthread_lib="-lpthread", :)
307
308 dnl Check for libogg
309 if test -n $with_ogg; then
310         CFLAGS="$CFLAGS -I$with_ogg/include -L$with_ogg/lib"
311 fi 
312 AC_CHECK_LIB(ogg, oggpack_read, LIBS="$LIBS -logg", AC_MSG_ERROR([You must have libogg to compile vorbis!!!]))
313
314 dnl --------------------------------------------------
315 dnl Check for library functions
316 dnl --------------------------------------------------
317
318 AC_FUNC_ALLOCA
319 AC_FUNC_MEMCMP
320
321 dnl --------------------------------------------------
322 dnl Do substitutions
323 dnl --------------------------------------------------
324
325 AC_SUBST(LIBS)
326 AC_SUBST(DEBUG)
327 AC_SUBST(PROFILE)
328 AC_SUBST(CC)
329 AC_SUBST(pthread_lib)
330
331 AC_OUTPUT(Makefile lib/Makefile doc/Makefile include/Makefile include/vorbis/Makefile include/vorbis/book/Makefile examples/Makefile)