]> git.saurik.com Git - wxWidgets.git/blobdiff - configure.in
Merge wxBitmapButton and wxButton panels in the xrc sample.
[wxWidgets.git] / configure.in
index 4372b556b493f26ffaf70c045143ffee3e9ae9d6..1eae0beda81292f65673d36071eba6d5b16b82d2 100644 (file)
@@ -8,7 +8,7 @@ dnl
 dnl Top-level configure.in for wxWidgets by Robert Roebling, Phil Blecker,
 dnl Vadim Zeitlin and Ron Lee
 dnl
-dnl This script is under the wxWidgets licence.
+dnl This script is under the wxWindows licence.
 dnl
 dnl Version: $Id$
 dnl ---------------------------------------------------------------------------
@@ -17,16 +17,25 @@ dnl ---------------------------------------------------------------------------
 dnl initialization
 dnl ---------------------------------------------------------------------------
 
-AC_INIT([wxWidgets], [2.9.0], [wx-dev@lists.wxwidgets.org])
+AC_INIT([wxWidgets], [2.9.2], [wx-dev@lists.wxwidgets.org])
 
 dnl the file passed to AC_CONFIG_SRCDIR should be specific to our package
 AC_CONFIG_SRCDIR([wx-config.in])
 
-dnl sets build, host, target variables and the same with _alias
+dnl sets build, host variables and the same with _alias
 AC_CANONICAL_BUILD
 AC_CANONICAL_HOST
-AC_CANONICAL_TARGET
 
+dnl notice that if --host was given but --build was not, cross_compiling is
+dnl only set to "maybe" and not "yes" and will be either set to "yes" later or
+dnl configure will exit with error in AC_PROG_CC so don't test for = "yes" here
+if test "$cross_compiling" != "no"; then
+    HOST_PREFIX="${host_alias}-"
+    HOST_SUFFIX="-$host_alias"
+else
+    HOST_PREFIX=
+    HOST_SUFFIX=
+fi
 
 dnl When making releases do:
 dnl
@@ -34,7 +43,7 @@ dnl wx_release_number += 1
 
 wx_major_version_number=2
 wx_minor_version_number=9
-wx_release_number=0
+wx_release_number=2
 wx_subrelease_number=0
 
 WX_RELEASE=$wx_major_version_number.$wx_minor_version_number
@@ -94,13 +103,15 @@ NEEDS_D_REENTRANT_FOR_R_FUNCS=0
 dnl the list of all available toolkits
 dnl
 dnl update NUM_TOOLKITS calculation below when adding a new toolkit here!
-ALL_TOOLKITS="COCOA GTK MAC MGL MICROWIN MOTIF MSW PM X11 DFB"
+ALL_TOOLKITS="COCOA GTK OSX_CARBON OSX_COCOA OSX_IPHONE MGL MICROWIN MOTIF MSW PM X11 DFB"
 
 dnl NB: these wxUSE_XXX constants have value of 0 or 1 unlike all the other ones
 dnl     which are either yes or no
-DEFAULT_wxUSE_COCOA=0
+DEFAULT_wxUSE_OLD_COCOA=0
 DEFAULT_wxUSE_GTK=0
-DEFAULT_wxUSE_MAC=0
+DEFAULT_wxUSE_OSX_CARBON=0
+DEFAULT_wxUSE_OSX_COCOA=0
+DEFAULT_wxUSE_OSX_IPHONE=0
 DEFAULT_wxUSE_MGL=0
 DEFAULT_wxUSE_MICROWIN=0
 DEFAULT_wxUSE_MOTIF=0
@@ -109,12 +120,14 @@ DEFAULT_wxUSE_PM=0
 DEFAULT_wxUSE_X11=0
 DEFAULT_wxUSE_DFB=0
 
-dnl these are the values which are really default for the given platform -
-dnl they're not cached and are only used if no --with-toolkit was given *and*
-dnl nothing was found in the cache
-DEFAULT_DEFAULT_wxUSE_COCOA=0
+dnl these are the values which are really default for the given platform:
+dnl they're used if no --with-<toolkit> options were given to detect the
+dnl toolkit to use by default for the target platform
+DEFAULT_DEFAULT_wxUSE_OLD_COCOA=0
 DEFAULT_DEFAULT_wxUSE_GTK=0
-DEFAULT_DEFAULT_wxUSE_MAC=0
+DEFAULT_DEFAULT_wxUSE_OSX_CARBON=0
+DEFAULT_DEFAULT_wxUSE_OSX_COCOA=0
+DEFAULT_DEFAULT_wxUSE_OSX_IPHONE=0
 DEFAULT_DEFAULT_wxUSE_MGL=0
 DEFAULT_DEFAULT_wxUSE_MICROWIN=0
 DEFAULT_DEFAULT_wxUSE_MOTIF=0
@@ -124,9 +137,9 @@ DEFAULT_DEFAULT_wxUSE_X11=0
 DEFAULT_DEFAULT_wxUSE_DFB=0
 
 PROGRAM_EXT=
-SO_SUFFIX=so
 SAMPLES_RPATH_FLAG=
-SAMPLES_RPATH_POSTLINK=
+DYLIB_RPATH_INSTALL=
+DYLIB_RPATH_POSTLINK=
 
 DEFAULT_STD_FLAG=yes
 
@@ -139,7 +152,6 @@ case "${host}" in
     USE_HPUX=1
     DEFAULT_DEFAULT_wxUSE_MOTIF=1
     NEEDS_D_REENTRANT_FOR_R_FUNCS=1
-    SO_SUFFIX=sl
     AC_DEFINE(__HPUX__)
 
     dnl many standard declarations in HP-UX headers are only included if either
@@ -172,6 +184,11 @@ case "${host}" in
     AC_DEFINE(__SVR4__)
     DEFAULT_DEFAULT_wxUSE_MOTIF=1
   ;;
+  *-*-qnx*)
+    USE_QNX=1
+    AC_DEFINE(__QNX__)
+    DEFAULT_DEFAULT_wxUSE_X11=1
+  ;;
   *-*-solaris2* )
     USE_SUN=1
     USE_SOLARIS=1
@@ -243,12 +260,6 @@ case "${host}" in
     USE_AIX=1
     USE_SYSV=1
     USE_SVR4=1
-    dnl quoting from http://www-1.ibm.com/servers/esdd/articles/gnu.html:
-    dnl
-    dnl     Both archive libraries and shared libraries on AIX have an .a
-    dnl     extension. This will explain why you can't link with an .so and
-    dnl     why it works with the name changed to .a.
-    SO_SUFFIX=a
     AC_DEFINE(__AIX__)
     AC_DEFINE(__SYSV__)
     AC_DEFINE(__SVR4__)
@@ -266,7 +277,6 @@ case "${host}" in
     dnl MBN: some of the defines have been moved after toolkit detection
     dnl      because for wxMotif/wxGTK/wxX11 to build on Cygwin
     dnl      USE_UNIX  must be set and not USE_WIN32
-    SO_SUFFIX=dll
     PROGRAM_EXT=".exe"
     DEFAULT_DEFAULT_wxUSE_MSW=1
   ;;
@@ -313,28 +323,23 @@ case "${host}" in
     DEFAULT_STD_FLAG=no
   ;;
 
+  arm-apple-darwin*)
+    dnl iPhone
+    USE_BSD=1
+    USE_DARWIN=1
+    AC_DEFINE(__BSD__)
+    AC_DEFINE(__DARWIN__)
+    DEFAULT_DEFAULT_wxUSE_OSX_IPHONE=1
+  ;;
+
   *-*-darwin* )
     dnl Darwin based distributions (including Mac OS X)
     USE_BSD=1
     USE_DARWIN=1
-    SO_SUFFIX=dylib
     AC_DEFINE(__BSD__)
     AC_DEFINE(__DARWIN__)
     AC_DEFINE(TARGET_CARBON)
-    DEFAULT_DEFAULT_wxUSE_MAC=1
-    DEFAULT_STD_FLAG=no
-  ;;
-  powerpc-apple-macos* )
-    dnl Classic Mac OS (< X)
-    USE_UNIX=0
-    dnl For some reason the test that should be cross-compiler capable fails
-    dnl However, there is no doubt that MacOS PowerPC is big endian.
-    ac_cv_c_bigendian=yes
-    SO_SUFFIX=shlib
-    dnl AC_DEFINE(TARGET_CARBON)
-    dnl platform.h needs TARGET_CARBON before setup.h, we'll add it to CPPFLAGS
-    DEFAULT_DEFAULT_wxUSE_MAC=1
-    DEFAULT_STD_FLAG=no
+    DEFAULT_DEFAULT_wxUSE_OSX_CARBON=1
   ;;
 
   *-*-beos* )
@@ -361,8 +366,6 @@ dnl platform should be changed, it can be done here too)
 dnl
 dnl NB: see also DEFAULT_wxUSE<toolkit> variables defined above
 
-WX_ARG_CACHE_INIT
-
 dnl it's only necessary to list the options which should be disabled by
 dnl default, all the rest have default value of "yes" (or, rather, of
 dnl wxUSE_ALL_FEATURES which is the only which has to be set to "yes" by
@@ -376,23 +379,26 @@ dnl libraries disabled by default
 DEFAULT_wxUSE_DMALLOC=no
 DEFAULT_wxUSE_LIBGNOMEVFS=no
 DEFAULT_wxUSE_LIBHILDON=no
+DEFAULT_wxUSE_LIBHILDON2=no
 DEFAULT_wxUSE_LIBMSPACK=no
 DEFAULT_wxUSE_LIBSDL=no
-DEFAULT_wxUSE_ODBC=no
-DEFAULT_wxUSE_OPENGL=no
 
 dnl features disabled by default
 DEFAULT_wxUSE_ACCESSIBILITY=no
-DEFAULT_wxUSE_DATAVIEWCTRL=no
-DEFAULT_wxUSE_GRAPHICS_CONTEXT=no
-DEFAULT_wxUSE_MEDIACTRL=no
-DEFAULT_wxUSE_TAB_DIALOG=no
+DEFAULT_wxUSE_IPV6=no
+DEFAULT_wxUSE_GSTREAMER8=no
 
+dnl automatic features
 DEFAULT_wxUSE_UNICODE_UTF8=auto
+DEFAULT_wxUSE_OPENGL=auto
+DEFAULT_wxUSE_MEDIACTRL=auto
+DEFAULT_wxUSE_COMPILER_TLS=auto
+
 DEFAULT_wxUSE_UNICODE_UTF8_LOCALE=no
 
 dnl Mac/Cocoa users need to enable building universal binaries explicitly
 DEFAULT_wxUSE_UNIVERSAL_BINARY=no
+DEFAULT_wxUSE_MAC_ARCH=no
 
 DEFAULT_wxUSE_OFFICIAL_BUILD=no
 
@@ -402,21 +408,6 @@ DEFAULT_wxUSE_GTK2=yes
 dnl Always default to no. Only special cases require this.
 DEFAULT_wxUSE_OBJC_UNIQUIFYING=no
 
-
-for toolkit in `echo $ALL_TOOLKITS`; do
-  LINE=`grep "wxUSE_$toolkit=" ${wx_arg_cache_file}`
-  if test "x$LINE" != "x" ; then
-    has_toolkit_in_cache=1
-    eval "DEFAULT_$LINE"
-    eval "CACHE_$toolkit=1"
-
-    LINE=`grep "wx${toolkit}_VERSION=" ${wx_arg_cache_file}`
-    if test "x$LINE" != "x" ; then
-        eval "DEFAULT_$LINE"
-    fi
-  fi
-done
-
 dnl ===========================
 dnl deal with configure options
 dnl ===========================
@@ -456,6 +447,14 @@ fi
 
 WX_ARG_DISABLE(all-features,[  --disable-all-features  disable all optional features to build minimal library], wxUSE_ALL_FEATURES)
 
+if test "$wxUSE_ALL_FEATURES" = "no"; then
+    dnl this is a bit ugly but currently we have no choice but to manually
+    dnl reset all the options with default value of auto if all features are to
+    dnl be disabled because we can't have an option with default value of
+    dnl "auto-or-no-if-wxUSE_ALL_FEATURES-is-disabled"
+    DEFAULT_wxUSE_MEDIACTRL=no
+fi
+
 dnl ---------------------------------------------------------------------------
 dnl port selection
 dnl ---------------------------------------------------------------------------
@@ -468,12 +467,18 @@ if test "$wxUSE_UNIVERSAL" = "yes"; then
 fi
 
 dnl we use AC_ARG_WITH and not WX_ARG_WITH for the toolkit options as they
-dnl shouldn't default to wxUSE_ALL_FEATURES, and we don't need to cache them
-dnl automatically
+dnl shouldn't default to wxUSE_ALL_FEATURES
 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])
 AC_ARG_WITH(motif,         [  --with-motif            use Motif/Lesstif], [wxUSE_MOTIF="$withval" CACHE_MOTIF=1 TOOLKIT_GIVEN=1])
-AC_ARG_WITH(mac,           [  --with-mac              use Mac OS X], [wxUSE_MAC="$withval" CACHE_MAC=1 TOOLKIT_GIVEN=1])
-AC_ARG_WITH(cocoa,         [  --with-cocoa            use Cocoa], [wxUSE_COCOA="$withval" CACHE_COCOA=1 TOOLKIT_GIVEN=1])
+AC_ARG_WITH(osx_carbon,    [  --with-osx_carbon       use Mac OS X (Carbon)], [wxUSE_OSX_CARBON="$withval" CACHE_OSX_CARBON=1 TOOLKIT_GIVEN=1])
+AC_ARG_WITH(osx_cocoa,     [  --with-osx_cocoa        use Mac OS X (Cocoa)], [wxUSE_OSX_COCOA="$withval" CACHE_OSX_COCOA=1 TOOLKIT_GIVEN=1])
+AC_ARG_WITH(osx_iphone,    [  --with-osx_iphone       use iPhone OS X port], [wxUSE_OSX_IPHONE="$withval" CACHE_OSX_IPHONE=1 TOOLKIT_GIVEN=1])
+AC_ARG_WITH(osx,           [  --with-osx              use Mac OS X (default port, currently Carbon)], [wxUSE_OSX_CARBON="$withval" CACHE_OSX_CARBON=1 TOOLKIT_GIVEN=1])
+AC_ARG_WITH(carbon,        [  --with-carbon           same as --with-osx_carbon], [wxUSE_OSX_CARBON="$withval" CACHE_OSX_CARBON=1 TOOLKIT_GIVEN=1])
+AC_ARG_WITH(cocoa,         [  --with-cocoa            same as --with-osx_cocoa], [wxUSE_OSX_COCOA="$withval" CACHE_OSX_COCOA=1 TOOLKIT_GIVEN=1])
+AC_ARG_WITH(iphone,        [  --with-iphone           same as --with-osx_iphone], [wxUSE_OSX_IPHONE="$withval" CACHE_OSX_IPHONE=1 TOOLKIT_GIVEN=1])
+AC_ARG_WITH(mac,           [  --with-mac              same as --with-osx], [wxUSE_OSX_CARBON="$withval" CACHE_OSX_CARBON=1 TOOLKIT_GIVEN=1])
+AC_ARG_WITH(old_cocoa,     [  --with-old_cocoa        use old, deprecated, Cocoa port], [wxUSE_OLD_COCOA="$withval" CACHE_OLD_COCOA=1 TOOLKIT_GIVEN=1])
 AC_ARG_WITH(wine,          [  --with-wine             use Wine], [wxUSE_WINE="$withval" CACHE_WINE=1])
 AC_ARG_WITH(msw,           [  --with-msw              use MS-Windows], [wxUSE_MSW="$withval" CACHE_MSW=1 TOOLKIT_GIVEN=1])
 AC_ARG_WITH(pm,            [  --with-pm               use OS/2 Presentation Manager], [wxUSE_PM="$withval" CACHE_PM=1 TOOLKIT_GIVEN=1])
@@ -486,6 +491,107 @@ WX_ARG_ENABLE(nanox,       [  --enable-nanox          use NanoX], wxUSE_NANOX)
 AC_ARG_ENABLE(gtk2,        [  --disable-gtk2          use GTK+ 1.2 instead of 2.0], [wxUSE_GTK2="$enableval"])
 WX_ARG_ENABLE(gpe,         [  --enable-gpe            use GNOME PDA Environment features if possible], wxUSE_GPE)
 
+dnl check that no more than one toolkit is given and that if none are given that
+dnl we have a default one
+
+AC_MSG_CHECKING(for toolkit)
+
+
+
+# In Wine, we need to default to MSW, not GTK or MOTIF
+if test "$wxUSE_WINE" = "yes"; then
+    DEFAULT_DEFAULT_wxUSE_GTK=0
+    DEFAULT_DEFAULT_wxUSE_MOTIF=0
+    DEFAULT_DEFAULT_wxUSE_MSW=1
+    wxUSE_SHARED=no
+    CC=${CC:-winegcc}
+    CXX=${CXX:-wineg++}
+fi
+
+
+if test "$wxUSE_GUI" = "yes"; then
+
+    if test "$USE_BEOS" = 1; then
+        AC_MSG_ERROR([BeOS GUI is not supported yet, use --disable-gui])
+    fi
+
+    if test "$TOOLKIT_GIVEN" = 1; then
+      dnl convert "yes", "any" or a number to 1 and "no" to 0
+      for toolkit in $ALL_TOOLKITS; do
+        var=wxUSE_$toolkit
+        eval "value=\$${var}"
+        if test "x$value" = "xno"; then
+          eval "$var=0"
+        elif test "x$value" != "x"; then
+          eval "$var=1"
+        fi
+
+        if test "x$value" != "x" -a "x$value" != "xyes" -a "x$value" != "xno"; then
+          eval "wx${toolkit}_VERSION=$value"
+        fi
+      done
+    else
+      dnl try to guess the most apropriate toolkit for this platform
+      for toolkit in $ALL_TOOLKITS; do
+        var=DEFAULT_DEFAULT_wxUSE_$toolkit
+        eval "wxUSE_$toolkit=\$${var}"
+      done
+    fi
+
+    dnl we suppose that expr is available (maybe there is a better way to do
+    dnl this? what about using ALL_TOOLKITS? TODO)
+    NUM_TOOLKITS=`expr ${wxUSE_OLD_COCOA:-0} + ${wxUSE_GTK:-0} + ${wxUSE_OSX_CARBON:-0} \
+                  + ${wxUSE_OSX_COCOA:-0} + ${wxUSE_OSX_IPHONE:-0} + ${wxUSE_MGL:-0} + ${wxUSE_DFB:-0} \
+                  + ${wxUSE_MICROWIN:-0} + ${wxUSE_MOTIF:-0} + ${wxUSE_MSW:-0} + ${wxUSE_X11:-0}`
+
+    dnl Allow wxUSE_PM only for OS/2 with EMX.
+    case "${host}" in
+      *-pc-os2_emx | *-pc-os2-emx )
+        NUM_TOOLKITS=`expr ${NUM_TOOLKITS} + ${wxUSE_PM:-0}`
+    esac
+
+    case "$NUM_TOOLKITS" in
+      1)
+      ;;
+      0)
+        AC_MSG_ERROR(Please specify a toolkit -- cannot determine the default for ${host})
+      ;;
+      *)
+        AC_MSG_ERROR(Please specify at most one toolkit)
+    esac
+
+    # to be removed when --disable-gtk2 isn't needed
+    if test "x$wxUSE_GTK2" = "xyes"; then
+        wxGTK_VERSION=2
+        wxUSE_GTK1=0
+    elif test "x$wxUSE_GTK2" = "xno"; then
+        wxGTK_VERSION=1
+        wxUSE_GTK1=1
+    fi
+
+    for toolkit in $ALL_TOOLKITS; do
+        var=wxUSE_$toolkit
+        eval "value=\$${var}"
+        if test "$value" = 1; then
+          toolkit_echo=`echo $toolkit | tr '[[A-Z]]' '[[a-z]]'`
+          AC_MSG_RESULT($toolkit_echo)
+        fi
+    done
+else
+    if test "x$host_alias" != "x"; then
+        AC_MSG_RESULT(base ($host_alias hosted) only)
+    else
+        AC_MSG_RESULT(base only)
+    fi
+fi
+
+wxUSE_MAC=0
+if test "$wxUSE_OSX_CARBON" = 1 \
+       -o "$wxUSE_OSX_COCOA" = 1 \
+       -o "$wxUSE_OSX_IPHONE" = 1; then
+    wxUSE_MAC=1
+fi
+
 dnl ---------------------------------------------------------------------------
 dnl external libraries
 dnl ---------------------------------------------------------------------------
