Always close fd when reading super block.
[wine] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 dnl Original author: Michael Patra
3 dnl See ChangeLog file for detailed change history.
4
5 m4_define(WINE_VERSION,regexp(m4_include(VERSION),[version \([-.0-9A-Za-z]+\)],[\1]))
6
7 AC_PREREQ(2.53)
8 AC_INIT([Wine],WINE_VERSION)
9 AC_CONFIG_SRCDIR(server/atom.c)         
10 AC_CONFIG_HEADERS(include/config.h)
11 AC_CONFIG_AUX_DIR(tools)
12
13 dnl **** Command-line arguments ****
14
15 dnl Default values
16 LIBEXT=so       # library type .so or .a
17
18 AC_ARG_ENABLE(debug, AC_HELP_STRING([--disable-debug],[compile out all debugging messages]))
19 AC_ARG_ENABLE(trace, AC_HELP_STRING([--disable-trace],[compile out TRACE messages]))
20 AC_ARG_ENABLE(opengl,AC_HELP_STRING([--enable-opengl],[force usage of OpenGL even if the latter is thread-safe via pthread]))
21 AC_ARG_WITH(curses,     AC_HELP_STRING([--without-curses],[do not use curses]))
22 AC_ARG_WITH(reentrant-x,AC_HELP_STRING([--without-reentrant-x],[compile for use with non-reentrant X libraries]))
23
24 AC_SUBST(OPTIONS)
25 if test "x$enable_debug" = "xno"
26 then
27     AC_DEFINE(NO_DEBUG_MSGS,1,[Define to disable all debug messages.])
28 fi
29 if test "x$enable_trace" = "xno" -o "x$enable_debug" = "xno"
30 then
31     AC_DEFINE(NO_TRACE_MSGS,1,[Define to disable trace messages.])
32 fi
33
34 dnl **** Check for some programs ****
35
36 AC_CANONICAL_TARGET
37 AC_PROG_MAKE_SET
38 AC_PROG_CC
39 AC_PROG_CPP
40 AC_PATH_XTRA
41 AC_PROG_YACC
42 AC_PROG_LEX
43
44 dnl **** Just additional warning checks, since AC_PROG just sets 'yacc' even
45 dnl **** without one present.
46 AC_CHECK_PROGS(XYACC,$YACC bison yacc,none)
47 if test "$XYACC" = "none"
48 then
49   AC_MSG_ERROR([no suitable bison/yacc found. Please install the 'bison' package.])
50 fi
51 AC_CHECK_PROGS(XLEX,$LEX flex lex,none)
52 if test "$XLEX" = "none"
53 then
54   AC_MSG_ERROR([no suitable lex found. Please install the 'flex' package.])
55 fi
56 AC_PROG_RANLIB
57 AC_PROG_INSTALL
58 AC_PROG_LN_S
59 AC_CHECK_PROG(C2MAN,c2man,c2man,\$(TOPSRCDIR)/tools/c2man.pl)
60 AC_PATH_PROG(LDCONFIG, ldconfig, true, [/sbin /usr/sbin $PATH])
61
62 dnl Check for lint
63 AC_CHECK_PROGS(LINT, lclint lint)
64 if test "$LINT" = "lint"
65 then
66   LINTFLAGS="$LINTFLAGS -errchk=%all,no%longptr64 -errhdr=%user -Ncheck=macro -Nlevel=4"
67   dnl LINTFLAGS='-D_SIZE_T "-Dsize_t=unsigned long" -errchk=longptr64'
68 fi
69 AC_SUBST(LINT)
70 AC_SUBST(LINTFLAGS)
71
72 case $host_os in
73   *cygwin*) LDCOMBINE="ld -r --enable-stdcall-fixup" ;;
74          *) LDCOMBINE="ld -r" ;;
75 esac
76 AC_SUBST(LDCOMBINE)
77
78 dnl **** Check for some libraries ****
79
80 dnl Check for -lm
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_FUNCS(iswalnum,,AC_CHECK_LIB(w,iswalnum))
88 dnl Check for -lnsl for Solaris
89 AC_CHECK_FUNCS(gethostbyname,,AC_CHECK_LIB(nsl,gethostbyname))
90 dnl Check for -lsocket for Solaris
91 AC_CHECK_FUNCS(connect,,AC_CHECK_LIB(socket,connect))
92 dnl Check for -lresolv for Solaris
93 AC_CHECK_FUNCS(inet_aton,,AC_CHECK_LIB(resolv,inet_aton))
94 dnl Check for -lxpg4 for FreeBSD
95 AC_CHECK_LIB(xpg4,_xpg4_setrunelocale)
96 dnl Check for -lmmap for OS/2
97 AC_CHECK_LIB(mmap,mmap)
98
99 dnl Check for openpty
100 UTILLIBS=""
101 AC_SUBST(UTILLIBS)
102 AC_CHECK_FUNCS(openpty,,
103         [AC_CHECK_LIB(util,openpty,
104                 [AC_DEFINE(HAVE_OPENPTY)
105                 UTILLIBS="-lutil"]
106         )])
107
108 DLLIBS=""
109 AC_SUBST(DLLIBS)
110 AC_CHECK_HEADERS(dlfcn.h,
111     [AC_CHECK_FUNCS(dlopen,,
112         [AC_CHECK_LIB(dl,dlopen,
113                      [AC_DEFINE(HAVE_DLOPEN,1,[Define if you have dlopen])
114                      DLLIBS="-ldl"],
115                      LIBEXT="a")]
116         )],
117         LIBEXT="a"
118     )
119
120 JPEGLIB=""
121 AC_SUBST(JPEGLIB)
122 AC_CHECK_HEADERS(jpeglib.h,
123     AC_CHECK_LIB(jpeg,jpeg_start_decompress,
124         AC_DEFINE(HAVE_LIBJPEG,1,[Define if you have libjpeg including devel headers])
125         JPEGLIB="-ljpeg"
126     )
127 )
128
129
130 AC_SUBST(XLIB)
131 AC_SUBST(XFILES)
132 XFILES=""
133 AC_SUBST(OPENGLFILES)
134 OPENGLFILES=""
135 AC_SUBST(GLU32FILES)
136 GLU32FILES=""
137 if test "$have_x" = "yes"
138 then
139     XLIB="-lXext -lX11"
140     ac_save_CPPFLAGS="$CPPFLAGS"
141     CPPFLAGS="$CPPFLAGS $X_CFLAGS"
142
143     dnl *** All of the following tests require X11/Xlib.h
144     AC_CHECK_HEADERS(X11/Xlib.h,
145       [
146         dnl *** Check for X keyboard extension
147         AC_CHECK_HEADERS(X11/XKBlib.h,
148             [ dnl *** If X11/XKBlib.h exists...
149               AC_CHECK_LIB(X11, XkbQueryExtension,
150               AC_DEFINE(HAVE_XKB, 1, [Define if you have the XKB extension]),,
151               $X_LIBS -lXext -lX11 $X_EXTRA_LIBS)
152             ],
153             AC_MSG_WARN([[Xkb extension not found, Wine will be built without it]])
154         )
155
156         dnl *** Check for X Shm extension
157         AC_CHECK_HEADERS(X11/extensions/XShm.h,
158             [ dnl *** If X11/extensions/XShm.h exists...
159               AC_CHECK_LIB(Xext, XShmQueryExtension,
160               AC_DEFINE(HAVE_LIBXXSHM, 1, [Define if you have the X Shm extension]),,
161               $X_LIBS -lXext -lX11 $X_EXTRA_LIBS)
162             ],
163             AC_MSG_WARN([[XShm extension not found, Wine will be built without it]]),
164             [#include <X11/Xlib.h>])
165
166         dnl *** Check for X shape extension
167         AC_CHECK_HEADERS(X11/extensions/shape.h,
168             [ dnl *** If X11/extensions/shape.h exists...
169               AC_CHECK_LIB(Xext,XShapeQueryExtension,
170               AC_DEFINE(HAVE_LIBXSHAPE, 1, [Define if you have the X Shape extension]),,
171               $X_LIBS -lXext -lX11 $X_EXTRA_LIBS)
172             ],
173             AC_MSG_WARN([[XShape extension not found, Wine will be built without it]]),
174             [#include <X11/Xlib.h>])
175         
176         dnl *** Check for XFree86 DGA / DGA 2.0 extension
177         AC_CHECK_HEADERS(X11/extensions/xf86dga.h,
178             [ dnl *** If X11/extensions/xf86dga.h exists, check 
179               dnl *** for XDGAQueryExtension()...
180               AC_CHECK_LIB(Xxf86dga, XDGAQueryExtension,
181                 [ dnl *** If found...
182                   AC_DEFINE(HAVE_LIBXXF86DGA2, 1,
183                             [Define if you have the Xxf86dga library version 2])
184                   X_PRE_LIBS="$X_PRE_LIBS -lXxf86dga"
185                ],
186                 [ dnl *** If not found, look for XF86DGAQueryExtension()
187                   dnl *** instead (DGA 2.0 not found)...
188                   AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension,
189                     [ AC_DEFINE(HAVE_LIBXXF86DGA, 1,
190                                 [Define if you have the Xxf86dga library version 1])
191                       X_PRE_LIBS="$X_PRE_LIBS -lXxf86dga"
192                     ],,
193                     $X_LIBS -lXext -lX11 $X_EXTRA_LIBS
194                   )
195                 ],
196                 $X_LIBS -lXext -lX11 $X_EXTRA_LIBS
197               )
198             ],
199             AC_MSG_WARN([[DGA extension not found, Wine will be built without it]]),
200             [#include <X11/Xlib.h>])
201
202         dnl *** Check for XFree86 VMODE extension
203         AC_CHECK_HEADERS(X11/extensions/xf86vmode.h,
204             [ dnl *** If X11/extensions/xf86vmode.h exists...
205                 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension,
206                   [ AC_DEFINE(HAVE_LIBXXF86VM, 1, [Define if you have the Xxf86vm library])
207                      X_PRE_LIBS="$X_PRE_LIBS -lXxf86vm"
208                   ],,
209                   $X_LIBS -lXext -lX11 $X_EXTRA_LIBS
210                 )
211             ],
212             AC_MSG_WARN([[XFree86 VMODE extension not found, Wine will be built without it]]),
213             [#include <X11/Xlib.h>])
214
215         dnl *** Check for XVideo extension supporting XvImages
216         AC_CHECK_HEADERS(X11/extensions/Xvlib.h,
217             [ dnl *** If X11/extensions/Xvlib.h exists...
218                 AC_CHECK_LIB(Xv, XvShmCreateImage,
219                   [ AC_DEFINE(HAVE_XVIDEO, 1, [Define if the X libraries support XVideo])
220                      X_PRE_LIBS="$X_PRE_LIBS -lXv"
221                   ],,
222                   $X_LIBS -lXext -lX11 $X_EXTRA_LIBS
223                 )
224             ],
225             AC_MSG_WARN([[XVideo extension not found, Wine will be built without it]]),
226             [#include <X11/Xlib.h>])
227
228         dnl *** Check for XRender extension
229         AC_CHECK_HEADERS(X11/extensions/Xrender.h,
230             [ dnl *** If X11/extensions/Xrender.h exists...
231                 AC_CHECK_LIB(Xrender, XRenderQueryExtension,
232                   [ AC_DEFINE(HAVE_LIBXRENDER, 1, [Define if you have the XRender extension library])
233                      X_PRE_LIBS="$X_PRE_LIBS -lXrender"
234                   ],,
235                   $X_LIBS -lXext -lX11 $X_EXTRA_LIBS
236                 )
237             ],
238             AC_MSG_WARN([[XRender extension not found, Wine will be built without it]]),
239             [#include <X11/Xlib.h>])
240
241       ]
242     ) dnl *** End of X11/Xlib.h check
243
244     dnl Check for the presence of OpenGL
245     if test "x$enable_opengl" != "xno"
246     then
247         if test -f /usr/X11R6/lib/libGL.a -a ! -f /usr/X11R6/lib/libGL.so
248         then
249             AC_MSG_ERROR([/usr/X11R6/lib/libGL.a is present on your system.
250 This prevents linking to OpenGL. Delete the file and restart configure.])
251         fi
252
253         AC_CHECK_HEADERS(GL/gl.h GL/glx.h)
254         if test "$ac_cv_header_GL_gl_h" = "yes" -a "$ac_cv_header_GL_glx_h" = "yes"
255         then
256             AC_CHECK_HEADERS(GL/glext.h,,,[#include <GL/glx.h>])
257             dnl Check for some problems due to old Mesa versions
258             AC_CACHE_CHECK([for up-to-date OpenGL version], wine_cv_opengl_version_OK,
259               AC_TRY_COMPILE(
260                 [#include <GL/gl.h>],
261                 [GLenum test = GL_UNSIGNED_SHORT_5_6_5;],
262                 [wine_cv_opengl_version_OK="yes"],
263                 [wine_cv_opengl_version_OK="no"]
264               )
265             )
266
267             dnl Check for the thread-safety of the OpenGL library
268             AC_CACHE_CHECK([for thread-safe OpenGL version], 
269                            wine_cv_opengl_version_threadsafe,
270               [saved_libs=$LIBS
271                LIBS="$X_LIBS -lGL"
272                AC_TRY_LINK([],[pthread_getspecific();],
273                               [wine_cv_opengl_version_threadsafe="yes"],
274                               [wine_cv_opengl_version_threadsafe="no"])
275                LIBS=$saved_libs]
276             )
277
278             if test "$wine_cv_opengl_version_OK" = "yes" -a \( "$wine_cv_opengl_version_threadsafe" = "no" -o "x$enable_opengl" = "xyes" \)
279             then
280                 dnl Check for the presence of the library
281                 AC_CHECK_LIB(GL,glXCreateContext,
282                              X_PRE_LIBS="$X_PRE_LIBS -lGL"
283                              ,,
284                              $X_LIBS -lXext -lX11 -lm $X_EXTRA_LIBS)
285
286                 if test "$ac_cv_lib_GL_glXCreateContext" = "yes"
287                 then
288                         OPENGLFILES='$(OPENGLFILES)'
289                         AC_DEFINE(HAVE_OPENGL, 1, [Define if OpenGL is present on the system])
290
291                         AC_CHECK_LIB(GL,glXGetProcAddressARB,
292                                      AC_DEFINE(HAVE_GLX_GETPROCADDRESS, 1,
293                                                [Define if the OpenGL library supports the glXGetProcAddressARB call]),,
294                                      $X_LIBS -lXext -lX11 -lm $X_EXTRA_LIBS)
295
296                         if test "$ac_cv_lib_GL_glXGetProcAddressARB" = "yes"
297                         then
298                                AC_CACHE_CHECK([for OpenGL extension functions prototypes], wine_cv_extension_prototypes,
299                                   [AC_TRY_COMPILE([#include <GL/gl.h>
300                                                   #ifdef HAVE_GL_GLEXT_H
301                                                   # include <GL/glext.h>
302                                                   #endif
303                                                   ],
304                                                  [PFNGLCOLORTABLEEXTPROC test_proc;],
305                                                  [wine_cv_extension_prototypes="yes"],
306                                                  [wine_cv_extension_prototypes="no"]
307                                   )]
308                                 )
309                                 if test "$wine_cv_extension_prototypes" = "yes"
310                                 then
311                                     AC_DEFINE(HAVE_GLEXT_PROTOTYPES, 1,
312                                               [Define if the OpenGL headers define extension typedefs])
313                                 fi
314                         fi
315
316                 fi
317                 dnl Check for GLU32 library.
318                 AC_CHECK_LIB(GLU,gluLookAt,
319                              [X_PRE_LIBS="$X_PRE_LIBS -lGLU"
320                              GLU32FILES='$(GLU32FILES)']
321                              ,,
322                              $X_LIBS $X_PRE_LIBS -lXext -lX11 -lm $X_EXTRA_LIBS
323                 )
324              fi
325          fi
326     fi
327
328     CPPFLAGS="$ac_save_CPPFLAGS"
329     XFILES='$(XFILES)'
330 else
331     XLIB=""
332     X_CFLAGS=""
333     X_LIBS=""
334 fi
335
336 dnl **** Check which curses lib to use ***
337 CURSESLIBS=""
338 if test "x$with_curses" != "xno"
339 then
340     AC_CHECK_HEADERS(ncurses.h,
341         [AC_CHECK_LIB(ncurses,waddch,
342             [AC_DEFINE(HAVE_LIBNCURSES, 1, [Define if you have the ncurses library (-lncurses)])
343              CURSESLIBS="-lncurses"],
344              [AC_CHECK_HEADERS(curses.h,
345                  [AC_CHECK_LIB(curses,waddch,
346                      [AC_DEFINE(HAVE_LIBCURSES, 1, [Define if you have the curses library (-lcurses)])
347                       CURSESLIBS="-lcurses"])])])])
348     saved_libs="$LIBS"
349     LIBS="$CURSESLIBS $LIBS"
350     AC_CHECK_FUNCS(getbkgd resizeterm)
351     LIBS="$saved_libs"
352 fi
353 AC_SUBST(CURSESLIBS)
354
355 CUPSLIBS=""
356 dnl **** Check for CUPS ****
357 wine_cv_warn_cups_h=no
358 AC_CHECK_LIB(cups,cupsGetPPD,
359         [AC_CHECK_HEADER(cups/cups.h,
360             [AC_DEFINE(HAVE_CUPS, 1, [Define if we have CUPS])
361             CUPSLIBS="-lcups"],
362             wine_cv_warn_cups_h=yes)]
363 )
364 AC_SUBST(CUPSLIBS)
365
366 dnl **** Check for SANE ****
367 AC_CHECK_PROG(sane_devel,sane-config,sane-config,no)
368 if test "$sane_devel" = "no"
369 then
370     SANELIBS=""
371     SANEINCL=""
372 else
373     SANELIBS="`$sane_devel --libs`"
374     SANEINCL="`$sane_devel --cflags`"
375     ac_save_CPPFLAGS="$CPPFLAGS"
376     ac_save_LIBS="$LIBS"
377     CPPFLAGS="$CPPFLAGS $SANEINCL"
378     LIBS="$LIBS $SANELIBS"
379     AC_CHECK_HEADER(sane/sane.h,
380                     [AC_CHECK_LIB(sane,sane_open,
381                                   [AC_DEFINE(HAVE_SANE, 1, [Define if we have SANE development environment])],
382                                   [SANELIBS=""
383                                   SANEINCL=""])],
384                     [SANELIBS=""
385                     SANEINCL=""])
386     LIBS="$ac_save_LIBS"
387     CPPFLAGS="$ac_save_CPPFLAGS"
388 fi
389 AC_SUBST(SANELIBS)
390 AC_SUBST(SANEINCL)
391
392 dnl **** Check for FreeType 2 ****
393 AC_CHECK_LIB(freetype,FT_Init_FreeType,ft_lib=yes,ft_lib=no,$X_LIBS)
394 if test "$ft_lib" = "no"
395 then
396     FREETYPEINCL=""
397     wine_cv_msg_freetype=no
398 else
399     AC_CHECK_PROG(ft_devel,freetype-config,freetype-config,no)
400     if test "$ft_devel" = "no"
401     then
402         AC_CHECK_PROG(ft_devel2,freetype2-config,freetype2-config,no)
403         if test "$ft_devel2" = "freetype2-config"
404         then
405                 ft_devel=$ft_devel2
406         fi
407     fi
408     if test "$ft_devel" = "no"
409     then
410         FREETYPEINCL=""
411         wine_cv_msg_freetype=yes
412     else
413         FREETYPEINCL=`$ft_devel --cflags`
414         ac_save_CPPFLAGS="$CPPFLAGS"
415         CPPFLAGS="$FREETYPEINCL $CPPFLAGS"
416         AC_CHECK_HEADERS(freetype/freetype.h \
417                          freetype/ftglyph.h \
418                          freetype/tttables.h \
419                          freetype/ftnames.h \
420                          freetype/ftsnames.h \
421                          freetype/ttnameid.h \
422                          freetype/ftoutln.h \
423                          freetype/internal/sfnt.h)
424         AC_TRY_CPP([#include <ft2build.h>
425                     #include <freetype/fttrigon.h>],
426                     [AC_DEFINE(HAVE_FREETYPE_FTTRIGON_H, 1,
427           [Define if you have the <freetype/fttrigon.h> header file.])
428                     wine_cv_fttrigon=yes],
429                     wine_cv_fttrigon=no)
430         CPPFLAGS="$ac_save_CPPFLAGS"
431         dnl Check that we have at least freetype/freetype.h
432         if test "$ac_cv_header_freetype_freetype_h" = "yes" -a "$wine_cv_fttrigon" = "yes"
433         then
434             AC_DEFINE(HAVE_FREETYPE, 1, [Define if FreeType 2 is installed])
435             wine_cv_msg_freetype=no
436         else
437             FREETYPEINCL=""
438             wine_cv_msg_freetype=yes
439         fi
440     fi
441 fi
442 AC_SUBST(FREETYPEINCL)
443
444 dnl **** Check for parport (currently Linux only) ****
445 AC_CACHE_CHECK([for parport header/ppdev.h], ac_cv_c_ppdev,
446  AC_TRY_COMPILE(
447    [#include <linux/ppdev.h>],
448    [ioctl (1,PPCLAIM,0)],
449    [ac_cv_c_ppdev="yes"],
450    [ac_cv_c_ppdev="no"])
451  )
452 if test "$ac_cv_c_ppdev" = "yes"
453 then
454     AC_DEFINE(HAVE_PPDEV, 1, [Define if we can use ppdev.h for parallel port access])
455 fi
456
457 dnl **** Check for IPX (currently Linux only) ****
458 AC_CACHE_CHECK([for GNU style IPX support], ac_cv_c_ipx_gnu,
459  AC_TRY_COMPILE(
460    [#include <sys/socket.h>
461     #include <netipx/ipx.h>],
462    [((struct sockaddr_ipx *)0)->sipx_family == AF_IPX],
463    [ac_cv_c_ipx_gnu="yes"],
464    [ac_cv_c_ipx_gnu="no"])
465  )
466 if test "$ac_cv_c_ipx_gnu" = "yes"
467 then
468     AC_DEFINE(HAVE_IPX_GNU, 1, [Define if IPX should use netipx/ipx.h from libc])
469 fi
470
471 if test "$ac_cv_c_ipx_gnu" = "no"
472 then
473  AC_CACHE_CHECK([for linux style IPX support], ac_cv_c_ipx_linux,
474   AC_TRY_COMPILE(
475     [#include <sys/socket.h>
476      #include <asm/types.h>
477      #include <linux/ipx.h>],
478     [((struct sockaddr_ipx *)0)->sipx_family == AF_IPX],
479     [ac_cv_c_ipx_linux="yes"],
480     [ac_cv_c_ipx_linux="no"])
481   )
482   if test "$ac_cv_c_ipx_linux" = "yes"
483   then
484       AC_DEFINE(HAVE_IPX_LINUX, 1, [Define if IPX includes are taken from Linux kernel])
485   fi
486 fi
487
488 dnl **** Check for Open Sound System ****
489 AC_CHECK_HEADERS(sys/soundcard.h machine/soundcard.h soundcard.h, break)
490
491 AC_CACHE_CHECK([for Open Sound System],
492         ac_cv_c_opensoundsystem,
493         AC_TRY_COMPILE([
494         #if defined(HAVE_SYS_SOUNDCARD_H)
495                 #include <sys/soundcard.h>
496         #elif defined(HAVE_MACHINE_SOUNDCARD_H)
497                 #include <machine/soundcard.h>
498         #elif defined(HAVE_SOUNDCARD_H)
499                 #include <soundcard.h>
500         #endif
501         ],[
502
503 /* check for one of the Open Sound System specific SNDCTL_ defines */
504 #if !defined(SNDCTL_DSP_STEREO)
505 #error No open sound system
506 #endif
507 ],ac_cv_c_opensoundsystem="yes",ac_cv_c_opensoundsystem="no"))
508
509 if test "$ac_cv_c_opensoundsystem" = "yes"
510 then
511     AC_DEFINE(HAVE_OSS, 1, [Define if you have the Open Sound system])
512 fi
513
514 AC_CACHE_CHECK([for Open Sound System/MIDI interface],
515         ac_cv_c_opensoundsystem_midi,
516         AC_TRY_COMPILE([
517         #if defined(HAVE_SYS_SOUNDCARD_H)
518                 #include <sys/soundcard.h>
519         #elif defined(HAVE_MACHINE_SOUNDCARD_H)
520                 #include <machine/soundcard.h>
521         #elif defined(HAVE_SOUNDCARD_H)
522                 #include <soundcard.h>
523         #endif
524         ],[
525
526 /* check for one of the Open Sound System specific SNDCTL_SEQ defines */
527 #if !defined(SNDCTL_SEQ_SYNC)
528 #error No open sound system MIDI interface
529 #endif
530 ],ac_cv_c_opensoundsystem_midi="yes",ac_cv_c_opensoundsystem_midi="no"))
531
532 if test "$ac_cv_c_opensoundsystem_midi" = "yes"
533 then
534     AC_DEFINE(HAVE_OSS_MIDI, 1, [Define if you have the Open Sound system (MIDI interface)])
535 fi
536
537 dnl **** Check for aRts Sound Server ****
538 AC_PATH_PROG(ARTSCCONFIG, artsc-config)
539 AC_CACHE_CHECK([for aRts Sound server],
540         ac_cv_c_artsserver,
541         if test x$ARTSCCONFIG = x -o x$ARTSCCONFIG = x'"$ARTSCCONFIG"';
542         then
543             ac_cv_c_artsserver=no
544         else
545             ARTSC_CFLAGS=`$ARTSCCONFIG --cflags`
546             ARTSC_LIBS=`$ARTSCCONFIG --libs`
547             ac_cv_c_artsserver=no
548             save_CFLAGS="$CFLAGS"
549             CFLAGS="$CFLAGS $ARTSC_CFLAGS"
550             AC_TRY_COMPILE([
551              #include <artsc.h>
552             ],[
553              arts_stream_t stream;
554             ],[
555             ac_cv_c_artsserver=yes
556             ])
557             CFLAGS="$save_CFLAGS"
558         fi)
559
560 if test "$ac_cv_c_artsserver" = "yes"
561 then
562     AC_SUBST(ARTSLIBS, $ARTSC_LIBS)
563     AC_SUBST(ARTSINCL, $ARTSC_CFLAGS)
564
565     AC_DEFINE(HAVE_ARTS, 1, [Define if you have ARTS sound server])
566 fi
567
568 dnl **** Check for broken glibc mmap64 ****
569
570 AC_CACHE_CHECK( [whether mmap64 works defined as mmap], ac_cv_mmap64_works,
571         AC_TRY_RUN([
572                 #define _FILE_OFFSET_BITS 64
573                 #include <stdio.h>
574                 #include <unistd.h>
575                 #include <fcntl.h>
576                 #include <sys/mman.h>
577                 #include <errno.h>
578
579                 int main(int argc,char **argv) {
580                         int fd = open("conftest.map",O_CREAT|O_RDWR,0600);
581                         if (fd == -1) exit(1);
582
583                         unlink("conftest.map");
584
585                         write(fd,"test",4);
586
587                         if ((-1 == mmap(0,4,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0)) &&
588                             (errno == EINVAL)
589                         ) {
590                                 exit(1);
591                         }
592                         close(fd);
593                         fprintf(stderr,"success!\n");
594                         exit(0);
595                 }
596
597         ],
598     ac_cv_mmap64_works="yes",
599     ac_cv_mmap64_works="no",
600     ac_cv_mmap64_works="no") )
601
602 if test "$ac_cv_mmap64_works" = "yes"
603 then
604     AC_DEFINE(_FILE_OFFSET_BITS, 64, [Set this to 64 to enable 64-bit file support on Linux])
605 fi
606
607 dnl **** Check for gcc strength-reduce bug ****
608
609 if test "x${GCC}" = "xyes"
610 then
611   CFLAGS="$CFLAGS -Wall"
612   AC_CACHE_CHECK( [for gcc strength-reduce bug], ac_cv_c_gcc_strength_bug,
613                   AC_TRY_RUN([
614 int     L[[4]] = {0,1,2,3};
615 int main(void) {
616   static int Array[[3]];
617   unsigned int B = 3;
618   int i;
619   for(i=0; i<B; i++) Array[[i]] = i - 3;
620   for(i=0; i<4 - 1; i++) L[[i]] = L[[i + 1]];
621   L[[i]] = 4;
622   
623   exit( Array[[1]] != -2 || L[[2]] != 3);
624 }],
625     ac_cv_c_gcc_strength_bug="no",
626     ac_cv_c_gcc_strength_bug="yes",
627     ac_cv_c_gcc_strength_bug="yes") )
628   if test "$ac_cv_c_gcc_strength_bug" = "yes"
629   then
630     CFLAGS="$CFLAGS -fno-strength-reduce"
631   fi
632
633   dnl Check for -mpreferred-stack-boundary
634   AC_CACHE_CHECK([for gcc -mpreferred-stack-boundary=2 support],
635                  ac_cv_c_gcc_stack_boundary,
636   [saved_cflags=$CFLAGS
637   CFLAGS="$CFLAGS -mpreferred-stack-boundary=2"
638   AC_TRY_COMPILE(,[return 0],ac_cv_c_gcc_stack_boundary="yes",ac_cv_c_gcc_stack_boundary="no")
639   CFLAGS=$saved_cflags
640   ])
641   if test "$ac_cv_c_gcc_stack_boundary" = "yes"
642   then
643     CFLAGS="$CFLAGS -mpreferred-stack-boundary=2"
644   fi
645 fi
646
647 dnl **** Check if we need to place .type inside a .def directive ****
648
649 AC_CACHE_CHECK([whether .type must sit inside a .def directive],
650                ac_cv_c_type_in_def,
651 [saved_libs=$LIBS
652 LIBS="conftest_asm.s $LIBS"
653 cat > conftest_asm.s <<EOF
654         .globl _ac_test
655         .def _ac_test; .scl 2; .type 32; .endef
656 _ac_test:
657         .long 0
658 EOF
659 AC_TRY_LINK(,,ac_cv_c_type_in_def="yes",ac_cv_c_type_in_def="no")
660 LIBS=$saved_libs])
661 if test "$ac_cv_c_type_in_def" = "yes"
662 then
663   AC_DEFINE(NEED_TYPE_IN_DEF, 1, [Define if .type asm directive must be inside a .def directive])
664 fi
665  
666 dnl **** Check for underscore on external symbols ****
667
668 AC_CACHE_CHECK([whether external symbols need an underscore prefix],
669                ac_cv_c_extern_prefix,
670 [saved_libs=$LIBS
671 LIBS="conftest_asm.s $LIBS"
672 cat > conftest_asm.s <<EOF
673         .globl _ac_test
674 _ac_test:
675         .long 0
676 EOF
677 AC_TRY_LINK([extern int ac_test;],[if (ac_test) return 1],
678             ac_cv_c_extern_prefix="yes",ac_cv_c_extern_prefix="no")
679 LIBS=$saved_libs])
680 if test "$ac_cv_c_extern_prefix" = "yes"
681 then
682   AC_DEFINE(NEED_UNDERSCORE_PREFIX, 1,
683             [Define if symbols declared in assembly code need an underscore prefix])
684 fi
685
686 dnl **** Check whether stdcall symbols need to be decorated ****
687
688 AC_CACHE_CHECK([whether stdcall symbols need to be decorated],
689                ac_cv_c_stdcall_decoration,
690 [saved_libs=$LIBS
691 LIBS="conftest_asm.s $LIBS"
692 if test "$ac_cv_c_extern_prefix" = "yes"
693 then
694 cat > conftest_asm.s <<EOF
695         .globl _ac_test@0
696 _ac_test@0:
697 EOF
698 else
699 cat > conftest_asm.s <<EOF
700         .globl ac_test@0
701 ac_test@0:
702 EOF
703 fi
704 AC_TRY_LINK([extern void __attribute__((__stdcall__)) ac_test(void);],
705             [ac_test(); return 0],
706             ac_cv_c_stdcall_decoration="yes",ac_cv_c_stdcall_decoration="no")
707 LIBS=$saved_libs])
708 if test "$ac_cv_c_stdcall_decoration" = "yes"
709 then
710   AC_DEFINE(NEED_STDCALL_DECORATION, 1,
711             [Define if stdcall symbols need to be decorated])
712 fi
713
714 dnl **** Check for .string in assembler ****
715
716 AC_CACHE_CHECK([whether assembler accepts .string],
717                ac_cv_c_asm_string,
718 [saved_libs=$LIBS
719 LIBS="conftest_asm.s $LIBS"
720 cat > conftest_asm.s <<EOF
721         .string "test"
722 EOF
723 AC_TRY_LINK(,,ac_cv_c_asm_string="yes",ac_cv_c_asm_string="no")
724 LIBS=$saved_libs])
725 if test "$ac_cv_c_asm_string" = "yes"
726 then
727   AC_DEFINE(HAVE_ASM_STRING, 1, [Define to use .string instead of .ascii])
728 fi
729
730 dnl **** Check for working dll ****
731
732 LDSHARED=""
733 LDDLLFLAGS=""
734 if test "$LIBEXT" = "so"
735 then
736   AC_CACHE_CHECK([whether we can build a GNU style ELF dll],
737                  ac_cv_c_dll_gnuelf,
738   [saved_cflags=$CFLAGS
739   CFLAGS="$CFLAGS -fPIC -shared -Wl,-soname,conftest.so.1.0,-Bsymbolic"
740   AC_TRY_LINK(,[return 1],ac_cv_c_dll_gnuelf="yes",ac_cv_c_dll_gnuelf="no")
741   CFLAGS=$saved_cflags
742   ])
743   if test "$ac_cv_c_dll_gnuelf" = "yes"
744   then
745     LDSHARED="\$(CC) -shared \$(SONAME:%=-Wl,-soname,%)"
746     LDDLLFLAGS="-Wl,-Bsymbolic"
747   else
748     AC_CACHE_CHECK(whether we can build a UnixWare (Solaris) dll,
749                  ac_cv_c_dll_unixware,
750     [saved_cflags=$CFLAGS
751     CFLAGS="$CFLAGS -fPIC -Wl,-G,-h,conftest.so.1.0,-B,symbolic"
752     AC_TRY_LINK(,[return 1],ac_cv_c_dll_unixware="yes",ac_cv_c_dll_unixware="no")
753     CFLAGS=$saved_cflags
754     ])
755     if test "$ac_cv_c_dll_unixware" = "yes"
756     then
757       LDSHARED="\$(CC) -Wl,-G \$(SONAME:%=-Wl,-h,%)"
758       LDDLLFLAGS="-Wl,-B,symbolic"
759     fi
760   fi
761   if test "$ac_cv_c_dll_gnuelf" = "no" -a "$ac_cv_c_dll_unixware" = "no"
762   then
763     LIBEXT="a"
764     AC_CHECK_PROG(DLLWRAP,dllwrap,dllwrap,false)
765     if test "$DLLWRAP" = "dllwrap"; then
766       dnl FIXME - check whether dllwrap works correctly...
767       case $host_os in
768         *cygwin*)
769             LIBEXT="dll"
770             ;;
771       esac
772     fi
773   fi
774 fi
775
776 if test "$LIBEXT" = "a"; then
777   AC_MSG_ERROR(
778 [could not find a way to build shared libraries.
779 It is currently not possible to build Wine without shared library
780 (.so) support to allow transparent switch between .so and .dll files.
781 If you are using Linux, you will need a newer binutils.]
782 )
783 fi
784
785 DLLFLAGS=""
786 LDPATH=""
787
788 if test "$LIBEXT" = "so"; then
789     DLLFLAGS="-fPIC"
790     DLLEXT=".so"
791     LDPATH="LD_LIBRARY_PATH=\"\$(TOPOBJDIR)/unicode:\$\$LD_LIBRARY_PATH\""
792 elif test "$LIBEXT" = "dll"; then
793     #DLLFLAGS="-fPIC" # -fPIC doesn't work(at least in cygwin-b20) - FIXME
794     DLLEXT=""
795     LDPATH="PATH=\"\$(TOPOBJDIR)/unicode:\$\$PATH\""
796 fi
797
798 AC_SUBST(DLLFLAGS)
799 AC_SUBST(DLLEXT)
800 AC_SUBST(LDSHARED)
801 AC_SUBST(LDDLLFLAGS)
802 AC_SUBST(LIBEXT)
803 AC_SUBST(LDPATH)
804
805 dnl **** Check for reentrant libc ****
806 dnl
807 dnl For cross-compiling we blindly assume that libc is reentrant. This is
808 dnl ok since non-reentrant libc is quite rare (mostly old libc5 versions).
809
810 AC_DEFUN([WINE_CHECK_ERRNO],
811 [
812   AC_CACHE_CHECK(for reentrant libc: $1, wine_cv_libc_r_$1,
813   [AC_TRY_RUN([int myerrno = 0;
814 char buf[256];
815 int *$1(){return &myerrno;}
816 main(){connect(0,buf,255); exit(!myerrno);}],
817   wine_cv_libc_r_$1=yes, wine_cv_libc_r_$1=no,
818   wine_cv_libc_r_$1=yes )
819 ])
820 if test "$wine_cv_libc_r_$1" = "yes"
821 then
822     wine_cv_libc_reentrant=$1 
823 fi
824 ])
825
826 wine_cv_libc_reentrant=no 
827 dnl Linux style errno location
828 WINE_CHECK_ERRNO(__errno_location)
829 dnl FreeBSD style errno location
830 WINE_CHECK_ERRNO(__error)
831 dnl Solaris style errno location
832 WINE_CHECK_ERRNO(___errno)
833 dnl UnixWare style errno location
834 WINE_CHECK_ERRNO(__thr_errno)
835 dnl NetBSD style errno location
836 WINE_CHECK_ERRNO(__errno)
837
838 if test "$wine_cv_libc_reentrant" != "no" 
839 then
840   AC_DEFINE_UNQUOTED(ERRNO_LOCATION,$wine_cv_libc_reentrant,
841                      [Define to the name of the function returning errno for reentrant libc])
842 fi
843
844 dnl **** Check for reentrant X libraries ****
845 dnl
846 dnl This may fail to determine whether X libraries are reentrant if
847 dnl AC_PATH_XTRA does not set x_libraries. In this case manual configuration
848 dnl is possible with the --without-reentrant-x option.
849
850 if test "$have_x" = "yes" -a "$wine_cv_libc_reentrant" != "no"
851 then
852 AC_CACHE_CHECK( [for reentrant X libraries], wine_cv_x_reentrant,
853   [ if test "x$with_reentrant_x" = "xno" 
854     then
855         wine_cv_x_reentrant=no
856     else
857         libX11_check=none
858         for dir in "$x_libraries" /usr/lib /usr/local/lib /lib; do
859             if test -r $dir/libX11.so; then
860                 libX11_check="-D $dir/libX11.so"
861                 break 1
862             fi
863             if test -r $dir/libX11.a; then
864                 libX11_check="$dir/libX11.a"
865                 break 1
866             fi
867         done
868         if test "$libX11_check" != "none"; then
869             if nm $libX11_check | grep $wine_cv_libc_reentrant >/dev/null 2>&1
870             then
871                 wine_cv_x_reentrant=yes
872             else
873                 wine_cv_x_reentrant=no
874             fi
875         else
876             wine_cv_x_reentrant=unknown
877         fi
878     fi ] )
879 else
880     wine_cv_x_reentrant=no
881 fi
882 if test "$wine_cv_x_reentrant" = "no"
883 then
884   AC_DEFINE(NO_REENTRANT_X11, 1,
885             [Define if X libraries are not reentrant (compiled without -D_REENTRANT)])
886 fi
887
888
889 dnl **** Check for functions ****
890
891 AC_FUNC_ALLOCA()
892 AC_CHECK_FUNCS(\
893         __libc_fork \
894         _lwp_create \
895         _pclose \
896         _popen \
897         _stricmp \
898         _strnicmp \
899         clone \
900         ecvt \
901         finite \
902         fpclass \
903         ftruncate64 \
904         getnetbyaddr \
905         getnetbyname \
906         getpagesize \
907         getprotobyname \
908         getprotobynumber \
909         getrlimit \
910         getservbyport \
911         getsockopt \
912         inet_network \
913         lseek64 \
914         lstat \
915         memmove \
916         mmap \
917         pclose \
918         pread \
919         popen \
920         pwrite \
921         rfork \
922         select \
923         sendmsg \
924         settimeofday \
925         sigaltstack \
926         statfs \
927         strcasecmp \
928         strerror \
929         strncasecmp \
930         tcgetattr \
931         timegm \
932         usleep \
933         vfscanf \
934         wait4 \
935         waitpid \
936 )
937
938 dnl **** Check for header files ****
939
940 AC_CHECK_HEADERS(\
941         arpa/inet.h \
942         arpa/nameser.h \
943         direct.h \
944         elf.h \
945         float.h \
946         ieeefp.h \
947         io.h \
948         libio.h \
949         libutil.h \
950         link.h \
951         linux/cdrom.h \
952         linux/input.h \
953         linux/joystick.h \
954         linux/serial.h \
955         linux/ucdrom.h \
956         net/if.h \
957         netdb.h \
958         netinet/in.h \
959         netinet/in_systm.h \
960         netinet/ip.h \
961         netinet/tcp.h \
962         pty.h \
963         resolv.h \
964         sched.h \
965         socket.h \
966         stdint.h \
967         strings.h \
968         sys/cdio.h \
969         sys/errno.h \
970         sys/file.h \
971         sys/filio.h \
972         sys/inttypes.h \
973         sys/ipc.h \
974         sys/link.h \
975         sys/lwp.h \
976         sys/mman.h \
977         sys/modem.h \
978         sys/mount.h \
979         sys/msg.h \
980         sys/param.h \
981         sys/ptrace.h \
982         sys/reg.h \
983         sys/signal.h \
984         sys/shm.h \
985         sys/socket.h \
986         sys/sockio.h \
987         sys/statfs.h \
988         sys/strtio.h \
989         sys/syscall.h \
990         sys/time.h \
991         sys/user.h \
992         sys/wait.h \
993         sys/v86.h \
994         sys/v86intr.h \
995         sys/vfs.h \
996         sys/vm86.h \
997         syscall.h \
998         ucontext.h \
999         unistd.h \
1000 )
1001 AC_HEADER_STAT()
1002
1003 dnl **** Check for types ****
1004
1005 AC_C_CONST
1006 AC_C_INLINE
1007 AC_TYPE_MODE_T
1008 AC_TYPE_OFF_T
1009 AC_TYPE_PID_T
1010 AC_TYPE_SIZE_T
1011 AC_CHECK_SIZEOF(long long,0)
1012
1013 AC_CACHE_CHECK([whether linux/input.h is for real],
1014         wine_cv_linux_input_h,
1015         AC_TRY_COMPILE([
1016             #include <linux/input.h>
1017         ] , [
1018             int foo = EVIOCGBIT(EV_ABS,42);
1019             int bar = BTN_PINKIE;
1020             int fortytwo = 42;
1021         ],
1022         wine_cv_linux_input_h=yes,
1023         wine_cv_linux_input_h=no,
1024         no
1025         )
1026     )
1027     if test "$wine_cv_linux_input_h" = "yes"
1028     then
1029         AC_DEFINE(HAVE_CORRECT_LINUXINPUT_H, 1,
1030                   [Define if we have linux/input.h AND it contains the INPUT event API])
1031     fi
1032
1033    
1034 AC_CACHE_CHECK([whether we can use re-entrant gethostbyname_r Linux style],
1035         wine_cv_linux_gethostbyname_r_6,
1036         AC_TRY_COMPILE([
1037 #include <netdb.h>
1038         ], [
1039     char *name=NULL;
1040     struct hostent he;
1041     struct hostent *result;
1042     char *buf=NULL;
1043     int bufsize=0;
1044     int res,errnr;
1045     char *addr=NULL;
1046     int addrlen=0;
1047     int addrtype=0;
1048     res=gethostbyname_r(name,&he,buf,bufsize,&result,&errnr);
1049     res=gethostbyaddr_r(addr, addrlen, addrtype,&he,buf,bufsize,&result,&errnr);
1050     ],
1051         wine_cv_linux_gethostbyname_r_6=yes,
1052         wine_cv_linux_gethostbyname_r_6=no
1053         )
1054    )
1055    if test "$wine_cv_linux_gethostbyname_r_6" = "yes"
1056    then
1057       AC_DEFINE(HAVE_LINUX_GETHOSTBYNAME_R_6, 1,
1058                 [Define if Linux-style gethostbyname_r and gethostbyaddr_r are available])
1059    fi
1060
1061 if test "$ac_cv_header_linux_joystick_h" = "yes"
1062 then
1063    AC_CACHE_CHECK([whether linux/joystick.h uses the Linux 2.2+ API],
1064         wine_cv_linux_joystick_22_api,
1065         AC_TRY_COMPILE([
1066         #include <sys/ioctl.h>
1067         #include <linux/joystick.h>
1068
1069         struct js_event blub;
1070         #if !defined(JS_EVENT_AXIS) || !defined(JS_EVENT_BUTTON)
1071         #error "no 2.2 header"
1072         #endif
1073         ],/*empty*/,
1074         wine_cv_linux_joystick_22_api=yes,
1075         wine_cv_linux_joystick_22_api=no,
1076         wine_cv_linux_joystick_22_api=no
1077         )
1078    )
1079    if test "$wine_cv_linux_joystick_22_api" = "yes"
1080    then
1081       AC_DEFINE(HAVE_LINUX_22_JOYSTICK_API, 1,
1082                 [Define if <linux/joystick.h> defines the Linux 2.2 joystick API])
1083    fi
1084 fi
1085
1086 dnl **** statfs checks ****
1087
1088 if test "$ac_cv_header_sys_vfs_h" = "yes"
1089 then
1090     AC_CACHE_CHECK( [whether sys/vfs.h defines statfs],
1091                     wine_cv_sys_vfs_has_statfs,
1092         AC_TRY_COMPILE([
1093         #include <sys/types.h>
1094         #ifdef HAVE_SYS_PARAM_H
1095         # include <sys/param.h>
1096         #endif
1097         #include <sys/vfs.h>
1098         ],[
1099                 struct statfs stfs;
1100
1101                 memset(&stfs,0,sizeof(stfs));
1102         ],wine_cv_sys_vfs_has_statfs=yes,wine_cv_sys_vfs_has_statfs=no
1103         )
1104     )
1105     if test "$wine_cv_sys_vfs_has_statfs" = "yes"
1106     then
1107       AC_DEFINE(STATFS_DEFINED_BY_SYS_VFS, 1,
1108                 [Define if the struct statfs is defined by <sys/vfs.h>])
1109     fi
1110 fi
1111
1112 if test "$ac_cv_header_sys_statfs_h" = "yes"
1113 then
1114     AC_CACHE_CHECK( [whether sys/statfs.h defines statfs],
1115                     wine_cv_sys_statfs_has_statfs,
1116         AC_TRY_COMPILE([
1117         #include <sys/types.h>
1118         #ifdef HAVE_SYS_PARAM_H
1119         # include <sys/param.h>
1120         #endif
1121         #include <sys/statfs.h>
1122         ],[
1123                 struct statfs stfs;
1124         ],wine_cv_sys_statfs_has_statfs=yes,wine_cv_sys_statfs_has_statfs=no
1125         )
1126     )
1127     if test "$wine_cv_sys_statfs_has_statfs" = "yes"
1128     then
1129       AC_DEFINE(STATFS_DEFINED_BY_SYS_STATFS, 1,
1130                 [Define if the struct statfs is defined by <sys/statfs.h>])
1131     fi
1132 fi
1133
1134 if test "$ac_cv_header_sys_mount_h" = "yes"
1135 then
1136     AC_CACHE_CHECK( [whether sys/mount.h defines statfs],
1137                     wine_cv_sys_mount_has_statfs,
1138         AC_TRY_COMPILE([
1139         #include <sys/types.h>
1140         #ifdef HAVE_SYS_PARAM_H
1141         # include <sys/param.h>
1142         #endif
1143         #include <sys/mount.h>
1144         ],[
1145                 struct statfs stfs;
1146         ],wine_cv_sys_mount_has_statfs=yes,wine_cv_sys_mount_has_statfs=no
1147         )
1148     )
1149     if test "$wine_cv_sys_mount_has_statfs" = "yes"
1150     then
1151       AC_DEFINE(STATFS_DEFINED_BY_SYS_MOUNT, 1,
1152                 [Define if the struct statfs is defined by <sys/mount.h>])
1153     fi
1154 fi
1155
1156 dnl *** Check for some structure members
1157
1158 dnl Macro to check if a structure contains a specified member
1159 dnl Usage: WINE_CHECK_STRUCT_MEMBER(struct,member,[includes,[action-if-found,[action-if-not-found]]])
1160
1161 AC_DEFUN([WINE_CHECK_STRUCT_MEMBER],
1162 [AC_CACHE_CHECK([for $2 in struct $1], ac_cv_c_$1_$2,
1163  AC_TRY_COMPILE([$3],[struct $1 s; s.$2 = 0],ac_cv_c_$1_$2="yes",ac_cv_c_$1_$2="no"))
1164 AS_IF([ test "x$ac_cv_c_$1_$2" = "xyes"],[$4],[$5])
1165 ])
1166
1167 dnl **** FIXME: what about mixed cases, where we need two of them? ***
1168
1169 WINE_CHECK_STRUCT_MEMBER(statfs,f_bfree,
1170 [#include <sys/types.h>
1171 #ifdef HAVE_SYS_PARAM_H
1172 # include <sys/param.h>
1173 #endif
1174 #ifdef STATFS_DEFINED_BY_SYS_MOUNT
1175 # include <sys/mount.h>
1176 #else
1177 # ifdef STATFS_DEFINED_BY_SYS_VFS
1178 #  include <sys/vfs.h>
1179 # else
1180 #  ifdef STATFS_DEFINED_BY_SYS_STATFS
1181 #   include <sys/statfs.h>
1182 #  endif
1183 # endif
1184 #endif],
1185     [AC_DEFINE(STATFS_HAS_BFREE, 1, [Define if the struct statfs has the member bfree])])
1186
1187 WINE_CHECK_STRUCT_MEMBER(statfs,f_bavail,
1188 [#include <sys/types.h>
1189 #ifdef HAVE_SYS_PARAM_H
1190 # include <sys/param.h>
1191 #endif
1192 #ifdef STATFS_DEFINED_BY_SYS_MOUNT
1193 # include <sys/mount.h>
1194 #else
1195 # ifdef STATFS_DEFINED_BY_SYS_VFS
1196 #  include <sys/vfs.h>
1197 # else
1198 #  ifdef STATFS_DEFINED_BY_SYS_STATFS
1199 #   include <sys/statfs.h>
1200 #  endif
1201 # endif
1202 #endif],
1203     [AC_DEFINE(STATFS_HAS_BAVAIL, 1, [Define if the struct statfs has the member bavail])])
1204
1205 dnl Check for file descriptor passing with msg_accrights
1206 WINE_CHECK_STRUCT_MEMBER(msghdr,msg_accrights,
1207 [#include <sys/types.h>
1208 #include <sys/socket.h>],
1209     [AC_DEFINE(HAVE_MSGHDR_ACCRIGHTS, 1, [Define if struct msghdr contains msg_accrights])])
1210
1211 dnl Check for the sa_len member in struct sockaddr
1212 WINE_CHECK_STRUCT_MEMBER(sockaddr,sa_len,
1213 [#include <sys/types.h>
1214 #include <sys/socket.h>],
1215     [AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if struct sockaddr contains sa_len])])
1216
1217 dnl Check for the sun_len member in struct sockaddr_un
1218 WINE_CHECK_STRUCT_MEMBER(sockaddr_un,sun_len,
1219 [#include <sys/types.h>
1220 #include <sys/socket.h>
1221 #include <sys/un.h>],
1222     [AC_DEFINE(HAVE_SOCKADDR_SUN_LEN, 1, [Define if struct sockaddr_un contains sun_len])])
1223
1224 dnl *** check for the need to define __i386__
1225
1226 case $target_cpu in
1227   *i[3456789]86* )
1228     AC_CACHE_CHECK([whether we need to define __i386__],ac_cv_cpp_def_i386,
1229       AC_EGREP_CPP(yes,[#ifndef __i386__
1230 yes
1231 #endif],
1232  ac_cv_cpp_def_i386="yes", ac_cv_cpp_def_i386="no"))
1233     ;;
1234 esac
1235 if test "$ac_cv_cpp_def_i386" = "yes"
1236 then
1237     CFLAGS="$CFLAGS -D__i386__"
1238     LINTFLAGS="$LINTFLAGS -D__i386__"
1239 fi
1240
1241 dnl **** Generate output files ****
1242
1243 dnl Macro to create non-existent directories from config.status
1244 dnl Usage: WINE_CONFIG_EXTRA_DIR(dirname)
1245 AC_DEFUN([WINE_CONFIG_EXTRA_DIR],
1246 [AC_CONFIG_COMMANDS([$1],[test -d "$1" || (AC_MSG_NOTICE([creating $1]) && mkdir "$1")])])
1247
1248 AH_TOP([#define __WINE_CONFIG_H])
1249
1250 WINE_CONFIG_EXTRA_DIR(dlls/ddraw/d3ddevice)
1251 WINE_CONFIG_EXTRA_DIR(dlls/ddraw/dclipper)
1252 WINE_CONFIG_EXTRA_DIR(dlls/ddraw/ddraw)
1253 WINE_CONFIG_EXTRA_DIR(dlls/ddraw/direct3d)
1254 WINE_CONFIG_EXTRA_DIR(dlls/ddraw/dpalette)
1255 WINE_CONFIG_EXTRA_DIR(dlls/ddraw/dsurface)
1256 WINE_CONFIG_EXTRA_DIR(dlls/dinput/joystick)
1257 WINE_CONFIG_EXTRA_DIR(dlls/dinput/keyboard)
1258 WINE_CONFIG_EXTRA_DIR(dlls/dinput/mouse)
1259 WINE_CONFIG_EXTRA_DIR(dlls/gdi/enhmfdrv)
1260 WINE_CONFIG_EXTRA_DIR(dlls/gdi/mfdrv)
1261 WINE_CONFIG_EXTRA_DIR(dlls/gdi/win16drv)
1262 WINE_CONFIG_EXTRA_DIR(dlls/kernel/messages)
1263 WINE_CONFIG_EXTRA_DIR(dlls/kernel/tests)
1264 WINE_CONFIG_EXTRA_DIR(dlls/oleaut32/tests)
1265 WINE_CONFIG_EXTRA_DIR(dlls/user/dde)
1266 WINE_CONFIG_EXTRA_DIR(dlls/user/resources)
1267 WINE_CONFIG_EXTRA_DIR(dlls/user/tests)
1268 WINE_CONFIG_EXTRA_DIR(dlls/wineps/data)
1269 WINE_CONFIG_EXTRA_DIR(include/wine)
1270 WINE_CONFIG_EXTRA_DIR(programs/regapi/tests)
1271 WINE_CONFIG_EXTRA_DIR(programs/winetest/tests)
1272
1273 MAKE_RULES=Make.rules
1274 AC_SUBST_FILE(MAKE_RULES)
1275
1276 MAKE_DLL_RULES=dlls/Makedll.rules
1277 AC_SUBST_FILE(MAKE_DLL_RULES)
1278
1279 MAKE_PROG_RULES=programs/Makeprog.rules
1280 AC_SUBST_FILE(MAKE_PROG_RULES)
1281
1282 AC_CONFIG_FILES([
1283 Make.rules
1284 dlls/Makedll.rules
1285 programs/Makeprog.rules
1286 Makefile
1287 controls/Makefile
1288 debugger/Makefile
1289 dlls/Makefile
1290 dlls/advapi32/Makefile
1291 dlls/avicap32/Makefile
1292 dlls/avifil32/Makefile
1293 dlls/comctl32/Makefile
1294 dlls/commdlg/Makefile
1295 dlls/crtdll/Makefile
1296 dlls/crypt32/Makefile
1297 dlls/dciman32/Makefile
1298 dlls/ddraw/Makefile
1299 dlls/devenum/Makefile
1300 dlls/dinput/Makefile
1301 dlls/dplay/Makefile
1302 dlls/dplayx/Makefile
1303 dlls/dsound/Makefile
1304 dlls/gdi/Makefile
1305 dlls/glu32/Makefile
1306 dlls/icmp/Makefile
1307 dlls/imagehlp/Makefile
1308 dlls/imm32/Makefile
1309 dlls/kernel/Makefile
1310 dlls/lzexpand/Makefile
1311 dlls/mapi32/Makefile
1312 dlls/mpr/Makefile
1313 dlls/msacm/Makefile
1314 dlls/msacm/imaadp32/Makefile
1315 dlls/msacm/msg711/Makefile
1316 dlls/msdmo/Makefile
1317 dlls/msimg32/Makefile
1318 dlls/msisys/Makefile
1319 dlls/msnet32/Makefile
1320 dlls/msrle32/Makefile
1321 dlls/msvcrt/Makefile
1322 dlls/msvcrt20/Makefile
1323 dlls/msvideo/Makefile
1324 dlls/netapi32/Makefile
1325 dlls/ntdll/Makefile
1326 dlls/odbc32/Makefile
1327 dlls/ole32/Makefile
1328 dlls/oleaut32/Makefile
1329 dlls/olecli/Makefile
1330 dlls/oledlg/Makefile
1331 dlls/olepro32/Makefile
1332 dlls/olesvr/Makefile
1333 dlls/opengl32/Makefile
1334 dlls/psapi/Makefile
1335 dlls/qcap/Makefile
1336 dlls/quartz/Makefile
1337 dlls/rasapi32/Makefile
1338 dlls/richedit/Makefile
1339 dlls/rpcrt4/Makefile
1340 dlls/serialui/Makefile
1341 dlls/setupapi/Makefile
1342 dlls/shdocvw/Makefile
1343 dlls/shell32/Makefile
1344 dlls/shfolder/Makefile
1345 dlls/shlwapi/Makefile
1346 dlls/sti/Makefile
1347 dlls/tapi32/Makefile
1348 dlls/ttydrv/Makefile
1349 dlls/twain/Makefile
1350 dlls/url/Makefile
1351 dlls/urlmon/Makefile
1352 dlls/user/Makefile
1353 dlls/version/Makefile
1354 dlls/win32s/Makefile
1355 dlls/winaspi/Makefile
1356 dlls/winedos/Makefile
1357 dlls/wineps/Makefile
1358 dlls/wininet/Makefile
1359 dlls/winmm/Makefile
1360 dlls/winmm/joystick/Makefile
1361 dlls/winmm/mcianim/Makefile
1362 dlls/winmm/mciavi/Makefile
1363 dlls/winmm/mcicda/Makefile
1364 dlls/winmm/mciseq/Makefile
1365 dlls/winmm/mciwave/Makefile
1366 dlls/winmm/midimap/Makefile
1367 dlls/winmm/wavemap/Makefile
1368 dlls/winmm/winearts/Makefile
1369 dlls/winmm/wineoss/Makefile
1370 dlls/winnls/Makefile
1371 dlls/winsock/Makefile
1372 dlls/winspool/Makefile
1373 dlls/wintrust/Makefile
1374 dlls/wow32/Makefile
1375 dlls/wsock32/Makefile
1376 dlls/x11drv/Makefile
1377 documentation/Makefile
1378 files/Makefile
1379 graphics/Makefile
1380 graphics/x11drv/Makefile
1381 if1632/Makefile
1382 include/Makefile
1383 library/Makefile
1384 libtest/Makefile
1385 loader/Makefile
1386 loader/ne/Makefile
1387 memory/Makefile
1388 misc/Makefile
1389 miscemu/Makefile
1390 msdos/Makefile
1391 objects/Makefile
1392 ole/Makefile
1393 programs/Makefile
1394 programs/avitools/Makefile
1395 programs/clock/Makefile
1396 programs/cmdlgtst/Makefile
1397 programs/control/Makefile
1398 programs/notepad/Makefile
1399 programs/osversioncheck/Makefile
1400 programs/progman/Makefile
1401 programs/regapi/Makefile
1402 programs/regedit/Makefile
1403 programs/regtest/Makefile
1404 programs/uninstaller/Makefile
1405 programs/view/Makefile
1406 programs/wcmd/Makefile
1407 programs/wineconsole/Makefile
1408 programs/winemine/Makefile
1409 programs/winetest/Makefile
1410 programs/winhelp/Makefile
1411 programs/winver/Makefile
1412 relay32/Makefile
1413 scheduler/Makefile
1414 server/Makefile
1415 tools/Makefile
1416 tools/winapi/Makefile
1417 tools/winebuild/Makefile
1418 tools/winedump/Makefile
1419 tools/wmc/Makefile
1420 tools/wrc/Makefile
1421 tsx11/Makefile
1422 unicode/Makefile
1423 win32/Makefile
1424 windows/Makefile
1425 windows/x11drv/Makefile ])
1426
1427 AC_OUTPUT
1428
1429 if test "$have_x" = "no"
1430 then
1431   echo
1432   echo "*** Warning: X development files not found. Wine will be built without"
1433   echo "*** X support, which currently does not work, and would probably not be"
1434   echo "*** what you want anyway. You will need to install devel packages of"
1435   echo "*** Xlib/Xfree86 at the very least."
1436 fi
1437
1438 if test "$ac_cv_lib_ncurses_resizeterm" = "no" -a "$ac_cv_lib_ncurses_waddch" = "yes"
1439 then
1440   echo
1441   echo "*** Warning: resizeterm not found in ncurses. Wine will be built without"
1442   echo "*** terminal resize support. Consider upgrading ncurses."
1443 fi
1444
1445 if test "$wine_cv_libc_reentrant" = "no" 
1446 then
1447   echo
1448   echo "*** Warning: non-reentrant libc detected. Wine will be built without"
1449   echo "*** threading support. Consider upgrading libc to a more recent"
1450   echo "*** reentrant version of libc."
1451 fi
1452
1453 if test "$wine_cv_opengl_version_OK" = "no"
1454 then
1455   echo
1456   echo "*** Warning: old Mesa headers detected. Wine will be built without Direct3D"
1457   echo "*** support. Consider upgrading your Mesa libraries (http://www.mesa3d.org/)."
1458 fi
1459
1460 if test "$wine_cv_opengl_version_threadsafe" = "yes" -a "x$enable_opengl" = "x"
1461 then
1462   echo
1463   echo "*** Warning: the OpenGL version you have installed relies on libpthread for"
1464   echo "*** thread-safety. To prevent crashes, OpenGL support has been removed."
1465   echo "*** A fix for glibc 2.1.3 that seems to work is included in this version of Wine,"
1466   echo "*** start configure with '--enable-opengl' to force OpenGL support."
1467 fi
1468
1469 if test "$wine_cv_opengl_version_threadsafe" = "yes" -a "x$enable_opengl" = "xyes"
1470 then
1471   echo
1472   echo "*** Warning: you explicitly linked in a thread-safe OpenGL version. If you"
1473   echo "*** experience unusual crashes on DirectDraw games, try first to disable OpenGL"
1474   echo "*** support before reporting bugs."
1475 fi
1476
1477 if test "$wine_cv_warn_cups_h" = "yes"
1478 then
1479   echo
1480   echo "*** Note: You have cups runtime libraries, but no development"
1481   echo "*** libraries. Install the cups-devel package or whichever package"
1482   echo "*** contains cups.h to enable CUPS support in Wine."
1483 fi
1484
1485 if test "$wine_cv_msg_freetype" = "yes"
1486 then
1487   echo
1488   echo "*** Note: Your system appears to have the FreeType 2 runtime libraries"
1489   echo "*** installed, but 'freetype-config' is not in your PATH. Install the"
1490   echo "*** freetype-devel package (or its equivalent on your distribution) to"
1491   echo "*** enable Wine to use TrueType fonts."
1492 fi
1493
1494 echo
1495 echo "Configure finished.  Do 'make depend && make' to compile Wine."
1496 echo
1497
1498 dnl Local Variables:
1499 dnl comment-start: "dnl "
1500 dnl comment-end: ""
1501 dnl comment-start-skip: "\\bdnl\\b\\s *"
1502 dnl compile-command: "autoconf"
1503 dnl End: