Compiling the XFree86/DRI tree

DRI Compilation Guide : Compiling the XFree86/DRI tree
Previous: Mesa
Next: Normal Installation and Configuration

## 8. Compiling the XFree86/DRI tree

### 8.1. Make a build tree

Rather than placing object files and library files right in the source tree, they're instead put into a parallel build tree. The build tree is made with the `lndir` command:

                cd ~/DRI-CVS
                ln -s xc XFree40
                mkdir build
                cd build
                lndir -silent -ignorelinks ../XFree40

The build tree will be populated with symbolic links which point back into the CVS source tree.

Advanced users may have several build trees for compiling and testing with different options.

### 8.2. Edit the host.def file

The `~/DRI-CVS/build/xc/config/cf/host.def` file is used to configure the XFree86 build process. You can change it to customize your build options or make adjustments for your particular system configuration

The default `host.def` file will look something like this:

                #define DefaultCCOptions -Wall
    (i386)      #define DefaultGcc2i386Opt -O2
    (Alpha)     #define DefaultGcc2AxpOpt -O2 -mcpu=ev6 (or similar)
                #define LibraryCDebugFlags -O2
                #define BuildServersOnly YES
                #define XF86CardDrivers vga tdfx mga ati i810
                #define LinuxDistribution LinuxRedHat
                #define DefaultCCOptions -ansi GccWarningOptions -pipe
                #define BuildXF86DRI YES
                /* Optionally turn these on for debugging */
                /* #define GlxBuiltInTdfx YES */
                /* #define GlxBuiltInMga YES */
                /* #define GlxBuiltInR128 YES */
                /* #define GlxBuiltInRadeon YES */
                /* #define DoLoadableServer NO */
                #define SharedLibFont NO

The `ProjectRoot` variable specifies where the XFree86 files will be installed. We recommend installing the DRI files over your existing XFree86 installation - it's generally safe to do and less error-prone. This policy is different than what we used to recommend.

If XFree86 4.x is not installed in /usr/X11R6/ you'll have to add the following to the `host.def` file:

                #define ProjectRoot pathToYourXFree86installation

Note the XF86CardDrivers line to be sure your card's driver is listed.

If you want to enable 3DNow! optimizations in Mesa and the DRI drivers, you should add the following:

                #define MesaUse3DNow YES

You don't have to be using an AMD processor in order to enable this option. The DRI will look for 3DNow! support and runtime and only enable it if applicable.

If you want to enable SSE optimizations in Mesa and the DRI drivers, you must upgrade to a Linux 2.4.x kernel. Mesa will verify that SSE is supported by both your processor and your operating system, but to build Mesa inside the DRI you need to have the Linux 2.4.x kernel headers in /usr/src/linux. If you enable SSE optimizations with an earlier version of the Linux kernel in /usr/src/linux, Mesa will not compile. You have been warned. If you do have a 2.4.x kernel, you should add the following:

                #define MesaUseSSE YES

### 8.3. Compilation

To compile the complete DRI tree:

                cd ~/DRI-CVS/build/xc/
                make World >& world.log

Or if you want to watch the compilation progress:

                cd ~/DRI-CVS/build/xc/
                make World >& world.log &
                tail -f world.log

With the default compilation flags it's normal to get a lot of warnings during compilation.

Building will take some time so you may want to go check your email or visit slashdot.

WARNING: do not use the -j option with make. It's reported that it does not work with XFree86/DRI.

### 8.4. Check for compilation errors

Using your text editor, examine `world.log` for errors by searching for the pattern `***`.

Verify that the DRI kernel module(s) for your system were built:

              cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel
              ls

For the 3dfx Voodoo, you should see tdfx.o. For the Matrox G200/G400, you should see mga.o. For the ATI Rage 128, you should see r128.o. For the ATI Radeon, you should see radeon.o. For the Intel i810, you should see i810.o.

If the DRI kernel module(s) failed to build you should verify that you're using the right version of the Linux kernel. The most recent kernels are not always supported.

If your build machine is running a different version of the kernel than your target machine (i.e. 2.2.x vs. 2.4.x), make will select the wrong kernel headers. This can be fixed by explicitly setting the value of `TREE`. If the path to your kernel source is `/usr/src/linux-2.4.x`,

              cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel
              make TREE=/usr/src/linux-2.4.x/include

or alternatively, edit Makefile to include this change.

After fixing the errors, run `make World` again. Later, you might just compile parts of the source tree but it's important that the whole tree will build first.

### 8.5. DRI kernel module installation

The DRI kernel modules will be in `~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/`.

To load the appropriate DRM module in your running kernel you can either use ismod and restart your X server or copy the kernel module to `/lib/modules/2.4.x/kernel/drivers/char/drm/` then run depmod and restart your X server.

Make sure you first unload any older DRI kernel modules that might be already loaded.

Note that some DRM modules require that the `agpgart` module be loaded first.

DRI Compilation Guide : Compiling the XFree86/DRI tree
Previous: Mesa
Next: Normal Installation and Configuration