-->
Table of Contents


Appendix B
XFree86 and Extensions

This appendix covers a frequently asked question about X on Linux: Linux doesn’t support an X program that requires a specific X extension, so how do you get an X installation to run these programs? For example, XFree86 does not come configured to run three-dimensional graphics programs requiring the PEX extension.

We’ll show you how to reconfigure your X server, extending it for these new needs. We’ll show you how to do this and we’ll discuss memory and performance trade-offs. We’ll focus on the 3-D PEX extension, because it’s the most-requested X extension that XFree86 doesn’t support by default on Linux. However, the principles described here can apply to any X extension not directly supported by default in Linux.

What Is an X Extension?

An X extension is a piece of program code that extends the X server by adding some significant new functionality missing from the core X protocol, such as direct support for 3-D graphics.

Each extension needs to modify the X server and come with a programmer’s library so that programs can use the extension. Some of these extensions, such as Shape, are so standard that it’s hard to view them as add-ons. The Shape extension, for example, allows you to have round (and other odd-shaped) windows. The oclock program takes advantage of this, as we show in Figure B.1.


Figure B.1  Oclock using the Shape extension.

We list the most common X extensions in Table B.1.

Table B.1 Common Extensions to X

Extension Usage
LBX Low-bandwidth (serial-line) X, removed from X11R6.1
MIT-SCREEN-SAVER Allows you to create your own screen savers
MIT-SHM MIT shared-memory Ximage extension
Shape Nonrectangular windows
X3D-PEX PHIGS 3-D extension to X
XTestExtension1 Testing
XIE X Image Extension
XInputExtension Adds new input devices, like digitizing tablets
XVideo Video extension

To see what X extensions your system supports, run the xdpyinfo program from within an xterm window (you must be running X, of course). When you run xdpyinfo, you’ll see a lot of output describing your X server. Part of that output will include a list of extensions, probably something like the following:


     number of extensions:       10

       BIG-REQUESTS

       MIT-SCREEN-SAVER

       MIT-SHM

       MIT-SUNDRY-NONSTANDARD

       Multi-Buffering

       SHAPE

       SYNC

       XC-MISC

       XFree86-VidModeExtension

       XTEST

Our X server doesn’t support a lot of fun extensions, such as PEX.

What You Need to Extend X on Linux

Most of the time, you’ll install XFree86 (the implementation of X for Linux) in binary format (meaning that you won’t compile a special version designed for your unique needs). Because of this, you need a special package, called the X link kit, to extend the Linux X server. The link kit allows you to compile and link a new X server. The version of XFree86 that ships with this book contains the link kit; to install it, you’ll need to run the setup program again. One of the menu choices should cover the link kit.

If you don’t have this, you can get it over the Internet. Usually the file is called X312lkit.tgz or something like that.

The link kit allows you to rebuild the X server, adding something new: the X extension you’d like to add. You’ll also need the gcc C compiler (which comes with Linux if you choose to install it) and libgcc.a, gcc’s standard C library. You should have installed both when you installed Linux. To see which version of gcc you have, try entering the following command line:


        $ gcc -v

   Reading specs from /usr/lib/gcc-lib/i486-linux/2.7.2/specs

   gcc version 2.7.2

To really use PEX, you’ll need to load the PEX libraries, include files, and fonts at install time. The PEX fonts, in /usr/lib/X11/fonts/PEX, are required to run most PEX programs.

In the next section, we’ll show how to use the link kit to rebuild the X server for PEX, the X extension that supports three-dimensional graphics. These steps are basically the same for adding other X extensions, such as XIE, the massive imaging extension. We chose PEX because we’ve seen quite a lot of questions regarding this particular X extension. Three-dimensional graphics are becoming more and more popular. The basic techniques, though, apply to any X extension you need to add.


NOTE:  Once again, Linux can provide a nifty short cut here. Instead of rebuilding the X server, PEX support can be loaded from a module. The main page for XF86Config has more information about how to set this up.

Configuring the Server Build

Before you can build a new X server, you must edit a configuration file, xf86site.def, in the /usr/X11R6/lib/Server/config/cf directory. In this directory, edit the xf86site.def file (always make a backup first). In this file, you need to specify a number of things, including which X extensions to build (e.g., PEX), and which X server to build, such as SuperVGA, XF86_SVGA, or S3 XF86_S3.

In Table B.2, we list the settings we’ve used successfully. Note that we disable the creation of most of the X servers, because we only need the S3 and SVGA X servers. Because of this, you’ll likely want to change our settings.

Table B.2 Settings in the xf86site.def File

