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
                #define HasGlide3 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. You probably don't want to use `/usr/X11R6/` because that would overwrite your default X files. The following is recommended:

                #define ProjectRoot /usr/X11R6-DRI

Especially note the XF86CardDrivers line to be sure your driver is listed.

If you have 3dfx hardware be sure that the Glide 3x headers are installed in `/usr/include/glide3/` and that the Glide 3x library is installed at `/usr/lib/libglide3.so`.

If you do not have 3dfx hardware comment out the `HasGlide3` line in `host.def`.

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

                #define MesaUse3DNow YES

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 MesaUseKatmai 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 are 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