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