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