diff --git a/configure.ac b/configure.ac
index bacea8a..691a9fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -77,6 +77,14 @@ AC_MSG_CHECKING([X protocol headers directory])
 protodir=$(pkg-config --variable=includex11dir xproto)
 AC_MSG_RESULT([$protodir])
 
+AC_MSG_CHECKING([X extension protocol headers directory])
+extprotodir=$(pkg-config --variable=includedir xextproto)
+AC_MSG_RESULT([$extprotodir])
+
+AC_MSG_CHECKING([XvMC headers directory])
+xvmcdir=$(pkg-config --variable=includedir xvmc)
+AC_MSG_RESULT([$extprotodir])
+
 # Checks for libraries.
 
 # Checks for header files.
@@ -139,7 +147,7 @@ if test "x$have_xvmc" != xno; then
 		      [have_xvmc_h="yes"], [have_xvmc_h="no"])
 	AC_CHECK_FILE([${protodir}/extensions/vldXvMC.h],
 		      [have_vldxvmc_h="yes"], [have_vldxvmc_h="no"])
-	AC_CHECK_FILE([${protodir}/extensions/XvMClib.h],
+	AC_CHECK_FILE([${xvmcdir}/X11/extensions/XvMClib.h],
 		      [have_xvmclib_h="yes"], [have_xvmclib_h="no"])
 fi
 
@@ -225,7 +233,7 @@ fi
 CFLAGS="$SAVED_CFLAGS"
 
 # in the xserver 1.7 timeframe, the protocol headers were split up.
-AC_CHECK_FILE([${protodir}/extensions/dpmsconst.h],
+AC_CHECK_FILE([${extprotodir}/X11/extensions/dpmsconst.h],
 	      [have_dpmsconst_h="yes"], [have_dpmsconst_h="no"])
 if test "x$have_dpmsconst_h" = xyes; then
 	AC_DEFINE(HAVE_DPMSCONST_H, 1, [Proto Headers have dpmsconst.h])
