Mesa has all of the configure machinery needed to compile and run without X, but gentoo does not currently expose that. I will attach an ebuild that adds an X use flag and makes dependencies conditional on it.
Created attachment 463190 [details] mesa-17.0.0_rc3.ebuild This ebuild adds a use flag USE="X", and sets dependencies and configure options as appropriate. Note that the bulk of the changes were made around 6 months ago. I have updated it to match changes to the gentoo ebuild since then, but if any relevant changes were made to mesa's configure since then I have missed them. It is tested to work on a system with no libX11 or the various other dependencies. It should not affect systems with X in any way (though I haven't actually installed on any).
Is this bug not a duplicate of bug 560096?
Yeah, it is. I've even commented on that bug previously. Whoops. *** This bug has been marked as a duplicate of bug 560096 ***