Preparing and building XFree86

First, I recommand you check how many copies you have of libGL. Assuming that updatedb has been run recently, use the command:

locate | xargs ls -l

This will show you how many actual copies of libGL are installed; you can ignore the files which are logical links. You should have a copy in X11R6/lib, and if you have recently done a build of XFree86 you will probably have a larger, unstripped, copy in the XFree86 build tree. But you shouldn't need any other copies. If you do, you may need to remove them in order to get the DRI to work.

Install the DRI source:

rpm -Uvh XFree86-

Add the following lines to the spec file, which will probably be at /usr/src/redhat/SPECS/XFree86.spec. The spec file seems to have two practical purposes. Firstly, it controls rpmbuild. Secondly, it creates the host.def file which determines which parts of XFree86 are to be built for your system.

Firstly, the rpmbuild instructions:

At the top of the file you should set up variables to simplify the instructions for the kernel module install (change the _DRMmodule line to suit if you aren't using Rage128):

%define with_DRMmodule      1
%define _kernelRelease      %(uname -r)
%define _DRMbuildDir        xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel
%define _kernelDRMdir       /lib/modules/%{_kernelRelease}/kernel/drivers/char/drm
%define _DRMmodule          r128.o

Add the description of the new DRM package at the end of the %package section (just before the beginning of the %prep section):

%if %{with_DRMmodule}
%package DRMmodule
Summary: XFree86 DRM module for kernel
Group: User Interface/X

%description DRMmodule
The XFree86 DRM module provides the r128.o driver needed to load
ATI Rage128 support as a kernel module.  You will need to change
the spec file if you want a DRM module for a chip other than the

Add the install instructions at the end of the %install section (just before "DELETE UNWANTED FILES"). Note that the file is copied by the install from the build directory to the temporary build root location - rpmbuild will figure out for itself how to map that properly onto the final target location:

%if %{with_DRMmodule}
echo "Copying DRM kernel module"
mkdir -p $RPM_BUILD_ROOT%{_kernelDRMdir}
install -c -m 644 %{_DRMbuildDir}/%{_DRMmodule} $RPM_BUILD_ROOT%{_kernelDRMdir}

Add the following at the end of the %files section (just before %clean):

%if %{with_DRMmodule}
%files DRMmodule

Secondly, the instructions which rpmbuild will insert into host.def. To begin with, we have to force the module to build. I have included the following lines and it seems to do the trick. The reference to ati seems to be necessary to get r128 to build, so this is something else to change if you're not using Rage128. Some of these lines may already be in your spec file, so change them if they conflict.

#define BuildXF86DRI          YES
#define BuildXF86DRM          YES
#define XF86CardDrivers       ati

Look for the definition of ProjectRoot and change it, if appropriate, for your X11 installation:

#define ProjectRoot /usr/X11R6

If you have Katmai support you may need the following lines. I have both but I'm not certain that the second is necessary:

#define HasKatmaiSupport      YES
#define MesaUseKatmai         YES

Lastly, I commented out the reference to %{_x11libdir}/modules/*.uc, as it was generating RPMbuild errors.

Now, build and package up XFree86 with the command:

rpmbuild -bb /usr/src/redhat/SPECS/XFree86.spec

This will create a full set of XFree86 RPMs, probably in the directory /usr/src/redhat/RPMS/i386/. One of these will be XFree86-DRMmodule-[version].i386.rpm.

Install the XFree86 RPMs:

rpm -Uvh /usr/src/redhat/RPMS/i386/XFree86*

You may need to append --force to the end of the above command if you are installing this over an existing installation of the same version of XFree86.

You will need to kill your X server and run the command depmod -a, or reboot, before you restart X.