Index: pjproject/trunk/aconfigure
===================================================================
--- pjproject/trunk/aconfigure	(revision 5957)
+++ 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
