Index: /pjproject/trunk/aconfigure
===================================================================
--- /pjproject/trunk/aconfigure	(revision 5958)
+++ /pjproject/trunk/aconfigure	(revision 5959)
@@ -821,4 +821,5 @@
 with_ssl
 with_gnutls
+enable_darwin_ssl
 enable_ssl
 with_opencore_amrnb
@@ -1489,4 +1490,5 @@
                           IPPSAMPLES env var or with --with-ipp and
                           --with-ipp-samples options
+  --disable-darwin-ssl    Exclude Darwin SSL (default: autodetect)
   --disable-ssl           Exclude SSL support the build (default: autodetect)
 
@@ -1543,10 +1545,5 @@
   --with-ipp-arch=ARCH    Specify the Intel IPP ARCH suffix, e.g. "64" or
                           "em64t. Default is blank for IA32"
-  --with-ssl=SSL_BACKEND/DIR
-                          Specify alternate SSL library prefix or SSL
-                          native-backend. You can specify "darwin" as the
-                          native iOS/MacOS backend using Security framework,
-                          or you can specify an alternate SSL library prefix
-                          directory. If a directory is specified, this option
+  --with-ssl=DIR          Specify alternate SSL library prefix. This option
                           will try to find OpenSSL first, then if not found,
                           GnuTLS. To skip OpenSSL finding, use --with-gnutls
@@ -7946,4 +7943,52 @@
 
 
+
+# Check whether --enable-darwin-ssl was given.
+if test "${enable_darwin_ssl+set}" = set; then :
+  enableval=$enable_darwin_ssl; if test "$enable_darwin_ssl" = "no"; then
+		 { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if Darwin SSL support is disabled... yes" >&5
+$as_echo "Checking if Darwin SSL support is disabled... yes" >&6; }
+	        fi
+else
+
+		case $target in
+	  	*darwin*)
+	            SAVED_LIBS="$LIBS"
+	            LIBS="-framework Security"
+	            cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_ssl_backend=darwin
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+		    LIBS="$SAVED_LIBS"
+	            if test "x$ac_ssl_backend" = "xdarwin"; then
+		        $as_echo "#define PJ_HAS_SSL_SOCK 1" >>confdefs.h
+
+		        $as_echo "#define PJ_SSL_SOCK_IMP PJ_SSL_SOCK_IMP_DARWIN" >>confdefs.h
+
+		        LIBS="$LIBS -framework Security"
+	  	        { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if Security framework for Darwin SSL is available... yes" >&5
+$as_echo "Checking if Security framework for Darwin SSL is available... yes" >&6; }
+	            else
+	                { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if Security framework for Darwin SSL is available... no" >&5
+$as_echo "Checking if Security framework for Darwin SSL is available... no" >&6; }
+		    fi
+		    ;;
+		esac
+
+fi
+
+
 # Check whether --enable-ssl was given.
 if test "${enable_ssl+set}" = set; then :
@@ -7957,40 +8002,5 @@
 else
 
-	        if test "x$with_ssl" = "xdarwin"; then
-	            SAVED_LIBS="$LIBS"
-	            LIBS="-framework Security"
-	            cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_ssl_backend=darwin
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-		    LIBS="$SAVED_LIBS"
-	            if test "x$ac_ssl_backend" = "xdarwin"; then
-		        $as_echo "#define PJ_HAS_SSL_SOCK 1" >>confdefs.h
-
-		        $as_echo "#define PJ_SSL_SOCK_IMP PJ_SSL_SOCK_IMP_DARWIN" >>confdefs.h
-
-		        LIBS="$LIBS -framework Security"
-		        ac_ssl_backend="darwin"
-	  	        { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if Security framework for Darwin SSL is available... yes" >&5
-$as_echo "Checking if Security framework for Darwin SSL is available... yes" >&6; }
-	            else
-	                { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if Security framework for Darwin SSL is available... no" >&5
-$as_echo "Checking if Security framework for Darwin SSL is available... no" >&6; }
-		    fi
-		fi
-
-	        if test "x$ac_ssl_backend" = "x" -a "x$with_ssl" != "xno" -a "x$with_ssl" != "x"; then
+	        if test "x$with_ssl" != "xno" -a "x$with_ssl" != "x"; then
                     CFLAGS="$CFLAGS -I$with_ssl/include"
                     CPPFLAGS="$CPPFLAGS -I$with_ssl/include"
@@ -8000,6 +8010,7 @@
                 fi
 
-	        if test "x$ac_ssl_backend" = "x" -a "x$with_gnutls" = "xno"; then
-
+	        if test "x$with_gnutls" = "xno"; then
+		    # We still need to check for OpenSSL installations even if
+		    # we find Darwin SSL above since DTLS requires OpenSSL.
 		    { $as_echo "$as_me:${as_lineno-$LINENO}: result: checking for OpenSSL installations.." >&5
 $as_echo "checking for OpenSSL installations.." >&6; }
@@ -8165,11 +8176,13 @@
 			fi
 
-			# PJSIP_HAS_TLS_TRANSPORT setting follows PJ_HAS_SSL_SOCK
-			#AC_DEFINE(PJSIP_HAS_TLS_TRANSPORT, 1)
-			$as_echo "#define PJ_HAS_SSL_SOCK 1" >>confdefs.h
-
-			$as_echo "#define PJ_SSL_SOCK_IMP PJ_SSL_SOCK_IMP_OPENSSL" >>confdefs.h
-
-			ac_ssl_backend="openssl"
+    		        if test "x$ac_ssl_backend" = "x"; then
+			    # PJSIP_HAS_TLS_TRANSPORT setting follows PJ_HAS_SSL_SOCK
+			    #AC_DEFINE(PJSIP_HAS_TLS_TRANSPORT, 1)
+			    $as_echo "#define PJ_HAS_SSL_SOCK 1" >>confdefs.h
+
+			    $as_echo "#define PJ_SSL_SOCK_IMP PJ_SSL_SOCK_IMP_OPENSSL" >>confdefs.h
+
+			    ac_ssl_backend="openssl"
+			fi
 		    else
 			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ** OpenSSL libraries not found **" >&5
