Fixed ANSI C related compile problems.
[wine] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 dnl Author: Michael Patra   <micky@marie.physik.tu-berlin.de>
3 dnl                         <patra@itp1.physik.tu-berlin.de>
4 AC_REVISION([configure.in 1.00])
5 AC_INIT(controls/edit.c)                
6 AC_CONFIG_HEADER(include/config.h)
7 AC_CONFIG_AUX_DIR(tools)
8
9 # We want these before the checks, so the checks can modify their values.
10
11 test -z "$PROGEXT" && PROGEXT="" AC_SUBST(PROGEXT)
12
13 dnl **** Command-line arguments ****
14
15 dnl Default values
16 EMU_TARGET=wine
17 LIBEXT=so       # library type .so or .a
18 TRACE_MSGS=yes  # the TRACE() macro
19 DEBUG_MSGS=yes  # the TRACE(), WARN(), and FIXME() macros.
20
21 AC_ARG_ENABLE(emulator,
22 [  --disable-emulator      build only the Wine library, not the emulator],
23 [if test "$enableval" = "no"; then EMU_TARGET=""; fi])
24
25 AC_ARG_ENABLE(dll,
26 [  --disable-dll           build static libraries instead of DLLs],
27 [if test "$enableval" = "no"; then LIBEXT="a"; fi])
28
29 AC_ARG_ENABLE(debug,
30 [  --disable-debug         compile out all debugging messages],
31 [if test "$enableval" = "no"; then DEBUG_MSGS="no"; fi])
32
33 AC_ARG_ENABLE(trace,
34 [  --disable-trace         compile out TRACE messages],
35 [if test "$enableval" = "no"; then TRACE_MSGS="no"; fi])
36
37 AC_ARG_WITH(reentrant-x,
38 [  --without-reentrant-x   compile for use with non-reentrant X libraries])
39
40 AC_SUBST(EMU_TARGET)
41 AC_SUBST(OPTIONS)
42
43 if test "$DEBUG_MSGS" = "no"
44 then
45     AC_DEFINE(NO_DEBUG_MSGS)
46     AC_DEFINE(NO_TRACE_MSGS)
47 else
48     if test "$TRACE_MSGS" = "no"
49     then
50         AC_DEFINE(NO_TRACE_MSGS)
51     fi
52 fi
53
54 dnl **** Check for some programs ****
55
56 AC_PROG_MAKE_SET
57 AC_PROG_CC
58 AC_PROG_CPP
59 AC_PATH_XTRA
60 AC_PROG_YACC
61 AC_PROG_LEX
62 AC_PROG_RANLIB
63 AC_PROG_INSTALL
64 AC_PROG_LN_S
65 AC_CHECK_PROG(C2MAN,c2man,c2man,true)
66 AC_PATH_PROG(LDCONFIG, ldconfig, true, /sbin:/usr/sbin:$PATH)
67
68 dnl Check for lint
69 AC_CHECK_PROGS(LINT, lclint lint)
70 if test "$LINT" = "lint"
71 then
72   LINTFLAGS="$LINTFLAGS -errchk=%all,no%longptr64 -errhdr=%user -Ncheck=macro -Nlevel=4"
73   dnl LINTFLAGS='-D_SIZE_T "-Dsize_t=unsigned long" -errchk=longptr64'
74 fi
75 AC_SUBST(LINT)
76 AC_SUBST(LINTFLAGS)
77
78 dnl **** Check for some libraries ****
79
80 dnl Check for -lm for BeOS
81 AC_CHECK_LIB(m,sqrt)
82 dnl Check for -li386 for NetBSD and OpenBSD
83 AC_CHECK_LIB(i386,i386_set_ldt)
84 dnl Check for -lossaudio for NetBSD
85 AC_CHECK_LIB(ossaudio,_oss_ioctl)
86 dnl Check for -lw for Solaris
87 AC_CHECK_LIB(w,iswalnum)
88 dnl Check for -lnsl for Solaris
89 AC_CHECK_FUNCS(gethostbyname,, AC_CHECK_LIB(nsl, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl", AC_CHECK_LIB(socket, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl", , -lnsl), -lsocket))
90 dnl Check for -lsocket for Solaris
91 AC_CHECK_FUNCS(connect,,AC_CHECK_LIB(socket,connect))
92 dnl Check for -lxpg4 for FreeBSD
93 AC_CHECK_LIB(xpg4,setrunelocale)
94 dnl Check for -lmmap for OS/2
95 AC_CHECK_LIB(mmap,mmap)
96 dnl Check for openpty
97 AC_CHECK_FUNCS(openpty,,
98         AC_CHECK_LIB(util,openpty,
99                 AC_DEFINE(HAVE_OPENPTY)
100                 LIBS="$LIBS -lutil"
101         ))
102
103 AC_CHECK_HEADERS(dlfcn.h,
104         AC_CHECK_FUNCS(dlopen,
105                 AC_DEFINE(HAVE_DL_API),
106                 AC_CHECK_LIB(dl,dlopen,
107                         AC_DEFINE(HAVE_DL_API)
108                         LIBS="$LIBS -ldl"
109                 )
110         )
111 )
112 AC_SUBST(XLIB)
113 if test "$have_x" = "yes"
114 then
115     XLIB="-lXext -lX11"
116     ac_save_CPPFLAGS="$CPPFLAGS"
117     CPPFLAGS="$CPPFLAGS $X_CFLAGS"
118
119     dnl Check for -lXpm
120     AC_CHECK_HEADERS(X11/xpm.h)
121     if test "$ac_cv_header_X11_xpm_h" = "yes"
122     then 
123         AC_CHECK_LIB(Xpm,XpmCreatePixmapFromData,AC_DEFINE(HAVE_LIBXXPM) X_PRE_LIBS="$X_PRE_LIBS -lXpm",,$X_LIBS -lXext -lX11 $X_EXTRA_LIBS)
124     else
125         echo "When compiling with X support, you need the Xpm library, or"
126         echo "WINE will not work. This Xpm library is within the following RPM,"
127         echo "which you need to install:"
128         echo "Redhat            :       xpm, xpm-devel"
129         echo "Caldera OpenLinux :       xpm, xpm-devel, xpm-devel-static"
130         echo "SuSE              :       xpm"
131         echo "Debian/Corel Linux:       xpm4g, xpm4g-dev"
132         echo
133         echo "Or get the sources from ftp.x.org and all its mirror sites from "
134         echo "the directory /contrib/libraries."
135         echo
136         exit 1
137     fi
138
139
140     dnl Check for X Shm extension
141     AC_CHECK_HEADERS(X11/Xlib.h X11/extensions/XShm.h)
142     if test "$ac_cv_header_X11_Xlib_h" = "yes" -a "$ac_cv_header_X11_extensions_XShm_h" = "yes"
143     then 
144         AC_CHECK_LIB(Xext,XShmQueryExtension,AC_DEFINE(HAVE_LIBXXSHM),,$X_LIBS -lXext -lX11 $X_EXTRA_LIBS)
145     fi
146     dnl Check for XFree86 DGA / DGA 2.0 extension
147     AC_CHECK_HEADERS(X11/Xlib.h X11/extensions/xf86dga.h)
148     if test "$ac_cv_header_X11_Xlib_h" = "yes" -a "$ac_cv_header_X11_extensions_xf86dga_h" = "yes"
149     then 
150          AC_CHECK_LIB(Xxf86dga,
151                       XDGAQueryExtension,
152                       AC_DEFINE(HAVE_LIBXXF86DGA2) AC_DEFINE(HAVE_LIBXXF86DGA) X_PRE_LIBS="$X_PRE_LIBS -lXxf86dga",,$X_LIBS -lXext -lX11 $X_EXTRA_LIBS)
153          if test "$ac_cv_lib_Xxf86dga_XDGAQueryExtension" = "no"
154          then
155            AC_CHECK_LIB(Xxf86dga,XF86DGAQueryExtension,AC_DEFINE(HAVE_LIBXXF86DGA) X_PRE_LIBS="$X_PRE_LIBS -lXxf86dga",,$X_LIBS -lXext -lX11 $X_EXTRA_LIBS)
156          fi
157     fi
158
159     dnl Check for XFree86 VMODE extension
160     AC_CHECK_HEADERS(X11/Xlib.h X11/extensions/xf86vmode.h)
161     if test "$ac_cv_header_X11_Xlib_h" = "yes" -a "$ac_cv_header_X11_extensions_xf86vmode_h" = "yes"
162     then 
163         AC_CHECK_LIB(Xxf86vm,XF86VidModeQueryExtension,AC_DEFINE(HAVE_LIBXXF86VM) X_PRE_LIBS="$X_PRE_LIBS -lXxf86vm",,$X_LIBS -lXext -lX11 $X_EXTRA_LIBS)
164     fi
165
166     dnl Check for the presence of Mesa
167     AC_CHECK_HEADERS(GL/gl.h GL/glx.h GL/osmesa.h)
168     if test "$ac_cv_header_GL_gl_h" = "yes" -a "$ac_cv_header_GL_glx_h" = "yes"
169     then
170         dnl Check for some problems due to old Mesa versions
171         AC_CACHE_CHECK("for up-to-date Mesa version", wine_cv_mesa_version_OK,
172           AC_TRY_COMPILE(
173             [#include <GL/gl.h>],
174             [GLenum test = GL_UNSIGNED_SHORT_5_6_5;],
175             [wine_cv_mesa_version_OK="yes"],
176             [wine_cv_mesa_version_OK="no"]
177           )
178         )
179
180         if test "$wine_cv_mesa_version_OK" = "yes"
181         then
182             dnl Check for the presense of the library
183             AC_CHECK_LIB(GL,glXCreateContext,AC_DEFINE(HAVE_LIBMESAGL) X_PRE_LIBS="$X_PRE_LIBS -lGL",,$X_LIBS -lXext -lX11 -lm $X_EXTRA_LIBS)
184             if test "$ac_cv_lib_GL_glXCreateContext" = "no"
185             then
186                 AC_CHECK_LIB(MesaGL,glXCreateContext,AC_DEFINE(HAVE_LIBMESAGL) X_PRE_LIBS="$X_PRE_LIBS -lMesaGL",,$X_LIBS -lXext -lX11 -lm $X_EXTRA_LIBS)
187             fi
188
189             dnl Check for the Color Table and Paletted Texture extensions
190             AC_CACHE_CHECK("for the OpenGL Color Index extension",dummy,
191               AC_TRY_COMPILE(
192                 [#include <GL/gl.h>],
193                 [GLenum test = GL_COLOR_INDEX8_EXT;],
194                 [AC_DEFINE(HAVE_GL_COLOR_TABLE)],
195               )
196             )
197             if test "$ac_cv_lib_GL_glXCreateContext" = "no"
198             then
199                 AC_CHECK_LIB(MesaGL,glColorTableEXT,AC_DEFINE(HAVE_GL_PALETTED_TEXTURE),,$X_LIBS -lXext -lX11 -lm $X_EXTRA_LIBS)
200             else
201                 AC_CHECK_LIB(GL,glColorTableEXT,AC_DEFINE(HAVE_GL_PALETTED_TEXTURE),,$X_LIBS -lXext -lX11 -lm $X_EXTRA_LIBS)
202             fi
203         fi
204     fi
205
206     CPPFLAGS="$ac_save_CPPFLAGS"
207 else
208     XLIB=""
209     X_CFLAGS=""
210     X_LIBS=""
211 fi
212
213 dnl **** Check which curses lib to use ***
214 AC_CHECK_HEADERS(ncurses.h)
215 if test "$ac_cv_header_ncurses_h" = "yes"
216 then 
217     AC_CHECK_LIB(ncurses,waddch)
218 fi
219 if test "$ac_cv_lib_ncurses_waddch" = "yes"
220 then
221     AC_CHECK_LIB(ncurses,resizeterm,AC_DEFINE(HAVE_RESIZETERM))
222     AC_CHECK_LIB(ncurses,getbkgd,AC_DEFINE(HAVE_GETBKGD))
223 else
224     AC_CHECK_HEADERS(curses.h)
225     if test "$ac_cv_header_curses_h" = "yes"
226     then    
227        AC_CHECK_LIB(curses,waddch)
228        AC_CHECK_LIB(curses,resizeterm,AC_DEFINE(HAVE_RESIZETERM))
229        AC_CHECK_LIB(curses,getbkgd,AC_DEFINE(HAVE_GETBKGD))
230     fi
231 fi
232
233 dnl **** Check for IPX (currently Linux only) ****
234 AC_CACHE_CHECK("for GNU style IPX support", ac_cv_c_ipx_gnu,
235  AC_TRY_COMPILE(
236    [#include <sys/socket.h>
237     #include <netipx/ipx.h>],
238    [((struct sockaddr_ipx *)0)->sipx_family == AF_IPX],
239    [ac_cv_c_ipx_gnu="yes"],
240    [ac_cv_c_ipx_gnu="no"])
241  )
242 if test "$ac_cv_c_ipx_gnu" = "yes"
243 then
244     AC_DEFINE(HAVE_IPX_GNU)
245 fi
246
247 if test "$ac_cv_c_ipx_gnu" = "no"
248 then
249  AC_CACHE_CHECK("for linux style IPX support", ac_cv_c_ipx_linux,
250   AC_TRY_COMPILE(
251     [#include <sys/socket.h>
252      #include <asm/types.h>
253      #include <linux/ipx.h>],
254     [((struct sockaddr_ipx *)0)->sipx_family == AF_IPX],
255     [ac_cv_c_ipx_linux="yes"],
256     [ac_cv_c_ipx_linux="no"])
257   )
258   if test "$ac_cv_c_ipx_linux" = "yes"
259   then
260       AC_DEFINE(HAVE_IPX_LINUX)
261   fi
262 fi
263
264 dnl **** Check for Open Sound System ****
265 AC_CHECK_HEADERS(sys/soundcard.h machine/soundcard.h soundcard.h, break)
266
267 AC_CACHE_CHECK("for Open Sound System",
268         ac_cv_c_opensoundsystem,
269         AC_TRY_COMPILE([
270         #if defined(HAVE_SYS_SOUNDCARD_H)
271                 #include <sys/soundcard.h>
272         #elif defined(HAVE_MACHINE_SOUNDCARD_H)
273                 #include <machine/soundcard.h>
274         #elif defined(HAVE_SOUNDCARD_H)
275                 #include <soundcard.h>
276         #endif
277         ],[
278
279 /* check for one of the Open Sound System specific SNDCTL_ defines */
280 #if !defined(SNDCTL_DSP_STEREO)
281 #error No open sound system
282 #endif
283 ],ac_cv_c_opensoundsystem="yes",ac_cv_c_opensoundsystem="no"))
284
285 if test "$ac_cv_c_opensoundsystem" = "yes"
286 then
287     AC_DEFINE(HAVE_OSS)
288 fi
289
290 AC_CACHE_CHECK("for Open Sound System/MIDI interface",
291         ac_cv_c_opensoundsystem_midi,
292         AC_TRY_COMPILE([
293         #if defined(HAVE_SYS_SOUNDCARD_H)
294                 #include <sys/soundcard.h>
295         #elif defined(HAVE_MACHINE_SOUNDCARD_H)
296                 #include <machine/soundcard.h>
297         #elif defined(HAVE_SOUNDCARD_H)
298                 #include <soundcard.h>
299         #endif
300         ],[
301
302 /* check for one of the Open Sound System specific SNDCTL_SEQ defines */
303 #if !defined(SNDCTL_SEQ_SYNC)
304 #error No open sound system MIDI interface
305 #endif
306 ],ac_cv_c_opensoundsystem_midi="yes",ac_cv_c_opensoundsystem_midi="no"))
307
308 if test "$ac_cv_c_opensoundsystem_midi" = "yes"
309 then
310     AC_DEFINE(HAVE_OSS_MIDI)
311 fi
312
313 dnl **** If ln -s doesn't work, use cp instead ****
314 if test "$ac_cv_prog_LN_S" = "ln -s"; then : ; else LN_S=cp ; fi
315
316 dnl **** Check for gcc strength-reduce bug ****
317
318 if test "x${GCC}" = "xyes"
319 then
320   CFLAGS="$CFLAGS -Wall"
321   AC_CACHE_CHECK( "for gcc strength-reduce bug", ac_cv_c_gcc_strength_bug,
322                   AC_TRY_RUN([
323 int main(void) {
324   static int Array[[3]];
325   unsigned int B = 3;
326   int i;
327   for(i=0; i<B; i++) Array[[i]] = i - 3;
328   exit( Array[[1]] != -2 );
329 }],
330     ac_cv_c_gcc_strength_bug="no",
331     ac_cv_c_gcc_strength_bug="yes",
332     ac_cv_c_gcc_strength_bug="yes") )
333   if test "$ac_cv_c_gcc_strength_bug" = "yes"
334   then
335     CFLAGS="$CFLAGS -fno-strength-reduce"
336   fi
337 fi
338
339 dnl **** Check for underscore on external symbols ****
340
341 AC_CACHE_CHECK("whether external symbols need an underscore prefix",
342                ac_cv_c_extern_prefix,
343 [saved_libs=$LIBS
344 LIBS="conftest_asm.s $LIBS"
345 cat > conftest_asm.s <<EOF
346         .globl _ac_test
347 _ac_test:
348         .long 0
349 EOF
350 AC_TRY_LINK([extern int ac_test;],[if (ac_test) return 1],
351             ac_cv_c_extern_prefix="yes",ac_cv_c_extern_prefix="no")
352 LIBS=$saved_libs])
353 if test "$ac_cv_c_extern_prefix" = "yes"
354 then
355   AC_DEFINE(NEED_UNDERSCORE_PREFIX)
356 fi
357
358 dnl **** Check for .string in assembler ****
359
360 AC_CACHE_CHECK("whether assembler accepts .string",
361                ac_cv_c_asm_string,
362 [saved_libs=$LIBS
363 LIBS="conftest_asm.s $LIBS"
364 cat > conftest_asm.s <<EOF
365         .string "test"
366 EOF
367 AC_TRY_LINK(,,ac_cv_c_asm_string="yes",ac_cv_c_asm_string="no")
368 LIBS=$saved_libs])
369 if test "$ac_cv_c_asm_string" = "yes"
370 then
371   AC_DEFINE(HAVE_ASM_STRING)
372 fi
373
374 dnl **** Check for working dll ****
375
376 LDSHARED=""
377 if test "$LIBEXT" = "so"
378 then
379   AC_CACHE_CHECK("whether we can build a Linux dll",
380                  ac_cv_c_dll_linux,
381   [saved_cflags=$CFLAGS
382   CFLAGS="$CFLAGS -fPIC -shared -Wl,-soname,conftest.so.1.0"
383   AC_TRY_LINK(,[return 1],ac_cv_c_dll_linux="yes",ac_cv_c_dll_linux="no")
384   CFLAGS=$saved_cflags
385   ])
386   if test "$ac_cv_c_dll_linux" = "yes"
387   then
388     LDSHARED="\$(CC) -shared -Wl,-soname,\$(SONAME),-rpath,\$(libdir)"
389   else
390     AC_CACHE_CHECK(whether we can build a UnixWare (Solaris) dll,
391                  ac_cv_c_dll_unixware,
392     [saved_cflags=$CFLAGS
393     CFLAGS="$CFLAGS -fPIC -Wl,-G,-h,conftest.so.1.0"
394     AC_TRY_LINK(,[return 1],ac_cv_c_dll_unixware="yes",ac_cv_c_dll_unixware="no")
395     CFLAGS=$saved_cflags
396     ])
397     if test "$ac_cv_c_dll_unixware" = "yes"
398     then
399       LDSHARED="\$(CC) -Wl,-G,-h,\$(libdir)/\$(SONAME)"
400     else
401       AC_CACHE_CHECK("whether we can build a NetBSD dll",
402                    ac_cv_c_dll_netbsd,
403       [saved_cflags=$CFLAGS
404       CFLAGS="$CFLAGS -fPIC -Bshareable -Bforcearchive"
405       AC_TRY_LINK(,[return 1],ac_cv_c_dll_netbsd="yes",ac_cv_c_dll_netbsd="no")
406       CFLAGS=$saved_cflags
407       ])
408       if test "$ac_cv_c_dll_netbsd" = "yes"
409       then
410         LDSHARED="ld -Bshareable -Bforcearchive"
411       fi
412     fi
413   fi
414   if test "$ac_cv_c_dll_linux" = "no" -a "$ac_cv_c_dll_unixware" = "no" -a "$ac_cv_c_dll_netbsd" = "no"
415   then
416     LIBEXT="a"
417   fi
418 fi
419
420 DLLFLAGS=""
421 BUILDFLAGS=""
422 DLL_LINK="-L\$(DLLDIR) \$(DLLS:%=-l%) -L\$(TOPOBJDIR) -lwine"
423
424 if test "$LIBEXT" = "so"; then
425     BUILDFLAGS="-pic"
426     DLLFLAGS="-fPIC"
427 else
428     AC_CACHE_CHECK([whether the linker supports --[[no]]-whole-archive (Linux)],
429                    ac_cv_c_whole_archive,
430             [saved_cflags=$CFLAGS
431             CFLAGS="$CFLAGS -Wl,--whole-archive -Wl,--no-whole-archive"
432             AC_TRY_LINK(,[return 1],ac_cv_c_whole_archive="yes",ac_cv_c_whole_archive="no")
433             CFLAGS=$saved_cflags
434             ])
435     if test "$ac_cv_c_whole_archive" = "yes"
436     then
437         DLL_LINK="-Wl,--whole-archive $DLL_LINK -Wl,--no-whole-archive"
438     else
439         AC_CACHE_CHECK([whether the linker supports -z {all,default}extract (Linux)],
440                        ac_cv_c_allextract,
441                 [saved_cflags=$CFLAGS
442                 CFLAGS="$CFLAGS -Wl,-z,allextract -Wl,-z,defaultextract"
443                 AC_TRY_LINK(,[return 1],ac_cv_c_allextract="yes",ac_cv_c_allextract="no")
444                 CFLAGS=$saved_cflags
445                 ])
446         if test "$ac_cv_c_allextract" = "yes"
447         then
448             DLL_LINK="-Wl,-z,allextract $DLL_LINK -Wl,-z,defaultextract"
449         fi
450     fi
451 fi
452
453 AC_SUBST(DLL_LINK)
454 AC_SUBST(BUILDFLAGS)
455 AC_SUBST(DLLFLAGS)
456 AC_SUBST(LDSHARED)
457 AC_SUBST(LIBEXT)
458
459 dnl **** Check for reentrant libc ****
460 dnl
461 dnl For cross-compiling we blindly assume that libc is reentrant. This is
462 dnl ok since non-reentrant libc is quite rare (mostly old libc5 versions).
463
464 wine_cv_libc_reentrant=no 
465 dnl 
466 dnl Linux style errno location
467 dnl 
468 AC_CACHE_CHECK("for reentrant libc: __errno_location", wine_cv_libc_r__errno_location,
469   [AC_TRY_RUN([int myerrno = 0;
470 char buf[256];
471 int *__errno_location(){return &myerrno;}
472 main(){connect(0,buf,255); exit(!myerrno);}],
473   wine_cv_libc_r__errno_location=yes, wine_cv_libc_r__errno_location=no,
474   wine_cv_libc_r__errno_location=yes )
475 ])
476 if test "$wine_cv_libc_r__errno_location" = "yes"
477 then
478     AC_DEFINE(HAVE__ERRNO_LOCATION)
479     wine_cv_libc_reentrant=__errno_location 
480 fi
481 dnl
482 dnl FreeBSD style errno location
483 dnl 
484 AC_CACHE_CHECK("for reentrant libc: __error", wine_cv_libc_r__error,
485   [AC_TRY_RUN([int myerrno = 0;
486 char buf[256];
487 int *__error(){return &myerrno;}
488 main(){connect(0,buf,255); exit(!myerrno);}],
489     wine_cv_libc_r__error=yes, wine_cv_libc_r__error=no,
490     wine_cv_libc_r__error=yes )
491 ])
492 if test "$wine_cv_libc_r__error" = "yes"
493 then
494     AC_DEFINE(HAVE__ERROR)
495     wine_cv_libc_reentrant=__error 
496 fi
497 dnl
498 dnl Solaris style errno location
499 dnl 
500 AC_CACHE_CHECK("for reentrant libc: ___errno", wine_cv_libc_r___errno,
501   [AC_TRY_RUN([int myerrno = 0;
502 char buf[256];
503 int *___errno(){return &myerrno;}
504 main(){connect(0,buf,255); exit(!myerrno);}],
505     wine_cv_libc_r___errno=yes, wine_cv_libc_r___errno=no,
506     wine_cv_libc_r___errno=yes )
507 ])
508 if test "$wine_cv_libc_r___errno" = "yes"
509 then
510     AC_DEFINE(HAVE___ERRNO)
511     wine_cv_libc_reentrant=___errno 
512 fi
513 dnl
514 dnl UnixWare style errno location
515 dnl 
516 AC_CACHE_CHECK("for reentrant libc: __thr_errno", wine_cv_libc_r__thr_errno,
517   [AC_TRY_RUN([int myerrno = 0;
518 char buf[256];
519 int *__thr_errno(){return &myerrno;}
520 main(){connect(0,buf,255); exit(!myerrno);}],
521     wine_cv_libc_r__thr_errno=yes, wine_cv_libc_r__thr_errno=no,
522     wine_cv_libc_r__thr_errno=yes )
523 ])
524 if test "$wine_cv_libc_r__thr_errno" = "yes"
525 then
526     AC_DEFINE(HAVE__THR_ERRNO)
527     wine_cv_libc_reentrant=__thr_errno 
528 fi
529 if test "$wine_cv_libc_reentrant" = "no" 
530 then
531   AC_DEFINE(NO_REENTRANT_LIBC)
532 fi
533
534 dnl **** Check for reentrant X libraries ****
535 dnl
536 dnl This may fail to determine whether X libraries are reentrant if
537 dnl AC_PATH_XTRA does not set x_libraries. In this case manual configuration
538 dnl is possible with the --without-reentrant-x option.
539
540 if test "$have_x" = "yes" -a "$wine_cv_libc_reentrant" != "no"
541 then
542 AC_CACHE_CHECK( "for reentrant X libraries", wine_cv_x_reentrant,
543   [ if test "x$with_reentrant_x" = "xno" 
544     then
545         wine_cv_x_reentrant=no
546     else
547         libX11_check=none
548         for dir in "$x_libraries" /usr/lib /usr/local/lib /lib; do
549             if test -r $dir/libX11.so; then
550                 libX11_check="-D $dir/libX11.so"
551                 break 1
552             fi
553             if test -r $dir/libX11.a; then
554                 libX11_check="$dir/libX11.a"
555                 break 1
556             fi
557         done
558         if test "$libX11_check" != "none"; then
559             if nm $libX11_check | grep $wine_cv_libc_reentrant >/dev/null 2>&1
560             then
561                 wine_cv_x_reentrant=yes
562             else
563                 wine_cv_x_reentrant=no
564             fi
565         else
566             wine_cv_x_reentrant=unknown
567         fi
568     fi ] )
569 else
570     wine_cv_x_reentrant=no
571 fi
572 if test "$wine_cv_x_reentrant" = "no"
573 then
574   AC_DEFINE(NO_REENTRANT_X11)
575 fi
576
577 dnl **** Check for endianness ****
578
579 AC_C_BIGENDIAN
580
581 dnl **** Check for functions ****
582
583 AC_FUNC_ALLOCA()
584 AC_CHECK_FUNCS(\
585         _lwp_create \
586         clone \
587         getnetbyaddr \
588         getnetbyname \
589         getpagesize \
590         getprotobyname \
591         getprotobynumber \
592         getservbyport \
593         getsockopt \
594         inet_network \
595         memmove \
596         rfork \
597         select \
598         sendmsg \
599         settimeofday \
600         sigaltstack \
601         statfs \
602         strcasecmp \
603         strerror \
604         strncasecmp \
605         tcgetattr \
606         timegm \
607         usleep \
608         vfscanf \
609         wait4 \
610         waitpid \
611 )
612
613 dnl **** Check for header files ****
614
615 AC_CHECK_HEADERS(\
616         a.out.h \
617         a_out.h \
618         arpa/inet.h \
619         arpa/nameser.h \
620         curses.h \
621         elf.h \
622         float.h \
623         libio.h \
624         link.h \
625         linux/cdrom.h \
626         linux/joystick.h \
627         linux/ucdrom.h \
628         ncurses.h \
629         net/if.h \
630         netinet/in.h \
631         netinet/tcp.h \
632         pty.h \
633         resolv.h \
634         sched.h \
635         socket.h \
636         strings.h \
637         sys/cdio.h \
638         sys/errno.h \
639         sys/file.h \
640         sys/filio.h \
641         sys/ipc.h \
642         sys/lwp.h \
643         sys/mman.h \
644         sys/modem.h \
645         sys/mount.h \
646         sys/msg.h \
647         sys/param.h \
648         sys/reg.h \
649         sys/signal.h \
650         sys/shm.h \
651         sys/socket.h \
652         sys/sockio.h \
653         sys/statfs.h \
654         sys/strtio.h \
655         sys/syscall.h \
656         sys/wait.h \
657         sys/v86.h \
658         sys/v86intr.h \
659         sys/vfs.h \
660         sys/vm86.h \
661         syscall.h \
662         ucontext.h \
663         wctype.h \
664 )
665 AC_HEADER_STAT()
666
667 dnl **** Check for types ****
668
669 AC_C_CONST()
670 AC_C_INLINE()
671 AC_TYPE_SIZE_T()
672 AC_CHECK_SIZEOF(long long,0)
673
674 if test "$ac_cv_header_linux_joystick_h" = "yes"
675 then
676    AC_CACHE_CHECK("whether linux/joystick.h uses the Linux 2.2+ API",
677         wine_cv_linux_joystick_22_api,
678         AC_TRY_COMPILE([
679         #include <sys/ioctl.h>
680         #include <linux/joystick.h>
681
682         struct js_event blub;
683         #if !defined(JS_EVENT_AXIS) || !defined(JS_EVENT_BUTTON)
684         #error "no 2.2 header"
685         #endif
686         ],/*empty*/,
687         wine_cv_linux_joystick_22_api=yes,
688         wine_cv_linux_joystick_22_api=no,
689         wine_cv_linux_joystick_22_api=no
690         )
691    )
692    if test "$wine_cv_linux_joystick_22_api"
693    then
694       AC_DEFINE(HAVE_LINUX_22_JOYSTICK_API)
695    fi
696 fi
697
698 dnl **** statfs checks ****
699
700 if test "$ac_cv_header_sys_vfs_h" = "yes"
701 then
702     AC_CACHE_CHECK( "whether sys/vfs.h defines statfs",
703                     wine_cv_sys_vfs_has_statfs,
704         AC_TRY_COMPILE([
705         #include <sys/types.h>
706         #ifdef HAVE_SYS_PARAM_H
707         # include <sys/param.h>
708         #endif
709         #include <sys/vfs.h>
710         ],[
711                 struct statfs stfs;
712
713                 memset(&stfs,0,sizeof(stfs));
714         ],wine_cv_sys_vfs_has_statfs=yes,wine_cv_sys_vfs_has_statfs=no
715         )
716     )
717     if test "$wine_cv_sys_vfs_has_statfs" = "yes"
718     then
719       AC_DEFINE(STATFS_DEFINED_BY_SYS_VFS)
720     fi
721 fi
722
723 if test "$ac_cv_header_sys_statfs_h" = "yes"
724 then
725     AC_CACHE_CHECK( "whether sys/statfs.h defines statfs",
726                     wine_cv_sys_statfs_has_statfs,
727         AC_TRY_COMPILE([
728         #include <sys/types.h>
729         #ifdef HAVE_SYS_PARAM_H
730         # include <sys/param.h>
731         #endif
732         #include <sys/statfs.h>
733         ],[
734                 struct statfs stfs;
735         ],wine_cv_sys_statfs_has_statfs=yes,wine_cv_sys_statfs_has_statfs=no
736         )
737     )
738     if test "$wine_cv_sys_statfs_has_statfs" = "yes"
739     then
740       AC_DEFINE(STATFS_DEFINED_BY_SYS_STATFS)
741     fi
742 fi
743
744 if test "$ac_cv_header_sys_mount_h" = "yes"
745 then
746     AC_CACHE_CHECK( "whether sys/mount.h defines statfs",
747                     wine_cv_sys_mount_has_statfs,
748         AC_TRY_COMPILE([
749         #include <sys/types.h>
750         #ifdef HAVE_SYS_PARAM_H
751         # include <sys/param.h>
752         #endif
753         #include <sys/mount.h>
754         ],[
755                 struct statfs stfs;
756         ],wine_cv_sys_mount_has_statfs=yes,wine_cv_sys_mount_has_statfs=no
757         )
758     )
759     if test "$wine_cv_sys_mount_has_statfs" = "yes"
760     then
761       AC_DEFINE(STATFS_DEFINED_BY_SYS_MOUNT)
762     fi
763 fi
764
765 dnl **** FIXME: what about mixed cases, where we need two of them? ***
766
767 AC_CACHE_CHECK( "for statfs.f_bfree", wine_cv_statfs_bfree,
768   [ if test "x$statfs_bfree" = "xno"
769     then
770         wine_cv_statfs_bfree=no
771     else
772         AC_TRY_COMPILE([
773         #include <sys/types.h>
774         #ifdef HAVE_SYS_PARAM_H
775         # include <sys/param.h>
776         #endif
777         #ifdef STATFS_DEFINED_BY_SYS_MOUNT
778         # include <sys/mount.h>
779         #else
780         # ifdef STATFS_DEFINED_BY_SYS_VFS
781         #  include <sys/vfs.h>
782         # else
783         #  ifdef STATFS_DEFINED_BY_SYS_STATFS
784         #   include <sys/statfs.h>
785         #  endif
786         # endif
787         #endif
788         ],[
789                 struct statfs stfs;
790
791                 stfs.f_bfree++;
792         ],wine_cv_statfs_bfree=yes,wine_cv_statfs_bfree=no
793         )
794     fi ] )
795 if test "$wine_cv_statfs_bfree" = "yes"
796 then
797   AC_DEFINE(STATFS_HAS_BFREE)
798 fi
799
800 AC_CACHE_CHECK( "for statfs.f_bavail", wine_cv_statfs_bavail,
801   [ if test "x$statfs_bavail" = "xno"
802     then
803         wine_cv_statfs_bavail=no
804     else
805         AC_TRY_COMPILE([
806         #include <sys/types.h>
807         #ifdef HAVE_SYS_PARAM_H
808         # include <sys/param.h>
809         #endif
810         #ifdef STATFS_DEFINED_BY_SYS_MOUNT
811         # include <sys/mount.h>
812         #else
813         # ifdef STATFS_DEFINED_BY_SYS_VFS
814         #  include <sys/vfs.h>
815         # else
816         #  ifdef STATFS_DEFINED_BY_SYS_STATFS
817         #   include <sys/statfs.h>
818         #  endif
819         # endif
820         #endif
821         ],[
822                 struct statfs stfs;
823
824                 stfs.f_bavail++;
825         ],wine_cv_statfs_bavail=yes,wine_cv_statfs_bavail=no
826         )
827     fi ] )
828 if test "$wine_cv_statfs_bavail" = "yes"
829 then
830   AC_DEFINE(STATFS_HAS_BAVAIL)
831 fi
832
833 dnl *** check for working sigaltstack
834 dnl glibc 2.0x defines it, but it always fails... so it is useless for us.
835
836 AC_CACHE_CHECK("for working sigaltstack",
837         ac_cv_c_working_sigaltstack,
838         AC_TRY_RUN([
839         #include <stdio.h>
840         #include <time.h> /* <sys/time.h> ? bad magic without end */
841         #include <sys/types.h>
842         #include <sys/signal.h>
843         #ifdef HAVE_SYS_PARAM_H
844         # include <sys/param.h>
845         #endif
846         #ifdef HAVE_SYSCALL_H
847         # include <syscall.h>
848         #else
849         # ifdef HAVE_SYS_SYSCALL_H
850         #  include <sys/syscall.h>
851         # endif
852         #endif
853         
854         unsigned char *xaltstack;
855
856         int
857         main(int argc,char **argv) {
858             struct sigaltstack  ss;
859
860             xaltstack = malloc(16384);
861             ss.ss_sp    = xaltstack;
862             ss.ss_size  = 16384;
863             ss.ss_flags = 0;
864             if (sigaltstack(&ss, NULL) < 0) {
865                 /* this catches the glibc case */
866                 perror("sigaltstack");
867                 return (1); /* aka exit(1) aka fail */
868             }
869             /* assume it works. */
870             return 0; /* OK */
871         }
872         ],
873         ac_cv_c_working_sigaltstack="yes",
874         ac_cv_c_working_sigaltstack="no",
875         ac_cv_c_working_sigaltstack="no"
876 ))
877
878 if test "$ac_cv_c_working_sigaltstack" = "yes"
879 then
880     AC_DEFINE(HAVE_WORKING_SIGALTSTACK)
881 fi
882
883
884 dnl *** check for file descriptor passing with msg_accrights
885
886 AC_CACHE_CHECK("for msg_accrights in struct msghdr", ac_cv_c_msg_accrights,
887  AC_TRY_COMPILE([#include <sys/types.h>
888 #include <sys/socket.h>],[struct msghdr hdr; hdr.msg_accrights=0],
889                 ac_cv_c_msg_accrights="yes", ac_cv_c_msg_accrights="no"))
890 if test "$ac_cv_c_msg_accrights" = "yes"
891 then
892     AC_DEFINE(HAVE_MSGHDR_ACCRIGHTS)
893 fi
894
895 dnl *** Check for the sun_len member in struct sockaddr_un
896
897 AC_CACHE_CHECK("for sun_len in struct sockaddr_un", ac_cv_c_sun_len,
898  AC_TRY_COMPILE([#include <sys/types.h>
899 #include <sys/socket.h>
900 #include <sys/un.h>], [static struct sockaddr_un addr; addr.sun_len = 1],
901                 ac_cv_c_sun_len="yes", ac_cv_c_sun_len="no"))
902 if test "$ac_cv_c_sun_len" = "yes"
903 then
904     AC_DEFINE(HAVE_SOCKADDR_SUN_LEN)
905 fi
906
907 dnl *** check for the need to define __i386__
908
909 AC_CACHE_CHECK("whether we need to define __i386__",ac_cv_cpp_def_i386,
910  AC_EGREP_CPP(yes,[#if (defined(i386) || defined(__i386)) && !defined(__i386__)
911 yes
912 #endif],
913  ac_cv_cpp_def_i386="yes", ac_cv_cpp_def_i386="no"))
914 if test "$ac_cv_cpp_def_i386" = "yes"
915 then
916     CFLAGS="$CFLAGS -D__i386__"
917     LINTFLAGS="$LINTFLAGS -D__i386__"
918 fi
919
920 dnl $GCC is set by autoconf
921 GCC_NO_BUILTIN=""
922 if test "$GCC" = "yes"
923 then
924     GCC_NO_BUILTIN="-fno-builtin"
925 fi
926 AC_SUBST(GCC_NO_BUILTIN)
927
928 dnl **** Generate output files ****
929
930 MAKE_RULES=Make.rules
931 AC_SUBST_FILE(MAKE_RULES)
932
933 MAKE_DLL_RULES=dlls/Makedll.rules
934 AC_SUBST_FILE(MAKE_DLL_RULES)
935
936 AC_OUTPUT([
937 Make.rules
938 Makefile
939 console/Makefile
940 controls/Makefile
941 debugger/Makefile
942 dlls/Makedll.rules
943 dlls/Makefile
944 dlls/advapi32/Makefile
945 dlls/avifil32/Makefile
946 dlls/comctl32/Makefile
947 dlls/commdlg/Makefile
948 dlls/crtdll/Makefile
949 dlls/dciman32/Makefile
950 dlls/ddraw/Makefile
951 dlls/dinput/Makefile
952 dlls/display/Makefile
953 dlls/dplayx/Makefile
954 dlls/dsound/Makefile
955 dlls/gdi/Makefile
956 dlls/icmp/Makefile
957 dlls/imagehlp/Makefile
958 dlls/imm32/Makefile
959 dlls/lzexpand/Makefile
960 dlls/mouse/Makefile
961 dlls/mpr/Makefile
962 dlls/msacm/Makefile
963 dlls/msacm32/Makefile
964 dlls/msnet32/Makefile
965 dlls/msvideo/Makefile
966 dlls/ntdll/Makefile
967 dlls/odbc32/Makefile
968 dlls/ole32/Makefile
969 dlls/oleaut32/Makefile
970 dlls/olecli/Makefile
971 dlls/oledlg/Makefile
972 dlls/olepro32/Makefile
973 dlls/olesvr/Makefile
974 dlls/psapi/Makefile
975 dlls/rasapi32/Makefile
976 dlls/setupx/Makefile
977 dlls/shell32/Makefile
978 dlls/sound/Makefile
979 dlls/stress/Makefile
980 dlls/tapi32/Makefile
981 dlls/ttydrv/Makefile
982 dlls/user/Makefile
983 dlls/version/Makefile
984 dlls/win32s/Makefile
985 dlls/win87em/Makefile
986 dlls/winaspi/Makefile
987 dlls/windebug/Makefile
988 dlls/wing/Makefile
989 dlls/winmm/Makefile
990 dlls/winmm/joystick/Makefile
991 dlls/winmm/mcianim/Makefile
992 dlls/winmm/mciavi/Makefile
993 dlls/winmm/mcicda/Makefile
994 dlls/winmm/mciseq/Makefile
995 dlls/winmm/mciwave/Makefile
996 dlls/winmm/midimap/Makefile
997 dlls/winmm/wavemap/Makefile
998 dlls/winmm/wineoss/Makefile
999 dlls/winsock/Makefile
1000 dlls/winspool/Makefile
1001 dlls/ttydrv/Makefile
1002 dlls/x11drv/Makefile
1003 documentation/Makefile
1004 documentation/wine.conf.man
1005 documentation/wine.man
1006 files/Makefile
1007 graphics/Makefile
1008 graphics/enhmetafiledrv/Makefile
1009 graphics/metafiledrv/Makefile
1010 graphics/psdrv/Makefile
1011 graphics/ttydrv/Makefile
1012 graphics/win16drv/Makefile
1013 graphics/x11drv/Makefile
1014 if1632/Makefile
1015 include/Makefile
1016 library/Makefile
1017 libtest/Makefile
1018 loader/Makefile
1019 loader/ne/Makefile
1020 loader/dos/Makefile
1021 memory/Makefile
1022 misc/Makefile
1023 miscemu/Makefile
1024 msdos/Makefile
1025 objects/Makefile
1026 ole/Makefile
1027 programs/Makefile
1028 programs/clock/Makefile
1029 programs/cmdlgtst/Makefile
1030 programs/control/Makefile
1031 programs/avitools/Makefile
1032 programs/osversioncheck/Makefile
1033 programs/notepad/Makefile
1034 programs/progman/Makefile
1035 programs/regtest/Makefile
1036 programs/regapi/Makefile
1037 programs/view/Makefile
1038 programs/wcmd/Makefile
1039 programs/winemine/Makefile
1040 programs/winhelp/Makefile
1041 programs/winver/Makefile
1042 rc/Makefile
1043 relay32/Makefile
1044 resources/Makefile
1045 scheduler/Makefile
1046 server/Makefile
1047 tools/Makefile
1048 tools/wrc/Makefile
1049 tsx11/Makefile
1050 win32/Makefile
1051 windows/Makefile
1052 windows/ttydrv/Makefile
1053 windows/x11drv/Makefile ])
1054
1055 if test "$have_x" = "no"
1056 then
1057   echo
1058   echo "*** Warning: X development files not found. Wine will be built without"
1059   echo "*** X support, which currently does not work, and would probably not be"
1060   echo "*** what you want anyway. You will need to install devel packages of"
1061   echo "*** Xlib/Xfree86 and Xpm at the very least."
1062 elif test "$ac_cv_lib_Xpm_XpmCreatePixmapFromData" = "no"
1063 then
1064   echo
1065   echo "*** Warning: Xpm development files not found. Wine will be built without"
1066   echo "*** Xpm support, which currently does not work. You will need to install"
1067   echo "*** devel packages of Xpm."
1068 fi
1069
1070 if test "$ac_cv_lib_ncurses_resizeterm" = "no" -a "$ac_cv_lib_ncurses_waddch" = "yes"
1071 then
1072   echo
1073   echo "*** Warning: resizeterm not found in ncurses. Wine will be built without"
1074   echo "*** terminal resize support. Consider upgrading ncurses."
1075 fi
1076
1077 if test "$wine_cv_libc_reentrant" = "no" 
1078 then
1079   echo
1080   echo "*** Warning: non-reentrant libc detected. Wine will be build without"
1081   echo "*** thread support. Consider upgrading libc to a more recent"
1082   echo "*** reentrant version of libc."
1083 fi
1084
1085 if test "$wine_cv_mesa_version_OK" = "no"
1086 then
1087   echo
1088   echo "*** Warning: old Mesa headers detected. Wine will be built without Direct3D"
1089   echo "*** support. Consider upgrading your Mesa libraries (http://www.mesa3d.org/)"
1090 fi
1091
1092 echo
1093 echo "Configure finished.  Do 'make depend && make' to compile Wine."
1094 echo
1095
1096 dnl Local Variables:
1097 dnl comment-start: "dnl "
1098 dnl comment-end: ""
1099 dnl comment-start-skip: "\\bdnl\\b\\s *"
1100 dnl compile-command: "autoconf"
1101 dnl End: