Index: aclocal.m4 --- aclocal.m4.orig +++ aclocal.m4 @@ -1,4 +1,3 @@ -builtin(include,pthread.m4) builtin(include,platform.m4) builtin(include,framework.m4) @@ -22,7 +21,7 @@ builtin(include,framework.m4) # Result is cached. # # Defines one of the following preprocessor macros: -# APPLE_RUNTIME GNU_RUNTIME +# APPLE_RUNTIME GNU_RUNTIME MODERN_RUNTIME # # Substitutes the following variables: # OBJC_RUNTIME OBJC_RUNTIME_FLAGS OBJC_LIBS @@ -30,7 +29,7 @@ builtin(include,framework.m4) #------------------------------------------------------------------------ AC_DEFUN([OD_OBJC_RUNTIME],[ AC_REQUIRE([AC_PROG_OBJC]) - AC_ARG_WITH(objc-runtime, AC_HELP_STRING([--with-objc-runtime], [Specify either "GNU" or "apple"]), [with_objc_runtime=${withval}]) + AC_ARG_WITH(objc-runtime, AC_HELP_STRING([--with-objc-runtime], [Specify either "GNU", "apple", or "modern"]), [with_objc_runtime=${withval}]) if test x"${with_objc_runtime}" != x; then case "${with_objc_runtime}" in @@ -38,8 +37,10 @@ AC_DEFUN([OD_OBJC_RUNTIME],[ ;; apple) ;; + modern) + ;; *) - AC_MSG_ERROR([${with_objc_runtime} is not a valid argument to --with-objc-runtime. Please specify either "GNU" or "apple"]) + AC_MSG_ERROR([${with_objc_runtime} is not a valid argument to --with-objc-runtime. Please specify either "GNU", "apple", or "modern"]) ;; esac fi @@ -58,7 +59,7 @@ AC_DEFUN([OD_OBJC_RUNTIME],[ # Add -lobjc and -fobjc-exceptions. The following tests will ensure that the library exists and # functions with the detected Objective C compiler OBJCFLAGS="${OBJCFLAGS} -fobjc-exceptions" - LIBS="${LIBS} -lobjc -fobjc-exceptions" + LIBS="${LIBS} -lobjc2 -fobjc-exceptions" # Test if pthreads are required to link against # libobjc - this is the case on FreeBSD. @@ -113,11 +114,11 @@ AC_DEFUN([OD_OBJC_RUNTIME],[ AC_MSG_RESULT(${od_cv_objc_req_pthread}) if test x"${od_cv_objc_req_pthread}" = x"no"; then - OBJC_LIBS="${OBJC_LIBS} -lobjc" + OBJC_LIBS="${OBJC_LIBS} -lobjc2" OBJC_PTHREAD_LIBS="${PTHREAD_LIBS} -fobjc-exceptions" OBJC_PTHREAD_CFLAGS="${PTHREAD_CFLAGS} -fobjc-exceptions" elif test x"${od_cv_objc_req_pthread}" = x"yes"; then - OBJC_LIBS="${OBJC_LIBS} -lobjc ${PTHREAD_LIBS} -fobjc-exceptions" + OBJC_LIBS="${OBJC_LIBS} -lobjc2 ${PTHREAD_LIBS} -fobjc-exceptions" OBJCFLAGS="${OBJCFLAGS} ${PTHREAD_CFLAGS} -fobjc-exceptions" fi @@ -184,15 +185,51 @@ AC_DEFUN([OD_OBJC_RUNTIME],[ od_cv_objc_runtime_gnu="no" fi + if test x"${with_objc_runtime}" = x || test x"${with_objc_runtime}" = x"modern"; then + AC_MSG_CHECKING([for Modern Objective C runtime]) + AC_CACHE_VAL(od_cv_objc_runtime_modern, [ + # The following uses quadrigraphs + # '@<:@' = '[' + # '@:>@' = ']' + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ + #include + #include + ], [ + id class = objc_lookUpClass("NSObject"); + id obj = @<:@class alloc@:>@; + puts(@<:@obj name@:>@); + ]) + ], [ + od_cv_objc_runtime_modern="yes" + ], [ + od_cv_objc_runtime_modern="no" + ] + ) + ]) + AC_MSG_RESULT(${od_cv_objc_runtime_modern}) + else + od_cv_objc_runtime_modern="no" + fi + # Apple runtime is prefered - if test x"${od_cv_objc_runtime_apple}" = x"yes"; then - OBJC_RUNTIME="APPLE_RUNTIME" - AC_MSG_NOTICE([Using Apple Objective-C runtime]) - AC_DEFINE([APPLE_RUNTIME], 1, [Define if using the Apple Objective-C runtime and compiler.]) - elif test x"${od_cv_objc_runtime_gnu}" = x"yes"; then - OBJC_RUNTIME="GNU_RUNTIME" - AC_MSG_NOTICE([Using GNU Objective-C runtime]) - AC_DEFINE([GNU_RUNTIME], 1, [Define if using the GNU Objective-C runtime and compiler.]) + if test x"${od_cv_objc_runtime_modern}" = x"yes"; then + OBJC_RUNTIME="MODERN_RUNTIME" + case "${target_os}" in + darwin*) OBJC_RUNTIME_FLAGS="-fnext-runtime" + LDFLAGS="-framework Foundation ${LDFLAGS}";; + *) AC_CHECK_PROG([have_gs_config], + [gnustep-config], [yes]) + if test x"$have_gs_config" != x"yes"; then + AC_MSG_ERROR([Cannot find gnustep-config.]) + else + OBJC_RUNTIME_FLAGS="`gnustep-config --objc-flags`" + OBJC_LIBS="`gnustep-config --base-libs`" + fi + ;; + esac + AC_MSG_NOTICE([Using Modern Objective-C runtime]) + AC_DEFINE([MODERN_RUNTIME], 1, [Define if using the Modern Objective-C runtime and compiler.]) else AC_MSG_FAILURE([Could not locate a working Objective-C runtime.]) fi