diff --git a/config/ac-macros/openssl.m4 b/config/ac-macros/openssl.m4
index aa46dd45360e6db821497bc2e8fce63ef9abfa40..1f9d53abe0180f730a06beae93b892901c268518 100644
--- a/config/ac-macros/openssl.m4
+++ b/config/ac-macros/openssl.m4
@@ -14,7 +14,8 @@ AC_DEFUN([MYSQL_FIND_OPENSSL], [
       for d in /usr/ssl/lib /usr/local/ssl/lib /usr/lib/openssl \
 /usr/lib /usr/lib64 /opt/ssl/lib /opt/openssl/lib \
 /usr/freeware/lib32 /usr/local/lib/ ; do
-      if test -f $d/libssl.a || test -f $d/libssl.so || test -f $d/libssl.dylib ; then
+      # Just to be safe, we test for ".so" anyway
+      if test -f $d/libssl.a || test -f $d/libssl.so || test -f $d/libssl$shrext_cmds ; then
         OPENSSL_LIB=$d
       fi
       done
@@ -26,7 +27,8 @@ AC_DEFUN([MYSQL_FIND_OPENSSL], [
       if test -f $incs/openssl/ssl.h  ; then
         OPENSSL_INCLUDE=-I$incs
       fi
-      if test -f $libs/libssl.a || test -f $libs/libssl.so || test -f $libs/libssl.dylib ; then
+      # Just to be safe, we test for ".so" anyway
+      if test -f $libs/libssl.a || test -f $libs/libssl.so || test -f $libs/libssl$shrext_cmds ; then
         OPENSSL_LIB=$libs
       fi
       ;;
diff --git a/config/ac-macros/zlib.m4 b/config/ac-macros/zlib.m4
index ec55f19b98f9c522d9a74ff0cc107d740b63b36a..8aafb3f4ced1bd88fc8940d103406145cb963f9d 100644
--- a/config/ac-macros/zlib.m4
+++ b/config/ac-macros/zlib.m4
@@ -89,8 +89,9 @@ case $SYSTEM_TYPE in
         fi
         ;;
       *)
+        # Just to be safe, we test for ".so" anyway
         if test \( -f "$mysql_zlib_dir/lib/libz.a"  -o -f "$mysql_zlib_dir/lib/libz.so" -o \
-                   -f "$mysql_zlib_dir/lib/libz.sl" -o -f "$mysql_zlib_dir/lib/libz.dylib" \) \
+                   -f "$mysql_zlib_dir/lib/libz$shrext_cmds" \) \
                 -a -f "$mysql_zlib_dir/include/zlib.h"; then
           ZLIB_INCLUDES="-I$mysql_zlib_dir/include"
           ZLIB_LIBS="-L$mysql_zlib_dir/lib -lz"