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