@@ -494,10 +600,12 @@ WX_ARG_SYS_WITH(libpng,    [  --with-libpng           use libpng (PNG image form
 WX_ARG_SYS_WITH(libjpeg,   [  --with-libjpeg          use libjpeg (JPEG file format)], wxUSE_LIBJPEG)
 WX_ARG_SYS_WITH(libtiff,   [  --with-libtiff          use libtiff (TIFF file format)], wxUSE_LIBTIFF)
 WX_ARG_SYS_WITH(libxpm,    [  --with-libxpm           use libxpm (XPM file format)], wxUSE_LIBXPM)
+WX_ARG_WITH(libiconv,      [  --with-libiconv         use libiconv (character conversion)], wxUSE_LIBICONV)
 WX_ARG_WITH(libmspack,     [  --with-libmspack        use libmspack (CHM help files loading)], wxUSE_LIBMSPACK)
+WX_ARG_WITHOUT(gtkprint,   [  --without-gtkprint      don't use GTK printing support], wxUSE_GTKPRINT)
 WX_ARG_WITHOUT(gnomeprint, [  --without-gnomeprint    don't use GNOME printing libraries], wxUSE_LIBGNOMEPRINT)
 WX_ARG_WITH(gnomevfs,      [  --with-gnomevfs         use GNOME VFS for associating MIME types], wxUSE_LIBGNOMEVFS)
-WX_ARG_WITH(hildon,        [  --with-hildon           use Hildon framework for Nokia 770], wxUSE_LIBHILDON)
+WX_ARG_WITH(hildon,        [  --with-hildon           use Hildon framework for Nokia 770/800/810], wxUSE_LIBHILDON)
 WX_ARG_WITH(opengl,        [  --with-opengl           use OpenGL (or Mesa)], wxUSE_OPENGL)
 
 fi
@@ -507,51 +615,112 @@ WX_ARG_WITH(dmalloc,       [  --with-dmalloc          use dmalloc library (http:
 WX_ARG_WITH(sdl,           [  --with-sdl              use SDL for audio on Unix], wxUSE_LIBSDL)
 WX_ARG_SYS_WITH(regex,     [  --with-regex            enable support for wxRegEx class], wxUSE_REGEX)
 WX_ARG_SYS_WITH(zlib,      [  --with-zlib             use zlib for LZW compression], wxUSE_ZLIB)
-WX_ARG_SYS_WITH(odbc,      [  --with-odbc             use the IODBC and wxODBC classes], wxUSE_ODBC)
 WX_ARG_SYS_WITH(expat,     [  --with-expat            enable XML support using expat parser], wxUSE_EXPAT)
 
+AC_MSG_CHECKING([for --with-macosx-sdk])
+AC_ARG_WITH(macosx-sdk,    [  --with-macosx-sdk=PATH  use an OS X SDK at PATH], [
+        wxUSE_MACOSX_SDK=$withval
+        wx_cv_use_macosx_sdk="wxUSE_MACOSX_SDK=$withval"
+    ])
+AC_MSG_RESULT([$wxUSE_MACOSX_SDK])
+
+AC_MSG_CHECKING([for --with-macosx-version-min])
+AC_ARG_WITH(macosx-version-min,    [  --with-macosx-version-min=VER   build binaries which require at least this OS X version], [
+        wxUSE_MACOSX_VERSION_MIN=$withval
+        wx_cv_use_macosx_version_min="wxUSE_MACOSX_VERSION_MIN=$withval"
+    ])
+AC_MSG_RESULT([$wxUSE_MACOSX_VERSION_MIN])
+
+dnl ---------------------------------------------------------------------------
+dnl debugging options
+dnl ---------------------------------------------------------------------------
+
+dnl don't use WX_ARG_ENABLE as it just gets in the way instead of helping with
+dnl this rather unusual option
+AC_MSG_CHECKING([for --enable-debug])
+AC_ARG_ENABLE(debug,       [  --enable-debug          build library for debugging],
+    [
+        if test "$enableval" = yes; then
+            wxUSE_DEBUG=yes
+        elif test "$enableval" = no; then
+            wxUSE_DEBUG=no
+        elif test "$enableval" = max; then
+            wxUSE_DEBUG=yes
+            WXCONFIG_CPPFLAGS="$WXCONFIG_CPPFLAGS -DwxDEBUG_LEVEL=2"
+        else
+            AC_MSG_ERROR([Invalid --enable-debug value, must be yes, no or max])
+        fi
+    ],
+    wxUSE_DEBUG=default
+)
+
+case "$wxUSE_DEBUG" in
+    yes)
+        dnl build the library for debugging: enable debugging code and generate
+        dnl the debug information for the library itself
+        DEFAULT_wxUSE_DEBUG_FLAG=yes
+        DEFAULT_wxUSE_DEBUG_INFO=yes
+
+        dnl also disable optimizations by default if --enable-debug was used
+        dnl (this can still be overridden by an explicit --enable-optimise)
+        DEFAULT_wxUSE_OPTIMISE=no
+        ;;
+
+    no)
+        dnl --disable-debug is equivalent to both --disable-debug_flag and
+        dnl --disable-debug_info
+        DEFAULT_wxUSE_DEBUG_FLAG=no
+        DEFAULT_wxUSE_DEBUG_INFO=no
+        ;;
+
+    default)
+        dnl the library is built with debugging support by default but without
+        dnl debug information as this requires much, much more disk space
+        DEFAULT_wxUSE_DEBUG_FLAG=yes
+        DEFAULT_wxUSE_DEBUG_INFO=no
+        ;;
+esac
+
+WX_ARG_DISABLE(debug_flag,   [  --disable-debug_flag    disable all debugging support], wxUSE_DEBUG_FLAG)
+WX_ARG_ENABLE(debug_info,    [  --enable-debug_info     generate debug information], wxUSE_DEBUG_INFO)
+
+dnl enabled if just --enable-debug_{flag,info} was
+dnl
+dnl in any case, only set the default value and allow overriding it with an
+
+WX_ARG_ENABLE(debug_gdb,     [  --enable-debug_gdb      create code with extra GDB debugging information], wxUSE_DEBUG_GDB)
+WX_ARG_ENABLE(debug_cntxt,   [  --enable-debug_cntxt    obsolete, don't use: use wxDebugContext], wxUSE_DEBUG_CONTEXT)
+WX_ARG_ENABLE(mem_tracing,   [  --enable-mem_tracing    obsolete, don't use: create code with memory tracing], wxUSE_MEM_TRACING)
+
 dnl ---------------------------------------------------------------------------
 dnl global compile options
 dnl ---------------------------------------------------------------------------
 
 WX_ARG_DISABLE(shared,     [  --disable-shared        create static library instead of shared], wxUSE_SHARED)
-WX_ARG_DISABLE(optimise,   [  --disable-optimise      create optimised code], wxUSE_OPTIMISE)
-WX_ARG_ENABLE(debug,       [  --enable-debug          same as debug_flag and debug_info], wxUSE_DEBUG)
 WX_ARG_ENABLE(stl,         [  --enable-stl            use STL for containers], wxUSE_STL)
 WX_ARG_ENABLE(std_iostreams, [  --enable-std_iostreams  use standard C++ stream classes], wxUSE_STD_IOSTREAM)
 WX_ARG_ENABLE(std_string,    [  --enable-std_string     use standard C++ string classes], wxUSE_STD_STRING)
 WX_ARG_DISABLE(unicode,      [  --disable-unicode       compile without Unicode support], wxUSE_UNICODE)
 WX_ARG_ENABLE(mslu,          [  --enable-mslu           use MS Layer for Unicode on Windows 9x (Win32 only)], wxUSE_UNICODE_MSLU)
 WX_ARG_ENABLE_PARAM(utf8,    [  --enable-utf8           use UTF-8 representation for strings (Unix only)], wxUSE_UNICODE_UTF8)
-WX_ARG_ENABLE(utf8only,      [  --enable-utf8only      only support UTF-8 locales in UTF-8 build (Unix only)], wxUSE_UNICODE_UTF8_LOCALE)
+WX_ARG_ENABLE(utf8only,      [  --enable-utf8only       only support UTF-8 locales in UTF-8 build (Unix only)], wxUSE_UNICODE_UTF8_LOCALE)
 WX_ARG_ENABLE(extended_rtti, [  --enable-extended_rtti  use extended RTTI (XTI)], wxUSE_EXTENDED_RTTI)
-if test "$USE_OS2" = "1"; then
+if test "$USE_OS2" = 1; then
     DEFAULT_wxUSE_OMF=no
     WX_ARG_ENABLE(omf,     [  --enable-omf            use OMF object format], wxUSE_OMF)
 fi
 
-if test "$wxUSE_DEBUG" = "yes"; then
-  DEFAULT_wxUSE_DEBUG_FLAG=yes
-  DEFAULT_wxUSE_DEBUG_INFO=yes
-  BUILD=debug
-elif test "$wxUSE_DEBUG" = "no"; then
-  DEFAULT_wxUSE_DEBUG_FLAG=no
-  DEFAULT_wxUSE_DEBUG_INFO=no
-  BUILD=release
-fi
+WX_ARG_DISABLE(optimise,   [  --disable-optimise      compile without optimisations], wxUSE_OPTIMISE)
 
-WX_ARG_ENABLE(debug_flag,    [  --enable-debug_flag     set __WXDEBUG__ flag (recommended for developers!)], wxUSE_DEBUG_FLAG)
-WX_ARG_ENABLE(debug_info,    [  --enable-debug_info     create code with debugging information], wxUSE_DEBUG_INFO)
-WX_ARG_ENABLE(debug_gdb,     [  --enable-debug_gdb      create code with extra GDB debugging information], wxUSE_DEBUG_GDB)
-WX_ARG_ENABLE(debug_cntxt,   [  --enable-debug_cntxt    use wxDebugContext], wxUSE_DEBUG_CONTEXT)
-WX_ARG_ENABLE(mem_tracing,   [  --enable-mem_tracing    create code with memory tracing], wxUSE_MEM_TRACING)
 WX_ARG_ENABLE(profile,       [  --enable-profile        create code with profiling information], wxUSE_PROFILE)
 WX_ARG_ENABLE(no_rtti,       [  --enable-no_rtti        create code without RTTI information], wxUSE_NO_RTTI)
 WX_ARG_ENABLE(no_exceptions, [  --enable-no_exceptions  create code without C++ exceptions handling], wxUSE_NO_EXCEPTIONS)
 WX_ARG_ENABLE(permissive,    [  --enable-permissive     compile code disregarding strict ANSI], wxUSE_PERMISSIVE)
 WX_ARG_ENABLE(no_deps,       [  --enable-no_deps        create code without dependency information], wxUSE_NO_DEPS)
 WX_ARG_DISABLE(vararg_macros,[  --disable-vararg_macros don't use vararg macros, even if they are supported], wxUSE_VARARG_MACROS)
-WX_ARG_ENABLE_PARAM(universal_binary, [[  --enable-universal_binary[=SDK] create Mac PowerPC and Intel Universal binary (not yet working)]], wxUSE_UNIVERSAL_BINARY)
+
+WX_ARG_ENABLE_PARAM(universal_binary, [[  --enable-universal_binary  create universal binary with Mac PPC and i386 (and x86_64 if using Cocoa) architectures ]], wxUSE_UNIVERSAL_BINARY)
+WX_ARG_ENABLE_PARAM(macosx_arch,      [[  --enable-macosx_arch=ARCH  build for just the specified architecture]], wxUSE_MAC_ARCH)
 
 WX_ARG_ENABLE(compat26,      [  --enable-compat26       enable wxWidgets 2.6 compatibility], WXWIN_COMPATIBILITY_2_6)
 WX_ARG_DISABLE(compat28,     [  --disable-compat28      disable wxWidgets 2.8 compatibility], WXWIN_COMPATIBILITY_2_8)
@@ -561,12 +730,14 @@ WX_ARG_DISABLE(rpath,        [  --disable-rpath         disable use of rpath for
 WX_ARG_ENABLE(objc_uniquifying,[  --enable-objc_uniquifying enable Objective-C class name uniquifying], wxUSE_OBJC_UNIQUIFYING)
 
 WX_ARG_DISABLE(visibility,   [  --disable-visibility    disable use of ELF symbols visibility even if supported], wxUSE_VISIBILITY)
+WX_ARG_DISABLE(tls,          [  --disable-tls           disable use of compiler TLS support], wxUSE_COMPILER_TLS)
 
 dnl ---------------------------------------------------------------------------
 dnl optional non GUI features
 dnl ---------------------------------------------------------------------------
 
 WX_ARG_FEATURE(intl,          [  --enable-intl           use internationalization system], wxUSE_INTL)
+WX_ARG_FEATURE(xlocale,       [  --enable-xlocale        use x-locale support (requires wxLocale)], wxUSE_XLOCALE)
 WX_ARG_FEATURE(config,        [  --enable-config         use wxConfig (and derived) classes], wxUSE_CONFIG)
 
 WX_ARG_FEATURE(protocols,     [  --enable-protocols      use wxProtocol and derived classes], wxUSE_PROTOCOL)
@@ -574,16 +745,18 @@ WX_ARG_FEATURE(ftp,           [  --enable-ftp            use wxFTP (requires wxP
 WX_ARG_FEATURE(http,          [  --enable-http           use wxHTTP (requires wxProtocol], wxUSE_PROTOCOL_HTTP)
 WX_ARG_FEATURE(fileproto,     [  --enable-fileproto      use wxFileProto class (requires wxProtocol], wxUSE_PROTOCOL_FILE)
 WX_ARG_FEATURE(sockets,       [  --enable-sockets        use socket/network classes], wxUSE_SOCKETS)
+WX_ARG_FEATURE(ipv6,          [  --enable-ipv6           enable IPv6 support in wxSocket], wxUSE_IPV6)
 WX_ARG_FEATURE(ole,           [  --enable-ole            use OLE classes (Win32 only)], wxUSE_OLE)
 WX_ARG_FEATURE(dataobj,       [  --enable-dataobj        use data object classes], wxUSE_DATAOBJ)
 
 WX_ARG_FEATURE(ipc,           [  --enable-ipc            use interprocess communication (wxSocket etc.)], wxUSE_IPC)
 
 WX_ARG_FEATURE(baseevtloop,   [  --enable-baseevtloop    use event loop in console programs too], wxUSE_CONSOLE_EVENTLOOP)
-WX_ARG_FEATURE(epoolloop,     [  --enable-epoolloop      use wxEpollDispatcher class (Linux only)], wxUSE_EPOLL_DISPATCHER)
+WX_ARG_FEATURE(epollloop,     [  --enable-epollloop      use wxEpollDispatcher class (Linux only)], wxUSE_EPOLL_DISPATCHER)
 WX_ARG_FEATURE(selectloop,    [  --enable-selectloop     use wxSelectDispatcher class], wxUSE_SELECT_DISPATCHER)
 
 dnl please keep the settings below in alphabetical order
+WX_ARG_FEATURE(any,           [  --enable-any            use wxAny class], wxUSE_ANY)
 WX_ARG_FEATURE(apple_ieee,    [  --enable-apple_ieee     use the Apple IEEE codec], wxUSE_APPLE_IEEE)
 WX_ARG_FEATURE(arcstream,     [  --enable-arcstream      use wxArchive streams], wxUSE_ARCHIVE_STREAMS)
 WX_ARG_FEATURE(base64,        [  --enable-base64         use base64 encoding/decoding functions], wxUSE_BASE64)
@@ -598,33 +771,34 @@ WX_ARG_FEATURE(dynamicloader, [  --enable-dynamicloader  use (new) wxDynamicLibr
 WX_ARG_FEATURE(exceptions,    [  --enable-exceptions     build exception-safe library], wxUSE_EXCEPTIONS)
 WX_ARG_FEATURE(ffile,         [  --enable-ffile          use wxFFile class], wxUSE_FFILE)
 WX_ARG_FEATURE(file,          [  --enable-file           use wxFile class], wxUSE_FILE)
+WX_ARG_FEATURE(filehistory,   [  --enable-filehistory    use wxFileHistory class], wxUSE_FILE_HISTORY)
 WX_ARG_FEATURE(filesystem,    [  --enable-filesystem     use virtual file systems classes], wxUSE_FILESYSTEM)
 WX_ARG_FEATURE(fontenum,      [  --enable-fontenum       use wxFontEnumerator class], wxUSE_FONTENUM)
 WX_ARG_FEATURE(fontmap,       [  --enable-fontmap        use font encodings conversion classes], wxUSE_FONTMAP)
 WX_ARG_FEATURE(fs_archive,    [  --enable-fs_archive     use virtual archive filesystems], wxUSE_FS_ARCHIVE)
 WX_ARG_FEATURE(fs_inet,       [  --enable-fs_inet        use virtual HTTP/FTP filesystems], wxUSE_FS_INET)
 WX_ARG_FEATURE(fs_zip,        [  --enable-fs_zip         now replaced by fs_archive], wxUSE_FS_ZIP)
+WX_ARG_FEATURE(fswatcher,     [  --enable-fswatcher      use wxFileSystemWatcher class], wxUSE_FSWATCHER)
 WX_ARG_FEATURE(geometry,      [  --enable-geometry       use geometry class], wxUSE_GEOMETRY)
 WX_ARG_FEATURE(log,           [  --enable-log            use logging system], wxUSE_LOG)
 WX_ARG_FEATURE(longlong,      [  --enable-longlong       use wxLongLong class], wxUSE_LONGLONG)
 WX_ARG_FEATURE(mimetype,      [  --enable-mimetype       use wxMimeTypesManager], wxUSE_MIMETYPE)
+WX_ARG_FEATURE(printfposparam,[  --enable-printfposparam use wxVsnprintf() which supports positional parameters], wxUSE_PRINTF_POS_PARAMS)
 WX_ARG_FEATURE(snglinst,      [  --enable-snglinst       use wxSingleInstanceChecker class], wxUSE_SNGLINST_CHECKER)
+WX_ARG_FEATURE(sound,         [  --enable-sound          use wxSound class], wxUSE_SOUND)
 WX_ARG_FEATURE(stdpaths,      [  --enable-stdpaths       use wxStandardPaths class], wxUSE_STDPATHS)
 WX_ARG_FEATURE(stopwatch,     [  --enable-stopwatch      use wxStopWatch class], wxUSE_STOPWATCH)
 WX_ARG_FEATURE(streams,       [  --enable-streams        use wxStream etc classes], wxUSE_STREAMS)
-WX_ARG_FEATURE(system_options,[  --enable-sysoptions     use wxSystemOptions], wxUSE_SYSTEM_OPTIONS)
+WX_ARG_FEATURE(sysoptions,    [  --enable-sysoptions     use wxSystemOptions], wxUSE_SYSTEM_OPTIONS)
 WX_ARG_FEATURE(tarstream,     [  --enable-tarstream      use wxTar streams], wxUSE_TARSTREAM)
 WX_ARG_FEATURE(textbuf,       [  --enable-textbuf        use wxTextBuffer class], wxUSE_TEXTBUFFER)
 WX_ARG_FEATURE(textfile,      [  --enable-textfile       use wxTextFile class], wxUSE_TEXTFILE)
 WX_ARG_FEATURE(timer,         [  --enable-timer          use wxTimer class], wxUSE_TIMER)
-WX_ARG_FEATURE(sound,         [  --enable-sound          use wxSound class], wxUSE_SOUND)
-WX_ARG_FEATURE(mediactrl,     [  --enable-mediactrl      use wxMediaCtrl class], wxUSE_MEDIACTRL)
-WX_ARG_FEATURE(gstreamer8,    [  --enable-gstreamer8     force GStreamer 0.8 instead of 0.10 with the wxMediaCtrl class on unix], wxUSE_GSTREAMER8)
-WX_ARG_FEATURE(printfposparam,[  --enable-printfposparam use wxVsnprintf() which supports positional parameters], wxUSE_PRINTF_POS_PARAMS)
+WX_ARG_FEATURE(variant,       [  --enable-variant        use wxVariant class], wxUSE_VARIANT)
 WX_ARG_FEATURE(zipstream,     [  --enable-zipstream      use wxZip streams], wxUSE_ZIPSTREAM)
 
+dnl URL-related classes
 WX_ARG_FEATURE(url,           [  --enable-url            use wxURL class], wxUSE_URL)
-WX_ARG_FEATURE(variant,       [  --enable-variant        use wxVariant class], wxUSE_VARIANT)
 WX_ARG_FEATURE(protocol,      [  --enable-protocol       use wxProtocol class], wxUSE_PROTOCOL)
 WX_ARG_FEATURE(protocol_http, [  --enable-protocol-http  HTTP support in wxProtocol], wxUSE_PROTOCOL_HTTP)
 WX_ARG_FEATURE(protocol_ftp,  [  --enable-protocol-ftp   FTP support in wxProtocol], wxUSE_PROTOCOL_FTP)
@@ -632,6 +806,9 @@ WX_ARG_FEATURE(protocol_file, [  --enable-protocol-file  FILE support in wxProto
 
 WX_ARG_FEATURE(threads,     [  --enable-threads        use threads], wxUSE_THREADS)
 
+WX_ARG_ENABLE(iniconf,      [  --enable-iniconf        use wxIniConfig (Win32 only)], wxUSE_INICONF)
+WX_ARG_FEATURE(regkey,      [  --enable-regkey         use wxRegKey class (Win32 only)], wxUSE_REGKEY)
+
 if test "$wxUSE_GUI" = "yes"; then
 
 dnl ---------------------------------------------------------------------------
@@ -645,20 +822,29 @@ WX_ARG_FEATURE(html,        [  --enable-html           use wxHTML sub-library],
 WX_ARG_FEATURE(htmlhelp,    [  --enable-htmlhelp       use wxHTML-based help], wxUSE_WXHTML_HELP)
 WX_ARG_FEATURE(xrc,         [  --enable-xrc            use XRC resources sub-library], wxUSE_XRC)
 WX_ARG_FEATURE(aui,         [  --enable-aui            use AUI docking library], wxUSE_AUI)
+WX_ARG_FEATURE(propgrid,    [  --enable-propgrid       use wxPropertyGrid library], wxUSE_PROPGRID)
+WX_ARG_FEATURE(ribbon,      [  --enable-ribbon         use wxRibbon library], wxUSE_RIBBON)
 WX_ARG_FEATURE(stc,         [  --enable-stc            use wxStyledTextCtrl library], wxUSE_STC)
 WX_ARG_FEATURE(constraints, [  --enable-constraints    use layout-constraints system], wxUSE_CONSTRAINTS)
-WX_ARG_FEATURE(printarch,   [  --enable-printarch      use printing architecture], wxUSE_PRINTING_ARCHITECTURE)
-WX_ARG_FEATURE(mdi,         [  --enable-mdi            use multiple document interface architecture], wxUSE_MDI)
-WX_ARG_FEATURE(mdidoc,      [  --enable-mdidoc         use docview architecture with MDI], wxUSE_MDI_ARCHITECTURE)
 WX_ARG_FEATURE(loggui,      [  --enable-loggui         use standard GUI logger], wxUSE_LOGGUI)
 WX_ARG_FEATURE(logwin,      [  --enable-logwin         use wxLogWindow], wxUSE_LOGWINDOW)
 WX_ARG_FEATURE(logdialog,   [  --enable-logdialog      use wxLogDialog], wxUSE_LOGDIALOG)
+WX_ARG_FEATURE(mdi,         [  --enable-mdi            use multiple document interface architecture], wxUSE_MDI)
+WX_ARG_FEATURE(mdidoc,      [  --enable-mdidoc         use docview architecture with MDI], wxUSE_MDI_ARCHITECTURE)
+WX_ARG_FEATURE(mediactrl,   [  --enable-mediactrl      use wxMediaCtrl class], wxUSE_MEDIACTRL)
+WX_ARG_FEATURE(gstreamer8,  [  --enable-gstreamer8     force GStreamer 0.8 instead of 0.10 with the wxMediaCtrl class on unix], wxUSE_GSTREAMER8)
 WX_ARG_FEATURE(webkit,      [  --enable-webkit         use wxWebKitCtrl (Mac)], wxUSE_WEBKIT)
 WX_ARG_FEATURE(richtext,    [  --enable-richtext       use wxRichTextCtrl], wxUSE_RICHTEXT)
-WX_ARG_FEATURE(graphics_ctx,[  --enable-graphics_ctx   use graphics context 2D drawing API], wxUSE_GRAPHICS_CONTEXT)
 WX_ARG_FEATURE(postscript,  [  --enable-postscript     use wxPostscriptDC device context (default for gtk+)], wxUSE_POSTSCRIPT)
+WX_ARG_FEATURE(printarch,   [  --enable-printarch      use printing architecture], wxUSE_PRINTING_ARCHITECTURE)
 WX_ARG_FEATURE(svg,         [  --enable-svg            use wxSVGFileDC device context], wxUSE_SVG)
 
+dnl wxDC is implemented in terms of wxGraphicsContext in wxOSX so the latter
+dnl can't be disabled, don't even provide an option to do it
+if test "$wxUSE_MAC" != 1; then
+WX_ARG_FEATURE(graphics_ctx,[  --enable-graphics_ctx   use graphics context 2D drawing API], wxUSE_GRAPHICS_CONTEXT)
+fi
+
 dnl ---------------------------------------------------------------------------
 dnl IPC &c
 dnl ---------------------------------------------------------------------------
@@ -675,122 +861,74 @@ dnl don't set DEFAULT_wxUSE_XXX below if the option is not specified
 DEFAULT_wxUSE_CONTROLS=none
 WX_ARG_DISABLE(controls,    [  --disable-controls      disable compilation of all standard controls], wxUSE_CONTROLS)
 
-dnl even with --enable-controls, some may be disabled by giving
-dnl --disable-<control> later on the command line - but by default all will be
-dnl used (and vice versa)
-if test "$wxUSE_CONTROLS" = "yes"; then
-  DEFAULT_wxUSE_ACCEL=yes
-  DEFAULT_wxUSE_ANIMATIONCTRL=yes
-  DEFAULT_wxUSE_BMPBUTTON=yes
-  DEFAULT_wxUSE_BUTTON=yes
-  DEFAULT_wxUSE_CALCTRL=yes
-  DEFAULT_wxUSE_CARET=yes
-  DEFAULT_wxUSE_COMBOBOX=yes
-  DEFAULT_wxUSE_CHECKBOX=yes
-  DEFAULT_wxUSE_CHECKLISTBOX=yes
-  DEFAULT_wxUSE_CHOICE=yes
-  DEFAULT_wxUSE_CHOICEBOOK=yes
-  DEFAULT_wxUSE_COLLPANE=yes
-  DEFAULT_wxUSE_COLOURPICKERCTRL=yes
-  DEFAULT_wxUSE_COMBOBOX=yes
-  DEFAULT_wxUSE_DATEPICKCTRL=yes
-  DEFAULT_wxUSE_DISPLAY=yes
-  DEFAULT_wxUSE_DETECT_SM=yes
-  DEFAULT_wxUSE_DIRPICKERCTRL=yes
-  DEFAULT_wxUSE_FILEPICKERCTRL=yes
-  DEFAULT_wxUSE_FONTPICKERCTRL=yes
-  DEFAULT_wxUSE_GAUGE=yes
-  DEFAULT_wxUSE_GRID=yes
-  DEFAULT_wxUSE_HYPERLINKCTRL=yes
-  DEFAULT_wxUSE_DATAVIEWCTRL=no
-  DEFAULT_wxUSE_IMAGLIST=yes
-  DEFAULT_wxUSE_LISTBOOK=yes
-  DEFAULT_wxUSE_LISTBOX=yes
-  DEFAULT_wxUSE_LISTCTRL=yes
-  DEFAULT_wxUSE_NOTEBOOK=yes
-  DEFAULT_wxUSE_RADIOBOX=yes
-  DEFAULT_wxUSE_RADIOBTN=yes
-  DEFAULT_wxUSE_SASH=yes
-  DEFAULT_wxUSE_SCROLLBAR=yes
-  DEFAULT_wxUSE_SEARCHCTRL=yes
-  DEFAULT_wxUSE_SLIDER=yes
-  DEFAULT_wxUSE_SPINBTN=yes
-  DEFAULT_wxUSE_SPINCTRL=yes
-  DEFAULT_wxUSE_SPLITTER=yes
-  DEFAULT_wxUSE_STATBMP=yes
-  DEFAULT_wxUSE_STATBOX=yes
-  DEFAULT_wxUSE_STATLINE=yes
-  DEFAULT_wxUSE_STATUSBAR=yes
-  DEFAULT_wxUSE_TAB_DIALOG=yes
-  DEFAULT_wxUSE_TOGGLEBTN=yes
-  DEFAULT_wxUSE_TOOLBAR=yes
-  DEFAULT_wxUSE_TOOLBAR_NATIVE=yes
-  DEFAULT_wxUSE_TOOLTIPS=yes
-  DEFAULT_wxUSE_TREEBOOK=yes
-  DEFAULT_wxUSE_TOOLBOOK=yes
-  DEFAULT_wxUSE_TREECTRL=yes
-  DEFAULT_wxUSE_POPUPWIN=yes
-  DEFAULT_wxUSE_TIPWINDOW=yes
-elif test "$wxUSE_CONTROLS" = "no"; then
-  DEFAULT_wxUSE_ACCEL=no
-  DEFAULT_wxUSE_ANIMATIONCTRL=no
-  DEFAULT_wxUSE_BMPBUTTON=no
-  DEFAULT_wxUSE_BUTTON=no
-  DEFAULT_wxUSE_CALCTRL=no
-  DEFAULT_wxUSE_CARET=no
-  DEFAULT_wxUSE_COLLPANE=no
-  DEFAULT_wxUSE_COMBOBOX=no
-  DEFAULT_wxUSE_CHECKBOX=no
-  DEFAULT_wxUSE_CHECKLISTBOX=no
-  DEFAULT_wxUSE_CHOICE=no
-  DEFAULT_wxUSE_CHOICEBOOK=no
-  DEFAULT_wxUSE_COLOURPICKERCTRL=no
-  DEFAULT_wxUSE_COMBOBOX=no
-  DEFAULT_wxUSE_DATEPICKCTRL=no
-  DEFAULT_wxUSE_DISPLAY=no
-  DEFAULT_wxUSE_DETECT_SM=no
-  DEFAULT_wxUSE_DIRPICKERCTRL=no
-  DEFAULT_wxUSE_FILEPICKERCTRL=no
-  DEFAULT_wxUSE_FONTPICKERCTRL=no
-  DEFAULT_wxUSE_GAUGE=no
-  DEFAULT_wxUSE_GRID=no
-  DEFAULT_wxUSE_HYPERLINKCTRL=no
-  DEFAULT_wxUSE_DATAVIEWCTRL=no
-  DEFAULT_wxUSE_IMAGLIST=no
-  DEFAULT_wxUSE_LISTBOOK=no
-  DEFAULT_wxUSE_LISTBOX=no
-  DEFAULT_wxUSE_LISTCTRL=no
-  DEFAULT_wxUSE_NOTEBOOK=no
-  DEFAULT_wxUSE_RADIOBOX=no
-  DEFAULT_wxUSE_RADIOBTN=no
-  DEFAULT_wxUSE_SASH=no
-  DEFAULT_wxUSE_SCROLLBAR=no
-  DEFAULT_wxUSE_SEARCHCTRL=no
-  DEFAULT_wxUSE_SLIDER=no
-  DEFAULT_wxUSE_SPINBTN=no
-  DEFAULT_wxUSE_SPINCTRL=no
-  DEFAULT_wxUSE_SPLITTER=no
-  DEFAULT_wxUSE_STATBMP=no
-  DEFAULT_wxUSE_STATBOX=no
-  DEFAULT_wxUSE_STATLINE=no
-  DEFAULT_wxUSE_STATUSBAR=no
-  DEFAULT_wxUSE_TAB_DIALOG=no
-  DEFAULT_wxUSE_TOGGLEBTN=no
-  DEFAULT_wxUSE_TOOLBAR=no
-  DEFAULT_wxUSE_TOOLBAR_NATIVE=no
-  DEFAULT_wxUSE_TOOLTIPS=no
-  DEFAULT_wxUSE_TREEBOOK=no
-  DEFAULT_wxUSE_TOOLBOOK=no
-  DEFAULT_wxUSE_TREECTRL=no
-  DEFAULT_wxUSE_POPUPWIN=no
-  DEFAULT_wxUSE_TIPWINDOW=no
+dnl even with --disable-controls, some may be enabled by an explicit
+dnl --enable-<control> later on the command line -- but by default all will be
+dnl disabled
+if test "$wxUSE_CONTROLS" = "no"; then
+    DEFAULT_wxUSE_ACCEL=no
+    DEFAULT_wxUSE_ANIMATIONCTRL=no
+    DEFAULT_wxUSE_BMPBUTTON=no
+    DEFAULT_wxUSE_BUTTON=no
+    DEFAULT_wxUSE_CALCTRL=no
+    DEFAULT_wxUSE_CARET=no
+    DEFAULT_wxUSE_CHECKBOX=no
+    DEFAULT_wxUSE_CHECKLISTBOX=no
+    DEFAULT_wxUSE_CHOICE=no
+    DEFAULT_wxUSE_CHOICEBOOK=no
+    DEFAULT_wxUSE_COLLPANE=no
+    DEFAULT_wxUSE_COLOURPICKERCTRL=no
+    DEFAULT_wxUSE_COMBOBOX=no
+    DEFAULT_wxUSE_COMBOBOX=no
+    DEFAULT_wxUSE_COMMANDLINKBUTTON=no
+    DEFAULT_wxUSE_DATAVIEWCTRL=no
+    DEFAULT_wxUSE_DATEPICKCTRL=no
+    DEFAULT_wxUSE_DETECT_SM=no
+    DEFAULT_wxUSE_DIRPICKERCTRL=no
+    DEFAULT_wxUSE_DISPLAY=no
+    DEFAULT_wxUSE_FILECTRL=no
+    DEFAULT_wxUSE_FILEPICKERCTRL=no
+    DEFAULT_wxUSE_FONTPICKERCTRL=no
+    DEFAULT_wxUSE_GAUGE=no
+    DEFAULT_wxUSE_GRID=no
+    DEFAULT_wxUSE_HEADERCTRL=no
+    DEFAULT_wxUSE_HYPERLINKCTRL=no
+    DEFAULT_wxUSE_IMAGLIST=no
+    DEFAULT_wxUSE_LISTBOOK=no
+    DEFAULT_wxUSE_LISTBOX=no
+    DEFAULT_wxUSE_LISTCTRL=no
+    DEFAULT_wxUSE_NOTEBOOK=no
+    DEFAULT_wxUSE_POPUPWIN=no
+    DEFAULT_wxUSE_RADIOBOX=no
+    DEFAULT_wxUSE_RADIOBTN=no
+    DEFAULT_wxUSE_RICHMSGDLG=no
+    DEFAULT_wxUSE_REARRANGECTRL=no
+    DEFAULT_wxUSE_SASH=no
+    DEFAULT_wxUSE_SCROLLBAR=no
+    DEFAULT_wxUSE_SEARCHCTRL=no
+    DEFAULT_wxUSE_SLIDER=no
+    DEFAULT_wxUSE_SPINBTN=no
+    DEFAULT_wxUSE_SPINCTRL=no
+    DEFAULT_wxUSE_SPLITTER=no
+    DEFAULT_wxUSE_STATBMP=no
+    DEFAULT_wxUSE_STATBOX=no
+    DEFAULT_wxUSE_STATLINE=no
+    DEFAULT_wxUSE_STATUSBAR=no
+    DEFAULT_wxUSE_TIPWINDOW=no
+    DEFAULT_wxUSE_TOGGLEBTN=no
+    DEFAULT_wxUSE_TOOLBAR=no
+    DEFAULT_wxUSE_TOOLBAR_NATIVE=no
+    DEFAULT_wxUSE_TOOLBOOK=no
+    DEFAULT_wxUSE_TOOLTIPS=no
+    DEFAULT_wxUSE_TREEBOOK=no
+    DEFAULT_wxUSE_TREECTRL=no
 fi
 
+dnl please keep the settings below in alphabetical order
 WX_ARG_FEATURE(accel,       [  --enable-accel          use accelerators], wxUSE_ACCEL)
 WX_ARG_FEATURE(animatectrl, [  --enable-animatectrl    use wxAnimationCtrl class], wxUSE_ANIMATIONCTRL)
-WX_ARG_FEATURE(button,      [  --enable-button         use wxButton class], wxUSE_BUTTON)
 WX_ARG_FEATURE(bmpbutton,   [  --enable-bmpbutton      use wxBitmapButton class], wxUSE_BMPBUTTON)
 WX_ARG_FEATURE(bmpcombobox, [  --enable-bmpcombobox    use wxBitmapComboBox class], wxUSE_BITMAPCOMBOBOX)
+WX_ARG_FEATURE(button,      [  --enable-button         use wxButton class], wxUSE_BUTTON)
 WX_ARG_FEATURE(calendar,    [  --enable-calendar       use wxCalendarCtrl class], wxUSE_CALCTRL)
 WX_ARG_FEATURE(caret,       [  --enable-caret          use wxCaret class], wxUSE_CARET)
 WX_ARG_FEATURE(checkbox,    [  --enable-checkbox       use wxCheckBox class], wxUSE_CHECKBOX)
@@ -801,25 +939,33 @@ WX_ARG_FEATURE(collpane,    [  --enable-collpane       use wxCollapsiblePane cla
 WX_ARG_FEATURE(colourpicker,[  --enable-colourpicker   use wxColourPickerCtrl class], wxUSE_COLOURPICKERCTRL)
 WX_ARG_FEATURE(combobox,    [  --enable-combobox       use wxComboBox class], wxUSE_COMBOBOX)
 WX_ARG_FEATURE(comboctrl,   [  --enable-comboctrl      use wxComboCtrl class], wxUSE_COMBOCTRL)
+WX_ARG_FEATURE(commandlinkbutton, [  --enable-commandlinkbutton      use wxCommmandLinkButton class], wxUSE_COMMANDLINKBUTTON)
+WX_ARG_FEATURE(dataviewctrl,[  --enable-dataviewctrl   use wxDataViewCtrl class], wxUSE_DATAVIEWCTRL)
 WX_ARG_FEATURE(datepick,    [  --enable-datepick       use wxDatePickerCtrl class], wxUSE_DATEPICKCTRL)
+WX_ARG_FEATURE(detect_sm,   [  --enable-detect_sm      use code to detect X11 session manager], wxUSE_DETECT_SM)
 WX_ARG_FEATURE(dirpicker,   [  --enable-dirpicker      use wxDirPickerCtrl class], wxUSE_DIRPICKERCTRL)
 WX_ARG_FEATURE(display,     [  --enable-display        use wxDisplay class], wxUSE_DISPLAY)
-WX_ARG_FEATURE(detect_sm,   [  --enable-detect_sm      use code to detect X11 session manager], wxUSE_DETECT_SM)
 WX_ARG_FEATURE(editablebox, [  --enable-editablebox    use wxEditableListBox class], wxUSE_EDITABLELISTBOX)
+WX_ARG_FEATURE(filectrl,    [  --enable-filectrl       use wxFileCtrl class], wxUSE_FILECTRL)
 WX_ARG_FEATURE(filepicker,  [  --enable-filepicker     use wxFilePickerCtrl class], wxUSE_FILEPICKERCTRL)
 WX_ARG_FEATURE(fontpicker,  [  --enable-fontpicker     use wxFontPickerCtrl class], wxUSE_FONTPICKERCTRL)
 WX_ARG_FEATURE(gauge,       [  --enable-gauge          use wxGauge class], wxUSE_GAUGE)
 WX_ARG_FEATURE(grid,        [  --enable-grid           use wxGrid class], wxUSE_GRID)
-WX_ARG_FEATURE(dataviewctrl,[  --enable-dataviewctrl   use wxDataViewCtrl class], wxUSE_DATAVIEWCTRL)
+WX_ARG_FEATURE(headerctrl,  [  --enable-headerctrl     use wxHeaderCtrl class], wxUSE_HEADERCTRL)
 WX_ARG_FEATURE(hyperlink,   [  --enable-hyperlink      use wxHyperlinkCtrl class], wxUSE_HYPERLINKCTRL)
 WX_ARG_FEATURE(imaglist,    [  --enable-imaglist       use wxImageList class], wxUSE_IMAGLIST)
+WX_ARG_FEATURE(infobar,     [  --enable-infobar        use wxInfoBar class], wxUSE_INFOBAR)
 WX_ARG_FEATURE(listbook,    [  --enable-listbook       use wxListbook class], wxUSE_LISTBOOK)
 WX_ARG_FEATURE(listbox,     [  --enable-listbox        use wxListBox class], wxUSE_LISTBOX)
 WX_ARG_FEATURE(listctrl,    [  --enable-listctrl       use wxListCtrl class], wxUSE_LISTCTRL)
 WX_ARG_FEATURE(notebook,    [  --enable-notebook       use wxNotebook class], wxUSE_NOTEBOOK)
+WX_ARG_FEATURE(notifmsg,    [  --enable-notifmsg       use wxNotificationMessage class], wxUSE_NOTIFICATION_MESSAGE)
 WX_ARG_FEATURE(odcombobox,  [  --enable-odcombobox     use wxOwnerDrawnComboBox class], wxUSE_ODCOMBOBOX)
+WX_ARG_FEATURE(popupwin,    [  --enable-popupwin       use wxPopUpWindow class], wxUSE_POPUPWIN)
 WX_ARG_FEATURE(radiobox,    [  --enable-radiobox       use wxRadioBox class], wxUSE_RADIOBOX)
 WX_ARG_FEATURE(radiobtn,    [  --enable-radiobtn       use wxRadioButton class], wxUSE_RADIOBTN)
+WX_ARG_FEATURE(richmsgdlg,  [  --enable-richmsgdlg     use wxRichMessageDialog class], wxUSE_RICHMSGDLG)
+WX_ARG_FEATURE(rearrangectrl,[  --enable-rearrangectrl  use wxRearrangeList/Ctrl/Dialog], wxUSE_REARRANGECTRL)
 WX_ARG_FEATURE(sash,        [  --enable-sash           use wxSashWindow class], wxUSE_SASH)
 WX_ARG_FEATURE(scrollbar,   [  --enable-scrollbar      use wxScrollBar class and scrollable windows], wxUSE_SCROLLBAR)
 WX_ARG_FEATURE(searchctrl,  [  --enable-searchctrl     use wxSearchCtrl class], wxUSE_SEARCHCTRL)
@@ -832,17 +978,15 @@ WX_ARG_FEATURE(statbox,     [  --enable-statbox        use wxStaticBox class], w
 WX_ARG_FEATURE(statline,    [  --enable-statline       use wxStaticLine class], wxUSE_STATLINE)
 WX_ARG_FEATURE(stattext,    [  --enable-stattext       use wxStaticText class], wxUSE_STATTEXT)
 WX_ARG_FEATURE(statusbar,   [  --enable-statusbar      use wxStatusBar class], wxUSE_STATUSBAR)
-WX_ARG_FEATURE(tabdialog,   [  --enable-tabdialog      use wxTabControl class], wxUSE_TAB_DIALOG)
 WX_ARG_FEATURE(taskbaricon, [  --enable-taskbaricon    use wxTaskBarIcon class], wxUSE_TASKBARICON)
+WX_ARG_FEATURE(tbarnative,  [  --enable-tbarnative     use native wxToolBar class], wxUSE_TOOLBAR_NATIVE)
 WX_ARG_FEATURE(textctrl,    [  --enable-textctrl       use wxTextCtrl class], wxUSE_TEXTCTRL)
+WX_ARG_FEATURE(tipwindow,   [  --enable-tipwindow      use wxTipWindow class], wxUSE_TIPWINDOW)
 WX_ARG_FEATURE(togglebtn,   [  --enable-togglebtn      use wxToggleButton class], wxUSE_TOGGLEBTN)
 WX_ARG_FEATURE(toolbar,     [  --enable-toolbar        use wxToolBar class], wxUSE_TOOLBAR)
-WX_ARG_FEATURE(tbarnative,  [  --enable-tbarnative     use native wxToolBar class], wxUSE_TOOLBAR_NATIVE)
-WX_ARG_FEATURE(treebook,    [  --enable-treebook       use wxTreebook class], wxUSE_TREEBOOK)
 WX_ARG_FEATURE(toolbook,    [  --enable-toolbook       use wxToolbook class], wxUSE_TOOLBOOK)
+WX_ARG_FEATURE(treebook,    [  --enable-treebook       use wxTreebook class], wxUSE_TREEBOOK)
 WX_ARG_FEATURE(treectrl,    [  --enable-treectrl       use wxTreeCtrl class], wxUSE_TREECTRL)
-WX_ARG_FEATURE(tipwindow,   [  --enable-tipwindow      use wxTipWindow class], wxUSE_TIPWINDOW)
-WX_ARG_FEATURE(popupwin,    [  --enable-popupwin       use wxPopUpWindow class], wxUSE_POPUPWIN)
 
 dnl ---------------------------------------------------------------------------
 dnl common dialogs
@@ -879,6 +1023,7 @@ WX_ARG_FEATURE(joystick,    [  --enable-joystick       use wxJoystick], wxUSE_JO
 WX_ARG_FEATURE(metafile,    [  --enable-metafiles      use wxMetaFile (Win32 only)], wxUSE_METAFILE)
 WX_ARG_FEATURE(dragimage,   [  --enable-dragimage      use wxDragImage], wxUSE_DRAGIMAGE)
 WX_ARG_FEATURE(accessibility,[  --enable-accessibility  enable accessibility support], wxUSE_ACCESSIBILITY)
+WX_ARG_FEATURE(uiactionsim,  [  --enable-uiactionsim    use wxUIActionSimulator (experimental)], wxUSE_UIACTIONSIMULATOR)
 
 dnl ---------------------------------------------------------------------------
 dnl support for image formats that do not rely on external library
@@ -892,7 +1037,7 @@ WX_ARG_FEATURE(tga,         [  --enable-tga            use tga images (TGA file
 WX_ARG_FEATURE(iff,         [  --enable-iff            use iff images (IFF file format)], wxUSE_IFF)
 WX_ARG_FEATURE(pnm,         [  --enable-pnm            use pnm images (PNM file format)], wxUSE_PNM)
 WX_ARG_FEATURE(xpm,         [  --enable-xpm            use xpm images (XPM file format)], wxUSE_XPM)
-WX_ARG_FEATURE(ico_cur,     [  --enable-icocur         use Windows ICO and CUR formats], wxUSE_ICO_CUR)
+WX_ARG_FEATURE(ico_cur,     [  --enable-ico_cur        use Windows ICO and CUR formats], wxUSE_ICO_CUR)
 
 dnl ---------------------------------------------------------------------------
 dnl wxMSW-only options
@@ -900,127 +1045,20 @@ dnl ---------------------------------------------------------------------------
 
 WX_ARG_FEATURE(dccache,     [  --enable-dccache        cache temporary wxDC objects (Win32 only)], wxUSE_DC_CACHEING)
 WX_ARG_FEATURE(ps-in-msw,   [  --enable-ps-in-msw      use PS printing in wxMSW (Win32 only)], wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW)
-WX_ARG_FEATURE(ownerdrawn,  [  --enable-ownerdrawn     use owner drawn controls (Win32 only)], wxUSE_OWNER_DRAWN)
-WX_ARG_FEATURE(regkey,      [  --enable-regkey         use wxRegKey class (Win32 only)], wxUSE_REGKEY)
+WX_ARG_FEATURE(ownerdrawn,  [  --enable-ownerdrawn     use owner drawn controls (Win32 and OS/2 only)], wxUSE_OWNER_DRAWN)
 WX_ARG_FEATURE(uxtheme,     [  --enable-uxtheme        enable support for Windows XP themed look (Win32 only)], wxUSE_UXTHEME)
 WX_ARG_FEATURE(wxdib,       [  --enable-wxdib          use wxDIB class (Win32 only)], wxUSE_DIB)
 
+dnl this one is not really MSW-specific but it exists mainly to be turned off
+dnl under MSW, it should be off by default on the other platforms
+if test "$wxUSE_MSW" != 1; then
+    DEFAULT_wxUSE_AUTOID_MANAGEMENT=no
 fi
-dnl for GUI only
 
-dnl cache the options values before (may be) aborting below
-WX_ARG_CACHE_FLUSH
+WX_ARG_FEATURE(autoidman,   [  --enable-autoidman      use automatic ids management], wxUSE_AUTOID_MANAGEMENT)
 
-dnl check that no more than one toolkit is given and that if none are given that
-dnl we have a default one
-
-AC_MSG_CHECKING(for toolkit)
-
-# In Wine, we need to default to MSW, not GTK or MOTIF
-if test "$wxUSE_WINE" = "yes"; then
-    DEFAULT_DEFAULT_wxUSE_GTK=0
-    DEFAULT_DEFAULT_wxUSE_MOTIF=0
-    DEFAULT_DEFAULT_wxUSE_MSW=1
-    wxUSE_SHARED=no
-    CC=${CC:-winegcc}
-    CXX=${CXX:-wineg++}
-fi
-
-
-if test "$wxUSE_GUI" = "yes"; then
-
-    if test "$USE_BEOS" = 1; then
-        AC_MSG_ERROR([BeOS GUI is not supported yet, use --disable-gui])
-    fi
-
-    if test "$TOOLKIT_GIVEN" = 1; then
-      dnl convert "yes", "any" or a number to 1 and "no" to 0
-      for toolkit in `echo $ALL_TOOLKITS`; do
-        var=wxUSE_$toolkit
-        eval "value=\$${var}"
-        if test "x$value" = "xno"; then
-          eval "$var=0"
-        elif test "x$value" != "x"; then
-          eval "$var=1"
-        fi
-
-        if test "x$value" != "x" -a "x$value" != "xyes" -a "x$value" != "xno"; then
-          eval "wx${toolkit}_VERSION=$value"
-        fi
-      done
-    else
-      dnl try to guess the most apropriate toolkit for this platform
-      for toolkit in `echo $ALL_TOOLKITS`; do
-        if test "$has_toolkit_in_cache" != 1; then
-          var=DEFAULT_DEFAULT_wxUSE_$toolkit
-        else
-          var=DEFAULT_wxUSE_$toolkit
-
-          eval "version=\$DEFAULT_wx${toolkit}_VERSION"
-          if test "x$version" != "x"; then
-            eval "wx${toolkit}_VERSION=$version"
-          fi
-        fi
-        eval "wxUSE_$toolkit=\$${var}"
-      done
-    fi
-
-    dnl we suppose that expr is available (maybe there is a better way to do
-    dnl this? what about using ALL_TOOLKITS? TODO)
-    NUM_TOOLKITS=`expr ${wxUSE_COCOA:-0} + ${wxUSE_GTK:-0} + ${wxUSE_MAC:-0} \
-                  + ${wxUSE_MGL:-0} + ${wxUSE_DFB:-0} + ${wxUSE_MICROWIN:-0} \
-                  + ${wxUSE_MOTIF:-0} + ${wxUSE_MSW:-0} + ${wxUSE_X11:-0}`
-
-    dnl Allow wxUSE_PM only for OS/2 with EMX.
-    case "${host}" in
-      *-pc-os2_emx | *-pc-os2-emx )
-        NUM_TOOLKITS=`expr ${NUM_TOOLKITS} + ${wxUSE_PM:-0}`
-    esac
-
-    case "$NUM_TOOLKITS" in
-      1)
-      ;;
-      0)
-        AC_MSG_ERROR(Please specify a toolkit -- cannot determine the default for ${host})
-      ;;
-      *)
-        AC_MSG_ERROR(Please specify at most one toolkit (maybe some are cached in configarg.cache?))
-    esac
-
-    # to be removed when --disable-gtk2 isn't needed
-    if test "x$wxUSE_GTK2" = "xyes"; then
-        wxGTK_VERSION=2
-    elif test "x$wxUSE_GTK2" = "xno"; then
-        wxGTK_VERSION=1
-    fi
-
-    dnl cache the wxUSE_<TOOLKIT> values too
-    for toolkit in `echo $ALL_TOOLKITS`; do
-      var=wxUSE_$toolkit
-      eval "value=\$${var}"
-      if test "x$value" != x; then
-        cache_var=CACHE_$toolkit
-        eval "cache=\$${cache_var}"
-        if test "$cache" = 1; then
-          echo "$var=$value" >> ${wx_arg_cache_file}
-          eval "version=\$wx${toolkit}_VERSION"
-          if test "x$version" != "x"; then
-            echo "wx${toolkit}_VERSION=$version" >> ${wx_arg_cache_file}
-          fi
-        fi
-        if test "$value" = 1; then
-          toolkit_echo=`echo $toolkit | tr "[[A-Z]]" "[[a-z]]"`
-          AC_MSG_RESULT($toolkit_echo)
-        fi
-      fi
-    done
-else
-    if test "x$host_alias" != "x"; then
-        AC_MSG_RESULT(base ($host_alias hosted) only)
-    else
-        AC_MSG_RESULT(base only)
-    fi
 fi
+dnl for GUI only
 
 dnl ---------------------------------------------------------------------------
 dnl Checks for programs
@@ -1037,7 +1075,7 @@ dnl   defines CFLAGS
 dnl
 dnl this magic incantation is needed to prevent AC_PROG_CC from setting the
 dnl default CFLAGS (something like "-g -O2") -- we don't need this as we add
-dnl -g and -O flags ourselves below
+dnl (if not already present in C*FLAGS) the -g and -O flags ourselves below
 CFLAGS=${CFLAGS:=}
 AC_BAKEFILE_PROG_CC
 
@@ -1045,53 +1083,255 @@ dnl is -traditional needed for correct compilations
 dnl   adds -traditional for gcc if needed
 AC_PROG_GCC_TRADITIONAL
 
-dnl C++-compiler checks
-dnl   defines CXX with the compiler to use
-dnl   defines GXX with yes if using gxx
-dnl   defines GXX empty if not using gxx
-dnl   defines CXXFLAGS
-dnl
-dnl see CFLAGS line above
-CXXFLAGS=${CXXFLAGS:=}
-AC_BAKEFILE_PROG_CXX
+dnl C++-compiler checks
+dnl   defines CXX with the compiler to use
+dnl   defines GXX with yes if using gxx
+dnl   defines GXX empty if not using gxx
+dnl   defines CXXFLAGS
+dnl
+dnl see CFLAGS line above
+CXXFLAGS=${CXXFLAGS:=}
+AC_BAKEFILE_PROG_CXX
+
+dnl configure always sets CXX to something as it falls back to g++ even if no
+dnl C++ compiler was found, but we prefer to abort now with a clear error
+dnl message rather than give errors about all tests failures below
+if test "$CXX" = "g++" -a "$GXX" != "yes"; then
+    AC_MSG_ERROR([C++ compiler is needed to build wxWidgets])
+fi
+
+dnl ar command
+dnl   defines AR with the appropriate command
+dnl
+dnl For Sun CC AC_BAKEFILE below sets AR to the compiler itself.
+if test "x$SUNCXX" != xyes; then
+    AC_CHECK_TOOL(AR, ar)
+    if test "x$AR" = "x" ; then
+        AC_MSG_ERROR([ar is needed to build wxWidgets])
+    fi
+fi
+
+dnl ---------------------------------------------------------------------------
+dnl Mac-specific SDK/architectures checks
+dnl ---------------------------------------------------------------------------
+
+if test "$wxUSE_MAC" = 1; then
+
+retest_macosx_linking=no
+
+OSX_ARCH_OPTS=""
+if test "x$wxUSE_MAC_ARCH" != xno; then
+    OSX_ARCH_OPTS="-arch $wxUSE_MAC_ARCH"
+fi
+
+dnl Support the old --enable-universal_binary in case anyone was using it.
+    if test "x$wxUSE_UNIVERSAL_BINARY" != xno ; then
+        dnl --enable-universal_binary uses a default SDK (currently 10.4u)
+        dnl --enable-universal_binary=SDK names a path to an SDK
+        if test "x$wxUSE_UNIVERSAL_BINARY" == xyes; then
+            # Implicitly turn on the new --with-macosx-sdk using the default
+            # SDK which provides the behavior this option has always had.
+            if test "x$wxUSE_MACOSX_SDK" = "x"; then
+                AC_MSG_WARN([Enabling default SDK due to --enable-universal_binary.])
+                AC_MSG_WARN([If you don't want this, specify --without-macosx-sdk])
+                wxUSE_MACOSX_SDK=yes
+            fi
+        else
+            # Complain to user if he specified an argument to --enable-universal_binary
+            # and also 1) specified --with-macosx-sdk using the default (yes) or
+            # 2) specified --with-macosx-sdk using a path or 3) specified
+            # --without-macosx-sdk (no).
+            if test "x$wxUSE_MACOSX_SDK" != "x" ; then
+                AC_MSG_FAILURE([Please specify the new --with-macosx-sdk=PATH and do not specify an arg to --enable-universal_binary])
+            else
+                # Put the SDK path into the wxUSE_MACOSX_SDK.  We don't have to
+                # special-case the empty string because the below test simply
+                # converts "no" to the empty string anyway.
+                wxUSE_MACOSX_SDK="$wxUSE_UNIVERSAL_BINARY"
+                dnl Warn about deprecated usage.
+                AC_MSG_WARN([Please use --with-macosx-sdk=PATH and --enable-universal_binary without an argument])
+            fi
+        fi
+        dnl FIXME: I think it would be better to put this into CC, CXX, and LD rather than the flags.
+        OSX_ARCH_OPTS="-arch ppc -arch i386"
+       if test "$wxUSE_OSX_COCOA" = 1; then
+            OSX_ARCH_OPTS="$OSX_ARCH_OPTS -arch x86_64"
+        fi
+        AC_MSG_CHECKING([for universal binary architectures])
+       AC_MSG_RESULT([$OSX_ARCH_OPTS])
+
+        dnl NOTE: Only the compiler driver needs arch flags.  The link editor
+        dnl is incapable of using them but the compiler driver (which we use
+        dnl as LD when building dynamic libraries) uses them to invoke the
+        dnl real ld multiple times.  If we moved to libtool -dynamic we would
+        dnl need no arch flags because libtool automatically invokes ld for
+        dnl every architecture found in the fat input files.
+        dnl
+        dnl For static library builds, AR/RANLIB automatically create proper
+        dnl fat archives although AR is unable to update them once RANLIB has
+        dnl made them into proper fat archives.  Fortunately, our link process
+        dnl simply removes the .a file before using ar to create a new one.
+        dnl If we did move to libtool -static we still wouldn't need arch flags
+        dnl because libtool automatically figures it out based on input.
+        retest_macosx_linking=yes
+
+        dnl HACK: PCH could be made to work by precompiling for each architecture into separate directories
+        dnl and including all architecture directories with each compiler invocation.
+        dnl That would require a major rework of Bakefile and at the same time it would be nice to have
+        dnl Objective-C++ precompiled headers.
+        AC_MSG_WARN([Disabling precompiled headers due to universal binary build.])
+        bk_use_pch=no
+    fi
+
+CXXFLAGS="$OSX_ARCH_OPTS $CXXFLAGS"
+CFLAGS="$OSX_ARCH_OPTS $CFLAGS"
+OBJCXXFLAGS="$OSX_ARCH_OPTS $OBJCXXFLAGS"
+OBJCFLAGS="$OSX_ARCH_OPTS $OBJCFLAGS"
+LDFLAGS="$OSX_ARCH_OPTS $LDFLAGS"
+
+dnl Set up the Mac OS X SDK.  We do this early so configure tests will occur
+dnl with the SDK in place.
+dnl NOTE: We clobber wxUSE_MACOSX_SDK with the SDK path
+if test "x$wxUSE_MACOSX_SDK" = "xno"; then
+    wxUSE_MACOSX_SDK=
+elif test "x$wxUSE_MACOSX_SDK" = "xyes"; then
+    # TODO: Search for most recent SDK and use it.
+    wxUSE_MACOSX_SDK="/Developer/SDKs/MacOSX10.4u.sdk"
+fi
+
+
+if test "x$wxUSE_MACOSX_SDK" != "x"; then
+    AC_MSG_CHECKING([for SDK directory $wxUSE_MACOSX_SDK])
+    if ! test -d "$wxUSE_MACOSX_SDK"; then
+        AC_MSG_FAILURE([not found])
+    else
+        AC_MSG_RESULT([exists])
+    fi
+    MACOSX_SDK_OPTS="-isysroot $wxUSE_MACOSX_SDK"
+    eval "CC=\"$CC $MACOSX_SDK_OPTS\""
+    eval "CXX=\"$CXX $MACOSX_SDK_OPTS\""
+    eval "LD=\"$LD $MACOSX_SDK_OPTS\""
+    retest_macosx_linking=yes
+    dnl NOTE: When libtool is used in lieu of AR/RANLIB (i.e. in static mode)
+    dnl the syslibroot makes no difference.  We aren't using libtool now but
+    dnl if we ever did, be aware that you don't need to worry about it.
+fi
+
+dnl Set up the deployment target
+dnl No   : Don't specify a min version even if using an SDK
+dnl Yes  : Use the version from the SDK if used, otherwise same as no
+dnl Param: Use the specified version
+if test "x$wxUSE_MACOSX_VERSION_MIN" = "xno"; then
+    wxUSE_MACOSX_VERSION_MIN=
+elif test "x$wxUSE_MACOSX_VERSION_MIN" = "xyes"; then
+    if test "x$wxUSE_MACOSX_SDK" != "x"; then
+        AC_MSG_CHECKING([SDK deployment version])
+dnl We need to quote the next line where we don't need macros and do need [] in the regex
+[
+        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/'`
+]
+        # If that failed, try again with the new key
+        if test "x$MACOSX_SDK_PLIST_VERSION_MIN" == "x"; then
+[
+            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/'`
+]
+        fi
+
+        if test "x$MACOSX_SDK_PLIST_VERSION_MIN" != "x"; then
+            wxUSE_MACOSX_VERSION_MIN=$MACOSX_SDK_PLIST_VERSION_MIN
+            AC_MSG_RESULT([$wxUSE_MACOSX_VERSION_MIN])
+        else
+            AC_MSG_WARN([Could not determine deployment target from SDKSettings.plist])
+            wxUSE_MACOSX_VERSION_MIN=
+        fi
+    else
+        wxUSE_MACOSX_VERSION_MIN=
+    fi
+elif test "x$wxUSE_MACOSX_VERSION_MIN" = "x"; then
+    AC_CHECK_PROGS(OSX_SW_VERS, sw_vers)
+    if test "$OSX_SW_VERS" != ""; then
+        OSX_VERSION=`sw_vers -productVersion | grep 10.[[0-9]]`
+    else
+        dnl can't determine it (happens e.g. when cross-compiling) so use a
+        dnl conservative default
+        AC_MSG_WARN([Assuming OS X 10.4, use --with-macosx-version-min to override.])
+        OSX_VERSION="10.4"
+    fi
+
+    case "$OSX_VERSION" in
+        10.4* )
+            wxUSE_MACOSX_VERSION_MIN=10.4
+            ;;
+
+        * )
+            if test "$wxUSE_OSX_CARBON" = 1; then
+                # otherwise configure stops on leopard for universal_binary
+                wxUSE_MACOSX_VERSION_MIN=10.4
+            else
+                # for Cocoa, use 10.5 to be able to compile it in 64 bits too
+                wxUSE_MACOSX_VERSION_MIN=10.5
+            fi
+            ;;
+    esac
+fi
+
+NEEDS_GCC40="no"
+if test "x$wxUSE_MACOSX_VERSION_MIN" == "x10.4"; then
+    NEEDS_GCC40="yes"
+fi
 
-dnl configure always sets CXX to something as it falls back to g++ even if no
-dnl C++ compiler was found, but we prefer to abort now with a clear error
-dnl message rather than give errors about all tests failures below
-if test "$CXX" = "g++" -a "$GXX" != "yes"; then
-    AC_MSG_ERROR([C++ compiler is needed to build wxWidgets])
+if test "$wxUSE_OSX_CARBON" = 1; then
+    NEEDS_GCC40="yes"
 fi
 
-dnl ranlib command
-dnl   defines RANLIB with the appropriate command
-AC_PROG_RANLIB
+if test "x$NEEDS_GCC40" == "xyes"; then
+    # gcc 4.2 cannot compile 10.4 compatible code, so if the user is using it
+    # and wants 10.4 compatible code, then 'downgrade' to 4.0
+    # This is also the simplest way to get 32-bit binaries on Snow Leopard.
+    if test "x$CC" = "xgcc"; then
+        CCVERSION=`$CC --version | grep 4.[[2-9]].`
+        if test "x$CCVERSION" != "x"; then
+            echo "$as_me:$LINENO: WARNING: gcc >= 4.2 cannot compile 10.4 compatible code. Using gcc 4.0 instead."
+            CC="/usr/bin/gcc-4.0"
+        fi
+    fi
 
-dnl ar command
-dnl   defines AR with the appropriate command
-dnl
-dnl For Sun CC AC_BAKEFILE below sets AR to the compiler itself.
-if test "x$SUNCXX" != xyes; then
-    AC_CHECK_TOOL(AR, ar)
-    if test "x$AR" = "x" ; then
-        AC_MSG_ERROR([ar is needed to build wxWidgets])
+    if test "x$CXX" = "xg++"; then
+        CCVERSION=`$CXX --version | grep 4.[[2-9]].`
+        if test "x$CCVERSION" != "x"; then
+            CXX="/usr/bin/g++-4.0"
+        fi
+    fi
+fi
+
+if test "x$wxUSE_MACOSX_VERSION_MIN" != "x"; then
+    if test "$wxUSE_OSX_IPHONE" = 1; then
+        MACOSX_VERSION_MIN_OPTS="-miphoneos-version-min=$wxUSE_MACOSX_VERSION_MIN"
+    else
+        MACOSX_VERSION_MIN_OPTS="-mmacosx-version-min=$wxUSE_MACOSX_VERSION_MIN"
     fi
+    eval "CC=\"$CC $MACOSX_VERSION_MIN_OPTS\""
+    eval "CXX=\"$CXX $MACOSX_VERSION_MIN_OPTS\""
+    eval "LD=\"$LD $MACOSX_VERSION_MIN_OPTS\""
+    retest_macosx_linking=yes
 fi
 
-dnl install checks
-dnl   defines INSTALL with the appropriate command
-AC_PROG_INSTALL
+dnl If either an SDK or a version option was added, make sure that we can
+dnl still compile and link both C and C++.  If we didn't do this, then most
+dnl of the remaining tests would fail.
+if test "x$retest_macosx_linking" = "xyes"; then
+    AC_LANG_PUSH(C)
+    AC_MSG_CHECKING([if C compiler works with SDK/version options])
+    AC_TRY_LINK([],[],[AC_MSG_RESULT([yes])],[AC_MSG_FAILURE([no.  Try a different SDK]); exit 1])
+    AC_LANG_POP()
 
-dnl   make install path absolute (if not already);
-dnl   will fail with (some) MSDOS paths
-case ${INSTALL} in
-  /* ) # Absolute
-     ;;
-  ?:* ) # Drive letter, considered as absolute.
-     ;;
-  *)
-     INSTALL=`pwd`/${INSTALL} ;;
-esac
+    AC_LANG_PUSH(C++)
+    AC_MSG_CHECKING([if C++ compiler works with SDK/version options])
+    AC_TRY_LINK([],[],[AC_MSG_RESULT([yes])],[AC_MSG_FAILURE([no.  Try a different SDK]); exit 1])
+    AC_LANG_POP()
+fi
 
+fi dnl wxUSE_MAC
 
 case "${host}" in
 
@@ -1106,91 +1346,6 @@ case "${host}" in
         ;;
 esac
 
-dnl strip command
-dnl   defines STRIP as strip or nothing (true) if not found
-AC_CHECK_TOOL(STRIP, strip, true)
-
-dnl Win32 tools
-if test "$wxUSE_WINE" = "yes"; then
-    AC_CHECK_TOOL(WINDRES, wrc)
-    RESCOMP="$WINDRES"
-else
-    case "${host}" in
-    *-*-cygwin* | *-*-mingw32* )
-        dnl Bakefile CVS (as of 2005-11-24) now detects windres properly
-        dnl ... maybe it does, but it does not make it available here
-        dnl anymore, so do it ourselves still.
-        AC_CHECK_TOOL(WINDRES, windres)
-        RESCOMP="$WINDRES"
-        AC_CHECK_TOOL(DLLTOOL, dlltool)
-        ;;
-    esac
-fi
-
-dnl does make support "-include" (only GNU make does AFAIK)?
-AC_CACHE_CHECK([if make is GNU make], wx_cv_prog_makeisgnu,
-[
-    if ( ${SHELL-sh} -c "${MAKE-make} --version" 2> /dev/null |
-            $EGREP -s GNU > /dev/null); then
-        wx_cv_prog_makeisgnu="yes"
-    else
-        wx_cv_prog_makeisgnu="no"
-    fi
-])
-
-if test "x$wx_cv_prog_makeisgnu" = "xyes"; then
-    IF_GNU_MAKE=""
-else
-    IF_GNU_MAKE="#"
-fi
-
-AC_SUBST(IF_GNU_MAKE)
-
-dnl we don't need to check for VPATH support in GNU make - it does have it
-if test "x$wx_cv_prog_makeisgnu" != "xyes"; then
-dnl check if VPATH works
-AC_CACHE_CHECK([if make supports VPATH], wx_cv_prog_makevpath, [
-dnl create Makefile
-cat - << EOF > confMake
-check : file
-       cp \$? \$@
-       cp \$? final_file
-EOF
-
-if test ! -d sub ; then
-  mkdir sub
-fi
-echo dummy > sub/file
-${MAKE-make} -f confMake VPATH=sub 2>&5 > /dev/null
-RESULT=$?
-rm -f sub/file check final_file confMake
-rmdir sub
-if test "$RESULT" = 0; then
-  wx_cv_prog_makevpath="yes"
-else
-  wx_cv_prog_makevpath="no"
-fi
-])
-
-if test "x$wx_cv_prog_makevpath" != "xyes"; then
-AC_MSG_ERROR([
-You need a make-utility that is able to use the variable
-VPATH correctly.
-If your version of make does not support VPATH correctly,
-please install GNU-make (possibly as gmake), and start
-configure with the following command:
-export MAKE=gmake; ./configure  for sh-type shells
-setenv MAKE gmake; ./configure  for csh-type shells
-Also please do remember to use gmake in this case every time
-you are trying to compile.
-])
-fi dnl make without VPATH
-fi dnl not GNU make
-
-dnl needed for making link to setup.h
-AC_PROG_LN_S
-
-
 dnl ------------------------------------------------------------------------
 dnl Platform specific tests
 dnl ------------------------------------------------------------------------
@@ -1431,7 +1586,7 @@ dnl ------------------------------------------------------------------------
 
 dnl Note: non-empty last parameter makes check compile-only,
 dnl   skipping worthless preprocessing check
-AC_CHECK_HEADERS(stdlib.h fnmatch.h langinfo.h malloc.h unistd.h wchar.h,,, [AC_INCLUDES_DEFAULT()])
+AC_CHECK_HEADERS(langinfo.h wchar.h,,, [AC_INCLUDES_DEFAULT])
 
 dnl maybe wchar_t is in wcstr.h if we don't have wchar.h?
 if test "$ac_cv_header_wchar_h" != "yes"; then
@@ -1480,7 +1635,7 @@ case "${host}" in
     ;;
     *-hp-hpux* )
         AC_CHECK_SIZEOF(long long, 0)
-        if test "$ac_cv_sizeof_long_long" != "0"; then
+        if test "$ac_cv_sizeof_long_long" != 0; then
             dnl HPUX 10.20 headers need this define in order to use long long definitions
             CPPFLAGS="-D_INCLUDE_LONGLONG $CPPFLAGS"
         fi
@@ -1509,7 +1664,7 @@ AC_CHECK_SIZEOF(wchar_t, 0,
         #include <stdio.h>
     ]
 )
-if test "$ac_cv_sizeof_wchar_t" != "0"; then
+if test "$ac_cv_sizeof_wchar_t" != 0; then
     wxUSE_WCHAR_T=yes
 else
     wxUSE_WCHAR_T=no
@@ -1617,76 +1772,79 @@ fi
 
 fi dnl wxUSE_VARARG_MACROS == yes
 
+
 dnl check for large file support
+LARGEFILE_CPPFLAGS=
 AC_SYS_LARGEFILE
+if test "$ac_cv_sys_file_offset_bits" = "64"; then
+    LARGEFILE_CPPFLAGS="-D_FILE_OFFSET_BITS=64"
+elif test "$ac_cv_sys_large_files" = 1; then
+    LARGEFILE_CPPFLAGS="-D_LARGE_FILES"
+fi
 
 dnl we need to define _FILE_OFFSET_BITS or _LARGE_FILES on the compiler command
 dnl line because otherwise the system headers risk being included before
 dnl wx/defs.h which defines these constants leading to inconsistent
 dnl sizeof(off_t) in different source files of the same program and linking
 dnl problems
-if test "x$wx_largefile" = "xyes"; then
-    if test "x$ac_cv_sys_file_offset_bits" = "x64"; then
-        WXCONFIG_CPPFLAGS="$WXCONFIG_CPPFLAGS -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES"
-
-        dnl We get "Large Files (ILP32) not supported in strict ANSI mode."
-        dnl #error from HP standard headers unless __STDC_EXT__ is defined.
-        dnl The compiler should define it automatically, but some old g++
-        dnl versions don't define it, so test and add it if necessary. AFAIK
-        dnl the problem only affects the C++ compiler so it is added to
-        dnl CXXFLAGS only.
-        if test "$USE_HPUX" = 1 -a "$GXX" = "yes"; then
-            AC_CACHE_CHECK(
-                [if -D__STDC_EXT__ is required],
-                wx_cv_STDC_EXT_required,
-                [
-                    AC_LANG_PUSH(C++)
-                    AC_TRY_COMPILE(
-                        [],
-                        [
-                            #ifndef __STDC_EXT__
-                                choke me
-                            #endif
-                        ],
-                        wx_cv_STDC_EXT_required=no,
-                        wx_cv_STDC_EXT_required=yes
-                    )
-                    AC_LANG_POP()
-                ]
-            )
-            if test "x$wx_cv_STDC_EXT_required" = "xyes"; then
-                WXCONFIG_CXXFLAGS="$WXCONFIG_CXXFLAGS -D__STDC_EXT__"
-            fi
+if test -n "$LARGEFILE_CPPFLAGS"; then
+    WXCONFIG_CPPFLAGS="$WXCONFIG_CPPFLAGS $LARGEFILE_CPPFLAGS"
+
+    dnl We get "Large Files (ILP32) not supported in strict ANSI mode."
+    dnl #error from HP standard headers unless __STDC_EXT__ is defined.
+    dnl The compiler should define it automatically, but some old g++
+    dnl versions don't define it, so test and add it if necessary. AFAIK
+    dnl the problem only affects the C++ compiler so it is added to
+    dnl CXXFLAGS only.
+    if test "$USE_HPUX" = 1 -a "$GXX" = "yes"; then
+        AC_CACHE_CHECK(
+            [if -D__STDC_EXT__ is required],
+            wx_cv_STDC_EXT_required,
+            [
+                AC_LANG_PUSH(C++)
+                AC_TRY_COMPILE(
+                    [],
+                    [
+                        #ifndef __STDC_EXT__
+                            choke me
+                        #endif
+                    ],
+                    wx_cv_STDC_EXT_required=no,
+                    wx_cv_STDC_EXT_required=yes
+                )
+                AC_LANG_POP()
+            ]
+        )
+        if test "x$wx_cv_STDC_EXT_required" = "xyes"; then
+            WXCONFIG_CXXFLAGS="$WXCONFIG_CXXFLAGS -D__STDC_EXT__"
         fi
-    else
-        WXCONFIG_CPPFLAGS="$WXCONFIG_CPPFLAGS -D_LARGE_FILES"
-    fi
-    dnl AC_FUNC_FSEEKO sets HAVE_FSEEKO and $ac_cv_sys_largefile_source
-    AC_FUNC_FSEEKO
-    if test "$ac_cv_sys_largefile_source" != no; then
-        WXCONFIG_CPPFLAGS="$WXCONFIG_CPPFLAGS -D_LARGEFILE_SOURCE=$ac_cv_sys_largefile_source"
     fi
 fi
 
+dnl AC_FUNC_FSEEKO sets HAVE_FSEEKO and $ac_cv_sys_largefile_source
+dnl
+dnl it may be affected by large file flags (this happens under HP-UX 11 for
+dnl example) so set them before using it and also use C++ to ensure that we get
+dnl errors, not warnings, about the missing functions
+AC_LANG_PUSH(C++)
+old_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $LARGEFILE_CPPFLAGS"
+AC_FUNC_FSEEKO
+CPPFLAGS="$old_CPPFLAGS"
+AC_LANG_POP()
+if test "$ac_cv_sys_largefile_source" != no; then
+    WXCONFIG_CPPFLAGS="$WXCONFIG_CPPFLAGS -D_LARGEFILE_SOURCE=$ac_cv_sys_largefile_source"
+fi
+
 dnl check for bytesex stuff (don't use AC_C_BIGENDIAN to allow cross-compiling)
 WX_C_BIGENDIAN
 
 dnl check for iostream (as opposed to iostream.h) standard header
 WX_CPP_NEW_HEADERS(, AC_DEFINE(wxUSE_IOSTREAMH))
 
-dnl check whether C++ compiler supports bool built-in type
-WX_CPP_BOOL
-
 dnl check whether C++ compiler supports explicit keyword
 WX_CPP_EXPLICIT
 
-dnl check whether C++ compiler supports C++ casts
-AC_CXX_CONST_CAST
-AC_CXX_REINTERPRET_CAST
-AC_CXX_STATIC_CAST
-dnl we don't use HAVE_DYNAMIC_CAST anywhere right now...
-dnl AC_CXX_DYNAMIC_CAST
-
 dnl With Sun CC, temporaries have block scope by default. This flag is needed
 dnl to get the expression scope behaviour that conforms to the standard.
 if test "x$SUNCXX" = xyes; then
@@ -1701,18 +1859,57 @@ if test "x$SUNCC" = xyes; then
     CFLAGS="-erroff=E_NO_EXPLICIT_TYPE_GIVEN $CFLAGS"
 fi
 
-dnl SGI mipsPro compiler gives this warning for "conversion from pointer to
-dnl same-sized integral type" even when there is an explicit cast and as there
-dnl is no way to turn it off and there are hundreds of these warnings in wx
-dnl sources, just turn it off for now
+dnl SGI mipsPro compiler version 7.4.4 and later (and maybe some earlier
+dnl versions too but it's known that 7.4.2 doesn't give this warning but does
+dnl instead warn about "unknown warning number 3970" which explains that we
+dnl don't want to do this for it) gives this warning for "conversion from
+dnl pointer to same-sized integral type" even when there is an explicit cast
+dnl and as there is no way to turn it off and there are hundreds of these
+dnl warnings in wx sources, just turn it off for now
 dnl
 dnl a better long term solution would be to use #pragma set/reset woff in
 dnl wxPtrToUInt() and use it instead of casts elsewhere
 if test "x$SGICC" = "xyes"; then
-    CFLAGS="-woff 3970 $CFLAGS"
+    AC_CACHE_CHECK([if cc version is 7.4.4 or greater],
+        wx_cv_prog_sgicc744,
+        [
+            AC_TRY_COMPILE([],
+                [
+                    #if _SGI_COMPILER_VERSION >= 744
+                    chock me: mipsPro is 7.4.4 or later
+                    #endif
+                ],
+                wx_cv_prog_sgicc744=no,
+                wx_cv_prog_sgicc744=yes
+            )
+        ]
+    )
+
+    if test "x$wx_cv_prog_sgicc744" = "xyes"; then
+        CFLAGS="-woff 3970 $CFLAGS"
+    fi
 fi
 if test "x$SGICXX" = "xyes"; then
-    CXXFLAGS="-woff 3970 $CXXFLAGS"
+    AC_CACHE_CHECK([if CC version is 7.4.4 or greater],
+        wx_cv_prog_sgicxx744,
+        [
+            AC_LANG_PUSH(C++)
+            AC_TRY_COMPILE([],
+                [
+                    #if _SGI_COMPILER_VERSION >= 744
+                    chock me: mipsPro is 7.4.4 or later
+                    #endif
+                ],
+                wx_cv_prog_sgicxx744=no,
+                wx_cv_prog_sgicxx744=yes
+            )
+            AC_LANG_POP()
+        ]
+    )
+
+    if test "x$wx_cv_prog_sgicxx744" = "xyes"; then
+        CXXFLAGS="-woff 3970 $CXXFLAGS"
+    fi
 fi
 
 dnl HP-UX c89/aCC compiler warnings
@@ -1726,7 +1923,11 @@ fi
 if test "x$HPCXX" = "xyes"; then
     dnl 2340: "value copied to temporary, reference to temporary used": very
     dnl       painful as triggered by any occurrence of user-defined conversion
-    CXXFLAGS="+W 2340 $CXXFLAGS"
+    dnl 4232: "conversion from 'Foo *' to a more strictly aligned type 'Bar *'
+    dnl       may cause misaligned access": this might indicate a real problem
+    dnl       but any use of GTK+ cast macros results in it so it's unusable
+    dnl       for wxGTK code
+    CXXFLAGS="+W 2340,4232 $CXXFLAGS"
 fi
 
 dnl DEC/Compaq/HP cxx warnings
@@ -1801,7 +2002,7 @@ if test "$wxUSE_STD_STRING" = "yes" -o "$wxUSE_STL" = "yes"; then
         if test "$wx_cv_class_stdbasicstring" != yes; then
             if test "$wxUSE_STL" = "yes"; then
                 AC_MSG_ERROR([Can't use --enable-stl without $std_string or std::basic_string<$char_type>])
-            elif grep wxUSE_STD_STRING $wx_arg_cache_file >/dev/null; then
+            elif test "$wxUSE_STD_STRING" = "yes"; then
                 AC_MSG_ERROR([Can't use --enable-std_string without $std_string or std::basic_string<$char_type>])
             else
                 AC_MSG_WARN([No $std_string or std::basic_string<$char_type>, switching to --disable-std_string])
@@ -1817,7 +2018,7 @@ if test "$wxUSE_STD_IOSTREAM" = "yes"; then
                    [#include <iostream>])
 
     if test "$wxUSE_STD_IOSTREAM" != "yes"; then
-        if grep wxUSE_STD_IOSTREAM $wx_arg_cache_file >/dev/null; then
+        if test "$wxUSE_STD_IOSTREAM" = "yes"; then
             AC_MSG_ERROR([Can't use --enable-std_iostreams without std::istream and std::ostream])
         else
             AC_MSG_WARN([No std::iostreams, switching to --disable-std_iostreams])
@@ -1868,48 +2069,97 @@ if test "$wxUSE_STL" = "yes"; then
         AC_DEFINE(HAVE_STD_STRING_COMPARE)
     fi
 
-    dnl check for hash_map and hash_set headers
-    AC_CHECK_HEADER([hash_map],
-        [AC_CACHE_CHECK([for standard hash_map and hash_set],
-            wx_cv_class_stdhashmapset,
-            [AC_TRY_COMPILE([#include <hash_map>
-                #include <hash_set>],
-                [std::hash_map<double*, char*, std::hash<double*>, std::equal_to<double*> > test1;
-                 std::hash_set<char*, std::hash<char*>, std::equal_to<char*> > test2;],
-                wx_cv_class_stdhashmapset=yes,
-                wx_cv_class_stdhashmapset=no)
-            ]
-        )],
-        [],
-        [ ]
-    )
-
-    if test "$wx_cv_class_stdhashmapset" = yes; then
-        AC_DEFINE(HAVE_HASH_MAP)
-        AC_DEFINE(HAVE_STD_HASH_MAP)
+    if test "$wx_cv_class_gnuhashmapset" = yes; then
+         AC_DEFINE(HAVE_EXT_HASH_MAP)
+         AC_DEFINE(HAVE_GNU_CXX_HASH_MAP)
     fi
 
-    AC_CHECK_HEADER([ext/hash_map],
-        [AC_CACHE_CHECK([for GNU hash_map and hash_set],
-            wx_cv_class_gnuhashmapset,
-            [AC_TRY_COMPILE([#include <ext/hash_map>
-                #include <ext/hash_set>],
-                [__gnu_cxx::hash_map<double*, char*, __gnu_cxx::hash<double*>, std::equal_to<double*> > test1;
-                 __gnu_cxx::hash_set<char*, __gnu_cxx::hash<char*>, std::equal_to<char*> > test2;],
-                wx_cv_class_gnuhashmapset=yes,
-                wx_cv_class_gnuhashmapset=no)
+    AC_CHECK_HEADER([unordered_map],
+        [AC_CACHE_CHECK([for unordered_map and unordered_set in std],
+            wx_cv_class_stdunorderedmapset,
+            [AC_TRY_COMPILE([#include <unordered_map>
+                #include <unordered_set>],
+                [std::unordered_map<double*, char*> test1;
+                 std::unordered_set<char*> test2;],
+                wx_cv_class_stdunorderedmapset=yes,
+                wx_cv_class_stdunorderedmapset=no)
             ]
         )],
         [],
         [ ]
     )
 
-    if test "$wx_cv_class_gnuhashmapset" = yes; then
-         AC_DEFINE(HAVE_EXT_HASH_MAP)
-         AC_DEFINE(HAVE_GNU_CXX_HASH_MAP)
+    if test "$wx_cv_class_stdunorderedmapset" = yes; then
+         AC_DEFINE(HAVE_STD_UNORDERED_MAP)
+         AC_DEFINE(HAVE_STD_UNORDERED_SET)
+    else
+        AC_CHECK_HEADER([tr1/unordered_map],
+            [AC_CACHE_CHECK([for unordered_map and unordered_set in std::tr1],
+                wx_cv_class_tr1unorderedmapset,
+                [AC_TRY_COMPILE([#include <tr1/unordered_map>
+                    #include <tr1/unordered_set>],
+                    [std::tr1::unordered_map<double*, char*> test1;
+                     std::tr1::unordered_set<char*> test2;
+            #if defined(__GNUC__) && (__GNUC__==4) && (__GNUC_MINOR__<2)
+            #error can't use unordered_{map,set} with gcc-4.[01]: http://gcc.gnu.org/PR24389
+            #endif],
+                    wx_cv_class_tr1unorderedmapset=yes,
+                    wx_cv_class_tr1unorderedmapset=no)
+                ]
+            )],
+            [],
+            [ ]
+        )
+
+        if test "$wx_cv_class_tr1unorderedmapset" = yes; then
+            AC_DEFINE(HAVE_TR1_UNORDERED_MAP)
+            AC_DEFINE(HAVE_TR1_UNORDERED_SET)
+        else
+            dnl check for hash_map and hash_set headers
+            AC_CHECK_HEADER([hash_map],
+                [AC_CACHE_CHECK([for std::hash_map and hash_set],
+                    wx_cv_class_stdhashmapset,
+                    [AC_TRY_COMPILE([#include <hash_map>
+                        #include <hash_set>],
+                        [std::hash_map<double*, char*, std::hash<double*>, std::equal_to<double*> > test1;
+                         std::hash_set<char*, std::hash<char*>, std::equal_to<char*> > test2;],
+                        wx_cv_class_stdhashmapset=yes,
+                        wx_cv_class_stdhashmapset=no)
+                    ]
+                )],
+                [],
+                [ ]
+            )
+
+            if test "$wx_cv_class_stdhashmapset" = yes; then
+                AC_DEFINE(HAVE_HASH_MAP)
+                AC_DEFINE(HAVE_STD_HASH_MAP)
+            fi
+
+            AC_CHECK_HEADER([ext/hash_map],
+                [AC_CACHE_CHECK([for GNU hash_map and hash_set],
+                    wx_cv_class_gnuhashmapset,
+                    [AC_TRY_COMPILE([#include <ext/hash_map>
+                        #include <ext/hash_set>],
+                        [__gnu_cxx::hash_map<double*, char*, __gnu_cxx::hash<double*>, std::equal_to<double*> > test1;
+                         __gnu_cxx::hash_set<char*, __gnu_cxx::hash<char*>, std::equal_to<char*> > test2;],
+                        wx_cv_class_gnuhashmapset=yes,
+                        wx_cv_class_gnuhashmapset=no)
+                    ]
+                )],
+                [],
+                [ ]
+            )
+
+        fi
     fi
 fi
 
+AC_CHECK_HEADERS([type_traits tr1/type_traits])
+
+dnl check for atomic operations builtins for wx/atomic.h:
+WX_ATOMIC_BUILTINS
+
 dnl pop C++
 AC_LANG_POP()
 
@@ -1929,6 +2179,12 @@ dnl In the same vein. Motif 2.1 should be tried before Motif 1.2 for the
 dnl systems which have both (AIX 4.x does)
 SEARCH_INCLUDE="\
     /usr/local/include        \
+    /usr/local/X11/include    \
+    /usr/local/include/X11    \
+    /usr/local/X11R7/include  \
+    /usr/local/X11R6/include  \
+    /usr/local/include/X11R7  \
+    /usr/local/include/X11R6  \
                               \
     /usr/Motif-2.1/include    \
     /usr/Motif-1.2/include    \
@@ -1939,31 +2195,29 @@ SEARCH_INCLUDE="\
                               \
     /usr/include/Xm           \
                               \
+    /usr/X11R7/include        \
     /usr/X11R6/include        \
     /usr/X11R6.4/include      \
-    /usr/X11R5/include        \
-    /usr/X11R4/include        \
                               \
+    /usr/include/X11R7        \
     /usr/include/X11R6        \
-    /usr/include/X11R5        \
-    /usr/include/X11R4        \
-                              \
-    /usr/local/X11R6/include  \
-    /usr/local/X11R5/include  \
-    /usr/local/X11R4/include  \
-                              \
-    /usr/local/include/X11R6  \
-    /usr/local/include/X11R5  \
-    /usr/local/include/X11R4  \
                               \
     /usr/X11/include          \
     /usr/include/X11          \
-    /usr/local/X11/include    \
-    /usr/local/include/X11    \
                               \
     /usr/XFree86/include/X11  \
     /usr/pkg/include          \
                               \
+    /usr/local/X1R5/include  \
+    /usr/local/include/X11R5  \
+    /usr/X11R5/include        \
+    /usr/include/X11R5        \
+                              \
+    /usr/local/X11R4/include  \
+    /usr/local/include/X11R4  \
+    /usr/X11R4/include        \
+    /usr/include/X11R4        \
+                              \
     /usr/openwin/share/include"
 
 dnl try to find out the standard lib locations for the systems with multiple
@@ -2189,7 +2443,7 @@ if test "$wxUSE_REGEX" != "no"; then
     AC_DEFINE(wxUSE_REGEX)
 
     if test "$wxUSE_UNICODE" = "yes" -a "$wxUSE_REGEX" = "yes"; then
-        AC_MSG_WARN([Defaulting to the the builtin regex library for Unicode build.])
+        AC_MSG_WARN([Defaulting to the builtin regex library for Unicode build.])
         wxUSE_REGEX=builtin
     fi
 
@@ -2338,7 +2592,7 @@ if test "$wxUSE_LIBPNG" != "no" ; then
             AC_CHECK_HEADER(png.h,,, [ ])
 
             if test "$ac_cv_header_png_h" = "yes"; then
-                AC_CHECK_LIB(png, png_check_sig, PNG_LINK=" -lpng -lz", , [-lz -lm])
+                AC_CHECK_LIB(png, png_sig_cmp, PNG_LINK=" -lpng -lz", , [-lz -lm])
             fi
 
             if test "x$PNG_LINK" = "x" ; then
@@ -2354,14 +2608,14 @@ if test "$wxUSE_LIBPNG" != "no" ; then
             fi
         fi
     fi
-
-    SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS png"
 fi
 
 dnl ------------------------------------------------------------------------
 dnl Check for jpeg library
 dnl ------------------------------------------------------------------------
 
+dnl this check must be done before the check for libtiff as libtiff uses
+dnl libjpeg itself
 JPEG_LINK=
 if test "$wxUSE_LIBJPEG" != "no" ; then
     AC_DEFINE(wxUSE_LIBJPEG)
@@ -2477,6 +2731,18 @@ if test "$wxUSE_LIBTIFF" != "no" ; then
             wxUSE_LIBTIFF=sys
         fi
     fi
+    if test "$wxUSE_LIBTIFF" = "builtin" ; then
+        if test "$wxUSE_LIBJPEG" = "no"; then
+            dnl we have to prevent the builtin libtiff configure from building the
+            dnl library with JPEG support as this was explicitly disabled by user,
+            dnl but unfortunately it needs --disable-jpeg and not --without-libjpeg
+            dnl (which will be passed to it anyhow as configure passes arguments to
+            dnl the top-level script to all the other ones called recursively), so
+            dnl we need to hack around this
+            ac_configure_args="$ac_configure_args --disable-jpeg"
+        fi
+        AC_CONFIG_SUBDIRS([src/tiff])
+    fi
 fi
 
 dnl ------------------------------------------------------------------------
@@ -2578,10 +2844,15 @@ if test "$USE_WIN32" = 1 ; then
     ],
     [ ])
 
-    dnl --- FIXME: This is still a somewhat random list of libs,
-    dnl ---        some of them should probably be included conditionally.
-    LIBS="$LIBS -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -lctl3d32 -ladvapi32 -lwsock32 -lgdi32"
-
+    LIBS="$LIBS -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -ladvapi32 -lwsock32 -lgdi32"
+    case "${host}" in
+        x86_64-*-mingw32* )
+            dnl we need to define this to embed the manifest for correct
+            dnl platform from wx/msw/wx.rc (this is not needed for x86 which is
+            dnl the default in wx/msw/rcdefs.h)
+            WINDRES_CPU_DEFINE="--define WX_CPU_AMD64"
+        ;;
+    esac
     if test "$wxUSE_ACCESSIBILITY" = "yes" ; then
         LIBS="$LIBS -loleacc"
     fi
@@ -2592,16 +2863,6 @@ if test "$USE_WIN32" = 1 ; then
             LIBS="$LIBS -lkernel32 -luser32"
     esac
 
-    dnl add extra odbc libs if we have compiled in odbc
-    if test "$wxUSE_ODBC" = "sys" ; then
-        wxUSE_ODBC = "yes"
-    fi
-    if test "$wxUSE_ODBC" = "yes" ; then
-        LIBS=" -lodbc32 -lole32 -loleaut32 $LIBS"
-        AC_DEFINE(wxUSE_ODBC)
-    fi
-    dnl We might want to abort here if wxUSE_ODBC="builtin" isn't supported on msw.
-
     dnl This one is still used by some sample makefiles.
     RESFLAGS="--include-dir \$(top_srcdir)/include --include-dir \$(top_srcdir)/\$(program_dir) --define __WIN32__ --define __WIN95__ --define __GNUWIN32__"
     RESPROGRAMOBJ="\$(PROGRAM)_resources.o"
@@ -2625,10 +2886,10 @@ if test "$wxUSE_GUI" = "yes"; then
 
     WXGTK12=
     WXGTK127=
-    WXGTK20=
+    WXGTK2=
     WXGPE=
 
-    if test "$wxUSE_COCOA" = 1 ; then
+    if test "$wxUSE_OLD_COCOA" = 1 ; then
         if test "$wxUSE_PRINTING_ARCHITECTURE" = "yes"; then
             AC_MSG_WARN([Printing not supported under wxCocoa yet, disabled])
             wxUSE_PRINTING_ARCHITECTURE=no
@@ -2687,7 +2948,7 @@ if test "$wxUSE_GUI" = "yes"; then
                             fi
                     esac
 
-                    AM_PATH_GTK_2_0(2.0.0, wx_cv_lib_gtk=2.0, , $GTK_MODULES)
+                    AM_PATH_GTK_2_0(2.4.0, wx_cv_lib_gtk=2.0, , $GTK_MODULES)
 
                     dnl Solaris also requires -lX11 for static lib
                     case "${host}" in
@@ -2716,7 +2977,7 @@ if test "$wxUSE_GUI" = "yes"; then
                     dnl we need to cache GTK_CFLAGS and GTK_LIBS for the
                     dnl subsequent runs
                     wx_cv_cflags_gtk=$GTK_CFLAGS
-                    wx_cv_libs_gtk=`echo $GTK_LIBS | sed -e 's/ -l[[^ ]]*cairo[[^ ]]*//g'`
+                    wx_cv_libs_gtk=$GTK_LIBS
                 fi
             ]
         )
@@ -2728,7 +2989,7 @@ if test "$wxUSE_GUI" = "yes"; then
         fi
 
         case "$wx_cv_lib_gtk" in
-            2.0)    WXGTK20=1
+            2.0)    WXGTK2=1
                     TOOLKIT_VERSION=2
                     ;;
             1.2.7)  WXGTK127=1
@@ -2747,84 +3008,77 @@ libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
                     ;;
         esac
 
-        if test "$WXGTK20" = 1; then
+        if test "$WXGTK2" = 1; then
             save_CFLAGS="$CFLAGS"
             save_LIBS="$LIBS"
             CFLAGS="$wx_cv_cflags_gtk $CFLAGS"
             LIBS="$LIBS $wx_cv_libs_gtk"
 
-            dnl gtk_icon_size_lookup is not available in the GTK+ headers
-            dnl that have shipped with some versions of Sun's JDS. Not using
-            dnl AC_CHECK_FUNCS here since it only checks the function exists
-            dnl in the lib (not the header).
-            AC_CHECK_DECLS([gtk_icon_size_lookup], [],
-                           [AC_DEFINE(NEED_GTK_ICON_SIZE_LOOKUP)],
-                           [#include <gtk/gtk.h>])
-
-
-            dnl test if we have at least GTK+ 2.10:
-            AC_MSG_CHECKING([if GTK+ is version >= 2.10])
+            dnl test if we have at least GTK+ 2.18:
+            AC_MSG_CHECKING([if GTK+ is version >= 2.18])
             AC_TRY_COMPILE([
                             #include <gtk/gtk.h>
                            ],
                            [
-                            #if !GTK_CHECK_VERSION(2,10,0)
-                            Not GTK+ 2.10
+                            #if !GTK_CHECK_VERSION(2,18,0)
+                            Not GTK+ 2.18
                             #endif
                            ],
                            [
+                            AC_DEFINE(__WXGTK218__)
                             AC_DEFINE(__WXGTK210__)
                             AC_DEFINE(__WXGTK26__)
-                            AC_DEFINE(__WXGTK24__)
                             AC_MSG_RESULT([yes])
-                            ac_wxgtk210=1
+                            ac_wxgtk218=1
                            ],
                            [
                             AC_MSG_RESULT([no])
-                            ac_wxgtk210=0
+                            ac_wxgtk218=0
                            ])
 
-            if test "$ac_wxgtk210" = 0; then
-                dnl test if we have at least GTK+ 2.6:
-                AC_MSG_CHECKING([if GTK+ is version >= 2.6])
+            if test "$ac_wxgtk218" = 0; then
+                dnl test if we have at least GTK+ 2.10:
+                AC_MSG_CHECKING([if GTK+ is version >= 2.10])
                 AC_TRY_COMPILE([
                                 #include <gtk/gtk.h>
-                            ],
-                            [
-                                #if !GTK_CHECK_VERSION(2,6,0)
-                                Not GTK+ 2.6
+                               ],
+                               [
+                                #if !GTK_CHECK_VERSION(2,10,0)
+                                Not GTK+ 2.10
                                 #endif
-                            ],
-                            [
+                               ],
+                               [
+                                AC_DEFINE(__WXGTK210__)
                                 AC_DEFINE(__WXGTK26__)
-                                AC_DEFINE(__WXGTK24__)
-                                AC_MSG_RESULT([yes])
-                                ac_wxgtk26=1
-                            ],
-                            [
-                                AC_MSG_RESULT([no])
-                                ac_wxgtk26=0
-                            ])
-            fi
-
-            if test "$ac_wxgtk26" = 0; then
-                dnl test if we have at least GTK+ 2.4:
-                AC_MSG_CHECKING([if GTK+ is version >= 2.4])
-                AC_TRY_COMPILE([
-                                #include <gtk/gtk.h>
-                            ],
-                            [
-                                #if !GTK_CHECK_VERSION(2,4,0)
-                                Not GTK+ 2.4
-                                #endif
-                            ],
-                            [
-                                AC_DEFINE(__WXGTK24__)
                                 AC_MSG_RESULT([yes])
-                            ],
-                            [
+                                ac_wxgtk210=1
+                               ],
+                               [
                                 AC_MSG_RESULT([no])
-                            ])
+                                ac_wxgtk210=0
+                               ])
+
+                if test "$ac_wxgtk210" = 0; then
+                    dnl test if we have at least GTK+ 2.6:
+                    AC_MSG_CHECKING([if GTK+ is version >= 2.6])
+                    AC_TRY_COMPILE([
+                                    #include <gtk/gtk.h>
+                                ],
+                                [
+                                    #if !GTK_CHECK_VERSION(2,6,0)
+                                    Not GTK+ 2.6
+                                    #endif
+                                ],
+                                [
+                                    AC_DEFINE(__WXGTK26__)
+                                    AC_MSG_RESULT([yes])
+                                    ac_wxgtk26=1
+                                ],
+                                [
+                                    AC_MSG_RESULT([no])
+                                    ac_wxgtk26=0
+                                ])
+                fi
             fi
 
             CFLAGS="$save_CFLAGS"
@@ -2848,6 +3102,9 @@ libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
         TOOLKIT_INCLUDE="$wx_cv_cflags_gtk"
         GUI_TK_LIBRARY="$wx_cv_libs_gtk $GUI_TK_LIBRARY"
 
+        dnl disable GTK runtime type checks
+        TOOLKIT_INCLUDE="$TOOLKIT_INCLUDE -DG_DISABLE_CAST_CHECKS"
+
         AFMINSTALL=afminstall
         TOOLKIT=GTK
         GUIDIST=GTK_DIST
@@ -3157,9 +3414,9 @@ libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
         libsm_ice_link=""
         libs_found=0
         for libp in "" " -lXp"; do
-            if test "$libs_found" = "0"; then
+            if test "$libs_found" = 0; then
                 for libsm_ice in "" " -lSM -lICE"; do
-                    if test "$libs_found" = "0"; then
+                    if test "$libs_found" = 0; then
                         save_LIBS="$LIBS"
                         LIBS="$GUI_TK_LIBRARY -lXm ${libp} -lXmu -lXext -lXt${libsm_ice} -lX11"
                         save_CFLAGS=$CFLAGS
@@ -3192,7 +3449,7 @@ libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
             fi
         done
 
-        if test "$libs_found" = "0"; then
+        if test "$libs_found" = 0; then
             AC_MSG_RESULT([can't find the right libraries])
             AC_MSG_ERROR([can't link a simple motif program])
         fi
@@ -3325,7 +3582,7 @@ libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
         fi
     fi
 
-    if test "$wxUSE_MAC" = 1; then
+    if test "$wxUSE_OSX_CARBON" = 1; then
         AC_MSG_CHECKING([for compiler syntax to enable Pascal strings])
         if test "$GCC" = yes; then
             AC_MSG_RESULT([gcc])
@@ -3338,21 +3595,39 @@ libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
         fi
 
         if test "x$wxUSE_UNIX" = "xyes"; then
-            CPPFLAGS="$CPPFLAGS_PASCAL -I\${top_srcdir}/src/mac/carbon/morefilex -I/Developer/Headers/FlatCarbon $CPPFLAGS"
+            CPPFLAGS="$CPPFLAGS_PASCAL -I/Developer/Headers/FlatCarbon $CPPFLAGS"
         else
             dnl platform.h needs TARGET_CARBON before setup.h
-            CPPFLAGS="$CPPFLAGS_PASCAL -I\${top_srcdir}/src/mac/carbon/morefilex -DTARGET_CARBON $CPPFLAGS"
+            CPPFLAGS="$CPPFLAGS_PASCAL -DTARGET_CARBON $CPPFLAGS"
         fi
 
-        TOOLKIT=MAC
+        TOOLKIT=OSX_CARBON
         dnl we can't call this MAC_DIST or autoconf thinks its a macro
-        GUIDIST=MACX_DIST
+        GUIDIST=OSX_CARBON_DIST
         dnl wxMac version of wxBase and wxCocoa or wxBase-only built on Darwin
         dnl are different, so they need different names:
         WXBASEPORT="_carbon"
+
+        dnl in addition to defining __WXOSX_CARBON__ for this toolkit we want
+        dnl to also define these extra symbols to make it possible to test for
+        dnl any Mac port (__WXMAC__ is for backwards compatibility, __WXOSX__
+        dnl is a new name)
+        TOOLCHAIN_DEFS="${TOOLCHAIN_DEFS} -D__WXMAC__ -D__WXOSX__"
+    fi
+
+    if test "$wxUSE_OSX_COCOA" = 1; then
+        TOOLKIT=OSX_COCOA
+        GUIDIST=OSX_COCOA_DIST
+
+        dnl see the comment above in wxUSE_OSX_CARBON branch
+        TOOLCHAIN_DEFS="${TOOLCHAIN_DEFS} -D__WXMAC__ -D__WXOSX__"
     fi
 
-    if test "$wxUSE_COCOA" = 1; then
+    if test "$wxUSE_OSX_IPHONE" = 1; then
+        TOOLKIT=OSX_IPHONE
+    fi
+
+    if test "$wxUSE_OLD_COCOA" = 1; then
         TOOLKIT=COCOA
         GUIDIST=COCOA_DIST
     fi
@@ -3386,7 +3661,7 @@ libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
     if test "$TOOLKIT" = "PM" ; then
         TOOLKIT_DIR="os2"
     else
-        TOOLKIT_DIR=`echo ${TOOLKIT} | tr "[[A-Z]]" "[[a-z]]"`
+        TOOLKIT_DIR=`echo ${TOOLKIT} | tr '[[A-Z]]' '[[a-z]]'`
     fi
 
     if test "$wxUSE_UNIVERSAL" = "yes"; then
@@ -3424,11 +3699,9 @@ dnl ---------------------------------------------------------------------------
 dnl If UTF-8 support wasn't explicitly enabled or disabled, enable it only
 dnl for ports where it makes sense by default (GTK+, DirectFB):
 if test "$wxUSE_UNICODE" = "yes" -a "$wxUSE_UNICODE_UTF8" = "auto" ; then
-    if test "$TOOLKIT" = "DFB" ; then
+    if test "$USE_UNIX" = 1 -a "$wxUSE_DARWIN" != 1 ; then
         wxUSE_UNICODE_UTF8=yes
-    elif test "$TOOLKIT" = "GTK" -a "$WXGTK20" = "1" ; then
-        wxUSE_UNICODE_UTF8=yes
-    elif test "$USE_OS2" = "1" ; then
+    elif test "$USE_OS2" = 1 ; then
         dnl wide char support is quite incomplete in libc;
         dnl UTF-8 might actually work when evaluating/setting
         dnl code pages correctly, even for ports other than GTK20.
@@ -3443,79 +3716,28 @@ dnl Optional libraries included when system library is not used
 dnl ---------------------------------------------------------------------------
 
 dnl do this after test for X11 above so that we have a chance of finding Xlib.h
-if test "$wxUSE_GUI" = "yes"; then
-    if test "$wxUSE_UNIX" = "yes" -a "$wxUSE_PM" != 1; then
-        dnl defines HAVE_X11_XKBLIB_H
-        AC_CHECK_HEADERS([X11/Xlib.h],,, [ ])
-        AC_CHECK_HEADERS([X11/XKBlib.h],,,
-                         [
-                          #if HAVE_X11_XLIB_H
-                            #include <X11/Xlib.h>
-                          #endif
-                         ])
-    fi
-fi
-
-
-dnl ----------------------------------------------------------------
-dnl iODBC support
-dnl ----------------------------------------------------------------
-
-IODBC_C_SRC=""
-
-
-dnl ODBC is handled separately for MSW
-if test "$TOOLKIT" != "MSW" ; then
-
-    if test "$wxUSE_ODBC" = "sys" -o "$wxUSE_ODBC" = "yes" ; then
-        dnl This is not ideal we really ough to use the unixodbc-config
-        dnl  or iodbc-config if they exist.
-
-        AC_CHECK_HEADER([sql.h], [found_sql_h=1],, [ ])
-        if test "x$found_sql_h" = "x1" ; then
-            AC_CHECK_LIB(iodbc, SQLAllocEnv, ODBC_LINK=" -liodbc",
-            [
-                AC_CHECK_LIB(unixodbc, SQLAllocEnv, ODBC_LINK=" -lunixodbc",
-                [
-                    AC_CHECK_LIB(odbc, SQLAllocEnv, ODBC_LINK=" -lodbc")
-                ])
-            ])
-        fi
-        if test "x$ODBC_LINK" = "x" ; then
-            if test "$wxUSE_ODBC" = "sys" ; then
-                AC_MSG_ERROR([system ODBC library not found! Use --with-odbc=builtin to use built-in version])
-            else
-                AC_MSG_WARN([system ODBC library not found, will use built-in instead])
-                wxUSE_ODBC=builtin
-            fi
-        else
-            dnl we are using the system library
-            wxUSE_ODBC=sys
-        fi
-    fi
-
-    if test "$wxUSE_ODBC" = "builtin" ; then
-        AC_DEFINE(wxUSE_BUILTIN_IODBC)
+if test "$wxUSE_GUI" = "yes"; then
+    if test "$wxUSE_UNIX" = "yes" -a "$wxUSE_PM" != 1; then
+        dnl defines HAVE_X11_XKBLIB_H
+        AC_CHECK_HEADERS([X11/Xlib.h],,, [ ])
+        AC_CHECK_HEADERS([X11/XKBlib.h],,,
+                         [
+                          #if HAVE_X11_XLIB_H
+                            #include <X11/Xlib.h>
+                          #endif
+                         ])
     fi
 fi
 
-if test "$wxUSE_ODBC" != "no" ; then
-    AC_DEFINE(wxUSE_ODBC)
-    SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS db"
-
-    dnl is this still necessary?
-    WXCONFIG_CPPFLAGS="$WXCONFIG_CPPFLAGS -D_IODBC_"
-fi
 
 dnl ---------------------------------------------------------------------------
-dnl wxDisplay Sanity checks
+dnl wxDisplay checks
 dnl ---------------------------------------------------------------------------
 
+USE_XINERAMA=0
 if test "$wxUSE_DISPLAY" = "yes"; then
-dnl ---------------------------------------------------------------------------
-dnl Xinerama (for unix ) - Brian Victor
-dnl ---------------------------------------------------------------------------
-    if test "$wxUSE_UNIX" = "yes" -a "$wxUSE_MAC" != 1 -a "$wxUSE_COCOA" != 1; then
+    dnl Xinerama is used for wxGTK1/wxX11/wxMotif only
+    if test "$wxUSE_MOTIF" = 1 -o "$wxUSE_X11" = 1 -o "$wxUSE_GTK1" = 1; then
         AC_MSG_CHECKING([for Xinerama])
         WX_PATH_FIND_LIBRARIES([$SEARCH_LIB],Xinerama)
         if test "$ac_find_libraries" != "" ; then
@@ -3523,45 +3745,48 @@ dnl ---------------------------------------------------------------------------
             if test "$ac_path_to_link" != " -L/usr/lib" ; then
                 LDFLAGS="$LDFLAGS $ac_path_to_link"
             fi
+            USE_XINERAMA=1
             GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lXinerama"
             AC_MSG_RESULT([yes])
-
-            AC_MSG_CHECKING([for Xxf86vm extension])
-            WX_PATH_FIND_LIBRARIES([$SEARCH_LIB],Xxf86vm)
-            if test "$ac_find_libraries" != "" ; then
-                AC_MSG_RESULT([yes])
-                AC_CHECK_HEADERS([X11/extensions/xf86vmode.h],
-                                 [
-                                  GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lXxf86vm"
-                                 ],
-                                 [],
-                                 [
-                                      #if HAVE_X11_XLIB_H
-                                        #include <X11/Xlib.h>
-                                      #endif
-                                 ])
-            else
-                AC_MSG_RESULT([no])
-            fi
-
         else
             AC_MSG_RESULT([no])
             AC_MSG_WARN([Xinerama not found; disabling wxDisplay])
             wxUSE_DISPLAY="no"
         fi
     elif test "$wxUSE_MSW" = 1; then
-dnl ---------------------------------------------------------------------------
-dnl DirectDraw for MSW - optionally used by WxDisplay.
-dnl ---------------------------------------------------------------------------
+        dnl DirectDraw for MSW - optionally used by WxDisplay.
         AC_CHECK_HEADER([ddraw.h], [], [], [#include <windows.h>])
     fi
 fi
 
+if test "$wxUSE_DISPLAY" = "yes"; then
+    dnl wxGTK2 needs Xxf86vm as well as Xinerama-using ports from above
+    if test "$USE_XINERAMA" = 1 -o "$wxUSE_GTK" = 1; then
+        AC_MSG_CHECKING([for Xxf86vm extension])
+        WX_PATH_FIND_LIBRARIES([$SEARCH_LIB],Xxf86vm)
+        if test "$ac_find_libraries" != "" ; then
+            AC_MSG_RESULT([yes])
+            AC_CHECK_HEADERS([X11/extensions/xf86vmode.h],
+                             [
+                              GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lXxf86vm"
+                             ],
+                             [],
+                             [
+                                  #if HAVE_X11_XLIB_H
+                                    #include <X11/Xlib.h>
+                                  #endif
+                             ])
+        else
+            AC_MSG_RESULT([no])
+        fi
+    fi
+fi
+
 dnl ---------------------------------------------------------------------------
 dnl X11 session management
 dnl ---------------------------------------------------------------------------
 if test "$wxUSE_DETECT_SM" = "yes"; then
-    if test "$wxUSE_UNIX" = "yes" -a "$wxUSE_MAC" != 1 -a "$wxUSE_COCOA" != 1; then
+    if test "$wxUSE_UNIX" = "yes" -a "$wxUSE_MAC" != 1 -a "$wxUSE_OLD_COCOA" != 1; then
         AC_MSG_CHECKING([for -lSM - X11 session management])
         WX_PATH_FIND_LIBRARIES([$SEARCH_LIB],SM)
         if test "$ac_find_libraries" != "" ; then
@@ -3587,15 +3812,16 @@ dnl OpenGL libraries
 dnl ---------------------------------------------------------------------------
 
 USE_OPENGL=0
-if test "$wxUSE_OPENGL" = "yes"; then
-    if test "$wxUSE_MGL" = 1 -o "$wxUSE_DFB" = "1"; then
-        AC_MSG_WARN([wxGLCanvas not implemented for this port, library will be compiled without it.])
-        wxUSE_OPENGL="no"
-    elif test "$wxUSE_MAC" = 1 -o "$wxUSE_COCOA" = "1"; then
+if test "$wxUSE_OPENGL" = "yes" -o "$wxUSE_OPENGL" = "auto"; then
+
+    dnl look in glcanvas.h for the list of platforms supported by wxGlCanvas:
+
+    if test "$wxUSE_OSX_CARBON" = 1 -o "$wxUSE_OSX_COCOA" = 1 -o "$wxUSE_OLD_COCOA" = 1; then
         OPENGL_LIBS="-framework OpenGL -framework AGL"
     elif test "$wxUSE_MSW" = 1; then
         OPENGL_LIBS="-lopengl32 -lglu32"
-    else
+    elif test "$wxUSE_MOTIF" = 1 -o "$wxUSE_X11" = 1 -o "$wxUSE_GTK2" = 1 -o "$wxUSE_GTK" = 1; then
+
         dnl adjust CPPFLAGS to include GL/gl.h location if necessary
         dnl (/opt/graphics/OpenGL is for HP-UX systems, bug 925307)
         AC_MSG_CHECKING([for OpenGL headers])
@@ -3656,17 +3882,31 @@ if test "$wxUSE_OPENGL" = "yes"; then
                         AC_MSG_RESULT([no])
                     fi
                 fi
-            ])
+            ],, [ ])
         ],
         [],
         [ ])
 
         if test "x$OPENGL_LIBS" = "x"; then
-            dnl it should be an error and not a warning because OpenGL is not on
-            dnl by default and so if it had been explicitly requested, we
-            dnl shouldn't just fall back to compiling the library without it
-            AC_MSG_ERROR(OpenGL libraries not available)
+            if test "$wxUSE_OPENGL" = "yes"; then
+                AC_MSG_ERROR([OpenGL libraries not available])
+            else
+                dnl case wxUSE_OPENGL=auto
+                AC_MSG_WARN([OpenGL libraries not available, disabling support for OpenGL])
+                wxUSE_OPENGL=no
+                USE_OPENGL=0
+            fi
         fi
+    else
+        AC_MSG_WARN([wxGLCanvas not implemented for this port, library will be compiled without it.])
+        wxUSE_OPENGL="no"
+    fi
+
+    if test "$wxUSE_OPENGL" = "auto"; then
+        dnl if the OpenGL libraries were unavailable, this would have been
+        dnl changed to "no" above, if it wasn't, change it to "yes" as we've
+        dnl verified that we can indeed use OpenGL
+        wxUSE_OPENGL=yes
     fi
 
     if test "$wxUSE_OPENGL" = "yes"; then
@@ -3755,26 +3995,31 @@ if test "$wxUSE_SHARED" = "yes"; then
       ;;
 
       *-*-darwin* )
-        install_name_tool=`which install_name_tool`
+        install_name_tool=`which ${HOST_PREFIX}install_name_tool`
         if test "$install_name_tool" -a -x "$install_name_tool"; then
-            SAMPLES_RPATH_POSTLINK="\$(wx_top_builddir)/change-install-names \$(LIBDIRNAME) \$(prefix) \$@"
+            DYLIB_RPATH_POSTLINK="${HOST_PREFIX}install_name_tool -id \$@ \$@"
             cat <<EOF >change-install-names
 #!/bin/sh
 libnames=\`cd \${1} ; ls -1 | grep '\.[[0-9]][[0-9]]*\.dylib\$'\`
-inst_cmd="install_name_tool "
 for i in \${libnames} ; do
-    inst_cmd="\${inst_cmd} -change \${2}/lib/\${i} \${1}/\${i}"
+    ${HOST_PREFIX}install_name_tool -id \${1}/\${i} \${1}/\${i}
+    for dep in \${libnames} ; do
+        ${HOST_PREFIX}install_name_tool -change \${2}/\${dep} \${1}/\${dep} \${1}/\${i}
+    done
 done
-\${inst_cmd} \${3}
 EOF
             chmod +x change-install-names
+            DYLIB_RPATH_INSTALL="\$(wx_top_builddir)/change-install-names \${libdir} \$(wx_top_builddir)/lib"
         fi
+
+        dnl the HEADER_PAD_OPTION is required by some wx samples to avoid the error:
+        dnl "install_name_tool: changing install names can't be redone for: the_exe_name
+        dnl (for architecture ppc) because larger updated load commands do not fit
+        dnl (the program must be relinked)"
+        HEADER_PAD_OPTION="-headerpad_max_install_names"
       ;;
 
       *-*-cygwin* | *-*-mingw32* )
-        dnl this one shouldn't be used for the library build so put it in a
-        dnl separate variable from WXCONFIG_CPPFLAGS
-        WXCONFIG_ONLY_CPPFLAGS="$WXCONFIG_ONLY_CPPFLAGS -DWXUSINGDLL"
         ;;
 
       *-*-hpux* )
@@ -3785,9 +4030,13 @@ EOF
     esac
     fi
 
+    dnl this one shouldn't be used for the library build so put it in a
+    dnl separate variable from WXCONFIG_CPPFLAGS
+    WXCONFIG_ONLY_CPPFLAGS="$WXCONFIG_ONLY_CPPFLAGS -DWXUSINGDLL"
+
     if test $wxUSE_RPATH = "no"; then
         SAMPLES_RPATH_FLAG=''
-        SAMPLES_RPATH_POSTLINK=''
+        DYLIB_PATH_POSTLINK=''
         WXCONFIG_RPATH=''
     fi
 
@@ -3810,15 +4059,6 @@ if test "$wxUSE_UNICODE" = "yes"; then
     UNICODE=1
 fi
 
-lib_debug_suffix=
-WX_DEBUGTYPE="release"
-DEBUG_FLAG=0
-if test "$wxUSE_DEBUG_FLAG" = "yes"; then
-    lib_debug_suffix=d
-    WX_DEBUGTYPE="debug"
-    DEBUG_FLAG=1
-fi
-
 WX_FLAVOUR=${WX_FLAVOUR:+-$WX_FLAVOUR}
 WX_LIB_FLAVOUR=`echo $WX_FLAVOUR | tr '-' '_'`
 
@@ -3827,31 +4067,30 @@ if test "$wxUSE_DEBUG_INFO" = "yes"; then
     DEBUG_INFO=1
 fi
 
-WX_VERSION_TAG=`echo WX${lib_unicode_suffix}${lib_debug_suffix}${WX_LIB_FLAVOUR}_${WX_RELEASE} | tr "[[a-z]]" "[[A-Z]]"`
-
-TOOLCHAIN_NAME="${TOOLKIT_DIR}${TOOLKIT_VERSION}${WIDGET_SET}${lib_unicode_suffix}${lib_debug_suffix}${WX_LIB_FLAVOUR}-${WX_RELEASE}"
+WX_VERSION_TAG=`echo WX${lib_unicode_suffix}${WX_LIB_FLAVOUR}_${WX_RELEASE} | tr '[[a-z]]' '[[A-Z]]'`
 
-TOOLCHAIN_FULLNAME="${TOOLKIT_DIR}${TOOLKIT_VERSION}${WIDGET_SET}-${WX_CHARTYPE}-${WX_DEBUGTYPE}${config_linkage_component}-${WX_RELEASE}${WX_FLAVOUR}"
+TOOLCHAIN_NAME="${TOOLKIT_DIR}${TOOLKIT_VERSION}${WIDGET_SET}${lib_unicode_suffix}${WX_LIB_FLAVOUR}-${WX_RELEASE}${HOST_SUFFIX}"
 
-if test "$cross_compiling" = "yes"; then
-    HOST_SUFFIX="-$host_alias"
-    TOOLCHAIN_NAME="$TOOLCHAIN_NAME$HOST_SUFFIX"
-    TOOLCHAIN_FULLNAME="${host_alias}-$TOOLCHAIN_FULLNAME"
-fi
+TOOLCHAIN_FULLNAME="${HOST_PREFIX}${TOOLKIT_DIR}${TOOLKIT_VERSION}${WIDGET_SET}-${WX_CHARTYPE}${config_linkage_component}-${WX_RELEASE}${WX_FLAVOUR}"
 
 dnl library link name
-dnl These just save us from exporting lib_{unicode,debug,flavour}_suffix.
+dnl These just save us from exporting lib_{unicode,flavour}_suffix.
 dnl If we ever need to do that, we won't need to keep these.
-WX_LIBRARY_BASENAME_NOGUI="wx_base${WXBASEPORT}${lib_unicode_suffix}${lib_debug_suffix}${WX_LIB_FLAVOUR}"
+
+if test "$wxUSE_OSX_CARBON" = 1 -o "$wxUSE_OSX_COCOA" = 1 -o "$wxUSE_OLD_COCOA" = 1; then
+    WX_LIBRARY_BASENAME_NOGUI="wx_base${lib_unicode_suffix}${WX_LIB_FLAVOUR}"
+else
+    WX_LIBRARY_BASENAME_NOGUI="wx_base${WXBASEPORT}${lib_unicode_suffix}${WX_LIB_FLAVOUR}"
+fi
 if test "${TOOLKIT_DIR}" = "os2"; then
-    WX_LIBRARY_BASENAME_GUI="wx_pm${WIDGET_SET}${lib_unicode_suffix}${lib_debug_suffix}${WX_LIB_FLAVOUR}"
+    WX_LIBRARY_BASENAME_GUI="wx_pm${WIDGET_SET}${lib_unicode_suffix}${WX_LIB_FLAVOUR}"
 else
-    WX_LIBRARY_BASENAME_GUI="wx_${TOOLKIT_DIR}${TOOLKIT_VERSION}${WIDGET_SET}${lib_unicode_suffix}${lib_debug_suffix}${WX_LIB_FLAVOUR}"
+    WX_LIBRARY_BASENAME_GUI="wx_${TOOLKIT_DIR}${TOOLKIT_VERSION}${WIDGET_SET}${lib_unicode_suffix}${WX_LIB_FLAVOUR}"
 fi
 
 
 
-if test "$wxUSE_COCOA" = 1; then
+if test "$wxUSE_OLD_COCOA" = 1; then
     AC_LANG_SAVE
     AC_WX_LANG_OBJECTIVEC
 dnl Recent AppKit/NSEvent.h include parts of IOKit which eventually
@@ -3880,50 +4119,6 @@ dnl to not typedef Point and thus fix the problem.
     AC_LANG_RESTORE
 fi
 
-if test "$wxUSE_MAC" = 1 -o "$wxUSE_COCOA" = 1; then
-    dnl base name of the resource file for wxMac must be the same
-    dnl as library installation base name (-install_name)
-    WX_RESOURCES_MACOSX_ASCII="libwx_${TOOLCHAIN_NAME}.${wx_release_number}.r"
-    WX_RESOURCES_MACOSX_DATA="libwx_${TOOLCHAIN_NAME}.${wx_release_number}.rsrc"
-
-    dnl add the resources target for wxMac
-    LIBWXMACRES="\$(wx_top_builddir)/lib/${WX_RESOURCES_MACOSX_ASCII}"
-
-    AC_CHECK_PROG(REZ, Rez, Rez, /Developer/Tools/Rez)
-    AC_CHECK_PROG(DEREZ, DeRez, DeRez, /Developer/Tools/DeRez)
-    AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
-
-    MACSETFILE="\$(SETFILE)"
-
-    dnl resources are bundled both with shared library and applications
-    dnl since the carb resource *must* be included in the application
-    if test "$wxUSE_MAC" = 1; then
-        POSTLINK_COMMAND="\$(REZ) -d __DARWIN__ -t APPL Carbon.r -o"
-        RESCOMP="$REZ"
-        WXCONFIG_RESFLAGS="-d __DARWIN__ -t APPL Carbon.r -o"
-    else
-        POSTLINK_COMMAND="echo -n | \$(REZ) -d __DARWIN__ -t APPL ${LIBWXMACRES}"
-        RESCOMP="echo -n \| $REZ"
-        WXCONFIG_RESFLAGS="-d __DARWIN__ -t APPL \$libdir/$WX_RESOURCES_MACOSX_ASCII"
-    fi
-
-else
-    dnl default value is to (silently) do nothing in the makefile
-    MACSETFILE="@true"
-
-    if test "$wxUSE_PM" = 1; then
-        RESCOMP="emxbind"
-        WXCONFIG_RESFLAGS="-ep"
-
-        dnl Is this one really used anywhere for pm?
-        POSTLINK_COMMAND="$RESCOMP $WXCONFIG_RESFLAGS"
-    else
-        POSTLINK_COMMAND="@true"
-    fi
-
-fi
-
-
 dnl ---------------------------------------------------------------------------
 dnl Checks for typedefs
 dnl ---------------------------------------------------------------------------
@@ -3936,8 +4131,6 @@ dnl   defines pid_t if not already defined
 AC_TYPE_PID_T
 dnl   defines size_t if not already defined
 AC_TYPE_SIZE_T
-dnl   defines uid_t and gid_t if not already defined
-AC_TYPE_UID_T
 
 dnl sets HAVE_SSIZE_T if ssize_t is defined
 AC_CHECK_TYPES(ssize_t)
@@ -4072,7 +4265,7 @@ if test "$wxUSE_WCHAR_T" = "yes"; then
         AC_DEFINE(HAVE_WCSLEN)
     fi
 
-    AC_CHECK_FUNCS([wcsdup])
+    AC_CHECK_FUNCS([wcsdup strnlen wcsnlen wcscasecmp wcsncasecmp])
 
     dnl On HP-UX aCC need this define to find mbstrtowcs() &c
     dnl Can't be used for g++ since the mbstate_t in wchar.h can conflict
@@ -4103,8 +4296,9 @@ dnl
 dnl so we first check if the function is in the library
 dnl
 dnl FIXME: replace this mess with WX_CHECK_FUNCS()
-AC_CHECK_FUNCS(snprintf vsnprintf)
+AC_CHECK_FUNCS(snprintf vsnprintf vsscanf)
 
+AC_LANG_PUSH(C++)
 if test "$ac_cv_func_vsnprintf" = "yes"; then
     dnl yes it is -- now check if it is in the headers
     AC_CACHE_CHECK([for vsnprintf declaration], wx_cv_func_vsnprintf_decl,
@@ -4199,36 +4393,6 @@ if test "$ac_cv_func_snprintf" = "yes"; then
 
     if test "$wx_cv_func_snprintf_decl" = "yes"; then
         AC_DEFINE(HAVE_SNPRINTF_DECL)
-
-        dnl we know there is an snprintf declaration, but some old headers
-        dnl may have one taking a "char *" format instead of "const char *"
-        AC_CACHE_CHECK([if snprintf declaration is broken], wx_cv_func_broken_snprintf_decl,
-            [
-                AC_TRY_COMPILE(
-                    [
-                        #include <stdio.h>
-                        #include <stdarg.h>
-                        #ifdef __MSL__
-                        #if __MSL__ >= 0x6000
-                        namespace std {}
-                        using namespace std;
-                        #endif
-                        #endif
-                    ],
-                    [
-                        char *buf;
-                        const char *fmt = "%s";
-                        snprintf(buf, 10u, fmt, "wx");
-                    ],
-                    wx_cv_func_broken_snprintf_decl=no,
-                    wx_cv_func_broken_snprintf_decl=yes
-                )
-            ]
-        )
-
-        if test "$wx_cv_func_broken_snprintf_decl" = "yes"; then
-            AC_DEFINE(HAVE_BROKEN_SNPRINTF_DECL)
-        fi
     fi
 
     if test "$wxUSE_PRINTF_POS_PARAMS" = "yes"; then
@@ -4270,39 +4434,40 @@ define HAVE_UNIX98_PRINTF as 1 in setup.h if it is available.])
     fi
 fi
 
-if test "$wxUSE_UNICODE" = yes; then
-
-    dnl our wxVsnprintf() implementation needs to use the system swprintf() in Unicode
-    dnl builds so let's check if swprintf() is declared as C99 imposes:
-    dnl     int swprintf(wchar_t *s, size_t n, const wchar_t *format, ...);
-    dnl or rather as:
-    dnl     int swprintf(wchar_t *s, const wchar_t *format, ...);
-    AC_CHECK_FUNCS(swprintf)
-
-    if test "$ac_cv_func_swprintf" = "yes"; then
-        AC_CACHE_CHECK([if swprintf declaration is broken], wx_cv_func_broken_swprintf_decl,
-            [
-                AC_TRY_COMPILE(
-                    [
-                        #include <stdio.h>
-                        #include <stdarg.h>
-                        #include <wchar.h>
-                    ],
-                    [
-                        wchar_t *buf;
-                        const wchar_t *fmt = L"test";
-                        swprintf(buf, 10u, fmt);
-                    ],
-                    wx_cv_func_broken_swprintf_decl=no,
-                    wx_cv_func_broken_swprintf_decl=yes
-                )
-            ]
-        )
+dnl the same as above but for vsscanf() now: it's not present in at least
+dnl Solaris 9 headers for gcc-3.4 (due to fixinclude's processing of stdio.h)
+if test "$ac_cv_func_vsscanf" = "yes"; then
+    AC_CACHE_CHECK([for vsscanf declaration], wx_cv_func_vsscanf_decl,
+        [
+            AC_TRY_COMPILE(
+                [
+                    #include <stdio.h>
+                    #include <stdarg.h>
+                    #ifdef __MSL__
+                    #if __MSL__ >= 0x6000
+                    namespace std {}
+                    using namespace std;
+                    #endif
+                    #endif
+                ],
+                [
+                    char *buf;
+                    va_list args;
+                    vsscanf(buf, "%s", args);
+                ],
+                wx_cv_func_vsscanf_decl=yes,
+                wx_cv_func_vsscanf_decl=no
+            )
+        ]
+    )
 
-        if test "$wx_cv_func_broken_swprintf_decl" = "yes"; then
-            AC_DEFINE(HAVE_BROKEN_SWPRINTF_DECL)
-        fi
+    if test "$wx_cv_func_vsscanf_decl" = "yes"; then
+        AC_DEFINE(HAVE_VSSCANF_DECL)
     fi
+fi
+AC_LANG_POP()
+
+if test "$wxUSE_UNICODE" = yes; then
 
     dnl also look if we have wide char IO functions, notice that [f]putws are
     dnl declared in special widec.h under Solaris
@@ -4317,7 +4482,7 @@ if test "$wxUSE_UNICODE" = yes; then
             fi
     esac
 
-    WX_CHECK_FUNCS(wputc wputchar putws fputws wprintf vswprintf,,,
+    WX_CHECK_FUNCS(putws fputws wprintf vswprintf vswscanf,,,
                    [$wchar_headers])
 
     dnl MinGW has a vswprintf with a different prototype, and
@@ -4331,10 +4496,6 @@ if test "$wxUSE_UNICODE" = yes; then
                    [AC_MSG_RESULT([no])]);
 fi
 
-if test "x$ac_cv_header_fnmatch_h" = "xyes"; then
-    WX_CHECK_FUNCS(fnmatch,,,[#include <fnmatch.h>])
-fi
-
 if test "$wxUSE_FILE" = "yes"; then
     WX_CHECK_FUNCS(fsync)
 fi
@@ -4349,9 +4510,10 @@ dnl the following tests are for Unix(like) systems only
 if test "$TOOLKIT" != "MSW"; then
 
 dnl check for available version of iconv()
-
-AM_ICONV
-LIBS="$LIBICONV $LIBS"
+if test "$wxUSE_LIBICONV" != "no" ; then
+    AM_ICONV
+    LIBS="$LIBICONV $LIBS"
+fi
 
 dnl check for POSIX signals if we need them
 if test "$wxUSE_ON_FATAL_EXCEPTION" = "yes" -a "$wxUSE_UNIX" = "yes"; then
@@ -4431,7 +4593,7 @@ if test "$wxUSE_STACKWALKER" = "yes" -a "$wxUSE_UNIX" = "yes"; then
     fi
 fi
 
-if test "$wxUSE_STACKWALKER" = "yes" -a "$USE_WIN32" != "1" -a "$USE_UNIX" != "1"; then
+if test "$wxUSE_STACKWALKER" = "yes" -a "$USE_WIN32" != 1 -a "$USE_UNIX" != 1; then
     AC_MSG_WARN([wxStackWalker is only available on Win32 and UNIX... disabled])
     wxUSE_STACKWALKER=no
 fi
@@ -4579,11 +4741,11 @@ if test "$wxUSE_SNGLINST_CHECKER" = "yes"; then
     fi
 fi
 
-dnl check for timegm() used by datetime.cpp
-AC_CHECK_FUNCS(timegm)
-
 dnl look for a function to modify the environment
 AC_CHECK_FUNCS(setenv putenv, break)
+if test "$ac_cv_func_setenv" = "yes"; then
+    AC_CHECK_FUNCS(unsetenv)
+fi
 
 HAVE_SOME_SLEEP_FUNC=0
 if test "$USE_BEOS" = 1; then
@@ -4665,6 +4827,32 @@ fi
 
 WX_CHECK_FUNCS(fdopen)
 
+if test "$wxUSE_TARSTREAM" = "yes"; then
+    WX_CHECK_FUNCS(sysconf)
+
+    WX_CHECK_FUNCS(getpwuid_r, [], [],
+                   [
+                    #define _REENTRANT
+                    #include <pwd.h>
+                   ],
+                   [[
+                    struct passwd pw, *ppw;
+                    char buf[1024];
+                    getpwuid_r(0, &pw, buf, sizeof(buf), &ppw)
+                   ]])
+
+    WX_CHECK_FUNCS(getgrgid_r, [], [],
+                   [
+                    #define _REENTRANT
+                    #include <grp.h>
+                   ],
+                   [[
+                    struct group grp, *pgrp;
+                    char buf[1024];
+                    getgrgid_r(0, &grp, buf, sizeof(buf), &pgrp)
+                   ]])
+fi
+
 fi
 
 
@@ -4762,6 +4950,12 @@ if test "$TOOLKIT" != "MSW" -a "$USE_OS2" != 1; then
                 fi
                 ;;
 
+          *-*-qnx*)
+                dnl under QNX thread functions are in libc so we don't need any
+                dnl special options to link with them
+                THREAD_OPTS=""
+                ;;
+
           *-*-*UnixWare*)
                 dnl flying by man pages here: Caldera online docs use this
                 if test "x$GCC" != "xyes"; then
@@ -4770,10 +4964,22 @@ if test "$TOOLKIT" != "MSW" -a "$USE_OS2" != 1; then
                 ;;
         esac
 
-        dnl simply linking with libpthread should make the test below work but
-        dnl it's far from certain that the threaded programs compiled without
-        dnl any special switches actually work, so try it after all the others
-        THREAD_OPTS="$THREAD_OPTS pthread none"
+        case "${host}" in
+            *-*-qnx*)
+                dnl -lpthread works, i.e. AC_TRY_LINK() would pass, but results
+                dnl in warnings and is not needed under QNX so try without it
+                dnl first
+                THREAD_OPTS="none pthread"
+                ;;
+
+            *)
+                dnl simply linking with libpthread should make the test below
+                dnl work but it's far from certain that the threaded programs
+                dnl compiled without any special switches actually work, so try
+                dnl it after all the others
+                THREAD_OPTS="$THREAD_OPTS pthread none"
+                ;;
+        esac
 
         dnl now test for all possibilities
         THREADS_OK=no
@@ -4821,7 +5027,14 @@ if test "$TOOLKIT" != "MSW" -a "$USE_OS2" != 1; then
       else
           dnl yes, these special compiler flags should be used with the
           dnl linker as well
+          dnl
+          dnl NB: add them to LDFLAGS immediately because we need them to be
+          dnl     used for the subsequent tests some of which can fail without
+          dnl     MT support, hence the reason for the duplication below:
+          dnl     adding them just to WXCONFIG_LDFLAGS and adding the entire
+          dnl     contents of the latter to LDFLAGS in the end is not enough.
           LDFLAGS="$THREADS_CFLAGS $LDFLAGS"
+          WXCONFIG_LDFLAGS="$THREADS_CFLAGS $WXCONFIG_LDFLAGS"
           LIBS="$THREADS_LINK $LIBS"
 
           AC_MSG_CHECKING([if more special flags are required for pthreads])
@@ -4835,6 +5048,7 @@ if test "$TOOLKIT" != "MSW" -a "$USE_OS2" != 1; then
                 dnl     search path should include -L/usr/lib/threads at the
                 dnl     beginning of the path.
                 LDFLAGS="-L/usr/lib/threads $LDFLAGS"
+                WXCONFIG_LDFLAGS="-L/usr/lib/threads $WXCONFIG_LDFLAGS"
                 flag="-D_THREAD_SAFE"
                 ;;
             *-freebsd*)
@@ -5006,12 +5220,68 @@ if test "$TOOLKIT" != "MSW" -a "$USE_OS2" != 1; then
           AC_MSG_WARN([wxMutex won't be recursive on this platform])
         fi
       fi
+
+      if test "$wxUSE_COMPILER_TLS" = "auto"; then
+          if test "$USE_NETBSD" = 1; then
+              AC_MSG_WARN([Disabling TLS under NetBSD, please contact wx-dev if it works now])
+              wxUSE_COMPILER_TLS=no
+          else
+              wxUSE_COMPILER_TLS=yes
+          fi
+      fi
+
+      if test "$wxUSE_COMPILER_TLS" = "yes"; then
+          dnl test for compiler thread-specific variables support
+          AC_CACHE_CHECK([for __thread keyword],
+                         wx_cv_cc___thread,
+              [
+                  AC_TRY_COMPILE([#include <pthread.h>],
+                      [
+                          static __thread int n = 0;
+                          static __thread int *p = 0;
+                      ],
+                      wx_cv_cc___thread=yes,
+                      wx_cv_cc___thread=no
+                  )
+              ]
+          )
+
+          if test "$wx_cv_cc___thread" = "yes"; then
+              AX_GXX_VERSION
+              if test -n "$ax_cv_gxx_version"; then
+                  dnl g++ supports __thread since at least version 3.3 but its support
+                  dnl seems to be broken until 4.1, see
+                  dnl   http://thread.gmane.org/gmane.comp.lib.wxwidgets.devel/108388
+                  dnl
+                  dnl NB: we still need to test __thread support with
+                  dnl     AC_TRY_COMPILE above even for g++ 4 as it doesn't
+                  dnl     support it for all architectures (e.g. it doesn't
+                  dnl     work under OS X)
+                  AC_MSG_CHECKING([whether __thread support in g++ is usable])
+                  case "$ax_cv_gxx_version" in
+                    1.* | 2.* | 3.* )
+                        AC_MSG_RESULT([no, it's broken])
+                        wx_cv_cc___thread=no
+                        ;;
+                    *)
+                        AC_MSG_RESULT([yes, it works])
+                        ;;
+                  esac
+              fi
+          fi
+
+          if test "$wx_cv_cc___thread" = "yes"; then
+            AC_DEFINE(HAVE___THREAD_KEYWORD)
+          fi
+        fi
     fi
 
 dnl from if !MSW
 else
     if test "$wxUSE_THREADS" = "yes" ; then
       case "${host}" in
+        x86_64-*-mingw32* )
+        ;;
         *-*-mingw32* )
             dnl check if the compiler accepts -mthreads
             AC_CACHE_CHECK([if compiler supports -mthreads],
@@ -5045,7 +5315,6 @@ fi
 
 AC_CHECK_FUNC(localtime_r, [ AC_DEFINE(HAVE_LOCALTIME_R) ])
 AC_CHECK_FUNC(gmtime_r, [ AC_DEFINE(HAVE_GMTIME_R) ])
-AC_CHECK_FUNC(readdir_r, [ AC_DEFINE(HAVE_READDIR_R) ])
 dnl By preference, we probably should use getaddrinfo which avoids thread
 dnl safety issues and supports IPv6, however there currently is no code
 dnl for it, so testing for it is temporarily disabled and we are restricted
@@ -5097,8 +5366,8 @@ else
   fi
 fi
 
-if test "$WXGTK20" = 1 ; then
-  AC_DEFINE_UNQUOTED(__WXGTK20__,$WXGTK20)
+if test "$WXGTK2" = 1 ; then
+  AC_DEFINE_UNQUOTED(__WXGTK20__,$WXGTK2)
   WXGTK12=1
 fi
 
@@ -5117,9 +5386,14 @@ fi
 dnl DEBUG_CFLAGS contains debugging options (supposed to be the same for C and C++
 dnl compilers: we'd need a separate DEBUG_CXXFLAGS if this is ever not the case)
 DEBUG_CFLAGS=
-if test "$wxUSE_DEBUG_INFO" = "yes" ; then
+if `echo $CXXFLAGS $CFLAGS | grep " -g" >/dev/null`; then
+    dnl the CXXFLAGS or the CFLAGS variable already contains the -g flag
+    dnl (e.g. it was specified by the user before running configure); since
+    dnl later they will be merged with DEBUG_CFLAGS, don't set the -g option
+    dnl in DEBUG_CFLAGS to avoid (possibly different) flag duplicates
+    AC_MSG_WARN([CXXFLAGS/CFLAGS already contains -g flag; ignoring the --enable-debug_info option])
+elif test "$wxUSE_DEBUG_INFO" = "yes" ; then
     DEBUG_CFLAGS="-g"
-    wxUSE_OPTIMISE=no
 fi
 
 if test "$wxUSE_DEBUG_GDB" = "yes" ; then
@@ -5129,10 +5403,9 @@ if test "$wxUSE_DEBUG_GDB" = "yes" ; then
     fi
 fi
 
-if test "$wxUSE_DEBUG_FLAG" = "yes" ; then
-    AC_DEFINE(WXDEBUG)
-    WXCONFIG_CPPFLAGS="$WXCONFIG_CPPFLAGS -D__WXDEBUG__"
-else
+if test "$wxUSE_DEBUG_FLAG" = "no" ; then
+    WXCONFIG_CPPFLAGS="$WXCONFIG_CPPFLAGS -DwxDEBUG_LEVEL=0"
+
     if test "$wxUSE_GTK" = 1 ; then
         if test "x$wxGTK_VERSION" = "x1" ; then
             CPPFLAGS="-DGTK_NO_CHECK_CASTS $CPPFLAGS"
@@ -5159,7 +5432,10 @@ fi
 
 if test "$GCC" = "yes" ; then
     if test "$wxUSE_NO_RTTI" = "yes" ; then
-        WXCONFIG_CXXFLAGS="$WXCONFIG_CXXFLAGS -fno-rtti"
+        dnl Define wxNO_RTTI on the command line because only g++ 4.3 and later
+        dnl define __GXX_RTTI which allows us to detect the use of -fno-rtti
+        dnl switch but we need to do it manually for the older versions.
+        WXCONFIG_CXXFLAGS="$WXCONFIG_CXXFLAGS -DwxNO_RTTI -fno-rtti"
     fi
     if test "$wxUSE_NO_EXCEPTIONS" = "yes" ; then
         WXCONFIG_CXXFLAGS="$WXCONFIG_CXXFLAGS -fno-exceptions"
@@ -5191,29 +5467,37 @@ fi
 
 dnl C/C++ compiler option for optimization (supposed to be the same for both)
 OPTIMISE_CFLAGS=
-if test "$wxUSE_OPTIMISE" = "no" ; then
-    if test "$GCC" = yes ; then
-        dnl use -O0 because compiling with it is faster than compiling with no
-        dnl optimization options at all (at least with g++ 3.2)
-        OPTIMISE_CFLAGS="-O0"
-    fi
+if `echo $CXXFLAGS $CFLAGS | grep " -O" >/dev/null`; then
+    dnl the CXXFLAGS or the CFLAGS variable already contains -O optimization flag
+    dnl (e.g. it was specified by the user before running configure); since
+    dnl later they will be merged with OPTIMISE_CFLAGS, don't set the -O option
+    dnl in OPTIMISE_CFLAGS to avoid (possibly different) flag duplicates
+    AC_MSG_WARN([CXXFLAGS/CFLAGS already contains -O flag; ignoring the --disable-optimise option])
 else
-    if test "$GCC" = yes ; then
-        case "${host}" in
-            *-pc-os2_emx | *-pc-os2-emx )
-                dnl Not all of the supported gcc versions understand
-                dnl -fstrict-aliasing and none actually needs it (yet).
-                OPTIMISE_CFLAGS="-O2"
-            ;;
-            *)
-                dnl Switch on optimisation but keep strict-aliasing off for
-                dnl now (see -fstrict-aliasing in the gcc manual). When it is
-                dnl switched back on consider using -Wstrict-aliasing=2.
-                OPTIMISE_CFLAGS="-O2 -fno-strict-aliasing"
-            ;;
-        esac
+    if test "$wxUSE_OPTIMISE" = "no" ; then
+        if test "$GCC" = yes ; then
+            dnl use -O0 because compiling with it is faster than compiling with no
+            dnl optimization options at all (at least with g++ 3.2)
+            OPTIMISE_CFLAGS="-O0"
+        fi
     else
-        OPTIMISE_CFLAGS="-O"
+        if test "$GCC" = yes ; then
+            case "${host}" in
+                *-pc-os2_emx | *-pc-os2-emx )
+                    dnl Not all of the supported gcc versions understand
+                    dnl -fstrict-aliasing and none actually needs it (yet).
+                    OPTIMISE_CFLAGS="-O2"
+                ;;
+                *)
+                    dnl Switch on optimisation but keep strict-aliasing off for
+                    dnl now (see -fstrict-aliasing in the gcc manual). When it is
+                    dnl switched back on consider using -Wstrict-aliasing=2.
+                    OPTIMISE_CFLAGS="-O2 -fno-strict-aliasing"
+                ;;
+            esac
+        else
+            OPTIMISE_CFLAGS="-O"
+        fi
     fi
 fi
 
@@ -5269,10 +5553,7 @@ if test "$TOOLKIT" != "MSW" -a "$USE_OS2" != 1; then
     HAVE_DL_FUNCS=0
     HAVE_SHL_FUNCS=0
     if test "$wxUSE_DYNAMIC_LOADER" = "yes" -o "$wxUSE_DYNLIB_CLASS" = "yes" ; then
-        if test "$USE_DARWIN" = 1; then
-            dnl dlopen/dlerror is implemented in dynlib.cpp for Darwin/Mac OS X
-            HAVE_DL_FUNCS=1
-        elif test "$USE_DOS" = 1; then
+        if test "$USE_DOS" = 1; then
             HAVE_DL_FUNCS=0
         else
             dnl the test is a bit complicated because we check for dlopen() both with
@@ -5306,15 +5587,21 @@ if test "$TOOLKIT" != "MSW" -a "$USE_OS2" != 1; then
                             ])
             ])
 
-        dnl check also for dlerror()
-        if test "$HAVE_DL_FUNCS" = 1; then
-            AC_CHECK_FUNCS(dlerror,
-                AC_DEFINE(HAVE_DLERROR),
-                [
-                    AC_CHECK_LIB(dl, dlerror, AC_DEFINE(HAVE_DLERROR))
-                ]
-            )
+            dnl check also for dlerror()
+            if test "$HAVE_DL_FUNCS" = 1; then
+                AC_CHECK_FUNCS(dlerror,
+                    AC_DEFINE(HAVE_DLERROR),
+                    [
+                        AC_CHECK_LIB(dl, dlerror, AC_DEFINE(HAVE_DLERROR))
+                    ]
+                )
+            fi
         fi
+
+        dnl Force HAVE_DL_FUNCS on for Darwin, even if the tests failed (e.g. pre-10.3)
+        if test "$USE_DARWIN" = 1; then
+            dnl dlopen/dlerror is implemented in dynlib.cpp for Darwin/Mac OS X
+            HAVE_DL_FUNCS=1
         fi
 
         if test "$HAVE_DL_FUNCS" = 0; then
@@ -5361,6 +5648,40 @@ if test "$wxUSE_PLUGINS" = "yes" ; then
     fi
 fi
 
+dnl ---------------------------------------------------------------------------
+dnl File system watcher checks
+dnl ---------------------------------------------------------------------------
+
+if test "$wxUSE_FSWATCHER" = "yes"; then
+    dnl wxFileSystemWatcher is always available under MSW but we need either
+    dnl inotify or kqueue support in the system for it under Unix (this
+    dnl includes OS X which does have kqueue but no other platforms)
+    if test "$wxUSE_MSW" != "1"; then
+        if test "$wxUSE_UNIX" = "yes"; then
+            AC_CHECK_HEADERS(sys/inotify.h,,, [AC_INCLUDES_DEFAULT()])
+            if test "$ac_cv_header_sys_inotify_h" = "yes"; then
+                AC_DEFINE(wxHAS_INOTIFY)
+            else
+                AC_CHECK_HEADERS(sys/event.h,,, [AC_INCLUDES_DEFAULT()])
+                if test "$ac_cv_header_sys_event_h" = "yes"; then
+                    AC_DEFINE(wxHAS_KQUEUE)
+                else
+                    wxUSE_FSWATCHER=no
+                fi
+            fi
+        else
+            wxUSE_FSWATCHER=no
+        fi
+    fi
+
+    if test "$wxUSE_FSWATCHER" = "yes"; then
+        AC_DEFINE(wxUSE_FSWATCHER)
+        SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS fswatcher"
+    else
+        AC_MSG_WARN([wxFileSystemWatcher won't be available on this platform])
+    fi
+fi
+
 dnl ---------------------------------------------------------------------------
 dnl Register non-GUI class options for makefiles and setup.h
 dnl ---------------------------------------------------------------------------
@@ -5373,6 +5694,10 @@ if test "$wxUSE_EXTENDED_RTTI" = "yes"; then
   AC_DEFINE(wxUSE_EXTENDED_RTTI)
 fi
 
+if test "$wxUSE_ANY" = "yes"; then
+    AC_DEFINE(wxUSE_ANY)
+fi
+
 if test "$wxUSE_APPLE_IEEE" = "yes"; then
   AC_DEFINE(wxUSE_APPLE_IEEE)
 fi
@@ -5383,7 +5708,7 @@ fi
 
 dnl Unix implementation needs additional checks because audio support
 dnl comes in many favours:
-if test "$USE_UNIX" = "1" ; then
+if test "$USE_UNIX" = 1 ; then
     dnl mmedia doesn't compile with wxMGL, remove this if this is ever fixed
     if test "$wxUSE_MGL" != 1; then
         dnl it's not enough to check for just the header because OSS under NetBSD
@@ -5426,7 +5751,7 @@ fi
 
 WITH_PLUGIN_SDL=0
 if test "$wxUSE_SOUND" = "yes"; then
-  if test "$USE_UNIX" = "1" ; then
+  if test "$USE_UNIX" = 1 ; then
     if test "$wxUSE_LIBSDL" != "no"; then
       AM_PATH_SDL([1.2.0],
                   [
@@ -5454,10 +5779,27 @@ if test "$wxUSE_SOUND" = "yes"; then
   SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS sound"
 fi
 
-if test "$WXGTK20" = 1; then
+if test "$WXGTK2" = 1; then
     PKG_PROG_PKG_CONFIG()
 
     if test "$wxUSE_PRINTING_ARCHITECTURE" = "yes" ; then
+
+        if test "$wxUSE_GTKPRINT" = "yes" ; then
+
+                PKG_CHECK_MODULES(GTKPRINT,
+                                  [gtk+-unix-print-2.0 >= 2.10],
+                    [
+                        CFLAGS="$GTKPRINT_CFLAGS $CFLAGS"
+                        CXXFLAGS="$GTKPRINT_CFLAGS $CXXFLAGS"
+                        AC_DEFINE(wxUSE_GTKPRINT)
+                    ],
+                    [
+                        AC_MSG_WARN([GTK printing support not found (GTK+ >= 2.10), library will use GNOME printing support or standard PostScript printing])
+                        wxUSE_GTKPRINT="no"
+                    ]
+                )
+        fi
+
         if test "$wxUSE_LIBGNOMEPRINT" = "yes" ; then
 
                 PKG_CHECK_MODULES(LIBGNOMEPRINTUI,
@@ -5501,12 +5843,30 @@ if test "$WXGTK20" = 1; then
                 CFLAGS="$CFLAGS $HILDON_CFLAGS"
                 CXXFLAGS="$CXXFLAGS $HILDON_CFLAGS"
                 AC_DEFINE(wxUSE_LIBHILDON)
+                ac_hildon_lgpl=1
             ],
             [
                 AC_MSG_WARN([libhildon_lgpl not found])
                         wxUSE_LIBHILDON="no"
+                        ac_hildon_lgpl=0
             ]
         )
+
+        if test "$ac_hildon_lgpl" = 0 ; then
+            PKG_CHECK_MODULES(HILDON2,
+                              [hildon-1 >= 1.99],
+                [
+                    EXTRALIBS_HILDON="$HILDON2_LIBS"
+                    CFLAGS="$CFLAGS $HILDON2_CFLAGS"
+                    CXXFLAGS="$CXXFLAGS $HILDON2_CFLAGS"
+                    AC_DEFINE(wxUSE_LIBHILDON2)
+                ],
+                [
+                    AC_MSG_WARN([libhildon_1 not found])
+                            wxUSE_LIBHILDON2="no"
+                ]
+            )
+        fi
     fi
 fi
 
@@ -5557,6 +5917,10 @@ if test "$wxUSE_TARSTREAM" = "yes"; then
   fi
 fi
 
+if test "$wxUSE_FILE_HISTORY" = "yes"; then
+  AC_DEFINE(wxUSE_FILE_HISTORY)
+fi
+
 if test "$wxUSE_FILESYSTEM" = "yes"; then
   if test "$wxUSE_STREAMS" != yes -o \( "$wxUSE_FILE" != yes -a "$wxUSE_FFILE" != yes \); then
     AC_MSG_WARN(wxFileSystem requires wxStreams and wxFile or wxFFile... disabled)
@@ -5596,7 +5960,7 @@ if test "$wxUSE_STACKWALKER" = "yes"; then
 fi
 
 if test "$wxUSE_DEBUGREPORT" = "yes"; then
-    if test "$USE_UNIX" != "1" -a "$USE_WIN32" != "1"; then
+    if test "$USE_UNIX" != 1 -a "$USE_WIN32" != 1; then
         AC_MSG_WARN([Creating debug reports not currently supported on this system, disabled])
         wxUSE_DEBUGREPORT=no
     else
@@ -5659,6 +6023,13 @@ if test "$wxUSE_INTL" = "yes" ; then
   fi
 fi
 
+if test "$wxUSE_XLOCALE" = "yes" ; then
+    AC_DEFINE(wxUSE_XLOCALE)
+    AC_CHECK_TYPES(locale_t,,,
+                   [#include <xlocale.h>
+                    #include <locale.h>])
+fi
+
 if test "$wxUSE_LOG" = "yes"; then
   AC_DEFINE(wxUSE_LOG)
 
@@ -5715,7 +6086,7 @@ if test "$wxUSE_CONSOLE_EVENTLOOP" = "yes"; then
         fi
 
         if test "$wxUSE_EPOLL_DISPATCHER" = "yes"; then
-            AC_CHECK_HEADERS(sys/epoll.h)
+            AC_CHECK_HEADERS(sys/epoll.h,,, [AC_INCLUDES_DEFAULT()])
             if test "$ac_cv_header_sys_epoll_h" = "yes"; then
                 AC_DEFINE(wxUSE_EPOLL_DISPATCHER)
             else
@@ -5772,65 +6143,6 @@ if test "$ac_cv_func_gettimeofday" = "yes"; then
 fi
 
 if test "$wxUSE_DATETIME" = "yes"; then
-    dnl check for strptime and for its declaration as some systems lack it
-    AC_CHECK_FUNC(strptime)
-    if test "$ac_cv_func_strptime" = "yes"; then
-        AC_CACHE_CHECK([for strptime declaration], wx_cv_func_strptime_decl,
-            [
-                AC_LANG_PUSH(C++)
-                AC_TRY_COMPILE(
-                    [
-                        #include <time.h>
-                    ],
-                    [
-                        struct tm t;
-                        strptime("foo", "bar", &t);
-                    ],
-                    wx_cv_func_strptime_decl=yes,
-                    wx_cv_func_strptime_decl=no
-                )
-                AC_LANG_POP()
-            ]
-        )
-    fi
-    if test "$wx_cv_func_strptime_decl" = "yes"; then
-        AC_DEFINE(HAVE_STRPTIME_DECL)
-    else
-        wx_strptime_decl="extern char *strptime(const char *, const char *, struct tm *);"
-    fi
-    if test "$ac_cv_func_strptime" = "yes"; then
-        dnl strptime() behaviour doesn't conform to POSIX under Mac OS X <
-        dnl 10.5 and possibly other BSD variants, check that strptime() we
-        dnl have fails to parse format when the string doesn't match it instea
-        dnl of just stopping immediately and returning non-NULL
-        AC_CACHE_CHECK([whether strptime() fails on invalid strings],
-            wx_cv_func_strptime_ok,
-            [AC_RUN_IFELSE(
-                [
-                    #include <stdlib.h>
-                    #include <time.h>
-                    #include "confdefs.h"
-
-                    $wx_strptime_decl
-
-                    int main()
-                    {
-                        struct tm t;
-                        return !!strptime("", "%x", &t);
-                    }
-                ],
-                wx_cv_func_strptime_ok=yes,
-                wx_cv_func_strptime_ok=no,
-                dnl be pessimistic when cross-compiling
-                wx_cv_func_strptime_ok=no
-            )]
-        )
-
-        if test "$wx_cv_func_strptime_ok" = "yes"; then
-            AC_DEFINE(HAVE_STRPTIME)
-        fi
-    fi
-
     dnl check for timezone variable
     dnl   doesn't exist under Darwin / Mac OS X which uses tm_gmtoff instead
     AC_CACHE_CHECK(for timezone variable in <time.h>,
@@ -5927,7 +6239,7 @@ dnl ------------------------------------------------------------------------
 
 dnl VZ: the GUI hooks wxSocket needs are not implemented yet in some toolkits
 if test "$wxUSE_SOCKETS" = "yes"; then
-    if test "$wxUSE_MGL" = "1"; then
+    if test "$wxUSE_MGL" = 1; then
         AC_MSG_WARN([wxSocket not yet supported under MGL... disabled])
         wxUSE_SOCKETS="no"
     fi
@@ -6083,6 +6395,33 @@ if test "$wxUSE_SOCKETS" = "yes" ; then
 fi
 
 if test "$wxUSE_SOCKETS" = "yes" ; then
+    if test "$wxUSE_IPV6" = "yes"; then
+        AC_CACHE_CHECK(
+            [whether we have sockaddr_in6],
+            [wx_cv_type_sockaddr_in6],
+            [
+                AC_TRY_COMPILE(
+                    [
+                        #include <sys/types.h>
+                        #include <sys/socket.h>
+                        #include <netinet/in.h>
+                    ],
+                    [
+                        struct sockaddr_in6 sa6;
+                    ],
+                    wx_cv_type_sockaddr_in6=yes,
+                    wx_cv_type_sockaddr_in6=no
+                )
+            ]
+        )
+
+        if test "$wx_cv_type_sockaddr_in6"="yes"; then
+            AC_DEFINE(wxUSE_IPV6)
+        else
+            AC_MSG_WARN([IPv6 support not available... disabled])
+        fi
+    fi
+
     AC_DEFINE(wxUSE_SOCKETS)
     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS sockets"
 fi
@@ -6143,7 +6482,7 @@ if test "$wxUSE_GUI" = "yes" -a "$wxUSE_JOYSTICK" = "yes"; then
         wxUSE_JOYSTICK=yes
 
     dnl mac only available on darwin
-    elif test "$TOOLKIT" = "MAC" -o "$TOOLKIT" = "COCOA"; then
+    elif test "$TOOLKIT" = "OSX" -o "$TOOLKIT" = "COCOA"; then
         if test "$USE_DARWIN" = 1; then
             dnl check for a bug in the headers, some have bad setEventCallout
             AC_MSG_CHECKING([headers have declarations needed for joystick support])
@@ -6161,7 +6500,7 @@ if test "$wxUSE_GUI" = "yes" -a "$wxUSE_JOYSTICK" = "yes"; then
     dnl joystick support is only for Linux 2.1.x or greater
     else
         dnl wxJoystick not supported by wxMGL at all
-        if test "$wxUSE_MGL" != "1"; then
+        if test "$wxUSE_MGL" != 1; then
             dnl notice the dummy includes argument: without it, AC_CHECK_HEADER
             dnl checks only whether the header can be preprocessed, not that it
             dnl can be compiled and in Linux 2.6.16 joystick.h is present but
@@ -6221,10 +6560,6 @@ if test "$wxUSE_UNICODE" = "yes" -a "$wxUSE_UNICODE_UTF8" = "yes"; then
     fi
 fi
 
-if test "$wxUSE_wxUSE_EXPERIMENTAL_PRINTF" = "yes"; then
-  AC_DEFINE(wxUSE_EXPERIMENTAL_PRINTF)
-fi
-
 dnl ---------------------------------------------------------------------------
 dnl big GUI components: MDI, doc/view, printing, help, ...
 dnl ---------------------------------------------------------------------------
@@ -6246,9 +6581,6 @@ fi
 if test "$wxUSE_DOC_VIEW_ARCHITECTURE" = "yes" ; then
     AC_DEFINE(wxUSE_DOC_VIEW_ARCHITECTURE)
     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS docview"
-    if test "$wxUSE_MDI_ARCHITECTURE" = "yes"; then
-        SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS docvwmdi"
-    fi
 fi
 
 if test "$wxUSE_HELP" = "yes"; then
@@ -6272,11 +6604,7 @@ if test "$wxUSE_HELP" = "yes"; then
 fi
 
 if test "$wxUSE_PRINTING_ARCHITECTURE" = "yes" ; then
-    if test "$wxUSE_CONSTRAINTS" != "yes"; then
-        AC_MSG_WARN(Printing support cannot be used without constraints so it won't be compiled without it)
-    else
-        AC_DEFINE(wxUSE_PRINTING_ARCHITECTURE)
-    fi
+    AC_DEFINE(wxUSE_PRINTING_ARCHITECTURE)
     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS printing"
 fi
 
@@ -6286,8 +6614,6 @@ fi
 
 AC_DEFINE(wxUSE_AFM_FOR_POSTSCRIPT)
 
-AC_DEFINE(wxUSE_NORMALIZED_PS_FONTS)
-
 if test "$wxUSE_SVG" = "yes"; then
     AC_DEFINE(wxUSE_SVG)
 fi
@@ -6414,6 +6740,10 @@ if test "$wxUSE_DRAG_AND_DROP" = "yes" -o "$wxUSE_CLIPBOARD" = "yes"; then
     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS dnd"
 fi
 
+if test "$wxUSE_CLIPBOARD" = "yes"; then
+    SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS clipboard"
+fi
+
 if test "$wxUSE_SPLINES" = "yes" ; then
   AC_DEFINE(wxUSE_SPLINES)
 fi
@@ -6422,6 +6752,11 @@ if test "$wxUSE_MOUSEWHEEL" = "yes" ; then
   AC_DEFINE(wxUSE_MOUSEWHEEL)
 fi
 
+if test "$wxUSE_UIACTIONSIMULATOR" = "yes" ; then
+    AC_DEFINE(wxUSE_UIACTIONSIMULATOR)
+    SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS uiaction"
+fi
+
 dnl ---------------------------------------------------------------------------
 dnl GUI controls
 dnl ---------------------------------------------------------------------------
@@ -6480,6 +6815,11 @@ if test "$wxUSE_COMBOCTRL" = "yes"; then
   USES_CONTROLS=1
 fi
 
+if test "$wxUSE_COMMANDLINKBUTTON" = "yes"; then
+  AC_DEFINE(wxUSE_COMMANDLINKBUTTON)
+  USES_CONTROLS=1
+fi
+
 if test "$wxUSE_CHOICE" = "yes"; then
   AC_DEFINE(wxUSE_CHOICE)
   USES_CONTROLS=1
@@ -6498,7 +6838,6 @@ fi
 if test "$wxUSE_CHECKLST" = "yes"; then
   AC_DEFINE(wxUSE_CHECKLISTBOX)
   USES_CONTROLS=1
-  SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS checklst"
 fi
 
 if test "$wxUSE_COLOURPICKERCTRL" = "yes"; then
@@ -6516,6 +6855,11 @@ if test "$wxUSE_DIRPICKERCTRL" = "yes"; then
   USES_CONTROLS=1
 fi
 
+if test "$wxUSE_FILECTRL" = "yes"; then
+  AC_DEFINE(wxUSE_FILECTRL)
+  USES_CONTROLS=1
+fi
+
 if test "$wxUSE_FILEPICKERCTRL" = "yes"; then
   AC_DEFINE(wxUSE_FILEPICKERCTRL)
   USES_CONTROLS=1
@@ -6532,7 +6876,7 @@ if test "$wxUSE_DISPLAY" = "yes"; then
         wxUSE_DISPLAY=no
     else
         AC_DEFINE(wxUSE_DISPLAY)
-        SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS display multimon"
+        SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS display"
     fi
 fi
 
@@ -6551,6 +6895,11 @@ if test "$wxUSE_GRID" = "yes"; then
   SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS grid"
 fi
 
+if test "$wxUSE_HEADERCTRL" = "yes"; then
+  AC_DEFINE(wxUSE_HEADERCTRL)
+  USES_CONTROLS=1
+fi
+
 if test "$wxUSE_HYPERLINKCTRL" = "yes"; then
   AC_DEFINE(wxUSE_HYPERLINKCTRL)
   USES_CONTROLS=1
@@ -6571,6 +6920,10 @@ if test "$wxUSE_IMAGLIST" = "yes"; then
     AC_DEFINE(wxUSE_IMAGLIST)
 fi
 
+if test "$wxUSE_INFOBAR" = "yes"; then
+    AC_DEFINE(wxUSE_INFOBAR)
+fi
+
 if test "$wxUSE_LISTBOOK" = "yes"; then
     AC_DEFINE(wxUSE_LISTBOOK)
     USES_CONTROLS=1
@@ -6579,7 +6932,6 @@ fi
 if test "$wxUSE_LISTBOX" = "yes"; then
     AC_DEFINE(wxUSE_LISTBOX)
     USES_CONTROLS=1
-    SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS listbox"
 fi
 
 if test "$wxUSE_LISTCTRL" = "yes"; then
@@ -6595,7 +6947,6 @@ fi
 if test "$wxUSE_EDITABLELISTBOX" = "yes"; then
     AC_DEFINE(wxUSE_EDITABLELISTBOX)
     USES_CONTROLS=1
-    SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS editlbox"
 fi
 
 if test "$wxUSE_NOTEBOOK" = "yes"; then
@@ -6604,18 +6955,16 @@ if test "$wxUSE_NOTEBOOK" = "yes"; then
     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS notebook"
 fi
 
+if test "$wxUSE_NOTIFICATION_MESSAGE" = "yes"; then
+    AC_DEFINE(wxUSE_NOTIFICATION_MESSAGE)
+fi
+
 if test "$wxUSE_ODCOMBOBOX" = "yes"; then
   AC_DEFINE(wxUSE_ODCOMBOBOX)
   USES_CONTROLS=1
   SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS combo"
 fi
 
-dnl if test "$wxUSE_PROPSHEET" = "yes"; then
-dnl     AC_DEFINE(wxUSE_PROPSHEET)
-dnl     USES_CONTROLS=1
-dnl     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS proplist"
-dnl fi
-
 if test "$wxUSE_RADIOBOX" = "yes"; then
     AC_DEFINE(wxUSE_RADIOBOX)
     USES_CONTROLS=1
@@ -6626,6 +6975,14 @@ if test "$wxUSE_RADIOBTN" = "yes"; then
     USES_CONTROLS=1
 fi
 
+if test "$wxUSE_REARRANGECTRL" = "yes"; then
+    AC_DEFINE(wxUSE_REARRANGECTRL)
+fi
+
+if test "$wxUSE_RICHMSGDLG" = "yes"; then
+    AC_DEFINE(wxUSE_RICHMSGDLG)
+fi
+
 if test "$wxUSE_SASH" = "yes"; then
     AC_DEFINE(wxUSE_SASH)
     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS sashtest"
@@ -6634,7 +6991,7 @@ fi
 if test "$wxUSE_SCROLLBAR" = "yes"; then
     AC_DEFINE(wxUSE_SCROLLBAR)
     USES_CONTROLS=1
-    SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS scroll scrollsub"
+    SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS scroll"
 fi
 
 if test "$wxUSE_SEARCHCTRL" = "yes"; then
@@ -6691,18 +7048,19 @@ if test "$wxUSE_STATUSBAR" = "yes"; then
     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS statbar"
 fi
 
-if test "$wxUSE_TAB_DIALOG" = "yes"; then
-    AC_DEFINE(wxUSE_TAB_DIALOG)
-fi
-
 if test "$wxUSE_TEXTCTRL" = "yes"; then
     AC_DEFINE(wxUSE_TEXTCTRL)
     USES_CONTROLS=1
     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS text"
+
+    dnl we don't have special switches to disable wxUSE_RICHEDIT[2], it doesn't
+    dnl seem useful to allow disabling them
+    AC_DEFINE(wxUSE_RICHEDIT)
+    AC_DEFINE(wxUSE_RICHEDIT2)
 fi
 
 if test "$wxUSE_TOGGLEBTN" = "yes"; then
-    if test "$wxUSE_COCOA" = 1 ; then
+    if test "$wxUSE_OLD_COCOA" = 1 ; then
         AC_MSG_WARN([Toggle button not yet supported under Mac OS X... disabled])
         wxUSE_TOGGLEBTN=no
     fi
@@ -6760,7 +7118,7 @@ if test "$wxUSE_TREECTRL" = "yes"; then
 fi
 
 if test "$wxUSE_POPUPWIN" = "yes"; then
-    if test "$wxUSE_MAC" = 1 -o "$wxUSE_COCOA" = 1 ; then
+    if test "$wxUSE_OLD_COCOA" = 1 ; then
         AC_MSG_WARN([Popup window not yet supported under Mac OS X... disabled])
     else
         if test "$wxUSE_PM" = 1; then
@@ -6775,7 +7133,7 @@ if test "$wxUSE_POPUPWIN" = "yes"; then
 fi
 
 if test "$wxUSE_DIALUP_MANAGER" = "yes"; then
-    if test "$wxUSE_MAC" = 1 -o "$wxUSE_COCOA" = 1 -o "$wxUSE_MGL" = 1; then
+    if test "$wxUSE_MAC" = 1 -o "$wxUSE_OLD_COCOA" = 1 -o "$wxUSE_MGL" = 1; then
         AC_MSG_WARN([Dialup manager not supported on this platform... disabled])
     else
         AC_DEFINE(wxUSE_DIALUP_MANAGER)
@@ -6824,9 +7182,6 @@ if test "$wxUSE_HTML" = "yes"; then
     AC_DEFINE(wxUSE_HTML)
     USE_HTML=1
     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS html html/about html/help html/helpview html/printing html/test html/virtual html/widget html/zip htlbox"
-    if test "$wxUSE_MAC" = 1; then
-        SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS html/htmlctrl"
-    fi
 fi
 if test "$wxUSE_WEBKIT" = "yes"; then
     if test "$wxUSE_MAC" = 1 -a "$USE_DARWIN" = 1; then
@@ -6846,11 +7201,14 @@ if test "$wxUSE_WEBKIT" = "yes"; then
                            #include <WebKit/WebKit.h>
                         ])
         CPPFLAGS="$old_CPPFLAGS"
-    elif test "$wxUSE_COCOA" = 1; then
+    elif test "$wxUSE_OLD_COCOA" = 1; then
         AC_DEFINE(wxUSE_WEBKIT)
     else
         wxUSE_WEBKIT=no
     fi
+    if test "$wxUSE_WEBKIT" = "yes"; then
+        SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS html/htmlctrl"
+    fi
 fi
 
 USE_XRC=0
@@ -6872,11 +7230,32 @@ if test "$wxUSE_AUI" = "yes"; then
    SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS aui"
 fi
 
+USE_PROPGRID=0
+if test "$wxUSE_PROPGRID" = "yes"; then
+   AC_DEFINE(wxUSE_PROPGRID)
+   USE_PROPGRID=1
+   SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS propgrid"
+fi
+
+USE_RIBBON=0
+if test "$wxUSE_RIBBON" = "yes"; then
+   AC_DEFINE(wxUSE_RIBBON)
+   USE_RIBBON=1
+   SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS ribbon"
+fi
+
 USE_STC=0
 if test "$wxUSE_STC" = "yes"; then
    AC_DEFINE(wxUSE_STC)
    USE_STC=1
    SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS stc"
+
+   dnl python is used to update src/stc.h (see build/bakefiles/scintilla.bkl)
+   AC_PATH_PROG(PYTHON, python)
+   if test "x$PYTHON" = "x"; then
+     COND_PYTHON="#"
+   fi
+   AC_SUBST(COND_PYTHON)
 fi
 
 if test "$wxUSE_MENUS" = "yes"; then
@@ -6894,7 +7273,6 @@ fi
 
 if test "$wxUSE_MINIFRAME" = "yes"; then
     AC_DEFINE(wxUSE_MINIFRAME)
-    SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS minifram"
 fi
 
 if test "$wxUSE_SYSTEM_OPTIONS" = "yes"; then
@@ -7014,11 +7392,7 @@ if test "$wxUSE_NUMBERDLG" = "yes"; then
 fi
 
 if test "$wxUSE_PROGRESSDLG" = "yes"; then
-    if test "$wxUSE_CONSTRAINTS" != "yes"; then
-       AC_MSG_WARN(wxProgressDialog requires constraints so it won't be compiled without them)
-    else
-        AC_DEFINE(wxUSE_PROGRESSDLG)
-    fi
+    AC_DEFINE(wxUSE_PROGRESSDLG)
 fi
 
 if test "$wxUSE_SPLASH" = "yes"; then
@@ -7027,11 +7401,7 @@ if test "$wxUSE_SPLASH" = "yes"; then
 fi
 
 if test "$wxUSE_STARTUP_TIPS" = "yes"; then
-    if test "$wxUSE_CONSTRAINTS" != "yes"; then
-       AC_MSG_WARN(Startup tips requires constraints and won't be compiled without them)
-    else
-        AC_DEFINE(wxUSE_STARTUP_TIPS)
-    fi
+    AC_DEFINE(wxUSE_STARTUP_TIPS)
 fi
 
 if test "$wxUSE_TEXTDLG" = "yes"; then
@@ -7043,56 +7413,106 @@ if test "$wxUSE_WIZARDDLG" = "yes"; then
     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS wizard"
 fi
 
+dnl ---------------------------------------------------------------------------
+dnl options used under wxMSW and wxPM
+dnl ---------------------------------------------------------------------------
+
+if test "$wxUSE_MSW" = 1 -o "$wxUSE_PM" = 1; then
+    if test "$wxUSE_OWNER_DRAWN" = "yes"; then
+        AC_DEFINE(wxUSE_OWNER_DRAWN)
+    fi
+fi
+
 dnl ---------------------------------------------------------------------------
 dnl wxMSW-only options
 dnl ---------------------------------------------------------------------------
 
 if test "$wxUSE_MSW" = 1 ; then
 
-if test "$wxUSE_DC_CACHEING" = "yes"; then
-    AC_DEFINE(wxUSE_DC_CACHEING)
-fi
+    if test "$wxUSE_DC_CACHEING" = "yes"; then
+        AC_DEFINE(wxUSE_DC_CACHEING)
+    fi
 
-if test "$wxUSE_DIB" = "yes"; then
-    AC_DEFINE(wxUSE_WXDIB)
-fi
+    if test "$wxUSE_DIB" = "yes"; then
+        AC_DEFINE(wxUSE_WXDIB)
+    fi
 
-if test "$wxUSE_OWNER_DRAWN" = "yes"; then
-    AC_DEFINE(wxUSE_OWNER_DRAWN)
-fi
+    if test "$wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW" = "yes"; then
+        AC_DEFINE(wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW)
+    fi
 
-if test "$wxUSE_REGKEY" = "yes"; then
-    AC_DEFINE(wxUSE_REGKEY)
-fi
+    if test "$wxUSE_UXTHEME" = "yes"; then
+        AC_DEFINE(wxUSE_UXTHEME)
+    fi
 
-if test "$wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW" = "yes"; then
-    AC_DEFINE(wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW)
 fi
+dnl wxUSE_MSW = 1
 
-if test "$wxUSE_UXTHEME" = "yes"; then
-    AC_DEFINE(wxUSE_UXTHEME)
+dnl not quite MSW-only although mostly useful to disable this under MSW
+if test "$wxUSE_AUTOID_MANAGEMENT" = "yes"; then
+    AC_DEFINE(wxUSE_AUTOID_MANAGEMENT)
 fi
 
+if test "$USE_WIN32" = 1 ; then
+    if test "$wxUSE_INICONF" = "yes"; then
+        AC_DEFINE(wxUSE_INICONF)
+    fi
+
+    if test "$wxUSE_REGKEY" = "yes"; then
+        AC_DEFINE(wxUSE_REGKEY)
+    fi
 fi
-dnl wxUSE_MSW = 1
+dnl USE_WIN32 = 1
 
 dnl ---------------------------------------------------------------------------
 dnl wxGraphicsContext
 dnl ---------------------------------------------------------------------------
 
+dnl Under Mac we don't even provide --enable-graphics_ctx switch as we always
+dnl need it -- but because we don't have the option, wxUSE_GRAPHICS_CONTEXT is
+dnl not defined automatically and we need to do it ourselves
+if test "$wxUSE_MAC" = 1; then
+    wxUSE_GRAPHICS_CONTEXT="yes"
+fi
+
 if test "$wxUSE_GRAPHICS_CONTEXT" = "yes"; then
-   if test "$wxUSE_MAC" = 1 -o "$wxUSE_COCOA" = "1"; then
-      AC_DEFINE(wxUSE_GRAPHICS_CONTEXT)
-   elif test "$wxUSE_GTK" != 1; then
-      dnl for other builds we'll just wing it for now...
-      AC_DEFINE(wxUSE_GRAPHICS_CONTEXT)
-   else
-      dnl ...but let's check for cairo availability for wxGTK builds
-      PKG_CHECK_MODULES(CAIRO, cairo,
-          [AC_DEFINE(wxUSE_GRAPHICS_CONTEXT)],
-          [AC_MSG_WARN([Cairo library not found, unable to set wxUSE_GRAPHICS_CONTEXT])]
-      )
-   fi
+    wx_has_graphics=0
+    if test "$wxUSE_MSW" = 1; then
+        AC_CACHE_CHECK([if GDI+ is available], wx_cv_lib_gdiplus,
+            [
+                dnl we need just the header, not the library, as we load the
+                dnl GDI+ DLL dynamically anyhow during run-time
+                AC_LANG_PUSH(C++)
+                AC_TRY_COMPILE(
+                    [#include <windows.h>
+                     #include <gdiplus.h>],
+                    [
+                        using namespace Gdiplus;
+                    ],
+                    wx_cv_lib_gdiplus=yes,
+                    wx_cv_lib_gdiplus=no
+                )
+                AC_LANG_POP()
+            ]
+        )
+        if test "$wx_cv_lib_gdiplus" = "yes"; then
+            wx_has_graphics=1
+        fi
+    elif test "$wxUSE_GTK" = 1; then
+        PKG_CHECK_MODULES(CAIRO, cairo,
+            [wx_has_graphics=1],
+            [AC_MSG_WARN([Cairo library not found])]
+        )
+    else
+        dnl assume it's ok, add more checks here if needed
+        wx_has_graphics=1
+    fi
+
+    if test "$wx_has_graphics" = 1; then
+        AC_DEFINE(wxUSE_GRAPHICS_CONTEXT)
+    else
+        AC_MSG_WARN([wxGraphicsContext won't be available])
+    fi
 fi
 
 dnl ---------------------------------------------------------------------------
@@ -7101,7 +7521,7 @@ dnl ---------------------------------------------------------------------------
 
 USE_MEDIA=0
 
-if test "$wxUSE_MEDIACTRL" = "yes"; then
+if test "$wxUSE_MEDIACTRL" = "yes" -o "$wxUSE_MEDIACTRL" = "auto"; then
     USE_MEDIA=1
 
     dnl -----------------------------------------------------------------------
@@ -7151,7 +7571,7 @@ if test "$wxUSE_MEDIACTRL" = "yes"; then
 
         if test "$wxUSE_GSTREAMER" = "yes"; then
             CPPFLAGS="$GST_CFLAGS $CPPFLAGS"
-            LIBS="$GST_LIBS $LIBS"
+            EXTRALIBS_MEDIA="$GST_LIBS"
 
             AC_DEFINE(wxUSE_GSTREAMER)
         else
@@ -7162,6 +7582,13 @@ if test "$wxUSE_MEDIACTRL" = "yes"; then
     if test $USE_MEDIA = 1; then
         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS mediaplayer"
         AC_DEFINE(wxUSE_MEDIACTRL)
+    else
+        if test "$wxUSE_MEDIACTRL" = "yes"; then
+            AC_MSG_ERROR([GStreamer not available])
+        else
+            dnl was set to 'auto'
+            AC_MSG_WARN([GStreamer not available... disabling wxMediaCtrl])
+        fi
     fi
 fi
 
@@ -7169,7 +7596,7 @@ dnl ---------------------------------------------------------------------------
 dnl get the string with OS info - used by wxGetOsDescription() on MacOS X
 dnl ---------------------------------------------------------------------------
 
-if test "$cross_compiling" = "yes"; then
+if test "$cross_compiling" != "no"; then
     dnl Use best guess from host as we can't use uname when cross compiling
     OSINFO="\"$host\""
 else
@@ -7200,15 +7627,12 @@ dnl ---------------------------------------------------------------------------
 STD_BASE_LIBS="base"
 STD_GUI_LIBS=""
 BUILT_WX_LIBS="base"
-ALL_WX_LIBS="xrc stc gl media dbgrid qa html adv core odbc xml net base"
+ALL_WX_LIBS="xrc stc gl media qa html adv core xml net base"
 
 if test "$wxUSE_SOCKETS" = "yes" ; then
     STD_BASE_LIBS="net $STD_BASE_LIBS"
     BUILT_WX_LIBS="net $BUILT_WX_LIBS"
 fi
-if test "$wxUSE_ODBC" != "no" ; then
-    BUILT_WX_LIBS="odbc $BUILT_WX_LIBS"
-fi
 if test "$wxUSE_XML" = "yes" ; then
     STD_BASE_LIBS="xml $STD_BASE_LIBS"
     BUILT_WX_LIBS="xml $BUILT_WX_LIBS"
@@ -7222,9 +7646,6 @@ if test "$wxUSE_GUI" = "yes"; then
         STD_GUI_LIBS="qa $STD_GUI_LIBS"
         BUILT_WX_LIBS="qa $BUILT_WX_LIBS"
     fi
-    if test "$wxUSE_ODBC" != "no" ; then
-        BUILT_WX_LIBS="dbgrid $BUILT_WX_LIBS"
-    fi
     if test "$wxUSE_HTML" = "yes" ; then
         STD_GUI_LIBS="html $STD_GUI_LIBS"
         BUILT_WX_LIBS="html $BUILT_WX_LIBS"
@@ -7238,6 +7659,15 @@ if test "$wxUSE_GUI" = "yes"; then
     if test "$wxUSE_AUI" = "yes" ; then
         BUILT_WX_LIBS="aui $BUILT_WX_LIBS"
     fi
+    if test "$wxUSE_PROPGRID" = "yes" ; then
+        BUILT_WX_LIBS="propgrid $BUILT_WX_LIBS"
+    fi
+    if test "$wxUSE_RIBBON" = "yes" ; then
+        BUILT_WX_LIBS="ribbon $BUILT_WX_LIBS"
+    fi
+    if test "$wxUSE_RICHTEXT" = "yes" ; then
+        BUILT_WX_LIBS="richtext $BUILT_WX_LIBS"
+    fi
     if test "$wxUSE_STC" = "yes" ; then
         BUILT_WX_LIBS="stc $BUILT_WX_LIBS"
     fi
@@ -7257,31 +7687,29 @@ dnl Output the makefiles and such from the results found above
 dnl ---------------------------------------------------------------------------
 
 dnl all additional libraries (except wxWidgets itself) we link with
-
+EXTRA_FRAMEWORKS=
 if test "$wxUSE_MAC" = 1 ; then
-    if test "$wxUSE_SOUND" = "yes" || test "$wxUSE_MEDIACTRL" = "yes"; then
-        if test "$USE_DARWIN" = 1; then
-            LDFLAGS="$LDFLAGS -framework QuickTime"
+    if test "$USE_DARWIN" = 1; then
+        if test "$wxUSE_OSX_IPHONE" = 1; then
+            EXTRA_FRAMEWORKS="-framework IOKit -framework UIKit -framework CFNetwork -framework AudioToolbox -framework CoreFoundation -framework CoreGraphics -framework OpenGLES -framework Foundation -framework QuartzCore"
         else
-            LDFLAGS="$LDFLAGS -lQuickTimeLib"
+            EXTRA_FRAMEWORKS="-framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -framework QuickTime"
         fi
     fi
-    if test "$USE_DARWIN" = 1; then
-        LDFLAGS="$LDFLAGS -framework IOKit -framework Carbon -framework Cocoa -framework System"
-    else
-        LDFLAGS="$LDFLAGS -lCarbonLib"
-    fi
 fi
-if test "$wxUSE_COCOA" = 1 ; then
-    LDFLAGS="$LDFLAGS -framework IOKit -framework Cocoa"
+if test "$wxUSE_OLD_COCOA" = 1 ; then
+    EXTRA_FRAMEWORKS="-framework IOKit -framework Cocoa"
     if test "$wxUSE_MEDIACTRL" = "yes"; then
-        LDFLAGS="$LDFLAGS -framework QuickTime"
+        EXTRA_FRAMEWORKS="$EXTRA_FRAMEWORKS -framework QuickTime"
     fi
 fi
-if test "$USE_DARWIN" = 1 -a "$wxUSE_MAC" != 1 -a "$wxUSE_COCOA" != 1 ; then
-    LDFLAGS="$LDFLAGS -framework IOKit -framework CoreServices -framework System -framework ApplicationServices"
+if test "$USE_DARWIN" = 1 -a "$wxUSE_MAC" != 1 -a "$wxUSE_OLD_COCOA" != 1 ; then
+    EXTRA_FRAMEWORKS="$EXTRA_FRAMEWORKS -framework IOKit -framework CoreServices -framework System -framework ApplicationServices"
 fi
 
+LDFLAGS="$LDFLAGS $EXTRA_FRAMEWORKS"
+WXCONFIG_LDFLAGS="$WXCONFIG_LDFLAGS $EXTRA_FRAMEWORKS"
+
 LIBS="$ZLIB_LINK $POSIX4_LINK $INET_LINK $WCHAR_LINK $DL_LINK $LIBS"
 
 if test "$wxUSE_GUI" = "yes"; then
@@ -7291,9 +7719,8 @@ if test "$wxUSE_GUI" = "yes"; then
 
     dnl TODO some samples are never built so far: mfc (requires VC++)
     SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS artprov controls dialogs drawing \
-                     dynamic erase event exec font image minimal mobile \
-                     mobile/wxedit mobile/styles propsize render \
-                     rotate shaped svg taborder vscroll widgets"
+                     erase event exec font image minimal render \
+                     shaped svg taborder vscroll widgets wrapsizer"
 
     if test "$wxUSE_MONOLITHIC" != "yes"; then
         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS console"
@@ -7301,7 +7728,7 @@ if test "$wxUSE_GUI" = "yes"; then
     if test "$TOOLKIT" = "MSW"; then
         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS regtest"
         if test "$wxUSE_UNIVERSAL" != "yes"; then
-            SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS ownerdrw nativdlg"
+            SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS ownerdrw nativdlg dll"
         fi
     fi
     if test "$TOOLKIT" = "PM" -a "$wxUSE_UNIVERSAL" != "yes"; then
@@ -7309,6 +7736,12 @@ if test "$wxUSE_GUI" = "yes"; then
     fi
 else
     SAMPLES_SUBDIRS="console"
+    if test "$wxUSE_SOCKETS" = "yes" ; then
+        SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS sockets"
+    fi
+    if test "$wxUSE_IPC" = "yes" ; then
+        SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS ipc"
+    fi
 fi
 
 
@@ -7318,14 +7751,14 @@ dnl check for icc before gcc as icc is also recognized as gcc
 if test "x$INTELCC" = "xyes" ; then
     dnl Warnings which can't be easily suppressed in C code are disabled:
     dnl
-    dnl     remark #810: conversion from "x" to "y" may lose significant bits
-    dnl     remark #869: parameter "foo" was never referenced
-    dnl     remark #1572: floating-point equality and inequality comparisons
-    dnl                   are unreliable
-    dnl     remark #1684: conversion from pointer to same-sized integral type
-    dnl
-    dnl (for others see below)
-    CWARNINGS="-Wall -wd810,869,981,1418,1572,1684"
+    dnl     #810: conversion from "x" to "y" may lose significant bits
+    dnl     #869: parameter "foo" was never referenced
+    dnl     #1572: floating-point equality and inequality comparisons
+    dnl            are unreliable
+    dnl     #1684: conversion from pointer to same-sized integral type
+    dnl     #2259: non-pointer conversion from "x" to "y" may lose significant
+    dnl            bits
+    CWARNINGS="-Wall -wd810,869,981,1418,1572,1684,2259"
 elif test "$GCC" = yes ; then
     CWARNINGS="-Wall -Wundef"
 fi
@@ -7337,18 +7770,27 @@ if test "x$INTELCXX" = "xyes" ; then
     dnl (279) are generated for standard macros and so there is nothing we can
     dnl do about them
     dnl
-    dnl     remark #279: controlling expression is constant
-    dnl     remark #383: value copied to temporary, reference to temporary used
-    dnl     remark #444: destructor for base class "xxx" is not virtual
-    dnl     remark #810: conversion from "x" to "y" may lose significant bits
-    dnl     remark #869: parameter "foo" was never referenced
-    dnl     remark #981: operands are evaluated in unspecified order
-    dnl     remark #1418: external definition with no prior declaration
-    dnl     remark #1419: external declaration in primary source file
-    CXXWARNINGS="-Wall -wd279,383,444,810,869,981,1418,1419"
+    dnl     #279: controlling expression is constant
+    dnl     #383: value copied to temporary, reference to temporary used
+    dnl     #444: destructor for base class "xxx" is not virtual
+    dnl     #981: operands are evaluated in unspecified order
+    dnl     #1418: external definition with no prior declaration
+    dnl     #1419: external declaration in primary source file
+    dnl     #1881: argument must be a constant null pointer value
+    dnl
+    dnl (for others see CWARNINGS above)
+    CXXWARNINGS="-Wall -wd279,383,444,810,869,981,1418,1419,1881,2259"
 elif test "$GXX" = yes ; then
-    dnl CXXWARNINGS="-Wall -W -Wcast-qual -Werror"
-    CXXWARNINGS="-Wall -Wundef -Wno-ctor-dtor-privacy"
+    CXXWARNINGS="-Wall -Wundef -Wunused-parameter -Wno-ctor-dtor-privacy"
+    AX_CXXFLAGS_GCC_OPTION(-Woverloaded-virtual, CXXWARNINGS)
+
+    dnl when building under Mac we currently get hundreds of deprecation
+    dnl warnings for Carbon symbols from the standard headers -- disable them
+    dnl as we already know that they're deprecated and nothing else can be seen
+    dnl with these warnings on
+    if test "$wxUSE_MAC" = 1 ; then
+        CXXWARNINGS="$CXXWARNINGS -Wno-deprecated-declarations"
+    fi
 fi
 
 
@@ -7371,6 +7813,8 @@ CPPFLAGS=`echo $WXCONFIG_CPPFLAGS \
 C_AND_CXX_FLAGS="$DEBUG_CFLAGS $PROFILE_FLAGS $OPTIMISE_CFLAGS"
 CFLAGS=`echo $WXCONFIG_CFLAGS $CWARNINGS $C_AND_CXX_FLAGS $CFLAGS `
 CXXFLAGS=`echo $WXCONFIG_CXXFLAGS $C_AND_CXX_FLAGS $CXXFLAGS `
+OBJCFLAGS=`echo $WXCONFIG_CFLAGS $CWARNINGS $C_AND_CXX_FLAGS $OBJCFLAGS `
+OBJCXXFLAGS=`echo $WXCONFIG_CXXFLAGS $C_AND_CXX_FLAGS $OBJCXXFLAGS `
 
 dnl now that we added WXCONFIG_CPPFLAGS to CPPFLAGS we can add the wx-config
 dnl only stuff to it
@@ -7397,8 +7841,8 @@ LIBS=`echo $LIBS`
 EXTRALIBS="$LDFLAGS $LDFLAGS_VERSIONING $LIBS $DMALLOC_LIBS"
 EXTRALIBS_XML="$EXPAT_LINK"
 EXTRALIBS_HTML="$MSPACK_LINK"
-EXTRALIBS_ODBC="$ODBC_LINK"
-EXTRALIBS_STC="-lwxscintilla${lib_debug_suffix}${WX_LIB_FLAVOUR}-${WX_RELEASE}${HOST_SUFFIX}"
+EXTRALIBS_MEDIA="$GST_LIBS"
+EXTRALIBS_STC="-lwxscintilla${WX_LIB_FLAVOUR}-${WX_RELEASE}${HOST_SUFFIX}"
 if test "$wxUSE_GUI" = "yes"; then
     EXTRALIBS_GUI=`echo $GUI_TK_LIBRARY $PNG_LINK $JPEG_LINK $TIFF_LINK $WEBKIT_LINK $EXTRALIBS_HILDON $EXTRALIBS_GNOMEVFS $EXTRALIBS_GNOMEPRINT`
 fi
@@ -7417,9 +7861,6 @@ fi
 if test "$wxUSE_EXPAT" = "builtin" ; then
     wxconfig_3rdparty="expat $wxconfig_3rdparty"
 fi
-if test "$wxUSE_ODBC" = "builtin" ; then
-    wxconfig_3rdparty="odbc $wxconfig_3rdparty"
-fi
 if test "$wxUSE_LIBTIFF" = "builtin" ; then
     wxconfig_3rdparty="tiff $wxconfig_3rdparty"
 fi
@@ -7434,7 +7875,7 @@ if test "$wxUSE_ZLIB" = "builtin" ; then
 fi
 
 for i in $wxconfig_3rdparty ; do
-    WXCONFIG_LIBS="-lwx${i}${lib_debug_suffix}${WX_LIB_FLAVOUR}-${WX_RELEASE}${HOST_SUFFIX} $WXCONFIG_LIBS"
+    WXCONFIG_LIBS="-lwx${i}${WX_LIB_FLAVOUR}-${WX_RELEASE}${HOST_SUFFIX} $WXCONFIG_LIBS"
 done
 
 
@@ -7447,7 +7888,7 @@ if test "x$wxUSE_UNIVERSAL" = "xyes" ; then
             ;;
 
         *)
-            for t in `echo $wxUNIV_THEMES | tr , ' ' | tr a-z A-Z`; do
+            for t in `echo $wxUNIV_THEMES | tr , ' ' | tr '[[a-z]]' '[[A-Z]]'`; do
                 AC_DEFINE_UNQUOTED(wxUSE_THEME_$t)
             done
     esac
@@ -7458,7 +7899,6 @@ fi
 AC_SUBST(wxUSE_ZLIB)
 AC_SUBST(wxUSE_REGEX)
 AC_SUBST(wxUSE_EXPAT)
-AC_SUBST(wxUSE_ODBC)
 AC_SUBST(wxUSE_LIBJPEG)
 AC_SUBST(wxUSE_LIBPNG)
 AC_SUBST(wxUSE_LIBTIFF)
@@ -7475,12 +7915,6 @@ else
     USE_PLUGINS=0
 fi
 
-if test $wxUSE_ODBC != "no" ; then
-    USE_ODBC=1
-else
-    USE_ODBC=0
-fi
-
 if test "$wxUSE_DEBUGREPORT" = "yes" ; then
     USE_QA=1
 else
@@ -7506,23 +7940,26 @@ AC_SUBST(CXXWARNINGS)
 AC_SUBST(EXTRALIBS)
 AC_SUBST(EXTRALIBS_XML)
 AC_SUBST(EXTRALIBS_HTML)
-AC_SUBST(EXTRALIBS_ODBC)
+AC_SUBST(EXTRALIBS_MEDIA)
 AC_SUBST(EXTRALIBS_GUI)
 AC_SUBST(EXTRALIBS_OPENGL)
 AC_SUBST(EXTRALIBS_SDL)
+AC_SUBST(EXTRALIBS_STC)
 AC_SUBST(WITH_PLUGIN_SDL)
+AC_SUBST(EXTRALIBS_GTKPRINT)
 AC_SUBST(EXTRALIBS_GNOMEPRINT)
 AC_SUBST(EXTRALIBS_GNOMEVFS)
 AC_SUBST(EXTRALIBS_HILDON)
 AC_SUBST(UNICODE)
-AC_SUBST(BUILD)
 AC_SUBST(DEBUG_INFO)
 AC_SUBST(DEBUG_FLAG)
-TOOLKIT_LOWERCASE=`echo $TOOLKIT | tr "[[A-Z]]" "[[a-z]]"`
+TOOLKIT_LOWERCASE=`echo $TOOLKIT | tr '[[A-Z]]' '[[a-z]]'`
 AC_SUBST(TOOLKIT_LOWERCASE)
 AC_SUBST(TOOLKIT_VERSION)
+AC_SUBST(DYLIB_RPATH_INSTALL)
+AC_SUBST(DYLIB_RPATH_POSTLINK)
 AC_SUBST(SAMPLES_RPATH_FLAG)
-AC_SUBST(SAMPLES_RPATH_POSTLINK)
+AC_SUBST(HEADER_PAD_OPTION)
 AC_SUBST(HOST_SUFFIX)
 AC_SUBST(CPPUNIT_CFLAGS)
 AC_SUBST(CPPUNIT_LIBS)
@@ -7530,8 +7967,11 @@ AC_SUBST(CPPUNIT_LIBS)
 case "$TOOLKIT" in
     GTK)
         TOOLKIT_DESC="GTK+"
-        if test "$WXGTK20" = 1; then
+        if test "$WXGTK2" = 1; then
             TOOLKIT_DESC="$TOOLKIT_DESC 2"
+            if test "$wxUSE_GTKPRINT" = "yes" ; then
+                TOOLKIT_EXTRA="$TOOLKIT_EXTRA GTK+ printing";
+            fi
             if test "$wxUSE_LIBGNOMEPRINT" = "yes" ; then
                 TOOLKIT_EXTRA="$TOOLKIT_EXTRA gnomeprint";
             fi
@@ -7541,6 +7981,9 @@ case "$TOOLKIT" in
             if test "$wxUSE_LIBHILDON" = "yes"; then
                 TOOLKIT_EXTRA="$TOOLKIT_EXTRA hildon"
             fi
+            if test "$wxUSE_LIBHILDON2" = "yes"; then
+                TOOLKIT_EXTRA="$TOOLKIT_EXTRA hildon"
+            fi
 
             if test "$TOOLKIT_EXTRA" != ""; then
                 TOOLKIT_DESC="$TOOLKIT_DESC with support for `echo $TOOLKIT_EXTRA | tr -s ' '`"
@@ -7561,32 +8004,6 @@ if test "$wxUSE_WINE" = "yes"; then
     BAKEFILE_FORCE_PLATFORM=win32
 fi
 
-dnl ---------------------------------------------------------------------------
-dnl Add Universal binary support
-dnl Note we don't do this earlier because adding these cpp/ld flags could
-dnl cause configure tests to fail.
-dnl ---------------------------------------------------------------------------
-if test "$wxUSE_MAC" = 1 ; then
-    if test "x$wxUSE_UNIVERSAL_BINARY" != xno ; then
-        dnl --enable-universal_binary uses a default SDK (currently 10.4u)
-        dnl --enable-universal_binary=SDK names a path to an SDK
-        if test "x$wxUSE_UNIVERSAL_BINARY" == xyes; then
-            OSX_UNIV_OPTS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk"
-        else
-            dnl '' would mean universal with no SDK, which may be the case if
-            dnl the compiler uses a sysroot by default
-            OSX_UNIV_OPTS=${wxUSE_UNIVERSAL_BINARY:+"-isysroot '$wxUSE_UNIVERSAL_BINARY'"}
-        fi
-        OSX_UNIV_OPTS="$OSX_UNIV_OPTS -arch ppc -arch i386"
-        CXXFLAGS="$OSX_UNIV_OPTS $CXXFLAGS"
-        CFLAGS="$OSX_UNIV_OPTS $CFLAGS"
-        LDFLAGS="$OSX_UNIV_OPTS $LDFLAGS"
-        bk_use_pch=no
-    fi
-    # TODO: where do we add "-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk" for libtool (static builds only)?
-    #       The makefile currently uses AR and RANLIB, which libtool apparently supercedes.
-fi
-
 dnl gcc 3.4 has a pch bug which truncates wide character constants in headers.
 dnl Hopefully for a non-unicode build there aren't any wide constants in
 dnl headers, but for a unicode build it's best to disable pch.
@@ -7636,6 +8053,71 @@ fi
 
 AC_BAKEFILE([m4_include(autoconf_inc.m4)])
 
+dnl make install path absolute (if not already);
+dnl will fail with (some) MSDOS paths
+case ${INSTALL} in
+  /* ) # Absolute
+     ;;
+  ?:* ) # Drive letter, considered as absolute.
+     ;;
+  *)
+     INSTALL=`pwd`/${INSTALL} ;;
+esac
+
+if test "$wxUSE_GUI" = "yes"; then
+
+if test "$wxUSE_MSW" = 1 ; then
+    if test "x$WINDRES" = "x"; then
+        AC_MSG_ERROR([Required windres program not found])
+    fi
+
+    RESCOMP="$WINDRES $WINDRES_CPU_DEFINE"
+fi
+
+if test "$wxUSE_MAC" = 1 -o "$wxUSE_OLD_COCOA" = 1; then
+    dnl base name of the resource file for wxMac must be the same
+    dnl as library installation base name (-install_name)
+    WX_RESOURCES_MACOSX_ASCII="libwx_${TOOLCHAIN_NAME}.${wx_release_number}.r"
+    WX_RESOURCES_MACOSX_DATA="libwx_${TOOLCHAIN_NAME}.${wx_release_number}.rsrc"
+
+    dnl add the resources target for wxMac
+    LIBWXMACRES="\$(wx_top_builddir)/lib/${WX_RESOURCES_MACOSX_ASCII}"
+
+    AC_CHECK_PROG(DEREZ, DeRez, DeRez, /Developer/Tools/DeRez)
+
+    MACSETFILE="\$(SETFILE)"
+
+    dnl resources are bundled both with shared library and applications
+    dnl since the carb resource *must* be included in the application
+    if test "$wxUSE_OSX_CARBON" = 1; then
+        POSTLINK_COMMAND="\$(REZ) -d __DARWIN__ -t APPL Carbon.r -o"
+        RESCOMP="$REZ"
+        WXCONFIG_RESFLAGS="-d __DARWIN__ -t APPL Carbon.r -o"
+    else
+        POSTLINK_COMMAND="cat /dev/null | \$(REZ) -d __DARWIN__ -t APPL ${LIBWXMACRES}"
+        RESCOMP="cat /dev/null \| $REZ"
+        WXCONFIG_RESFLAGS="-d __DARWIN__ -t APPL \$libdir/$WX_RESOURCES_MACOSX_ASCII"
+    fi
+
+else
+    dnl default value is to (silently) do nothing in the makefile
+    MACSETFILE="@true"
+
+    if test "$wxUSE_PM" = 1; then
+        RESCOMP="emxbind"
+        WXCONFIG_RESFLAGS="-ep"
+
+        dnl Is this one really used anywhere for pm?
+        POSTLINK_COMMAND="$RESCOMP $WXCONFIG_RESFLAGS"
+    else
+        POSTLINK_COMMAND="@true"
+    fi
+fi
+
+fi
+dnl wxUSE_GUI = 1
+
+
 dnl find out if the compiler supports PCH
 dnl
 dnl TODO: this should be in bakefile
@@ -7647,7 +8129,11 @@ then
         AC_MSG_WARN([*** see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13361])
     fi
 
-    CPPFLAGS="-DWX_PRECOMP $CPPFLAGS"
+    # Our WX_PRECOMP flag does not make sense for any language except C++ because
+    # the headers that benefit from precompilation are mostly C++ headers.
+    CXXFLAGS="-DWX_PRECOMP $CXXFLAGS"
+    # When Bakefile can do multi-language PCH (e.g. C++ and Objective-C++) enable this:
+    #OBJCXXFLAGS="-DWX_PRECOMP $CXXFLAGS"
 fi
 
 dnl HACK ALERT!!
@@ -7665,16 +8151,6 @@ if test "$wxUSE_MAC" = 1 ; then
 fi
 
 if test "$wxUSE_SHARED" = "yes"; then
-
-    dnl We get the shared build linker from bakefile, since it
-    dnl moved all the logic for this out of this file and into
-    dnl its own macro.  But it can't decide on whether to return
-    dnl us $(VAR), ${VAR}, or the present expansion of VAR.
-    dnl So normalise and expand everything here now, because its
-    dnl not going to change inside wx-config anyway.
-    sanitised_bakefile_mess=`echo "$SHARED_LD_CXX" | tr -d '()'`
-    EXE_LINKER=`eval echo "$sanitised_bakefile_mess"`
-
     dnl Need addtional flag on OS/2, so override bakefiles value
     dnl (there currently is no suitable variable to which the
     dnl  missing flags could be added, AFAICS. SN, 18.12.2004. )
@@ -7686,11 +8162,6 @@ if test "$wxUSE_SHARED" = "yes"; then
         cp -p ${srcdir}/src/os2/dllar.sh .
       ;;
     esac
-else
-
-    dnl No bakefile support for static builds, but this should be ok for most.
-    EXE_LINKER="$CXX -o"
-
 fi
 if test "$wxUSE_OMF" = "yes"; then
     case "${host}" in
@@ -7719,7 +8190,7 @@ case "${host}" in
     *-*-solaris2* )
         dnl system packages are compiled with Sun CC and so pkg-config outputs
         dnl CC-specific "-mt" flag, remove it when using gcc
-        if "$GCC" = yes; then
+        if test "$GCC" = yes; then
             CPPFLAGS=`echo $CPPFLAGS | sed 's/-mt//'`
             LIBS=`echo $LIBS | sed 's/-mt//'`
             EXTRALIBS_GUI=`echo $EXTRALIBS_GUI | sed 's/-mt//'`
@@ -7741,6 +8212,8 @@ dnl Add visibility support flags to CFLAGS/CXXFLAGS - do it this late so that
 dnl it doesn't affect compilation checks above
 CFLAGS="$CFLAGS $CFLAGS_VISIBILITY"
 CXXFLAGS="$CXXFLAGS $CXXFLAGS_VISIBILITY"
+OBJCFLAGS="$OBJCFLAGS $CFLAGS_VISIBILITY"
+OBJCXXFLAGS="$OBJCXXFLAGS $CXXFLAGS_VISIBILITY"
 
 dnl for convenience, sort the samples in alphabetical order
 dnl
@@ -7779,7 +8252,6 @@ AC_SUBST(WX_RELEASE)
 AC_SUBST(WX_VERSION)
 AC_SUBST(WX_SUBVERSION)
 AC_SUBST(WX_CHARTYPE)
-AC_SUBST(WX_DEBUGTYPE)
 
 dnl note that in addition to the usual CPP/C/CXXFLAGS which are used for
 dnl building the library itself, we also have WXCONFIG_-prefixed variants which
@@ -7797,9 +8269,9 @@ AC_SUBST(WXCONFIG_CXXFLAGS)
 
 AC_SUBST(WXCONFIG_LIBS)
 AC_SUBST(WXCONFIG_RPATH)
+AC_SUBST(WXCONFIG_LDFLAGS)
 AC_SUBST(WXCONFIG_LDFLAGS_GUI)
 AC_SUBST(WXCONFIG_RESFLAGS)
-AC_SUBST(EXE_LINKER)
 
 dnl distribution vars
 AC_SUBST(GUIDIST)
@@ -7844,10 +8316,7 @@ AC_PROG_MAKE_SET
 AC_CONFIG_HEADERS([lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/setup.h:setup.h.in])
 
 if test "$USE_WIN32" = 1; then
-    AC_CONFIG_COMMANDS(
-        [
-            rcdefs.h
-        ],
+    AC_CONFIG_COMMANDS([rcdefs.h],
         [
             mkdir -p $outdir &&
             $CPP $infile | sed 's/^# *[1-9].*//;s/^ *//;/./,/^$/!d' > $outdir/rcdefs.h
@@ -7868,6 +8337,11 @@ AC_CONFIG_FILES([ lib/wx/config/inplace-${TOOLCHAIN_FULLNAME}:wx-config-inplace.
                 [ chmod +x lib/wx/config/inplace-${TOOLCHAIN_FULLNAME} ],
                 [ TOOLCHAIN_FULLNAME="${TOOLCHAIN_FULLNAME}" ])
 
+dnl this is used to run ifacecheck with the same flags used by the compiler
+dnl for the real compilation:
+AC_CONFIG_FILES([ utils/ifacecheck/rungccxml.sh ],
+                [ chmod +x utils/ifacecheck/rungccxml.sh ])
+
 if test "$wx_cv_version_script" = "yes"; then
     AC_CONFIG_FILES(version-script)
 fi
@@ -7891,21 +8365,22 @@ if test "$wxWITH_SUBDIRS" != "no"; then
 dnl Configure samples, demos etc. directories, but only if they are present:
 if test "$wxUSE_GUI" = "yes"; then
     SUBDIRS="samples demos utils"
-else dnl we build wxBase only
+else
+    dnl we build wxBase only
     dnl there are no wxBase programs in demos
     SUBDIRS="samples utils"
 fi
 dnl Add tests to the list of subdirs if cppunit 1.8.0+ is detected
 AM_PATH_CPPUNIT(1.8.0, [SUBDIRS="$SUBDIRS tests"])
 
-for subdir in `echo $SUBDIRS`; do
+for subdir in $SUBDIRS; do
     if test -d ${srcdir}/${subdir} ; then
         if test "$wxUSE_GUI" = "yes"; then
             if test ${subdir} = "samples"; then
                 dnl only take those samples which compile in the current
                 dnl configuration and which exist
                 makefiles="samples/Makefile.in $makefiles"
-                for sample in `echo $SAMPLES_SUBDIRS`; do
+                for sample in $SAMPLES_SUBDIRS; do
                     if test -d $srcdir/samples/$sample; then
                         makefiles="samples/$sample/Makefile.in $makefiles"
                     fi
@@ -7914,26 +8389,33 @@ for subdir in `echo $SUBDIRS`; do
                 dnl assume that everything compiles for utils &c
                 dnl any that shouldn't be built can be added to
                 dnl DISABLED_UTILS, DISABLED_DEMOS
-                disabled_var=DISABLED_`echo $subdir | tr [[a-z]] [[A-Z]]`;
+                disabled_var=DISABLED_`echo $subdir | tr '[[a-z]]' '[[A-Z]]'`
                 eval "disabled=\$$disabled_var"
                 disabled=/`echo X $disabled | sed 's@ @/|/@g'`/
                 makefiles=`(cd $srcdir ; find $subdir -name Makefile.in) | $EGREP -v "$disabled"`
             fi
-        else dnl we build wxBase only
-            dnl don't take all samples/utils, just those which build with
-            dnl wxBase
+        else
+            dnl we build wxBase only
+            dnl don't take all samples/utils, just those which build with wxBase
             if test ${subdir} = "samples"; then
-                makefiles="samples/Makefile.in samples/console/Makefile.in"
+                dnl only take those samples which compile in the current
+                dnl configuration and which exist
+                makefiles="samples/Makefile.in $makefiles"
+                for sample in `echo $SAMPLES_SUBDIRS`; do
+                    if test -d $srcdir/samples/$sample; then
+                        makefiles="samples/$sample/Makefile.in $makefiles"
+                    fi
+                done
             elif test ${subdir} = "utils"; then
                 makefiles=""
-                for util in HelpGen tex2rtf ; do
+                for util in ifacecheck ; do
                     if test -d $srcdir/utils/$util ; then
-                        makefiles="utils/$util/Makefile.in \
-                                   utils/$util/src/Makefile.in \
+                        makefiles="utils/$util/src/Makefile.in \
                                    $makefiles"
                     fi
                 done
-            else dnl assume that everything compiles for tests
+            else
+                dnl assume that everything compiles for tests
                 makefiles=`(cd $srcdir ; find $subdir -name Makefile.in)`
             fi
         fi
@@ -7954,10 +8436,8 @@ echo "Configured wxWidgets ${WX_VERSION} for \`${host}'"
 echo ""
 echo "  Which GUI toolkit should wxWidgets use?                 ${TOOLKIT_DESC}"
 echo "  Should wxWidgets be compiled into single library?       ${wxUSE_MONOLITHIC:-yes}"
-
-echo "  Should wxWidgets be compiled in debug mode?             ${wxUSE_DEBUG:-no}"
 echo "  Should wxWidgets be linked as a shared library?         ${wxUSE_SHARED:-no}"
-echo -n "  Should wxWidgets support Unicode?                       ${wxUSE_UNICODE:-no}"
+echo $ECHO_N "  Should wxWidgets support Unicode?                       ${wxUSE_UNICODE:-no}$ECHO_C"
 if test "$wxUSE_UNICODE" = "yes"; then
     if test "$wxUSE_UNICODE_UTF8" = "yes"; then
         echo " (using UTF-8)"
@@ -7973,6 +8453,7 @@ echo "                                       wxWidgets 2.6      ${WXWIN_COMPATIB
 echo "                                       wxWidgets 2.8      ${WXWIN_COMPATIBILITY_2_8:-yes}"
 
 echo "  Which libraries should wxWidgets use?"
+echo "                                       STL                ${wxUSE_STL}"
 echo "                                       jpeg               ${wxUSE_LIBJPEG-none}"
 echo "                                       png                ${wxUSE_LIBPNG-none}"
 echo "                                       regex              ${wxUSE_REGEX}"
@@ -7981,7 +8462,6 @@ if test "$wxUSE_X11" = 1 -o "$wxUSE_MOTIF" = 1; then
 echo "                                       xpm                ${wxUSE_LIBXPM-none}"
 fi
 echo "                                       zlib               ${wxUSE_ZLIB}"
-echo "                                       odbc               ${wxUSE_ODBC}"
 echo "                                       expat              ${wxUSE_EXPAT}"
 echo "                                       libmspack          ${wxUSE_LIBMSPACK}"
 echo "                                       sdl                ${wxUSE_LIBSDL}"