--- a/cmulocal/berkdb.m4
+++ b/cmulocal/berkdb.m4
@@ -213,30 +213,14 @@ AC_DEFUN([CYRUS_BERKELEY_DB_CHK_LIB],
 	fi
 
 	saved_LIBS=$LIBS
-	    for dbname in ${with_bdb} \
-	        db-4.8 db4.8 db48 \
-	        db-4.7 db4.7 db47 \
-	        db-4.6 db4.6 db46 \
-	        db-4.5 db4.5 db45 \
-	        db-4.4 db4.4 db44 \
-	        db-4.3 db4.3 db43 \
-	        db-4.2 db4.2 db42 \
-	        db-4.1 db4.1 db41 \
-	        db-4.0 db4.0 db40 db-4 db4 \
-	        db-3.3 db3.3 db33 \
-	        db-3.2 db3.2 db32 \
-	        db-3.1 db3.1 db31 \
-	        db-3.0 db3.0 db30 db-3 db3 \
-	        db
-	      do
-	    LIBS="$saved_LIBS -l$dbname"
-	    AC_TRY_LINK([#include <stdio.h>
+
+	LIBS="$saved_LIBS -ldb"
+	AC_TRY_LINK([#include <stdio.h>
 #include <db.h>],
-	    [db_create(NULL, NULL, 0);],
-	    BDB_LIBADD="$BDB_LIBADD -l$dbname"; dblib="berkeley"; dbname=db,
-            dblib="no")
-	    if test "$dblib" = "berkeley"; then break; fi
-          done
+	[db_create(NULL, NULL, 0);],
+	BDB_LIBADD="$BDB_LIBADD -ldb"; dblib="berkeley"; dbname=db,
+        dblib="no")
+
         if test "$dblib" = "no"; then
 	    LIBS="$saved_LIBS -ldb"
 	    AC_TRY_LINK([#include <stdio.h>
