Index: aclocal.m4
===================================================================
--- aclocal.m4 (revision 1378)
+++ aclocal.m4 (working copy)
@@ -1,4 +1,3 @@
-builtin(include,objc.m4)
builtin(include,pthread.m4)
builtin(include,platform.m4)
builtin(include,check.m4)
@@ -23,7 +22,7 @@
# 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
@@ -31,7 +30,7 @@
#------------------------------------------------------------------------
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
@@ -39,8 +38,10 @@
;;
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
@@ -174,6 +175,33 @@
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 <objc/objc.h>
+ #include <objc/runtime.h>
+ ], [
+ 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"
@@ -185,6 +213,16 @@
OBJC_RUNTIME_FLAGS="-fgnu-runtime"
AC_MSG_NOTICE([Using GNU Objective-C runtime])
AC_DEFINE([GNU_RUNTIME], 1, [Define if using the GNU Objective-C runtime and compiler.])
+ elif test x"${od_cv_objc_runtime_modern}" = x"yes"; then
+ OBJC_RUNTIME="MODERN_RUNTIME"
+ case "${target_os}" in
+ linux*) OBJC_RUNTIME_FLAGS="-fgnu-runtime"
+ OBJC_LIBS="-lgnustep-base ${OBJC_LIBS}";;
+ darwin*) OBJC_RUNTIME_FLAGS="-fnext-runtime"
+ LDFLAGS="-framework Foundation ${LDFLAGS}";;
+ 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
Index: src/TRObject.h
===================================================================
--- src/TRObject.h (revision 1378)
+++ src/TRObject.h (working copy)
@@ -40,7 +40,11 @@
#endif
#include <stdbool.h>
+#ifdef MODERN_RUNTIME
+#include <Foundation/NSObject.h>
+#else
#include <objc/Object.h>
+#endif
#include "auth-ldap.h"
@@ -54,7 +58,11 @@
@end
+#ifdef MODERN_RUNTIME
+@interface TRObject : NSObject <TRObject> {
+#else
@interface TRObject : Object <TRObject> {
+#endif
unsigned int _refCount;
}
Index: src/TRObject.m
===================================================================
--- src/TRObject.m (revision 1378)
+++ src/TRObject.m (working copy)
@@ -53,9 +53,11 @@
* Additionally, we implement brain-dead, non-thread-safe
* reference counting.
*/
+#ifndef MODERN_RUNTIME
@interface Object (AppleAddedAReallyStupidGCCWarning)
- (void) dealloc;
@end
+#endif
@implementation TRObject
@@ -69,7 +71,11 @@
}
- (void) dealloc {
+#ifdef MODERN_RUNTIME
+ [super dealloc];
+#else
[super free];
+#endif
/* Make Apple's objc compiler be quiet */
if (false)
Index: src/auth-ldap.m
===================================================================
--- src/auth-ldap.m (revision 1378)
+++ src/auth-ldap.m (working copy)
@@ -48,6 +48,9 @@
#include <TRPacketFilter.h>
#include <TRPFAddress.h>
#include <TRLog.h>
+#ifdef MODERN_RUNTIME
+#include <Foundation/NSAutoreleasePool.h>
+#endif
/* Plugin Context */
typedef struct ldap_ctx {
@@ -267,7 +270,6 @@
}
#endif
-
*type = OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY) |
OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_CLIENT_CONNECT) |
OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_CLIENT_DISCONNECT);
@@ -550,6 +552,10 @@
TRLDAPEntry *ldapUser = nil;
int ret = OPENVPN_PLUGIN_FUNC_ERROR;
+#ifdef MODERN_RUNTIME
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+#endif
+
username = get_env("username", envp);
password = get_env("password", envp);
remoteAddress = get_env("ifconfig_pool_remote_ip", envp);
@@ -613,5 +619,8 @@
[ldapUser release];
if (ldap)
[ldap release];
+#ifdef MODERN_RUNTIME
+ [pool drain];
+#endif
return (ret);
}
Index: tests/Makefile.in
===================================================================
--- tests/Makefile.in (revision 1378)
+++ tests/Makefile.in (working copy)
@@ -26,7 +26,7 @@
CFLAGS+= @CHECK_CFLAGS@ -DTEST_DATA=\"${srcdir}/data\"
OBJCFLAGS+= @CHECK_CFLAGS@ -DTEST_DATA=\"${srcdir}/data\"
LIBS+= -lauth-ldap-testing $(OBJC_LIBS) $(LDAP_LIBS) @CHECK_LIBS@
-LDFLAGS+= -L${top_builddir}src $(LIBS)
+LDFLAGS+= -L${top_builddir}/src $(LIBS)
# Recompile the tests every time
all: tests