Index: /pjproject/trunk/aconfigure.ac
===================================================================
--- /pjproject/trunk/aconfigure.ac	(revision 5958)
+++ /pjproject/trunk/aconfigure.ac	(revision 5959)
@@ -1542,12 +1542,8 @@
 dnl # SSL alt prefix
 AC_ARG_WITH(ssl,
-    AS_HELP_STRING([--with-ssl=SSL_BACKEND/DIR],
-		   [Specify alternate SSL library prefix or SSL native-backend.
-		    You can specify "darwin" as the native iOS/MacOS backend
-		    using Security framework, or you can specify an alternate
-		    SSL library prefix directory. If a directory
-		    is specified, this option will try to find OpenSSL first,
-		    then if not found, GnuTLS. To skip OpenSSL finding, use
-		    --with-gnutls option instead.]),
+    AS_HELP_STRING([--with-ssl=DIR],
+                   [Specify alternate SSL library prefix. This option will try
+                    to find OpenSSL first, then if not found, GnuTLS. To skip
+                    OpenSSL finding, use --with-gnutls option instead.]),
     [],
     [with_ssl=no]
@@ -1571,16 +1567,14 @@
 AC_SUBST(ac_ssl_has_aes_gcm,0)
 AC_SUBST(ac_ssl_backend)
-AC_ARG_ENABLE(ssl,
-	      AS_HELP_STRING([--disable-ssl],
-			     [Exclude SSL support the build (default: autodetect)])
-	      ,
-	      [
-		if test "$enable_ssl" = "no"; then
-		 [ac_no_ssl=1]
-		 AC_MSG_RESULT([Checking if SSL support is disabled... yes])
-	        fi
-	      ],
-	      [
-	        if test "x$with_ssl" = "xdarwin"; then
+
+AC_ARG_ENABLE(darwin-ssl,
+	      AS_HELP_STRING([--disable-darwin-ssl],
+			     [Exclude Darwin SSL (default: autodetect)]),
+	      [if test "$enable_darwin_ssl" = "no"; then
+		 AC_MSG_RESULT([Checking if Darwin SSL support is disabled... yes])
+	        fi],
+	      [
+		case $target in
+	  	*darwin*)
 	            SAVED_LIBS="$LIBS"
 	            LIBS="-framework Security"
@@ -1592,12 +1586,24 @@
 		        AC_DEFINE(PJ_SSL_SOCK_IMP, PJ_SSL_SOCK_IMP_DARWIN)
 		        LIBS="$LIBS -framework Security"
-		        ac_ssl_backend="darwin"
 	  	        AC_MSG_RESULT([Checking if Security framework for Darwin SSL is available... yes])
 	            else
 	                AC_MSG_RESULT([Checking if Security framework for Darwin SSL is available... no])
 		    fi
-		fi
-	        
-	        if test "x$ac_ssl_backend" = "x" -a "x$with_ssl" != "xno" -a "x$with_ssl" != "x"; then
+		    ;;
+		esac
+	      ])
+
+AC_ARG_ENABLE(ssl,
+	      AS_HELP_STRING([--disable-ssl],
+			     [Exclude SSL support the build (default: autodetect)])
+	      ,
+	      [
+		if test "$enable_ssl" = "no"; then
+		 [ac_no_ssl=1]
+		 AC_MSG_RESULT([Checking if SSL support is disabled... yes])
+	        fi
+	      ],
+	      [
+	        if test "x$with_ssl" != "xno" -a "x$with_ssl" != "x"; then
                     CFLAGS="$CFLAGS -I$with_ssl/include"
                     CPPFLAGS="$CPPFLAGS -I$with_ssl/include"
@@ -1606,6 +1612,7 @@
                 fi
 
-	        if test "x$ac_ssl_backend" = "x" -a "x$with_gnutls" = "xno"; then
-
+	        if test "x$with_gnutls" = "xno"; then
+		    # We still need to check for OpenSSL installations even if
+		    # we find Darwin SSL above since DTLS requires OpenSSL.
 		    AC_MSG_RESULT([checking for OpenSSL installations..])
 		    AC_SUBST(openssl_h_present)
@@ -1633,9 +1640,11 @@
 			fi
 
-			# PJSIP_HAS_TLS_TRANSPORT setting follows PJ_HAS_SSL_SOCK
-			#AC_DEFINE(PJSIP_HAS_TLS_TRANSPORT, 1)
-			AC_DEFINE(PJ_HAS_SSL_SOCK, 1)
-			AC_DEFINE(PJ_SSL_SOCK_IMP, PJ_SSL_SOCK_IMP_OPENSSL)
-			ac_ssl_backend="openssl"
+    		        if test "x$ac_ssl_backend" = "x"; then
+			    # PJSIP_HAS_TLS_TRANSPORT setting follows PJ_HAS_SSL_SOCK
+			    #AC_DEFINE(PJSIP_HAS_TLS_TRANSPORT, 1)
+			    AC_DEFINE(PJ_HAS_SSL_SOCK, 1)
+			    AC_DEFINE(PJ_SSL_SOCK_IMP, PJ_SSL_SOCK_IMP_OPENSSL)
+			    ac_ssl_backend="openssl"
+			fi
 		    else
 			AC_MSG_RESULT([** OpenSSL libraries not found **])
