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