Fix for windres flags used in Win64 mingw build.
[wxWidgets.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_REVISION($Id$)dnl
3
4 AC_PREREQ(2.58)
5
6 dnl ---------------------------------------------------------------------------
7 dnl
8 dnl Top-level configure.in for wxWidgets by Robert Roebling, Phil Blecker,
9 dnl Vadim Zeitlin and Ron Lee
10 dnl
11 dnl This script is under the wxWidgets licence.
12 dnl
13 dnl Version: $Id$
14 dnl ---------------------------------------------------------------------------
15
16 dnl ---------------------------------------------------------------------------
17 dnl initialization
18 dnl ---------------------------------------------------------------------------
19
20 AC_INIT([wxWidgets], [2.9.1], [wx-dev@lists.wxwidgets.org])
21
22 dnl the file passed to AC_CONFIG_SRCDIR should be specific to our package
23 AC_CONFIG_SRCDIR([wx-config.in])
24
25 dnl sets build, host variables and the same with _alias
26 AC_CANONICAL_BUILD
27 AC_CANONICAL_HOST
28
29 dnl notice that if --host was given but --build was not, cross_compiling is
30 dnl only set to "maybe" and not "yes" and will be either set to "yes" later or
31 dnl configure will exit with error in AC_PROG_CC so don't test for = "yes" here
32 if test "$cross_compiling" != "no"; then
33     HOST_PREFIX="${host_alias}-"
34     HOST_SUFFIX="-$host_alias"
35 else
36     HOST_PREFIX=
37     HOST_SUFFIX=
38 fi
39
40 dnl When making releases do:
41 dnl
42 dnl wx_release_number += 1
43
44 wx_major_version_number=2
45 wx_minor_version_number=9
46 wx_release_number=1
47 wx_subrelease_number=0
48
49 WX_RELEASE=$wx_major_version_number.$wx_minor_version_number
50 WX_VERSION=$WX_RELEASE.$wx_release_number
51 WX_SUBVERSION=$WX_VERSION.$wx_subrelease_number
52
53 WX_MSW_VERSION=$wx_major_version_number$wx_minor_version_number$wx_release_number
54
55
56 dnl Autoconf-2.60 changed the meaning of top_builddir variable, so we have
57 dnl to use our own replacement that will work with both 2.5x and 2.60+:
58 wx_top_builddir="`pwd`"
59 AC_SUBST(wx_top_builddir)
60
61
62 dnl ------------------------------------------------------------------------
63 dnl Check platform (host system)
64 dnl ------------------------------------------------------------------------
65
66 dnl OS (assume Unix)
67 USE_UNIX=1
68 USE_OS2=0
69 USE_WIN32=0
70 USE_DOS=0
71 USE_BEOS=0
72 USE_MAC=0
73
74 dnl Unix kind
75 USE_AIX=
76 USE_BSD=                            dnl any BSD
77 USE_DARWIN=                         dnl a.k.a. Mac OS X
78 USE_FREEBSD=
79 USE_GNU=                            dnl GNU/Hurd
80 USE_HPUX=
81 USE_LINUX=
82 USE_NETBSD=
83 USE_OPENBSD=
84 USE_OSF=                            dnl OSF/1 (obsolete?)
85 USE_SGI=
86 USE_SOLARIS=                        dnl Solaris ("SunOS" >= 5)
87 USE_SUN=                            dnl SunOS or Solaris
88 USE_SUNOS=                          dnl old/real SunOS (obsolete)
89 USE_SVR4=                           dnl SysV R4
90 USE_SYSV=                           dnl any System V
91 USE_VMS=
92 USE_ULTRIX=
93 USE_UNIXWARE=
94
95 dnl hardware platform
96 USE_ALPHA=
97
98 dnl on some platforms xxx_r() functions are declared inside "#ifdef
99 dnl _REENTRANT" and it's easier to just define this symbol for these platforms
100 dnl than checking it during run-time
101 NEEDS_D_REENTRANT_FOR_R_FUNCS=0
102
103 dnl the list of all available toolkits
104 dnl
105 dnl update NUM_TOOLKITS calculation below when adding a new toolkit here!
106 ALL_TOOLKITS="COCOA GTK OSX_CARBON OSX_COCOA MGL MICROWIN MOTIF MSW PM X11 DFB"
107
108 dnl NB: these wxUSE_XXX constants have value of 0 or 1 unlike all the other ones
109 dnl     which are either yes or no
110 DEFAULT_wxUSE_COCOA=0
111 DEFAULT_wxUSE_GTK=0
112 DEFAULT_wxUSE_OSX_CARBON=0
113 DEFAULT_wxUSE_OSX_COCOA=0
114 DEFAULT_wxUSE_MGL=0
115 DEFAULT_wxUSE_MICROWIN=0
116 DEFAULT_wxUSE_MOTIF=0
117 DEFAULT_wxUSE_MSW=0
118 DEFAULT_wxUSE_PM=0
119 DEFAULT_wxUSE_X11=0
120 DEFAULT_wxUSE_DFB=0
121
122 dnl these are the values which are really default for the given platform:
123 dnl they're used if no --with-<toolkit> options were given to detect the
124 dnl toolkit to use by default for the target platform
125 DEFAULT_DEFAULT_wxUSE_COCOA=0
126 DEFAULT_DEFAULT_wxUSE_GTK=0
127 DEFAULT_DEFAULT_wxUSE_OSX_CARBON=0
128 DEFAULT_DEFAULT_wxUSE_OSX_COCOA=0
129 DEFAULT_DEFAULT_wxUSE_MGL=0
130 DEFAULT_DEFAULT_wxUSE_MICROWIN=0
131 DEFAULT_DEFAULT_wxUSE_MOTIF=0
132 DEFAULT_DEFAULT_wxUSE_MSW=0
133 DEFAULT_DEFAULT_wxUSE_PM=0
134 DEFAULT_DEFAULT_wxUSE_X11=0
135 DEFAULT_DEFAULT_wxUSE_DFB=0
136
137 PROGRAM_EXT=
138 SAMPLES_RPATH_FLAG=
139 DYLIB_RPATH_INSTALL=
140 DYLIB_RPATH_POSTLINK=
141
142 DEFAULT_STD_FLAG=yes
143
144 dnl to support a new system, you need to add its canonical name (as determined
145 dnl by config.sub or specified by the configure command line) to this "case"
146 dnl and also define the shared library flags below - search for
147 dnl SHARED_LIB_SETUP to find the exact place
148 case "${host}" in
149   *-hp-hpux* )
150     USE_HPUX=1
151     DEFAULT_DEFAULT_wxUSE_MOTIF=1
152     NEEDS_D_REENTRANT_FOR_R_FUNCS=1
153     AC_DEFINE(__HPUX__)
154
155     dnl many standard declarations in HP-UX headers are only included if either
156     dnl _HPUX_SOURCE is defined, see stdsyms(5)
157     CPPFLAGS="-D_HPUX_SOURCE $CPPFLAGS"
158   ;;
159   *-*-linux* )
160     USE_LINUX=1
161     AC_DEFINE(__LINUX__)
162     TMP=`uname -m`
163     if test "x$TMP" = "xalpha"; then
164       USE_ALPHA=1
165       AC_DEFINE(__ALPHA__)
166     fi
167     DEFAULT_DEFAULT_wxUSE_GTK=1
168   ;;
169   *-*-gnu* | *-*-k*bsd*-gnu )
170     USE_GNU=1
171     TMP=`uname -m`
172     if test "x$TMP" = "xalpha"; then
173       USE_ALPHA=1
174       AC_DEFINE(__ALPHA__)
175     fi
176     DEFAULT_DEFAULT_wxUSE_GTK=1
177   ;;
178   *-*-irix5* | *-*-irix6* )
179     USE_SGI=1
180     USE_SVR4=1
181     AC_DEFINE(__SGI__)
182     AC_DEFINE(__SVR4__)
183     DEFAULT_DEFAULT_wxUSE_MOTIF=1
184   ;;
185   *-*-solaris2* )
186     USE_SUN=1
187     USE_SOLARIS=1
188     USE_SVR4=1
189     AC_DEFINE(__SUN__)
190     AC_DEFINE(__SOLARIS__)
191     AC_DEFINE(__SVR4__)
192     DEFAULT_DEFAULT_wxUSE_MOTIF=1
193     NEEDS_D_REENTRANT_FOR_R_FUNCS=1
194   ;;
195   *-*-sunos4* )
196     USE_SUN=1
197     USE_SUNOS=1
198     USE_BSD=1
199     AC_DEFINE(__SUN__)
200     AC_DEFINE(__SUNOS__)
201     AC_DEFINE(__BSD__)
202     DEFAULT_DEFAULT_wxUSE_MOTIF=1
203   ;;
204   *-*-freebsd*)
205     USE_BSD=1
206     USE_FREEBSD=1
207     AC_DEFINE(__FREEBSD__)
208     AC_DEFINE(__BSD__)
209     DEFAULT_DEFAULT_wxUSE_GTK=1
210   ;;
211   *-*-openbsd*|*-*-mirbsd*)
212     USE_BSD=1
213     USE_OPENBSD=1
214     AC_DEFINE(__OPENBSD__)
215     AC_DEFINE(__BSD__)
216     DEFAULT_DEFAULT_wxUSE_GTK=1
217   ;;
218   *-*-netbsd*)
219     USE_BSD=1
220     USE_NETBSD=1
221     AC_DEFINE(__NETBSD__)
222     AC_DEFINE(__BSD__)
223     DEFAULT_DEFAULT_wxUSE_GTK=1
224     NEEDS_D_REENTRANT_FOR_R_FUNCS=1
225
226     dnl some standard declarations in NetBSD headers are only included if
227     dnl _NETBSD_SOURCE and _LIBC are defined, e.g. getservbyname_r in netdb.h
228     CPPFLAGS="-D_NETBSD_SOURCE -D_LIBC $CPPFLAGS"
229   ;;
230   *-*-osf* )
231     USE_ALPHA=1
232     USE_OSF=1
233     AC_DEFINE(__ALPHA__)
234     AC_DEFINE(__OSF__)
235     DEFAULT_DEFAULT_wxUSE_MOTIF=1
236     NEEDS_D_REENTRANT_FOR_R_FUNCS=1
237   ;;
238   *-*-dgux5* )
239     USE_ALPHA=1
240     USE_SVR4=1
241     AC_DEFINE(__ALPHA__)
242     AC_DEFINE(__SVR4__)
243     DEFAULT_DEFAULT_wxUSE_MOTIF=1
244   ;;
245   *-*-sysv5* )
246     USE_SYSV=1
247     USE_SVR4=1
248     AC_DEFINE(__SYSV__)
249     AC_DEFINE(__SVR4__)
250     DEFAULT_DEFAULT_wxUSE_MOTIF=1
251   ;;
252   *-*-aix* )
253     USE_AIX=1
254     USE_SYSV=1
255     USE_SVR4=1
256     AC_DEFINE(__AIX__)
257     AC_DEFINE(__SYSV__)
258     AC_DEFINE(__SVR4__)
259     DEFAULT_DEFAULT_wxUSE_MOTIF=1
260   ;;
261
262   *-*-*UnixWare*)
263     USE_SYSV=1
264     USE_SVR4=1
265     USE_UNIXWARE=1
266     AC_DEFINE(__UNIXWARE__)
267   ;;
268
269   *-*-cygwin* | *-*-mingw32* )
270     dnl MBN: some of the defines have been moved after toolkit detection
271     dnl      because for wxMotif/wxGTK/wxX11 to build on Cygwin
272     dnl      USE_UNIX  must be set and not USE_WIN32
273     PROGRAM_EXT=".exe"
274     DEFAULT_DEFAULT_wxUSE_MSW=1
275   ;;
276
277   *-pc-msdosdjgpp )
278     USE_UNIX=0
279     USE_DOS=1
280     AC_DEFINE(__DOS__)
281     PROGRAM_EXT=".exe"
282     DEFAULT_DEFAULT_wxUSE_MGL=1
283   ;;
284
285   *-pc-os2_emx | *-pc-os2-emx )
286     AC_DEFINE(__EMX__)
287     USE_OS2=1
288     AC_DEFINE(__OS2__)
289     PROGRAM_EXT=".exe"
290     DEFAULT_DEFAULT_wxUSE_PM=1
291     dnl "c++" wrapper is not always available, so always use plain gcc.
292     CXX=gcc
293     LDFLAGS="$LDFLAGS -Zcrtdll"
294     dnl
295     dnl Some special code that's automatically added by autoconf-2.57 for OS/2
296     dnl and hopefully also by autoconf-2.58 and newer on all other platforms.
297     dnl For now however, we still need it to make sure the configure script
298     dnl works on OS/2 no matter what platform it is generated on.
299     ac_executable_extensions=".exe"
300     export ac_executable_extensions
301     dnl This strange code is necessary to deal with handling of
302     dnl backslashes by ksh and pdksh's sh variant.
303     ac_save_IFS="$IFS"
304     IFS='\\'
305     ac_TEMP_PATH=
306     for ac_dir in $PATH; do
307       IFS=$ac_save_IFS
308       if test -z "$ac_TEMP_PATH"; then
309         ac_TEMP_PATH="$ac_dir"
310       else
311         ac_TEMP_PATH="$ac_TEMP_PATH/$ac_dir"
312       fi
313     done
314     export PATH="$ac_TEMP_PATH"
315     unset ac_TEMP_PATH
316     DEFAULT_STD_FLAG=no
317   ;;
318
319   *-*-darwin* )
320     dnl Darwin based distributions (including Mac OS X)
321     USE_BSD=1
322     USE_DARWIN=1
323     AC_DEFINE(__BSD__)
324     AC_DEFINE(__DARWIN__)
325     AC_DEFINE(TARGET_CARBON)
326     DEFAULT_DEFAULT_wxUSE_OSX_CARBON=1
327   ;;
328
329   *-*-beos* )
330     dnl leave USE_UNIX on - BeOS is sufficiently Unix-like for this
331     USE_BEOS=1
332     AC_DEFINE(__BEOS__)
333   ;;
334
335   *)
336     AC_MSG_WARN([*** System type ${host} is unknown, assuming generic Unix and continuing nevertheless.])
337     AC_MSG_WARN([*** Please report the build results to wx-dev@lists.wxwidgets.org.])
338
339     DEFAULT_DEFAULT_wxUSE_X11=1
340     DEFAULT_wxUSE_SHARED=no
341 esac
342
343 dnl ---------------------------------------------------------------------------
344 dnl command line options for configure
345 dnl ---------------------------------------------------------------------------
346
347 dnl the default values for all options - we collect them all here to simplify
348 dnl modification of the default values (for example, if the defaults for some
349 dnl platform should be changed, it can be done here too)
350 dnl
351 dnl NB: see also DEFAULT_wxUSE<toolkit> variables defined above
352
353 dnl it's only necessary to list the options which should be disabled by
354 dnl default, all the rest have default value of "yes" (or, rather, of
355 dnl wxUSE_ALL_FEATURES which is the only which has to be set to "yes" by
356 dnl default)
357 DEFAULT_wxUSE_ALL_FEATURES=yes
358
359 DEFAULT_wxUSE_STD_IOSTREAM=$DEFAULT_STD_FLAG
360 DEFAULT_wxUSE_STD_STRING=$DEFAULT_STD_FLAG
361
362 dnl libraries disabled by default
363 DEFAULT_wxUSE_DMALLOC=no
364 DEFAULT_wxUSE_LIBGNOMEVFS=no
365 DEFAULT_wxUSE_LIBHILDON=no
366 DEFAULT_wxUSE_LIBHILDON2=no
367 DEFAULT_wxUSE_LIBMSPACK=no
368 DEFAULT_wxUSE_LIBSDL=no
369
370 dnl features disabled by default
371 DEFAULT_wxUSE_ACCESSIBILITY=no
372 DEFAULT_wxUSE_GRAPHICS_CONTEXT=no
373 DEFAULT_wxUSE_IPV6=no
374 DEFAULT_wxUSE_GSTREAMER8=no
375
376 dnl automatic features
377 DEFAULT_wxUSE_UNICODE_UTF8=auto
378 DEFAULT_wxUSE_OPENGL=auto
379 DEFAULT_wxUSE_MEDIACTRL=auto
380 DEFAULT_wxUSE_COMPILER_TLS=auto
381
382 DEFAULT_wxUSE_UNICODE_UTF8_LOCALE=no
383
384 dnl Mac/Cocoa users need to enable building universal binaries explicitly
385 DEFAULT_wxUSE_UNIVERSAL_BINARY=no
386
387 DEFAULT_wxUSE_OFFICIAL_BUILD=no
388
389 dnl Applicable only when --with-gtk was used:
390 DEFAULT_wxUSE_GTK2=yes
391
392 dnl Always default to no. Only special cases require this.
393 DEFAULT_wxUSE_OBJC_UNIQUIFYING=no
394
395 dnl ===========================
396 dnl deal with configure options
397 dnl ===========================
398
399 dnl we use several macros here:
400 dnl     - AC_ARG_WITH/AC_ARG_ENABLE are the standard autoconf macros, see
401 dnl       autoconf manual for details about them
402 dnl     - WX_ARG_WITH/WX_ARG_ENABLE are their wx counterparts which perform
403 dnl       the caching of the command line options and also use DEFAULT_foo
404 dnl       variable as the default value for "foo" if neither --enable-foo nor
405 dnl       --disable-foo is specified
406 dnl     - WX_ARG_SYS_WITH is a special version of WX_ARG_WITH which allows
407 dnl       to choose not only whether an external library is used but also if we
408 dnl       use the copy of it included with wxWidgets or an already installed
409 dnl       system version
410 dnl     - WX_ARG_WITHOUT/WX_ARG_DISABLE mirror WX_ARG_WITH/WX_ARG_ENABLE but
411 dnl       should be used for the options which are enabled by default
412 dnl     - WX_ARG_FEATURE is a version of WX_ARG_ENABLE which should be used for
413 dnl       optional features, i.e. options which should be disabled if
414 dnl       --disable-all-features is specified (WX_ARG_WITH/WX_ARG_SYS_WITH are
415 dnl       also affected by this)
416
417 dnl ---------------------------------------------------------------------------
418 dnl global build options
419 dnl ---------------------------------------------------------------------------
420
421 WX_ARG_DISABLE(gui,        [  --disable-gui           don't build GUI parts of the library], wxUSE_GUI)
422 WX_ARG_ENABLE(monolithic,  [  --enable-monolithic     build wxWidgets as single library], wxUSE_MONOLITHIC)
423 WX_ARG_ENABLE(plugins,     [  --enable-plugins        build parts of wxWidgets as loadable components], wxUSE_PLUGINS)
424 WX_ARG_WITHOUT(subdirs,    [  --without-subdirs       don't generate makefiles for samples/demos/...], wxWITH_SUBDIRS)
425 AC_ARG_WITH(flavour,       [  --with-flavour=NAME     specify a name to identify this build], [WX_FLAVOUR="$withval"])
426 WX_ARG_ENABLE(official_build,  [  --enable-official_build official build of wxWidgets (win32 DLL only)], wxUSE_OFFICIAL_BUILD)
427 AC_ARG_ENABLE(vendor,  [  --enable-vendor=VENDOR  vendor name (win32 DLL only)], [VENDOR="$enableval"])
428 if test "x$VENDOR" = "x"; then
429     VENDOR="custom"
430 fi
431
432 WX_ARG_DISABLE(all-features,[  --disable-all-features  disable all optional features to build minimal library], wxUSE_ALL_FEATURES)
433
434 if test "$wxUSE_ALL_FEATURES" = "no"; then
435     dnl this is a bit ugly but currently we have no choice but to manually
436     dnl reset all the options with default value of auto if all features are to
437     dnl be disabled because we can't have an option with default value of
438     dnl "auto-or-no-if-wxUSE_ALL_FEATURES-is-disabled"
439     DEFAULT_wxUSE_MEDIACTRL=no
440 fi
441
442 dnl ---------------------------------------------------------------------------
443 dnl port selection
444 dnl ---------------------------------------------------------------------------
445
446 if test "$wxUSE_GUI" = "yes"; then
447
448 WX_ARG_ENABLE(universal,   [  --enable-universal      use wxWidgets GUI controls instead of native ones], wxUSE_UNIVERSAL)
449 if test "$wxUSE_UNIVERSAL" = "yes"; then
450     AC_ARG_WITH(themes,    [  --with-themes=all|list  use only the specified comma-separated list of wxUniversal themes], [wxUNIV_THEMES="$withval"])
451 fi
452
453 dnl we use AC_ARG_WITH and not WX_ARG_WITH for the toolkit options as they
454 dnl shouldn't default to wxUSE_ALL_FEATURES
455 AC_ARG_WITH(gtk,          [[  --with-gtk[=VERSION]    use GTK+, VERSION can be 2 (default), 1 or "any"]], [wxUSE_GTK="$withval" CACHE_GTK=1 TOOLKIT_GIVEN=1])
456 AC_ARG_WITH(motif,         [  --with-motif            use Motif/Lesstif], [wxUSE_MOTIF="$withval" CACHE_MOTIF=1 TOOLKIT_GIVEN=1])
457 AC_ARG_WITH(osx_carbon,    [  --with-osx_carbon       use Mac OS X (Carbon) ], [wxUSE_OSX_CARBON="$withval" CACHE_OSX_CARBON=1 TOOLKIT_GIVEN=1])
458 AC_ARG_WITH(osx_cocoa,     [  --with-osx_cocoa        use Mac OS X (Cocoa) ], [wxUSE_OSX_COCOA="$withval" CACHE_OSX_COCOA=1 TOOLKIT_GIVEN=1])
459 AC_ARG_WITH(mac,           [  --with-mac              use Mac OS X (Default) ], [wxUSE_OSX_CARBON="$withval" CACHE_OSX_CARBON=1 TOOLKIT_GIVEN=1])
460 AC_ARG_WITH(cocoa,         [  --with-cocoa            use Cocoa], [wxUSE_COCOA="$withval" CACHE_COCOA=1 TOOLKIT_GIVEN=1])
461 AC_ARG_WITH(wine,          [  --with-wine             use Wine], [wxUSE_WINE="$withval" CACHE_WINE=1])
462 AC_ARG_WITH(msw,           [  --with-msw              use MS-Windows], [wxUSE_MSW="$withval" CACHE_MSW=1 TOOLKIT_GIVEN=1])
463 AC_ARG_WITH(pm,            [  --with-pm               use OS/2 Presentation Manager], [wxUSE_PM="$withval" CACHE_PM=1 TOOLKIT_GIVEN=1])
464 AC_ARG_WITH(mgl,           [  --with-mgl              use SciTech MGL], [wxUSE_MGL="$withval" wxUSE_UNIVERSAL="yes" CACHE_MGL=1 TOOLKIT_GIVEN=1])
465 AC_ARG_WITH(directfb,      [  --with-directfb         use DirectFB], [wxUSE_DFB="$withval" wxUSE_UNIVERSAL="yes" CACHE_DFB=1 TOOLKIT_GIVEN=1])
466 AC_ARG_WITH(microwin,      [  --with-microwin         use MicroWindows], [wxUSE_MICROWIN="$withval" CACHE_MICROWIN=1 TOOLKIT_GIVEN=1])
467 AC_ARG_WITH(x11,           [  --with-x11              use X11], [wxUSE_X11="$withval" wxUSE_UNIVERSAL="yes" CACHE_X11=1 TOOLKIT_GIVEN=1])
468 WX_ARG_ENABLE(nanox,       [  --enable-nanox          use NanoX], wxUSE_NANOX)
469
470 AC_ARG_ENABLE(gtk2,        [  --disable-gtk2          use GTK+ 1.2 instead of 2.0], [wxUSE_GTK2="$enableval"])
471 WX_ARG_ENABLE(gpe,         [  --enable-gpe            use GNOME PDA Environment features if possible], wxUSE_GPE)
472
473 dnl check that no more than one toolkit is given and that if none are given that
474 dnl we have a default one
475
476 AC_MSG_CHECKING(for toolkit)
477
478
479
480 # In Wine, we need to default to MSW, not GTK or MOTIF
481 if test "$wxUSE_WINE" = "yes"; then
482     DEFAULT_DEFAULT_wxUSE_GTK=0
483     DEFAULT_DEFAULT_wxUSE_MOTIF=0
484     DEFAULT_DEFAULT_wxUSE_MSW=1
485     wxUSE_SHARED=no
486     CC=${CC:-winegcc}
487     CXX=${CXX:-wineg++}
488 fi
489
490
491 if test "$wxUSE_GUI" = "yes"; then
492
493     if test "$USE_BEOS" = 1; then
494         AC_MSG_ERROR([BeOS GUI is not supported yet, use --disable-gui])
495     fi
496
497     if test "$TOOLKIT_GIVEN" = 1; then
498       dnl convert "yes", "any" or a number to 1 and "no" to 0
499       for toolkit in $ALL_TOOLKITS; do
500         var=wxUSE_$toolkit
501         eval "value=\$${var}"
502         if test "x$value" = "xno"; then
503           eval "$var=0"
504         elif test "x$value" != "x"; then
505           eval "$var=1"
506         fi
507
508         if test "x$value" != "x" -a "x$value" != "xyes" -a "x$value" != "xno"; then
509           eval "wx${toolkit}_VERSION=$value"
510         fi
511       done
512     else
513       dnl try to guess the most apropriate toolkit for this platform
514       for toolkit in $ALL_TOOLKITS; do
515         var=DEFAULT_DEFAULT_wxUSE_$toolkit
516         eval "wxUSE_$toolkit=\$${var}"
517       done
518     fi
519
520     dnl we suppose that expr is available (maybe there is a better way to do
521     dnl this? what about using ALL_TOOLKITS? TODO)
522     NUM_TOOLKITS=`expr ${wxUSE_COCOA:-0} + ${wxUSE_GTK:-0} + ${wxUSE_OSX_CARBON:-0} \
523                   + ${wxUSE_OSX_COCOA:-0} + ${wxUSE_MGL:-0} + ${wxUSE_DFB:-0} \
524                   + ${wxUSE_MICROWIN:-0} + ${wxUSE_MOTIF:-0} + ${wxUSE_MSW:-0} + ${wxUSE_X11:-0}`
525
526     dnl Allow wxUSE_PM only for OS/2 with EMX.
527     case "${host}" in
528       *-pc-os2_emx | *-pc-os2-emx )
529         NUM_TOOLKITS=`expr ${NUM_TOOLKITS} + ${wxUSE_PM:-0}`
530     esac
531
532     case "$NUM_TOOLKITS" in
533       1)
534       ;;
535       0)
536         AC_MSG_ERROR(Please specify a toolkit -- cannot determine the default for ${host})
537       ;;
538       *)
539         AC_MSG_ERROR(Please specify at most one toolkit)
540     esac
541
542     # to be removed when --disable-gtk2 isn't needed
543     if test "x$wxUSE_GTK2" = "xyes"; then
544         wxGTK_VERSION=2
545     elif test "x$wxUSE_GTK2" = "xno"; then
546         wxGTK_VERSION=1
547     fi
548
549     for toolkit in $ALL_TOOLKITS; do
550         var=wxUSE_$toolkit
551         eval "value=\$${var}"
552         if test "$value" = 1; then
553           toolkit_echo=`echo $toolkit | tr '[[A-Z]]' '[[a-z]]'`
554           AC_MSG_RESULT($toolkit_echo)
555         fi
556     done
557 else
558     if test "x$host_alias" != "x"; then
559         AC_MSG_RESULT(base ($host_alias hosted) only)
560     else
561         AC_MSG_RESULT(base only)
562     fi
563 fi
564
565 wxUSE_MAC=0
566 if test "$wxUSE_OSX_CARBON" = 1 -o "$wxUSE_OSX_COCOA" = 1; then
567     wxUSE_MAC=1
568 fi
569
570 dnl ---------------------------------------------------------------------------
571 dnl external libraries
572 dnl ---------------------------------------------------------------------------
573
574 WX_ARG_SYS_WITH(libpng,    [  --with-libpng           use libpng (PNG image format)], wxUSE_LIBPNG)
575 WX_ARG_SYS_WITH(libjpeg,   [  --with-libjpeg          use libjpeg (JPEG file format)], wxUSE_LIBJPEG)
576 WX_ARG_SYS_WITH(libtiff,   [  --with-libtiff          use libtiff (TIFF file format)], wxUSE_LIBTIFF)
577 WX_ARG_SYS_WITH(libxpm,    [  --with-libxpm           use libxpm (XPM file format)], wxUSE_LIBXPM)
578 WX_ARG_WITH(libiconv,      [  --with-libiconv         use libiconv (character conversion)], wxUSE_LIBICONV)
579 WX_ARG_WITH(libmspack,     [  --with-libmspack        use libmspack (CHM help files loading)], wxUSE_LIBMSPACK)
580 WX_ARG_WITHOUT(gtkprint,   [  --without-gtkprint      don't use GTK printing support], wxUSE_GTKPRINT)
581 WX_ARG_WITHOUT(gnomeprint, [  --without-gnomeprint    don't use GNOME printing libraries], wxUSE_LIBGNOMEPRINT)
582 WX_ARG_WITH(gnomevfs,      [  --with-gnomevfs         use GNOME VFS for associating MIME types], wxUSE_LIBGNOMEVFS)
583 WX_ARG_WITH(hildon,        [  --with-hildon           use Hildon framework for Nokia 770/800/810], wxUSE_LIBHILDON)
584 WX_ARG_WITH(opengl,        [  --with-opengl           use OpenGL (or Mesa)], wxUSE_OPENGL)
585
586 fi
587 dnl for GUI only
588
589 WX_ARG_WITH(dmalloc,       [  --with-dmalloc          use dmalloc library (http://dmalloc.com/)], wxUSE_DMALLOC)
590 WX_ARG_WITH(sdl,           [  --with-sdl              use SDL for audio on Unix], wxUSE_LIBSDL)
591 WX_ARG_SYS_WITH(regex,     [  --with-regex            enable support for wxRegEx class], wxUSE_REGEX)
592 WX_ARG_SYS_WITH(zlib,      [  --with-zlib             use zlib for LZW compression], wxUSE_ZLIB)
593 WX_ARG_SYS_WITH(expat,     [  --with-expat            enable XML support using expat parser], wxUSE_EXPAT)
594
595 AC_MSG_CHECKING([for --with-macosx-sdk])
596 AC_ARG_WITH(macosx-sdk,    [  --with-macosx-sdk=PATH  use an OS X SDK at PATH], [
597         wxUSE_MACOSX_SDK=$withval
598         wx_cv_use_macosx_sdk="wxUSE_MACOSX_SDK=$withval"
599     ])
600 AC_MSG_RESULT([$wxUSE_MACOSX_SDK])
601
602 AC_MSG_CHECKING([for --with-macosx-version-min])
603 AC_ARG_WITH(macosx-version-min,    [  --with-macosx-version-min=VER   build binaries which require at least this OS X version], [
604         wxUSE_MACOSX_VERSION_MIN=$withval
605         wx_cv_use_macosx_version_min="wxUSE_MACOSX_VERSION_MIN=$withval"
606     ])
607 AC_MSG_RESULT([$wxUSE_MACOSX_VERSION_MIN])
608
609 dnl ---------------------------------------------------------------------------
610 dnl debugging options
611 dnl ---------------------------------------------------------------------------
612
613 dnl don't use WX_ARG_ENABLE as it just gets in the way instead of helping with
614 dnl this rather unusual option
615 AC_MSG_CHECKING([for --enable-debug])
616 AC_ARG_ENABLE(debug,       [  --enable-debug          build library for debugging],
617     [
618         if test "$enableval" = yes; then
619             wxUSE_DEBUG=yes
620         elif test "$enableval" = no; then
621             wxUSE_DEBUG=no
622         elif test "$enableval" = max; then
623             wxUSE_DEBUG=yes
624             WXCONFIG_CPPFLAGS="$WXCONFIG_CPPFLAGS -DwxDEBUG_LEVEL=2"
625         else
626             AC_MSG_ERROR([Invalid --enable-debug value, must be yes, no or max])
627         fi
628     ],
629     wxUSE_DEBUG=default
630 )
631
632 case "$wxUSE_DEBUG" in
633     yes)
634         dnl build the library for debugging: enable debugging code and generate
635         dnl the debug information for the library itself
636         DEFAULT_wxUSE_DEBUG_FLAG=yes
637         DEFAULT_wxUSE_DEBUG_INFO=yes
638
639         dnl also disable optimizations by default if --enable-debug was used
640         dnl (this can still be overridden by an explicit --enable-optimise)
641         DEFAULT_wxUSE_OPTIMISE=no
642         ;;
643
644     no)
645         dnl --disable-debug is equivalent to both --disable-debug_flag and
646         dnl --disable-debug_info
647         DEFAULT_wxUSE_DEBUG_FLAG=no
648         DEFAULT_wxUSE_DEBUG_INFO=no
649         ;;
650
651     default)
652         dnl the library is built with debugging support by default but without
653         dnl debug information as this requires much, much more disk space
654         DEFAULT_wxUSE_DEBUG_FLAG=yes
655         DEFAULT_wxUSE_DEBUG_INFO=no
656         ;;
657 esac
658
659 WX_ARG_DISABLE(debug_flag,   [  --disable-debug_flag    disable all debugging support], wxUSE_DEBUG_FLAG)
660 WX_ARG_ENABLE(debug_info,    [  --enable-debug_info     generate debug information], wxUSE_DEBUG_INFO)
661
662 dnl enabled if just --enable-debug_{flag,info} was
663 dnl
664 dnl in any case, only set the default value and allow overriding it with an
665
666 WX_ARG_ENABLE(debug_gdb,     [  --enable-debug_gdb      create code with extra GDB debugging information], wxUSE_DEBUG_GDB)
667 WX_ARG_ENABLE(debug_cntxt,   [  --enable-debug_cntxt    obsolete, don't use: use wxDebugContext], wxUSE_DEBUG_CONTEXT)
668 WX_ARG_ENABLE(mem_tracing,   [  --enable-mem_tracing    obsolete, don't use: create code with memory tracing], wxUSE_MEM_TRACING)
669
670 dnl ---------------------------------------------------------------------------
671 dnl global compile options
672 dnl ---------------------------------------------------------------------------
673
674 WX_ARG_DISABLE(shared,     [  --disable-shared        create static library instead of shared], wxUSE_SHARED)
675 WX_ARG_ENABLE(stl,         [  --enable-stl            use STL for containers], wxUSE_STL)
676 WX_ARG_ENABLE(std_iostreams, [  --enable-std_iostreams  use standard C++ stream classes], wxUSE_STD_IOSTREAM)
677 WX_ARG_ENABLE(std_string,    [  --enable-std_string     use standard C++ string classes], wxUSE_STD_STRING)
678 WX_ARG_DISABLE(unicode,      [  --disable-unicode       compile without Unicode support], wxUSE_UNICODE)
679 WX_ARG_ENABLE(mslu,          [  --enable-mslu           use MS Layer for Unicode on Windows 9x (Win32 only)], wxUSE_UNICODE_MSLU)
680 WX_ARG_ENABLE_PARAM(utf8,    [  --enable-utf8           use UTF-8 representation for strings (Unix only)], wxUSE_UNICODE_UTF8)
681 WX_ARG_ENABLE(utf8only,      [  --enable-utf8only       only support UTF-8 locales in UTF-8 build (Unix only)], wxUSE_UNICODE_UTF8_LOCALE)
682 WX_ARG_ENABLE(extended_rtti, [  --enable-extended_rtti  use extended RTTI (XTI)], wxUSE_EXTENDED_RTTI)
683 if test "$USE_OS2" = 1; then
684     DEFAULT_wxUSE_OMF=no
685     WX_ARG_ENABLE(omf,     [  --enable-omf            use OMF object format], wxUSE_OMF)
686 fi
687
688 WX_ARG_DISABLE(optimise,   [  --disable-optimise      compile without optimisations], wxUSE_OPTIMISE)
689
690 WX_ARG_ENABLE(profile,       [  --enable-profile        create code with profiling information], wxUSE_PROFILE)
691 WX_ARG_ENABLE(no_rtti,       [  --enable-no_rtti        create code without RTTI information], wxUSE_NO_RTTI)
692 WX_ARG_ENABLE(no_exceptions, [  --enable-no_exceptions  create code without C++ exceptions handling], wxUSE_NO_EXCEPTIONS)
693 WX_ARG_ENABLE(permissive,    [  --enable-permissive     compile code disregarding strict ANSI], wxUSE_PERMISSIVE)
694 WX_ARG_ENABLE(no_deps,       [  --enable-no_deps        create code without dependency information], wxUSE_NO_DEPS)
695 WX_ARG_DISABLE(vararg_macros,[  --disable-vararg_macros don't use vararg macros, even if they are supported], wxUSE_VARARG_MACROS)
696 WX_ARG_ENABLE_PARAM(universal_binary, [[  --enable-universal_binary  create Mac PowerPC and Intel Universal binary]], wxUSE_UNIVERSAL_BINARY)
697
698 WX_ARG_ENABLE(compat26,      [  --enable-compat26       enable wxWidgets 2.6 compatibility], WXWIN_COMPATIBILITY_2_6)
699 WX_ARG_DISABLE(compat28,     [  --disable-compat28      disable wxWidgets 2.8 compatibility], WXWIN_COMPATIBILITY_2_8)
700
701 WX_ARG_DISABLE(rpath,        [  --disable-rpath         disable use of rpath for uninstalled builds], wxUSE_RPATH)
702
703 WX_ARG_ENABLE(objc_uniquifying,[  --enable-objc_uniquifying enable Objective-C class name uniquifying], wxUSE_OBJC_UNIQUIFYING)
704
705 WX_ARG_DISABLE(visibility,   [  --disable-visibility    disable use of ELF symbols visibility even if supported], wxUSE_VISIBILITY)
706 WX_ARG_DISABLE(tls,          [  --disable-tls           disable use of compiler TLS support], wxUSE_COMPILER_TLS)
707
708 dnl ---------------------------------------------------------------------------
709 dnl optional non GUI features
710 dnl ---------------------------------------------------------------------------
711
712 WX_ARG_FEATURE(intl,          [  --enable-intl           use internationalization system], wxUSE_INTL)
713 WX_ARG_FEATURE(xlocale,       [  --enable-xlocale        use x-locale support (requires wxLocale)], wxUSE_XLOCALE)
714 WX_ARG_FEATURE(config,        [  --enable-config         use wxConfig (and derived) classes], wxUSE_CONFIG)
715
716 WX_ARG_FEATURE(protocols,     [  --enable-protocols      use wxProtocol and derived classes], wxUSE_PROTOCOL)
717 WX_ARG_FEATURE(ftp,           [  --enable-ftp            use wxFTP (requires wxProtocol], wxUSE_PROTOCOL_FTP)
718 WX_ARG_FEATURE(http,          [  --enable-http           use wxHTTP (requires wxProtocol], wxUSE_PROTOCOL_HTTP)
719 WX_ARG_FEATURE(fileproto,     [  --enable-fileproto      use wxFileProto class (requires wxProtocol], wxUSE_PROTOCOL_FILE)
720 WX_ARG_FEATURE(sockets,       [  --enable-sockets        use socket/network classes], wxUSE_SOCKETS)
721 WX_ARG_FEATURE(ipv6,          [  --enable-ipv6           enable IPv6 support in wxSocket], wxUSE_IPV6)
722 WX_ARG_FEATURE(ole,           [  --enable-ole            use OLE classes (Win32 only)], wxUSE_OLE)
723 WX_ARG_FEATURE(dataobj,       [  --enable-dataobj        use data object classes], wxUSE_DATAOBJ)
724
725 WX_ARG_FEATURE(ipc,           [  --enable-ipc            use interprocess communication (wxSocket etc.)], wxUSE_IPC)
726
727 WX_ARG_FEATURE(baseevtloop,   [  --enable-baseevtloop    use event loop in console programs too], wxUSE_CONSOLE_EVENTLOOP)
728 WX_ARG_FEATURE(epollloop,     [  --enable-epollloop      use wxEpollDispatcher class (Linux only)], wxUSE_EPOLL_DISPATCHER)
729 WX_ARG_FEATURE(selectloop,    [  --enable-selectloop     use wxSelectDispatcher class], wxUSE_SELECT_DISPATCHER)
730
731 dnl please keep the settings below in alphabetical order
732 WX_ARG_FEATURE(any,           [  --enable-any            use wxAny class], wxUSE_ANY)
733 WX_ARG_FEATURE(apple_ieee,    [  --enable-apple_ieee     use the Apple IEEE codec], wxUSE_APPLE_IEEE)
734 WX_ARG_FEATURE(arcstream,     [  --enable-arcstream      use wxArchive streams], wxUSE_ARCHIVE_STREAMS)
735 WX_ARG_FEATURE(base64,        [  --enable-base64         use base64 encoding/decoding functions], wxUSE_BASE64)
736 WX_ARG_FEATURE(backtrace,     [  --enable-backtrace      use wxStackWalker class for getting backtraces], wxUSE_STACKWALKER)
737 WX_ARG_FEATURE(catch_segvs,   [  --enable-catch_segvs    catch signals in wxApp::OnFatalException (Unix only)], wxUSE_ON_FATAL_EXCEPTION)
738 WX_ARG_FEATURE(cmdline,       [  --enable-cmdline        use wxCmdLineParser class], wxUSE_CMDLINE_PARSER)
739 WX_ARG_FEATURE(datetime,      [  --enable-datetime       use wxDateTime class], wxUSE_DATETIME)
740 WX_ARG_FEATURE(debugreport,   [  --enable-debugreport    use wxDebugReport class], wxUSE_DEBUGREPORT)
741 WX_ARG_FEATURE(dialupman,     [  --enable-dialupman      use dialup network classes], wxUSE_DIALUP_MANAGER)
742 WX_ARG_FEATURE(dynlib,        [  --enable-dynlib         use wxLibrary class for DLL loading], wxUSE_DYNLIB_CLASS)
743 WX_ARG_FEATURE(dynamicloader, [  --enable-dynamicloader  use (new) wxDynamicLibrary class], wxUSE_DYNAMIC_LOADER)
744 WX_ARG_FEATURE(exceptions,    [  --enable-exceptions     build exception-safe library], wxUSE_EXCEPTIONS)
745 WX_ARG_FEATURE(ffile,         [  --enable-ffile          use wxFFile class], wxUSE_FFILE)
746 WX_ARG_FEATURE(file,          [  --enable-file           use wxFile class], wxUSE_FILE)
747 WX_ARG_FEATURE(filesystem,    [  --enable-filesystem     use virtual file systems classes], wxUSE_FILESYSTEM)
748 WX_ARG_FEATURE(fontenum,      [  --enable-fontenum       use wxFontEnumerator class], wxUSE_FONTENUM)
749 WX_ARG_FEATURE(fontmap,       [  --enable-fontmap        use font encodings conversion classes], wxUSE_FONTMAP)
750 WX_ARG_FEATURE(fs_archive,    [  --enable-fs_archive     use virtual archive filesystems], wxUSE_FS_ARCHIVE)
751 WX_ARG_FEATURE(fs_inet,       [  --enable-fs_inet        use virtual HTTP/FTP filesystems], wxUSE_FS_INET)
752 WX_ARG_FEATURE(fs_zip,        [  --enable-fs_zip         now replaced by fs_archive], wxUSE_FS_ZIP)
753 WX_ARG_FEATURE(geometry,      [  --enable-geometry       use geometry class], wxUSE_GEOMETRY)
754 WX_ARG_FEATURE(log,           [  --enable-log            use logging system], wxUSE_LOG)
755 WX_ARG_FEATURE(longlong,      [  --enable-longlong       use wxLongLong class], wxUSE_LONGLONG)
756 WX_ARG_FEATURE(mimetype,      [  --enable-mimetype       use wxMimeTypesManager], wxUSE_MIMETYPE)
757 WX_ARG_FEATURE(printfposparam,[  --enable-printfposparam use wxVsnprintf() which supports positional parameters], wxUSE_PRINTF_POS_PARAMS)
758 WX_ARG_FEATURE(snglinst,      [  --enable-snglinst       use wxSingleInstanceChecker class], wxUSE_SNGLINST_CHECKER)
759 WX_ARG_FEATURE(sound,         [  --enable-sound          use wxSound class], wxUSE_SOUND)
760 WX_ARG_FEATURE(stdpaths,      [  --enable-stdpaths       use wxStandardPaths class], wxUSE_STDPATHS)
761 WX_ARG_FEATURE(stopwatch,     [  --enable-stopwatch      use wxStopWatch class], wxUSE_STOPWATCH)
762 WX_ARG_FEATURE(streams,       [  --enable-streams        use wxStream etc classes], wxUSE_STREAMS)
763 WX_ARG_FEATURE(system_options,[  --enable-sysoptions     use wxSystemOptions], wxUSE_SYSTEM_OPTIONS)
764 WX_ARG_FEATURE(tarstream,     [  --enable-tarstream      use wxTar streams], wxUSE_TARSTREAM)
765 WX_ARG_FEATURE(textbuf,       [  --enable-textbuf        use wxTextBuffer class], wxUSE_TEXTBUFFER)
766 WX_ARG_FEATURE(textfile,      [  --enable-textfile       use wxTextFile class], wxUSE_TEXTFILE)
767 WX_ARG_FEATURE(timer,         [  --enable-timer          use wxTimer class], wxUSE_TIMER)
768 WX_ARG_FEATURE(variant,       [  --enable-variant        use wxVariant class], wxUSE_VARIANT)
769 WX_ARG_FEATURE(zipstream,     [  --enable-zipstream      use wxZip streams], wxUSE_ZIPSTREAM)
770
771 dnl URL-related classes
772 WX_ARG_FEATURE(url,           [  --enable-url            use wxURL class], wxUSE_URL)
773 WX_ARG_FEATURE(protocol,      [  --enable-protocol       use wxProtocol class], wxUSE_PROTOCOL)
774 WX_ARG_FEATURE(protocol_http, [  --enable-protocol-http  HTTP support in wxProtocol], wxUSE_PROTOCOL_HTTP)
775 WX_ARG_FEATURE(protocol_ftp,  [  --enable-protocol-ftp   FTP support in wxProtocol], wxUSE_PROTOCOL_FTP)
776 WX_ARG_FEATURE(protocol_file, [  --enable-protocol-file  FILE support in wxProtocol], wxUSE_PROTOCOL_FILE)
777
778 WX_ARG_FEATURE(threads,     [  --enable-threads        use threads], wxUSE_THREADS)
779
780 WX_ARG_ENABLE(iniconf,      [  --enable-iniconf        use wxIniConfig (Win32 only)], wxUSE_INICONF)
781 WX_ARG_FEATURE(regkey,      [  --enable-regkey         use wxRegKey class (Win32 only)], wxUSE_REGKEY)
782
783 if test "$wxUSE_GUI" = "yes"; then
784
785 dnl ---------------------------------------------------------------------------
786 dnl optional "big" GUI features
787 dnl ---------------------------------------------------------------------------
788
789 WX_ARG_FEATURE(docview,     [  --enable-docview        use document view architecture], wxUSE_DOC_VIEW_ARCHITECTURE)
790 WX_ARG_FEATURE(help,        [  --enable-help           use help subsystem], wxUSE_HELP)
791 WX_ARG_FEATURE(mshtmlhelp,  [  --enable-mshtmlhelp     use MS HTML Help (win32)], wxUSE_MS_HTML_HELP)
792 WX_ARG_FEATURE(html,        [  --enable-html           use wxHTML sub-library], wxUSE_HTML)
793 WX_ARG_FEATURE(htmlhelp,    [  --enable-htmlhelp       use wxHTML-based help], wxUSE_WXHTML_HELP)
794 WX_ARG_FEATURE(xrc,         [  --enable-xrc            use XRC resources sub-library], wxUSE_XRC)
795 WX_ARG_FEATURE(aui,         [  --enable-aui            use AUI docking library], wxUSE_AUI)
796 WX_ARG_FEATURE(propgrid,    [  --enable-propgrid       use wxPropertyGrid library], wxUSE_PROPGRID)
797 WX_ARG_FEATURE(ribbon,      [  --enable-ribbon         use wxRibbon library], wxUSE_RIBBON)
798 WX_ARG_FEATURE(stc,         [  --enable-stc            use wxStyledTextCtrl library], wxUSE_STC)
799 WX_ARG_FEATURE(constraints, [  --enable-constraints    use layout-constraints system], wxUSE_CONSTRAINTS)
800 WX_ARG_FEATURE(loggui,      [  --enable-loggui         use standard GUI logger], wxUSE_LOGGUI)
801 WX_ARG_FEATURE(logwin,      [  --enable-logwin         use wxLogWindow], wxUSE_LOGWINDOW)
802 WX_ARG_FEATURE(logdialog,   [  --enable-logdialog      use wxLogDialog], wxUSE_LOGDIALOG)
803 WX_ARG_FEATURE(mdi,         [  --enable-mdi            use multiple document interface architecture], wxUSE_MDI)
804 WX_ARG_FEATURE(mdidoc,      [  --enable-mdidoc         use docview architecture with MDI], wxUSE_MDI_ARCHITECTURE)
805 WX_ARG_FEATURE(mediactrl,   [  --enable-mediactrl      use wxMediaCtrl class], wxUSE_MEDIACTRL)
806 WX_ARG_FEATURE(gstreamer8,  [  --enable-gstreamer8     force GStreamer 0.8 instead of 0.10 with the wxMediaCtrl class on unix], wxUSE_GSTREAMER8)
807 WX_ARG_FEATURE(webkit,      [  --enable-webkit         use wxWebKitCtrl (Mac)], wxUSE_WEBKIT)
808 WX_ARG_FEATURE(richtext,    [  --enable-richtext       use wxRichTextCtrl], wxUSE_RICHTEXT)
809 WX_ARG_FEATURE(graphics_ctx,[  --enable-graphics_ctx   use graphics context 2D drawing API], wxUSE_GRAPHICS_CONTEXT)
810 WX_ARG_FEATURE(postscript,  [  --enable-postscript     use wxPostscriptDC device context (default for gtk+)], wxUSE_POSTSCRIPT)
811 WX_ARG_FEATURE(printarch,   [  --enable-printarch      use printing architecture], wxUSE_PRINTING_ARCHITECTURE)
812 WX_ARG_FEATURE(svg,         [  --enable-svg            use wxSVGFileDC device context], wxUSE_SVG)
813
814 dnl ---------------------------------------------------------------------------
815 dnl IPC &c
816 dnl ---------------------------------------------------------------------------
817
818 WX_ARG_FEATURE(clipboard,   [  --enable-clipboard      use wxClipboard class], wxUSE_CLIPBOARD)
819 WX_ARG_FEATURE(dnd,         [  --enable-dnd            use Drag'n'Drop classes], wxUSE_DRAG_AND_DROP)
820 WX_ARG_FEATURE(metafile,    [  --enable-metafile       use win32 metafiles], wxUSE_METAFILE)
821
822 dnl ---------------------------------------------------------------------------
823 dnl optional GUI controls (in alphabetical order except the first one)
824 dnl ---------------------------------------------------------------------------
825
826 dnl don't set DEFAULT_wxUSE_XXX below if the option is not specified
827 DEFAULT_wxUSE_CONTROLS=none
828 WX_ARG_DISABLE(controls,    [  --disable-controls      disable compilation of all standard controls], wxUSE_CONTROLS)
829
830 dnl even with --disable-controls, some may be enabled by an explicit
831 dnl --enable-<control> later on the command line -- but by default all will be
832 dnl disabled
833 if test "$wxUSE_CONTROLS" = "no"; then
834     DEFAULT_wxUSE_ACCEL=no
835     DEFAULT_wxUSE_ANIMATIONCTRL=no
836     DEFAULT_wxUSE_BMPBUTTON=no
837     DEFAULT_wxUSE_BUTTON=no
838     DEFAULT_wxUSE_CALCTRL=no
839     DEFAULT_wxUSE_CARET=no
840     DEFAULT_wxUSE_CHECKBOX=no
841     DEFAULT_wxUSE_CHECKLISTBOX=no
842     DEFAULT_wxUSE_CHOICE=no
843     DEFAULT_wxUSE_CHOICEBOOK=no
844     DEFAULT_wxUSE_COLLPANE=no
845     DEFAULT_wxUSE_COLOURPICKERCTRL=no
846     DEFAULT_wxUSE_COMBOBOX=no
847     DEFAULT_wxUSE_COMBOBOX=no
848     DEFAULT_wxUSE_DATAVIEWCTRL=no
849     DEFAULT_wxUSE_DATEPICKCTRL=no
850     DEFAULT_wxUSE_DETECT_SM=no
851     DEFAULT_wxUSE_DIRPICKERCTRL=no
852     DEFAULT_wxUSE_DISPLAY=no
853     DEFAULT_wxUSE_FILECTRL=no
854     DEFAULT_wxUSE_FILEPICKERCTRL=no
855     DEFAULT_wxUSE_FONTPICKERCTRL=no
856     DEFAULT_wxUSE_GAUGE=no
857     DEFAULT_wxUSE_GRID=no
858     DEFAULT_wxUSE_HEADERCTRL=no
859     DEFAULT_wxUSE_HYPERLINKCTRL=no
860     DEFAULT_wxUSE_IMAGLIST=no
861     DEFAULT_wxUSE_LISTBOOK=no
862     DEFAULT_wxUSE_LISTBOX=no
863     DEFAULT_wxUSE_LISTCTRL=no
864     DEFAULT_wxUSE_NOTEBOOK=no
865     DEFAULT_wxUSE_POPUPWIN=no
866     DEFAULT_wxUSE_RADIOBOX=no
867     DEFAULT_wxUSE_RADIOBTN=no
868     DEFAULT_wxUSE_REARRANGECTRL=no
869     DEFAULT_wxUSE_SASH=no
870     DEFAULT_wxUSE_SCROLLBAR=no
871     DEFAULT_wxUSE_SEARCHCTRL=no
872     DEFAULT_wxUSE_SLIDER=no
873     DEFAULT_wxUSE_SPINBTN=no
874     DEFAULT_wxUSE_SPINCTRL=no
875     DEFAULT_wxUSE_SPLITTER=no
876     DEFAULT_wxUSE_STATBMP=no
877     DEFAULT_wxUSE_STATBOX=no
878     DEFAULT_wxUSE_STATLINE=no
879     DEFAULT_wxUSE_STATUSBAR=no
880     DEFAULT_wxUSE_TIPWINDOW=no
881     DEFAULT_wxUSE_TOGGLEBTN=no
882     DEFAULT_wxUSE_TOOLBAR=no
883     DEFAULT_wxUSE_TOOLBAR_NATIVE=no
884     DEFAULT_wxUSE_TOOLBOOK=no
885     DEFAULT_wxUSE_TOOLTIPS=no
886     DEFAULT_wxUSE_TREEBOOK=no
887     DEFAULT_wxUSE_TREECTRL=no
888 fi
889
890 dnl please keep the settings below in alphabetical order
891 WX_ARG_FEATURE(accel,       [  --enable-accel          use accelerators], wxUSE_ACCEL)
892 WX_ARG_FEATURE(animatectrl, [  --enable-animatectrl    use wxAnimationCtrl class], wxUSE_ANIMATIONCTRL)
893 WX_ARG_FEATURE(bmpbutton,   [  --enable-bmpbutton      use wxBitmapButton class], wxUSE_BMPBUTTON)
894 WX_ARG_FEATURE(bmpcombobox, [  --enable-bmpcombobox    use wxBitmapComboBox class], wxUSE_BITMAPCOMBOBOX)
895 WX_ARG_FEATURE(button,      [  --enable-button         use wxButton class], wxUSE_BUTTON)
896 WX_ARG_FEATURE(calendar,    [  --enable-calendar       use wxCalendarCtrl class], wxUSE_CALCTRL)
897 WX_ARG_FEATURE(caret,       [  --enable-caret          use wxCaret class], wxUSE_CARET)
898 WX_ARG_FEATURE(checkbox,    [  --enable-checkbox       use wxCheckBox class], wxUSE_CHECKBOX)
899 WX_ARG_FEATURE(checklst,    [  --enable-checklst       use wxCheckListBox (listbox with checkboxes) class], wxUSE_CHECKLST)
900 WX_ARG_FEATURE(choice,      [  --enable-choice         use wxChoice class], wxUSE_CHOICE)
901 WX_ARG_FEATURE(choicebook,  [  --enable-choicebook     use wxChoicebook class], wxUSE_CHOICEBOOK)
902 WX_ARG_FEATURE(collpane,    [  --enable-collpane       use wxCollapsiblePane class], wxUSE_COLLPANE)
903 WX_ARG_FEATURE(colourpicker,[  --enable-colourpicker   use wxColourPickerCtrl class], wxUSE_COLOURPICKERCTRL)
904 WX_ARG_FEATURE(combobox,    [  --enable-combobox       use wxComboBox class], wxUSE_COMBOBOX)
905 WX_ARG_FEATURE(comboctrl,   [  --enable-comboctrl      use wxComboCtrl class], wxUSE_COMBOCTRL)
906 WX_ARG_FEATURE(dataviewctrl,[  --enable-dataviewctrl   use wxDataViewCtrl class], wxUSE_DATAVIEWCTRL)
907 WX_ARG_FEATURE(datepick,    [  --enable-datepick       use wxDatePickerCtrl class], wxUSE_DATEPICKCTRL)
908 WX_ARG_FEATURE(detect_sm,   [  --enable-detect_sm      use code to detect X11 session manager], wxUSE_DETECT_SM)
909 WX_ARG_FEATURE(dirpicker,   [  --enable-dirpicker      use wxDirPickerCtrl class], wxUSE_DIRPICKERCTRL)
910 WX_ARG_FEATURE(display,     [  --enable-display        use wxDisplay class], wxUSE_DISPLAY)
911 WX_ARG_FEATURE(editablebox, [  --enable-editablebox    use wxEditableListBox class], wxUSE_EDITABLELISTBOX)
912 WX_ARG_FEATURE(filectrl,    [  --enable-filectrl       use wxFileCtrl class], wxUSE_FILECTRL)
913 WX_ARG_FEATURE(filepicker,  [  --enable-filepicker     use wxFilePickerCtrl class], wxUSE_FILEPICKERCTRL)
914 WX_ARG_FEATURE(fontpicker,  [  --enable-fontpicker     use wxFontPickerCtrl class], wxUSE_FONTPICKERCTRL)
915 WX_ARG_FEATURE(gauge,       [  --enable-gauge          use wxGauge class], wxUSE_GAUGE)
916 WX_ARG_FEATURE(grid,        [  --enable-grid           use wxGrid class], wxUSE_GRID)
917 WX_ARG_FEATURE(headerctrl,  [  --enable-headerctrl     use wxHeaderCtrl class], wxUSE_HEADERCTRL)
918 WX_ARG_FEATURE(hyperlink,   [  --enable-hyperlink      use wxHyperlinkCtrl class], wxUSE_HYPERLINKCTRL)
919 WX_ARG_FEATURE(imaglist,    [  --enable-imaglist       use wxImageList class], wxUSE_IMAGLIST)
920 WX_ARG_FEATURE(infobar,     [  --enable-infobar        use wxInfoBar class], wxUSE_INFOBAR)
921 WX_ARG_FEATURE(listbook,    [  --enable-listbook       use wxListbook class], wxUSE_LISTBOOK)
922 WX_ARG_FEATURE(listbox,     [  --enable-listbox        use wxListBox class], wxUSE_LISTBOX)
923 WX_ARG_FEATURE(listctrl,    [  --enable-listctrl       use wxListCtrl class], wxUSE_LISTCTRL)
924 WX_ARG_FEATURE(notebook,    [  --enable-notebook       use wxNotebook class], wxUSE_NOTEBOOK)
925 WX_ARG_FEATURE(notifmsg,    [  --enable-notifmsg       use wxNotificationMessage class], wxUSE_NOTIFICATION_MESSAGE)
926 WX_ARG_FEATURE(odcombobox,  [  --enable-odcombobox     use wxOwnerDrawnComboBox class], wxUSE_ODCOMBOBOX)
927 WX_ARG_FEATURE(popupwin,    [  --enable-popupwin       use wxPopUpWindow class], wxUSE_POPUPWIN)
928 WX_ARG_FEATURE(radiobox,    [  --enable-radiobox       use wxRadioBox class], wxUSE_RADIOBOX)
929 WX_ARG_FEATURE(radiobtn,    [  --enable-radiobtn       use wxRadioButton class], wxUSE_RADIOBTN)
930 WX_ARG_FEATURE(rearrangectrl,[  --enable-rearrangectrl  use wxRearrangeList/Ctrl/Dialog], wxUSE_REARRANGECTRL)
931 WX_ARG_FEATURE(sash,        [  --enable-sash           use wxSashWindow class], wxUSE_SASH)
932 WX_ARG_FEATURE(scrollbar,   [  --enable-scrollbar      use wxScrollBar class and scrollable windows], wxUSE_SCROLLBAR)
933 WX_ARG_FEATURE(searchctrl,  [  --enable-searchctrl     use wxSearchCtrl class], wxUSE_SEARCHCTRL)
934 WX_ARG_FEATURE(slider,      [  --enable-slider         use wxSlider class], wxUSE_SLIDER)
935 WX_ARG_FEATURE(spinbtn,     [  --enable-spinbtn        use wxSpinButton class], wxUSE_SPINBTN)
936 WX_ARG_FEATURE(spinctrl,    [  --enable-spinctrl       use wxSpinCtrl class], wxUSE_SPINCTRL)
937 WX_ARG_FEATURE(splitter,    [  --enable-splitter       use wxSplitterWindow class], wxUSE_SPLITTER)
938 WX_ARG_FEATURE(statbmp,     [  --enable-statbmp        use wxStaticBitmap class], wxUSE_STATBMP)
939 WX_ARG_FEATURE(statbox,     [  --enable-statbox        use wxStaticBox class], wxUSE_STATBOX)
940 WX_ARG_FEATURE(statline,    [  --enable-statline       use wxStaticLine class], wxUSE_STATLINE)
941 WX_ARG_FEATURE(stattext,    [  --enable-stattext       use wxStaticText class], wxUSE_STATTEXT)
942 WX_ARG_FEATURE(statusbar,   [  --enable-statusbar      use wxStatusBar class], wxUSE_STATUSBAR)
943 WX_ARG_FEATURE(taskbaricon, [  --enable-taskbaricon    use wxTaskBarIcon class], wxUSE_TASKBARICON)
944 WX_ARG_FEATURE(tbarnative,  [  --enable-tbarnative     use native wxToolBar class], wxUSE_TOOLBAR_NATIVE)
945 WX_ARG_FEATURE(textctrl,    [  --enable-textctrl       use wxTextCtrl class], wxUSE_TEXTCTRL)
946 WX_ARG_FEATURE(tipwindow,   [  --enable-tipwindow      use wxTipWindow class], wxUSE_TIPWINDOW)
947 WX_ARG_FEATURE(togglebtn,   [  --enable-togglebtn      use wxToggleButton class], wxUSE_TOGGLEBTN)
948 WX_ARG_FEATURE(toolbar,     [  --enable-toolbar        use wxToolBar class], wxUSE_TOOLBAR)
949 WX_ARG_FEATURE(toolbook,    [  --enable-toolbook       use wxToolbook class], wxUSE_TOOLBOOK)
950 WX_ARG_FEATURE(treebook,    [  --enable-treebook       use wxTreebook class], wxUSE_TREEBOOK)
951 WX_ARG_FEATURE(treectrl,    [  --enable-treectrl       use wxTreeCtrl class], wxUSE_TREECTRL)
952
953 dnl ---------------------------------------------------------------------------
954 dnl common dialogs
955 dnl ---------------------------------------------------------------------------
956
957 WX_ARG_FEATURE(commondlg,   [  --enable-commondlg      use all common dialogs], wxUSE_COMMONDLGS)
958 WX_ARG_FEATURE(aboutdlg,    [  --enable-aboutdlg       use wxAboutBox], wxUSE_ABOUTDLG)
959 WX_ARG_FEATURE(choicedlg,   [  --enable-choicedlg      use wxChoiceDialog], wxUSE_CHOICEDLG)
960 WX_ARG_FEATURE(coldlg,      [  --enable-coldlg         use wxColourDialog], wxUSE_COLOURDLG)
961 WX_ARG_FEATURE(filedlg,     [  --enable-filedlg        use wxFileDialog], wxUSE_FILEDLG)
962 WX_ARG_FEATURE(finddlg,     [  --enable-finddlg        use wxFindReplaceDialog], wxUSE_FINDREPLDLG)
963 WX_ARG_FEATURE(fontdlg,     [  --enable-fontdlg        use wxFontDialog], wxUSE_FONTDLG)
964 WX_ARG_FEATURE(dirdlg,      [  --enable-dirdlg         use wxDirDialog], wxUSE_DIRDLG)
965 WX_ARG_FEATURE(msgdlg,      [  --enable-msgdlg         use wxMessageDialog], wxUSE_MSGDLG)
966 WX_ARG_FEATURE(numberdlg,   [  --enable-numberdlg      use wxNumberEntryDialog], wxUSE_NUMBERDLG)
967 WX_ARG_FEATURE(splash,      [  --enable-splash         use wxSplashScreen], wxUSE_SPLASH)
968 WX_ARG_FEATURE(textdlg,     [  --enable-textdlg        use wxTextDialog], wxUSE_TEXTDLG)
969 WX_ARG_FEATURE(tipdlg,      [  --enable-tipdlg         use startup tips], wxUSE_STARTUP_TIPS)
970 WX_ARG_FEATURE(progressdlg, [  --enable-progressdlg    use wxProgressDialog], wxUSE_PROGRESSDLG)
971 WX_ARG_FEATURE(wizarddlg,   [  --enable-wizarddlg      use wxWizard], wxUSE_WIZARDDLG)
972
973 dnl ---------------------------------------------------------------------------
974 dnl misc GUI options
975 dnl ---------------------------------------------------------------------------
976
977 WX_ARG_FEATURE(menus,       [  --enable-menus          use wxMenu/wxMenuBar/wxMenuItem classes], wxUSE_MENUS)
978 WX_ARG_FEATURE(miniframe,   [  --enable-miniframe      use wxMiniFrame class], wxUSE_MINIFRAME)
979 WX_ARG_FEATURE(tooltips,    [  --enable-tooltips       use wxToolTip class], wxUSE_TOOLTIPS)
980 WX_ARG_FEATURE(splines,     [  --enable-splines        use spline drawing code], wxUSE_SPLINES)
981 WX_ARG_FEATURE(mousewheel,  [  --enable-mousewheel     use mousewheel], wxUSE_MOUSEWHEEL)
982 WX_ARG_FEATURE(validators,  [  --enable-validators     use wxValidator and derived classes], wxUSE_VALIDATORS)
983 WX_ARG_FEATURE(busyinfo,    [  --enable-busyinfo       use wxBusyInfo], wxUSE_BUSYINFO)
984 WX_ARG_FEATURE(joystick,    [  --enable-joystick       use wxJoystick], wxUSE_JOYSTICK)
985 WX_ARG_FEATURE(metafile,    [  --enable-metafiles      use wxMetaFile (Win32 only)], wxUSE_METAFILE)
986 WX_ARG_FEATURE(dragimage,   [  --enable-dragimage      use wxDragImage], wxUSE_DRAGIMAGE)
987 WX_ARG_FEATURE(accessibility,[  --enable-accessibility  enable accessibility support], wxUSE_ACCESSIBILITY)
988
989 dnl ---------------------------------------------------------------------------
990 dnl support for image formats that do not rely on external library
991 dnl ---------------------------------------------------------------------------
992
993 WX_ARG_FEATURE(palette,     [  --enable-palette        use wxPalette class], wxUSE_PALETTE)
994 WX_ARG_FEATURE(image,       [  --enable-image          use wxImage class], wxUSE_IMAGE)
995 WX_ARG_FEATURE(gif,         [  --enable-gif            use gif images (GIF file format)], wxUSE_GIF)
996 WX_ARG_FEATURE(pcx,         [  --enable-pcx            use pcx images (PCX file format)], wxUSE_PCX)
997 WX_ARG_FEATURE(tga,         [  --enable-tga            use tga images (TGA file format)], wxUSE_TGA)
998 WX_ARG_FEATURE(iff,         [  --enable-iff            use iff images (IFF file format)], wxUSE_IFF)
999 WX_ARG_FEATURE(pnm,         [  --enable-pnm            use pnm images (PNM file format)], wxUSE_PNM)
1000 WX_ARG_FEATURE(xpm,         [  --enable-xpm            use xpm images (XPM file format)], wxUSE_XPM)
1001 WX_ARG_FEATURE(ico_cur,     [  --enable-ico_cur        use Windows ICO and CUR formats], wxUSE_ICO_CUR)
1002
1003 dnl ---------------------------------------------------------------------------
1004 dnl wxMSW-only options
1005 dnl ---------------------------------------------------------------------------
1006
1007 WX_ARG_FEATURE(dccache,     [  --enable-dccache        cache temporary wxDC objects (Win32 only)], wxUSE_DC_CACHEING)
1008 WX_ARG_FEATURE(ps-in-msw,   [  --enable-ps-in-msw      use PS printing in wxMSW (Win32 only)], wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW)
1009 WX_ARG_FEATURE(ownerdrawn,  [  --enable-ownerdrawn     use owner drawn controls (Win32 and OS/2 only)], wxUSE_OWNER_DRAWN)
1010 WX_ARG_FEATURE(uxtheme,     [  --enable-uxtheme        enable support for Windows XP themed look (Win32 only)], wxUSE_UXTHEME)
1011 WX_ARG_FEATURE(wxdib,       [  --enable-wxdib          use wxDIB class (Win32 only)], wxUSE_DIB)
1012
1013 dnl this one is not really MSW-specific but it exists mainly to be turned off
1014 dnl under MSW, it should be off by default on the other platforms
1015 if test "$wxUSE_MSW" != 1; then
1016     DEFAULT_wxUSE_AUTOID_MANAGEMENT=no
1017 fi
1018
1019 WX_ARG_FEATURE(autoidman,   [  --enable-autoidman      use automatic ids management], wxUSE_AUTOID_MANAGEMENT)
1020
1021 fi
1022 dnl for GUI only
1023
1024 dnl ---------------------------------------------------------------------------
1025 dnl Checks for programs
1026 dnl ---------------------------------------------------------------------------
1027
1028 dnl flush the cache because checking for programs might abort
1029 AC_CACHE_SAVE
1030
1031 dnl C-compiler checks
1032 dnl   defines CC with the compiler to use
1033 dnl   defines GCC with yes if using gcc
1034 dnl   defines GCC empty if not using gcc
1035 dnl   defines CFLAGS
1036 dnl
1037 dnl this magic incantation is needed to prevent AC_PROG_CC from setting the
1038 dnl default CFLAGS (something like "-g -O2") -- we don't need this as we add
1039 dnl (if not already present in C*FLAGS) the -g and -O flags ourselves below
1040 CFLAGS=${CFLAGS:=}
1041 AC_BAKEFILE_PROG_CC
1042
1043 dnl is -traditional needed for correct compilations
1044 dnl   adds -traditional for gcc if needed
1045 AC_PROG_GCC_TRADITIONAL
1046
1047 dnl C++-compiler checks
1048 dnl   defines CXX with the compiler to use
1049 dnl   defines GXX with yes if using gxx
1050 dnl   defines GXX empty if not using gxx
1051 dnl   defines CXXFLAGS
1052 dnl
1053 dnl see CFLAGS line above
1054 CXXFLAGS=${CXXFLAGS:=}
1055 AC_BAKEFILE_PROG_CXX
1056
1057 dnl configure always sets CXX to something as it falls back to g++ even if no
1058 dnl C++ compiler was found, but we prefer to abort now with a clear error
1059 dnl message rather than give errors about all tests failures below
1060 if test "$CXX" = "g++" -a "$GXX" != "yes"; then
1061     AC_MSG_ERROR([C++ compiler is needed to build wxWidgets])
1062 fi
1063
1064 dnl ar command
1065 dnl   defines AR with the appropriate command
1066 dnl
1067 dnl For Sun CC AC_BAKEFILE below sets AR to the compiler itself.
1068 if test "x$SUNCXX" != xyes; then
1069     AC_CHECK_TOOL(AR, ar)
1070     if test "x$AR" = "x" ; then
1071         AC_MSG_ERROR([ar is needed to build wxWidgets])
1072     fi
1073 fi
1074
1075 dnl ---------------------------------------------------------------------------
1076 dnl Mac-specific SDK/architectures checks
1077 dnl ---------------------------------------------------------------------------
1078
1079 if test "$wxUSE_MAC" = 1; then
1080
1081 retest_macosx_linking=no
1082
1083 dnl Support the old --enable-universal_binary in case anyone was using it.
1084     if test "x$wxUSE_UNIVERSAL_BINARY" != xno ; then
1085         dnl --enable-universal_binary uses a default SDK (currently 10.4u)
1086         dnl --enable-universal_binary=SDK names a path to an SDK
1087         if test "x$wxUSE_UNIVERSAL_BINARY" == xyes; then
1088             # Implicitly turn on the new --with-macosx-sdk using the default
1089             # SDK which provides the behavior this option has always had.
1090             if test "x$wxUSE_MACOSX_SDK" = "x"; then
1091                 AC_MSG_WARN([Enabling default SDK due to --enable-universal_binary.])
1092                 AC_MSG_WARN([If you don't want this, specify --without-macosx-sdk])
1093                 wxUSE_MACOSX_SDK=yes
1094             fi
1095         else
1096             # Complain to user if he specified an argument to --enable-universal_binary
1097             # and also 1) specified --with-macosx-sdk using the default (yes) or
1098             # 2) specified --with-macosx-sdk using a path or 3) specified
1099             # --without-macosx-sdk (no).
1100             if test "x$wxUSE_MACOSX_SDK" != "x" ; then
1101                 AC_MSG_FAILURE([Please specify the new --with-macosx-sdk=PATH and do not specify an arg to --enable-universal_binary])
1102             else
1103                 # Put the SDK path into the wxUSE_MACOSX_SDK.  We don't have to
1104                 # special-case the empty string because the below test simply
1105                 # converts "no" to the empty string anyway.
1106                 wxUSE_MACOSX_SDK="$wxUSE_UNIVERSAL_BINARY"
1107                 dnl Warn about deprecated usage.
1108                 AC_MSG_WARN([Please use --with-macosx-sdk=PATH and --enable-universal_binary without an argument])
1109             fi
1110         fi
1111         dnl FIXME: I think it would be better to put this into CC, CXX, and LD rather than the flags.
1112         OSX_UNIV_OPTS="-arch ppc -arch i386"
1113         CXXFLAGS="$OSX_UNIV_OPTS $CXXFLAGS"
1114         CFLAGS="$OSX_UNIV_OPTS $CFLAGS"
1115         OBJCXXFLAGS="$OSX_UNIV_OPTS $OBJCXXFLAGS"
1116         OBJCFLAGS="$OSX_UNIV_OPTS $OBJCFLAGS"
1117         LDFLAGS="$OSX_UNIV_OPTS $LDFLAGS"
1118         dnl NOTE: Only the compiler driver needs arch flags.  The link editor
1119         dnl is incapable of using them but the compiler driver (which we use
1120         dnl as LD when building dynamic libraries) uses them to invoke the
1121         dnl real ld multiple times.  If we moved to libtool -dynamic we would
1122         dnl need no arch flags because libtool automatically invokes ld for
1123         dnl every architecture found in the fat input files.
1124         dnl
1125         dnl For static library builds, AR/RANLIB automatically create proper
1126         dnl fat archives although AR is unable to update them once RANLIB has
1127         dnl made them into proper fat archives.  Fortunately, our link process
1128         dnl simply removes the .a file before using ar to create a new one.
1129         dnl If we did move to libtool -static we still wouldn't need arch flags
1130         dnl because libtool automatically figures it out based on input.
1131         retest_macosx_linking=yes
1132
1133         dnl HACK: PCH could be made to work by precompiling for each architecture into separate directories
1134         dnl and including all architecture directories with each compiler invocation.
1135         dnl That would require a major rework of Bakefile and at the same time it would be nice to have
1136         dnl Objective-C++ precompiled headers.
1137         AC_MSG_WARN([Disabling precompiled headers due to universal binary build.])
1138         bk_use_pch=no
1139     fi
1140
1141 dnl Set up the Mac OS X SDK.  We do this early so configure tests will occur
1142 dnl with the SDK in place.
1143 dnl NOTE: We clobber wxUSE_MACOSX_SDK with the SDK path
1144 if test "x$wxUSE_MACOSX_SDK" = "xno"; then
1145     wxUSE_MACOSX_SDK=
1146 elif test "x$wxUSE_MACOSX_SDK" = "xyes"; then
1147     # TODO: Search for most recent SDK and use it.
1148     wxUSE_MACOSX_SDK="/Developer/SDKs/MacOSX10.4u.sdk"
1149 fi
1150
1151
1152 if test "x$wxUSE_MACOSX_SDK" != "x"; then
1153     AC_MSG_CHECKING([for SDK directory $wxUSE_MACOSX_SDK])
1154     if ! test -d "$wxUSE_MACOSX_SDK"; then
1155         AC_MSG_FAILURE([not found])
1156     else
1157         AC_MSG_RESULT([exists])
1158     fi
1159     MACOSX_SDK_OPTS="-isysroot $wxUSE_MACOSX_SDK"
1160     eval "CC=\"$CC $MACOSX_SDK_OPTS\""
1161     eval "CXX=\"$CXX $MACOSX_SDK_OPTS\""
1162     eval "LD=\"$LD $MACOSX_SDK_OPTS\""
1163     retest_macosx_linking=yes
1164     dnl NOTE: When libtool is used in lieu of AR/RANLIB (i.e. in static mode)
1165     dnl the syslibroot makes no difference.  We aren't using libtool now but
1166     dnl if we ever did, be aware that you don't need to worry about it.
1167 fi
1168
1169 dnl Set up the deployment target
1170 dnl No   : Don't specify a min version even if using an SDK
1171 dnl Yes  : Use the version from the SDK if used, otherwise same as no
1172 dnl Param: Use the specified version
1173 if test "x$wxUSE_MACOSX_VERSION_MIN" = "xno"; then
1174     wxUSE_MACOSX_VERSION_MIN=
1175 elif test "x$wxUSE_MACOSX_VERSION_MIN" = "xyes"; then
1176     if test "x$wxUSE_MACOSX_SDK" != "x"; then
1177         AC_MSG_CHECKING([SDK deployment version])
1178 dnl We need to quote the next line where we don't need macros and do need [] in the regex
1179 [
1180         MACOSX_SDK_PLIST_VERSION_MIN=`defaults read "$wxUSE_MACOSX_SDK/SDKSettings" buildSettings | grep '^ *"\{0,1\}MACOSX_DEPLOYMENT_TARGET"\{0,1\} *= *"\{0,1\}[^"]*"\{0,1\}; *$' | sed 's/^ *"\{0,1\}MACOSX_DEPLOYMENT_TARGET"\{0,1\} *= *"\{0,1\}\([^"]*\)"\{0,1\} *; *$/\1/'`
1181 ]
1182         # If that failed, try again with the new key
1183         if test "x$MACOSX_SDK_PLIST_VERSION_MIN" == "x"; then
1184 [
1185             MACOSX_SDK_PLIST_VERSION_MIN=`defaults read "$wxUSE_MACOSX_SDK/SDKSettings" DefaultProperties | grep '^ *"\{0,1\}MACOSX_DEPLOYMENT_TARGET"\{0,1\} *= *"\{0,1\}[^"]*"\{0,1\}; *$' | sed 's/^ *"\{0,1\}MACOSX_DEPLOYMENT_TARGET"\{0,1\} *= *"\{0,1\}\([^"]*\)"\{0,1\} *; *$/\1/'`
1186 ]
1187         fi
1188
1189         if test "x$MACOSX_SDK_PLIST_VERSION_MIN" != "x"; then
1190             wxUSE_MACOSX_VERSION_MIN=$MACOSX_SDK_PLIST_VERSION_MIN
1191             AC_MSG_RESULT([$wxUSE_MACOSX_VERSION_MIN])
1192         else
1193             AC_MSG_WARN([Could not determine deployment target from SDKSettings.plist])
1194             wxUSE_MACOSX_VERSION_MIN=
1195         fi
1196     else
1197         wxUSE_MACOSX_VERSION_MIN=
1198     fi
1199 elif test "x$wxUSE_MACOSX_VERSION_MIN" = "x"; then
1200     OSX_VERSION=`sw_vers -productVersion | grep 10.[[0-9]]`
1201     if test "$wxUSE_OSX_CARBON" = 1 -o "x$OSX_VERSION" = "x10.4"; then
1202         # otherwise configure stops on leopard for universal_binary
1203         wxUSE_MACOSX_VERSION_MIN=10.4
1204     else
1205         # for OS X Cocoa, use 10.5 so we can get 64-bit compile on Snow Leopard
1206         wxUSE_MACOSX_VERSION_MIN=10.5
1207     fi
1208 fi
1209
1210 NEEDS_GCC40="no"
1211 if test "x$wxUSE_MACOSX_VERSION_MIN" == "x10.4"; then
1212     NEEDS_GCC40="yes"
1213 fi
1214
1215 if test "$wxUSE_OSX_CARBON" = 1; then
1216     NEEDS_GCC40="yes"
1217 fi
1218
1219 if test "x$NEEDS_GCC40" == "xyes"; then
1220     # gcc 4.2 cannot compile 10.4 compatible code, so if the user is using it
1221     # and wants 10.4 compatible code, then 'downgrade' to 4.0
1222     # This is also the simplest way to get 32-bit binaries on Snow Leopard.
1223     if test "x$CC" = "xgcc"; then
1224         CCVERSION=`$CC --version | grep 4.[[2-9]].`
1225         if test "x$CCVERSION" != "x"; then
1226             echo "$as_me:$LINENO: WARNING: gcc >= 4.2 cannot compile 10.4 compatible code. Using gcc 4.0 instead."
1227             CC="/usr/bin/gcc-4.0"
1228         fi
1229     fi
1230
1231     if test "x$CXX" = "xg++"; then
1232         CCVERSION=`$CXX --version | grep 4.[[2-9]].`
1233         if test "x$CCVERSION" != "x"; then
1234             CXX="/usr/bin/g++-4.0"
1235         fi
1236     fi
1237 fi
1238
1239 if test "x$wxUSE_MACOSX_VERSION_MIN" != "x"; then
1240     MACOSX_VERSION_MIN_OPTS="-mmacosx-version-min=$wxUSE_MACOSX_VERSION_MIN"
1241     eval "CC=\"$CC $MACOSX_VERSION_MIN_OPTS\""
1242     eval "CXX=\"$CXX $MACOSX_VERSION_MIN_OPTS\""
1243     eval "LD=\"$LD $MACOSX_VERSION_MIN_OPTS\""
1244     retest_macosx_linking=yes
1245 fi
1246
1247 dnl If either an SDK or a version option was added, make sure that we can
1248 dnl still compile and link both C and C++.  If we didn't do this, then most
1249 dnl of the remaining tests would fail.
1250 if test "x$retest_macosx_linking" = "xyes"; then
1251     AC_LANG_PUSH(C)
1252     AC_MSG_CHECKING([if C compiler works with SDK/version options])
1253     AC_TRY_LINK([],[],[AC_MSG_RESULT([yes])],[AC_MSG_FAILURE([no.  Try a different SDK]); exit 1])
1254     AC_LANG_POP()
1255
1256     AC_LANG_PUSH(C++)
1257     AC_MSG_CHECKING([if C++ compiler works with SDK/version options])
1258     AC_TRY_LINK([],[],[AC_MSG_RESULT([yes])],[AC_MSG_FAILURE([no.  Try a different SDK]); exit 1])
1259     AC_LANG_POP()
1260 fi
1261
1262 fi dnl wxUSE_MAC
1263
1264 case "${host}" in
1265
1266     dnl The other BSD's should probably go in here too, since this is
1267     dnl to workaround a strange static lib BSDism.
1268     dnl Mac OS X install seems to ignore -p option...
1269     *-*-darwin* )
1270         INSTALL_PROGRAM="cp -fp"
1271         INSTALL_DATA="cp -fp"
1272         ;;
1273     *)
1274         ;;
1275 esac
1276
1277 dnl ------------------------------------------------------------------------
1278 dnl Platform specific tests
1279 dnl ------------------------------------------------------------------------
1280
1281 dnl xlC needs -qunique under AIX so that one source file can be
1282 dnl compiled to multiple object files and safely linked together.
1283 if test "x$XLCXX" = "xyes" -a "x$USE_AIX" = "x1"; then
1284     CXXFLAGS="-qunique $CXXFLAGS"
1285 fi
1286
1287 dnl This case is for PowerPC OS X vs. everything else
1288 case "${host}" in
1289   powerpc-*-darwin* )
1290     AC_MSG_CHECKING([if __POWERPC__ is already defined])
1291     AC_TRY_COMPILE([],[#ifndef __POWERPC__
1292         choke me for lack of PowerPC
1293 #endif
1294 ],
1295         [AC_MSG_RESULT([yes])],
1296         [AC_MSG_RESULT([no])
1297         AC_DEFINE(__POWERPC__)
1298     ])
1299   ;;
1300 esac
1301
1302 dnl This case is for OS X vs. everything else
1303 case "${host}" in
1304   *-*-darwin* )
1305     AC_MSG_CHECKING([if CoreFoundation/CFBase.h is usable])
1306     AC_TRY_COMPILE([#include <CoreFoundation/CFBase.h>
1307 ],[],
1308         [AC_MSG_RESULT([yes])],
1309         [AC_MSG_RESULT([no])
1310         AC_MSG_CHECKING([if __CF_USE_FRAMEWORK_INCLUDES__ is required])
1311         AC_TRY_COMPILE([#define __CF_USE_FRAMEWORK_INCLUDES__
1312 #include <CoreFoundation/CFBase.h>
1313         ],[],
1314         [AC_MSG_RESULT([yes])
1315         dnl We must use -D so source files that don't include wx/setup.h
1316         dnl but do include CFBase will work.
1317         CPPFLAGS="-D__CF_USE_FRAMEWORK_INCLUDES__ $CPPFLAGS"],
1318         [AC_MSG_FAILURE([no.  CoreFoundation not available.])]
1319         )
1320         ]
1321     )
1322   ;;
1323 esac
1324
1325 dnl Determine whether we want to use Cygwin as Windows or POSIX platform: the
1326 dnl latter makes more sense for wxGTK/Motif/X11 ports
1327 wants_win32=0
1328 doesnt_want_win32=0
1329 case "${host}" in
1330   *-*-cygwin*)
1331       if test "$wxUSE_MSW" = 1 ; then
1332         wants_win32=1
1333       else
1334         dnl when we use cygwin compiler with -mno-cygwin option it uses mingw32
1335         dnl headers and libraries, so it's Windows-like in this case
1336         AC_CACHE_CHECK([if -mno-cygwin is in effect], wx_cv_nocygwin,
1337             [
1338                 AC_TRY_COMPILE(
1339                     [],
1340                     [
1341                         #ifdef __MINGW32__
1342                             choke me
1343                         #endif
1344                     ],
1345                     wx_cv_nocygwin=no,
1346                     wx_cv_nocygwin=yes
1347                 )
1348             ]
1349         )
1350
1351         if test "$wx_cv_nocygwin" = "yes"; then
1352             wants_win32=1
1353         else
1354             doesnt_want_win32=1
1355         fi
1356       fi
1357       if test "$wants_win32" = 1 ; then
1358         BAKEFILE_FORCE_PLATFORM=win32
1359       fi
1360   ;;
1361   *-*-mingw*)
1362       wants_win32=1
1363   ;;
1364 esac
1365
1366 if test "$wxUSE_WINE" = "yes"; then
1367     wants_win32=1
1368     LDFLAGS_GUI="-mwindows"
1369 fi
1370
1371 dnl NB: The two tests bellow are *NOT* mutually exclusive! They should only
1372 dnl     take effect on Cygwin/Mingw and not other platforms.
1373 if test "$wants_win32" = 1 ; then
1374     USE_UNIX=0
1375     USE_WIN32=1
1376     AC_DEFINE(__WIN32__)
1377     AC_DEFINE(__WIN95__)
1378     AC_DEFINE(__WINDOWS__)
1379     AC_DEFINE(__GNUWIN32__)
1380     AC_DEFINE(STRICT)
1381 fi
1382 if test "$doesnt_want_win32" = 1 ; then
1383     USE_UNIX=1
1384     USE_WIN32=0
1385 fi
1386 dnl (end of Windows-only piece)
1387
1388 if test "$USE_UNIX" = 1 ; then
1389     wxUSE_UNIX=yes
1390     AC_DEFINE(__UNIX__)
1391 fi
1392
1393 dnl This case is for OS/2 vs. everything else
1394 case "${host}" in
1395   *-pc-os2_emx | *-pc-os2-emx )
1396       dnl ---------------------------------------------------------------------
1397       dnl When we are using gcc on OS/2, we want to be either using resources
1398       dnl (PM) or a more complete POSIX emulation for Motif/GTK+/X11.
1399       dnl Moreover we need to link explicitly against either stdcpp.a or
1400       dnl stdcxx.a (depending on compiler version), since we are using "gcc",
1401       dnl not "g++/c++".
1402       dnl ---------------------------------------------------------------------
1403       dnl (OS/2-only piece)
1404       if test "$wxUSE_MOTIF" = 1 -o "$wxUSE_GTK" = 1 -o "$wxUSE_X11" = 1; then
1405           dnl More complete Unix emulation for unix-like ports
1406           dnl by linking in POSIX/2's cExt (if available).
1407           AC_CHECK_LIB(cExt, drand48, LIBS="$LIBS -lcExt")
1408       else
1409           dnl Include resources for the "native" port (wxPM).
1410           RESPROGRAMOBJ="\${top_srcdir}/include/wx/os2/wx.res"
1411       fi
1412       dnl Check for the gcc version (and thereby for the C runtime library).
1413       dnl wx_cv_gccversion = EMX2 -> Standard EMX environment
1414       dnl wx_cv_gccversion = EMX3 -> EMX with gcc-3.0.3 or gcc-3.2.1
1415       dnl wx_cv_gccversion = Innotek5 -> gcc-3.2.2 with Innotek libc5
1416       dnl wx_cv_gccversion = Innotek6 -> gcc-3.3.5 with Innotek libc6.
1417       AC_CACHE_CHECK([for gcc/libc version], wx_cv_gccversion,[
1418           AC_TRY_RUN(
1419               dnl Check the gcc version macro.
1420               [
1421                   #include <stdio.h>
1422
1423                   int main()
1424                   {
1425                       FILE *f=fopen("conftestval", "w");
1426                       if (!f) exit(1);
1427                       fprintf(f,
1428                   #if (__GNUC__ < 3)
1429                               "EMX2"
1430                   #elif (__GNUC__==3) && ((__GNUC_MINOR__ < 2) || ((__GNUC_MINOR__==2) && (__GNUC_PATCHLEVEL__<2)))
1431                               "EMX3"
1432                   #elif (__GNUC__==3) && (__GNUC_MINOR__==2) && (__GNUC_PATCHLEVEL__==2)
1433                               "Innotek5"
1434                   #else
1435                               "Innotek6"
1436                   #endif
1437                       );
1438                       exit(0);
1439                   }
1440               ],
1441               wx_cv_gccversion=`cat conftestval`,
1442               wx_cv_gccversion="EMX2",
1443               dnl Compilation error: Assuming standard EMX environment
1444               wx_cv_gccversion="EMX2"
1445           )
1446       ])
1447       if test "$wx_cv_gccversion" = "EMX2"; then
1448           LIBS="$LIBS -lstdcpp"
1449           LDFLAGS="$LDFLAGS -Zsysv-signals"
1450       else
1451           if test "$wx_cv_gccversion" = "EMX3"; then
1452               LIBS="$LIBS -lstdcxx -lgcc"
1453               LDFLAGS="$LDFLAGS -Zsysv-signals"
1454           else
1455               LIBS="$LIBS -lstdc++"
1456           fi
1457       fi
1458       if test "$wxUSE_SHARED" = "yes" -a "$wxUSE_OMF" = "no"; then
1459         AC_MSG_WARN([Building DLLs requires OMF mode, enabled])
1460         wxUSE_OMF=yes
1461         enable_omf=yes
1462       fi
1463       dnl (end of OS/2-only piece)
1464   ;;
1465   *)
1466       dnl ---------------------------------------------------------------------
1467       dnl look for strcasecmp() in string.h and then strings.h if it's not
1468       dnl there. Don't do this on OS/2, where "stricmp" is the function to be
1469       dnl used.
1470       dnl ---------------------------------------------------------------------
1471       dnl (non-OS/2-only piece)
1472
1473       AC_CACHE_CHECK([for strcasecmp() in string.h], ac_cv_string_strcasecmp, [
1474           AC_TRY_LINK([
1475               #include <string.h>
1476               ],
1477               [
1478                   strcasecmp("foo", "bar");
1479               ],
1480               ac_cv_string_strcasecmp=yes,
1481               ac_cv_string_strcasecmp=no
1482           )
1483       ])
1484
1485       if test x"$ac_cv_string_strcasecmp" = "xyes"; then
1486           AC_DEFINE(HAVE_STRCASECMP_IN_STRING_H)
1487       else
1488           AC_CACHE_CHECK([for strcasecmp() in strings.h], ac_cv_strings_strcasecmp, [
1489               AC_TRY_LINK([
1490                   #include <strings.h>
1491                   ],
1492                   [
1493                       strcasecmp("foo", "bar");
1494                   ],
1495                   ac_cv_strings_strcasecmp=yes,
1496                   ac_cv_strings_strcasecmp=no
1497               )
1498           ])
1499
1500           if test x"$ac_cv_strings_strcasecmp" = "xyes"; then
1501               AC_DEFINE(HAVE_STRCASECMP_IN_STRINGS_H)
1502           else
1503               AC_MSG_ERROR([No case-insensitive string comparison function found.])
1504           fi
1505       fi
1506
1507       dnl (end of non-OS/2-only piece)
1508   ;;
1509 esac
1510
1511 dnl ------------------------------------------------------------------------
1512 dnl Check for headers
1513 dnl ------------------------------------------------------------------------
1514
1515 dnl Note: non-empty last parameter makes check compile-only,
1516 dnl   skipping worthless preprocessing check
1517 AC_CHECK_HEADERS(langinfo.h wchar.h,,, [AC_INCLUDES_DEFAULT])
1518
1519 dnl maybe wchar_t is in wcstr.h if we don't have wchar.h?
1520 if test "$ac_cv_header_wchar_h" != "yes"; then
1521     AC_CHECK_HEADERS([wcstr.h],,, [AC_INCLUDES_DEFAULT()])
1522 fi
1523
1524 case "${host}" in
1525   *-pc-os2_emx | *-pc-os2-emx )
1526       dnl Explicitly link -lintl if langinfo.h is available
1527       dnl and intl not yet included in libc
1528       if test $ac_cv_header_langinfo_h = "yes" \
1529                 -a \(   "$wx_cv_gccversion" = "EMX2" \
1530                      -o "$wx_cv_gccversion" = "EMX3" \
1531                      -o "$wx_cv_gccversion" = "Innotek5" \); then
1532           LIBS="$LIBS -lintl"
1533       fi
1534   ;;
1535 esac
1536
1537 dnl POSIX needs this for select(), but old systems don't have it
1538 if test "$USE_UNIX" = 1 ; then
1539     AC_CHECK_HEADERS([sys/select.h],,, [AC_INCLUDES_DEFAULT()])
1540 fi
1541
1542 dnl ---------------------------------------------------------------------------
1543 dnl Checks for compiler characteristics
1544 dnl ---------------------------------------------------------------------------
1545
1546 dnl defines const to be empty if c-compiler does not support const fully
1547 AC_C_CONST
1548 dnl defines inline to a sensible value for the c-compiler
1549 AC_C_INLINE
1550
1551 dnl check the sizes of integral types (give some reasonable default values for
1552 dnl cross-compiling)
1553 dnl   defines the size of certain types of variables in SIZEOF_<TYPE>
1554 AC_CHECK_SIZEOF(short, 2)
1555 AC_CHECK_SIZEOF(void *, 4)
1556 AC_CHECK_SIZEOF(int, 4)
1557 AC_CHECK_SIZEOF(long, 4)
1558 AC_CHECK_SIZEOF(size_t, 4)
1559
1560 case "${host}" in
1561     arm-*-linux* )
1562         AC_CHECK_SIZEOF(long long, 8)
1563     ;;
1564     *-hp-hpux* )
1565         AC_CHECK_SIZEOF(long long, 0)
1566         if test "$ac_cv_sizeof_long_long" != 0; then
1567             dnl HPUX 10.20 headers need this define in order to use long long definitions
1568             CPPFLAGS="-D_INCLUDE_LONGLONG $CPPFLAGS"
1569         fi
1570     ;;
1571     * )
1572         AC_CHECK_SIZEOF(long long, 0)
1573 esac
1574
1575 dnl SGI/Irix's stdio.h does not include wchar_t. Mac OS X does not provide
1576 dnl wchar.h and wchar_t is defined by stdlib.h (GD)
1577 AC_CHECK_SIZEOF(wchar_t, 0,
1578     [
1579         /* DJGPP's wchar_t is now a keyword in C++ (still not C though) */
1580         #if defined(__DJGPP__) && !( (__GNUC_MINOR__ >= 8 && __GNUC__ == 2 ) || __GNUC__ >= 3 )
1581         #  error "fake wchar_t"
1582         #endif
1583         #ifdef HAVE_WCHAR_H
1584         #  ifdef __CYGWIN__
1585         #    include <stddef.h>
1586         #  endif
1587         #  include <wchar.h>
1588         #endif
1589         #ifdef HAVE_STDLIB_H
1590         #  include <stdlib.h>
1591         #endif
1592         #include <stdio.h>
1593     ]
1594 )
1595 if test "$ac_cv_sizeof_wchar_t" != 0; then
1596     wxUSE_WCHAR_T=yes
1597 else
1598     wxUSE_WCHAR_T=no
1599 fi
1600
1601 dnl checks needed to define wxVaCopy
1602 AC_CACHE_CHECK([for va_copy],
1603     wx_cv_func_va_copy,
1604     [
1605         AC_LANG_PUSH(C++)
1606         AC_LINK_IFELSE([
1607             #include <stdarg.h>
1608             void foo(char *f, ...)
1609             {
1610                 va_list ap1, ap2;
1611                 va_start(ap1, f);
1612                 va_copy(ap2, ap1);
1613                 va_end(ap2);
1614                 va_end(ap1);
1615             }
1616             int main()
1617             {
1618                 foo("hi", 17);
1619                 return 0;
1620             }],
1621             wx_cv_func_va_copy=yes,
1622             wx_cv_func_va_copy=no
1623         )
1624         AC_LANG_POP()
1625     ]
1626 )
1627
1628 if test $wx_cv_func_va_copy = "yes"; then
1629     AC_DEFINE(HAVE_VA_COPY)
1630 else
1631     dnl try to understand how can we copy va_lists
1632     AC_CACHE_CHECK([if va_list can be copied by value],
1633         wx_cv_type_va_list_lvalue,
1634         [
1635             AC_RUN_IFELSE([
1636                 #include <stdarg.h>
1637                 int foo(char *f, ...)
1638                 {
1639                     va_list ap1, ap2;
1640                     va_start(ap1, f);
1641                     ap2 = ap1;
1642                     if ( va_arg(ap1, int) != 17 || va_arg(ap2, int) != 17 )
1643                         return 1;
1644                     va_end(ap2);
1645                     va_end(ap1);
1646                     return 0;
1647                 }
1648                 int main()
1649                 {
1650                     return foo("hi", 17);
1651                 }],
1652                 wx_cv_type_va_list_lvalue=yes,
1653                 wx_cv_type_va_list_lvalue=no,
1654                 dnl assume most common case for cross-compiling...
1655                 wx_cv_type_va_list_lvalue=yes
1656             )
1657         ]
1658     )
1659
1660     if test $wx_cv_type_va_list_lvalue != "yes"; then
1661         dnl we suppose that the only thing which can't be copied like this
1662         dnl are arrays... only experience will show whether this is really true
1663         AC_DEFINE(VA_LIST_IS_ARRAY)
1664     fi
1665 fi
1666
1667 dnl don't check for vararg macros if they're explicitly disabled: this is
1668 dnl useful if the user code using the library wants to limit itself to standard
1669 dnl C++ only (e.g. is compiled with g++ -std=c++98)
1670 if test "$wxUSE_VARARG_MACROS" = "yes"; then
1671
1672 dnl Check if variadic macros (C99 feature) are supported:
1673 AC_CACHE_CHECK(
1674     [whether the compiler supports variadic macros],
1675     [wx_cv_have_variadic_macros],
1676     [
1677         dnl C compiler might support variadic macros when C++ one doesn't
1678         dnl (happens with gcc/g++ 2.95.4), so must use C++ one explicitly
1679         AC_LANG_PUSH(C++)
1680         AC_COMPILE_IFELSE(
1681             AC_LANG_PROGRAM(
1682                 [
1683                     #include <stdio.h>
1684                     #define test(fmt, ...) printf(fmt, __VA_ARGS__)
1685                 ],
1686                 [
1687                     test("%s %d %p", "test", 1, 0);
1688                 ]
1689             ),
1690             [wx_cv_have_variadic_macros=yes],
1691             [wx_cv_have_variadic_macros=no]
1692             )
1693         AC_LANG_POP()
1694     ]
1695 )
1696
1697 if test $wx_cv_have_variadic_macros = "yes"; then
1698     AC_DEFINE(HAVE_VARIADIC_MACROS)
1699 fi
1700
1701 fi dnl wxUSE_VARARG_MACROS == yes
1702
1703
1704 dnl check for large file support
1705 LARGEFILE_CPPFLAGS=
1706 AC_SYS_LARGEFILE
1707 if test "$ac_cv_sys_file_offset_bits" = "64"; then
1708     LARGEFILE_CPPFLAGS="-D_FILE_OFFSET_BITS=64"
1709 elif test "$ac_cv_sys_large_files" = 1; then
1710     LARGEFILE_CPPFLAGS="-D_LARGE_FILES"
1711 fi
1712
1713 dnl we need to define _FILE_OFFSET_BITS or _LARGE_FILES on the compiler command
1714 dnl line because otherwise the system headers risk being included before
1715 dnl wx/defs.h which defines these constants leading to inconsistent
1716 dnl sizeof(off_t) in different source files of the same program and linking
1717 dnl problems
1718 if test -n "$LARGEFILE_CPPFLAGS"; then
1719     WXCONFIG_CPPFLAGS="$WXCONFIG_CPPFLAGS $LARGEFILE_CPPFLAGS"
1720
1721     dnl We get "Large Files (ILP32) not supported in strict ANSI mode."
1722     dnl #error from HP standard headers unless __STDC_EXT__ is defined.
1723     dnl The compiler should define it automatically, but some old g++
1724     dnl versions don't define it, so test and add it if necessary. AFAIK
1725     dnl the problem only affects the C++ compiler so it is added to
1726     dnl CXXFLAGS only.
1727     if test "$USE_HPUX" = 1 -a "$GXX" = "yes"; then
1728         AC_CACHE_CHECK(
1729             [if -D__STDC_EXT__ is required],
1730             wx_cv_STDC_EXT_required,
1731             [
1732                 AC_LANG_PUSH(C++)
1733                 AC_TRY_COMPILE(
1734                     [],
1735                     [
1736                         #ifndef __STDC_EXT__
1737                             choke me
1738                         #endif
1739                     ],
1740                     wx_cv_STDC_EXT_required=no,
1741                     wx_cv_STDC_EXT_required=yes
1742                 )
1743                 AC_LANG_POP()
1744             ]
1745         )
1746         if test "x$wx_cv_STDC_EXT_required" = "xyes"; then
1747             WXCONFIG_CXXFLAGS="$WXCONFIG_CXXFLAGS -D__STDC_EXT__"
1748         fi
1749     fi
1750 fi
1751
1752 dnl AC_FUNC_FSEEKO sets HAVE_FSEEKO and $ac_cv_sys_largefile_source
1753 dnl
1754 dnl it may be affected by large file flags (this happens under HP-UX 11 for
1755 dnl example) so set them before using it and also use C++ to ensure that we get
1756 dnl errors, not warnings, about the missing functions
1757 AC_LANG_PUSH(C++)
1758 old_CPPFLAGS="$CPPFLAGS"
1759 CPPFLAGS="$CPPFLAGS $LARGEFILE_CPPFLAGS"
1760 AC_FUNC_FSEEKO
1761 CPPFLAGS="$old_CPPFLAGS"
1762 AC_LANG_POP()
1763 if test "$ac_cv_sys_largefile_source" != no; then
1764     WXCONFIG_CPPFLAGS="$WXCONFIG_CPPFLAGS -D_LARGEFILE_SOURCE=$ac_cv_sys_largefile_source"
1765 fi
1766
1767 dnl check for bytesex stuff (don't use AC_C_BIGENDIAN to allow cross-compiling)
1768 WX_C_BIGENDIAN
1769
1770 dnl check for iostream (as opposed to iostream.h) standard header
1771 WX_CPP_NEW_HEADERS(, AC_DEFINE(wxUSE_IOSTREAMH))
1772
1773 dnl check whether C++ compiler supports explicit keyword
1774 WX_CPP_EXPLICIT
1775
1776 dnl With Sun CC, temporaries have block scope by default. This flag is needed
1777 dnl to get the expression scope behaviour that conforms to the standard.
1778 if test "x$SUNCXX" = xyes; then
1779     CXXFLAGS="-features=tmplife $CXXFLAGS"
1780 fi
1781
1782 dnl Sun X11 headers are (still, in 2005!) non-ANSI and the best they could do
1783 dnl was to hack their C++ compiler to accept them silently -- but C compiler
1784 dnl still spits out dozens of warnings for each X include file, so suppress
1785 dnl them
1786 if test "x$SUNCC" = xyes; then
1787     CFLAGS="-erroff=E_NO_EXPLICIT_TYPE_GIVEN $CFLAGS"
1788 fi
1789
1790 dnl SGI mipsPro compiler gives this warning for "conversion from pointer to
1791 dnl same-sized integral type" even when there is an explicit cast and as there
1792 dnl is no way to turn it off and there are hundreds of these warnings in wx
1793 dnl sources, just turn it off for now
1794 dnl
1795 dnl a better long term solution would be to use #pragma set/reset woff in
1796 dnl wxPtrToUInt() and use it instead of casts elsewhere
1797 if test "x$SGICC" = "xyes"; then
1798     CFLAGS="-woff 3970 $CFLAGS"
1799 fi
1800 if test "x$SGICXX" = "xyes"; then
1801     CXXFLAGS="-woff 3970 $CXXFLAGS"
1802 fi
1803
1804 dnl HP-UX c89/aCC compiler warnings
1805 if test "x$HPCC" = "xyes"; then
1806     dnl 2011: "unrecognized preprocessor directive": nice warning but it's given
1807     dnl       even for directives inside #if which is not true (i.e. which are
1808     dnl       used for other compilers/OS) and so we have no way to get rid of it
1809     dnl 2450: "long long is non standard" -- yes, we know
1810     CFLAGS="+W 2011,2450 $CFLAGS"
1811 fi
1812 if test "x$HPCXX" = "xyes"; then
1813     dnl 2340: "value copied to temporary, reference to temporary used": very
1814     dnl       painful as triggered by any occurrence of user-defined conversion
1815     dnl 4232: "conversion from 'Foo *' to a more strictly aligned type 'Bar *'
1816     dnl       may cause misaligned access": this might indicate a real problem
1817     dnl       but any use of GTK+ cast macros results in it so it's unusable
1818     dnl       for wxGTK code
1819     CXXFLAGS="+W 2340,4232 $CXXFLAGS"
1820 fi
1821
1822 dnl DEC/Compaq/HP cxx warnings
1823 if test "x$COMPAQCXX" = "xyes"; then
1824     dnl -w0 enables all warnings, then we disable some of them:
1825     dnl basclsnondto: base class dtor non virtual (sometimes we do want this)
1826     dnl unrimpret:  "end of routine block may be unreachable" is given for
1827     dnl             every "if ( ) return ...; else return ...;"
1828     dnl intconlosbit: "conversion to integral type of smaller size could lose
1829     dnl               data" this is a useful warning but there are too many of
1830     dnl               them for now
1831     CXXFLAGS="-w0 -msg_disable basclsnondto,unrimpret,intconlosbit"
1832 fi
1833
1834 dnl the next few tests are all for C++ features and so need to be done using
1835 dnl C++ compiler
1836 AC_LANG_PUSH(C++)
1837
1838 dnl check for std::string or std::wstring
1839 if test "$wxUSE_STD_STRING" = "yes" -o "$wxUSE_STL" = "yes"; then
1840     if test "$wxUSE_UNICODE" = "yes"; then
1841         std_string="std::wstring"
1842         char_type="wchar_t"
1843     else
1844         std_string="std::string"
1845         char_type="char"
1846     fi
1847
1848     dnl check if <string> declares std::[w]string
1849     AC_CACHE_CHECK([for $std_string in <string>],
1850         wx_cv_class_stdstring,
1851         [
1852             AC_TRY_COMPILE([#include <string>],
1853                 [$std_string foo;],
1854                 wx_cv_class_stdstring=yes,
1855                 wx_cv_class_stdstring=no
1856             )
1857         ]
1858     )
1859
1860     if test "$wx_cv_class_stdstring" = yes; then
1861         if test "$wxUSE_UNICODE" = "yes"; then
1862             AC_DEFINE(HAVE_STD_WSTRING)
1863         fi
1864         dnl we don't need HAVE_STD_STRING, we just suppose it's available if
1865         dnl wxUSE_STD_STRING==yes
1866     else
1867         AC_CACHE_CHECK([if std::basic_string<$char_type> works],
1868             wx_cv_class_stdbasicstring,
1869             [
1870                 AC_TRY_COMPILE([
1871                     #ifdef HAVE_WCHAR_H
1872                     #  ifdef __CYGWIN__
1873                     #    include <stddef.h>
1874                     #  endif
1875                     #  include <wchar.h>
1876                     #endif
1877                     #ifdef HAVE_STDLIB_H
1878                     #  include <stdlib.h>
1879                     #endif
1880                     #include <stdio.h>
1881                     #include <string>
1882                     ],
1883                     [std::basic_string<$char_type> foo;
1884                      const $char_type* dummy = foo.c_str();],
1885                     wx_cv_class_stdbasicstring=yes,
1886                     wx_cv_class_stdbasicstring=no
1887                 )
1888             ]
1889         )
1890
1891         if test "$wx_cv_class_stdbasicstring" != yes; then
1892             if test "$wxUSE_STL" = "yes"; then
1893                 AC_MSG_ERROR([Can't use --enable-stl without $std_string or std::basic_string<$char_type>])
1894             elif test "$wxUSE_STD_STRING" = "yes"; then
1895                 AC_MSG_ERROR([Can't use --enable-std_string without $std_string or std::basic_string<$char_type>])
1896             else
1897                 AC_MSG_WARN([No $std_string or std::basic_string<$char_type>, switching to --disable-std_string])
1898                 wxUSE_STD_STRING=no
1899             fi
1900         fi
1901     fi
1902 fi
1903
1904 if test "$wxUSE_STD_IOSTREAM" = "yes"; then
1905     AC_CHECK_TYPES([std::istream, std::ostream],,
1906                    [wxUSE_STD_IOSTREAM=no],
1907                    [#include <iostream>])
1908
1909     if test "$wxUSE_STD_IOSTREAM" != "yes"; then
1910         if test "$wxUSE_STD_IOSTREAM" = "yes"; then
1911             AC_MSG_ERROR([Can't use --enable-std_iostreams without std::istream and std::ostream])
1912         else
1913             AC_MSG_WARN([No std::iostreams, switching to --disable-std_iostreams])
1914         fi
1915     fi
1916 fi
1917
1918 if test "$wxUSE_STL" = "yes"; then
1919     dnl check for basic STL functionality
1920     AC_CACHE_CHECK([for basic STL functionality],
1921         wx_cv_lib_stl,
1922         [AC_TRY_COMPILE([#include <string>
1923             #include <functional>
1924             #include <algorithm>
1925             #include <vector>
1926             #include <list>],
1927             [std::vector<int> moo;
1928              std::list<int> foo;
1929              std::vector<int>::iterator it =
1930                  std::find_if(moo.begin(), moo.end(),
1931                               std::bind2nd(std::less<int>(), 3));],
1932             wx_cv_lib_stl=yes,
1933             wx_cv_lib_stl=no
1934         )]
1935     )
1936
1937     if test "$wx_cv_lib_stl" != yes; then
1938          AC_MSG_ERROR([Can't use --enable-stl as basic STL functionality is missing])
1939     fi
1940
1941     dnl check for compliant std::string::compare
1942     AC_CACHE_CHECK([for compliant std::string::compare],
1943         wx_cv_func_stdstring_compare,
1944         [AC_TRY_COMPILE([#include <string>],
1945             [std::string foo, bar;
1946             foo.compare(bar);
1947             foo.compare(1, 1, bar);
1948             foo.compare(1, 1, bar, 1, 1);
1949             foo.compare("");
1950             foo.compare(1, 1, "");
1951             foo.compare(1, 1, "", 2);],
1952             wx_cv_func_stdstring_compare=yes,
1953             wx_cv_func_stdstring_compare=no
1954         )]
1955     )
1956
1957     if test "$wx_cv_func_stdstring_compare" = yes; then
1958         AC_DEFINE(HAVE_STD_STRING_COMPARE)
1959     fi
1960
1961     if test "$wx_cv_class_gnuhashmapset" = yes; then
1962          AC_DEFINE(HAVE_EXT_HASH_MAP)
1963          AC_DEFINE(HAVE_GNU_CXX_HASH_MAP)
1964     fi
1965
1966     AC_CHECK_HEADER([unordered_map],
1967         [AC_CACHE_CHECK([for unordered_map and unordered_set in std],
1968             wx_cv_class_stdunorderedmapset,
1969             [AC_TRY_COMPILE([#include <unordered_map>
1970                 #include <unordered_set>],
1971                 [std::unordered_map<double*, char*> test1;
1972                  std::unordered_set<char*> test2;],
1973                 wx_cv_class_stdunorderedmapset=yes,
1974                 wx_cv_class_stdunorderedmapset=no)
1975             ]
1976         )],
1977         [],
1978         [ ]
1979     )
1980
1981     if test "$wx_cv_class_stdunorderedmapset" = yes; then
1982          AC_DEFINE(HAVE_STD_UNORDERED_MAP)
1983          AC_DEFINE(HAVE_STD_UNORDERED_SET)
1984     else
1985         AC_CHECK_HEADER([tr1/unordered_map],
1986             [AC_CACHE_CHECK([for unordered_map and unordered_set in std::tr1],
1987                 wx_cv_class_tr1unorderedmapset,
1988                 [AC_TRY_COMPILE([#include <tr1/unordered_map>
1989                     #include <tr1/unordered_set>],
1990                     [std::tr1::unordered_map<double*, char*> test1;
1991                      std::tr1::unordered_set<char*> test2;
1992             #if defined(__GNUC__) && (__GNUC__==4) && (__GNUC_MINOR__<2)
1993             #error can't use unordered_{map,set} with gcc-4.[01]: http://gcc.gnu.org/PR24389
1994             #endif],
1995                     wx_cv_class_tr1unorderedmapset=yes,
1996                     wx_cv_class_tr1unorderedmapset=no)
1997                 ]
1998             )],
1999             [],
2000             [ ]
2001         )
2002
2003         if test "$wx_cv_class_tr1unorderedmapset" = yes; then
2004             AC_DEFINE(HAVE_TR1_UNORDERED_MAP)
2005             AC_DEFINE(HAVE_TR1_UNORDERED_SET)
2006         else
2007             dnl check for hash_map and hash_set headers
2008             AC_CHECK_HEADER([hash_map],
2009                 [AC_CACHE_CHECK([for std::hash_map and hash_set],
2010                     wx_cv_class_stdhashmapset,
2011                     [AC_TRY_COMPILE([#include <hash_map>
2012                         #include <hash_set>],
2013                         [std::hash_map<double*, char*, std::hash<double*>, std::equal_to<double*> > test1;
2014                          std::hash_set<char*, std::hash<char*>, std::equal_to<char*> > test2;],
2015                         wx_cv_class_stdhashmapset=yes,
2016                         wx_cv_class_stdhashmapset=no)
2017                     ]
2018                 )],
2019                 [],
2020                 [ ]
2021             )
2022
2023             if test "$wx_cv_class_stdhashmapset" = yes; then
2024                 AC_DEFINE(HAVE_HASH_MAP)
2025                 AC_DEFINE(HAVE_STD_HASH_MAP)
2026             fi
2027
2028             AC_CHECK_HEADER([ext/hash_map],
2029                 [AC_CACHE_CHECK([for GNU hash_map and hash_set],
2030                     wx_cv_class_gnuhashmapset,
2031                     [AC_TRY_COMPILE([#include <ext/hash_map>
2032                         #include <ext/hash_set>],
2033                         [__gnu_cxx::hash_map<double*, char*, __gnu_cxx::hash<double*>, std::equal_to<double*> > test1;
2034                          __gnu_cxx::hash_set<char*, __gnu_cxx::hash<char*>, std::equal_to<char*> > test2;],
2035                         wx_cv_class_gnuhashmapset=yes,
2036                         wx_cv_class_gnuhashmapset=no)
2037                     ]
2038                 )],
2039                 [],
2040                 [ ]
2041             )
2042
2043         fi
2044     fi
2045 fi
2046
2047 dnl check for atomic operations builtins for wx/atomic.h:
2048 WX_ATOMIC_BUILTINS
2049
2050 dnl pop C++
2051 AC_LANG_POP()
2052
2053 dnl ---------------------------------------------------------------------------
2054 dnl Define search path for includes and libraries: all headers and libs will be
2055 dnl looked for in all directories of this path
2056 dnl ---------------------------------------------------------------------------
2057
2058 dnl Notice that /usr/include should *not* be in this list, otherwise it breaks
2059 dnl compilation on Solaris/AIX/... with gcc because standard (non ANSI C)
2060 dnl headers are included instead of the "fixed" (ANSI-fied) gcc ones.
2061 dnl
2062 dnl Also try to put all directories which may contain X11R6 before those which
2063 dnl may contain X11R5/4 - we want to use R6 on machines which have both!
2064 dnl
2065 dnl In the same vein. Motif 2.1 should be tried before Motif 1.2 for the
2066 dnl systems which have both (AIX 4.x does)
2067 SEARCH_INCLUDE="\
2068     /usr/local/include        \
2069     /usr/local/X11/include    \
2070     /usr/local/include/X11    \
2071     /usr/local/X11R7/include  \
2072     /usr/local/X11R6/include  \
2073     /usr/local/include/X11R7  \
2074     /usr/local/include/X11R6  \
2075                               \
2076     /usr/Motif-2.1/include    \
2077     /usr/Motif-1.2/include    \
2078     /usr/include/Motif1.2     \
2079                               \
2080     /usr/dt/include           \
2081     /usr/openwin/include      \
2082                               \
2083     /usr/include/Xm           \
2084                               \
2085     /usr/X11R7/include        \
2086     /usr/X11R6/include        \
2087     /usr/X11R6.4/include      \
2088                               \
2089     /usr/include/X11R7        \
2090     /usr/include/X11R6        \
2091                               \
2092     /usr/X11/include          \
2093     /usr/include/X11          \
2094                               \
2095     /usr/XFree86/include/X11  \
2096     /usr/pkg/include          \
2097                               \
2098     /usr/local/X1R5/include  \
2099     /usr/local/include/X11R5  \
2100     /usr/X11R5/include        \
2101     /usr/include/X11R5        \
2102                               \
2103     /usr/local/X11R4/include  \
2104     /usr/local/include/X11R4  \
2105     /usr/X11R4/include        \
2106     /usr/include/X11R4        \
2107                               \
2108     /usr/openwin/share/include"
2109
2110 dnl try to find out the standard lib locations for the systems with multiple
2111 dnl ABIs
2112 AC_MSG_CHECKING([for libraries directory])
2113
2114 case "${host}" in
2115     *-*-irix6* )
2116         AC_CACHE_VAL(
2117             wx_cv_std_libpath,
2118             [
2119                 for d in WX_STD_LIBPATH(); do
2120                     for e in a so sl dylib dll.a; do
2121                         libc="$d/libc.$e"
2122                         if test -f $libc; then
2123                             save_LIBS="$LIBS"
2124                             LIBS="$libc"
2125                             AC_LINK_IFELSE([int main() { return 0; }],
2126                                 wx_cv_std_libpath=`echo $d | sed s@/usr/@@`)
2127                             LIBS="$save_LIBS"
2128                             if test "x$wx_cv_std_libpath" != "x"; then
2129                                 break 2
2130                             fi
2131                         fi
2132                     done
2133                 done
2134                 if test "x$wx_cv_std_libpath" = "x"; then
2135                     wx_cv_std_libpath="lib"
2136                 fi
2137             ]
2138         )
2139         ;;
2140
2141     *-*-solaris2* )
2142         dnl use ../lib or ../lib/64 depending on the size of void*
2143         if test "$ac_cv_sizeof_void_p" = 8 -a -d "/usr/lib/64"; then
2144             wx_cv_std_libpath="lib/64"
2145         else
2146             wx_cv_std_libpath="lib"
2147         fi
2148         ;;
2149
2150     *-*-linux* )
2151         dnl use ../lib or ../lib64 depending on the size of void*
2152         if test "$ac_cv_sizeof_void_p" = 8 -a \
2153                 -d "/usr/lib64" -a ! -h "/usr/lib64"; then
2154             wx_cv_std_libpath="lib64"
2155         else
2156             wx_cv_std_libpath="lib"
2157         fi
2158         ;;
2159
2160     *)
2161         wx_cv_std_libpath="lib";
2162         ;;
2163 esac
2164
2165 AC_MSG_RESULT($wx_cv_std_libpath)
2166
2167 SEARCH_LIB="`echo "$SEARCH_INCLUDE" | sed s@include@$wx_cv_std_libpath@g` /usr/$wx_cv_std_libpath"
2168
2169 dnl Cross compiling with gcc?
2170 if test "$build" != "$host" -a "$GCC" = yes; then
2171     dnl for gcc cross-compilers "$CC -print-prog-name=ld" prints the path to
2172     dnl the linker. Stripping off the trailing '/bin/ld' gives us a candiate
2173     dnl for a 'root' below which libraries and headers for the target system
2174     dnl might be installed.
2175     if cross_root=`$CC -print-prog-name=ld 2>/dev/null`; then
2176         cross_root=`dirname $cross_root`
2177         cross_root=`dirname $cross_root`
2178
2179         dnl substitute this candiate root for '^/usr' in the search lists,
2180         dnl strip out any that don't start '^/usr'.
2181         SEARCH_LIB=`for x in $SEARCH_LIB; do echo $x; done | sed -ne "s|^/usr|$cross_root|p"`
2182         SEARCH_INCLUDE=`for x in $SEARCH_INCLUDE; do echo $x; done | sed -ne "s|^/usr|$cross_root|p"`
2183         SEARCH_INCLUDE="$SEARCH_INCLUDE $cross_root/include"
2184
2185         dnl also have pkg-config search for *.pc files under this 'root'
2186         if test -z "$PKG_CONFIG_PATH"; then
2187             PKG_CONFIG_PATH="$cross_root/local/lib/pkgconfig:$cross_root/lib/pkgconfig"
2188             export PKG_CONFIG_PATH
2189         fi
2190
2191         dnl AC_PATH_XTRA doesn't work currently unless -x-includes and
2192         dnl -x-libraries are given on the command line. So if they are not
2193         dnl set then set them here to plausible defaults.
2194         if test -z "$x_includes" -o "$x_includes" = NONE; then
2195             WX_PATH_FIND_INCLUDES($SEARCH_INCLUDE, X11/Intrinsic.h)
2196             x_includes=$ac_find_includes
2197         fi
2198         if test -z "$x_libraries" -o "$x_libraries" = NONE; then
2199             WX_PATH_FIND_LIBRARIES($SEARCH_LIB, Xt)
2200             x_libraries=$ac_find_libraries
2201         fi
2202     fi
2203 fi
2204
2205 dnl ------------------------------------------------------------------------
2206 dnl Check for libraries
2207 dnl ------------------------------------------------------------------------
2208
2209 dnl flush the cache because checking for libraries below might abort
2210 AC_CACHE_SAVE
2211
2212 dnl check for glibc version
2213 dnl
2214 dnl VZ: I have no idea why had this check been there originally, but now
2215 dnl     we could probably do without it by just always adding _GNU_SOURCE
2216 if test "$USE_LINUX" = 1 -o "$USE_GNU" = 1; then
2217     AC_CACHE_CHECK([for glibc 2.1 or later], wx_cv_lib_glibc21,[
2218         AC_TRY_COMPILE([#include <features.h>],
2219             [
2220                 #if (__GLIBC__ < 2) || (__GLIBC_MINOR__ < 1)
2221                 not glibc 2.1
2222                 #endif
2223             ],
2224             [
2225                 wx_cv_lib_glibc21=yes
2226             ],
2227             [
2228                 wx_cv_lib_glibc21=no
2229             ]
2230         )
2231     ])
2232     if test "$wx_cv_lib_glibc21" = "yes"; then
2233         AC_DEFINE(wxHAVE_GLIBC2)
2234     fi
2235 fi
2236
2237 dnl we may need _GNU_SOURCE for 2 things:
2238 dnl
2239 dnl  1. to get PTHREAD_MUTEX_RECURSIVE with glibc 2.1+ (strictly speaking we
2240 dnl  only need _XOPEN_SOURCE=500 but just defining this disables _BSD_SOURCE
2241 dnl  which breaks libtiff compilation, so it is simpler to just define
2242 dnl  _GNU_SOURCE to get everything)
2243 dnl
2244 dnl  2. for Unicode functions
2245 if test "x$wx_cv_lib_glibc21" = "xyes"; then
2246     if test "$wxUSE_UNICODE" = "yes" -o "$wxUSE_THREADS" = "yes"; then
2247         AC_DEFINE(_GNU_SOURCE)
2248     fi
2249 fi
2250
2251 dnl Only add the -lm library if floating point functions cannot be used
2252 dnl without it.  This check is important on cygwin because of the bizarre
2253 dnl way that they have organized functions into libraries.  On cygwin, both
2254 dnl libc.a and libm.a are symbolic links to a single lib libcygwin.a.  This
2255 dnl means that
2256 dnl   1) linking with -lm is not necessary, and
2257 dnl   2) linking with -lm is dangerous if the order of libraries is wrong
2258 dnl In particular, if you compile any program with -mno-cygwin and link with
2259 dnl -lm, it will crash instantly when it is run.  This happens because the
2260 dnl linker incorrectly links the Cygwin libm.a (==libcygwin.a), which replaces
2261 dnl the ___main function instead of allowing it to be defined by
2262 dnl /usr/lib/mingw/libmingw32.a as it should be.
2263 dnl
2264 dnl On MacOS X, this test will find that -lm is unnecessary and leave it out.
2265 dnl
2266 dnl Just check a few floating point functions. If they are all found without
2267 dnl -lm, then we must not need -lm.
2268 have_cos=0
2269 have_floor=0
2270 AC_CHECK_FUNCS(cos, have_cos=1)
2271 AC_CHECK_FUNCS(floor, have_floor=1)
2272 AC_MSG_CHECKING(if floating point functions link without -lm)
2273 if test "$have_cos" = 1 -a "$have_floor" = 1; then
2274     AC_MSG_RESULT(yes)
2275 else
2276     AC_MSG_RESULT(no)
2277     LIBS="$LIBS -lm"
2278     # use different functions to avoid configure caching
2279     have_sin=0
2280     have_ceil=0
2281     AC_CHECK_FUNCS(sin, have_sin=1)
2282     AC_CHECK_FUNCS(ceil, have_ceil=1)
2283     AC_MSG_CHECKING(if floating point functions link with -lm)
2284     if test "$have_sin" = 1 -a "$have_ceil" = 1; then
2285         AC_MSG_RESULT(yes)
2286     else
2287         AC_MSG_RESULT(no)
2288         # not sure we should warn the user, crash, etc.
2289     fi
2290 fi
2291
2292 dnl check for C99 string to long long conversion functions, assume that if we
2293 dnl have the unsigned variants, then we have the signed ones as well
2294 dnl
2295 dnl at least under SGI these functions are only available in C99 code and not
2296 dnl in C++ so do these tests using C++ compiler
2297 AC_LANG_PUSH(C++)
2298 if test "wxUSE_UNICODE" = "yes"; then
2299     WX_CHECK_FUNCS(wcstoull)
2300 else
2301     WX_CHECK_FUNCS(strtoull)
2302 fi
2303 AC_LANG_POP()
2304
2305 dnl ---------------------------------------------------------------------------
2306 dnl Optional libraries
2307 dnl
2308 dnl   --with-<lib>=sys
2309 dnl       looks for system library and fails if not found
2310 dnl
2311 dnl   --with-<lib>
2312 dnl   --with-<lib>=yes
2313 dnl       looks for system library and, if not found, prints a warning,
2314 dnl       falls back to the builtin wx version, and continues configuration
2315 dnl
2316 dnl   --with-<lib>=builtin
2317 dnl       uses builtin wx version without searching for system library
2318 dnl
2319 dnl   --with-<lib>=no
2320 dnl   --without-<lib>
2321 dnl       do not use library (neither system nor builtin wx version)
2322 dnl
2323 dnl ---------------------------------------------------------------------------
2324
2325 dnl ------------------------------------------------------------------------
2326 dnl Check for regex libraries
2327 dnl ------------------------------------------------------------------------
2328
2329 if test "$wxUSE_REGEX" != "no"; then
2330     AC_DEFINE(wxUSE_REGEX)
2331
2332     if test "$wxUSE_UNICODE" = "yes" -a "$wxUSE_REGEX" = "yes"; then
2333         AC_MSG_WARN([Defaulting to the builtin regex library for Unicode build.])
2334         wxUSE_REGEX=builtin
2335     fi
2336
2337     if test "$wxUSE_REGEX" = "sys" -o "$wxUSE_REGEX" = "yes" ; then
2338         dnl according to Unix 98 specs, regcomp() is in libc but I believe that
2339         dnl on some old systems it may be in libregex - check for it too?
2340         AC_CHECK_HEADER(regex.h, [AC_CHECK_FUNCS(regcomp re_search)],, [ ])
2341
2342         if test "x$ac_cv_func_regcomp" != "xyes"; then
2343             if test "$wxUSE_REGEX" = "sys" ; then
2344                 AC_MSG_ERROR([system regex library not found! Use --with-regex to use built-in version])
2345             else
2346                 AC_MSG_WARN([system regex library not found, will use built-in instead])
2347                 wxUSE_REGEX=builtin
2348             fi
2349         else
2350             dnl we are using the system library
2351             wxUSE_REGEX=sys
2352             dnl only the built-in supports advanced REs
2353             AC_DEFINE(WX_NO_REGEX_ADVANCED)
2354         fi
2355     fi
2356 fi
2357
2358 dnl ------------------------------------------------------------------------
2359 dnl Check for zlib compression library
2360 dnl ------------------------------------------------------------------------
2361
2362 ZLIB_LINK=
2363 if test "$wxUSE_ZLIB" != "no" ; then
2364     AC_DEFINE(wxUSE_ZLIB)
2365
2366     if test "$wxUSE_ZLIB" = "sys" -o "$wxUSE_ZLIB" = "yes" ; then
2367         dnl don't test for zlib under Mac -- its verson there is 1.1.3 but we
2368         dnl should still use it because hopefully (can someone confirm this?)
2369         dnl Apple did fix the security problem in it and not using the system
2370         dnl library results in a whole bunch of warnings when linking with
2371         dnl Carbon framework
2372         if test "$USE_DARWIN" = 1; then
2373             system_zlib_h_ok="yes"
2374         else
2375             dnl we have troubles with ancient zlib versions (e.g. 1.0.4 is
2376             dnl known to not work) and although I don't know which is
2377             dnl the minimal required version it's safer to test for 1.1.4 as
2378             dnl it fixes a security problem in 1.1.3 -- and hopefully nobody
2379             dnl has anything more ancient (1.1.3 was released in July 1998)
2380             dnl anyhow
2381             AC_CACHE_CHECK([for zlib.h >= 1.1.4], ac_cv_header_zlib_h,
2382                 [AC_TRY_RUN(
2383                     dnl zlib.h defines ZLIB_VERSION="x.y.z"
2384                     [
2385                         #include <zlib.h>
2386                         #include <stdio.h>
2387
2388                         int main()
2389                         {
2390                             FILE *f=fopen("conftestval", "w");
2391                             if (!f) exit(1);
2392                             fprintf(f, "%s",
2393                                     ZLIB_VERSION[0] == '1' &&
2394                                     (ZLIB_VERSION[2] > '1' ||
2395                                     (ZLIB_VERSION[2] == '1' &&
2396                                      ZLIB_VERSION[4] >= '4')) ? "yes" : "no");
2397                             exit(0);
2398                         }
2399                     ],
2400                     ac_cv_header_zlib_h=`cat conftestval`,
2401                     ac_cv_header_zlib_h=no,
2402                     dnl cross-compiling: don't have an answer, try later
2403                     unset ac_cv_header_zlib_h
2404                 )]
2405             )
2406             dnl If the test above did not come up with a value (e.g. cross
2407             dnl compiling) then this should give a definitive answer
2408             AC_CHECK_HEADER(zlib.h,,, [ ])
2409
2410             system_zlib_h_ok=$ac_cv_header_zlib_h
2411         fi
2412
2413         if test "$system_zlib_h_ok" = "yes"; then
2414             AC_CHECK_LIB(z, deflate, ZLIB_LINK=" -lz")
2415         fi
2416
2417         if test "x$ZLIB_LINK" = "x" ; then
2418             if test "$wxUSE_ZLIB" = "sys" ; then
2419                 AC_MSG_ERROR([zlib library not found or too old! Use --with-zlib=builtin to use built-in version])
2420             else
2421                 AC_MSG_WARN([zlib library not found or too old, will use built-in instead])
2422                 wxUSE_ZLIB=builtin
2423             fi
2424         else
2425             dnl we are using the system library
2426             wxUSE_ZLIB=sys
2427         fi
2428     fi
2429 fi
2430
2431 dnl ------------------------------------------------------------------------
2432 dnl Check for png library
2433 dnl ------------------------------------------------------------------------
2434
2435 PNG_LINK=
2436 if test "$wxUSE_LIBPNG" != "no" ; then
2437     AC_DEFINE(wxUSE_LIBPNG)
2438
2439     if test "$wxUSE_MGL" = 1 -a "$wxUSE_LIBPNG" = "builtin" ; then
2440         AC_MSG_WARN([wxMGL doesn't work with builtin png library, will use MGL one instead])
2441         wxUSE_LIBPNG=sys
2442     fi
2443
2444     dnl for the check below to have a chance to succeed, we must already have
2445     dnl libz somewhere (don't do this when bulding wxMGL since its libpng
2446     dnl doesn't depend on zlib)
2447     if test "$wxUSE_MGL" != 1 -a "$wxUSE_LIBPNG" = "sys" -a "$wxUSE_ZLIB" != "sys" ; then
2448         AC_MSG_WARN([system png library doesn't work without system zlib, will use built-in instead])
2449         wxUSE_LIBPNG=builtin
2450     fi
2451
2452     if test "$wxUSE_MGL" != 1 ; then
2453         dnl Don't check for libpng when building wxMGL, libmgl contains it
2454         if test "$wxUSE_LIBPNG" = "sys" -o "$wxUSE_LIBPNG" = "yes" ; then
2455             dnl libpng version 0.9 is known to not work, if an even newer
2456             dnl version is required, just bump it up in the test below
2457             AC_CACHE_CHECK([for png.h > 0.90], ac_cv_header_png_h,
2458                 [AC_TRY_RUN(
2459                     dnl png.h defines PNG_LIBPNG_VER=number
2460                     [
2461                         #include <png.h>
2462                         #include <stdio.h>
2463
2464                         int main()
2465                         {
2466                             FILE *f=fopen("conftestval", "w");
2467                             if (!f) exit(1);
2468                             fprintf(f, "%s",
2469                                      PNG_LIBPNG_VER > 90 ? "yes" : "no");
2470                             exit(0);
2471                         }
2472                     ],
2473                     ac_cv_header_png_h=`cat conftestval`,
2474                     ac_cv_header_png_h=no,
2475                     dnl cross-compiling: test (later) if we have any png.h
2476                     unset ac_cv_header_png_h
2477                 )]
2478             )
2479             AC_CHECK_HEADER(png.h,,, [ ])
2480
2481             if test "$ac_cv_header_png_h" = "yes"; then
2482                 AC_CHECK_LIB(png, png_check_sig, PNG_LINK=" -lpng -lz", , [-lz -lm])
2483             fi
2484
2485             if test "x$PNG_LINK" = "x" ; then
2486                 if test "$wxUSE_LIBPNG" = "sys" ; then
2487                     AC_MSG_ERROR([system png library not found or too old! Use --with-libpng=builtin to use built-in version])
2488                 else
2489                     AC_MSG_WARN([system png library not found or too old, will use built-in instead])
2490                     wxUSE_LIBPNG=builtin
2491                 fi
2492             else
2493                 dnl we are using the system library
2494                 wxUSE_LIBPNG=sys
2495             fi
2496         fi
2497     fi
2498 fi
2499
2500 dnl ------------------------------------------------------------------------
2501 dnl Check for jpeg library
2502 dnl ------------------------------------------------------------------------
2503
2504 dnl this check must be done before the check for libtiff as libtiff uses
2505 dnl libjpeg itself
2506 JPEG_LINK=
2507 if test "$wxUSE_LIBJPEG" != "no" ; then
2508     AC_DEFINE(wxUSE_LIBJPEG)
2509
2510     if test "$wxUSE_MGL" = 1 -a "$wxUSE_LIBJPEG" = "builtin" ; then
2511         AC_MSG_WARN([wxMGL doesn't work with builtin jpeg library, will use MGL one instead])
2512         wxUSE_LIBJPEG=sys
2513     fi
2514
2515     if test "$wxUSE_MGL" != 1 ; then
2516         dnl Don't check for libjpeg when building wxMGL, libmgl contains it
2517         if test "$wxUSE_LIBJPEG" = "sys" -o "$wxUSE_LIBJPEG" = "yes" ; then
2518             dnl can't use AC_CHECK_HEADER as jconfig.h defines things like
2519             dnl HAVE_STDLIB_H which are already defined and this provokes
2520             dnl a compiler warning which configure considers as an error...
2521             AC_MSG_CHECKING(for jpeglib.h)
2522             AC_CACHE_VAL(ac_cv_header_jpeglib_h,
2523                 AC_TRY_COMPILE(
2524                     [
2525                         #undef HAVE_STDLIB_H
2526                         #include <stdio.h>
2527                         #include <jpeglib.h>
2528                     ],
2529                     [
2530                     ],
2531                     ac_cv_header_jpeglib_h=yes,
2532                     ac_cv_header_jpeglib_h=no
2533                 )
2534             )
2535             AC_MSG_RESULT($ac_cv_header_jpeglib_h)
2536
2537             if test "$ac_cv_header_jpeglib_h" = "yes"; then
2538                 AC_CHECK_LIB(jpeg, jpeg_read_header, JPEG_LINK=" -ljpeg")
2539             fi
2540
2541             if test "x$JPEG_LINK" = "x" ; then
2542                 if test "$wxUSE_LIBJPEG" = "sys" ; then
2543                     AC_MSG_ERROR([system jpeg library not found! Use --with-libjpeg=builtin to use built-in version])
2544                 else
2545                     AC_MSG_WARN([system jpeg library not found, will use built-in instead])
2546                     wxUSE_LIBJPEG=builtin
2547                 fi
2548             else
2549                 dnl we are using the system library
2550                 wxUSE_LIBJPEG=sys
2551
2552                 if test "$wxUSE_MSW" = 1; then
2553                     dnl boolean is defined by the jpeg headers and also by the
2554                     dnl Windows headers of some compilers. This type has been
2555                     dnl renamed in the builtin, so it is only an issue when
2556                     dnl using an external jpeg lib on Windows.
2557                     AC_CHECK_TYPES(
2558                         [boolean],
2559                         [
2560                             AC_CHECK_SIZEOF(
2561                                 [boolean],
2562                                 [],
2563                                 [
2564                                     #undef HAVE_BOOLEAN
2565                                     #include <stdio.h>
2566                                     #include <jpeglib.h>
2567                                 ])
2568                             AC_DEFINE_UNQUOTED(
2569                                 [wxHACK_BOOLEAN],
2570                                 [wxInt`expr 8 \* $ac_cv_sizeof_boolean`])
2571                         ],
2572                         [],
2573                         [#include <windows.h>])
2574                 fi
2575             fi
2576         fi
2577     fi
2578 fi
2579
2580 dnl ------------------------------------------------------------------------
2581 dnl Check for tiff library
2582 dnl ------------------------------------------------------------------------
2583
2584 TIFF_LINK=
2585 TIFF_PREREQ_LINKS=-lm
2586 if test "$wxUSE_LIBTIFF" != "no" ; then
2587     AC_DEFINE(wxUSE_LIBTIFF)
2588
2589     if test "$wxUSE_LIBTIFF" = "sys" -o "$wxUSE_LIBTIFF" = "yes" ; then
2590         dnl libtiff may depend on libjpeg and libz so use them in the test
2591         dnl below or it would fail
2592         if test "$wxUSE_LIBJPEG" = "sys"; then
2593             TIFF_PREREQ_LINKS="$TIFF_PREREQ_LINKS $JPEG_LINK"
2594         fi
2595         if test "$wxUSE_ZLIB" = "sys"; then
2596             TIFF_PREREQ_LINKS="$TIFF_PREREQ_LINKS $ZLIB_LINK"
2597         fi
2598         AC_CHECK_HEADER(tiffio.h,
2599                         [
2600                             AC_CHECK_LIB(tiff, TIFFError,
2601                                          TIFF_LINK=" -ltiff",
2602                                          ,
2603                                          $TIFF_PREREQ_LINKS)
2604                         ],
2605                         [],
2606                         [ ]
2607                        )
2608
2609         if test "x$TIFF_LINK" = "x" ; then
2610             if test "$wxUSE_LIBTIFF" = "sys" ; then
2611                 AC_MSG_ERROR([system tiff library not found! Use --with-libtiff=builtin to use built-in version])
2612             else
2613                 AC_MSG_WARN([system tiff library not found, will use built-in instead])
2614                 wxUSE_LIBTIFF=builtin
2615             fi
2616         else
2617             dnl we are using the system library
2618             wxUSE_LIBTIFF=sys
2619         fi
2620     fi
2621     if test "$wxUSE_LIBTIFF" = "builtin" ; then
2622         if test "$wxUSE_LIBJPEG" = "no"; then
2623             dnl we have to prevent the builtin libtiff configure from building the
2624             dnl library with JPEG support as this was explicitly disabled by user,
2625             dnl but unfortunately it needs --disable-jpeg and not --without-libjpeg
2626             dnl (which will be passed to it anyhow as configure passes arguments to
2627             dnl the top-level script to all the other ones called recursively), so
2628             dnl we need to hack around this
2629             ac_configure_args="$ac_configure_args --disable-jpeg"
2630         fi
2631         AC_CONFIG_SUBDIRS([src/tiff])
2632     fi
2633 fi
2634
2635 dnl ------------------------------------------------------------------------
2636 dnl Check for expat libraries
2637 dnl ------------------------------------------------------------------------
2638
2639 if test "$wxUSE_WCHAR_T" != "yes"; then
2640     if test "$wxUSE_EXPAT" != "no"; then
2641         AC_MSG_WARN([wxWidgets requires wchar_t to use expat, disabling])
2642         wxUSE_EXPAT=no
2643     fi
2644     if test "$wxUSE_XML" != "no"; then
2645         AC_MSG_WARN([wxWidgets requires wchar_t to use xml, disabling])
2646         wxUSE_XML=no
2647     fi
2648 fi
2649
2650 if test "$wxUSE_EXPAT" != "no"; then
2651     wxUSE_XML=yes
2652     AC_DEFINE(wxUSE_EXPAT)
2653     AC_DEFINE(wxUSE_XML)
2654
2655     if test "$wxUSE_EXPAT" = "sys" -o "$wxUSE_EXPAT" = "yes" ; then
2656         AC_CHECK_HEADER([expat.h], [found_expat_h=1],, [ ])
2657         if test "x$found_expat_h" = "x1"; then
2658             dnl Expat 1.95.6 comes with broken expat.h:
2659             AC_CACHE_CHECK([if expat.h is valid C++ header],
2660                 wx_cv_expat_is_not_broken,
2661                 [
2662                 AC_LANG_PUSH(C++)
2663                 AC_TRY_COMPILE([#include <expat.h>],[],
2664                     wx_cv_expat_is_not_broken=yes,
2665                     wx_cv_expat_is_not_broken=no
2666                 )
2667                 AC_LANG_POP()
2668                 ]
2669             )
2670             if test "$wx_cv_expat_is_not_broken" = "yes" ; then
2671                 AC_CHECK_LIB(expat, XML_ParserCreate, EXPAT_LINK=" -lexpat")
2672             fi
2673         fi
2674         if test "x$EXPAT_LINK" = "x" ; then
2675             if test "$wxUSE_EXPAT" = "sys" ; then
2676                 AC_MSG_ERROR([system expat library not found! Use --with-expat=builtin to use built-in version])
2677             else
2678                 AC_MSG_WARN([system expat library not found, will use built-in instead])
2679                 wxUSE_EXPAT=builtin
2680             fi
2681         else
2682             dnl we are using the system library
2683             wxUSE_EXPAT=sys
2684         fi
2685     fi
2686     if test "$wxUSE_EXPAT" = "builtin" ; then
2687         dnl Expat needs this:
2688         AC_CONFIG_SUBDIRS([src/expat])
2689     fi
2690 fi
2691
2692
2693 dnl ------------------------------------------------------------------------
2694 dnl Check for libmspack
2695 dnl ------------------------------------------------------------------------
2696
2697 if test "$wxUSE_LIBMSPACK" != "no"; then
2698     AC_CHECK_HEADER([mspack.h], [found_mspack_h=1],, [ ])
2699     if test "x$found_mspack_h" = "x1"; then
2700         AC_CHECK_LIB(mspack, mspack_create_chm_decompressor,
2701                      MSPACK_LINK=" -lmspack")
2702     fi
2703     if test "x$MSPACK_LINK" = "x" ; then
2704         wxUSE_LIBMSPACK=no
2705     fi
2706 fi
2707
2708 if test "$wxUSE_LIBMSPACK" != "no"; then
2709     AC_DEFINE(wxUSE_LIBMSPACK)
2710 fi
2711
2712
2713 dnl ----------------------------------------------------------------
2714 dnl search for toolkit (widget sets)
2715 dnl ----------------------------------------------------------------
2716
2717 AFMINSTALL=
2718 WIN32INSTALL=
2719
2720 TOOLKIT=
2721 TOOLKIT_INCLUDE=
2722 WIDGET_SET=
2723
2724 dnl are we building for a win32 target environment?
2725 dnl If so, setup common stuff needed for both GUI and Base libs.
2726 if test "$USE_WIN32" = 1 ; then
2727     AC_CHECK_HEADERS(w32api.h,,, [ ])
2728     AC_CHECK_HEADER(windows.h,,
2729     [
2730         AC_MSG_ERROR(please set CFLAGS to contain the location of windows.h)
2731     ],
2732     [ ])
2733
2734     dnl --- FIXME: This is still a somewhat random list of libs,
2735     dnl ---        some of them should probably be included conditionally.
2736     case "${host}" in
2737         x86_64-*-mingw32* )
2738             dnl --- For mingw-w64 lctl3d32's name has changed
2739             LIBS="$LIBS -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -lwctl3d32 -ladvapi32 -lwsock32 -lgdi32"
2740
2741             dnl we need to define this to embed the manifest for correct
2742             dnl platform from wx/msw/wx.rc (this is not needed for x86 which is
2743             dnl the default in wx/msw/rcdefs.h)
2744             WINDRES_CPU_DEFINE="--define WX_CPU_AMD64"
2745         ;;
2746         * )
2747             LIBS="$LIBS -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -lctl3d32 -ladvapi32 -lwsock32 -lgdi32"
2748         ;;
2749     esac
2750     if test "$wxUSE_ACCESSIBILITY" = "yes" ; then
2751         LIBS="$LIBS -loleacc"
2752     fi
2753
2754     case "${host}" in
2755         *-*-cygwin* )
2756             dnl Cygwin doesn't include these by default
2757             LIBS="$LIBS -lkernel32 -luser32"
2758     esac
2759
2760     dnl This one is still used by some sample makefiles.
2761     RESFLAGS="--include-dir \$(top_srcdir)/include --include-dir \$(top_srcdir)/\$(program_dir) --define __WIN32__ --define __WIN95__ --define __GNUWIN32__"
2762     RESPROGRAMOBJ="\$(PROGRAM)_resources.o"
2763
2764     dnl This lot we export to wx-config.  It must add the relevant
2765     dnl include directories at the point when they can be known.
2766     dnl (but are these (still) required anyway?)
2767     WXCONFIG_RESFLAGS="--define __WIN32__ --define __WIN95__ --define __GNUWIN32__"
2768
2769     dnl install Win32-specific files in "make install"
2770     WIN32INSTALL=win32install
2771
2772     dnl pbt.h is missing on Wine at least
2773     AC_CHECK_HEADER([pbt.h],, [AC_DEFINE(NEED_PBT_H)], [ ])
2774 fi
2775
2776 if test "$wxUSE_GUI" = "yes"; then
2777     USE_GUI=1
2778
2779     GUI_TK_LIBRARY=
2780
2781     WXGTK12=
2782     WXGTK127=
2783     WXGTK2=
2784     WXGPE=
2785
2786     if test "$wxUSE_COCOA" = 1 ; then
2787         if test "$wxUSE_PRINTING_ARCHITECTURE" = "yes"; then
2788             AC_MSG_WARN([Printing not supported under wxCocoa yet, disabled])
2789             wxUSE_PRINTING_ARCHITECTURE=no
2790         fi
2791         if test "$wxUSE_DRAG_AND_DROP" = "yes"; then
2792             AC_MSG_WARN([Drag and Drop not supported under wxCocoa yet, disabled])
2793             wxUSE_DRAG_AND_DROP=no
2794         fi
2795         if test "$wxUSE_DRAGIMAGE" = "yes"; then
2796             AC_MSG_WARN([wxDragImage not supported under wxCocoa yet, disabled])
2797             wxUSE_DRAGIMAGE=no
2798         fi
2799     fi
2800
2801     if test "$wxUSE_MSW" = 1 ; then
2802         TOOLKIT=MSW
2803         GUIDIST=MSW_DIST
2804
2805         dnl -mwindows causes a heap of other default gui libs to be linked in.
2806         case "${host}" in
2807             *-*-mingw32* )
2808                 WXCONFIG_LDFLAGS_GUI="$LDFLAGS -Wl,--subsystem,windows -mwindows"
2809         esac
2810     fi
2811
2812     if test "$wxUSE_GTK" = 1; then
2813         dnl GTK+ test program must be compiled with C compiler
2814         AC_MSG_CHECKING([for GTK+ version])
2815
2816         gtk_version_cached=1
2817         AC_CACHE_VAL(wx_cv_lib_gtk,
2818             [
2819                 dnl stupid GTK+ AM macros produce their own messages, so we
2820                 dnl have to pass to the next line
2821                 gtk_version_cached=0
2822                 AC_MSG_RESULT()
2823
2824                 dnl we must link against lgthread unless the user
2825                 dnl used --disable-threads
2826                 GTK_MODULES=
2827                 if test "$wxUSE_THREADS" = "yes"; then
2828                     GTK_MODULES=gthread
2829                 fi
2830
2831                 dnl detect GTK2
2832                 wx_cv_lib_gtk=
2833                 if test "x$wxGTK_VERSION" != "x1"
2834                 then
2835                     dnl The gthread.pc that ships with Solaris returns '-mt',
2836                     dnl it's correct for Sun CC, but gcc requires '-pthreads'.
2837                     dnl So disable the compile check and remove the -mt below.
2838                     case "${host}" in
2839                         *-*-solaris2* )
2840                             if test "$wxUSE_THREADS" = "yes" -a "$GCC" = yes; then
2841                                 enable_gtktest=no
2842                             fi
2843                     esac
2844
2845                     AM_PATH_GTK_2_0(2.4.0, wx_cv_lib_gtk=2.0, , $GTK_MODULES)
2846
2847                     dnl Solaris also requires -lX11 for static lib
2848                     case "${host}" in
2849                         *-*-solaris2* )
2850                             if test "$wxUSE_SHARED" != "yes"; then
2851                                 GTK_LIBS="$GTK_LIBS -lX11"
2852                             fi
2853                     esac
2854                 fi
2855
2856                 dnl detect GTK1.x
2857                 if test -z "$wx_cv_lib_gtk"; then
2858                     if test "x$wxGTK_VERSION" = "x1" -o "x$wxGTK_VERSION" = "xany" ; then
2859                         AM_PATH_GTK(1.2.7, wx_cv_lib_gtk=1.2.7, , $GTK_MODULES)
2860
2861                         if test -z "$wx_cv_lib_gtk"; then
2862                             AM_PATH_GTK(1.2.3, wx_cv_lib_gtk=1.2.3, , $GTK_MODULES)
2863                         fi
2864                     fi
2865                 fi
2866
2867                 if test -z "$wx_cv_lib_gtk"; then
2868                     dnl looks better in AC_MSG_RESULT
2869                     wx_cv_lib_gtk=none
2870                 else
2871                     dnl we need to cache GTK_CFLAGS and GTK_LIBS for the
2872                     dnl subsequent runs
2873                     wx_cv_cflags_gtk=$GTK_CFLAGS
2874                     wx_cv_libs_gtk=`echo $GTK_LIBS | sed -e 's/ -l[[^ ]]*cairo[[^ ]]*//g'`
2875                 fi
2876             ]
2877         )
2878
2879         dnl if it wasn't cached, the messages from AM_PATH_GTK() above are
2880         dnl enough
2881         if test "$gtk_version_cached" = 1; then
2882             AC_MSG_RESULT($wx_cv_lib_gtk)
2883         fi
2884
2885         case "$wx_cv_lib_gtk" in
2886             2.0)    WXGTK2=1
2887                     TOOLKIT_VERSION=2
2888                     ;;
2889             1.2.7)  WXGTK127=1
2890                     WXGTK12=1
2891                     ;;
2892             1.2.3)  WXGTK12=1
2893                     ;;
2894             *)      AC_MSG_ERROR([
2895 The development files for GTK+ were not found. For GTK+ 2, please
2896 ensure that pkg-config is in the path and that gtk+-2.0.pc is
2897 installed. For GTK+ 1.2 please check that gtk-config is in the path,
2898 and that the version is 1.2.3 or above. Also check that the
2899 libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
2900 --libs' are in the LD_LIBRARY_PATH or equivalent.
2901                             ])
2902                     ;;
2903         esac
2904
2905         if test "$WXGTK2" = 1; then
2906             save_CFLAGS="$CFLAGS"
2907             save_LIBS="$LIBS"
2908             CFLAGS="$wx_cv_cflags_gtk $CFLAGS"
2909             LIBS="$LIBS $wx_cv_libs_gtk"
2910
2911             dnl test if we have at least GTK+ 2.18:
2912             AC_MSG_CHECKING([if GTK+ is version >= 2.18])
2913             AC_TRY_COMPILE([
2914                             #include <gtk/gtk.h>
2915                            ],
2916                            [
2917                             #if !GTK_CHECK_VERSION(2,18,0)
2918                             Not GTK+ 2.18
2919                             #endif
2920                            ],
2921                            [
2922                             AC_DEFINE(__WXGTK218__)
2923                             AC_DEFINE(__WXGTK210__)
2924                             AC_DEFINE(__WXGTK26__)
2925                             AC_MSG_RESULT([yes])
2926                             ac_wxgtk218=1
2927                            ],
2928                            [
2929                             AC_MSG_RESULT([no])
2930                             ac_wxgtk218=0
2931                            ])
2932
2933             if test "$ac_wxgtk218" = 0; then
2934                 dnl test if we have at least GTK+ 2.10:
2935                 AC_MSG_CHECKING([if GTK+ is version >= 2.10])
2936                 AC_TRY_COMPILE([
2937                                 #include <gtk/gtk.h>
2938                                ],
2939                                [
2940                                 #if !GTK_CHECK_VERSION(2,10,0)
2941                                 Not GTK+ 2.10
2942                                 #endif
2943                                ],
2944                                [
2945                                 AC_DEFINE(__WXGTK210__)
2946                                 AC_DEFINE(__WXGTK26__)
2947                                 AC_MSG_RESULT([yes])
2948                                 ac_wxgtk210=1
2949                                ],
2950                                [
2951                                 AC_MSG_RESULT([no])
2952                                 ac_wxgtk210=0
2953                                ])
2954
2955                 if test "$ac_wxgtk210" = 0; then
2956                     dnl test if we have at least GTK+ 2.6:
2957                     AC_MSG_CHECKING([if GTK+ is version >= 2.6])
2958                     AC_TRY_COMPILE([
2959                                     #include <gtk/gtk.h>
2960                                 ],
2961                                 [
2962                                     #if !GTK_CHECK_VERSION(2,6,0)
2963                                     Not GTK+ 2.6
2964                                     #endif
2965                                 ],
2966                                 [
2967                                     AC_DEFINE(__WXGTK26__)
2968                                     AC_MSG_RESULT([yes])
2969                                     ac_wxgtk26=1
2970                                 ],
2971                                 [
2972                                     AC_MSG_RESULT([no])
2973                                     ac_wxgtk26=0
2974                                 ])
2975                 fi
2976             fi
2977
2978             CFLAGS="$save_CFLAGS"
2979             LIBS="$save_LIBS"
2980         else
2981             if test "$wxUSE_UNICODE" = "yes"; then
2982                 AC_MSG_WARN([Unicode configuration not supported with GTK+ 1.x])
2983                 wxUSE_UNICODE=no
2984             fi
2985
2986             dnl test for XIM support in libgdk
2987             AC_CHECK_LIB(gdk, gdk_im_open, AC_DEFINE(HAVE_XIM))
2988
2989             dnl we need poll() in src/gtk1/app.cpp (we know that Darwin doesn't
2990             dnl have it but we do the check for the others)
2991             if test "$USE_DARWIN" != 1; then
2992                 AC_CHECK_FUNCS(poll)
2993             fi
2994         fi
2995
2996         TOOLKIT_INCLUDE="$wx_cv_cflags_gtk"
2997         GUI_TK_LIBRARY="$wx_cv_libs_gtk $GUI_TK_LIBRARY"
2998
2999         AFMINSTALL=afminstall
3000         TOOLKIT=GTK
3001         GUIDIST=GTK_DIST
3002
3003         dnl test for external libxpm if we're configured to use it
3004         if test "$wxUSE_GPE" = "yes"; then
3005             AC_MSG_CHECKING(for gpewidget library)
3006             WX_PATH_FIND_LIBRARIES($SEARCH_LIB,gpewidget)
3007             if test "$ac_find_libraries" != "" ; then
3008                 WX_LINK_PATH_EXIST($ac_find_libraries,$GUI_TK_LIBRARY)
3009                 dnl -lgpewidget must be before all GTK libs and
3010                 dnl we guess its path from the prefix
3011                 GUI_TK_LIBRARY="-L${prefix}/lib -lgpewidget $GUI_TK_LIBRARY"
3012                 WXGPE=1
3013                 AC_MSG_RESULT([found in $ac_find_libraries])
3014             else
3015                 AC_MSG_RESULT(not found)
3016             fi
3017
3018             dnl AC_MSG_CHECKING(for gpe library)
3019             dnl WX_PATH_FIND_LIBRARIES($SEARCH_LIB,gpe)
3020             dnl if test "$ac_find_libraries" != "" ; then
3021             dnl     WX_LINK_PATH_EXIST($ac_find_libraries,$GUI_TK_LIBRARY)
3022             dnl     GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lgpe"
3023             dnl     AC_MSG_RESULT(found in $ac_find_libraries)
3024             dnl else
3025             dnl     AC_MSG_RESULT(not found)
3026             dnl fi
3027         fi
3028     fi
3029
3030     if test "$wxUSE_MGL" = 1; then
3031        AC_MSG_CHECKING(for SciTech MGL library)
3032         if test "x$MGL_ROOT" = x ; then
3033             AC_MSG_RESULT(not found)
3034             AC_MSG_ERROR([Cannot find MGL library. Make sure MGL_ROOT is set.])
3035         else
3036             AC_MSG_RESULT($MGL_ROOT)
3037         fi
3038
3039         AC_MSG_CHECKING(for libmgl location)
3040         dnl Find MGL library that we want
3041         dnl FIXME_MGL - test for MGL variants for freebsd etc.;
3042         dnl             and for non-x86 versions
3043         case "${host}" in
3044             *-*-linux* )
3045               dnl glibc.so, glibc are for older versions of MGL,
3046               dnl x86/a, x86/so are used by >= 5.0 R11
3047               if test "x$wxUSE_SHARED" = xyes ; then
3048                   mgl_os_candidates="linux/gcc/x86/so linux/gcc/x86/a linux/gcc/glibc.so linux/gcc/glibc"
3049               else
3050                   mgl_os_candidates="linux/gcc/x86/a linux/gcc/x86/so linux/gcc/glibc linux/gcc/glibc.so"
3051               fi
3052               ;;
3053             *-pc-msdosdjgpp )
3054               mgl_os_candidates="dos32/dj2"
3055               ;;
3056             *)
3057               AC_MSG_ERROR(This system type ${host} is not yet supported by wxMGL.)
3058         esac
3059
3060         mgl_lib_type=""
3061         mgl_os=""
3062
3063         for mgl_os_i in $mgl_os_candidates ; do
3064             if test "x$mgl_os" = x ; then
3065                 if test "$wxUSE_DEBUG_FLAG" = yes ; then
3066                     if test -f $MGL_ROOT/lib/debug/$mgl_os_i/libmgl.a -o \
3067                             -f $MGL_ROOT/lib/debug/$mgl_os_i/libmgl.so; then
3068                         mgl_lib_type=debug
3069                         mgl_os=$mgl_os_i
3070                     fi
3071                 fi
3072                 if test "x$mgl_lib_type" = x ; then
3073                     if test -f $MGL_ROOT/lib/release/$mgl_os_i/libmgl.a -o \
3074                             -f $MGL_ROOT/lib/release/$mgl_os_i/libmgl.so; then
3075                         mgl_lib_type=release
3076                         mgl_os=$mgl_os_i
3077                     fi
3078                 fi
3079             fi
3080         done
3081
3082         if test "x$mgl_os" = x ; then
3083             AC_MSG_RESULT(not found)
3084             AC_MSG_ERROR([Cannot find MGL libraries, make sure they are compiled.])
3085         fi
3086         AC_MSG_RESULT("$MGL_ROOT/lib/$mgl_lib_type/$mgl_os")
3087
3088         wxUSE_UNIVERSAL="yes"
3089
3090         TOOLKIT_INCLUDE="-I$MGL_ROOT/include"
3091         GUI_TK_LIBRARY="-L$MGL_ROOT/lib/$mgl_lib_type/$mgl_os -lmgl -lmglcpp -lpm"
3092
3093         AFMINSTALL=afminstall
3094         TOOLKIT=MGL
3095         GUIDIST=MGL_DIST
3096     fi
3097
3098     if test "$wxUSE_DFB" = 1; then
3099        PKG_PROG_PKG_CONFIG()
3100
3101        PKG_CHECK_MODULES(DIRECTFB,
3102                          [directfb >= 0.9.23],
3103                          [
3104                            wxUSE_UNIVERSAL="yes"
3105                            TOOLKIT_INCLUDE="$DIRECTFB_CFLAGS"
3106                            GUI_TK_LIBRARY="$DIRECTFB_LIBS"
3107                            TOOLKIT=DFB
3108                            GUIDIST=DFB_DIST
3109                          ],
3110                          [
3111                            AC_MSG_ERROR([DirectFB not found.])
3112                          ]
3113                          )
3114     fi
3115
3116     if test "$wxUSE_MICROWIN" = 1; then
3117         AC_MSG_CHECKING(for MicroWindows)
3118         if test "x$MICROWINDOWS" = x ; then
3119             AC_MSG_RESULT(not found)
3120             AC_MSG_ERROR([Cannot find MicroWindows library. Make sure MICROWINDOWS is set.])
3121         else
3122             AC_MSG_RESULT($MICROWINDOWS)
3123         fi
3124
3125         if test -f $MICROWINDOWS/lib/libmwin.a; then
3126             AC_MSG_RESULT(MicroWindows' libraries found.)
3127         else
3128             AC_MSG_ERROR([Cannot find MicroWindows libraries, make sure they are compiled.])
3129         fi
3130
3131         TOOLKIT_INCLUDE="-I$MICROWINDOWS/include"
3132         GUI_TK_LIBRARY="-L$MICROWINDOWS/lib -lmwin -lmwengine -mwfonts -mwdrivers -mwinlib"
3133
3134         wxUSE_UNIVERSAL="yes"
3135
3136         AFMINSTALL=afminstall
3137         TOOLKIT=MICROWIN
3138         GUIDIST=MICROWIN_DIST
3139
3140         TOOLCHAIN_DEFS="${TOOLCHAIN_DEFS} -D__WXMSW__ -D__WIN95__ -D__WIN32__ -DMWIN -DMICROWIN_NOCONTROLS -DMICROWIN_TODO=1"
3141     fi
3142
3143     dnl common part of X11 and Motif port checks
3144     if test "$wxUSE_X11" = 1 -o "$wxUSE_MOTIF" = 1; then
3145         dnl use standard macros to check for X headers/libs, this brings
3146         dnl support for the standard configure options --x-includes,
3147         dnl --x-libraries and --no-x
3148         AC_PATH_XTRA
3149
3150         if test "$no_x" = "yes"; then
3151           AC_MSG_ERROR([X11 not found, please use --x-includes and/or --x-libraries options (see config.log for details)])
3152         fi
3153
3154         dnl for some reason AC_PATH_XTRA seems to add -INONE and -LNONE (and
3155         dnl also sometimes -RNONE) to X_CFLAGS and X_LIBS respectively, filter
3156         dnl this junk out
3157         GUI_TK_LIBRARY=`echo $X_LIBS | sed 's/ -LNONE//' | sed 's/ -RNONE//'`
3158         TOOLKIT_INCLUDE=`echo $X_CFLAGS | sed 's/ -INONE//'`
3159         AFMINSTALL=afminstall
3160         COMPILED_X_PROGRAM=0
3161
3162     fi
3163
3164     if test "$wxUSE_X11" = 1; then
3165         if test "$wxUSE_NANOX" = "yes"; then
3166             AC_MSG_CHECKING(for MicroWindows/NanoX distribution)
3167             if test "x$MICROWIN" = x ; then
3168                 AC_MSG_RESULT(not found)
3169                 AC_MSG_ERROR([Cannot find MicroWindows library. Make sure MICROWIN is set.])
3170             else
3171                 AC_MSG_RESULT($MICROWIN)
3172                 AC_DEFINE(wxUSE_NANOX)
3173             fi
3174         fi
3175
3176         if test "$wxUSE_UNICODE" = "yes"; then
3177             PKG_PROG_PKG_CONFIG()
3178
3179             PKG_CHECK_MODULES(PANGOX, pangox,
3180                 [
3181                     CFLAGS="$PANGOX_CFLAGS $CFLAGS"
3182                     CXXFLAGS="$PANGOX_CFLAGS $CXXFLAGS"
3183                     GUI_TK_LIBRARY="$GUI_TK_LIBRARY $PANGOX_LIBS"
3184                 ],
3185                 [
3186                     AC_MSG_ERROR([pangox library not found, library cannot be compiled in Unicode mode])
3187                 ]
3188             )
3189             PKG_CHECK_MODULES(PANGOFT2, pangoft2,
3190                 [
3191                     CFLAGS="$PANGOFT2_CFLAGS $CFLAGS"
3192                     CXXFLAGS="$PANGOFT2_CFLAGS $CXXFLAGS"
3193                     GUI_TK_LIBRARY="$GUI_TK_LIBRARY $PANGOFT2_LIBS"
3194                 ],
3195                 [
3196                     AC_MSG_WARN([pangoft2 library not found, library will be compiled without printing support])
3197                     wxUSE_PRINTING_ARCHITECTURE="no"
3198                 ]
3199             )
3200             PKG_CHECK_MODULES(PANGOXFT, pangoxft,
3201                 [
3202                     AC_DEFINE(HAVE_PANGO_XFT)
3203                     CFLAGS="$PANGOXFT_CFLAGS $CFLAGS"
3204                     CXXFLAGS="$PANGOXFT_CFLAGS $CXXFLAGS"
3205                     GUI_TK_LIBRARY="$GUI_TK_LIBRARY $PANGOXFT_LIBS"
3206                 ],
3207                 [
3208                     AC_MSG_WARN([pangoxft library not found, library will be compiled without anti-aliasing support])
3209                 ]
3210             )
3211             save_LIBS="$LIBS"
3212             LIBS="$LIBS $PANGOX_LIBS"
3213             AC_CHECK_FUNCS([pango_font_family_is_monospace])
3214             LIBS="$save_LIBS"
3215         fi
3216
3217         wxUSE_UNIVERSAL="yes"
3218
3219         if test "$wxUSE_NANOX" = "yes"; then
3220             TOOLKIT_INCLUDE="-I\$(top_srcdir)/include/wx/x11/nanox -I\$(MICROWIN)/src/include $TOOLKIT_INCLUDE"
3221             TOOLCHAIN_DEFS="${TOOLCHAIN_DEFS} -D__NANOX__ -DMWPIXEL_FORMAT=MWPF_TRUECOLOR0888 -DHAVE_FILEIO -DHAVE_BMP_SUPPORT=1 -DHAVE_GIF_SUPPORT=1 -DHAVE_PNM_SUPPORT=1 -DHAVE_XPM_SUPPORT=1 -DUNIX=1 -DUSE_EXPOSURE -DSCREEN_HEIGHT=480 -DSCREEN_WIDTH=640 -DSCREEN_DEPTH=4 -DX11=1"
3222             GUI_TK_LIBRARY="$GUI_TK_LIBRARY \$(MICROWIN)/src/lib/libnano-X.a"
3223         else
3224             GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lX11"
3225         fi
3226
3227         TOOLKIT=X11
3228         GUIDIST=X11_DIST
3229     fi
3230
3231     if test "$wxUSE_MOTIF" = 1; then
3232         AC_MSG_CHECKING(for Motif/Lesstif headers)
3233         WX_PATH_FIND_INCLUDES($SEARCH_INCLUDE, Xm/Xm.h)
3234         if test "$ac_find_includes" != "" ; then
3235             AC_MSG_RESULT(found in $ac_find_includes)
3236             WX_INCLUDE_PATH_EXIST($ac_find_includes, $TOOLKIT_INCLUDE)
3237             TOOLKIT_INCLUDE="$TOOLKIT_INCLUDE$ac_path_to_include"
3238         else
3239             save_CFLAGS=$CFLAGS
3240             CFLAGS="$TOOLKIT_INCLUDE $CFLAGS"
3241
3242             AC_TRY_COMPILE(
3243                 [
3244                     #include <Xm/Xm.h>
3245                 ],
3246                 [
3247                     int version;
3248                     version = xmUseVersion;
3249                 ],
3250                 [
3251                     AC_MSG_RESULT(found in default search path)
3252                     COMPILED_X_PROGRAM=1
3253                 ],
3254                 [
3255                     AC_MSG_RESULT(no)
3256                     AC_MSG_ERROR(please set CPPFLAGS to contain the location of Xm/Xm.h)
3257                 ]
3258             )
3259
3260             CFLAGS=$save_CFLAGS
3261         fi
3262
3263
3264         AC_MSG_CHECKING(for Motif/Lesstif library)
3265         WX_PATH_FIND_LIBRARIES($SEARCH_LIB, Xm)
3266
3267         if test "x$ac_find_libraries" != "x" ; then
3268             AC_MSG_RESULT(found in $ac_find_libraries)
3269
3270             WX_LINK_PATH_EXIST($ac_find_libraries, $GUI_TK_LIBRARY)
3271             GUI_TK_LIBRARY="$GUI_TK_LIBRARY$ac_path_to_link"
3272         else
3273             dnl it might happen that we found headers in one of the standard
3274             dnl paths but the libs are elsewhere but still in default (linker)
3275             dnl path -- try to compile a test program to check for this
3276             save_CFLAGS=$CFLAGS
3277             CFLAGS="$TOOLKIT_INCLUDE $CFLAGS"
3278             save_LIBS="$LIBS"
3279             LIBS="$GUI_TK_LIBRARY -lXm -lXmu -lXext -lX11"
3280
3281             AC_TRY_LINK(
3282                 [
3283                     #include <Xm/Xm.h>
3284                 ],
3285                 [
3286                     int version;
3287                     version = xmUseVersion;
3288                 ],
3289                 [
3290                     AC_MSG_RESULT(found in default search path)
3291                     COMPILED_X_PROGRAM=1
3292                 ],
3293                 [
3294                     AC_MSG_RESULT(no)
3295                     AC_MSG_ERROR(please set LDFLAGS to contain the location of libXm)
3296                 ]
3297             )
3298
3299             CFLAGS=$save_CFLAGS
3300             LIBS="$save_LIBS"
3301         fi
3302
3303         AC_MSG_CHECKING([if we need -lXp and/or -lSM -lICE])
3304         libp_link=""
3305         libsm_ice_link=""
3306         libs_found=0
3307         for libp in "" " -lXp"; do
3308             if test "$libs_found" = 0; then
3309                 for libsm_ice in "" " -lSM -lICE"; do
3310                     if test "$libs_found" = 0; then
3311                         save_LIBS="$LIBS"
3312                         LIBS="$GUI_TK_LIBRARY -lXm ${libp} -lXmu -lXext -lXt${libsm_ice} -lX11"
3313                         save_CFLAGS=$CFLAGS
3314                         CFLAGS="$TOOLKIT_INCLUDE $CFLAGS"
3315
3316                         AC_TRY_LINK(
3317                             [
3318                                 #include <Xm/Xm.h>
3319                                 #include <Xm/List.h>
3320                             ],
3321                             [
3322                                 XmString string = NULL;
3323                                 Widget w = NULL;
3324                                 int position = 0;
3325                                 XmListAddItem(w, string, position);
3326                             ],
3327                             [
3328                                 libp_link="$libp"
3329                                 libsm_ice_link="$libsm_ice"
3330                                 AC_MSG_RESULT(
3331                                     [need${libp_link}${libsm_ice_link}])
3332                                 libs_found=1
3333                             ], []
3334                         )
3335
3336                         LIBS="$save_LIBS"
3337                         CFLAGS=$save_CFLAGS
3338                     fi
3339                 done
3340             fi
3341         done
3342
3343         if test "$libs_found" = 0; then
3344             AC_MSG_RESULT([can't find the right libraries])
3345             AC_MSG_ERROR([can't link a simple motif program])
3346         fi
3347
3348         dnl this seems to be needed under IRIX and shouldn't do any harm
3349         dnl elsewhere
3350         AC_CHECK_LIB(Sgm, [SgCreateList], [libsgm_link=" -lSgm"])
3351
3352         save_CFLAGS=$CFLAGS
3353         CFLAGS="$TOOLKIT_INCLUDE $CFLAGS"
3354
3355         AC_CACHE_CHECK([for Motif 2],
3356             wx_cv_lib_motif2,
3357             AC_TRY_COMPILE([
3358                             #include <Xm/Xm.h>
3359                            ],
3360                            [
3361                             #if XmVersion < 2000
3362                             Not Motif 2
3363                             #endif
3364                            ],
3365                            wx_cv_lib_motif2="yes",
3366                            wx_cv_lib_motif2="no"))
3367         if test "$wx_cv_lib_motif2" = "yes"; then
3368             AC_DEFINE(__WXMOTIF20__,1)
3369         else
3370             AC_DEFINE(__WXMOTIF20__,0)
3371         fi
3372
3373         AC_CACHE_CHECK([whether Motif is Lesstif],
3374             wx_cv_lib_lesstif,
3375             AC_TRY_COMPILE([
3376                             #include <Xm/Xm.h>
3377                            ],
3378                            [
3379                             #if !defined(LesstifVersion) || LesstifVersion <= 0
3380                             Not Lesstif
3381                             #endif
3382                            ],
3383                            wx_cv_lib_lesstif="yes",
3384                            wx_cv_lib_lesstif="no")
3385         )
3386         if test "$wx_cv_lib_lesstif" = "yes"; then
3387             AC_DEFINE(__WXLESSTIF__,1)
3388         else
3389             AC_DEFINE(__WXLESSTIF__,0)
3390         fi
3391
3392         CFLAGS=$save_CFLAGS
3393
3394         GUI_TK_LIBRARY="$GUI_TK_LIBRARY${libsgm_link} -lXm${libp_link} -lXmu -lXext -lXt${libsm_ice_link} -lX11"
3395         TOOLKIT=MOTIF
3396         GUIDIST=MOTIF_DIST
3397     fi
3398
3399     dnl more tests common to X11 and Motif:
3400     if test "$wxUSE_X11" = 1 -o "$wxUSE_MOTIF" = 1; then
3401         dnl test for external libxpm if we're configured to use it
3402         if test "$wxUSE_LIBXPM" = "sys"; then
3403             AC_MSG_CHECKING(for Xpm library)
3404             WX_PATH_FIND_LIBRARIES($SEARCH_LIB,Xpm)
3405             if test "$ac_find_libraries" != "" ; then
3406                 WX_LINK_PATH_EXIST($ac_find_libraries,$GUI_TK_LIBRARY)
3407                 GUI_TK_LIBRARY="$GUI_TK_LIBRARY$ac_path_to_link"
3408                 AC_MSG_RESULT(found in $ac_find_libraries)
3409
3410                 AC_CACHE_CHECK([for X11/xpm.h],
3411                     wx_cv_x11_xpm_h,
3412                     [
3413                         save_CFLAGS=$CFLAGS
3414                         CFLAGS="$TOOLKIT_INCLUDE $CFLAGS"
3415
3416                         AC_TRY_COMPILE(
3417                             [
3418                                 #include <X11/xpm.h>
3419                             ],
3420                             [
3421                                 int version;
3422                                 version = XpmLibraryVersion();
3423                             ],
3424                             wx_cv_x11_xpm_h=yes,
3425                             wx_cv_x11_xpm_h=no
3426                         )
3427
3428                         CFLAGS=$save_CFLAGS
3429                     ]
3430                 )
3431
3432                 if test $wx_cv_x11_xpm_h = "yes"; then
3433                     GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lXpm"
3434                     AC_DEFINE(wxHAVE_LIB_XPM)
3435                 else
3436                     AC_MSG_WARN([built-in less efficient XPM decoder will be used])
3437                 fi
3438             fi
3439
3440         fi
3441
3442         dnl XShapeQueryExtension checks: first the library, then prototype
3443         AC_CHECK_LIB([Xext], [XShapeQueryExtension],
3444                      [
3445                       GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lXext"
3446                       wxHAVE_XEXT_LIB=1
3447                      ],
3448                      [], [$GUI_TK_LIBRARY -lX11])
3449
3450         if test "$wxHAVE_XEXT_LIB" = 1; then
3451             save_CFLAGS="$CFLAGS"
3452             CFLAGS="$TOOLKIT_INCLUDE $CFLAGS"
3453
3454             AC_MSG_CHECKING([for X11/extensions/shape.h])
3455             AC_TRY_COMPILE([
3456                             #include <X11/Xlib.h>
3457                             #include <X11/extensions/shape.h>
3458                            ],
3459                            [
3460                             int dummy1, dummy2;
3461                             XShapeQueryExtension((Display*)NULL,
3462                                                  (int*)NULL, (int*)NULL);
3463                            ],
3464                            [
3465                             AC_DEFINE(HAVE_XSHAPE)
3466                             AC_MSG_RESULT([found])
3467                            ],
3468                            [
3469                             AC_MSG_RESULT([not found])
3470                            ])
3471             CFLAGS="$save_CFLAGS"
3472
3473         fi
3474     fi
3475
3476     if test "$wxUSE_OSX_CARBON" = 1; then
3477         AC_MSG_CHECKING([for compiler syntax to enable Pascal strings])
3478         if test "$GCC" = yes; then
3479             AC_MSG_RESULT([gcc])
3480             CPPFLAGS_PASCAL="-fpascal-strings"
3481         elif test "`echo $CXX | sed -e 's@.*/@@'`" = "xlC"; then
3482             AC_MSG_RESULT([xlc])
3483             CPPFLAGS_PASCAL="-qmacpstr"
3484         else
3485             AC_MSG_RESULT([none])
3486         fi
3487
3488         if test "x$wxUSE_UNIX" = "xyes"; then
3489             CPPFLAGS="$CPPFLAGS_PASCAL -I\${top_srcdir}/src/mac/carbon/morefilex -I/Developer/Headers/FlatCarbon $CPPFLAGS"
3490         else
3491             dnl platform.h needs TARGET_CARBON before setup.h
3492             CPPFLAGS="$CPPFLAGS_PASCAL -I\${top_srcdir}/src/mac/carbon/morefilex -DTARGET_CARBON $CPPFLAGS"
3493         fi
3494
3495         TOOLKIT=OSX_CARBON
3496         dnl we can't call this MAC_DIST or autoconf thinks its a macro
3497         GUIDIST=OSX_CARBON_DIST
3498         dnl wxMac version of wxBase and wxCocoa or wxBase-only built on Darwin
3499         dnl are different, so they need different names:
3500         WXBASEPORT="_carbon"
3501
3502         dnl in addition to defining __WXOSX_CARBON__ for this toolkit we want
3503         dnl to also define these extra symbols to make it possible to test for
3504         dnl any Mac port (__WXMAC__ is for backwards compatibility, __WXOSX__
3505         dnl is a new name)
3506         TOOLCHAIN_DEFS="${TOOLCHAIN_DEFS} -D__WXMAC__ -D__WXOSX__"
3507     fi
3508
3509     if test "$wxUSE_OSX_COCOA" = 1; then
3510         TOOLKIT=OSX_COCOA
3511         GUIDIST=OSX_COCOA_DIST
3512
3513         dnl see the comment above in wxUSE_OSX_CARBON branch
3514         TOOLCHAIN_DEFS="${TOOLCHAIN_DEFS} -D__WXMAC__ -D__WXOSX__"
3515     fi
3516
3517     if test "$wxUSE_COCOA" = 1; then
3518         TOOLKIT=COCOA
3519         GUIDIST=COCOA_DIST
3520     fi
3521
3522     if test "$wxUSE_PM" = 1; then
3523         TOOLKIT=PM
3524         GUIDIST=PM_DIST
3525         AC_CACHE_CHECK([for type SPBCDATA],
3526             wx_cv_spbcdata,
3527             [
3528                 AC_TRY_COMPILE(
3529                     [
3530                         #define INCL_PM
3531                         #include <os2.h>
3532                     ],
3533                     [
3534                         SPBCDATA test;
3535                     ],
3536                     wx_cv_spbcdata=yes,
3537                     wx_cv_spbcdata=no
3538                 )
3539             ]
3540         )
3541
3542         if test $wx_cv_spbcdata = "yes"; then
3543             AC_DEFINE(HAVE_SPBCDATA)
3544         fi
3545     fi
3546
3547     dnl the name of the directory where the files for this toolkit live
3548     if test "$TOOLKIT" = "PM" ; then
3549         TOOLKIT_DIR="os2"
3550     else
3551         TOOLKIT_DIR=`echo ${TOOLKIT} | tr '[[A-Z]]' '[[a-z]]'`
3552     fi
3553
3554     if test "$wxUSE_UNIVERSAL" = "yes"; then
3555         TOOLCHAIN_DEFS="${TOOLCHAIN_DEFS} -D__WXUNIVERSAL__"
3556         WIDGET_SET=univ
3557     fi
3558
3559     dnl distribute samples/demos/utils with GUI versions
3560     GUIDIST="${GUIDIST} SAMPLES_DIST DEMOS_DIST UTILS_DIST MISC_DIST"
3561     DISTDIR="wx\$(TOOLKIT)"
3562 else
3563     USE_GUI=0
3564
3565     dnl this doesn't quite work right for wxBase, but the places
3566     dnl where it is wrong aren't fatal (yet) though.
3567     TOOLKIT_DIR="base"
3568
3569     dnl the sources, their dependenices and the headers
3570     if test "$USE_WIN32" = 1 ; then
3571         dnl yes, the toolkit for wxBase on win32 is actually MSW
3572         dnl wxBase on unix does not need a 'TOOLKIT' defined.
3573         TOOLKIT="MSW"
3574     fi
3575
3576     dnl distribute only wxBase sources/headers
3577     GUIDIST="BASE_DIST"
3578     DISTDIR="wxBase"
3579 fi
3580
3581
3582 dnl ---------------------------------------------------------------------------
3583 dnl UTF-8 support
3584 dnl ---------------------------------------------------------------------------
3585
3586 dnl If UTF-8 support wasn't explicitly enabled or disabled, enable it only
3587 dnl for ports where it makes sense by default (GTK+, DirectFB):
3588 if test "$wxUSE_UNICODE" = "yes" -a "$wxUSE_UNICODE_UTF8" = "auto" ; then
3589     if test "$USE_UNIX" = 1 -a "$wxUSE_DARWIN" != 1 ; then
3590         wxUSE_UNICODE_UTF8=yes
3591     elif test "$USE_OS2" = 1 ; then
3592         dnl wide char support is quite incomplete in libc;
3593         dnl UTF-8 might actually work when evaluating/setting
3594         dnl code pages correctly, even for ports other than GTK20.
3595         wxUSE_UNICODE_UTF8=yes
3596     else
3597         wxUSE_UNICODE_UTF8=no
3598     fi
3599 fi
3600
3601 dnl ---------------------------------------------------------------------------
3602 dnl Optional libraries included when system library is not used
3603 dnl ---------------------------------------------------------------------------
3604
3605 dnl do this after test for X11 above so that we have a chance of finding Xlib.h
3606 if test "$wxUSE_GUI" = "yes"; then
3607     if test "$wxUSE_UNIX" = "yes" -a "$wxUSE_PM" != 1; then
3608         dnl defines HAVE_X11_XKBLIB_H
3609         AC_CHECK_HEADERS([X11/Xlib.h],,, [ ])
3610         AC_CHECK_HEADERS([X11/XKBlib.h],,,
3611                          [
3612                           #if HAVE_X11_XLIB_H
3613                             #include <X11/Xlib.h>
3614                           #endif
3615                          ])
3616     fi
3617 fi
3618
3619
3620 dnl ---------------------------------------------------------------------------
3621 dnl wxDisplay Sanity checks
3622 dnl ---------------------------------------------------------------------------
3623
3624 if test "$wxUSE_DISPLAY" = "yes"; then
3625 dnl ---------------------------------------------------------------------------
3626 dnl Xinerama (for unix ) - Brian Victor
3627 dnl ---------------------------------------------------------------------------
3628     if test "$wxUSE_UNIX" = "yes" -a "$wxUSE_MAC" != 1 -a "$wxUSE_COCOA" != 1; then
3629         AC_MSG_CHECKING([for Xinerama])
3630         WX_PATH_FIND_LIBRARIES([$SEARCH_LIB],Xinerama)
3631         if test "$ac_find_libraries" != "" ; then
3632             WX_LINK_PATH_EXIST([$ac_find_libraries],[$LDFLAGS])
3633             if test "$ac_path_to_link" != " -L/usr/lib" ; then
3634                 LDFLAGS="$LDFLAGS $ac_path_to_link"
3635             fi
3636             GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lXinerama"
3637             AC_MSG_RESULT([yes])
3638
3639             AC_MSG_CHECKING([for Xxf86vm extension])
3640             WX_PATH_FIND_LIBRARIES([$SEARCH_LIB],Xxf86vm)
3641             if test "$ac_find_libraries" != "" ; then
3642                 AC_MSG_RESULT([yes])
3643                 AC_CHECK_HEADERS([X11/extensions/xf86vmode.h],
3644                                  [
3645                                   GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lXxf86vm"
3646                                  ],
3647                                  [],
3648                                  [
3649                                       #if HAVE_X11_XLIB_H
3650                                         #include <X11/Xlib.h>
3651                                       #endif
3652                                  ])
3653             else
3654                 AC_MSG_RESULT([no])
3655             fi
3656
3657         else
3658             AC_MSG_RESULT([no])
3659             AC_MSG_WARN([Xinerama not found; disabling wxDisplay])
3660             wxUSE_DISPLAY="no"
3661         fi
3662     elif test "$wxUSE_MSW" = 1; then
3663 dnl ---------------------------------------------------------------------------
3664 dnl DirectDraw for MSW - optionally used by WxDisplay.
3665 dnl ---------------------------------------------------------------------------
3666         AC_CHECK_HEADER([ddraw.h], [], [], [#include <windows.h>])
3667     fi
3668 fi
3669
3670 dnl ---------------------------------------------------------------------------
3671 dnl X11 session management
3672 dnl ---------------------------------------------------------------------------
3673 if test "$wxUSE_DETECT_SM" = "yes"; then
3674     if test "$wxUSE_UNIX" = "yes" -a "$wxUSE_MAC" != 1 -a "$wxUSE_COCOA" != 1; then
3675         AC_MSG_CHECKING([for -lSM - X11 session management])
3676         WX_PATH_FIND_LIBRARIES([$SEARCH_LIB],SM)
3677         if test "$ac_find_libraries" != "" ; then
3678             WX_LINK_PATH_EXIST([$ac_find_libraries],[$LDFLAGS])
3679             if test "$ac_path_to_link" != " -L/usr/lib" ; then
3680                 LDFLAGS="$LDFLAGS $ac_path_to_link"
3681             fi
3682             GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lSM"
3683             AC_MSG_RESULT([yes])
3684         else
3685             AC_MSG_RESULT([no])
3686             AC_MSG_WARN([libSM not found; disabling session management detection])
3687             wxUSE_DETECT_SM="no"
3688         fi
3689     else
3690         wxUSE_DETECT_SM="no"
3691     fi
3692 fi
3693
3694
3695 dnl ---------------------------------------------------------------------------
3696 dnl OpenGL libraries
3697 dnl ---------------------------------------------------------------------------
3698
3699 USE_OPENGL=0
3700 if test "$wxUSE_OPENGL" = "yes" -o "$wxUSE_OPENGL" = "auto"; then
3701
3702     dnl look in glcanvas.h for the list of platforms supported by wxGlCanvas:
3703
3704     if test "$wxUSE_OSX_CARBON" = 1 -o "$wxUSE_OSX_COCOA" = 1 -o "$wxUSE_COCOA" = 1; then
3705         OPENGL_LIBS="-framework OpenGL -framework AGL"
3706     elif test "$wxUSE_MSW" = 1; then
3707         OPENGL_LIBS="-lopengl32 -lglu32"
3708     elif test "$wxUSE_MOTIF" = 1 -o "$wxUSE_X11" = 1 -o "$wxUSE_GTK2" = 1 -o "$wxUSE_GTK" = 1; then
3709
3710         dnl adjust CPPFLAGS to include GL/gl.h location if necessary
3711         dnl (/opt/graphics/OpenGL is for HP-UX systems, bug 925307)
3712         AC_MSG_CHECKING([for OpenGL headers])
3713         WX_PATH_FIND_INCLUDES([$SEARCH_INCLUDE /opt/graphics/OpenGL/include], GL/gl.h)
3714         if test "$ac_find_includes" != "" ; then
3715             AC_MSG_RESULT(found in $ac_find_includes)
3716             WX_INCLUDE_PATH_EXIST($ac_find_includes, $CPPFLAGS)
3717             CPPFLAGS="$ac_path_to_include $CPPFLAGS"
3718         else
3719             AC_MSG_RESULT([not found])
3720         fi
3721
3722         AC_CHECK_HEADER(GL/gl.h, [
3723             AC_CHECK_HEADER(GL/glu.h, [
3724                 found_gl=0
3725
3726                 AC_MSG_CHECKING([for -lGL])
3727                 WX_PATH_FIND_LIBRARIES([$SEARCH_LIB /opt/graphics/OpenGL/lib],GL)
3728                 if test "$ac_find_libraries" != "" ; then
3729                     AC_MSG_RESULT([found in $ac_find_libraries])
3730
3731                     WX_LINK_PATH_EXIST([$ac_find_libraries],[$LDFLAGS])
3732                     if test "$ac_path_to_link" != " -L/usr/lib" ; then
3733                         LDFLAGS_GL="$ac_path_to_link"
3734                     fi
3735
3736                     dnl don't suppose that libGL and libGLU are always in the
3737                     dnl same directory -- this is not true for some common
3738                     dnl distributions
3739                     AC_MSG_CHECKING([for -lGLU])
3740                     WX_PATH_FIND_LIBRARIES([$SEARCH_LIB],GLU)
3741                     if test "$ac_find_libraries" != "" ; then
3742                         WX_LINK_PATH_EXIST([$ac_find_libraries],[$LDFLAGS])
3743                         if test "$ac_path_to_link" != " -L/usr/lib" -a \
3744                                     "$ac_path_to_link" != "$LDFLAGS_GL"; then
3745                             LDFLAGS_GL="$LDFLAGS_GL$ac_path_to_link"
3746                         fi
3747
3748                         found_gl=1
3749                         OPENGL_LIBS="-lGL -lGLU"
3750                         AC_MSG_RESULT([yes])
3751                     else
3752                         AC_MSG_RESULT([no])
3753                     fi
3754                 else
3755                     AC_MSG_RESULT([no])
3756                 fi
3757
3758                 if test "$found_gl" != 1; then
3759                     AC_MSG_CHECKING([for -lMesaGL])
3760                     WX_PATH_FIND_LIBRARIES([$SEARCH_LIB],MesaGL)
3761                     if test "$ac_find_libraries" != "" ; then
3762                         WX_LINK_PATH_EXIST([$ac_find_libraries],[$LDFLAGS])
3763                         LDFLAGS_GL="$LDFLAGS$ac_path_to_link"
3764                         OPENGL_LIBS="-lMesaGL -lMesaGLU"
3765                         AC_MSG_RESULT([yes])
3766                     else
3767                         AC_MSG_RESULT([no])
3768                     fi
3769                 fi
3770             ],, [ ])
3771         ],
3772         [],
3773         [ ])
3774
3775         if test "x$OPENGL_LIBS" = "x"; then
3776             if test "$wxUSE_OPENGL" = "yes"; then
3777                 AC_MSG_ERROR([OpenGL libraries not available])
3778             else
3779                 dnl case wxUSE_OPENGL=auto
3780                 AC_MSG_WARN([OpenGL libraries not available, disabling support for OpenGL])
3781                 wxUSE_OPENGL=no
3782                 USE_OPENGL=0
3783             fi
3784         fi
3785     else
3786         AC_MSG_WARN([wxGLCanvas not implemented for this port, library will be compiled without it.])
3787         wxUSE_OPENGL="no"
3788     fi
3789
3790     if test "$wxUSE_OPENGL" = "auto"; then
3791         dnl if the OpenGL libraries were unavailable, this would have been
3792         dnl changed to "no" above, if it wasn't, change it to "yes" as we've
3793         dnl verified that we can indeed use OpenGL
3794         wxUSE_OPENGL=yes
3795     fi
3796
3797     if test "$wxUSE_OPENGL" = "yes"; then
3798         USE_OPENGL=1
3799         AC_DEFINE(wxUSE_OPENGL)
3800         AC_DEFINE(wxUSE_GLCANVAS)
3801         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS opengl opengl/cube opengl/penguin opengl/isosurf"
3802     fi
3803 fi
3804
3805
3806 dnl the symbol which allows conditional compilation for the given toolkit
3807 if test -n "$TOOLKIT" ; then
3808     TOOLCHAIN_DEFS="${TOOLCHAIN_DEFS} -D__WX${TOOLKIT}__"
3809 fi
3810
3811
3812 dnl --- the marker for quick search, leave it here: SHARED_LIB_SETUP ---
3813
3814 if test "$wxUSE_SHARED" = "yes"; then
3815     case "${host}" in
3816       *-pc-msdosdjgpp )
3817         dnl only static for now
3818         wxUSE_SHARED=no
3819         AC_MSG_WARN([Host system doesn't support shared libraries, disabling])
3820       ;;
3821     esac
3822 fi
3823
3824 if test "$wxUSE_SHARED" = "yes"; then
3825
3826     dnl use versioned symbols if available on the platform
3827     WX_VERSIONED_SYMBOLS([\$(wx_top_builddir)/version-script])
3828
3829     dnl test for GCC's visibility support (sets CFLAGS_VISIBILITY, which is
3830     dnl assigned to CFLAGS and CXXFLAGS below)
3831     if test "$wxUSE_VISIBILITY" != "no"; then
3832         WX_VISIBILITY
3833     fi
3834
3835     dnl test for Sun CC which can be used under both Solaris and Linux
3836     if test "x$SUNCXX" = xyes; then
3837         SAMPLES_RPATH_FLAG="-R\$(wx_top_builddir)/lib"
3838         WXCONFIG_RPATH="-R\$libdir"
3839     else
3840     case "${host}" in
3841       *-*-linux* | *-*-gnu* )
3842         SAMPLES_RPATH_FLAG="-Wl,-rpath,\$(wx_top_builddir)/lib"
3843         WXCONFIG_RPATH="-Wl,-rpath,\$libdir"
3844         ;;
3845
3846       *-*-solaris2* )
3847         dnl here we know that Sun CC is not used as we tested for it above,
3848         dnl hence we must be using gcc
3849
3850         dnl newer versions of gcc need -isystem to compile X headers on
3851         dnl Solaris (which use old style C syntax)
3852         CPPFLAGS="-isystem /usr/openwin/include $CPPFLAGS"
3853
3854         dnl gcc may use Sun's ld, in which case -rpath gives a confusing
3855         dnl error message. We have to try both -Wl,-rpath and -Wl,-R:
3856         saveLdflags="$LDFLAGS"
3857         LDFLAGS="$saveLdflags -Wl,-rpath,/"
3858         AC_MSG_CHECKING([if the linker accepts -rpath])
3859         AC_TRY_LINK(
3860             [],[],
3861             [
3862                 AC_MSG_RESULT([yes])
3863                 SAMPLES_RPATH_FLAG="-Wl,-rpath,\$(wx_top_builddir)/lib"
3864                 WXCONFIG_RPATH="-Wl,-rpath,\$libdir"
3865             ],[
3866                 AC_MSG_RESULT([no])
3867                 AC_MSG_CHECKING([if the linker accepts -R])
3868                 LDFLAGS="$saveLdflags -Wl,-R,/"
3869                 AC_TRY_LINK(
3870                     [],[],
3871                     [
3872                         AC_MSG_RESULT([yes])
3873                         SAMPLES_RPATH_FLAG="-Wl,-R,\$(wx_top_builddir)/lib"
3874                         WXCONFIG_RPATH="-Wl,-R,\$libdir"
3875                     ],[
3876                         AC_MSG_RESULT([no])
3877                     ])
3878             ])
3879         LDFLAGS="$saveLdflags"
3880       ;;
3881
3882       *-*-darwin* )
3883         install_name_tool=`which ${HOST_PREFIX}install_name_tool`
3884         if test "$install_name_tool" -a -x "$install_name_tool"; then
3885             DYLIB_RPATH_POSTLINK="${HOST_PREFIX}install_name_tool -id \$@ \$@"
3886             cat <<EOF >change-install-names
3887 #!/bin/sh
3888 libnames=\`cd \${1} ; ls -1 | grep '\.[[0-9]][[0-9]]*\.dylib\$'\`
3889 for i in \${libnames} ; do
3890     ${HOST_PREFIX}install_name_tool -id \${1}/\${i} \${1}/\${i}
3891     for dep in \${libnames} ; do
3892         ${HOST_PREFIX}install_name_tool -change \${2}/\${dep} \${1}/\${dep} \${1}/\${i}
3893     done
3894 done
3895 EOF
3896             chmod +x change-install-names
3897             DYLIB_RPATH_INSTALL="\$(wx_top_builddir)/change-install-names \${libdir} \$(wx_top_builddir)/lib"
3898         fi
3899
3900         dnl the HEADER_PAD_OPTION is required by some wx samples to avoid the error:
3901         dnl "install_name_tool: changing install names can't be redone for: the_exe_name
3902         dnl (for architecture ppc) because larger updated load commands do not fit
3903         dnl (the program must be relinked)"
3904         HEADER_PAD_OPTION="-headerpad_max_install_names"
3905       ;;
3906
3907       *-*-cygwin* | *-*-mingw32* )
3908         ;;
3909
3910       *-*-hpux* )
3911         SAMPLES_RPATH_FLAG="-Wl,+b,\$(wx_top_builddir)/lib"
3912         WXCONFIG_RPATH="-Wl,+b,\$libdir"
3913         ;;
3914
3915     esac
3916     fi
3917
3918     dnl this one shouldn't be used for the library build so put it in a
3919     dnl separate variable from WXCONFIG_CPPFLAGS
3920     WXCONFIG_ONLY_CPPFLAGS="$WXCONFIG_ONLY_CPPFLAGS -DWXUSINGDLL"
3921
3922     if test $wxUSE_RPATH = "no"; then
3923         SAMPLES_RPATH_FLAG=''
3924         DYLIB_PATH_POSTLINK=''
3925         WXCONFIG_RPATH=''
3926     fi
3927
3928     SHARED=1
3929
3930 else
3931
3932     config_linkage_component="-static"
3933     SHARED=0
3934
3935 fi
3936
3937
3938 UNICODE=0
3939 lib_unicode_suffix=
3940 WX_CHARTYPE="ansi"
3941 if test "$wxUSE_UNICODE" = "yes"; then
3942     lib_unicode_suffix=u
3943     WX_CHARTYPE="unicode"
3944     UNICODE=1
3945 fi
3946
3947 WX_FLAVOUR=${WX_FLAVOUR:+-$WX_FLAVOUR}
3948 WX_LIB_FLAVOUR=`echo $WX_FLAVOUR | tr '-' '_'`
3949
3950 DEBUG_INFO=0
3951 if test "$wxUSE_DEBUG_INFO" = "yes"; then
3952     DEBUG_INFO=1
3953 fi
3954
3955 WX_VERSION_TAG=`echo WX${lib_unicode_suffix}${WX_LIB_FLAVOUR}_${WX_RELEASE} | tr '[[a-z]]' '[[A-Z]]'`
3956
3957 TOOLCHAIN_NAME="${TOOLKIT_DIR}${TOOLKIT_VERSION}${WIDGET_SET}${lib_unicode_suffix}${WX_LIB_FLAVOUR}-${WX_RELEASE}${HOST_SUFFIX}"
3958
3959 TOOLCHAIN_FULLNAME="${HOST_PREFIX}${TOOLKIT_DIR}${TOOLKIT_VERSION}${WIDGET_SET}-${WX_CHARTYPE}${config_linkage_component}-${WX_RELEASE}${WX_FLAVOUR}"
3960
3961 dnl library link name
3962 dnl These just save us from exporting lib_{unicode,flavour}_suffix.
3963 dnl If we ever need to do that, we won't need to keep these.
3964
3965 if test "$wxUSE_OSX_CARBON" = 1 -o "$wxUSE_OSX_COCOA" = 1 -o "$wxUSE_COCOA" = 1; then
3966     WX_LIBRARY_BASENAME_NOGUI="wx_base${lib_unicode_suffix}${WX_LIB_FLAVOUR}"
3967 else
3968     WX_LIBRARY_BASENAME_NOGUI="wx_base${WXBASEPORT}${lib_unicode_suffix}${WX_LIB_FLAVOUR}"
3969 fi
3970 if test "${TOOLKIT_DIR}" = "os2"; then
3971     WX_LIBRARY_BASENAME_GUI="wx_pm${WIDGET_SET}${lib_unicode_suffix}${WX_LIB_FLAVOUR}"
3972 else
3973     WX_LIBRARY_BASENAME_GUI="wx_${TOOLKIT_DIR}${TOOLKIT_VERSION}${WIDGET_SET}${lib_unicode_suffix}${WX_LIB_FLAVOUR}"
3974 fi
3975
3976
3977
3978 if test "$wxUSE_COCOA" = 1; then
3979     AC_LANG_SAVE
3980     AC_WX_LANG_OBJECTIVEC
3981 dnl Recent AppKit/NSEvent.h include parts of IOKit which eventually
3982 dnl gets IOKit/graphics/IOGraphicsTypes.h included which typedefs
3983 dnl Point but only if MacTypes.h was not included first.  Of course,
3984 dnl if MacTypes.h is included later then you're screwed when it
3985 dnl tries to typedef Point.  Defining __Point__ will cause IOGraphicsTypes.h
3986 dnl to not typedef Point and thus fix the problem.
3987     AC_MSG_CHECKING([if AppKit/NSEvent.h conflicts with CoreFoundation])
3988     AC_TRY_COMPILE([#include <AppKit/NSEvent.h>
3989 #include <CoreFoundation/CoreFoundation.h>
3990         ],[],
3991         [AC_MSG_RESULT([no])],
3992         [AC_MSG_RESULT([yes])
3993         AC_MSG_CHECKING([if defining __Point__ will fix it])
3994         AC_TRY_COMPILE([#define __Point__ 1
3995 #include <AppKit/NSEvent.h>
3996 #include <CoreFoundation/CoreFoundation.h>
3997             ],[],
3998             [AC_MSG_RESULT([yes])
3999             AC_DEFINE(__Point__)
4000             ],
4001             [AC_MSG_FAILURE([no])]
4002         )]
4003     )
4004     AC_LANG_RESTORE
4005 fi
4006
4007 dnl ---------------------------------------------------------------------------
4008 dnl Checks for typedefs
4009 dnl ---------------------------------------------------------------------------
4010
4011 dnl   defines mode_t if not already defined
4012 AC_TYPE_MODE_T
4013 dnl   defines off_t if not already defined
4014 AC_TYPE_OFF_T
4015 dnl   defines pid_t if not already defined
4016 AC_TYPE_PID_T
4017 dnl   defines size_t if not already defined
4018 AC_TYPE_SIZE_T
4019
4020 dnl sets HAVE_SSIZE_T if ssize_t is defined
4021 AC_CHECK_TYPES(ssize_t)
4022
4023 dnl check what exactly size_t is on this machine - this is necessary to avoid
4024 dnl ambiguous overloads in several places, notably wx/string.h and wx/array.h
4025 AC_LANG_PUSH(C++) dnl tests below use overloaded functions and so need C++
4026 AC_CACHE_CHECK([if size_t is unsigned int],
4027     wx_cv_size_t_is_uint,
4028     [
4029     dnl an obvious check like AC_TRY_COMPILE[struct Foo { ... };] doesn't work
4030     dnl with egcs (at least) up to 1.1.1 as it allows you to compile duplicate
4031     dnl methods in a local class (i.e. class inside a function) declaration
4032     dnl without any objections!!
4033     dnl
4034     dnl hence the hack below: we must have Foo at global scope!
4035     AC_TRY_COMPILE([#include <stddef.h>],
4036         [
4037             return 0; }
4038
4039             struct Foo { void foo(size_t); void foo(unsigned int); };
4040
4041             int bar() {
4042         ],
4043         wx_cv_size_t_is_uint=no,
4044         wx_cv_size_t_is_uint=yes
4045     )
4046     ]
4047 )
4048
4049 if test "$wx_cv_size_t_is_uint" = "yes"; then
4050     AC_DEFINE(wxSIZE_T_IS_UINT)
4051 else
4052     AC_CACHE_CHECK([if size_t is unsigned long],
4053         wx_cv_size_t_is_ulong,
4054         AC_TRY_COMPILE([#include <stddef.h>],
4055             [
4056                 return 0; }
4057
4058                 struct Foo { void foo(size_t); void foo(unsigned long); };
4059
4060                 int bar() {
4061             ],
4062             wx_cv_size_t_is_ulong=no,
4063             wx_cv_size_t_is_ulong=yes
4064         )
4065     )
4066
4067     if test "$wx_cv_size_t_is_ulong" = "yes"; then
4068         AC_DEFINE(wxSIZE_T_IS_ULONG)
4069     fi
4070 fi
4071
4072 AC_CACHE_CHECK([if wchar_t is separate type],
4073     wx_cv_wchar_t_is_separate_type,
4074     AC_TRY_COMPILE([#include <wchar.h>],
4075         [
4076             return 0; }
4077
4078             struct Foo { void foo(wchar_t);
4079                          void foo(unsigned short);
4080                          void foo(unsigned int);
4081                          void foo(unsigned long); };
4082
4083             int bar() {
4084         ],
4085         wx_cv_wchar_t_is_separate_type=yes,
4086         wx_cv_wchar_t_is_separate_type=no
4087     )
4088 )
4089
4090 if test "$wx_cv_wchar_t_is_separate_type" = "yes"; then
4091     AC_DEFINE(wxWCHAR_T_IS_REAL_TYPE, 1)
4092 else
4093     AC_DEFINE(wxWCHAR_T_IS_REAL_TYPE, 0)
4094 fi
4095
4096 AC_LANG_POP() dnl C++
4097
4098 dnl ---------------------------------------------------------------------------
4099 dnl Checks for structures
4100 dnl ---------------------------------------------------------------------------
4101
4102 dnl does passwd struct has the pw_gecos field?
4103 AC_CACHE_CHECK([for pw_gecos in struct passwd], wx_cv_struct_pw_gecos,
4104     [
4105         AC_TRY_COMPILE([#include <pwd.h>],
4106              [
4107                 char *p;
4108                 struct passwd *pw;
4109                 p = pw->pw_gecos;
4110              ],
4111              [
4112                 wx_cv_struct_pw_gecos=yes
4113              ],
4114              [
4115                 wx_cv_struct_pw_gecos=no
4116              ]
4117         )
4118     ]
4119 )
4120
4121 if test "$wx_cv_struct_pw_gecos" = "yes"; then
4122     AC_DEFINE(HAVE_PW_GECOS)
4123 fi
4124
4125 dnl ---------------------------------------------------------------------------
4126 dnl Check for functions
4127 dnl ---------------------------------------------------------------------------
4128
4129 dnl don't check for wchar_t functions if we haven't got wchar_t itself
4130 if test "$wxUSE_WCHAR_T" = "yes"; then
4131     AC_DEFINE(wxUSE_WCHAR_T)
4132
4133     dnl check for wcslen in all possible places
4134     WCSLEN_FOUND=0
4135     WCHAR_LINK=
4136     AC_CHECK_FUNCS(wcslen, WCSLEN_FOUND=1)
4137
4138     if test "$WCSLEN_FOUND" = 0; then
4139         if test "$TOOLKIT" = "MSW"; then
4140             AC_CHECK_LIB(msvcrt, wcslen, WCHAR_OK=1)
4141         else
4142             AC_CHECK_LIB(w, wcslen, [
4143                             WCHAR_LINK=" -lw"
4144                             WCSLEN_FOUND=1
4145                         ])
4146         fi
4147     fi
4148
4149     if test "$WCSLEN_FOUND" = 1; then
4150         AC_DEFINE(HAVE_WCSLEN)
4151     fi
4152
4153     AC_CHECK_FUNCS([wcsdup strnlen wcsnlen wcscasecmp wcsncasecmp])
4154
4155     dnl On HP-UX aCC need this define to find mbstrtowcs() &c
4156     dnl Can't be used for g++ since the mbstate_t in wchar.h can conflict
4157     dnl with g++'s in <cwchar> (unless -D_INCLUDE__STDC_A1_SOURCE is in the
4158     dnl flags when g++ is configured, it will declare it's own).
4159     if test "$USE_HPUX" = 1 -a "$GCC" != "yes"; then
4160         CPPFLAGS="-D_INCLUDE__STDC_A1_SOURCE $CPPFLAGS"
4161     fi
4162
4163     dnl Try to use wcsrtombs instead of wcstombs which is buggy in old GNU
4164     dnl libc versions if possible. AC_CHECK_FUNCS only checks it's in the
4165     dnl library, not the header, so do a header check for mbstate_t first.
4166     AC_CHECK_TYPES([mbstate_t],
4167                    [AC_CHECK_FUNCS(wcsrtombs)],
4168                    [],
4169                    [#include <wchar.h>])
4170 else
4171     AC_MSG_WARN([Wide character support is unavailable])
4172 fi
4173
4174 dnl check for vsnprintf() -- a safe version of vsprintf())
4175 dnl
4176 dnl the trouble here is that on some systems (e.g HP-UX 10) this function is
4177 dnl present in libc but not in the system headers and so AC_CHECK_FUNCS (which,
4178 dnl stupidly, provides a dummy function declaration inside its extension)
4179 dnl succeeds, even with C++ compiler, but the compilation of wxWidgets fails
4180 dnl
4181 dnl so we first check if the function is in the library
4182 dnl
4183 dnl FIXME: replace this mess with WX_CHECK_FUNCS()
4184 AC_CHECK_FUNCS(snprintf vsnprintf vsscanf)
4185
4186 AC_LANG_PUSH(C++)
4187 if test "$ac_cv_func_vsnprintf" = "yes"; then
4188     dnl yes it is -- now check if it is in the headers
4189     AC_CACHE_CHECK([for vsnprintf declaration], wx_cv_func_vsnprintf_decl,
4190         [
4191             dnl our troubles are not over: HP-UX 11 prototypes vsnprintf() as
4192             dnl taking "char *" and not "const char *" while Metrowerks does
4193             dnl provide a correct vsnprintf declaration but in C++ mode it's
4194             dnl always in std namespace and so we have to bring it in scope
4195             AC_TRY_COMPILE(
4196                 [
4197                     #include <stdio.h>
4198                     #include <stdarg.h>
4199                     #ifdef __MSL__
4200                     #if __MSL__ >= 0x6000
4201                     namespace std {}
4202                     using namespace std;
4203                     #endif
4204                     #endif
4205                 ],
4206                 [
4207                     char *buf;
4208                     va_list ap;
4209                     vsnprintf(buf, 10u, "%s", ap);
4210                 ],
4211                 wx_cv_func_vsnprintf_decl=yes,
4212                 wx_cv_func_vsnprintf_decl=no
4213             )
4214         ]
4215     )
4216
4217     if test "$wx_cv_func_vsnprintf_decl" = "yes"; then
4218         AC_DEFINE(HAVE_VSNPRINTF_DECL)
4219
4220         dnl we know there is a vsnprintf declaration, but some old headers
4221         dnl may have one taking a "char *" format instead of "const char *"
4222         AC_CACHE_CHECK([if vsnprintf declaration is broken], wx_cv_func_broken_vsnprintf_decl,
4223             [
4224                 AC_TRY_COMPILE(
4225                     [
4226                         #include <stdio.h>
4227                         #include <stdarg.h>
4228                         #ifdef __MSL__
4229                         #if __MSL__ >= 0x6000
4230                         namespace std {}
4231                         using namespace std;
4232                         #endif
4233                         #endif
4234                     ],
4235                     [
4236                         char *buf;
4237                         va_list ap;
4238                         const char *fmt = "%s";
4239                         vsnprintf(buf, 10u, fmt, ap);
4240                     ],
4241                     wx_cv_func_broken_vsnprintf_decl=no,
4242                     wx_cv_func_broken_vsnprintf_decl=yes
4243                 )
4244             ]
4245         )
4246
4247         if test "$wx_cv_func_broken_vsnprintf_decl" = "yes"; then
4248             AC_DEFINE(HAVE_BROKEN_VSNPRINTF_DECL)
4249         fi
4250     fi
4251 fi
4252
4253 dnl the same as above but for snprintf() now: it's not present in at least AIX
4254 dnl 4.2 headers
4255 if test "$ac_cv_func_snprintf" = "yes"; then
4256     AC_CACHE_CHECK([for snprintf declaration], wx_cv_func_snprintf_decl,
4257         [
4258             AC_TRY_COMPILE(
4259                 [
4260                     #include <stdio.h>
4261                     #include <stdarg.h>
4262                     #ifdef __MSL__
4263                     #if __MSL__ >= 0x6000
4264                     namespace std {}
4265                     using namespace std;
4266                     #endif
4267                     #endif
4268                 ],
4269                 [
4270                     char *buf;
4271                     snprintf(buf, 10u, "%s", "wx");
4272                 ],
4273                 wx_cv_func_snprintf_decl=yes,
4274                 wx_cv_func_snprintf_decl=no
4275             )
4276         ]
4277     )
4278
4279     if test "$wx_cv_func_snprintf_decl" = "yes"; then
4280         AC_DEFINE(HAVE_SNPRINTF_DECL)
4281     fi
4282
4283     if test "$wxUSE_PRINTF_POS_PARAMS" = "yes"; then
4284
4285         dnl check if snprintf() has support for positional arguments
4286         dnl NB: if snprintf() has positional support we can safely suppose that also
4287         dnl     other *printf() functions support them as they all belong to the same
4288         dnl     family and they all fallback to the same implementation
4289         AC_CACHE_CHECK([if snprintf supports positional arguments], wx_cv_func_snprintf_pos_params,
4290             [
4291                 AC_TRY_RUN(
4292                     [
4293                         #include <stdio.h>
4294
4295                         int main (void)
4296                         {
4297                             char buffer[128];
4298                             snprintf (buffer, 128, "%2$d %3$d %1$d", 1, 2, 3);
4299                             if (strcmp ("2 3 1", buffer) == 0)
4300                                 exit (0);
4301                             exit (1);
4302                         }
4303                     ],
4304                     wx_cv_func_snprintf_pos_params=no,
4305                     wx_cv_func_snprintf_pos_params=yes,
4306                     dnl be pessimistic when cross-compiling
4307                     [
4308                         AC_MSG_WARN([Assuming Unix98 printf() is not available,
4309 define HAVE_UNIX98_PRINTF as 1 in setup.h if it is available.])
4310                         wx_cv_func_snprintf_pos_params=no
4311                     ]
4312                 )
4313             ]
4314         )
4315
4316         if test "$wx_cv_func_snprintf_pos_params" = "yes"; then
4317             AC_DEFINE(HAVE_UNIX98_PRINTF)
4318         fi
4319     fi
4320 fi
4321
4322 dnl the same as above but for vsscanf() now: it's not present in at least
4323 dnl Solaris 9 headers for gcc-3.4 (due to fixinclude's processing of stdio.h)
4324 if test "$ac_cv_func_vsscanf" = "yes"; then
4325     AC_CACHE_CHECK([for vsscanf declaration], wx_cv_func_vsscanf_decl,
4326         [
4327             AC_TRY_COMPILE(
4328                 [
4329                     #include <stdio.h>
4330                     #include <stdarg.h>
4331                     #ifdef __MSL__
4332                     #if __MSL__ >= 0x6000
4333                     namespace std {}
4334                     using namespace std;
4335                     #endif
4336                     #endif
4337                 ],
4338                 [
4339                     char *buf;
4340                     va_list args;
4341                     vsscanf(buf, "%s", args);
4342                 ],
4343                 wx_cv_func_vsscanf_decl=yes,
4344                 wx_cv_func_vsscanf_decl=no
4345             )
4346         ]
4347     )
4348
4349     if test "$wx_cv_func_vsscanf_decl" = "yes"; then
4350         AC_DEFINE(HAVE_VSSCANF_DECL)
4351     fi
4352 fi
4353 AC_LANG_POP()
4354
4355 if test "$wxUSE_UNICODE" = yes; then
4356
4357     dnl also look if we have wide char IO functions, notice that [f]putws are
4358     dnl declared in special widec.h under Solaris
4359     wchar_headers="#include <stdio.h>
4360 #include <wchar.h>"
4361     case "${host}" in
4362         *-*-solaris2* )
4363             AC_CHECK_HEADERS(widec.h,,, [AC_INCLUDES_DEFAULT()])
4364             if test "$ac_cv_header_widec_h" = "yes"; then
4365                 wchar_headers="$wchar_headers
4366 #include <widec.h>"
4367             fi
4368     esac
4369
4370     WX_CHECK_FUNCS(putws fputws wprintf vswprintf vswscanf,,,
4371                    [$wchar_headers])
4372
4373     dnl MinGW has a vswprintf with a different prototype, and
4374     dnl a _vsnwprintf with the correct prototype, but AC_CHECK_FUNCS
4375     dnl finds it even if it is not declared in some versions...
4376     AC_MSG_CHECKING([for _vsnwprintf])
4377     AC_TRY_COMPILE([#include <wchar.h>],
4378                    [&_vsnwprintf;],
4379                    [AC_MSG_RESULT([yes])
4380                     AC_DEFINE(HAVE__VSNWPRINTF)],
4381                    [AC_MSG_RESULT([no])]);
4382 fi
4383
4384 if test "$wxUSE_FILE" = "yes"; then
4385     WX_CHECK_FUNCS(fsync)
4386 fi
4387
4388 dnl at least under IRIX with mipsPro the C99 round() function is available when
4389 dnl building using the C compiler but not when using C++ one
4390 AC_LANG_PUSH(C++)
4391 WX_CHECK_FUNCS(round,,,[#include <math.h>])
4392 AC_LANG_POP()
4393
4394 dnl the following tests are for Unix(like) systems only
4395 if test "$TOOLKIT" != "MSW"; then
4396
4397 dnl check for available version of iconv()
4398 if test "$wxUSE_LIBICONV" != "no" ; then
4399     AM_ICONV
4400     LIBS="$LIBICONV $LIBS"
4401 fi
4402
4403 dnl check for POSIX signals if we need them
4404 if test "$wxUSE_ON_FATAL_EXCEPTION" = "yes" -a "$wxUSE_UNIX" = "yes"; then
4405     AC_CHECK_FUNCS(sigaction)
4406
4407     if test "$ac_cv_func_sigaction" = "no"; then
4408         AC_MSG_WARN([No POSIX signal functions on this system, wxApp::OnFatalException will not be called])
4409         wxUSE_ON_FATAL_EXCEPTION=no
4410     fi
4411
4412     if test "$wxUSE_ON_FATAL_EXCEPTION" = "yes"; then
4413       AC_CACHE_CHECK([for sa_handler type], wx_cv_type_sa_handler,
4414       [
4415         dnl C compiler happily compiles the code even if there is type mismatch
4416         AC_LANG_PUSH(C++)
4417         AC_TRY_COMPILE([#include <signal.h>],
4418                      [
4419                         extern void testSigHandler(int);
4420
4421                         struct sigaction sa;
4422                         sa.sa_handler = testSigHandler;
4423                      ], [
4424                         wx_cv_type_sa_handler=int
4425                      ], [
4426                         wx_cv_type_sa_handler=void
4427                      ])
4428         AC_LANG_POP()
4429       ])
4430
4431       AC_DEFINE_UNQUOTED(wxTYPE_SA_HANDLER, $wx_cv_type_sa_handler)
4432     fi
4433 fi
4434
4435 dnl backtrace() and backtrace_symbols() for wxStackWalker
4436 if test "$wxUSE_STACKWALKER" = "yes" -a "$wxUSE_UNIX" = "yes"; then
4437     AC_CACHE_CHECK([for backtrace() in <execinfo.h>], wx_cv_func_backtrace,
4438         [
4439             AC_LANG_PUSH(C++)
4440             AC_TRY_COMPILE([#include <execinfo.h>],
4441                 [
4442                     void *trace[1];
4443                     char **messages;
4444
4445                     backtrace(trace, 1);
4446                     messages = backtrace_symbols(trace, 1);
4447                 ],
4448                 wx_cv_func_backtrace=yes,
4449                 wx_cv_func_backtrace=no
4450             )
4451             AC_LANG_POP()
4452         ]
4453     )
4454
4455
4456     if test "$wx_cv_func_backtrace" = "no"; then
4457         AC_MSG_WARN([backtrace() is not available, wxStackWalker will not be available])
4458         wxUSE_STACKWALKER=no
4459     else
4460         AC_CACHE_CHECK([for __cxa_demangle() in <cxxabi.h>], wx_cv_func_cxa_demangle,
4461             [
4462                 AC_LANG_PUSH(C++)
4463                 AC_TRY_LINK([#include <cxxabi.h>],
4464                     [
4465                         int rc;
4466                         __cxxabiv1::__cxa_demangle("foo", 0, 0, &rc);
4467                     ],
4468                     wx_cv_func_cxa_demangle=yes,
4469                     wx_cv_func_cxa_demangle=no
4470                 )
4471                 AC_LANG_POP()
4472             ]
4473         )
4474
4475         if test "$wx_cv_func_cxa_demangle" = "yes"; then
4476             AC_DEFINE(HAVE_CXA_DEMANGLE)
4477         fi
4478     fi
4479 fi
4480
4481 if test "$wxUSE_STACKWALKER" = "yes" -a "$USE_WIN32" != 1 -a "$USE_UNIX" != 1; then
4482     AC_MSG_WARN([wxStackWalker is only available on Win32 and UNIX... disabled])
4483     wxUSE_STACKWALKER=no
4484 fi
4485
4486
4487 dnl check for the function for temp files creation
4488 AC_CHECK_FUNCS(mkstemp mktemp, break)
4489
4490 dnl get the library function to use for wxGetDiskSpace(): it is statfs() under
4491 dnl Linux and *BSD and statvfs() under Solaris
4492 AC_CACHE_CHECK(for statfs, wx_cv_func_statfs,
4493     AC_TRY_COMPILE(
4494         [
4495              #if defined(__BSD__)
4496              #include <sys/param.h>
4497              #include <sys/mount.h>
4498              #else
4499              #include <sys/vfs.h>
4500              #endif
4501         ],
4502         [
4503              long l;
4504              struct statfs fs;
4505              statfs("/", &fs);
4506              l = fs.f_bsize;
4507              l += fs.f_blocks;
4508              l += fs.f_bavail;
4509         ],
4510          wx_cv_func_statfs=yes,
4511          wx_cv_func_statfs=no
4512     )
4513 )
4514
4515 if test "$wx_cv_func_statfs" = "yes"; then
4516     dnl check whether we have its dcelaration too: some systems (AIX 4) lack it
4517     AC_CACHE_CHECK(for statfs declaration, wx_cv_func_statfs_decl,
4518         AC_LANG_PUSH(C++)
4519         AC_TRY_COMPILE(
4520             [
4521                  #if defined(__BSD__)
4522                  #include <sys/param.h>
4523                  #include <sys/mount.h>
4524                  #else
4525                  #include <sys/vfs.h>
4526                  #endif
4527             ],
4528             [
4529                 struct statfs fs;
4530                 statfs("", &fs);
4531             ],
4532             wx_cv_func_statfs_decl=yes,
4533             wx_cv_func_statfs_decl=no
4534         )
4535         AC_LANG_POP()
4536     )
4537
4538     if test "$wx_cv_func_statfs_decl" = "yes"; then
4539         AC_DEFINE(HAVE_STATFS_DECL)
4540     fi
4541
4542     wx_cv_type_statvfs_t="struct statfs"
4543     AC_DEFINE(HAVE_STATFS)
4544 else
4545     AC_CACHE_CHECK(for statvfs, wx_cv_func_statvfs,
4546         AC_TRY_COMPILE(
4547             [
4548                 #include <stddef.h>
4549                 #include <sys/statvfs.h>
4550             ],
4551             [
4552                 statvfs("/", NULL);
4553             ],
4554             wx_cv_func_statvfs=yes,
4555             wx_cv_func_statvfs=no
4556         )
4557     )
4558
4559     if test "$wx_cv_func_statvfs" = "yes"; then
4560         dnl we also have to check whether we should use statvfs_t (works under
4561         dnl Solaris 8, doesn't work under Solaris 7) or "struct statvfs" (vice
4562         dnl versa) as the argument for statvfs in 64 bit off_t mode (in 32 bit
4563         dnl mode both work fine)
4564         dnl
4565         dnl for this check C++ compiler has to be used as passing incompatible
4566         dnl pointers is just a warning and not an error in C
4567         AC_CACHE_CHECK(for statvfs argument type, wx_cv_type_statvfs_t,
4568             AC_LANG_PUSH(C++)
4569             AC_TRY_COMPILE(
4570                 [
4571                     #include <sys/statvfs.h>
4572                 ],
4573                 [
4574                     long l;
4575                     statvfs_t fs;
4576                     statvfs("/", &fs);
4577                     l = fs.f_bsize;
4578                     l += fs.f_blocks;
4579                     l += fs.f_bavail;
4580                 ],
4581                 wx_cv_type_statvfs_t=statvfs_t,
4582                 [
4583                     AC_TRY_COMPILE(
4584                         [
4585                             #include <sys/statvfs.h>
4586                         ],
4587                         [
4588                             long l;
4589                             struct statvfs fs;
4590                             statvfs("/", &fs);
4591                             l = fs.f_bsize;
4592                             l += fs.f_blocks;
4593                             l += fs.f_bavail;
4594                         ],
4595                         wx_cv_type_statvfs_t="struct statvfs",
4596                         wx_cv_type_statvfs_t="unknown"
4597                     )
4598                 ]
4599             )
4600             AC_LANG_POP()
4601         )
4602
4603         if test "$wx_cv_type_statvfs_t" != "unknown"; then
4604             AC_DEFINE(HAVE_STATVFS)
4605         fi
4606     else
4607         dnl set it for the test below
4608         wx_cv_type_statvfs_t="unknown"
4609     fi
4610 fi
4611
4612 if test "$wx_cv_type_statvfs_t" != "unknown"; then
4613     AC_DEFINE_UNQUOTED(WX_STATFS_T, $wx_cv_type_statvfs_t)
4614 else
4615     AC_MSG_WARN([wxGetDiskSpace() function won't work without statfs()])
4616 fi
4617
4618 dnl check for fcntl() or at least flock() needed by Unix implementation of
4619 dnl wxSingleInstanceChecker
4620 if test "$wxUSE_SNGLINST_CHECKER" = "yes"; then
4621     AC_CHECK_FUNCS(fcntl flock, break)
4622
4623     if test "$ac_cv_func_fcntl" != "yes" -a "$ac_cv_func_flock" != "yes"; then
4624         AC_MSG_WARN(wxSingleInstanceChecker not available)
4625         wxUSE_SNGLINST_CHECKER=no
4626     fi
4627 fi
4628
4629 dnl look for a function to modify the environment
4630 AC_CHECK_FUNCS(setenv putenv, break)
4631 if test "$ac_cv_func_setenv" = "yes"; then
4632     AC_CHECK_FUNCS(unsetenv)
4633 fi
4634
4635 HAVE_SOME_SLEEP_FUNC=0
4636 if test "$USE_BEOS" = 1; then
4637     dnl BeOS has its own (wonder where did they get it from) sleep() function
4638     dnl in unistd.h
4639     AC_DEFINE(HAVE_SLEEP)
4640     HAVE_SOME_SLEEP_FUNC=1
4641 fi
4642
4643 if test "$USE_DARWIN" = 1; then
4644     dnl Mac OS X/Darwin has both nanosleep and usleep
4645     dnl but only usleep is defined in unistd.h
4646     AC_DEFINE(HAVE_USLEEP)
4647     HAVE_SOME_SLEEP_FUNC=1
4648 fi
4649
4650 if test "$HAVE_SOME_SLEEP_FUNC" != 1; then
4651     dnl try nanosleep() in libc and libposix4, if this fails - usleep()
4652     POSIX4_LINK=
4653     AC_CHECK_FUNCS(nanosleep,
4654         AC_DEFINE(HAVE_NANOSLEEP),
4655         [
4656             AC_CHECK_LIB(posix4, nanosleep,
4657                 [
4658                     AC_DEFINE(HAVE_NANOSLEEP)
4659                     POSIX4_LINK=" -lposix4"
4660                 ],
4661                 [
4662                     WX_CHECK_FUNCS(usleep,,
4663                                     AC_MSG_WARN([wxSleep() function will not work])
4664                     )
4665                 ]
4666             )
4667         ]
4668     )
4669 fi
4670
4671 dnl check for uname (POSIX) and gethostname (BSD)
4672 WX_CHECK_FUNCS(uname,,,[#include <sys/utsname.h>])
4673 if test "$wx_cv_func_uname" != yes; then
4674     WX_CHECK_FUNCS(gethostname)
4675 fi
4676
4677 WX_CHECK_FUNCS(strtok_r, [], [], [#define _REENTRANT])
4678
4679 dnl check for inet_addr and inet_aton (these may live either in libc, or in
4680 dnl libnsl or libresolv or libsocket)
4681 INET_LINK=
4682 AC_CHECK_FUNCS(inet_addr,
4683     AC_DEFINE(HAVE_INET_ADDR),
4684     [
4685         AC_CHECK_LIB(nsl, inet_addr,
4686             INET_LINK="nsl",
4687             [
4688                 AC_CHECK_LIB(resolv, inet_addr,
4689                     INET_LINK="resolv",
4690                     [
4691                         AC_CHECK_LIB(socket, inet_addr,
4692                             INET_LINK="socket"
4693                         )
4694                     ]
4695                 )
4696             ]
4697         )
4698     ]
4699 )
4700
4701 AC_CHECK_FUNCS(inet_aton,
4702         AC_DEFINE(HAVE_INET_ATON),
4703         [
4704             dnl only check it in the same lib
4705             AC_CHECK_LIB($INET_LINK, inet_aton, AC_DEFINE(HAVE_INET_ATON))
4706         ])
4707
4708 if test "x$INET_LINK" != "x"; then
4709     AC_DEFINE(HAVE_INET_ADDR)
4710     INET_LINK=" -l$INET_LINK"
4711 fi
4712
4713 WX_CHECK_FUNCS(fdopen)
4714
4715 if test "$wxUSE_TARSTREAM" = "yes"; then
4716     WX_CHECK_FUNCS(sysconf)
4717
4718     WX_CHECK_FUNCS(getpwuid_r, [], [],
4719                    [
4720                     #define _REENTRANT
4721                     #include <pwd.h>
4722                    ],
4723                    [[
4724                     struct passwd pw, *ppw;
4725                     char buf[1024];
4726                     getpwuid_r(0, &pw, buf, sizeof(buf), &ppw)
4727                    ]])
4728
4729     WX_CHECK_FUNCS(getgrgid_r, [], [],
4730                    [
4731                     #define _REENTRANT
4732                     #include <grp.h>
4733                    ],
4734                    [[
4735                     struct group grp, *pgrp;
4736                     char buf[1024];
4737                     getgrgid_r(0, &grp, buf, sizeof(buf), &pgrp)
4738                    ]])
4739 fi
4740
4741 fi
4742
4743
4744 dnl ===========================================================================
4745 dnl Now we have all the info we need - use it!
4746 dnl ===========================================================================
4747
4748 dnl flush the cache
4749 AC_CACHE_SAVE
4750
4751 dnl ---------------------------------------------------------------------------
4752 dnl thread support for Unix (for Win32 and OS/2 see past
4753 dnl                          the next matching "else")
4754 dnl ---------------------------------------------------------------------------
4755
4756 dnl under MSW (except mingw32) we always have thread support
4757 if test "$TOOLKIT" != "MSW" -a "$USE_OS2" != 1; then
4758
4759     dnl the code below:
4760     dnl
4761     dnl   defines THREADS_LINK and THREADS_CFLAGS which are the options
4762     dnl   necessary to build the MT programs for the linker and compiler
4763     dnl   respectively
4764     dnl
4765     dnl   sets wxUSE_THREADS=1 if thread support is activated
4766
4767     THREADS_LINK=
4768     THREADS_CFLAGS=
4769
4770     if test "$wxUSE_THREADS" = "yes" ; then
4771         if test "$USE_BEOS" = 1; then
4772             AC_MSG_WARN([BeOS threads are not yet supported... disabled])
4773             wxUSE_THREADS="no"
4774         fi
4775     fi
4776
4777     if test "$wxUSE_THREADS" = "yes" ; then
4778         dnl find if POSIX threads are available
4779         dnl
4780         dnl the tests here are based on ACX_PTHREAD macro from autoconf macro
4781         dnl archive from http://ac-archive.sourceforge.net/
4782         dnl
4783         dnl thanks to Steven G. Johnson <stevenj@alum.mit.edu> and Alejandro
4784         dnl Forero Cuervo <bachue@bachue.com> for the original code
4785
4786         dnl TODO: cache the result
4787
4788         dnl define the list of the thread options to try in the loop below
4789         dnl with the convention that anything starting with '-' is a cpp flag
4790         dnl while anything else is a library (i.e. there is an implicit "-l")
4791         THREAD_OPTS="-pthread"
4792         if test "x$SUNCXX" = xyes; then
4793             THREAD_OPTS="-mt lthread $THREAD_OPTS"
4794         fi
4795
4796         case "${host}" in
4797           *-*-solaris2* | *-*-sunos4* )
4798                 if test "x$GCC" = "xyes"; then
4799                     dnl Solaris/gcc combination use this one for some reason
4800                     THREAD_OPTS="-pthreads $THREAD_OPTS"
4801                 fi
4802                 ;;
4803           *-*-freebsd*)
4804                 dnl look, in order, for the kernel threads, then Linux threads
4805                 dnl and finally the userland threads
4806                 THREAD_OPTS="-kthread lthread $THREAD_OPTS c_r"
4807                 ;;
4808           *-*-darwin* | *-*-cygwin* )
4809                 dnl Darwin / Mac OS X just uses -lpthread tested below
4810                 dnl and so does Cygwin
4811                 THREAD_OPTS=""
4812                 ;;
4813           *-*-aix*)
4814                 dnl AIX calls the library libpthreads - thanks IBM!
4815                 THREAD_OPTS="pthreads"
4816                 ;;
4817           *-hp-hpux* )
4818                 if test "x$GCC" = "xyes"; then
4819                     dnl g++ versions before 3.3.2 don't support -pthread.
4820                     $CXX -dumpspecs | grep 'pthread:' >/dev/null ||
4821                         THREAD_OPTS=""
4822                 else
4823                     dnl HP-UX aCC (tested with version B3910B A.06.05 [Jul 25
4824                     dnl 2005]) supports -mt
4825                     THREAD_OPTS="-mt"
4826                 fi
4827                 ;;
4828
4829           *-*-irix* )
4830                 dnl gcc under IRIX doesn't seem to like -pthread, but it
4831                 dnl doesn't give an error for it neither, just a warning
4832                 dnl message -- but this is still very annoying
4833                 if test "x$GCC" = "xyes"; then
4834                     THREAD_OPTS=""
4835                 fi
4836                 ;;
4837
4838           *-*-*UnixWare*)
4839                 dnl flying by man pages here: Caldera online docs use this
4840                 if test "x$GCC" != "xyes"; then
4841                     THREAD_OPTS="-Ethread"
4842                 fi
4843                 ;;
4844         esac
4845
4846         dnl simply linking with libpthread should make the test below work but
4847         dnl it's far from certain that the threaded programs compiled without
4848         dnl any special switches actually work, so try it after all the others
4849         THREAD_OPTS="$THREAD_OPTS pthread none"
4850
4851         dnl now test for all possibilities
4852         THREADS_OK=no
4853         for flag in $THREAD_OPTS; do
4854             case $flag in
4855                 none)
4856                     AC_MSG_CHECKING([whether pthreads work without any flags])
4857                     ;;
4858
4859                 -*)
4860                     AC_MSG_CHECKING([whether pthreads work with $flag])
4861                     THREADS_CFLAGS="$flag"
4862                     ;;
4863
4864                 *)
4865                     AC_MSG_CHECKING([for the pthreads library -l$flag])
4866                     THREADS_LINK="-l$flag"
4867                     ;;
4868               esac
4869
4870               save_LIBS="$LIBS"
4871               save_CFLAGS="$CFLAGS"
4872               LIBS="$THREADS_LINK $LIBS"
4873               CFLAGS="$THREADS_CFLAGS $CFLAGS"
4874
4875               AC_TRY_LINK([#include <pthread.h>],
4876                           [pthread_create(0,0,0,0);],
4877                           THREADS_OK=yes)
4878
4879               LIBS="$save_LIBS"
4880               CFLAGS="$save_CFLAGS"
4881
4882               AC_MSG_RESULT($THREADS_OK)
4883               if test "x$THREADS_OK" = "xyes"; then
4884                       break;
4885               fi
4886
4887               THREADS_LINK=""
4888               THREADS_CFLAGS=""
4889       done
4890
4891       if test "x$THREADS_OK" != "xyes"; then
4892           wxUSE_THREADS=no
4893           AC_MSG_WARN([No thread support on this system... disabled])
4894       else
4895           dnl yes, these special compiler flags should be used with the
4896           dnl linker as well
4897           LDFLAGS="$THREADS_CFLAGS $LDFLAGS"
4898           LIBS="$THREADS_LINK $LIBS"
4899
4900           AC_MSG_CHECKING([if more special flags are required for pthreads])
4901           flag=no
4902           case "${host}" in
4903             *-aix*)
4904                 dnl again quoting from
4905                 dnl http://www-1.ibm.com/servers/esdd/articles/gnu.html:
4906                 dnl
4907                 dnl     When compiling and linking with -pthread, the library
4908                 dnl     search path should include -L/usr/lib/threads at the
4909                 dnl     beginning of the path.
4910                 LDFLAGS="-L/usr/lib/threads $LDFLAGS"
4911                 flag="-D_THREAD_SAFE"
4912                 ;;
4913             *-freebsd*)
4914                 flag="-D_THREAD_SAFE"
4915                 ;;
4916             *-hp-hpux* )
4917                 flag="-D_REENTRANT"
4918                 if test "x$GCC" != "xyes"; then
4919                     dnl see http://docs.hp.com/hpux/onlinedocs/2213/threads.htm
4920                     flag="$flag -D_RWSTD_MULTI_THREAD"
4921                 fi
4922                 ;;
4923             *solaris* | alpha*-osf*)
4924                 flag="-D_REENTRANT"
4925                 ;;
4926           esac
4927           AC_MSG_RESULT(${flag})
4928           if test "x$flag" != xno; then
4929               THREADS_CFLAGS="$THREADS_CFLAGS $flag"
4930           fi
4931
4932           dnl don't add these options to CPPFLAGS as cpp might not know them
4933           WXCONFIG_CFLAGS="$WXCONFIG_CFLAGS $THREADS_CFLAGS"
4934       fi
4935     fi
4936
4937     dnl do other tests only if we are using threads
4938     if test "$wxUSE_THREADS" = "yes" ; then
4939       AC_CHECK_FUNCS(thr_setconcurrency)
4940
4941       dnl can't use AC_CHECK_FUNCS for this one as it's usually a macro and so
4942       dnl wouldn't be found by it
4943       AC_CACHE_CHECK([for pthread_cleanup_push/pop], wx_cv_func_pthread_cleanup,
4944       [
4945         dnl C compiler may treat pthread_cleanup_push() as an undeclared
4946         dnl function and not give a warning even if it's unavailable, so use
4947         dnl the C++ one for this test
4948         AC_LANG_PUSH(C++)
4949         AC_TRY_COMPILE([#include <pthread.h>
4950                void ThreadCleanupFunc(void *p);
4951             ],
4952             [
4953                 void *p;
4954                 pthread_cleanup_push(ThreadCleanupFunc, p);
4955                 pthread_cleanup_pop(0);
4956             ], [
4957                wx_cv_func_pthread_cleanup=yes
4958             ], [
4959                wx_cv_func_pthread_cleanup=no
4960             ]
4961         )
4962         AC_LANG_POP()
4963       ])
4964       if test "x$wx_cv_func_pthread_cleanup" = "xyes"; then
4965         AC_DEFINE(wxHAVE_PTHREAD_CLEANUP)
4966       fi
4967
4968       AC_CHECK_HEADERS(sched.h,,, [AC_INCLUDES_DEFAULT()])
4969       if test "$ac_cv_header_sched_h" = "yes"; then
4970           AC_CHECK_FUNC(sched_yield,
4971             AC_DEFINE(HAVE_SCHED_YIELD),
4972             [
4973                 AC_CHECK_LIB(posix4,
4974                     sched_yield,
4975                     [AC_DEFINE(HAVE_SCHED_YIELD) POSIX4_LINK=" -lposix4"],
4976                     AC_MSG_WARN(wxThread::Yield will not work properly)
4977                 )
4978             ]
4979           )
4980       fi
4981
4982       dnl to be able to set the thread priority, we need to have all of the
4983       dnl following functions:
4984       dnl   1. pthread_attr_getschedpolicy
4985       dnl   2. sched_get_priority_min and sched_get_priority_max
4986       dnl      (this one can be in either libpthread or libposix4 (under Solaris))
4987       dnl   3. pthread_attr_getschedparam and pthread_attr_setschedparam
4988       HAVE_PRIOR_FUNCS=0
4989       AC_CHECK_FUNC(pthread_attr_getschedpolicy,
4990                      [AC_CHECK_FUNC(pthread_attr_setschedparam,
4991                        [AC_CHECK_FUNC(sched_get_priority_max,
4992                            HAVE_PRIOR_FUNCS=1,
4993                            [AC_CHECK_LIB([posix4], sched_get_priority_max,
4994                              [
4995                                 HAVE_PRIOR_FUNCS=1
4996                                 POSIX4_LINK=" -lposix4"
4997                              ],
4998                            )]
4999                        )]
5000                      )]
5001                    )
5002
5003       if test "$HAVE_PRIOR_FUNCS" = 1; then
5004         AC_DEFINE(HAVE_THREAD_PRIORITY_FUNCTIONS)
5005       else
5006         AC_MSG_WARN(Setting thread priority will not work)
5007       fi
5008
5009       AC_CHECK_FUNC(pthread_cancel,
5010                     AC_DEFINE(HAVE_PTHREAD_CANCEL),
5011                     AC_MSG_WARN([wxThread::Kill() will not work properly]))
5012
5013       AC_CHECK_FUNC(pthread_mutex_timedlock,
5014                     AC_DEFINE(HAVE_PTHREAD_MUTEX_TIMEDLOCK),
5015                     AC_MSG_WARN([wxMutex::LockTimeout() will not work]))
5016
5017       AC_CHECK_FUNC(pthread_attr_setstacksize,
5018                     AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACKSIZE))
5019
5020       dnl mutexattr_t initialization is done in quite different ways on different
5021       dnl platforms, so check for a few things:
5022       dnl
5023       dnl HAVE_MUTEX_RECURSIVE means that we can create recursive mutexes
5024       dnl HAVE_MUTEXATTR_SETTYPE means that we do it using
5025       dnl pthread_mutexattr_settype(PTHREAD_MUTEX_RECURSIVE) and if it is not
5026       dnl defined, we do it by directly assigned
5027       dnl PTHREAD_MUTEX_RECURSIVE_MUTEX_INITIALIZER_NP to attr
5028
5029       AC_CACHE_CHECK([for pthread_mutexattr_t], wx_cv_type_pthread_mutexattr_t,
5030       [
5031         AC_TRY_COMPILE([#include <pthread.h>],
5032             [
5033                pthread_mutexattr_t attr;
5034                pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
5035             ],
5036             wx_cv_type_pthread_mutexattr_t=yes,
5037             wx_cv_type_pthread_mutexattr_t=no
5038         )
5039       ])
5040
5041       if test "$wx_cv_type_pthread_mutexattr_t" = "yes"; then
5042         AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_T)
5043
5044         dnl check if we already have the declaration we need, it is not
5045         dnl present in some systems' headers
5046         AC_CACHE_CHECK([for pthread_mutexattr_settype declaration],
5047                        wx_cv_func_pthread_mutexattr_settype_decl, [
5048                        AC_TRY_COMPILE([#include <pthread.h>],
5049                            [
5050                                pthread_mutexattr_t attr;
5051                                pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
5052                            ],
5053                            wx_cv_func_pthread_mutexattr_settype_decl=yes,
5054                            wx_cv_func_pthread_mutexattr_settype_decl=no
5055                        )
5056         ])
5057         if test "$wx_cv_func_pthread_mutexattr_settype_decl" = "yes"; then
5058             AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_SETTYPE_DECL)
5059         fi
5060       else
5061         dnl don't despair, there may be another way to do it
5062         AC_CACHE_CHECK([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER],
5063                        wx_cv_type_pthread_rec_mutex_init,
5064         [
5065             AC_TRY_COMPILE([#include <pthread.h>],
5066                 [
5067                     pthread_mutex_t attr = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
5068                 ], [
5069                     wx_cv_type_pthread_rec_mutex_init=yes
5070                 ], [
5071                     wx_cv_type_pthread_rec_mutex_init=no
5072                 ]
5073             )
5074         ])
5075         if test "$wx_cv_type_pthread_rec_mutex_init" = "yes"; then
5076           AC_DEFINE(HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
5077         else
5078           dnl this may break code working elsewhere, so at least warn about it
5079           AC_MSG_WARN([wxMutex won't be recursive on this platform])
5080         fi
5081       fi
5082
5083       if test "$wxUSE_COMPILER_TLS" = "auto"; then
5084           if test "$USE_NETBSD" = 1; then
5085               AC_MSG_WARN([Disabling TLS under NetBSD, please contact wx-dev if it works now])
5086               wxUSE_COMPILER_TLS=no
5087           else
5088               wxUSE_COMPILER_TLS=yes
5089           fi
5090       fi
5091
5092       if test "$wxUSE_COMPILER_TLS" = "yes"; then
5093           dnl test for compiler thread-specific variables support
5094           AC_CACHE_CHECK([for __thread keyword],
5095                          wx_cv_cc___thread,
5096               [
5097                   AC_TRY_COMPILE([#include <pthread.h>],
5098                       [
5099                           static __thread int n = 0;
5100                           static __thread int *p = 0;
5101                       ],
5102                       wx_cv_cc___thread=yes,
5103                       wx_cv_cc___thread=no
5104                   )
5105               ]
5106           )
5107
5108           if test "$wx_cv_cc___thread" = "yes"; then
5109               AX_GXX_VERSION
5110               if test -n "$ax_cv_gxx_version"; then
5111                   dnl g++ supports __thread since at least version 3.3 but its support
5112                   dnl seems to be broken until 4.1, see
5113                   dnl   http://thread.gmane.org/gmane.comp.lib.wxwidgets.devel/108388
5114                   dnl
5115                   dnl NB: we still need to test __thread support with
5116                   dnl     AC_TRY_COMPILE above even for g++ 4 as it doesn't
5117                   dnl     support it for all architectures (e.g. it doesn't
5118                   dnl     work under OS X)
5119                   AC_MSG_CHECKING([whether __thread support in g++ is usable])
5120                   case "$ax_cv_gxx_version" in
5121                     1.* | 2.* | 3.* )
5122                         AC_MSG_RESULT([no, it's broken])
5123                         wx_cv_cc___thread=no
5124                         ;;
5125                     *)
5126                         AC_MSG_RESULT([yes, it works])
5127                         ;;
5128                   esac
5129               fi
5130           fi
5131
5132           if test "$wx_cv_cc___thread" = "yes"; then
5133             AC_DEFINE(HAVE___THREAD_KEYWORD)
5134           fi
5135         fi
5136     fi
5137
5138 dnl from if !MSW
5139 else
5140     if test "$wxUSE_THREADS" = "yes" ; then
5141       case "${host}" in
5142         x86_64-*-mingw32* )
5143         ;;
5144         *-*-mingw32* )
5145             dnl check if the compiler accepts -mthreads
5146             AC_CACHE_CHECK([if compiler supports -mthreads],
5147                 wx_cv_cflags_mthread,
5148                 [
5149                     CFLAGS_OLD="$CFLAGS"
5150                     CFLAGS="-mthreads $CFLAGS"
5151                     AC_TRY_COMPILE([], [],
5152                         wx_cv_cflags_mthread=yes,
5153                         wx_cv_cflags_mthread=no
5154                     )
5155                 ]
5156             )
5157
5158             if test "$wx_cv_cflags_mthread" = "yes"; then
5159                 dnl it does, use it
5160                 WXCONFIG_CFLAGS="$WXCONFIG_CFLAGS -mthreads"
5161                 LDFLAGS="$LDFLAGS -mthreads"
5162             else
5163                 dnl it doesn't
5164                 CFLAGS="$CFLAGS_OLD"
5165             fi
5166         ;;
5167         *-pc-os2*emx )
5168             WXCONFIG_CFLAGS="$WXCONFIG_CFLAGS -Zmt -D__ST_MT_ERRNO__"
5169             LDFLAGS="$LDFLAGS -Zmt"
5170         ;;
5171       esac
5172     fi
5173 fi
5174
5175 AC_CHECK_FUNC(localtime_r, [ AC_DEFINE(HAVE_LOCALTIME_R) ])
5176 AC_CHECK_FUNC(gmtime_r, [ AC_DEFINE(HAVE_GMTIME_R) ])
5177 dnl By preference, we probably should use getaddrinfo which avoids thread
5178 dnl safety issues and supports IPv6, however there currently is no code
5179 dnl for it, so testing for it is temporarily disabled and we are restricted
5180 dnl to gethostbyname_r/gethostbyaddr_r  and getservbyname_r
5181
5182 dnl AC_CHECK_FUNC(getaddrinfo, AC_DEFINE(HAVE_GETADDRINFO), [
5183     dnl no getaddrinfo, so check for gethostbyname_r and
5184     dnl related functions (taken from python's configure.in)
5185     dnl sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments
5186       AX_FUNC_WHICH_GETHOSTBYNAME_R
5187       if test "x$ac_cv_func_which_gethostbyname_r" = "xno" -o \
5188               "x$ac_cv_func_which_gethostbyname_r" = "xunknown" ; then
5189           AC_CHECK_FUNC(gethostbyname, [ AC_DEFINE(HAVE_GETHOSTBYNAME) ])
5190       fi
5191       dnl A similar test for getservbyname_r
5192       dnl I'm tempted to just not do this test which is taking much time and
5193       dnl do something similar as for gethostbyaddr_r, but OTOH the macro
5194       dnl doing the test already exists, so using it is easy enough.     - SN
5195       AC_raf_FUNC_WHICH_GETSERVBYNAME_R
5196       if test "x$ac_cv_func_which_getservbyname_r" = "xno" -o \
5197               "x$ac_cv_func_which_getservbyname_r" = "xunknown" ; then
5198           AC_CHECK_FUNCS(getservbyname,[ AC_DEFINE(HAVE_GETSERVBYNAME) ])
5199       fi
5200       dnl For gethostbyaddr_r, we currently do no separate test, instead, we
5201       dnl silently assume it's available exactly if gethostbyname_r is
5202       dnl available and always requires two more arguments than
5203       dnl gethostbyname_r.
5204       dnl (also, I'm lazy and there no m4 file that's ready for use for this
5205       dnl  function, although it should be easy to rewrite the gethostbyname_r
5206       dnl  check to fit this case, if it's really needed.                - SN )
5207 dnl    ]
5208 dnl )
5209
5210 if test "$wxUSE_THREADS" = "yes"; then
5211   AC_DEFINE(wxUSE_THREADS)
5212
5213   SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS thread"
5214 else
5215   dnl on some systems, _REENTRANT should be defined if we want to use any _r()
5216   dnl functions - add tests for other functions here as well
5217   if test "$wx_cv_func_strtok_r" = "yes"; then
5218     AC_MSG_CHECKING(if -D_REENTRANT is needed)
5219     if test "$NEEDS_D_REENTRANT_FOR_R_FUNCS" = 1; then
5220         WXCONFIG_CPPFLAGS="$WXCONFIG_CPPFLAGS -D_REENTRANT"
5221         AC_MSG_RESULT(yes)
5222     else
5223         AC_MSG_RESULT(no)
5224     fi
5225   fi
5226 fi
5227
5228 if test "$WXGTK2" = 1 ; then
5229   AC_DEFINE_UNQUOTED(__WXGTK20__,$WXGTK2)
5230   WXGTK12=1
5231 fi
5232
5233 if test "$WXGTK12" = 1 ; then
5234   AC_DEFINE_UNQUOTED(__WXGTK12__,$WXGTK12)
5235 fi
5236
5237 if test "$WXGTK127" = 1 ; then
5238   AC_DEFINE_UNQUOTED(__WXGTK127__,$WXGTK127)
5239 fi
5240
5241 if test "$WXGPE" = 1 ; then
5242   AC_DEFINE_UNQUOTED(__WXGPE__,$WXGPE)
5243 fi
5244
5245 dnl DEBUG_CFLAGS contains debugging options (supposed to be the same for C and C++
5246 dnl compilers: we'd need a separate DEBUG_CXXFLAGS if this is ever not the case)
5247 DEBUG_CFLAGS=
5248 if `echo $CXXFLAGS $CFLAGS | grep " -g" >/dev/null`; then
5249     dnl the CXXFLAGS or the CFLAGS variable already contains the -g flag
5250     dnl (e.g. it was specified by the user before running configure); since
5251     dnl later they will be merged with DEBUG_CFLAGS, don't set the -g option
5252     dnl in DEBUG_CFLAGS to avoid (possibly different) flag duplicates
5253     AC_MSG_WARN([CXXFLAGS/CFLAGS already contains -g flag; ignoring the --enable-debug_info option])
5254 elif test "$wxUSE_DEBUG_INFO" = "yes" ; then
5255     DEBUG_CFLAGS="-g"
5256 fi
5257
5258 if test "$wxUSE_DEBUG_GDB" = "yes" ; then
5259     wxUSE_DEBUG_INFO=yes
5260     if test "$GCC" = yes; then
5261         DEBUG_CFLAGS="-ggdb"
5262     fi
5263 fi
5264
5265 if test "$wxUSE_DEBUG_FLAG" = "no" ; then
5266     if test "$wxUSE_GTK" = 1 ; then
5267         if test "x$wxGTK_VERSION" = "x1" ; then
5268             CPPFLAGS="-DGTK_NO_CHECK_CASTS $CPPFLAGS"
5269         fi
5270     fi
5271 fi
5272
5273 if test "$wxUSE_MEM_TRACING" = "yes" ; then
5274     AC_DEFINE(wxUSE_MEMORY_TRACING)
5275     AC_DEFINE(wxUSE_GLOBAL_MEMORY_OPERATORS)
5276     AC_DEFINE(wxUSE_DEBUG_NEW_ALWAYS)
5277     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS memcheck"
5278 fi
5279
5280 if test "$wxUSE_DMALLOC" = "yes" ; then
5281     DMALLOC_LIBS="-ldmallocthcxx"
5282 fi
5283
5284 dnl cc/cxx/ld option for profiling
5285 PROFILE_FLAGS=
5286 if test "$wxUSE_PROFILE" = "yes" ; then
5287     PROFILE_FLAGS=" -pg"
5288 fi
5289
5290 if test "$GCC" = "yes" ; then
5291     if test "$wxUSE_NO_RTTI" = "yes" ; then
5292         WXCONFIG_CXXFLAGS="$WXCONFIG_CXXFLAGS -fno-rtti"
5293     fi
5294     if test "$wxUSE_NO_EXCEPTIONS" = "yes" ; then
5295         WXCONFIG_CXXFLAGS="$WXCONFIG_CXXFLAGS -fno-exceptions"
5296     fi
5297     if test "$wxUSE_PERMISSIVE" = "yes" ; then
5298         WXCONFIG_CFLAGS="$WXCONFIG_CFLAGS -fpermissive"
5299     fi
5300
5301     dnl Ian Brown <ian.brown@printsoft.de> reports that versions of gcc before
5302     dnl 3.0 overflow the table of contents on rs6000 as they create an entry
5303     dnl for each subroutine by default -- using the switch below only creates
5304     dnl one entry per file instead at the price of minor performance penalty
5305     dnl
5306     dnl As of wx2.4 a bug in the hppa gcc compiler causes a similar problem
5307     dnl without -ffunction-sections.  No idea how long we'll need to maintain
5308     dnl this, or even the extent of gcc/wx version combinations affected, but
5309     dnl also as above, this 'fix' does not come without side effects.
5310     dnl
5311     dnl TODO: test for the gcc version here (how?)
5312     case "${host}" in
5313       powerpc*-*-aix* )
5314         WXCONFIG_CFLAGS="$WXCONFIG_CFLAGS -mminimal-toc"
5315         ;;
5316       *-hppa* )
5317         WXCONFIG_CFLAGS="$WXCONFIG_CFLAGS -ffunction-sections"
5318         ;;
5319     esac
5320 fi
5321
5322 dnl C/C++ compiler option for optimization (supposed to be the same for both)
5323 OPTIMISE_CFLAGS=
5324 if `echo $CXXFLAGS $CFLAGS | grep " -O" >/dev/null`; then
5325     dnl the CXXFLAGS or the CFLAGS variable already contains -O optimization flag
5326     dnl (e.g. it was specified by the user before running configure); since
5327     dnl later they will be merged with OPTIMISE_CFLAGS, don't set the -O option
5328     dnl in OPTIMISE_CFLAGS to avoid (possibly different) flag duplicates
5329     AC_MSG_WARN([CXXFLAGS/CFLAGS already contains -O flag; ignoring the --disable-optimise option])
5330 else
5331     if test "$wxUSE_OPTIMISE" = "no" ; then
5332         if test "$GCC" = yes ; then
5333             dnl use -O0 because compiling with it is faster than compiling with no
5334             dnl optimization options at all (at least with g++ 3.2)
5335             OPTIMISE_CFLAGS="-O0"
5336         fi
5337     else
5338         if test "$GCC" = yes ; then
5339             case "${host}" in
5340                 *-pc-os2_emx | *-pc-os2-emx )
5341                     dnl Not all of the supported gcc versions understand
5342                     dnl -fstrict-aliasing and none actually needs it (yet).
5343                     OPTIMISE_CFLAGS="-O2"
5344                 ;;
5345                 *)
5346                     dnl Switch on optimisation but keep strict-aliasing off for
5347                     dnl now (see -fstrict-aliasing in the gcc manual). When it is
5348                     dnl switched back on consider using -Wstrict-aliasing=2.
5349                     OPTIMISE_CFLAGS="-O2 -fno-strict-aliasing"
5350                 ;;
5351             esac
5352         else
5353             OPTIMISE_CFLAGS="-O"
5354         fi
5355     fi
5356 fi
5357
5358 dnl ---------------------------------------------------------------------------
5359 dnl compatibility level
5360 dnl ---------------------------------------------------------------------------
5361
5362 if test "x$WXWIN_COMPATIBILITY_2_6" = "xyes"; then
5363     AC_DEFINE(WXWIN_COMPATIBILITY_2_6)
5364
5365     WXWIN_COMPATIBILITY_2_8="yes"
5366 fi
5367
5368 if test "x$WXWIN_COMPATIBILITY_2_8" != "xno"; then
5369     AC_DEFINE(WXWIN_COMPATIBILITY_2_8)
5370 fi
5371
5372 dnl ---------------------------------------------------------------------------
5373 dnl the library may be built without GUI classes at all
5374 dnl ---------------------------------------------------------------------------
5375
5376 if test "$wxUSE_GUI" = "yes"; then
5377     AC_DEFINE(wxUSE_GUI)
5378
5379     dnl the things we always pull in the GUI version of the library:
5380     dnl 1. basic things like wxApp, wxWindow, wxControl, wxFrame, wxDialog (the
5381     dnl    library really can't be built without those)
5382     dnl 2. basic controls: wxButton, wxStaticText, wxTextCtrl (these are used in
5383     dnl    almost any program and the first 2 are needed to show a message box
5384     dnl    which want to be always able to do)
5385     dnl 3. GDI stuff: icon, cursors and all that. Although it would be very nice
5386     dnl    to compile without them (if the app doesn't do any drawing, it doesn't
5387     dnl    need the dcs, pens, brushes, ...), this just can't be done now
5388     dnl 4. menu stuff: wxMenu, wxMenuBar, wxMenuItem
5389     dnl 5. misc stuff: timers, settings, message box
5390 fi
5391
5392 dnl ---------------------------------------------------------------------------
5393 dnl Unix/Windows
5394 dnl ---------------------------------------------------------------------------
5395
5396 if test "$wxUSE_UNIX" = "yes"; then
5397   AC_DEFINE(wxUSE_UNIX)
5398 fi
5399
5400 dnl ------------------------------------------------------------------------
5401 dnl DLL support
5402 dnl ------------------------------------------------------------------------
5403
5404 dnl under MSW we always have LoadLibrary/GetProcAddress
5405 if test "$TOOLKIT" != "MSW" -a "$USE_OS2" != 1; then
5406
5407     HAVE_DL_FUNCS=0
5408     HAVE_SHL_FUNCS=0
5409     if test "$wxUSE_DYNAMIC_LOADER" = "yes" -o "$wxUSE_DYNLIB_CLASS" = "yes" ; then
5410         if test "$USE_DOS" = 1; then
5411             HAVE_DL_FUNCS=0
5412         else
5413             dnl the test is a bit complicated because we check for dlopen() both with
5414             dnl and without -ldl and we also try to find shl_load() if there is no
5415             dnl dlopen() on this system
5416             AC_CHECK_FUNCS(dlopen,
5417             [
5418                 AC_DEFINE(HAVE_DLOPEN)
5419                 HAVE_DL_FUNCS=1
5420             ],
5421             [
5422                 AC_CHECK_LIB(dl, dlopen,
5423                             [
5424                                 AC_DEFINE(HAVE_DLOPEN)
5425                                 HAVE_DL_FUNCS=1
5426                                 DL_LINK=" -ldl$DL_LINK"
5427                             ],
5428                             [
5429                                 AC_CHECK_FUNCS(shl_load,
5430                                               [
5431                                                 AC_DEFINE(HAVE_SHL_LOAD)
5432                                                 HAVE_SHL_FUNCS=1
5433                                               ],
5434                                               [
5435                                                 AC_CHECK_LIB(shl_load, dld,
5436                                                              [
5437                                                                 HAVE_SHL_FUNCS=1
5438                                                                 DL_LINK=" -ldld$DL_LINK"
5439                                                              ])
5440                                               ])
5441                             ])
5442             ])
5443
5444             dnl check also for dlerror()
5445             if test "$HAVE_DL_FUNCS" = 1; then
5446                 AC_CHECK_FUNCS(dlerror,
5447                     AC_DEFINE(HAVE_DLERROR),
5448                     [
5449                         AC_CHECK_LIB(dl, dlerror, AC_DEFINE(HAVE_DLERROR))
5450                     ]
5451                 )
5452             fi
5453         fi
5454
5455         dnl Force HAVE_DL_FUNCS on for Darwin, even if the tests failed (e.g. pre-10.3)
5456         if test "$USE_DARWIN" = 1; then
5457             dnl dlopen/dlerror is implemented in dynlib.cpp for Darwin/Mac OS X
5458             HAVE_DL_FUNCS=1
5459         fi
5460
5461         if test "$HAVE_DL_FUNCS" = 0; then
5462             if test "$HAVE_SHL_FUNCS" = 0; then
5463               if test "$USE_UNIX" = 1 -o "$USE_DOS" = 1; then
5464                   AC_MSG_WARN([Missing dynamic loading support, several features will be disabled])
5465                   wxUSE_DYNAMIC_LOADER=no
5466                   wxUSE_DYNLIB_CLASS=no
5467               else
5468                   AC_MSG_WARN([Assuming wxLibrary class works on this platform])
5469               fi
5470             fi
5471         fi
5472     fi
5473 fi
5474
5475 if test "$wxUSE_DYNAMIC_LOADER" = "yes" ; then
5476     AC_DEFINE(wxUSE_DYNAMIC_LOADER)
5477 fi
5478 if test "$wxUSE_DYNLIB_CLASS" = "yes" ; then
5479     AC_DEFINE(wxUSE_DYNLIB_CLASS)
5480 fi
5481
5482
5483 dnl ---------------------------------------------------------------------------
5484 dnl Verify consistency of plugins/monolithic/shared settings:
5485 dnl ---------------------------------------------------------------------------
5486
5487 if test "$wxUSE_PLUGINS" = "yes" ; then
5488     if test "$wxUSE_SHARED" = "no" ; then
5489         AC_MSG_WARN([plugins supported only in shared build, disabling])
5490         wxUSE_PLUGINS=no
5491     fi
5492     if test "$wxUSE_MONOLITHIC" = "yes" ; then
5493         AC_MSG_WARN([plugins not supported monolithic build, disabling])
5494         wxUSE_PLUGINS=no
5495     fi
5496     if test "$wxUSE_DYNLIB_CLASS" = "no" ; then
5497         AC_MSG_WARN([plugins require wxDynamicLibrary, disabling])
5498         wxUSE_PLUGINS=no
5499     fi
5500     if test "$wxUSE_PLUGINS" = "yes" ; then
5501         AC_DEFINE(wxUSE_PLUGINS)
5502     fi
5503 fi
5504
5505 dnl ---------------------------------------------------------------------------
5506 dnl Register non-GUI class options for makefiles and setup.h
5507 dnl ---------------------------------------------------------------------------
5508
5509 if test "$wxUSE_STL" = "yes"; then
5510   AC_DEFINE(wxUSE_STL)
5511 fi
5512
5513 if test "$wxUSE_EXTENDED_RTTI" = "yes"; then
5514   AC_DEFINE(wxUSE_EXTENDED_RTTI)
5515 fi
5516
5517 if test "$wxUSE_ANY" = "yes"; then
5518     AC_DEFINE(wxUSE_ANY)
5519 fi
5520
5521 if test "$wxUSE_APPLE_IEEE" = "yes"; then
5522   AC_DEFINE(wxUSE_APPLE_IEEE)
5523 fi
5524
5525 if test "$wxUSE_TIMER" = "yes"; then
5526   AC_DEFINE(wxUSE_TIMER)
5527 fi
5528
5529 dnl Unix implementation needs additional checks because audio support
5530 dnl comes in many favours:
5531 if test "$USE_UNIX" = 1 ; then
5532     dnl mmedia doesn't compile with wxMGL, remove this if this is ever fixed
5533     if test "$wxUSE_MGL" != 1; then
5534         dnl it's not enough to check for just the header because OSS under NetBSD
5535         dnl redefines ioctl as oss_ioctrl inside it and so we also need to test
5536         dnl whether we need -lossaudio at link-time
5537         AC_CACHE_CHECK([for SNDCTL_DSP_SPEED in sys/soundcard.h], ac_cv_header_sys_soundcard, [
5538             AC_TRY_LINK([
5539                     #include <sys/ioctl.h>
5540                     #include <sys/soundcard.h>
5541                 ],
5542                 [
5543                     ioctl(0, SNDCTL_DSP_SPEED, 0);
5544                 ],
5545                 ac_cv_header_sys_soundcard=yes,
5546                 [
5547                     saveLibs="$LIBS"
5548                     LIBS="$saveLibs -lossaudio"
5549                     AC_TRY_LINK([
5550                             #include <sys/ioctl.h>
5551                             #include <sys/soundcard.h>
5552                         ],
5553                         [
5554                             ioctl(0, SNDCTL_DSP_SPEED, 0);
5555                         ],
5556                         ac_cv_header_sys_soundcard=yes,
5557                         [
5558                             LIBS="$saveLibs"
5559                             ac_cv_header_sys_soundcard=no
5560                         ]
5561                     )
5562                 ]
5563             )
5564         ])
5565     fi
5566
5567     if test "$ac_cv_header_sys_soundcard" = "yes"; then
5568         AC_DEFINE(HAVE_SYS_SOUNDCARD_H)
5569     fi
5570 fi
5571
5572 WITH_PLUGIN_SDL=0
5573 if test "$wxUSE_SOUND" = "yes"; then
5574   if test "$USE_UNIX" = 1 ; then
5575     if test "$wxUSE_LIBSDL" != "no"; then
5576       AM_PATH_SDL([1.2.0],
5577                   [
5578                     EXTRALIBS_SDL="$SDL_LIBS"
5579                     CFLAGS="$SDL_CFLAGS $CFLAGS"
5580                     CXXFLAGS="$SDL_CFLAGS $CXXFLAGS"
5581                     AC_DEFINE(wxUSE_LIBSDL)
5582                   ],
5583                   [wxUSE_LIBSDL="no"])
5584       if test "$wxUSE_LIBSDL" = "yes" -a "$wxUSE_PLUGINS" = "yes" ; then
5585         WITH_PLUGIN_SDL=1
5586       fi
5587     fi
5588   else
5589     dnl wxMGL doesn't support sound under DOS, only under Unix
5590     if test "$wxUSE_MGL" = 1; then
5591         AC_MSG_WARN([wxSound not supported in MGL under DOS... disabled])
5592         wxUSE_SOUND="no"
5593     fi
5594   fi
5595 fi
5596
5597 if test "$wxUSE_SOUND" = "yes"; then
5598   AC_DEFINE(wxUSE_SOUND)
5599   SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS sound"
5600 fi
5601
5602 if test "$WXGTK2" = 1; then
5603     PKG_PROG_PKG_CONFIG()
5604
5605     if test "$wxUSE_PRINTING_ARCHITECTURE" = "yes" ; then
5606
5607         if test "$wxUSE_GTKPRINT" = "yes" ; then
5608
5609                 PKG_CHECK_MODULES(GTKPRINT,
5610                                   [gtk+-unix-print-2.0 >= 2.10],
5611                     [
5612                         CFLAGS="$GTKPRINT_CFLAGS $CFLAGS"
5613                         CXXFLAGS="$GTKPRINT_CFLAGS $CXXFLAGS"
5614                         AC_DEFINE(wxUSE_GTKPRINT)
5615                     ],
5616                     [
5617                         AC_MSG_WARN([GTK printing support not found (GTK+ >= 2.10), library will use GNOME printing support or standard PostScript printing])
5618                         wxUSE_GTKPRINT="no"
5619                     ]
5620                 )
5621         fi
5622
5623         if test "$wxUSE_LIBGNOMEPRINT" = "yes" ; then
5624
5625                 PKG_CHECK_MODULES(LIBGNOMEPRINTUI,
5626                                   [libgnomeprintui-2.2 >= 2.8],
5627                     [
5628                         CFLAGS="$LIBGNOMEPRINTUI_CFLAGS $CFLAGS"
5629                         CXXFLAGS="$LIBGNOMEPRINTUI_CFLAGS $CXXFLAGS"
5630                         AC_DEFINE(wxUSE_LIBGNOMEPRINT)
5631                     ],
5632                     [
5633                         AC_MSG_WARN([libgnomeprintui not found, library will use standard PostScript printing])
5634                         wxUSE_LIBGNOMEPRINT="no"
5635                     ]
5636                 )
5637         fi
5638     fi
5639
5640     if test "$wxUSE_MIMETYPE" = "yes" ; then
5641         if test "$wxUSE_LIBGNOMEVFS" = "yes" ; then
5642
5643                 PKG_CHECK_MODULES(GNOMEVFS,
5644                                   [gnome-vfs-2.0 >= 2.0],
5645                     [
5646                         CFLAGS="$GNOMEVFS_CFLAGS $CFLAGS"
5647                         CXXFLAGS="$GNOMEVFS_CFLAGS $CXXFLAGS"
5648                         AC_DEFINE(wxUSE_LIBGNOMEVFS)
5649                     ],
5650                     [
5651                         AC_MSG_WARN([libgnomevfs not found, library won't be able to associate MIME type])
5652                         wxUSE_LIBGNOMEVFS="no"
5653                     ]
5654                 )
5655         fi
5656     fi
5657
5658     if test "$wxUSE_LIBHILDON" = "yes" ; then
5659         PKG_CHECK_MODULES(HILDON,
5660                           [hildon-lgpl >= 0.9],
5661             [
5662                 EXTRALIBS_HILDON="$HILDON_LIBS"
5663                 CFLAGS="$CFLAGS $HILDON_CFLAGS"
5664                 CXXFLAGS="$CXXFLAGS $HILDON_CFLAGS"
5665                 AC_DEFINE(wxUSE_LIBHILDON)
5666                 ac_hildon_lgpl=1
5667             ],
5668             [
5669                 AC_MSG_WARN([libhildon_lgpl not found])
5670                         wxUSE_LIBHILDON="no"
5671                         ac_hildon_lgpl=0
5672             ]
5673         )
5674
5675         if test "$ac_hildon_lgpl" = 0 ; then
5676             PKG_CHECK_MODULES(HILDON2,
5677                               [hildon-1 >= 1.99],
5678                 [
5679                     EXTRALIBS_HILDON="$HILDON2_LIBS"
5680                     CFLAGS="$CFLAGS $HILDON2_CFLAGS"
5681                     CXXFLAGS="$CXXFLAGS $HILDON2_CFLAGS"
5682                     AC_DEFINE(wxUSE_LIBHILDON2)
5683                 ],
5684                 [
5685                     AC_MSG_WARN([libhildon_1 not found])
5686                             wxUSE_LIBHILDON2="no"
5687                 ]
5688             )
5689         fi
5690     fi
5691 fi
5692
5693 if test "$wxUSE_CMDLINE_PARSER" = "yes"; then
5694   AC_DEFINE(wxUSE_CMDLINE_PARSER)
5695 fi
5696
5697 if test "$wxUSE_STOPWATCH" = "yes"; then
5698   AC_DEFINE(wxUSE_STOPWATCH)
5699 fi
5700
5701 if test "$wxUSE_DATETIME" = "yes"; then
5702   AC_DEFINE(wxUSE_DATETIME)
5703 fi
5704
5705 if test "$wxUSE_FILE" = "yes"; then
5706   AC_DEFINE(wxUSE_FILE)
5707 fi
5708
5709 if test "$wxUSE_FFILE" = "yes"; then
5710   AC_DEFINE(wxUSE_FFILE)
5711 fi
5712
5713 if test "$wxUSE_ARCHIVE_STREAMS" = "yes"; then
5714   if test "$wxUSE_STREAMS" != yes; then
5715     AC_MSG_WARN(wxArchive requires wxStreams... disabled)
5716     wxUSE_ARCHIVE_STREAMS=no
5717   else
5718     AC_DEFINE(wxUSE_ARCHIVE_STREAMS)
5719   fi
5720 fi
5721
5722 if test "$wxUSE_ZIPSTREAM" = "yes"; then
5723   if test "$wxUSE_ARCHIVE_STREAMS" != "yes"; then
5724     AC_MSG_WARN(wxZip requires wxArchive... disabled)
5725   elif test "$wxUSE_ZLIB" = "no"; then
5726     AC_MSG_WARN(wxZip requires wxZlib... disabled)
5727   else
5728     AC_DEFINE(wxUSE_ZIPSTREAM)
5729   fi
5730 fi
5731
5732 if test "$wxUSE_TARSTREAM" = "yes"; then
5733   if test "$wxUSE_ARCHIVE_STREAMS" != "yes"; then
5734     AC_MSG_WARN(wxTar requires wxArchive... disabled)
5735   else
5736     AC_DEFINE(wxUSE_TARSTREAM)
5737   fi
5738 fi
5739
5740 if test "$wxUSE_FILESYSTEM" = "yes"; then
5741   if test "$wxUSE_STREAMS" != yes -o \( "$wxUSE_FILE" != yes -a "$wxUSE_FFILE" != yes \); then
5742     AC_MSG_WARN(wxFileSystem requires wxStreams and wxFile or wxFFile... disabled)
5743     wxUSE_FILESYSTEM=no
5744   else
5745     AC_DEFINE(wxUSE_FILESYSTEM)
5746   fi
5747 fi
5748
5749 if test "$wxUSE_FS_ARCHIVE" = "yes"; then
5750   if test "$wxUSE_FILESYSTEM" != yes -o "$wxUSE_ARCHIVE_STREAMS" != yes; then
5751     AC_MSG_WARN(wxArchiveFSHandler requires wxArchive and wxFileSystem... disabled)
5752   else
5753     AC_DEFINE(wxUSE_FS_ARCHIVE)
5754   fi
5755 fi
5756
5757 if test "$wxUSE_FS_ZIP" = "yes"; then
5758   if test "$wxUSE_FS_ARCHIVE" != yes; then
5759     AC_MSG_WARN(wxZipFSHandler requires wxArchiveFSHandler... disabled)
5760   else
5761     AC_DEFINE(wxUSE_FS_ZIP)
5762   fi
5763 fi
5764
5765 if test "$wxUSE_ON_FATAL_EXCEPTION" = "yes"; then
5766   if test "$USE_UNIX" != 1; then
5767     AC_MSG_WARN([Catching fatal exceptions not currently supported on this system, wxApp::OnFatalException will not be called])
5768     wxUSE_ON_FATAL_EXCEPTION=no
5769   else
5770     AC_DEFINE(wxUSE_ON_FATAL_EXCEPTION)
5771   fi
5772 fi
5773
5774 if test "$wxUSE_STACKWALKER" = "yes"; then
5775     AC_DEFINE(wxUSE_STACKWALKER)
5776 fi
5777
5778 if test "$wxUSE_DEBUGREPORT" = "yes"; then
5779     if test "$USE_UNIX" != 1 -a "$USE_WIN32" != 1; then
5780         AC_MSG_WARN([Creating debug reports not currently supported on this system, disabled])
5781         wxUSE_DEBUGREPORT=no
5782     else
5783         AC_DEFINE(wxUSE_DEBUGREPORT)
5784         if test "$wxUSE_ON_FATAL_EXCEPTION" = "yes"; then
5785             SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS debugrpt"
5786         fi
5787     fi
5788 fi
5789
5790 if test "$wxUSE_SNGLINST_CHECKER" = "yes"; then
5791   AC_DEFINE(wxUSE_SNGLINST_CHECKER)
5792 fi
5793
5794 if test "$wxUSE_BUSYINFO" = "yes"; then
5795   AC_DEFINE(wxUSE_BUSYINFO)
5796 fi
5797
5798 if test "$wxUSE_STD_IOSTREAM" = "yes"; then
5799   AC_DEFINE(wxUSE_STD_IOSTREAM)
5800 fi
5801
5802 if test "$wxUSE_STD_STRING" = "yes"; then
5803   AC_DEFINE(wxUSE_STD_STRING)
5804 fi
5805
5806 if test "$wxUSE_STDPATHS" = "yes"; then
5807   AC_DEFINE(wxUSE_STDPATHS)
5808 fi
5809
5810 if test "$wxUSE_TEXTBUFFER" = "yes"; then
5811     AC_DEFINE(wxUSE_TEXTBUFFER)
5812 fi
5813
5814 if test "$wxUSE_TEXTFILE" = "yes"; then
5815   if test "$wxUSE_FILE" != "yes" -o "$wxUSE_TEXTBUFFER" != "yes" ; then
5816     AC_MSG_WARN(wxTextFile requires wxFile and wxTextBuffer... disabled)
5817   else
5818     AC_DEFINE(wxUSE_TEXTFILE)
5819   fi
5820 fi
5821
5822 if test "$wxUSE_CONFIG" = "yes" ; then
5823   if test "$wxUSE_TEXTFILE" != "yes"; then
5824     AC_MSG_WARN(wxConfig requires wxTextFile... disabled)
5825   else
5826     AC_DEFINE(wxUSE_CONFIG)
5827     AC_DEFINE(wxUSE_CONFIG_NATIVE)
5828     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS config"
5829   fi
5830 fi
5831
5832 if test "$wxUSE_INTL" = "yes" ; then
5833   if test "$wxUSE_FILE" != "yes"; then
5834     AC_MSG_WARN(I18n code requires wxFile... disabled)
5835   else
5836     AC_DEFINE(wxUSE_INTL)
5837     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS internat"
5838     GUIDIST="$GUIDIST INTL_DIST"
5839   fi
5840 fi
5841
5842 if test "$wxUSE_XLOCALE" = "yes" ; then
5843     AC_DEFINE(wxUSE_XLOCALE)
5844     AC_CHECK_TYPES(locale_t,,,
5845                    [#include <xlocale.h>
5846                     #include <locale.h>])
5847 fi
5848
5849 if test "$wxUSE_LOG" = "yes"; then
5850   AC_DEFINE(wxUSE_LOG)
5851
5852     if test "$wxUSE_LOGGUI" = "yes"; then
5853       AC_DEFINE(wxUSE_LOGGUI)
5854     fi
5855
5856     if test "$wxUSE_LOGWINDOW" = "yes"; then
5857       AC_DEFINE(wxUSE_LOGWINDOW)
5858     fi
5859
5860     if test "$wxUSE_LOGDIALOG" = "yes"; then
5861       AC_DEFINE(wxUSE_LOG_DIALOG)
5862     fi
5863
5864     dnl the keyboard sample requires wxUSE_LOG
5865     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS keyboard"
5866 fi
5867
5868 if test "$wxUSE_LONGLONG" = "yes"; then
5869   AC_DEFINE(wxUSE_LONGLONG)
5870 fi
5871
5872 if test "$wxUSE_GEOMETRY" = "yes"; then
5873   AC_DEFINE(wxUSE_GEOMETRY)
5874 fi
5875
5876 if test "$wxUSE_BASE64" = "yes"; then
5877   AC_DEFINE(wxUSE_BASE64)
5878 fi
5879
5880 if test "$wxUSE_STREAMS" = "yes" ; then
5881   AC_DEFINE(wxUSE_STREAMS)
5882 fi
5883
5884 if test "$wxUSE_PRINTF_POS_PARAMS" = "yes"; then
5885   AC_DEFINE(wxUSE_PRINTF_POS_PARAMS)
5886 fi
5887
5888 if test "$wxUSE_OBJC_UNIQUIFYING" = "yes"; then
5889   AC_DEFINE(wxUSE_OBJC_UNIQUIFYING)
5890 fi
5891
5892 dnl ---------------------------------------------------------------------------
5893 dnl console event loop stuff
5894 dnl ---------------------------------------------------------------------------
5895
5896 if test "$wxUSE_CONSOLE_EVENTLOOP" = "yes"; then
5897     AC_DEFINE(wxUSE_CONSOLE_EVENTLOOP)
5898
5899     if test "$wxUSE_UNIX" = "yes"; then
5900         if test "$wxUSE_SELECT_DISPATCHER" = "yes"; then
5901             AC_DEFINE(wxUSE_SELECT_DISPATCHER)
5902         fi
5903
5904         if test "$wxUSE_EPOLL_DISPATCHER" = "yes"; then
5905             AC_CHECK_HEADERS(sys/epoll.h,,, [AC_INCLUDES_DEFAULT()])
5906             if test "$ac_cv_header_sys_epoll_h" = "yes"; then
5907                 AC_DEFINE(wxUSE_EPOLL_DISPATCHER)
5908             else
5909                 AC_MSG_WARN([sys/epoll.h not available, wxEpollDispatcher disabled])
5910             fi
5911         fi
5912     fi
5913 fi
5914
5915 dnl ---------------------------------------------------------------------------
5916 dnl time/date functions
5917 dnl ---------------------------------------------------------------------------
5918
5919 dnl check for gettimeofday (SVr4, BSD 4.3) and ftime (V7, BSD 4.3) for the
5920 dnl function to be used for high resolution timers
5921 AC_CHECK_FUNCS(gettimeofday ftime, break)
5922
5923 if test "$ac_cv_func_gettimeofday" = "yes"; then
5924     AC_CACHE_CHECK([whether gettimeofday takes two arguments],
5925                    wx_cv_func_gettimeofday_has_2_args,
5926     [
5927         dnl on some _really_ old systems it takes only 1 argument
5928         AC_TRY_COMPILE(
5929             [
5930                 #include <sys/time.h>
5931                 #include <unistd.h>
5932             ],
5933             [
5934                 struct timeval tv;
5935                 gettimeofday(&tv, NULL);
5936             ],
5937             wx_cv_func_gettimeofday_has_2_args=yes,
5938             AC_TRY_COMPILE(
5939                 [
5940                     #include <sys/time.h>
5941                     #include <unistd.h>
5942                 ],
5943                 [
5944                     struct timeval tv;
5945                     gettimeofday(&tv);
5946                 ],
5947                 wx_cv_func_gettimeofday_has_2_args=no,
5948                 [
5949                     AC_MSG_WARN([failed to determine number of gettimeofday() arguments])
5950                     wx_cv_func_gettimeofday_has_2_args=unknown
5951                 ]
5952             )
5953         )
5954     ])
5955
5956     if test "$wx_cv_func_gettimeofday_has_2_args" != "yes"; then
5957         AC_DEFINE(WX_GETTIMEOFDAY_NO_TZ)
5958     fi
5959 fi
5960
5961 if test "$wxUSE_DATETIME" = "yes"; then
5962     dnl check for timezone variable
5963     dnl   doesn't exist under Darwin / Mac OS X which uses tm_gmtoff instead
5964     AC_CACHE_CHECK(for timezone variable in <time.h>,
5965                    wx_cv_var_timezone,
5966                    [
5967                         AC_LANG_PUSH(C++)
5968                         AC_TRY_COMPILE(
5969                             [
5970                                 #include <time.h>
5971                             ],
5972                             [
5973                                 int tz;
5974                                 tz = timezone;
5975                             ],
5976                             [
5977                                 wx_cv_var_timezone=timezone
5978                             ],
5979                             [
5980                                 AC_TRY_COMPILE(
5981                                     [
5982                                         #include <time.h>
5983                                     ],
5984                                     [
5985                                         int tz;
5986                                         tz = _timezone;
5987                                     ],
5988                                     [
5989                                         wx_cv_var_timezone=_timezone
5990                                     ],
5991                                     [
5992                                         AC_TRY_COMPILE(
5993                                             [
5994                                                 #include <time.h>
5995                                             ],
5996                                             [
5997                                                 int tz;
5998                                                 tz = __timezone;
5999                                             ],
6000                                             [
6001                                                 wx_cv_var_timezone=__timezone
6002                                             ],
6003                                             [
6004                                                 if test "$USE_DOS" = 0 ; then
6005                                                     AC_MSG_WARN(no timezone variable, will use tm_gmtoff instead)
6006                                                 fi
6007                                             ]
6008                                         )
6009                                     ]
6010                                 )
6011                             ]
6012                         )
6013                         AC_LANG_POP()
6014                    ]
6015     )
6016
6017     dnl as we want $wx_cv_var_timezone to be expanded, use AC_DEFINE_UNQUOTED
6018     if test "x$wx_cv_var_timezone" != x ; then
6019         AC_DEFINE_UNQUOTED(WX_TIMEZONE, $wx_cv_var_timezone)
6020     fi
6021
6022     dnl check for localtime (it's POSIX, but the check can do no harm...)
6023     AC_CHECK_FUNCS(localtime)
6024
6025     if test "$ac_cv_func_localtime" = "yes"; then
6026         AC_CACHE_CHECK(for tm_gmtoff in struct tm,
6027                        wx_cv_struct_tm_has_gmtoff,
6028         [
6029             AC_TRY_COMPILE(
6030                 [
6031                     #include <time.h>
6032                 ],
6033                 [
6034                     struct tm tm;
6035                     tm.tm_gmtoff++;
6036                 ],
6037                 [
6038                     wx_cv_struct_tm_has_gmtoff=yes
6039                 ],
6040                 wx_cv_struct_tm_has_gmtoff=no
6041             )
6042         ])
6043     fi
6044
6045     if test "$wx_cv_struct_tm_has_gmtoff" = "yes"; then
6046         AC_DEFINE(WX_GMTOFF_IN_TM)
6047     fi
6048
6049     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS typetest"
6050 fi
6051
6052 dnl ------------------------------------------------------------------------
6053 dnl wxSocket
6054 dnl ------------------------------------------------------------------------
6055
6056 dnl VZ: the GUI hooks wxSocket needs are not implemented yet in some toolkits
6057 if test "$wxUSE_SOCKETS" = "yes"; then
6058     if test "$wxUSE_MGL" = 1; then
6059         AC_MSG_WARN([wxSocket not yet supported under MGL... disabled])
6060         wxUSE_SOCKETS="no"
6061     fi
6062 fi
6063
6064 if test "$wxUSE_SOCKETS" = "yes"; then
6065     dnl under MSW we always have sockets
6066     if test "$TOOLKIT" != "MSW"; then
6067         dnl under Solaris and OS/2, socket functions live in -lsocket
6068         AC_CHECK_FUNC(socket,,
6069             [
6070                 AC_CHECK_LIB(socket, socket,
6071                     if test "$INET_LINK" != " -lsocket"; then
6072                         INET_LINK="$INET_LINK -lsocket"
6073                     fi,
6074                     [
6075                         AC_MSG_WARN([socket library not found - sockets will be disabled])
6076                         wxUSE_SOCKETS=no
6077                     ]
6078                 )
6079             ]
6080         )
6081     fi
6082 fi
6083
6084 if test "$wxUSE_SOCKETS" = "yes" ; then
6085     dnl this test may be appropriate if building under cygwin
6086     dnl right now I'm assuming it also uses the winsock stuff
6087     dnl like mingw does..  -- RL
6088     if test "$TOOLKIT" != "MSW"; then
6089         dnl determine the type of third argument for getsockname
6090         dnl This test needs to be done in C++ mode since gsocket.cpp now
6091         dnl is C++ code and pointer cast that are possible even without
6092         dnl warning in C still fail in C++.
6093         AC_CACHE_CHECK([what is the type of the third argument of getsockname],
6094                        wx_cv_type_getsockname3,
6095             [
6096                 AC_LANG_PUSH(C++)
6097                 AC_TRY_COMPILE(
6098                     [
6099                         #include <sys/types.h>
6100                         #include <sys/socket.h>
6101                     ],
6102                     [
6103                         socklen_t len;
6104                         getsockname(0, 0, &len);
6105                     ],
6106                     wx_cv_type_getsockname3=socklen_t,
6107                     [
6108                         dnl the compiler will compile the version with size_t
6109                         dnl even if the real type of the last parameter is int
6110                         dnl but it should give at least a warning about
6111                         dnl converting between incompatible pointer types, so
6112                         dnl try to use it to get the correct behaviour at
6113                         dnl least with gcc (otherwise we'd always use size_t)
6114                         CFLAGS_OLD="$CFLAGS"
6115                         if test "$GCC" = yes ; then
6116                             CFLAGS="-Werror $CFLAGS"
6117                         fi
6118
6119                         AC_TRY_COMPILE(
6120                             [
6121                                 #include <sys/types.h>
6122                                 #include <sys/socket.h>
6123                             ],
6124                             [
6125                                 size_t len;
6126                                 getsockname(0, 0, &len);
6127                             ],
6128                             wx_cv_type_getsockname3=size_t,
6129                             AC_TRY_COMPILE(
6130                                 [
6131                                     #include <sys/types.h>
6132                                     #include <sys/socket.h>
6133                                 ],
6134                                 [
6135                                     int len;
6136                                     getsockname(0, 0, &len);
6137                                 ],
6138                                 wx_cv_type_getsockname3=int,
6139                                 wx_cv_type_getsockname3=unknown
6140                             )
6141                         )
6142
6143                         CFLAGS="$CFLAGS_OLD"
6144                     ]
6145                 )
6146                 AC_LANG_POP()
6147             ])
6148
6149         if test "$wx_cv_type_getsockname3" = "unknown"; then
6150             wxUSE_SOCKETS=no
6151             AC_MSG_WARN([Couldn't find socklen_t synonym for this system])
6152         else
6153             AC_DEFINE_UNQUOTED(WX_SOCKLEN_T, $wx_cv_type_getsockname3)
6154         fi
6155         dnl Do this again for getsockopt as it may be different
6156         AC_CACHE_CHECK([what is the type of the fifth argument of getsockopt],
6157                        wx_cv_type_getsockopt5,
6158             [
6159                 dnl Note that the rules for compatibility of pointers
6160                 dnl are somewhat different between C and C++, so code
6161                 dnl that fails in C++ may not even give a warning about
6162                 dnl converting between incompatible pointer types in C.
6163                 dnl So this test needs to be done in C++ mode.
6164                 AC_LANG_PUSH(C++)
6165                 AC_TRY_COMPILE(
6166                     [
6167                         #include <sys/types.h>
6168                         #include <sys/socket.h>
6169                     ],
6170                     [
6171                         socklen_t len;
6172                         getsockopt(0, 0, 0, 0, &len);
6173                     ],
6174                     wx_cv_type_getsockopt5=socklen_t,
6175                     [
6176                         AC_TRY_COMPILE(
6177                             [
6178                                 #include <sys/types.h>
6179                                 #include <sys/socket.h>
6180                             ],
6181                             [
6182                                 size_t len;
6183                                 getsockopt(0, 0, 0, 0, &len);
6184                             ],
6185                             wx_cv_type_getsockopt5=size_t,
6186                             AC_TRY_COMPILE(
6187                                 [
6188                                     #include <sys/types.h>
6189                                     #include <sys/socket.h>
6190                                 ],
6191                                 [
6192                                     int len;
6193                                     getsockopt(0, 0, 0, 0, &len);
6194                                 ],
6195                                 wx_cv_type_getsockopt5=int,
6196                                 wx_cv_type_getsockopt5=unknown
6197                             )
6198                         )
6199                     ]
6200                 )
6201                 AC_LANG_POP()
6202             ])
6203
6204         if test "$wx_cv_type_getsockopt5" = "unknown"; then
6205             wxUSE_SOCKETS=no
6206             AC_MSG_WARN([Couldn't find socklen_t synonym for this system])
6207         else
6208             AC_DEFINE_UNQUOTED(SOCKOPTLEN_T, $wx_cv_type_getsockopt5)
6209         fi
6210     fi
6211 fi
6212
6213 if test "$wxUSE_SOCKETS" = "yes" ; then
6214     if test "$wxUSE_IPV6" = "yes"; then
6215         AC_CACHE_CHECK(
6216             [whether we have sockaddr_in6],
6217             [wx_cv_type_sockaddr_in6],
6218             [
6219                 AC_TRY_COMPILE(
6220                     [
6221                         #include <sys/types.h>
6222                         #include <sys/socket.h>
6223                         #include <netinet/in.h>
6224                     ],
6225                     [
6226                         struct sockaddr_in6 sa6;
6227                     ],
6228                     wx_cv_type_sockaddr_in6=yes,
6229                     wx_cv_type_sockaddr_in6=no
6230                 )
6231             ]
6232         )
6233
6234         if test "$wx_cv_type_sockaddr_in6"="yes"; then
6235             AC_DEFINE(wxUSE_IPV6)
6236         else
6237             AC_MSG_WARN([IPv6 support not available... disabled])
6238         fi
6239     fi
6240
6241     AC_DEFINE(wxUSE_SOCKETS)
6242     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS sockets"
6243 fi
6244
6245 if test "$wxUSE_PROTOCOL" = "yes"; then
6246     if test "$wxUSE_SOCKETS" != "yes"; then
6247         AC_MSG_WARN(Protocol classes require sockets... disabled)
6248         wxUSE_PROTOCOL=no
6249     fi
6250 fi
6251
6252 if test "$wxUSE_PROTOCOL" = "yes"; then
6253     AC_DEFINE(wxUSE_PROTOCOL)
6254
6255     if test "$wxUSE_PROTOCOL_HTTP" = "yes"; then
6256         AC_DEFINE(wxUSE_PROTOCOL_HTTP)
6257     fi
6258     if test "$wxUSE_PROTOCOL_FTP" = "yes"; then
6259         AC_DEFINE(wxUSE_PROTOCOL_FTP)
6260     fi
6261     if test "$wxUSE_PROTOCOL_FILE" = "yes"; then
6262         AC_DEFINE(wxUSE_PROTOCOL_FILE)
6263     fi
6264 else
6265     if test "$wxUSE_FS_INET" = "yes"; then
6266         AC_MSG_WARN([HTTP filesystem require protocol classes... disabled])
6267         wxUSE_FS_INET="no"
6268     fi
6269 fi
6270
6271 if test "$wxUSE_URL" = "yes"; then
6272     if test "$wxUSE_PROTOCOL" != "yes"; then
6273         AC_MSG_WARN(wxURL class requires wxProtocol... disabled)
6274         wxUSE_URL=no
6275     fi
6276     if test "$wxUSE_URL" = "yes"; then
6277         AC_DEFINE(wxUSE_URL)
6278     fi
6279 fi
6280
6281 if test "$wxUSE_VARIANT" = "yes"; then
6282     AC_DEFINE(wxUSE_VARIANT)
6283 fi
6284
6285 if test "$wxUSE_FS_INET" = "yes"; then
6286   AC_DEFINE(wxUSE_FS_INET)
6287 fi
6288
6289 dnl ---------------------------------------------------------------------------
6290 dnl Joystick support
6291 dnl ---------------------------------------------------------------------------
6292
6293 if test "$wxUSE_GUI" = "yes" -a "$wxUSE_JOYSTICK" = "yes"; then
6294     wxUSE_JOYSTICK=no
6295
6296     dnl under MSW we always have joystick support
6297     if test "$TOOLKIT" = "MSW"; then
6298         wxUSE_JOYSTICK=yes
6299
6300     dnl mac only available on darwin
6301     elif test "$TOOLKIT" = "OSX" -o "$TOOLKIT" = "COCOA"; then
6302         if test "$USE_DARWIN" = 1; then
6303             dnl check for a bug in the headers, some have bad setEventCallout
6304             AC_MSG_CHECKING([headers have declarations needed for joystick support])
6305             AC_LANG_PUSH(C++)
6306             AC_TRY_COMPILE( [ #include <IOKit/hid/IOHIDLib.h> ],
6307                             [ IOHIDQueueInterface *qi = NULL;
6308                               IOHIDCallbackFunction cb = NULL;
6309                               qi->setEventCallout(NULL, cb, NULL, NULL); ],
6310                             [ wxUSE_JOYSTICK=yes ]
6311                           )
6312             AC_LANG_POP()
6313             AC_MSG_RESULT($wxUSE_JOYSTICK)
6314         fi
6315
6316     dnl joystick support is only for Linux 2.1.x or greater
6317     else
6318         dnl wxJoystick not supported by wxMGL at all
6319         if test "$wxUSE_MGL" != 1; then
6320             dnl notice the dummy includes argument: without it, AC_CHECK_HEADER
6321             dnl checks only whether the header can be preprocessed, not that it
6322             dnl can be compiled and in Linux 2.6.16 joystick.h is present but
6323             dnl can't be compiled because of an error and with the default
6324             dnl AC_CHECK_HEADER semantics we'd still detect it in this case and
6325             dnl build would fail later
6326             AC_CHECK_HEADERS([linux/joystick.h], [wxUSE_JOYSTICK=yes],, [AC_INCLUDES_DEFAULT()])
6327         fi
6328     fi
6329
6330     if test "$wxUSE_JOYSTICK" = "yes"; then
6331         AC_DEFINE(wxUSE_JOYSTICK)
6332         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS joytest"
6333     else
6334         AC_MSG_WARN(Joystick not supported by this system... disabled)
6335     fi
6336 fi
6337
6338
6339 dnl ---------------------------------------------------------------------------
6340 dnl String stuff
6341 dnl ---------------------------------------------------------------------------
6342
6343 if test "$wxUSE_FONTENUM" = "yes" ; then
6344   AC_DEFINE(wxUSE_FONTENUM)
6345 fi
6346
6347 if test "$wxUSE_FONTMAP" = "yes" ; then
6348   AC_DEFINE(wxUSE_FONTMAP)
6349 fi
6350
6351 if test "$wxUSE_UNICODE" = "yes" ; then
6352   AC_DEFINE(wxUSE_UNICODE)
6353
6354   if test "$USE_WIN32" != 1; then
6355       wxUSE_UNICODE_MSLU=no
6356   fi
6357
6358   if test "$USE_WIN32" = 1 -a "$wxUSE_UNICODE_MSLU" = "yes"; then
6359         AC_CHECK_LIB(unicows,main,
6360             [
6361                 AC_DEFINE(wxUSE_UNICODE_MSLU)
6362             ],
6363             [
6364                 AC_MSG_WARN([Compiler doesn't support MSLU (libunicows.a), disabled.
6365                              Applications will only run on Windows NT/2000/XP!])
6366                 wxUSE_UNICODE_MSLU=no
6367             ])
6368     fi
6369 fi
6370
6371 if test "$wxUSE_UNICODE" = "yes" -a "$wxUSE_UNICODE_UTF8" = "yes"; then
6372     AC_DEFINE(wxUSE_UNICODE_UTF8)
6373
6374     if test "$wxUSE_UNICODE_UTF8_LOCALE" = "yes"; then
6375         AC_DEFINE(wxUSE_UTF8_LOCALE_ONLY)
6376     fi
6377 fi
6378
6379 dnl ---------------------------------------------------------------------------
6380 dnl big GUI components: MDI, doc/view, printing, help, ...
6381 dnl ---------------------------------------------------------------------------
6382
6383 if test "$wxUSE_CONSTRAINTS" = "yes"; then
6384     AC_DEFINE(wxUSE_CONSTRAINTS)
6385     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS layout"
6386 fi
6387
6388 if test "$wxUSE_MDI" = "yes"; then
6389     AC_DEFINE(wxUSE_MDI)
6390
6391     if test "$wxUSE_MDI_ARCHITECTURE" = "yes"; then
6392         AC_DEFINE(wxUSE_MDI_ARCHITECTURE)
6393         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS mdi"
6394     fi
6395 fi
6396
6397 if test "$wxUSE_DOC_VIEW_ARCHITECTURE" = "yes" ; then
6398     AC_DEFINE(wxUSE_DOC_VIEW_ARCHITECTURE)
6399     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS docview"
6400 fi
6401
6402 if test "$wxUSE_HELP" = "yes"; then
6403     AC_DEFINE(wxUSE_HELP)
6404     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS help"
6405
6406     if test "$wxUSE_MSW" = 1; then
6407       if test "$wxUSE_MS_HTML_HELP" = "yes"; then
6408         AC_DEFINE(wxUSE_MS_HTML_HELP)
6409       fi
6410     fi
6411
6412     if test "$wxUSE_WXHTML_HELP" = "yes"; then
6413       if test "$wxUSE_HTML" = "yes"; then
6414         AC_DEFINE(wxUSE_WXHTML_HELP)
6415       else
6416         AC_MSG_WARN(Cannot use wxHTML-based help without wxHTML so it won't be compiled)
6417         wxUSE_WXHTML_HELP=no
6418       fi
6419     fi
6420 fi
6421
6422 if test "$wxUSE_PRINTING_ARCHITECTURE" = "yes" ; then
6423     AC_DEFINE(wxUSE_PRINTING_ARCHITECTURE)
6424     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS printing"
6425 fi
6426
6427 if test "$wxUSE_POSTSCRIPT" = "yes" ; then
6428   AC_DEFINE(wxUSE_POSTSCRIPT)
6429 fi
6430
6431 AC_DEFINE(wxUSE_AFM_FOR_POSTSCRIPT)
6432
6433 if test "$wxUSE_SVG" = "yes"; then
6434     AC_DEFINE(wxUSE_SVG)
6435 fi
6436
6437 dnl ---------------------------------------------------------------------------
6438 dnl wxMetafile availability
6439 dnl ---------------------------------------------------------------------------
6440
6441 if test "$wxUSE_METAFILE" = "yes"; then
6442     if test "$wxUSE_MSW" != 1 -a "$wxUSE_MAC" != 1 -a "$wxUSE_PM" != 1; then
6443         AC_MSG_WARN([wxMetafile is not available on this system... disabled])
6444         wxUSE_METAFILE=no
6445     fi
6446 fi
6447
6448 dnl ---------------------------------------------------------------------------
6449 dnl IPC: IPC, Drag'n'Drop, Clipboard, ...
6450 dnl ---------------------------------------------------------------------------
6451
6452 dnl check for ole headers and disable a few features requiring it if not
6453 dnl present (earlier versions of mingw32 don't have ole2.h)
6454 if test "$USE_WIN32" = 1 -a \( "$wxUSE_DATAOBJ"       = "yes" \
6455                           -o "$wxUSE_CLIPBOARD"     = "yes" \
6456                           -o "$wxUSE_OLE"     = "yes" \
6457                           -o "$wxUSE_DRAG_AND_DROP" = "yes" \) ; then
6458     AC_CHECK_HEADER(ole2.h,,, [ ])
6459
6460     if test "$ac_cv_header_ole2_h" = "yes" ; then
6461         if test "$GCC" = yes ; then
6462             AC_MSG_CHECKING([if g++ requires -fvtable-thunks])
6463             AC_TRY_COMPILE([#include <windows.h>
6464                             #include <ole2.h>],
6465                            [],
6466                            [AC_MSG_RESULT(no)],
6467                            [AC_MSG_RESULT(yes)
6468                             WXCONFIG_CXXFLAGS="$WXCONFIG_CXXFLAGS -fvtable-thunks"])
6469             LIBS=" -lrpcrt4 -loleaut32 -lole32 -luuid$LIBS"
6470             if test "$wxUSE_OLE" = "yes" ; then
6471                 AC_DEFINE(wxUSE_OLE)
6472                 AC_DEFINE(wxUSE_OLE_AUTOMATION)
6473                 AC_DEFINE(wxUSE_ACTIVEX)
6474                 SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS oleauto"
6475             fi
6476         fi
6477
6478         dnl for OLE clipboard and dnd
6479         if test "$wxUSE_DATAOBJ" = "yes" ; then
6480             AC_DEFINE(wxUSE_DATAOBJ)
6481         fi
6482     else
6483         AC_MSG_WARN([Some features disabled because OLE headers not found])
6484
6485         wxUSE_CLIPBOARD=no
6486         wxUSE_DRAG_AND_DROP=no
6487         wxUSE_DATAOBJ=no
6488         wxUSE_OLE=no
6489     fi
6490
6491     if test "$wxUSE_METAFILE" = "yes"; then
6492         AC_DEFINE(wxUSE_METAFILE)
6493
6494         dnl this one should probably be made separately configurable
6495         AC_DEFINE(wxUSE_ENH_METAFILE)
6496     fi
6497 fi
6498
6499 if test "$wxUSE_IPC" = "yes"; then
6500     if test "$wxUSE_SOCKETS" != "yes" -a "$USE_WIN32" != 1; then
6501         AC_MSG_WARN(wxWidgets IPC classes require sockets... disabled)
6502         wxUSE_IPC=no
6503     fi
6504
6505     if test "$wxUSE_IPC" = "yes"; then
6506         AC_DEFINE(wxUSE_IPC)
6507         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS ipc"
6508     fi
6509 fi
6510
6511 if test "$wxUSE_DATAOBJ" = "yes"; then
6512     if test "$wxUSE_MGL" = 1 -o "$wxUSE_DFB" = 1; then
6513         AC_MSG_WARN([wxDataObject not yet supported under $TOOLKIT... disabled])
6514         wxUSE_DATAOBJ=no
6515     else
6516         AC_DEFINE(wxUSE_DATAOBJ)
6517     fi
6518 else
6519     AC_MSG_WARN([Clipboard and drag-and-drop require wxDataObject -- disabled])
6520     wxUSE_CLIPBOARD=no
6521     wxUSE_DRAG_AND_DROP=no
6522 fi
6523
6524 if test "$wxUSE_CLIPBOARD" = "yes"; then
6525     if test "$wxUSE_MGL" = 1 -o "$wxUSE_DFB" = 1; then
6526         AC_MSG_WARN([Clipboard not yet supported under $TOOLKIT... disabled])
6527         wxUSE_CLIPBOARD=no
6528     fi
6529
6530     if test "$wxUSE_CLIPBOARD" = "yes"; then
6531         AC_DEFINE(wxUSE_CLIPBOARD)
6532     fi
6533 fi
6534
6535 if test "$wxUSE_DRAG_AND_DROP" = "yes" ; then
6536     if test "$wxUSE_GTK" = 1; then
6537         if test "$WXGTK12" != 1; then
6538             AC_MSG_WARN([Drag and drop is only supported under GTK+ 1.2... disabled])
6539             wxUSE_DRAG_AND_DROP=no
6540         fi
6541     fi
6542
6543     if test "$wxUSE_MOTIF" = 1 -o "$wxUSE_X11" = 1 -o "$wxUSE_MGL" = 1 -o \
6544             "$wxUSE_DFB" = 1; then
6545         AC_MSG_WARN([Drag and drop not yet supported under $TOOLKIT... disabled])
6546         wxUSE_DRAG_AND_DROP=no
6547     fi
6548
6549     if test "$wxUSE_DRAG_AND_DROP" = "yes"; then
6550         AC_DEFINE(wxUSE_DRAG_AND_DROP)
6551     fi
6552
6553 fi
6554
6555 if test "$wxUSE_DRAG_AND_DROP" = "yes" -o "$wxUSE_CLIPBOARD" = "yes"; then
6556     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS dnd"
6557 fi
6558
6559 if test "$wxUSE_CLIPBOARD" = "yes"; then
6560     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS clipboard"
6561 fi
6562
6563 if test "$wxUSE_SPLINES" = "yes" ; then
6564   AC_DEFINE(wxUSE_SPLINES)
6565 fi
6566
6567 if test "$wxUSE_MOUSEWHEEL" = "yes" ; then
6568   AC_DEFINE(wxUSE_MOUSEWHEEL)
6569 fi
6570
6571 dnl ---------------------------------------------------------------------------
6572 dnl GUI controls
6573 dnl ---------------------------------------------------------------------------
6574
6575 USES_CONTROLS=0
6576 if test "$wxUSE_CONTROLS" = "yes"; then
6577   USES_CONTROLS=1
6578 fi
6579
6580 if test "$wxUSE_ACCEL" = "yes"; then
6581   AC_DEFINE(wxUSE_ACCEL)
6582   USES_CONTROLS=1
6583 fi
6584
6585 if test "$wxUSE_ANIMATIONCTRL" = "yes"; then
6586   AC_DEFINE(wxUSE_ANIMATIONCTRL)
6587   USES_CONTROLS=1
6588   SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS animate"
6589 fi
6590
6591 if test "$wxUSE_BUTTON" = "yes"; then
6592   AC_DEFINE(wxUSE_BUTTON)
6593   USES_CONTROLS=1
6594 fi
6595
6596 if test "$wxUSE_BMPBUTTON" = "yes"; then
6597   AC_DEFINE(wxUSE_BMPBUTTON)
6598   USES_CONTROLS=1
6599 fi
6600
6601 if test "$wxUSE_CALCTRL" = "yes"; then
6602   AC_DEFINE(wxUSE_CALENDARCTRL)
6603   USES_CONTROLS=1
6604   SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS calendar"
6605 fi
6606
6607 if test "$wxUSE_CARET" = "yes"; then
6608   AC_DEFINE(wxUSE_CARET)
6609   USES_CONTROLS=1
6610   SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS caret"
6611 fi
6612
6613 if test "$wxUSE_COLLPANE" = "yes"; then
6614     AC_DEFINE(wxUSE_COLLPANE)
6615     USES_CONTROLS=1
6616     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS collpane"
6617 fi
6618
6619 if test "$wxUSE_COMBOBOX" = "yes"; then
6620   AC_DEFINE(wxUSE_COMBOBOX)
6621   USES_CONTROLS=1
6622 fi
6623
6624 if test "$wxUSE_COMBOCTRL" = "yes"; then
6625   AC_DEFINE(wxUSE_COMBOCTRL)
6626   USES_CONTROLS=1
6627 fi
6628
6629 if test "$wxUSE_CHOICE" = "yes"; then
6630   AC_DEFINE(wxUSE_CHOICE)
6631   USES_CONTROLS=1
6632 fi
6633
6634 if test "$wxUSE_CHOICEBOOK" = "yes"; then
6635     AC_DEFINE(wxUSE_CHOICEBOOK)
6636     USES_CONTROLS=1
6637 fi
6638
6639 if test "$wxUSE_CHECKBOX" = "yes"; then
6640   AC_DEFINE(wxUSE_CHECKBOX)
6641   USES_CONTROLS=1
6642 fi
6643
6644 if test "$wxUSE_CHECKLST" = "yes"; then
6645   AC_DEFINE(wxUSE_CHECKLISTBOX)
6646   USES_CONTROLS=1
6647 fi
6648
6649 if test "$wxUSE_COLOURPICKERCTRL" = "yes"; then
6650   AC_DEFINE(wxUSE_COLOURPICKERCTRL)
6651   USES_CONTROLS=1
6652 fi
6653
6654 if test "$wxUSE_DATEPICKCTRL" = "yes"; then
6655   AC_DEFINE(wxUSE_DATEPICKCTRL)
6656   USES_CONTROLS=1
6657 fi
6658
6659 if test "$wxUSE_DIRPICKERCTRL" = "yes"; then
6660   AC_DEFINE(wxUSE_DIRPICKERCTRL)
6661   USES_CONTROLS=1
6662 fi
6663
6664 if test "$wxUSE_FILECTRL" = "yes"; then
6665   AC_DEFINE(wxUSE_FILECTRL)
6666   USES_CONTROLS=1
6667 fi
6668
6669 if test "$wxUSE_FILEPICKERCTRL" = "yes"; then
6670   AC_DEFINE(wxUSE_FILEPICKERCTRL)
6671   USES_CONTROLS=1
6672 fi
6673
6674 if test "$wxUSE_FONTPICKERCTRL" = "yes"; then
6675   AC_DEFINE(wxUSE_FONTPICKERCTRL)
6676   USES_CONTROLS=1
6677 fi
6678
6679 if test "$wxUSE_DISPLAY" = "yes"; then
6680     if test "$wxUSE_DFB" = 1 -o "$wxUSE_MGL" = 1; then
6681         AC_MSG_WARN([wxDisplay not yet supported under $TOOLKIT... disabled])
6682         wxUSE_DISPLAY=no
6683     else
6684         AC_DEFINE(wxUSE_DISPLAY)
6685         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS display"
6686     fi
6687 fi
6688
6689 if test "$wxUSE_DETECT_SM" = "yes"; then
6690     AC_DEFINE(wxUSE_DETECT_SM)
6691 fi
6692
6693 if test "$wxUSE_GAUGE" = "yes"; then
6694   AC_DEFINE(wxUSE_GAUGE)
6695   USES_CONTROLS=1
6696 fi
6697
6698 if test "$wxUSE_GRID" = "yes"; then
6699   AC_DEFINE(wxUSE_GRID)
6700   USES_CONTROLS=1
6701   SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS grid"
6702 fi
6703
6704 if test "$wxUSE_HEADERCTRL" = "yes"; then
6705   AC_DEFINE(wxUSE_HEADERCTRL)
6706   USES_CONTROLS=1
6707 fi
6708
6709 if test "$wxUSE_HYPERLINKCTRL" = "yes"; then
6710   AC_DEFINE(wxUSE_HYPERLINKCTRL)
6711   USES_CONTROLS=1
6712 fi
6713
6714 if test "$wxUSE_BITMAPCOMBOBOX" = "yes"; then
6715   AC_DEFINE(wxUSE_BITMAPCOMBOBOX)
6716   USES_CONTROLS=1
6717 fi
6718
6719 if test "$wxUSE_DATAVIEWCTRL" = "yes"; then
6720   AC_DEFINE(wxUSE_DATAVIEWCTRL)
6721   USES_CONTROLS=1
6722   SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS dataview"
6723 fi
6724
6725 if test "$wxUSE_IMAGLIST" = "yes"; then
6726     AC_DEFINE(wxUSE_IMAGLIST)
6727 fi
6728
6729 if test "$wxUSE_INFOBAR" = "yes"; then
6730     AC_DEFINE(wxUSE_INFOBAR)
6731 fi
6732
6733 if test "$wxUSE_LISTBOOK" = "yes"; then
6734     AC_DEFINE(wxUSE_LISTBOOK)
6735     USES_CONTROLS=1
6736 fi
6737
6738 if test "$wxUSE_LISTBOX" = "yes"; then
6739     AC_DEFINE(wxUSE_LISTBOX)
6740     USES_CONTROLS=1
6741 fi
6742
6743 if test "$wxUSE_LISTCTRL" = "yes"; then
6744     if test "$wxUSE_IMAGLIST" = "yes"; then
6745         AC_DEFINE(wxUSE_LISTCTRL)
6746         USES_CONTROLS=1
6747         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS listctrl"
6748     else
6749         AC_MSG_WARN([wxListCtrl requires wxImageList and won't be compiled without it])
6750     fi
6751 fi
6752
6753 if test "$wxUSE_EDITABLELISTBOX" = "yes"; then
6754     AC_DEFINE(wxUSE_EDITABLELISTBOX)
6755     USES_CONTROLS=1
6756 fi
6757
6758 if test "$wxUSE_NOTEBOOK" = "yes"; then
6759     AC_DEFINE(wxUSE_NOTEBOOK)
6760     USES_CONTROLS=1
6761     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS notebook"
6762 fi
6763
6764 if test "$wxUSE_NOTIFICATION_MESSAGE" = "yes"; then
6765     AC_DEFINE(wxUSE_NOTIFICATION_MESSAGE)
6766 fi
6767
6768 if test "$wxUSE_ODCOMBOBOX" = "yes"; then
6769   AC_DEFINE(wxUSE_ODCOMBOBOX)
6770   USES_CONTROLS=1
6771   SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS combo"
6772 fi
6773
6774 if test "$wxUSE_RADIOBOX" = "yes"; then
6775     AC_DEFINE(wxUSE_RADIOBOX)
6776     USES_CONTROLS=1
6777 fi
6778
6779 if test "$wxUSE_RADIOBTN" = "yes"; then
6780     AC_DEFINE(wxUSE_RADIOBTN)
6781     USES_CONTROLS=1
6782 fi
6783
6784 if test "$wxUSE_REARRANGECTRL" = "yes"; then
6785     AC_DEFINE(wxUSE_REARRANGECTRL)
6786 fi
6787
6788 if test "$wxUSE_SASH" = "yes"; then
6789     AC_DEFINE(wxUSE_SASH)
6790     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS sashtest"
6791 fi
6792
6793 if test "$wxUSE_SCROLLBAR" = "yes"; then
6794     AC_DEFINE(wxUSE_SCROLLBAR)
6795     USES_CONTROLS=1
6796     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS scroll"
6797 fi
6798
6799 if test "$wxUSE_SEARCHCTRL" = "yes"; then
6800     AC_DEFINE(wxUSE_SEARCHCTRL)
6801     USES_CONTROLS=1
6802 fi
6803
6804 if test "$wxUSE_SLIDER" = "yes"; then
6805     AC_DEFINE(wxUSE_SLIDER)
6806     USES_CONTROLS=1
6807 fi
6808
6809 if test "$wxUSE_SPINBTN" = "yes"; then
6810     AC_DEFINE(wxUSE_SPINBTN)
6811     USES_CONTROLS=1
6812 fi
6813
6814 if test "$wxUSE_SPINCTRL" = "yes"; then
6815     AC_DEFINE(wxUSE_SPINCTRL)
6816     USES_CONTROLS=1
6817 fi
6818
6819 if test "$wxUSE_SPLITTER" = "yes"; then
6820     AC_DEFINE(wxUSE_SPLITTER)
6821     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS splitter"
6822 fi
6823
6824 if test "$wxUSE_STATBMP" = "yes"; then
6825     AC_DEFINE(wxUSE_STATBMP)
6826     USES_CONTROLS=1
6827 fi
6828
6829 if test "$wxUSE_STATBOX" = "yes"; then
6830     AC_DEFINE(wxUSE_STATBOX)
6831     USES_CONTROLS=1
6832 fi
6833
6834 if test "$wxUSE_STATTEXT" = "yes"; then
6835     AC_DEFINE(wxUSE_STATTEXT)
6836     USES_CONTROLS=1
6837 fi
6838
6839 if test "$wxUSE_STATLINE" = "yes"; then
6840     AC_DEFINE(wxUSE_STATLINE)
6841     USES_CONTROLS=1
6842 fi
6843
6844 if test "$wxUSE_STATUSBAR" = "yes"; then
6845     dnl this will get undefined in wx/chkconf.h if it's not supported
6846     AC_DEFINE(wxUSE_NATIVE_STATUSBAR)
6847     AC_DEFINE(wxUSE_STATUSBAR)
6848     USES_CONTROLS=1
6849
6850     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS statbar"
6851 fi
6852
6853 if test "$wxUSE_TEXTCTRL" = "yes"; then
6854     AC_DEFINE(wxUSE_TEXTCTRL)
6855     USES_CONTROLS=1
6856     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS text"
6857
6858     dnl we don't have special switches to disable wxUSE_RICHEDIT[2], it doesn't
6859     dnl seem useful to allow disabling them
6860     AC_DEFINE(wxUSE_RICHEDIT)
6861     AC_DEFINE(wxUSE_RICHEDIT2)
6862 fi
6863
6864 if test "$wxUSE_TOGGLEBTN" = "yes"; then
6865     if test "$wxUSE_COCOA" = 1 ; then
6866         AC_MSG_WARN([Toggle button not yet supported under Mac OS X... disabled])
6867         wxUSE_TOGGLEBTN=no
6868     fi
6869
6870     if test "$wxUSE_TOGGLEBTN" = "yes"; then
6871         AC_DEFINE(wxUSE_TOGGLEBTN)
6872         USES_CONTROLS=1
6873     fi
6874 fi
6875
6876 if test "$wxUSE_TOOLBAR" = "yes"; then
6877     AC_DEFINE(wxUSE_TOOLBAR)
6878     USES_CONTROLS=1
6879
6880     if test "$wxUSE_UNIVERSAL" = "yes"; then
6881         wxUSE_TOOLBAR_NATIVE="no"
6882     else
6883         wxUSE_TOOLBAR_NATIVE="yes"
6884         AC_DEFINE(wxUSE_TOOLBAR_NATIVE)
6885     fi
6886
6887     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS toolbar"
6888 fi
6889
6890 if test "$wxUSE_TOOLTIPS" = "yes"; then
6891     if test "$wxUSE_MOTIF" = 1; then
6892         AC_MSG_WARN([wxTooltip not supported yet under Motif... disabled])
6893     else
6894         if test "$wxUSE_UNIVERSAL" = "yes"; then
6895             AC_MSG_WARN([wxTooltip not supported yet in wxUniversal... disabled])
6896         else
6897             AC_DEFINE(wxUSE_TOOLTIPS)
6898         fi
6899     fi
6900 fi
6901
6902 if test "$wxUSE_TREEBOOK" = "yes"; then
6903     AC_DEFINE(wxUSE_TREEBOOK)
6904     USES_CONTROLS=1
6905 fi
6906
6907 if test "$wxUSE_TOOLBOOK" = "yes"; then
6908     AC_DEFINE(wxUSE_TOOLBOOK)
6909     USES_CONTROLS=1
6910 fi
6911
6912 if test "$wxUSE_TREECTRL" = "yes"; then
6913     if test "$wxUSE_IMAGLIST" = "yes"; then
6914         AC_DEFINE(wxUSE_TREECTRL)
6915         USES_CONTROLS=1
6916         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS treectrl"
6917     else
6918         AC_MSG_WARN([wxTreeCtrl requires wxImageList and won't be compiled without it])
6919     fi
6920 fi
6921
6922 if test "$wxUSE_POPUPWIN" = "yes"; then
6923     if test "$wxUSE_COCOA" = 1 ; then
6924         AC_MSG_WARN([Popup window not yet supported under Mac OS X... disabled])
6925     else
6926         if test "$wxUSE_PM" = 1; then
6927             AC_MSG_WARN([wxPopupWindow not yet supported under PM... disabled])
6928         else
6929             AC_DEFINE(wxUSE_POPUPWIN)
6930             SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS popup"
6931
6932             USES_CONTROLS=1
6933         fi
6934     fi
6935 fi
6936
6937 if test "$wxUSE_DIALUP_MANAGER" = "yes"; then
6938     if test "$wxUSE_MAC" = 1 -o "$wxUSE_COCOA" = 1 -o "$wxUSE_MGL" = 1; then
6939         AC_MSG_WARN([Dialup manager not supported on this platform... disabled])
6940     else
6941         AC_DEFINE(wxUSE_DIALUP_MANAGER)
6942         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS dialup"
6943     fi
6944 fi
6945
6946 if test "$wxUSE_TIPWINDOW" = "yes"; then
6947     if test "$wxUSE_PM" = 1; then
6948         AC_MSG_WARN([wxTipWindow not yet supported under PM... disabled])
6949     else
6950         AC_DEFINE(wxUSE_TIPWINDOW)
6951     fi
6952 fi
6953
6954 if test "$USES_CONTROLS" = 1; then
6955     AC_DEFINE(wxUSE_CONTROLS)
6956 fi
6957
6958 dnl ---------------------------------------------------------------------------
6959 dnl misc options
6960 dnl ---------------------------------------------------------------------------
6961
6962 dnl please keep the settings below in alphabetical order
6963 if test "$wxUSE_ACCESSIBILITY" = "yes"; then
6964     AC_DEFINE(wxUSE_ACCESSIBILITY)
6965     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS access"
6966 fi
6967
6968 if test "$wxUSE_DRAGIMAGE" = "yes"; then
6969     AC_DEFINE(wxUSE_DRAGIMAGE)
6970     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS dragimag"
6971 fi
6972
6973 if test "$wxUSE_EXCEPTIONS" = "yes"; then
6974     if test "$wxUSE_NO_EXCEPTIONS" = "yes" ; then
6975         AC_MSG_WARN([--enable-exceptions can't be used with --enable-no_exceptions])
6976     else
6977         AC_DEFINE(wxUSE_EXCEPTIONS)
6978         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS except"
6979     fi
6980 fi
6981
6982 USE_HTML=0
6983 if test "$wxUSE_HTML" = "yes"; then
6984     AC_DEFINE(wxUSE_HTML)
6985     USE_HTML=1
6986     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS html html/about html/help html/helpview html/printing html/test html/virtual html/widget html/zip htlbox"
6987 fi
6988 if test "$wxUSE_WEBKIT" = "yes"; then
6989     if test "$wxUSE_MAC" = 1 -a "$USE_DARWIN" = 1; then
6990         old_CPPFLAGS="$CPPFLAGS"
6991         CPPFLAGS="-x objective-c++ $CPPFLAGS"
6992         AC_CHECK_HEADER([WebKit/HIWebView.h],
6993                         [
6994                            AC_DEFINE(wxUSE_WEBKIT)
6995                            WEBKIT_LINK="-framework WebKit"
6996                         ],
6997                         [
6998                            AC_MSG_WARN([WebKit headers not found; disabling wxWebKit])
6999                            wxUSE_WEBKIT=no
7000                         ],
7001                         [
7002                            #include <Carbon/Carbon.h>
7003                            #include <WebKit/WebKit.h>
7004                         ])
7005         CPPFLAGS="$old_CPPFLAGS"
7006     elif test "$wxUSE_COCOA" = 1; then
7007         AC_DEFINE(wxUSE_WEBKIT)
7008     else
7009         wxUSE_WEBKIT=no
7010     fi
7011     if test "$wxUSE_WEBKIT" = "yes"; then
7012         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS html/htmlctrl"
7013     fi
7014 fi
7015
7016 USE_XRC=0
7017 if test "$wxUSE_XRC" = "yes"; then
7018     if test "$wxUSE_XML" != "yes"; then
7019         AC_MSG_WARN([XML library not built, XRC resources disabled])
7020         wxUSE_XRC=no
7021     else
7022         AC_DEFINE(wxUSE_XRC)
7023         USE_XRC=1
7024         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS xrc"
7025     fi
7026 fi
7027
7028 USE_AUI=0
7029 if test "$wxUSE_AUI" = "yes"; then
7030    AC_DEFINE(wxUSE_AUI)
7031    USE_AUI=1
7032    SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS aui"
7033 fi
7034
7035 USE_PROPGRID=0
7036 if test "$wxUSE_PROPGRID" = "yes"; then
7037    AC_DEFINE(wxUSE_PROPGRID)
7038    USE_PROPGRID=1
7039    SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS propgrid"
7040 fi
7041
7042 USE_RIBBON=0
7043 if test "$wxUSE_RIBBON" = "yes"; then
7044    AC_DEFINE(wxUSE_RIBBON)
7045    USE_RIBBON=1
7046    SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS ribbon"
7047 fi
7048
7049 USE_STC=0
7050 if test "$wxUSE_STC" = "yes"; then
7051    AC_DEFINE(wxUSE_STC)
7052    USE_STC=1
7053    SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS stc"
7054
7055    dnl python is used to update src/stc.h (see build/bakefiles/scintilla.bkl)
7056    AC_PATH_PROG(PYTHON, python)
7057    if test "x$PYTHON" = "x"; then
7058      COND_PYTHON="#"
7059    fi
7060    AC_SUBST(COND_PYTHON)
7061 fi
7062
7063 if test "$wxUSE_MENUS" = "yes"; then
7064     AC_DEFINE(wxUSE_MENUS)
7065     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS menu"
7066 fi
7067
7068 if test "$wxUSE_METAFILE" = "yes"; then
7069     AC_DEFINE(wxUSE_METAFILE)
7070 fi
7071
7072 if test "$wxUSE_MIMETYPE" = "yes"; then
7073     AC_DEFINE(wxUSE_MIMETYPE)
7074 fi
7075
7076 if test "$wxUSE_MINIFRAME" = "yes"; then
7077     AC_DEFINE(wxUSE_MINIFRAME)
7078 fi
7079
7080 if test "$wxUSE_SYSTEM_OPTIONS" = "yes"; then
7081     AC_DEFINE(wxUSE_SYSTEM_OPTIONS)
7082 fi
7083
7084 if test "$wxUSE_TASKBARICON" = "yes"; then
7085     AC_DEFINE(wxUSE_TASKBARICON)
7086     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS taskbar"
7087 fi
7088
7089
7090 if test "$wxUSE_VALIDATORS" = "yes"; then
7091     AC_DEFINE(wxUSE_VALIDATORS)
7092     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS validate"
7093 fi
7094
7095 if test "$wxUSE_PALETTE" = "yes" ; then
7096     if test "$wxUSE_DFB" = 1; then
7097         AC_MSG_WARN([wxPalette not yet supported under DFB... disabled])
7098         wxUSE_PALETTE=no
7099     else
7100         AC_DEFINE(wxUSE_PALETTE)
7101     fi
7102 fi
7103
7104 if test "$wxUSE_UNICODE" = "yes" -a "$wxUSE_UNICODE_MSLU" = "yes" ; then
7105   dnl Must be done this late because -lunicows must be before all the other libs
7106   LIBS=" -lunicows $LIBS"
7107 fi
7108
7109 USE_RICHTEXT=0
7110 if test "$wxUSE_RICHTEXT" = "yes"; then
7111     AC_DEFINE(wxUSE_RICHTEXT)
7112     USE_RICHTEXT=1
7113     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS richtext"
7114 fi
7115
7116 dnl ---------------------------------------------------------------------------
7117 dnl wxImage options
7118 dnl ---------------------------------------------------------------------------
7119
7120 if test "$wxUSE_IMAGE" = "yes" ; then
7121     AC_DEFINE(wxUSE_IMAGE)
7122
7123     if test "$wxUSE_GIF" = "yes" ; then
7124       AC_DEFINE(wxUSE_GIF)
7125     fi
7126
7127     if test "$wxUSE_PCX" = "yes" ; then
7128       AC_DEFINE(wxUSE_PCX)
7129     fi
7130
7131     if test "$wxUSE_TGA" = "yes" ; then
7132       AC_DEFINE(wxUSE_TGA)
7133     fi
7134
7135     if test "$wxUSE_IFF" = "yes" ; then
7136       AC_DEFINE(wxUSE_IFF)
7137     fi
7138
7139     if test "$wxUSE_PNM" = "yes" ; then
7140       AC_DEFINE(wxUSE_PNM)
7141     fi
7142
7143     if test "$wxUSE_XPM" = "yes" ; then
7144       AC_DEFINE(wxUSE_XPM)
7145     fi
7146
7147     if test "$wxUSE_ICO_CUR" = "yes" ; then
7148       AC_DEFINE(wxUSE_ICO_CUR)
7149     fi
7150 fi
7151
7152 dnl ---------------------------------------------------------------------------
7153 dnl common dialogs
7154 dnl ---------------------------------------------------------------------------
7155
7156 if test "$wxUSE_ABOUTDLG" = "yes"; then
7157     AC_DEFINE(wxUSE_ABOUTDLG)
7158 fi
7159
7160 if test "$wxUSE_CHOICEDLG" = "yes"; then
7161     AC_DEFINE(wxUSE_CHOICEDLG)
7162 fi
7163
7164 if test "$wxUSE_COLOURDLG" = "yes"; then
7165     AC_DEFINE(wxUSE_COLOURDLG)
7166 fi
7167
7168 if test "$wxUSE_FILEDLG" = "yes"; then
7169     AC_DEFINE(wxUSE_FILEDLG)
7170 fi
7171
7172 if test "$wxUSE_FINDREPLDLG" = "yes"; then
7173     AC_DEFINE(wxUSE_FINDREPLDLG)
7174 fi
7175
7176 if test "$wxUSE_FONTDLG" = "yes"; then
7177     AC_DEFINE(wxUSE_FONTDLG)
7178 fi
7179
7180 if test "$wxUSE_DIRDLG" = "yes"; then
7181     if test "$wxUSE_TREECTRL" != "yes"; then
7182         AC_MSG_WARN(wxDirDialog requires wxTreeCtrl so it won't be compiled without it)
7183     else
7184         AC_DEFINE(wxUSE_DIRDLG)
7185     fi
7186 fi
7187
7188 if test "$wxUSE_MSGDLG" = "yes"; then
7189     AC_DEFINE(wxUSE_MSGDLG)
7190 fi
7191
7192 if test "$wxUSE_NUMBERDLG" = "yes"; then
7193     AC_DEFINE(wxUSE_NUMBERDLG)
7194 fi
7195
7196 if test "$wxUSE_PROGRESSDLG" = "yes"; then
7197     AC_DEFINE(wxUSE_PROGRESSDLG)
7198 fi
7199
7200 if test "$wxUSE_SPLASH" = "yes"; then
7201     AC_DEFINE(wxUSE_SPLASH)
7202     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS splash"
7203 fi
7204
7205 if test "$wxUSE_STARTUP_TIPS" = "yes"; then
7206     AC_DEFINE(wxUSE_STARTUP_TIPS)
7207 fi
7208
7209 if test "$wxUSE_TEXTDLG" = "yes"; then
7210     AC_DEFINE(wxUSE_TEXTDLG)
7211 fi
7212
7213 if test "$wxUSE_WIZARDDLG" = "yes"; then
7214     AC_DEFINE(wxUSE_WIZARDDLG)
7215     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS wizard"
7216 fi
7217
7218 dnl ---------------------------------------------------------------------------
7219 dnl options used under wxMSW and wxPM
7220 dnl ---------------------------------------------------------------------------
7221
7222 if test "$wxUSE_MSW" = 1 -o "$wxUSE_PM" = 1; then
7223     if test "$wxUSE_OWNER_DRAWN" = "yes"; then
7224         AC_DEFINE(wxUSE_OWNER_DRAWN)
7225     fi
7226 fi
7227
7228 dnl ---------------------------------------------------------------------------
7229 dnl wxMSW-only options
7230 dnl ---------------------------------------------------------------------------
7231
7232 if test "$wxUSE_MSW" = 1 ; then
7233
7234     if test "$wxUSE_DC_CACHEING" = "yes"; then
7235         AC_DEFINE(wxUSE_DC_CACHEING)
7236     fi
7237
7238     if test "$wxUSE_DIB" = "yes"; then
7239         AC_DEFINE(wxUSE_WXDIB)
7240     fi
7241
7242     if test "$wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW" = "yes"; then
7243         AC_DEFINE(wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW)
7244     fi
7245
7246     if test "$wxUSE_UXTHEME" = "yes"; then
7247         AC_DEFINE(wxUSE_UXTHEME)
7248     fi
7249
7250 fi
7251 dnl wxUSE_MSW = 1
7252
7253 dnl not quite MSW-only although mostly useful to disable this under MSW
7254 if test "$wxUSE_AUTOID_MANAGEMENT" = "yes"; then
7255     AC_DEFINE(wxUSE_AUTOID_MANAGEMENT)
7256 fi
7257
7258 if test "$USE_WIN32" = 1 ; then
7259     if test "$wxUSE_INICONF" = "yes"; then
7260         AC_DEFINE(wxUSE_INICONF)
7261     fi
7262
7263     if test "$wxUSE_REGKEY" = "yes"; then
7264         AC_DEFINE(wxUSE_REGKEY)
7265     fi
7266 fi
7267 dnl USE_WIN32 = 1
7268
7269 dnl ---------------------------------------------------------------------------
7270 dnl wxGraphicsContext
7271 dnl ---------------------------------------------------------------------------
7272
7273 if test "$wxUSE_MAC" = 1; then
7274         wxUSE_GRAPHICS_CONTEXT="yes"
7275 fi
7276
7277 if test "$wxUSE_GRAPHICS_CONTEXT" = "yes"; then
7278    if test "$wxUSE_MAC" = 1 -o "$wxUSE_COCOA" = 1; then
7279       AC_DEFINE(wxUSE_GRAPHICS_CONTEXT)
7280    elif test "$wxUSE_GTK" != 1; then
7281       dnl for other builds we'll just wing it for now...
7282       AC_DEFINE(wxUSE_GRAPHICS_CONTEXT)
7283    else
7284       dnl ...but let's check for cairo availability for wxGTK builds
7285       PKG_CHECK_MODULES(CAIRO, cairo,
7286           [AC_DEFINE(wxUSE_GRAPHICS_CONTEXT)],
7287           [AC_MSG_WARN([Cairo library not found, unable to set wxUSE_GRAPHICS_CONTEXT])]
7288       )
7289    fi
7290 fi
7291
7292 dnl ---------------------------------------------------------------------------
7293 dnl wxMediaCtrl
7294 dnl ---------------------------------------------------------------------------
7295
7296 USE_MEDIA=0
7297
7298 if test "$wxUSE_MEDIACTRL" = "yes" -o "$wxUSE_MEDIACTRL" = "auto"; then
7299     USE_MEDIA=1
7300
7301     dnl -----------------------------------------------------------------------
7302     dnl GStreamer
7303     dnl -----------------------------------------------------------------------
7304     if test "$wxUSE_GTK" = 1; then
7305         wxUSE_GSTREAMER="no"
7306
7307         dnl -------------------------------------------------------------------
7308         dnl Test for at least 0.8 gstreamer module from pkg-config
7309         dnl Even totem doesn't accept 0.9 evidently.
7310         dnl
7311         dnl So, we first check to see if 0.10 if available - if not we
7312         dnl try the older 0.8 version
7313         dnl -------------------------------------------------------------------
7314         GST_VERSION_MAJOR=0
7315         GST_VERSION_MINOR=10
7316         GST_VERSION=$GST_VERSION_MAJOR.$GST_VERSION_MINOR
7317
7318         if test "$wxUSE_GSTREAMER8" = "no"; then
7319             PKG_CHECK_MODULES(GST,
7320                 [gstreamer-$GST_VERSION gstreamer-plugins-base-$GST_VERSION gconf-2.0],
7321                 [
7322                     wxUSE_GSTREAMER="yes"
7323                     GST_LIBS="$GST_LIBS -lgstinterfaces-$GST_VERSION"
7324                 ],
7325                 [
7326                     AC_MSG_WARN([GStreamer 0.10 not available, falling back to 0.8])
7327                     GST_VERSION_MINOR=8
7328                 ]
7329             )
7330         else
7331             dnl check only for 0.8
7332             GST_VERSION_MINOR=8
7333         fi
7334
7335         if test $GST_VERSION_MINOR = "8"; then
7336             GST_VERSION=$GST_VERSION_MAJOR.$GST_VERSION_MINOR
7337             PKG_CHECK_MODULES(GST,
7338                 [gstreamer-$GST_VERSION gstreamer-interfaces-$GST_VERSION gstreamer-gconf-$GST_VERSION],
7339                 wxUSE_GSTREAMER="yes",
7340                 [
7341                     AC_MSG_WARN([GStreamer 0.8/0.10 not available.])
7342                 ])
7343         fi
7344
7345
7346         if test "$wxUSE_GSTREAMER" = "yes"; then
7347             CPPFLAGS="$GST_CFLAGS $CPPFLAGS"
7348             EXTRALIBS_MEDIA="$GST_LIBS"
7349
7350             AC_DEFINE(wxUSE_GSTREAMER)
7351         else
7352             USE_MEDIA=0
7353         fi
7354     fi
7355
7356     if test $USE_MEDIA = 1; then
7357         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS mediaplayer"
7358         AC_DEFINE(wxUSE_MEDIACTRL)
7359     else
7360         if test "$wxUSE_MEDIACTRL" = "yes"; then
7361             AC_MSG_ERROR([GStreamer not available])
7362         else
7363             dnl was set to 'auto'
7364             AC_MSG_WARN([GStreamer not available... disabling wxMediaCtrl])
7365         fi
7366     fi
7367 fi
7368
7369 dnl ---------------------------------------------------------------------------
7370 dnl get the string with OS info - used by wxGetOsDescription() on MacOS X
7371 dnl ---------------------------------------------------------------------------
7372
7373 if test "$cross_compiling" != "no"; then
7374     dnl Use best guess from host as we can't use uname when cross compiling
7375     OSINFO="\"$host\""
7376 else
7377     dnl attualy work out OS version
7378     OSINFO=`uname -s -r -m`
7379     OSINFO="\"$OSINFO\""
7380 fi
7381
7382 AC_DEFINE_UNQUOTED(WXWIN_OS_DESCRIPTION, $OSINFO)
7383
7384 dnl ---------------------------------------------------------------------------
7385 dnl define the variable containing the installation prefix (used in dcpsg.cpp)
7386 dnl ---------------------------------------------------------------------------
7387
7388 if test "x$prefix" != "xNONE"; then
7389     wxPREFIX=$prefix
7390 else
7391     wxPREFIX=$ac_default_prefix
7392 fi
7393
7394 AC_DEFINE_UNQUOTED(wxINSTALL_PREFIX, "$wxPREFIX")
7395
7396
7397 dnl ---------------------------------------------------------------------------
7398 dnl define variables with all built libraries for wx-config
7399 dnl ---------------------------------------------------------------------------
7400
7401 STD_BASE_LIBS="base"
7402 STD_GUI_LIBS=""
7403 BUILT_WX_LIBS="base"
7404 ALL_WX_LIBS="xrc stc gl media qa html adv core xml net base"
7405
7406 if test "$wxUSE_SOCKETS" = "yes" ; then
7407     STD_BASE_LIBS="net $STD_BASE_LIBS"
7408     BUILT_WX_LIBS="net $BUILT_WX_LIBS"
7409 fi
7410 if test "$wxUSE_XML" = "yes" ; then
7411     STD_BASE_LIBS="xml $STD_BASE_LIBS"
7412     BUILT_WX_LIBS="xml $BUILT_WX_LIBS"
7413 fi
7414
7415 if test "$wxUSE_GUI" = "yes"; then
7416     STD_GUI_LIBS="adv core"
7417     BUILT_WX_LIBS="$STD_GUI_LIBS $BUILT_WX_LIBS"
7418
7419     if test "$wxUSE_DEBUGREPORT" = "yes" ; then
7420         STD_GUI_LIBS="qa $STD_GUI_LIBS"
7421         BUILT_WX_LIBS="qa $BUILT_WX_LIBS"
7422     fi
7423     if test "$wxUSE_HTML" = "yes" ; then
7424         STD_GUI_LIBS="html $STD_GUI_LIBS"
7425         BUILT_WX_LIBS="html $BUILT_WX_LIBS"
7426     fi
7427     if test "$wxUSE_MEDIACTRL" = "yes" ; then
7428         BUILT_WX_LIBS="media $BUILT_WX_LIBS"
7429     fi
7430     if test "$wxUSE_OPENGL" = "yes" ; then
7431         BUILT_WX_LIBS="gl $BUILT_WX_LIBS"
7432     fi
7433     if test "$wxUSE_AUI" = "yes" ; then
7434         BUILT_WX_LIBS="aui $BUILT_WX_LIBS"
7435     fi
7436     if test "$wxUSE_PROPGRID" = "yes" ; then
7437         BUILT_WX_LIBS="propgrid $BUILT_WX_LIBS"
7438     fi
7439     if test "$wxUSE_RIBBON" = "yes" ; then
7440         BUILT_WX_LIBS="ribbon $BUILT_WX_LIBS"
7441     fi
7442     if test "$wxUSE_RICHTEXT" = "yes" ; then
7443         BUILT_WX_LIBS="richtext $BUILT_WX_LIBS"
7444     fi
7445     if test "$wxUSE_STC" = "yes" ; then
7446         BUILT_WX_LIBS="stc $BUILT_WX_LIBS"
7447     fi
7448     if test "$wxUSE_XRC" = "yes" ; then
7449         STD_GUI_LIBS="xrc $STD_GUI_LIBS"
7450         BUILT_WX_LIBS="xrc $BUILT_WX_LIBS"
7451     fi
7452 fi
7453
7454 AC_SUBST(ALL_WX_LIBS)
7455 AC_SUBST(BUILT_WX_LIBS)
7456 AC_SUBST(STD_BASE_LIBS)
7457 AC_SUBST(STD_GUI_LIBS)
7458
7459 dnl ---------------------------------------------------------------------------
7460 dnl Output the makefiles and such from the results found above
7461 dnl ---------------------------------------------------------------------------
7462
7463 dnl all additional libraries (except wxWidgets itself) we link with
7464
7465 if test "$wxUSE_MAC" = 1 ; then
7466     if test "$USE_DARWIN" = 1; then
7467         LDFLAGS="$LDFLAGS -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -framework QuickTime"
7468     fi
7469 fi
7470 if test "$wxUSE_COCOA" = 1 ; then
7471     LDFLAGS="$LDFLAGS -framework IOKit -framework Cocoa"
7472     if test "$wxUSE_MEDIACTRL" = "yes"; then
7473         LDFLAGS="$LDFLAGS -framework QuickTime"
7474     fi
7475 fi
7476 if test "$USE_DARWIN" = 1 -a "$wxUSE_MAC" != 1 -a "$wxUSE_COCOA" != 1 ; then
7477     LDFLAGS="$LDFLAGS -framework IOKit -framework CoreServices -framework System -framework ApplicationServices"
7478 fi
7479
7480 LIBS="$ZLIB_LINK $POSIX4_LINK $INET_LINK $WCHAR_LINK $DL_LINK $LIBS"
7481
7482 if test "$wxUSE_GUI" = "yes"; then
7483
7484     dnl TODO add checks that these samples will really compile (i.e. all the
7485     dnl      library features they need are present)
7486
7487     dnl TODO some samples are never built so far: mfc (requires VC++)
7488     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS artprov controls dialogs drawing \
7489                      erase event exec font image minimal render \
7490                      shaped svg taborder vscroll widgets wrapsizer"
7491
7492     if test "$wxUSE_MONOLITHIC" != "yes"; then
7493         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS console"
7494     fi
7495     if test "$TOOLKIT" = "MSW"; then
7496         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS regtest"
7497         if test "$wxUSE_UNIVERSAL" != "yes"; then
7498             SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS ownerdrw nativdlg"
7499         fi
7500     fi
7501     if test "$TOOLKIT" = "PM" -a "$wxUSE_UNIVERSAL" != "yes"; then
7502         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS ownerdrw"
7503     fi
7504 else
7505     SAMPLES_SUBDIRS="console"
7506     if test "$wxUSE_SOCKETS" = "yes" ; then
7507         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS sockets"
7508     fi
7509     if test "$wxUSE_IPC" = "yes" ; then
7510         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS ipc"
7511     fi
7512 fi
7513
7514
7515 dnl C/C++ compiler options used to compile wxWidgets
7516 dnl
7517 dnl check for icc before gcc as icc is also recognized as gcc
7518 if test "x$INTELCC" = "xyes" ; then
7519     dnl Warnings which can't be easily suppressed in C code are disabled:
7520     dnl
7521     dnl     #810: conversion from "x" to "y" may lose significant bits
7522     dnl     #869: parameter "foo" was never referenced
7523     dnl     #1572: floating-point equality and inequality comparisons
7524     dnl            are unreliable
7525     dnl     #1684: conversion from pointer to same-sized integral type
7526     dnl     #2259: non-pointer conversion from "x" to "y" may lose significant
7527     dnl            bits
7528     CWARNINGS="-Wall -wd810,869,981,1418,1572,1684,2259"
7529 elif test "$GCC" = yes ; then
7530     CWARNINGS="-Wall -Wundef"
7531 fi
7532
7533 if test "x$INTELCXX" = "xyes" ; then
7534     dnl Intel compiler gives some warnings which simply can't be worked
7535     dnl around or of which we have too many (810, 869) so it's impractical to
7536     dnl keep them enabled even if in theory it would be nice and some others
7537     dnl (279) are generated for standard macros and so there is nothing we can
7538     dnl do about them
7539     dnl
7540     dnl     #279: controlling expression is constant
7541     dnl     #383: value copied to temporary, reference to temporary used
7542     dnl     #444: destructor for base class "xxx" is not virtual
7543     dnl     #981: operands are evaluated in unspecified order
7544     dnl     #1418: external definition with no prior declaration
7545     dnl     #1419: external declaration in primary source file
7546     dnl     #1881: argument must be a constant null pointer value
7547     dnl
7548     dnl (for others see CWARNINGS above)
7549     CXXWARNINGS="-Wall -wd279,383,444,810,869,981,1418,1419,1881,2259"
7550 elif test "$GXX" = yes ; then
7551     CXXWARNINGS="-Wall -Wundef -Wunused-parameter -Wno-ctor-dtor-privacy"
7552     AX_CXXFLAGS_GCC_OPTION(-Woverloaded-virtual, CXXWARNINGS)
7553
7554     dnl when building under Mac we currently get hundreds of deprecation
7555     dnl warnings for Carbon symbols from the standard headers -- disable them
7556     dnl as we already know that they're deprecated and nothing else can be seen
7557     dnl with these warnings on
7558     if test "$wxUSE_MAC" = 1 ; then
7559         CXXWARNINGS="$CXXWARNINGS -Wno-deprecated-declarations"
7560     fi
7561 fi
7562
7563
7564 dnl combine everything together and remove the extra white space while doing it
7565 WXCONFIG_CFLAGS=`echo $WXCONFIG_CFLAGS`
7566 WXCONFIG_CXXFLAGS=`echo $WXCONFIG_CFLAGS $WXCONFIG_CXXFLAGS`
7567
7568
7569 dnl add -I options we use during library compilation
7570 dnl
7571 dnl note that the order is somewhat important: wxWidgets headers should
7572 dnl come first and the one with setup.h should be before $(top_srcdir)/include
7573 dnl in case the latter contains setup.h used by non-autoconf makefiles (e.g.
7574 dnl CodeWarrior):
7575 CPPFLAGS=`echo $WXCONFIG_CPPFLAGS \
7576  -I\\${wx_top_builddir}/lib/wx/include/${TOOLCHAIN_FULLNAME} \
7577  -I\\${top_srcdir}/include $TOOLKIT_INCLUDE \
7578  $CPPFLAGS `
7579
7580 C_AND_CXX_FLAGS="$DEBUG_CFLAGS $PROFILE_FLAGS $OPTIMISE_CFLAGS"
7581 CFLAGS=`echo $WXCONFIG_CFLAGS $CWARNINGS $C_AND_CXX_FLAGS $CFLAGS `
7582 CXXFLAGS=`echo $WXCONFIG_CXXFLAGS $C_AND_CXX_FLAGS $CXXFLAGS `
7583 OBJCFLAGS=`echo $WXCONFIG_CFLAGS $CWARNINGS $C_AND_CXX_FLAGS $OBJCFLAGS `
7584 OBJCXXFLAGS=`echo $WXCONFIG_CXXFLAGS $C_AND_CXX_FLAGS $OBJCXXFLAGS `
7585
7586 dnl now that we added WXCONFIG_CPPFLAGS to CPPFLAGS we can add the wx-config
7587 dnl only stuff to it
7588 WXCONFIG_CPPFLAGS=`echo $WXCONFIG_CPPFLAGS $WXCONFIG_ONLY_CPPFLAGS`
7589
7590
7591 if test "x$MWCC" = "xyes"; then
7592     dnl Correct MW 8.3 to be more similar to GCC.  In particular we
7593     dnl must use <regex.h> from system not our local copy on OS X,
7594     dnl but must use local not system on OS 9.
7595     dnl The following should make all -I paths usable for <> includes
7596     dnl while first checking in real system paths.  With 8.3 using
7597     dnl -gccincludes it will actually check local paths before system
7598     dnl even for <> which is totally wrong.
7599
7600     dnl Note that because this absolutely needs to be before any -I
7601     dnl that we have to tack it on to the end of the compiler commandline.
7602     CC="$CC -cwd source -I-"
7603     CXX="$CXX -cwd source -I-"
7604 fi
7605
7606
7607 LIBS=`echo $LIBS`
7608 EXTRALIBS="$LDFLAGS $LDFLAGS_VERSIONING $LIBS $DMALLOC_LIBS"
7609 EXTRALIBS_XML="$EXPAT_LINK"
7610 EXTRALIBS_HTML="$MSPACK_LINK"
7611 EXTRALIBS_MEDIA="$GST_LIBS"
7612 EXTRALIBS_STC="-lwxscintilla${WX_LIB_FLAVOUR}-${WX_RELEASE}${HOST_SUFFIX}"
7613 if test "$wxUSE_GUI" = "yes"; then
7614     EXTRALIBS_GUI=`echo $GUI_TK_LIBRARY $PNG_LINK $JPEG_LINK $TIFF_LINK $WEBKIT_LINK $EXTRALIBS_HILDON $EXTRALIBS_GNOMEVFS $EXTRALIBS_GNOMEPRINT`
7615 fi
7616 if test "$wxUSE_OPENGL" = "yes"; then
7617     EXTRALIBS_OPENGL="$LDFLAGS_GL $OPENGL_LIBS"
7618 fi
7619
7620 LDFLAGS="$LDFLAGS $PROFILE_FLAGS"
7621
7622 WXCONFIG_LIBS="$LIBS"
7623
7624 dnl wx-config must output builtin 3rd party libs in --libs in static build:
7625 if test "$wxUSE_REGEX" = "builtin" ; then
7626     wxconfig_3rdparty="regex${lib_unicode_suffix} $wxconfig_3rdparty"
7627 fi
7628 if test "$wxUSE_EXPAT" = "builtin" ; then
7629     wxconfig_3rdparty="expat $wxconfig_3rdparty"
7630 fi
7631 if test "$wxUSE_LIBTIFF" = "builtin" ; then
7632     wxconfig_3rdparty="tiff $wxconfig_3rdparty"
7633 fi
7634 if test "$wxUSE_LIBJPEG" = "builtin" ; then
7635     wxconfig_3rdparty="jpeg $wxconfig_3rdparty"
7636 fi
7637 if test "$wxUSE_LIBPNG" = "builtin" ; then
7638     wxconfig_3rdparty="png $wxconfig_3rdparty"
7639 fi
7640 if test "$wxUSE_ZLIB" = "builtin" ; then
7641     wxconfig_3rdparty="zlib $wxconfig_3rdparty"
7642 fi
7643
7644 for i in $wxconfig_3rdparty ; do
7645     WXCONFIG_LIBS="-lwx${i}${WX_LIB_FLAVOUR}-${WX_RELEASE}${HOST_SUFFIX} $WXCONFIG_LIBS"
7646 done
7647
7648
7649 if test "x$wxUSE_UNIVERSAL" = "xyes" ; then
7650     WXUNIV=1
7651
7652     case "$wxUNIV_THEMES" in
7653         ''|all)
7654             AC_DEFINE(wxUSE_ALL_THEMES)
7655             ;;
7656
7657         *)
7658             for t in `echo $wxUNIV_THEMES | tr , ' ' | tr '[[a-z]]' '[[A-Z]]'`; do
7659                 AC_DEFINE_UNQUOTED(wxUSE_THEME_$t)
7660             done
7661     esac
7662 else
7663     WXUNIV=0
7664 fi
7665
7666 AC_SUBST(wxUSE_ZLIB)
7667 AC_SUBST(wxUSE_REGEX)
7668 AC_SUBST(wxUSE_EXPAT)
7669 AC_SUBST(wxUSE_LIBJPEG)
7670 AC_SUBST(wxUSE_LIBPNG)
7671 AC_SUBST(wxUSE_LIBTIFF)
7672
7673 if test $wxUSE_MONOLITHIC = "yes" ; then
7674     MONOLITHIC=1
7675 else
7676     MONOLITHIC=0
7677 fi
7678
7679 if test $wxUSE_PLUGINS = "yes" ; then
7680     USE_PLUGINS=1
7681 else
7682     USE_PLUGINS=0
7683 fi
7684
7685 if test "$wxUSE_DEBUGREPORT" = "yes" ; then
7686     USE_QA=1
7687 else
7688     USE_QA=0
7689 fi
7690
7691 if test $wxUSE_OFFICIAL_BUILD = "yes" ; then
7692     OFFICIAL_BUILD=1
7693 else
7694     OFFICIAL_BUILD=0
7695 fi
7696
7697 AC_SUBST(VENDOR)
7698 AC_SUBST(OFFICIAL_BUILD)
7699 AC_SUBST(WX_FLAVOUR)
7700 AC_SUBST(WX_LIB_FLAVOUR)
7701
7702 AC_SUBST(WXUNIV)
7703 AC_SUBST(MONOLITHIC)
7704 AC_SUBST(USE_PLUGINS)
7705 AC_SUBST(LIBS)
7706 AC_SUBST(CXXWARNINGS)
7707 AC_SUBST(EXTRALIBS)
7708 AC_SUBST(EXTRALIBS_XML)
7709 AC_SUBST(EXTRALIBS_HTML)
7710 AC_SUBST(EXTRALIBS_MEDIA)
7711 AC_SUBST(EXTRALIBS_GUI)
7712 AC_SUBST(EXTRALIBS_OPENGL)
7713 AC_SUBST(EXTRALIBS_SDL)
7714 AC_SUBST(EXTRALIBS_STC)
7715 AC_SUBST(WITH_PLUGIN_SDL)
7716 AC_SUBST(EXTRALIBS_GTKPRINT)
7717 AC_SUBST(EXTRALIBS_GNOMEPRINT)
7718 AC_SUBST(EXTRALIBS_GNOMEVFS)
7719 AC_SUBST(EXTRALIBS_HILDON)
7720 AC_SUBST(UNICODE)
7721 AC_SUBST(DEBUG_INFO)
7722 AC_SUBST(DEBUG_FLAG)
7723 TOOLKIT_LOWERCASE=xxx
7724 if test "$TOOLKIT" = "MAC"; then
7725     TOOLKIT_LOWERCASE=osx_carbon
7726 fi
7727 if test "$TOOLKIT" = "OSX_CARBON"; then
7728     TOOLKIT_LOWERCASE=osx_carbon
7729 fi
7730 if test "$TOOLKIT" = "OSX_COCOA"; then
7731     TOOLKIT_LOWERCASE=osx_cocoa
7732 fi
7733 if test "$TOOLKIT_LOWERCASE" = "xxx"; then
7734     TOOLKIT_LOWERCASE=`echo $TOOLKIT | tr '[[A-Z]]' '[[a-z]]'`
7735 fi
7736 AC_SUBST(TOOLKIT_LOWERCASE)
7737 AC_SUBST(TOOLKIT_VERSION)
7738 AC_SUBST(DYLIB_RPATH_INSTALL)
7739 AC_SUBST(DYLIB_RPATH_POSTLINK)
7740 AC_SUBST(SAMPLES_RPATH_FLAG)
7741 AC_SUBST(HEADER_PAD_OPTION)
7742 AC_SUBST(HOST_SUFFIX)
7743 AC_SUBST(CPPUNIT_CFLAGS)
7744 AC_SUBST(CPPUNIT_LIBS)
7745
7746 case "$TOOLKIT" in
7747     GTK)
7748         TOOLKIT_DESC="GTK+"
7749         if test "$WXGTK2" = 1; then
7750             TOOLKIT_DESC="$TOOLKIT_DESC 2"
7751             if test "$wxUSE_GTKPRINT" = "yes" ; then
7752                 TOOLKIT_EXTRA="$TOOLKIT_EXTRA GTK+ printing";
7753             fi
7754             if test "$wxUSE_LIBGNOMEPRINT" = "yes" ; then
7755                 TOOLKIT_EXTRA="$TOOLKIT_EXTRA gnomeprint";
7756             fi
7757             if test "$wxUSE_LIBGNOMEVFS" = "yes" ; then
7758                 TOOLKIT_EXTRA="$TOOLKIT_EXTRA gnomevfs"
7759             fi
7760             if test "$wxUSE_LIBHILDON" = "yes"; then
7761                 TOOLKIT_EXTRA="$TOOLKIT_EXTRA hildon"
7762             fi
7763             if test "$wxUSE_LIBHILDON2" = "yes"; then
7764                 TOOLKIT_EXTRA="$TOOLKIT_EXTRA hildon"
7765             fi
7766
7767             if test "$TOOLKIT_EXTRA" != ""; then
7768                 TOOLKIT_DESC="$TOOLKIT_DESC with support for `echo $TOOLKIT_EXTRA | tr -s ' '`"
7769             fi
7770         fi
7771         ;;
7772
7773     ?*)
7774         TOOLKIT_DESC=$TOOLKIT_LOWERCASE
7775         ;;
7776
7777     *)
7778         TOOLKIT_DESC="base only"
7779         ;;
7780 esac
7781
7782 if test "$wxUSE_WINE" = "yes"; then
7783     BAKEFILE_FORCE_PLATFORM=win32
7784 fi
7785
7786 dnl gcc 3.4 has a pch bug which truncates wide character constants in headers.
7787 dnl Hopefully for a non-unicode build there aren't any wide constants in
7788 dnl headers, but for a unicode build it's best to disable pch.
7789 if test "$wxUSE_UNICODE" = yes -a "$GCC" = yes -a "$bk_use_pch" != no
7790 then
7791     AC_CACHE_CHECK(
7792         [for gcc precompiled header bug],
7793         [wx_cv_gcc_pch_bug],
7794         [[
7795             echo '#include <stdio.h>
7796                   const wchar_t test_var[] = L"awidetest";' > conftest.h
7797
7798             echo '#include "conftest.h"
7799                   int main()
7800                   {
7801                      printf("%ls", test_var);
7802                      return 0;
7803                   }' > conftest.cpp
7804
7805             wx_cv_gcc_pch_bug="pch not supported"
7806
7807             if $CXX conftest.h >/dev/null 2>&1
7808             then
7809                 wx_cv_gcc_pch_bug=
7810
7811                 if $CXX -o conftest$PROGRAM_EXT conftest.cpp >/dev/null 2>&1
7812                 then
7813                     if tr -dc '[a-z]' < conftest$PROGRAM_EXT |
7814                         grep awidetest >/dev/null
7815                     then
7816                         wx_cv_gcc_pch_bug=no
7817                     else
7818                         wx_cv_gcc_pch_bug=yes
7819                     fi
7820                 fi
7821             fi
7822
7823             rm -f conftest.h conftest.gch conftest.cpp conftest$PROGRAM_EXT
7824         ]])
7825
7826     if test "$wx_cv_gcc_pch_bug" = yes; then
7827         dnl make the default for pch 'no'
7828         dnl further below check whether the user overrode and warn them
7829         bk_use_pch=no
7830     fi
7831 fi
7832
7833 AC_BAKEFILE([m4_include(autoconf_inc.m4)])
7834
7835 dnl make install path absolute (if not already);
7836 dnl will fail with (some) MSDOS paths
7837 case ${INSTALL} in
7838   /* ) # Absolute
7839      ;;
7840   ?:* ) # Drive letter, considered as absolute.
7841      ;;
7842   *)
7843      INSTALL=`pwd`/${INSTALL} ;;
7844 esac
7845
7846 if test "$wxUSE_GUI" = "yes"; then
7847
7848 if test "$wxUSE_MSW" = 1 ; then
7849     if test "x$WINDRES" = "x"; then
7850         AC_MSG_ERROR([Required windres program not found])
7851     fi
7852
7853     RESCOMP="$WINDRES $WINDRES_CPU_DEFINE"
7854 fi
7855
7856 if test "$wxUSE_MAC" = 1 -o "$wxUSE_COCOA" = 1; then
7857     dnl base name of the resource file for wxMac must be the same
7858     dnl as library installation base name (-install_name)
7859     WX_RESOURCES_MACOSX_ASCII="libwx_${TOOLCHAIN_NAME}.${wx_release_number}.r"
7860     WX_RESOURCES_MACOSX_DATA="libwx_${TOOLCHAIN_NAME}.${wx_release_number}.rsrc"
7861
7862     dnl add the resources target for wxMac
7863     LIBWXMACRES="\$(wx_top_builddir)/lib/${WX_RESOURCES_MACOSX_ASCII}"
7864
7865     AC_CHECK_PROG(DEREZ, DeRez, DeRez, /Developer/Tools/DeRez)
7866
7867     MACSETFILE="\$(SETFILE)"
7868
7869     dnl resources are bundled both with shared library and applications
7870     dnl since the carb resource *must* be included in the application
7871     if test "$wxUSE_OSX_CARBON" = 1; then
7872         POSTLINK_COMMAND="\$(REZ) -d __DARWIN__ -t APPL Carbon.r -o"
7873         RESCOMP="$REZ"
7874         WXCONFIG_RESFLAGS="-d __DARWIN__ -t APPL Carbon.r -o"
7875     else
7876         POSTLINK_COMMAND="cat /dev/null | \$(REZ) -d __DARWIN__ -t APPL ${LIBWXMACRES}"
7877         RESCOMP="cat /dev/null \| $REZ"
7878         WXCONFIG_RESFLAGS="-d __DARWIN__ -t APPL \$libdir/$WX_RESOURCES_MACOSX_ASCII"
7879     fi
7880
7881 else
7882     dnl default value is to (silently) do nothing in the makefile
7883     MACSETFILE="@true"
7884
7885     if test "$wxUSE_PM" = 1; then
7886         RESCOMP="emxbind"
7887         WXCONFIG_RESFLAGS="-ep"
7888
7889         dnl Is this one really used anywhere for pm?
7890         POSTLINK_COMMAND="$RESCOMP $WXCONFIG_RESFLAGS"
7891     else
7892         POSTLINK_COMMAND="@true"
7893     fi
7894 fi
7895
7896 fi
7897 dnl wxUSE_GUI = 1
7898
7899
7900 dnl find out if the compiler supports PCH
7901 dnl
7902 dnl TODO: this should be in bakefile
7903 if test $GCC_PCH = 1
7904 then
7905     if test "$wx_cv_gcc_pch_bug" = yes; then
7906         AC_MSG_WARN([*** Precompiled header support is broken on this compiler])
7907         AC_MSG_WARN([*** --enable-precomp-headers is not recommended])
7908         AC_MSG_WARN([*** see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13361])
7909     fi
7910
7911     # Our WX_PRECOMP flag does not make sense for any language except C++ because
7912     # the headers that benefit from precompilation are mostly C++ headers.
7913     CXXFLAGS="-DWX_PRECOMP $CXXFLAGS"
7914     # When Bakefile can do multi-language PCH (e.g. C++ and Objective-C++) enable this:
7915     #OBJCXXFLAGS="-DWX_PRECOMP $CXXFLAGS"
7916 fi
7917
7918 dnl HACK ALERT!!
7919 dnl For now, we need to alter bk-deps not to generate deps
7920 dnl when we've configured a Universal binary build.
7921 dnl The next version of Bakefile will have the correct fix for this
7922 dnl at which time, this hack can be removed.
7923
7924 if test "$wxUSE_MAC" = 1 ; then
7925     if test "x$wxUSE_UNIVERSAL_BINARY" != "xno" ; then
7926         sed "s/DEPSMODE=gcc/DEPSMODE=none/" < bk-deps > temp
7927         mv temp bk-deps
7928         chmod +x bk-deps
7929     fi
7930 fi
7931
7932 if test "$wxUSE_SHARED" = "yes"; then
7933     dnl Need addtional flag on OS/2, so override bakefiles value
7934     dnl (there currently is no suitable variable to which the
7935     dnl  missing flags could be added, AFAICS. SN, 18.12.2004. )
7936     case "${host}" in
7937       *-pc-os2_emx | *-pc-os2-emx )
7938         SHARED_LD_CC="`pwd`/dllar.sh -name-mangler-script ./dllnames.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
7939         SHARED_LD_CXX="`pwd`/dllar.sh -name-mangler-script ./dllnames.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
7940         cp -p ${srcdir}/src/os2/dllnames.sh .
7941         cp -p ${srcdir}/src/os2/dllar.sh .
7942       ;;
7943     esac
7944 fi
7945 if test "$wxUSE_OMF" = "yes"; then
7946     case "${host}" in
7947       *-pc-os2_emx | *-pc-os2-emx )
7948         LDFLAGS="$LDFLAGS -Zlinker /EXEPACK"
7949         LDFLAGS_GUI="-Zlinker /PMTYPE:PM"
7950         WXCONFIG_LDFLAGS_GUI="-Zlinker /PMTYPE:PM"
7951       ;;
7952     esac
7953 fi
7954
7955 dnl TOOLCHAIN_DEFS should be used for both wx and client code
7956 WXCONFIG_CPPFLAGS="$WXCONFIG_CPPFLAGS $TOOLCHAIN_DEFS"
7957
7958
7959 dnl Sun cc is compatible with gcc and so either of them can use the C
7960 dnl libraries built with the other, i.e. gcc can be used to build wxGTK under
7961 dnl Solaris where GTK+ is compiled using cc and cc can be used under Linux
7962 dnl where GTK+ is built with gcc
7963 dnl
7964 dnl However the compiler options are not compatible at all and in particular
7965 dnl gcc doesn't like cc -mt option and cc doesn't like -pthread. We simply
7966 dnl filter them out as we already have the correct options for multithreaded
7967 dnl programs if we're using threads (and if we don't, it shouldn't matter)
7968 case "${host}" in
7969     *-*-solaris2* )
7970         dnl system packages are compiled with Sun CC and so pkg-config outputs
7971         dnl CC-specific "-mt" flag, remove it when using gcc
7972         if test "$GCC" = yes; then
7973             CPPFLAGS=`echo $CPPFLAGS | sed 's/-mt//'`
7974             LIBS=`echo $LIBS | sed 's/-mt//'`
7975             EXTRALIBS_GUI=`echo $EXTRALIBS_GUI | sed 's/-mt//'`
7976         fi
7977         ;;
7978
7979     *-*-linux* )
7980         dnl OTOH when using Sun CC under Linux, the flags contain gcc-specific
7981         dnl -pthreads which Sun CC doesn't know about
7982         if test "x$SUNCXX" = xyes; then
7983             CPPFLAGS=`echo $CPPFLAGS | sed 's/-pthread//'`
7984             LIBS=`echo $LIBS | sed 's/-pthread//'`
7985             EXTRALIBS_GUI=`echo $EXTRALIBS_GUI | sed 's/-pthread//'`
7986         fi
7987         ;;
7988 esac
7989
7990 dnl Add visibility support flags to CFLAGS/CXXFLAGS - do it this late so that
7991 dnl it doesn't affect compilation checks above
7992 CFLAGS="$CFLAGS $CFLAGS_VISIBILITY"
7993 CXXFLAGS="$CXXFLAGS $CXXFLAGS_VISIBILITY"
7994 OBJCFLAGS="$OBJCFLAGS $CFLAGS_VISIBILITY"
7995 OBJCXXFLAGS="$OBJCXXFLAGS $CXXFLAGS_VISIBILITY"
7996
7997 dnl for convenience, sort the samples in alphabetical order
7998 dnl
7999 dnl FIXME For some mysterious reasons, sometimes the directories are duplicated
8000 dnl       in this list - hence uniq. But normally, this shouldn't be needed!
8001 dnl
8002 dnl       Unfortunately, there is a bug in OS/2's tr, such that
8003 dnl       tr ' ' '\n' introduces DOS-like line breaks, whereas tr '\n' ' '
8004 dnl       only removes the Unix-like part of the introduced line break.
8005 SAMPLES_SUBDIRS="`echo $SAMPLES_SUBDIRS | tr -s ' ' | tr ' ' '\n' | sort | uniq | tr '\n' ' '| tr -d '\r'`"
8006
8007 dnl subtle bakefile goop.
8008 dnl Used in wx-config now too, as its STATIC_FLAG with different makeup.
8009 dnl I wish we would have called it something less likely to clash with
8010 dnl things though.
8011 AC_SUBST(SHARED)
8012
8013 dnl global options
8014 AC_SUBST(WX_LIBRARY_BASENAME_NOGUI)
8015 AC_SUBST(WX_LIBRARY_BASENAME_GUI)
8016
8017 dnl toolkit options
8018 AC_SUBST(USE_GUI)
8019 AC_SUBST(AFMINSTALL)
8020 AC_SUBST(WIN32INSTALL)
8021 AC_SUBST(TOOLKIT)
8022 AC_SUBST(TOOLKIT_DIR)
8023 AC_SUBST(TOOLCHAIN_NAME)
8024 AC_SUBST(TOOLCHAIN_FULLNAME)
8025
8026 dnl wx-config options
8027 AC_SUBST(host_alias)
8028 AC_SUBST(cross_compiling)
8029 AC_SUBST(WIDGET_SET)
8030 AC_SUBST(WX_RELEASE)
8031 AC_SUBST(WX_VERSION)
8032 AC_SUBST(WX_SUBVERSION)
8033 AC_SUBST(WX_CHARTYPE)
8034
8035 dnl note that in addition to the usual CPP/C/CXXFLAGS which are used for
8036 dnl building the library itself, we also have WXCONFIG_-prefixed variants which
8037 dnl are used when building the libraries using the library
8038 dnl
8039 dnl so put anything which should be used only during the library build in, e.g.
8040 dnl CXXFLAGS, but put everything else (by default) into WXCONFIG_CXXFLAGS
8041 dnl
8042 dnl and, finally, for some things which should be only used by wx-config but
8043 dnl not during the library compilation, use WXCONFIG_ONLY_CPPFLAGS which is
8044 dnl added to WXCONFIG_CPPFLAGS after adding the latter to CPPFLAGS
8045 AC_SUBST(WXCONFIG_CPPFLAGS)
8046 AC_SUBST(WXCONFIG_CFLAGS)
8047 AC_SUBST(WXCONFIG_CXXFLAGS)
8048
8049 AC_SUBST(WXCONFIG_LIBS)
8050 AC_SUBST(WXCONFIG_RPATH)
8051 AC_SUBST(WXCONFIG_LDFLAGS_GUI)
8052 AC_SUBST(WXCONFIG_RESFLAGS)
8053
8054 dnl distribution vars
8055 AC_SUBST(GUIDIST)
8056 AC_SUBST(DISTDIR)
8057
8058 dnl additional subdirectories where we will build
8059 AC_SUBST(SAMPLES_SUBDIRS)
8060
8061 dnl additional libraries and linker settings
8062 AC_SUBST(LDFLAGS)
8063 AC_SUBST(LDFLAGS_GL)
8064 AC_SUBST(OPENGL_LIBS)
8065 AC_SUBST(DMALLOC_LIBS)
8066 AC_SUBST(WX_VERSION_TAG)
8067
8068 dnl additional resurces settings
8069 AC_SUBST(RESCOMP)
8070 AC_SUBST(WINDRES)
8071 AC_SUBST(REZ)
8072 AC_SUBST(RESFLAGS)
8073 AC_SUBST(RESPROGRAMOBJ)
8074 AC_SUBST(WX_RESOURCES_MACOSX_ASCII)
8075 AC_SUBST(WX_RESOURCES_MACOSX_DATA)
8076
8077 dnl additional for Mac OS X
8078 AC_SUBST(DEREZ)
8079 AC_SUBST(LIBWXMACRES)
8080 AC_SUBST(POSTLINK_COMMAND)
8081 AC_SUBST(MACSETFILE)
8082
8083 dnl other tools
8084 AC_SUBST(GCC)
8085 AC_SUBST(DLLTOOL)
8086
8087
8088 dnl MAKE_SET will be replaced with "MAKE=..." or nothing if make sets MAKE
8089 dnl itself (this macro is required if SUBDIRS variable is used in Makefile.am
8090 dnl - and we do use it)
8091 AC_PROG_MAKE_SET
8092
8093
8094 AC_CONFIG_HEADERS([lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/setup.h:setup.h.in])
8095
8096 if test "$USE_WIN32" = 1; then
8097     AC_CONFIG_COMMANDS([rcdefs.h],
8098         [
8099             mkdir -p $outdir &&
8100             $CPP $infile | sed 's/^# *[1-9].*//;s/^ *//;/./,/^$/!d' > $outdir/rcdefs.h
8101         ],
8102         [
8103             CPP="$CPP"
8104             infile="$srcdir/include/wx/msw/genrcdefs.h"
8105             outdir="lib/wx/include/$TOOLCHAIN_FULLNAME/wx/msw"
8106         ]
8107     )
8108 fi
8109
8110 AC_CONFIG_FILES([ lib/wx/config/${TOOLCHAIN_FULLNAME}:wx-config.in ],
8111                 [ chmod +x lib/wx/config/${TOOLCHAIN_FULLNAME} ],
8112                 [ TOOLCHAIN_FULLNAME="${TOOLCHAIN_FULLNAME}" ])
8113
8114 AC_CONFIG_FILES([ lib/wx/config/inplace-${TOOLCHAIN_FULLNAME}:wx-config-inplace.in ],
8115                 [ chmod +x lib/wx/config/inplace-${TOOLCHAIN_FULLNAME} ],
8116                 [ TOOLCHAIN_FULLNAME="${TOOLCHAIN_FULLNAME}" ])
8117
8118 dnl this is used to run ifacecheck with the same flags used by the compiler
8119 dnl for the real compilation:
8120 AC_CONFIG_FILES([ utils/ifacecheck/rungccxml.sh ],
8121                 [ chmod +x utils/ifacecheck/rungccxml.sh ])
8122
8123 if test "$wx_cv_version_script" = "yes"; then
8124     AC_CONFIG_FILES(version-script)
8125 fi
8126 AC_CONFIG_FILES(Makefile)
8127
8128 AC_CONFIG_COMMANDS([wx-config],
8129                    [ rm -f wx-config
8130                      ${LN_S} lib/wx/config/inplace-${TOOLCHAIN_FULLNAME} wx-config
8131                    ],
8132                    [ TOOLCHAIN_FULLNAME="${TOOLCHAIN_FULLNAME}"
8133                      LN_S="${LN_S}"
8134                    ])
8135
8136 dnl This would give us us build dir that in every significant way
8137 dnl resembles an installed wx in prefix=$builddir.  It is troublesome
8138 dnl though in this form because AC_CONFIG_LINKS will fail for directories
8139 dnl on platforms that do not have symlinks.
8140 dnl AC_CONFIG_LINKS([ include/wx-$WX_RELEASE$WX_FLAVOUR:include ])
8141
8142 if test "$wxWITH_SUBDIRS" != "no"; then
8143 dnl Configure samples, demos etc. directories, but only if they are present:
8144 if test "$wxUSE_GUI" = "yes"; then
8145     SUBDIRS="samples demos utils"
8146 else
8147     dnl we build wxBase only
8148     dnl there are no wxBase programs in demos
8149     SUBDIRS="samples utils"
8150 fi
8151 dnl Add tests to the list of subdirs if cppunit 1.8.0+ is detected
8152 AM_PATH_CPPUNIT(1.8.0, [SUBDIRS="$SUBDIRS tests"])
8153
8154 for subdir in $SUBDIRS; do
8155     if test -d ${srcdir}/${subdir} ; then
8156         if test "$wxUSE_GUI" = "yes"; then
8157             if test ${subdir} = "samples"; then
8158                 dnl only take those samples which compile in the current
8159                 dnl configuration and which exist
8160                 makefiles="samples/Makefile.in $makefiles"
8161                 for sample in $SAMPLES_SUBDIRS; do
8162                     if test -d $srcdir/samples/$sample; then
8163                         makefiles="samples/$sample/Makefile.in $makefiles"
8164                     fi
8165                 done
8166             else
8167                 dnl assume that everything compiles for utils &c
8168                 dnl any that shouldn't be built can be added to
8169                 dnl DISABLED_UTILS, DISABLED_DEMOS
8170                 disabled_var=DISABLED_`echo $subdir | tr '[[a-z]]' '[[A-Z]]'`
8171                 eval "disabled=\$$disabled_var"
8172                 disabled=/`echo X $disabled | sed 's@ @/|/@g'`/
8173                 makefiles=`(cd $srcdir ; find $subdir -name Makefile.in) | $EGREP -v "$disabled"`
8174             fi
8175         else
8176             dnl we build wxBase only
8177             dnl don't take all samples/utils, just those which build with wxBase
8178             if test ${subdir} = "samples"; then
8179                 dnl only take those samples which compile in the current
8180                 dnl configuration and which exist
8181                 makefiles="samples/Makefile.in $makefiles"
8182                 for sample in `echo $SAMPLES_SUBDIRS`; do
8183                     if test -d $srcdir/samples/$sample; then
8184                         makefiles="samples/$sample/Makefile.in $makefiles"
8185                     fi
8186                 done
8187             elif test ${subdir} = "utils"; then
8188                 makefiles=""
8189                 for util in ifacecheck ; do
8190                     if test -d $srcdir/utils/$util ; then
8191                         makefiles="utils/$util/src/Makefile.in \
8192                                    $makefiles"
8193                     fi
8194                 done
8195             else
8196                 dnl assume that everything compiles for tests
8197                 makefiles=`(cd $srcdir ; find $subdir -name Makefile.in)`
8198             fi
8199         fi
8200
8201         for mkin in $makefiles ; do
8202             mk=`echo $mkin | sed 's/Makefile\.in/Makefile/g'`
8203             AC_CONFIG_FILES([$mk])
8204         done
8205     fi
8206 done
8207 fi dnl wxWITH_SUBDIRS
8208
8209 AC_OUTPUT
8210
8211 dnl report how we have been configured
8212 echo
8213 echo "Configured wxWidgets ${WX_VERSION} for \`${host}'"
8214 echo ""
8215 echo "  Which GUI toolkit should wxWidgets use?                 ${TOOLKIT_DESC}"
8216 echo "  Should wxWidgets be compiled into single library?       ${wxUSE_MONOLITHIC:-yes}"
8217 echo "  Should wxWidgets be linked as a shared library?         ${wxUSE_SHARED:-no}"
8218 echo $ECHO_N "  Should wxWidgets support Unicode?                       ${wxUSE_UNICODE:-no}$ECHO_C"
8219 if test "$wxUSE_UNICODE" = "yes"; then
8220     if test "$wxUSE_UNICODE_UTF8" = "yes"; then
8221         echo " (using UTF-8)"
8222     else
8223         echo " (using wchar_t)"
8224     fi
8225 else
8226     echo
8227 fi
8228
8229 echo "  What level of wxWidgets compatibility should be enabled?"
8230 echo "                                       wxWidgets 2.6      ${WXWIN_COMPATIBILITY_2_6:-no}"
8231 echo "                                       wxWidgets 2.8      ${WXWIN_COMPATIBILITY_2_8:-yes}"
8232
8233 echo "  Which libraries should wxWidgets use?"
8234 echo "                                       STL                ${wxUSE_STL}"
8235 echo "                                       jpeg               ${wxUSE_LIBJPEG-none}"
8236 echo "                                       png                ${wxUSE_LIBPNG-none}"
8237 echo "                                       regex              ${wxUSE_REGEX}"
8238 echo "                                       tiff               ${wxUSE_LIBTIFF-none}"
8239 if test "$wxUSE_X11" = 1 -o "$wxUSE_MOTIF" = 1; then
8240 echo "                                       xpm                ${wxUSE_LIBXPM-none}"
8241 fi
8242 echo "                                       zlib               ${wxUSE_ZLIB}"
8243 echo "                                       expat              ${wxUSE_EXPAT}"
8244 echo "                                       libmspack          ${wxUSE_LIBMSPACK}"
8245 echo "                                       sdl                ${wxUSE_LIBSDL}"
8246
8247 echo ""
8248
8249 dnl vi: set et sts=4 sw=4 com=\:dnl: