e55890
diff --git a/contrib/dlz/config.dlz.in b/contrib/dlz/config.dlz.in
e55890
index 47525af..eefe3c3 100644
e55890
--- a/contrib/dlz/config.dlz.in
e55890
+++ b/contrib/dlz/config.dlz.in
e55890
@@ -17,6 +17,13 @@
e55890
 #
e55890
 dlzdir='${DLZ_DRIVER_DIR}'
e55890
 
e55890
+AC_MSG_CHECKING([for target libdir])
e55890
+AC_RUN_IFELSE([int main(void) {exit((sizeof(void *) == 8) ? 0 : 1);}],
e55890
+	[target_lib=lib64],
e55890
+	[target_lib=lib],
e55890
+)
e55890
+AC_MSG_RESULT(["$target_lib"])
e55890
+
e55890
 #
e55890
 # Private autoconf macro to simplify configuring drivers:
e55890
 #
e55890
@@ -292,9 +299,9 @@ case "$use_dlz_bdb" in
e55890
 					then
e55890
 						break
e55890
 					fi
e55890
-				elif test -f "$dd/lib/lib${d}.so"
e55890
+				elif test -f "$dd/${target_lib}/lib${d}.so"
e55890
 				then
e55890
-					dlz_bdb_libs="-L${dd}/lib -l${d}"
e55890
+					dlz_bdb_libs="-L${dd}/${target_lib} -l${d}"
e55890
 					break
e55890
 				fi
e55890
 			done
e55890
@@ -396,7 +403,7 @@ case "$use_dlz_ldap" in
e55890
 	*)
e55890
 		DLZ_ADD_DRIVER(LDAP, dlz_ldap_driver,
e55890
 				[-I$use_dlz_ldap/include],
e55890
-				[-L$use_dlz_ldap/lib -lldap -llber])
e55890
+				[-L$use_dlz_ldap/${target_lib} -lldap -llber])
e55890
 
e55890
 		AC_MSG_RESULT(
e55890
 [using LDAP from $use_dlz_ldap/lib and $use_dlz_ldap/include])
e55890
@@ -432,11 +439,11 @@ then
e55890
 		odbcdirs="/usr /usr/local /usr/pkg"
e55890
 		for d in $odbcdirs
e55890
 		do
e55890
-			if test -f $d/include/sql.h -a -f $d/lib/libodbc.a
e55890
+			if test -f $d/include/sql.h -a -f $d/${target_lib}/libodbc.a
e55890
 			then
e55890
 				use_dlz_odbc=$d
e55890
 				dlz_odbc_include="-I$use_dlz_odbc/include"
e55890
-				dlz_odbc_libs="-L$use_dlz_odbc/lib -lodbc"
e55890
+				dlz_odbc_libs="-L$use_dlz_odbc/${target_lib} -lodbc"
e55890
 				break
e55890
 			fi
e55890
 		done