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