The proposed solution is to use C_INCLUDE_PATH to prepend the include locations with real xorg-x11 include location (/usr/$(get_libdir)/opengl/xorg-x11/include) as it doesn't require patching the sourcecode and shouldn't cause problems with cross-compiling (like pkg-config hacking would). Additionally, it is required for the include location to contain a 'GL' subdirectory. The second attached patch makes 'x11-proto/glproto' create a symlink for that directory to 'exist'. However, I think the best solution would be to install files onto that subdirectory and make eselect-opengl aware of that.
Created attachment 227813 [details, diff] The xorg-server patch
Created attachment 227815 [details, diff] The glproto patch
The new versions of related ebuilds can be found on: http://git.mgorny.alt.pl/x11/ (which is a clone of the x11 overlay). I've made the following changes: 1) added eselect-opengl with patch to support installing headers inside 'GL' subdirectory, 2) modified and revbumped glproto and mesa to install their headers inside the 'GL' subdirectory, 3) modified mesa and xorg-server to use the OpenGL headers from /usr/$(get_libdir)/opengl instead of relying on eselect-opengl to provide xorg-x11 implementation.
Ok, I've managed to "fix" xorg-server to do all the work on its own without requiring modifications anywhere else. I'm pretty sure this could be further improved, but this is at least a good first step. If anyone wants to do this with a fake .pc file instead, be my guest :) Like Michał, I've managed to build this with /usr/include/GL files hacked to contain #error (meaning they are effectively ignored, otherwise the build would fail). Bottom line, the currenly selected opengl implementation with eselect-opengl no longer matters. With this done, eselect-opengl should be cleaned up to what it used to do. No other patches are needed. Many thanks to Michał for doing most of the work I've committed :) Cheers