This page contains some outdated information. To get an up-to-date description of how to build the packages, please take a look at Building the X Window System.

Modular X development using the git trees

Since it's fairly common to do development that touches several layers of the graphics stack, this guide will cover building the whole thing, from the DRM up through the X server and drivers. We'll install the whole stack into a separate directory, just to keep things separated from the distribution packages we (presumably) want to keep working as we break things in our sandbox.

On a basic level, you'll need to build things in roughly this order:

kernel

Dependencies

DRM (both libdrm & the DRM modules for non-intel)

Mesa

X server

X drivers

An alternate method of building the packages in a more automated fashion using the jhbuild utility can be found in the JhBuildInstructions.

Everything described underneath is also available as a pre made script, located at the bottom of this page.

Minimum requirements

Basically, Linux 2.6.x, Free/Net/OpenBSD, OpenSolaris/Solaris 10, Hurd, OS X 10.5, and Cygwin systems should work fine on any architecture these are likely to run on. Compiler-wise, gcc 3.x, Intel icc, Sun Studio, and llvm-clang are generally known to work. See below if you're looking at a port:

So, here's the assumptions I've been working from:
The X server core and software DDXes should build and work on basically
all of the free BSDs (not counting Darwin), Solaris 10+ and OpenSolaris,
Linux, Hurd, and some versions of SCO, on any CPU architecture they
support. Kdrive's hardware servers - basically just Xfbdev at this
point - is Linux-only; the rest should work anywhere. The Xorg DDX
could probably be built for just about any architecture, but it doesn't
really make sense to do so in all cases; s390 doesn't have a PCI bus, so
it'd be a bit silly. But the bus support code is in some sense
optional, an arm port wouldn't necessarily need PCI support, etc. The
Xorg DDX does assume a vaguely ELF-like linking environment and a
libdl-like interface to it; this isn't a problem for any of the
currently supported ports, but anyone trying to port it to OSX, AIX, or
ancient HP/UX would probably have issues.
Obviously, the xwin and quartz DDXes are platform-specific.
The server's compiler needs to be C89 plus a few common C99 extensions.
Don't say "requires C99"; no compiler completely supports C99 yet, as
far as I'm aware. Yes, even gcc:
http://gcc.gnu.org/c99status.html
Most of the client libs and apps should work on pretty much any vaguely
modern unix; there's generally no compelling need to break them, and
indeed most of the apps should be left the hell alone because they're
not things we want to encourage people to use. xtrans is sort of a
special case because it's so deeply tied to the X server, it should be
considered as portable as the server is.
Non-server compiler pretty much just needs to be C89 or better.
- ajax

Kernel

As of linux 2.6.28, the canonical upstream for the Intel DRM (direct rendering manager) code is the linux kernel, and replaces the linux-core build below for other chipsets. There are plenty of instructions on building your own kernel out there, but the quick summary is:

Building Dependencies

Autoconf (part of the autotools system X uses for its build system) likely needs macros defined by X. These are included in the util/macros package:

macros - git://git.freedesktop.org/git/xorg/util/macros
Once you've installed the macros, you need to let the other packages use them:

export ACLOCAL="aclocal -I /opt/gfx-test/share/aclocal"
Mesa and the X server proper have several dependencies, and depending on your distribution you may need to update some of the libraries, headers, and prototypes it depends on before configuring the build. Common examples include:

Building Mesa

The Mesa package contains the GL stack and its associated chip specific drivers, which provide direct and indirect rendering acceleration. Note that to build some of the test programs there is a dependency on the development packages for GLUT. You'll have to ensure those development packages have been installed, or you can disable building the GLUT programs by adding_ --disable-glut_ to the autogen line below. You will still be able to build the common demo programs such as glxgears without GLUT, though.

git clone git://git.freedesktop.org/git/mesa/mesa

cd mesa

./autogen.sh --prefix=/opt/gfx-test --with-driver=dri --disable-glut

make

make install

mkdir -p /opt/gfx-test/bin

install -m755 progs/xdemos/{glxinfo,glxgears} /opt/gfx-test/bin/

Gallium build instructions

Gallium is an alternative architecture for hardware acceleration in mesa. It is currently a branch in the official mesa tree.

git clone git://git.freedesktop.org/git/mesa/mesa

cd mesa

git checkout origin/gallium-0.1

make with whatever target you want (the list of targets is in mesa/configs/, common targets are linux, linux-dri, linux-dri-x86 and linux-dri-x86-64)

Building the X Server

Here we build the X server with builtin fonts so we don't have to do too much configuration later. Note if you're building DMX or Xgl for example you need the --with-mesa-source option.