Setting Value Meaning
HasGcc YES Linux uses the gcc C compiler
HasGcc2 YES Linux uses gcc version 2.x
XF86SVGAServer YES Builds 256-color SVGA X server
XF86VGA16Server NO Builds 16-color VGA X server
XF86MonoServer NO Builds monochrome VGA X server
XF86S3Server YES Builds S3 X server
XF86Mach8Server NO Builds the Mach8 X server
XF86Mach32Server NO Builds the Mach32 X server
XF86Mach64Server NO Builds the Mach64 X server
XF86P9000Server NO Builds the P9000 X server
XF86AGXServer NO Builds the AGX X server
XF86W32Server NO Builds the ET4000/W32 X server
XF86I8514Server NO Builds the IBM 8514/A X server
XnestServer NO Builds the Xnest server
BuildPexExt YES Builds the PEX extension
BuildXIE NO Builds the XIE extension
BuildLBX NO Builds the Low Bandwidth X extension
BuildScreenSaverExt YES Builds screen saver extension


NOTE:  With any X release, these settings may change and there may be many new ones. Use Table B.2 as a guide, not as gospel. At this time, because you’re rebuilding the X server anyway, you may also want to build in one of the other X extensions, such as LBX or XIE.

Most of the servers are turned on automatically. You can turn off what you don’t want. For each X server, especially the SuperVGA ones, there is a list of drivers you can set. We always pick the defaults and leave the settings (XF86SvgaDrivers, XF86Vga16Drivers, XF86Vga2Drivers, and XF86MonoDrivers) alone.

If you build more than one X server, you need to uncomment the ServerToInstall line and put in the X server you want installed with the symbolic link from X. Otherwise, the XF86_SVGA gets set up as the default X server, X.

Comment out the XF86Contrib line to build all the contributed software.

Once you’ve set up the xf86site.def file, you’re ready to starting building a new X server.

Building a New X Server

As the root user, you should perform the following steps to build your new X server:

1.  Back up your current X server.
2.  Build all the Makefiles.
3.  Make the new X servers.
4.  Quit X.
5.  Install the new X servers.
6.  Ensure that /usr/X11R6/bin/X links to the proper X server.
7.  Start X to verify that the new X server works.
8.  Run xdpyinfo to see if the new X extensions are available.
9.  Clean the /usr/X11R6/lib/Server directory with make clean.

Before you start, always back up your current X server. This is to allow you to continue processing in case the new build fails. Then change back to the /usr/X11R6/lib/Server directory and build all the Makefiles by running the following command:


       $ ./mkmf

All these commands must be run in the /usr/X11R6/lib/Server directory as the root user. This process will take a while, as it runs makedepend on a number of files.

Once mkmf finishes successfully, run make:


       $ make

This builds the new X servers and will take even longer than the last step. Once you’ve built the new X servers, you must ensure that X is stopped. It’s very convenient to su to the root user in one xterm window and build the new X servers while you have all the other windows on your screen available for your work—that’s what multitasking is all about. When you need to install the new X server, however, you must ensure that X is stopped. So quit X in the usual way.

Then change back to the /usr/X11R6/lib/Server directory and run (again as root):


        $ make install

This will copy the new X servers to /usr/X11R6/bin and set up /usr/X11R6/bin/X as a link to the default X server (the one you configured for this earlier). Double-check this essential link anyway and ensure that /usr/X11R6/bin/X links to the proper X server (see Chapter 3 for more on this).

Now comes the fun part. Try to run X as a normal user (as yourself, not the root user), using startx. This step is to ensure that X still works (presuming X worked before you did all this).

If you get X up and running (it came right up for us, so if it compiled and linked with no problems, this step should be easy), then run xdpyinfo in an xterm window to see if the new X extensions are available. The list should look something like the following:


     number of extensions:    11

         BIG-REQUESTS

         LBX

         MIT-SCREEN-SAVER

         MIT-SHM

         MIT-SUNDRY-NONSTANDARD

         Multi-Buffering

         SHAPE

         SYNC

         X3D-PEX

         XC-MISC

         XFree86-VidModeExtension

         XTEST

(Yes, we cheated and built the LBX extension at the same time we built PEX.)

Once you’re confident that everything is built up properly, run make clean in the /usr/X11R6/lib/Server directory (again as root):


      $ make clean

This will get rid of all the .o files created when you built the X servers and free up a lot of wasted disk space.

As a final test, you may want to run one of the PEX demo programs that comes with X (you may not have loaded these programs, though), such as beach_ball.

Performance and Memory Issues

PEX consumes a lot of system resources, so don’t load this extension if you’re short on physical memory. When we built PEX and LBX into a new X server, it grew quite a lot, from 1,351,712 bytes to 1,509,550 bytes on disk.

Because of this, you may not want to compile in PEX or XIE, two of the largest X servers. If you have a low-memory system, then PEX or other large extensions like XIE (the X Image Extension) are simply not for you.


Table of Contents