diff -up bind-9.9.0/contrib/dlz/config.dlz.in.64bit bind-9.9.0/contrib/dlz/config.dlz.in
--- bind-9.9.0/contrib/dlz/config.dlz.in.64bit	2011-11-05 06:14:28.000000000 +0100
+++ bind-9.9.0/contrib/dlz/config.dlz.in	2012-04-24 14:52:08.398511143 +0200
@@ -17,6 +17,13 @@
 #
 dlzdir='${DLZ_DRIVER_DIR}'
 
+AC_MSG_CHECKING([for target libdir])
+AC_RUN_IFELSE([int main(void) {exit((sizeof(void *) == 8) ? 0 : 1);}],
+	[target_lib=lib64],
+	[target_lib=lib],
+)
+AC_MSG_RESULT(["$target_lib"])
+
 #
 # Private autoconf macro to simplify configuring drivers:
 #
@@ -135,9 +142,9 @@ then
 		then
 			use_dlz_mysql=$d
 			mysql_include=$d/include/mysql
-			if test -d $d/lib/mysql
+			if test -d $d/${target_lib}/mysql
 			then
-				mysql_lib=$d/lib/mysql
+				mysql_lib=$d/${target_lib}/mysql
 			else
 				mysql_lib=$d/lib
 			fi
@@ -274,11 +281,11 @@ case "$use_dlz_bdb" in
 			bdb_libnames="db48 db-4.8 db47 db-4.7 db46 db-4.6 db45 db-4.5 db44 db-4.4 db43 db-4.3 db42 db-4.2 db41 db-4.1 db"
 			for d in $bdb_libnames
 			do
-				if test -f "$dd/lib/lib${d}.so"
+				if test -f "$dd/${target_lib}/lib${d}.so"
 				then
 					if test "$dd" != "/usr"
 					then
-						dlz_bdb_libs="-L${dd}/lib "
+						dlz_bdb_libs="-L${dd}/${target_lib} "
 					else
 						dlz_bdb_libs=""
 					fi
@@ -383,7 +390,7 @@ case "$use_dlz_ldap" in
 	*)
 		DLZ_ADD_DRIVER(LDAP, dlz_ldap_driver,
 				[-I$use_dlz_ldap/include],
-				[-L$use_dlz_ldap/lib -lldap -llber])
+				[-L$use_dlz_ldap/${target_lib} -lldap -llber])
 
 		AC_MSG_RESULT(
 [using LDAP from $use_dlz_ldap/lib and $use_dlz_ldap/include])
@@ -407,7 +414,7 @@ then
 	odbcdirs="/usr /usr/local /usr/pkg"
 	for d in $odbcdirs
 	do
-		if test -f $d/include/sql.h -a -f $d/lib/libodbc.a
+		if test -f $d/include/sql.h -a -f $d/${target_lib}/libodbc.a
 		then
 			use_dlz_odbc=$d
 			break
@@ -427,7 +434,7 @@ case "$use_dlz_odbc" in
 	*)
 		DLZ_ADD_DRIVER(ODBC, dlz_odbc_driver,
 				[-I$use_dlz_odbc/include],
-				[-L$use_dlz_odbc/lib -lodbc])
+				[-L$use_dlz_odbc/${target_lib} -lodbc])
 
 		AC_MSG_RESULT([using ODBC from $use_dlz_odbc])
 		;;
