⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 appendix-b.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Linux Configuration and Installation:Appendix B: XFree86 and Extensions</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=1558285660//-->

<!--TITLE=Linux Configuration and Installation//-->

<!--AUTHOR=Patrick Volkerding//-->

<!--AUTHOR=Kevin Reichard//-->

<!--AUTHOR=Eric Foster//-->

<!--PUBLISHER=IDG Books Worldwide, Inc.//-->

<!--IMPRINT=M & T Books//-->

<!--APPENDIX=B//-->

<!--PAGES=497-504//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="ewtoc.html">Table of Contents</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H2><A NAME="Heading1"></A><FONT COLOR="#000077">Appendix B<BR>XFree86 and Extensions

</FONT></H2>

<P>This appendix covers a frequently asked question about X on Linux: Linux doesn&#146;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.

</P>

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

<H3><A NAME="Heading2"></A><FONT COLOR="#000077">What Is an X Extension?</FONT></H3>

<P>An <I>X extension</I> 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.</P>

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

<P><A NAME="Fig1"></A><A HREF="javascript:displayWindow('images/apb-01.jpg',103,113 )"><IMG SRC="images/apb-01t.jpg"></A>

<BR><A HREF="javascript:displayWindow('images/apb-01.jpg',103,113)"><FONT COLOR="#000077"><B>Figure B.1</B></FONT></A>&nbsp;&nbsp;Oclock using the Shape extension.</P>

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

</P>

<TABLE WIDTH="100%"><CAPTION><B>Table B.1</B> Common Extensions to X

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TH WIDTH="35%" ALIGN="LEFT">Extension

<TH WIDTH="65%" ALIGN="LEFT">Usage

<TR>

<TD>LBX

<TD>Low-bandwidth (serial-line) X, removed from X11R6.1

<TR>

<TD>MIT-SCREEN-SAVER

<TD>Allows you to create your own screen savers

<TR>

<TD>MIT-SHM

<TD>MIT shared-memory Ximage extension

<TR>

<TD>Shape

<TD>Nonrectangular windows

<TR>

<TD>X3D-PEX

<TD>PHIGS 3-D extension to X

<TR>

<TD>XTestExtension1

<TD>Testing

<TR>

<TD>XIE

<TD>X Image Extension

<TR>

<TD>XInputExtension

<TD>Adds new input devices, like digitizing tablets

<TR>

<TD>XVideo

<TD>Video extension

<TR>

<TD COLSPAN="2"><HR>

</TABLE>

<P>To see what X extensions your system supports, run the <B>xdpyinfo</B> program from within an <B>xterm</B> window (you must be running X, of course). When you run <B>xdpyinfo</B>, you&#146;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:</P>

<!-- CODE //-->

<PRE>

     number of extensions:       10

       BIG-REQUESTS

       MIT-SCREEN-SAVER

       MIT-SHM

       MIT-SUNDRY-NONSTANDARD

       Multi-Buffering

       SHAPE

       SYNC

       XC-MISC

       XFree86-VidModeExtension

       XTEST

</PRE>

<!-- END CODE //-->

<P>Our X server doesn&#146;t support a lot of fun extensions, such as PEX.

</P>

<H4 ALIGN="LEFT"><A NAME="Heading3"></A><FONT COLOR="#000077">What You Need to Extend X on Linux</FONT></H4>

<P>Most of the time, you&#146;ll install XFree86 (the implementation of X for Linux) in binary format (meaning that you won&#146;t compile a special version designed for your unique needs). Because of this, you need a special package, called the <I>X link kit</I>, 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&#146;ll need to run the <B>setup</B> program again. One of the menu choices should cover the link kit.</P>

<P>If you don&#146;t have this, you can get it over the Internet. Usually the file is called <B>X312lkit.tgz</B> or something like that.</P>

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

<!-- CODE SNIP //-->

<PRE>

        $ gcc -v

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

   gcc version 2.7.2

</PRE>

<!-- END CODE SNIP //-->

<P>To really use PEX, you&#146;ll need to load the PEX libraries, include files, and fonts at install time. The PEX fonts, in <B>/usr/lib/X11/fonts/PEX</B>, are required to run most PEX programs.</P>

<P>In the next section, we&#146;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&#146;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.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>NOTE:&nbsp;&nbsp;</B>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.<HR></FONT>

</BLOCKQUOTE>

<H4 ALIGN="LEFT"><A NAME="Heading4"></A><FONT COLOR="#000077">Configuring the Server Build</FONT></H4>

<P>Before you can build a new X server, you must edit a configuration file, <B>xf86site.def</B>, in the <B>/usr/X11R6/lib/Server/config/cf</B> directory. In this directory, edit the <B>xf86site.def</B> 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.</P>

<P>In Table B.2, we list the settings we&#146;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&#146;ll likely want to change our settings.</P>

<TABLE WIDTH="100%"><CAPTION><B>Table B.2</B> Settings in the xf86site.def File

<TR>

<TH COLSPAN="3"><HR>

<TR>

<TH WIDTH="35%" ALIGN="LEFT">Setting

<TH WIDTH="20%" ALIGN="LEFT">Value

<TH WIDTH="45%" ALIGN="LEFT">Meaning

<TR>

<TD>HasGcc

<TD>YES

<TD>Linux uses the <B>gcc</B> C compiler

