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