-->
Table of Contents |
This appendix covers a frequently asked question about X on Linux: Linux doesnt 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.
Well show you how to reconfigure your X server, extending it for these new needs. Well show you how to do this and well discuss memory and performance trade-offs. Well focus on the 3-D PEX extension, because its the most-requested X extension that XFree86 doesnt support by default on Linux. However, the principles described here can apply to any X extension not directly supported by default in Linux.
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 programmers library so that programs can use the extension. Some of these extensions, such as Shape, are so standard that its 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.
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, youll 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 doesnt support a lot of fun extensions, such as PEX.
Most of the time, youll install XFree86 (the implementation of X for Linux) in binary format (meaning that you wont 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, youll need to run the setup program again. One of the menu choices should cover the link kit.
If you dont 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 youd like to add. Youll also need the gcc C compiler (which comes with Linux if you choose to install it) and libgcc.a, gccs 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, youll 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, well 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 weve 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.
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 weve 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, youll likely want to change our settings.
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 youre 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 dont 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 youve set up the xf86site.def file, youre ready to starting building a new X server.
As the root user, you should perform the following steps to build your new X server:
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 youve built the new X servers, you must ensure that X is stopped. Its 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 workthats 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 youre 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.
PEX consumes a lot of system resources, so dont load this extension if youre 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 |