<TR>

<TD>HasGcc2

<TD>YES

<TD>Linux uses <B>gcc</B> version 2.x

<TR>

<TD>XF86SVGAServer

<TD>YES

<TD>Builds 256-color SVGA X server

<TR>

<TD>XF86VGA16Server

<TD>NO

<TD>Builds 16-color VGA X server

<TR>

<TD>XF86MonoServer

<TD>NO

<TD>Builds monochrome VGA X server

<TR>

<TD>XF86S3Server

<TD>YES

<TD>Builds S3 X server

<TR>

<TD>XF86Mach8Server

<TD>NO

<TD>Builds the Mach8 X server

<TR>

<TD>XF86Mach32Server

<TD>NO

<TD>Builds the Mach32 X server

<TR>

<TD>XF86Mach64Server

<TD>NO

<TD>Builds the Mach64 X server

<TR>

<TD>XF86P9000Server

<TD>NO

<TD>Builds the P9000 X server

<TR>

<TD>XF86AGXServer

<TD>NO

<TD>Builds the AGX X server

<TR>

<TD>XF86W32Server

<TD>NO

<TD>Builds the ET4000/W32 X server

<TR>

<TD>XF86I8514Server

<TD>NO

<TD>Builds the IBM 8514/A X server

<TR>

<TD>XnestServer

<TD>NO

<TD>Builds the Xnest server

<TR>

<TD>BuildPexExt

<TD>YES

<TD>Builds the PEX extension

<TR>

<TD>BuildXIE

<TD>NO

<TD>Builds the XIE extension

<TR>

<TD>BuildLBX

<TD>NO

<TD>Builds the Low Bandwidth X extension

<TR>

<TD>BuildScreenSaverExt

<TD>YES

<TD>Builds screen saver extension

<TR>

<TD COLSPAN="3"><HR>

</TABLE>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>NOTE:&nbsp;&nbsp;</B>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&#146;re rebuilding the X server anyway, you may also want to build in one of the other X extensions, such as LBX or XIE.<HR></FONT>

</BLOCKQUOTE>

<P>Most of the servers are turned on automatically. You can turn off what you don&#146;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.

</P>

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

<P>Comment out the <I>XF86Contrib</I> line to build all the contributed software.</P>

<P>Once you&#146;ve set up the <B>xf86site.def</B> file, you&#146;re ready to starting building a new X server.</P>

<H3><A NAME="Heading5"></A><FONT COLOR="#000077">Building a New X Server</FONT></H3>

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

</P>

<DL>

<DD><B>1.</B>&nbsp;&nbsp;Back up your current X server.

<DD><B>2.</B>&nbsp;&nbsp;Build all the <B>Makefile</B>s.

<DD><B>3.</B>&nbsp;&nbsp;Make the new X servers.

<DD><B>4.</B>&nbsp;&nbsp;Quit X.

<DD><B>5.</B>&nbsp;&nbsp;Install the new X servers.

<DD><B>6.</B>&nbsp;&nbsp;Ensure that <B>/usr/X11R6/bin/X</B> links to the proper X server.

<DD><B>7.</B>&nbsp;&nbsp;Start X to verify that the new X server works.

<DD><B>8.</B>&nbsp;&nbsp;Run <B>xdpyinfo</B> to see if the new X extensions are available.

<DD><B>9.</B>&nbsp;&nbsp;Clean the /usr/X11R6/lib/Server directory with make clean.

</DL>

<P>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 <B>/usr/X11R6/lib/Server</B> directory and build all the <B>Makefile</B>s by running the following command:</P>

<!-- CODE SNIP //-->

<PRE>

       $ ./mkmf

</PRE>

<!-- END CODE SNIP //-->

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

<P>Once <B>mkmf</B> finishes successfully, run <B>make</B>:</P>

<!-- CODE SNIP //-->

<PRE>

       $ make

</PRE>

<!-- END CODE SNIP //-->

<P>This builds the new X servers and will take even longer than the last step. Once you&#146;ve built the new X servers, you must ensure that X is stopped. It&#146;s very convenient to <B>su</B> to the root user in one <B>xterm</B> window and build the new X servers while you have all the other windows on your screen available for your work&#151;that&#146;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.</P>

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

<!-- CODE SNIP //-->

<PRE>

        $ make install

</PRE>

<!-- END CODE SNIP //-->

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

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

<P>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 <B>xdpyinfo</B> in an <B>xterm</B> window to see if the new X extensions are available. The list should look something like the following:</P>

<!-- CODE //-->

<PRE>

     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

</PRE>

<!-- END CODE //-->

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

</P>

<P>Once you&#146;re confident that everything is built up properly, run <B>make clean</B> in the <B>/usr/X11R6/lib/Server</B> directory (again as <B>root</B>):</P>

<!-- CODE SNIP //-->

<PRE>

      $ make clean

</PRE>

<!-- END CODE SNIP //-->

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

<P>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 <B>beach_ball</B>.</P>

<H4 ALIGN="LEFT"><A NAME="Heading6"></A><FONT COLOR="#000077">Performance and Memory Issues</FONT></H4>

<P>PEX consumes a lot of system resources, so don&#146;t load this extension if you&#146;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.

</P>

<P>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.</P><P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="ewtoc.html">Table of Contents</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -