Just a semi-educated guess:
The symptoms suggest to me that Mesa is either not installed, or not fully installed (or broken), or is installed somewhere that it's header files aren't being found, or finally, that the version of Mesa you have installed does not contain the declarations required by the X build you're doing.
However, a quick google about this chunk of your error messages:
produces lots of things, including this mailing list thread:
which suggests that if the nvidia driver is installed, then the X build seems to look at the wrong header files. Have you got the nvidia driver installed? If so, maybe un-install it first, and try again, or run
for your X build, and see what options and/or environment variables you can tweak to point the build at the correct (Mesa) header files.