+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