diff --git a/aconfigure b/aconfigure
index d6f0e8809..9dcd46398 100755
--- a/aconfigure
+++ b/aconfigure
@@ -9768,7 +9768,11 @@
         if test "x$with_ssl" != "xno" -a "x$with_ssl" != "x"; then
             CFLAGS="$CFLAGS -I$with_ssl/include"
             CPPFLAGS="$CPPFLAGS -I$with_ssl/include"
-            LDFLAGS="$LDFLAGS -L$with_ssl/lib"
+            if test -d $with_ssl/lib; then
+                LDFLAGS="$LDFLAGS -L$with_ssl/lib"
+            else
+                LDFLAGS="$LDFLAGS -L$with_ssl"
+            fi
             { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Using SSL prefix... $with_ssl" >&5
 printf "%s\n" "Using SSL prefix... $with_ssl" >&6; }
         fi
diff --git a/aconfigure.ac b/aconfigure.ac
index 16b311045..849da81ab 100644
--- a/aconfigure.ac
+++ b/aconfigure.ac
@@ -2172,7 +2172,11 @@
         if test "x$with_ssl" != "xno" -a "x$with_ssl" != "x"; then
             CFLAGS="$CFLAGS -I$with_ssl/include"
             CPPFLAGS="$CPPFLAGS -I$with_ssl/include"
-            LDFLAGS="$LDFLAGS -L$with_ssl/lib"
+            if test -d $with_ssl/lib; then
+                LDFLAGS="$LDFLAGS -L$with_ssl/lib"
+            else
+                LDFLAGS="$LDFLAGS -L$with_ssl"
+            fi
             AC_MSG_RESULT([Using SSL prefix... $with_ssl])
         fi
 
