Cross Compile Mesa 9.1.5 without X11

Recently I try to add opengl support for our embeded project, at least software emulated support. So I try to cross compile the mesa3d library. There are tons errors about X11 related stuffs missing, but we do not need the X11 support! After a long and difficult journey, I found the way to compile it without X11 and with framebuffer only.

You must enable the dri options, otherwise it will report:

/mesa/lib/libGLESv2.so: undefined reference to `_glapi_Dispatch' or something else.

Because the glapi will not compile without dri.

See references:

https://bugs.freedesktop.org/show_bug.cgi?id=61750

The compile commands:

export TOOLCHAIN_TARGET_SYSTEM=arm-none-linux-gnueabi
export  TOOLCHAIN_INSTALL_DIRECTORY=/opt/toolchain

./configure CPPFLAGS=-DMESA_EGL_NO_X11_HEADERS CFLAGS=-DMESA_EGL_NO_X11_HEADERS CC=$TOOLCHAIN_TARGET_SYSTEM-gcc CXX=$TOOLCHAIN_TARGET_SYSTEM-g++ --build=$TOOLCHAIN_BUILD_SYSTEM --target=$TOOLCHAIN_TARGET_SYSTEM --host=$TOOLCHAIN_TARGET_SYSTEM --prefix=$TOOLCHAIN_INSTALL_DIRECTORY --enable-opengl --enable-gles2 --enable-gles1 --disable-glx --enable-egl --enable-gallium-egl --enable-dri --with-dri-drivers=swrast --with-gallium-drivers=swrast --with-egl-platforms=fbdev --disable-xorg --disable-xa --disable-xlib-glx

Commands Explanation:

If without MESA_EGL_NO_X11_HEADERS defined, there will cause compile errors because without X11 headers, and we do not have any other better options to disable the X11 using, see "include/EGL/eglplatform.h". So we just defined the macro to avaid this suitation.

Comments !