f2fb8b
diff --git a/contrib/dlz/config.dlz.in b/contrib/dlz/config.dlz.in
f2fb8b
index 9b1464c..d1fe16e 100644
f2fb8b
--- a/contrib/dlz/config.dlz.in
f2fb8b
+++ b/contrib/dlz/config.dlz.in
f2fb8b
@@ -135,38 +135,48 @@ AC_ARG_WITH(dlz_mysql,
f2fb8b
 			       (Required to use MySQL with DLZ)],
f2fb8b
     use_dlz_mysql="$withval", use_dlz_mysql="no")
f2fb8b
 
f2fb8b
+AC_CHECK_PROGS(MYSQL_CONFIG, mysql_config)
f2fb8b
+
f2fb8b
 mysql_include=""
f2fb8b
 mysql_lib=""
f2fb8b
 if test "$use_dlz_mysql" = "yes"
f2fb8b
 then
f2fb8b
-	# User did not specify a path - guess it
f2fb8b
-	mysqldirs="/usr /usr/local /usr/local/mysql /usr/pkg"
f2fb8b
-	for d in $mysqldirs
f2fb8b
-	do
f2fb8b
-		if test -f $d/include/mysql/mysql.h
f2fb8b
-		then
f2fb8b
-			use_dlz_mysql=$d
f2fb8b
-			mysql_include=$d/include/mysql
f2fb8b
-			if test -d $d/${target_lib}/mysql
f2fb8b
+	if test -n "$MYSQL_CONFIG"
f2fb8b
+	then
f2fb8b
+		mysql_include=`${MYSQL_CONFIG} --include`
f2fb8b
+		mysql_lib=`${MYSQL_CONFIG} --libs`
f2fb8b
+		use_dlz_mysql="config"
f2fb8b
+
f2fb8b
+	else
f2fb8b
+		# User did not specify a path - guess it
f2fb8b
+		mysqldirs="/usr /usr/local /usr/local/mysql /usr/pkg"
f2fb8b
+		for d in $mysqldirs
f2fb8b
+		do
f2fb8b
+			if test -f $d/include/mysql/mysql.h
f2fb8b
 			then
f2fb8b
-				mysql_lib=$d/${target_lib}/mysql
f2fb8b
-			else
f2fb8b
-				mysql_lib=$d/lib
f2fb8b
-			fi
f2fb8b
-			break
f2fb8b
-		elif test -f $d/include/mysql.h
f2fb8b
-		then
f2fb8b
-			use_dlz_mysql=$d
f2fb8b
-			mysql_include=$d/include
f2fb8b
-			if test -d $d/lib/mysql
f2fb8b
+				use_dlz_mysql=$d
f2fb8b
+				mysql_include=$d/include/mysql
f2fb8b
+				if test -d $d/${target_lib}/mysql
f2fb8b
+				then
f2fb8b
+					mysql_lib=$d/${target_lib}/mysql
f2fb8b
+				else
f2fb8b
+					mysql_lib=$d/lib
f2fb8b
+				fi
f2fb8b
+				break
f2fb8b
+			elif test -f $d/include/mysql.h
f2fb8b
 			then
f2fb8b
-				mysql_lib=$d/lib/mysql
f2fb8b
-			else
f2fb8b
-				mysql_lib=$d/lib
f2fb8b
+				use_dlz_mysql=$d
f2fb8b
+				mysql_include=$d/include
f2fb8b
+				if test -d $d/lib/mysql
f2fb8b
+				then
f2fb8b
+					mysql_lib=$d/lib/mysql
f2fb8b
+				else
f2fb8b
+					mysql_lib=$d/lib
f2fb8b
+				fi
f2fb8b
+				break
f2fb8b
 			fi
f2fb8b
-			break
f2fb8b
-		fi
f2fb8b
-	done
f2fb8b
+		done
f2fb8b
+	fi
f2fb8b
 elif test "$use_dlz_mysql" != "no"
f2fb8b
 then
f2fb8b
 	d=$use_dlz_mysql
f2fb8b
@@ -202,6 +212,14 @@ case "$use_dlz_mysql" in
f2fb8b
 	no)
f2fb8b
 		AC_MSG_RESULT(no)
f2fb8b
 		;;
f2fb8b
+	config)
f2fb8b
+		DLZ_ADD_DRIVER(MYSQL, dlz_mysql_driver,
f2fb8b
+				[${mysql_include}],
f2fb8b
+				[${mysql_lib}])
f2fb8b
+
f2fb8b
+		AC_MSG_RESULT(
f2fb8b
+[using mysql with libs ${mysql_lib} and includes ${mysql_include}])
f2fb8b
+		;;
f2fb8b
 	*)
f2fb8b
 		DLZ_ADD_DRIVER(MYSQL, dlz_mysql_driver,
f2fb8b
 				[-I${mysql_include}],