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