3 AUTHORS: Sam Halliday <fommil AT yahoo DOT ie>
6 This hint covers the building and initial configuration of an XFree86
7 server and client (XWindows). The setup of DRI (graphics acceleration) is also
8 shown for those who have such a capable card (for a recent list of supported
9 cards, see http://dri.sourceforge.net/doc/feature_table.html)
12 This hint is a combination of hints x11.txt, xfree86_41.txt,
13 xfree86_42.txt, xfree86_4.2.0_dri.txt, nvidia_glx and dri.txt. For that
14 reason, credits are due to
15 Matthias Benkmann <m DOT s DOT b AT gmx DOT net>
16 Marc Heerdink <marc AT koelkast DOT net>
17 Dave Ayers <fogey AT mindspring DOT com>
18 Luke Guest <laguest AT nebulas DOT demon DOT co DOT uk>
19 Ryan Strayer <rstrayer AT kc DOT rr DOT com>
20 manaveru <manaveru AT manaveru DOT net>
21 Sergey Ostrovsky <sostrovsky AT snip DOT net>
22 Further credit must be given to
23 Jim Gifford <jim AT jg555 DOT com>
28 0.02 suggestions by Matthias Benkmann.
29 0.03 suggestions by Marc Heerdink.
30 0.04 building of glut added, more from Matthias Benkmann.
31 0.05 updated ttmkfdir, cleaned configuration, better xfs initscript.
32 0.06 fixed typo in the host.def file which breaks compilation :(
33 added note about newer XFree86 version.
35 WHY YOU MIGHT WANT THIS HINT:
36 Unless you really, _really_ want XFree86-4.2.1 for some specific
37 reason, do NOT use this hint. XFree86-4.3 is (almost) out and you should
38 use that instead. This hint exists simply as a legacy hint as it explains
39 a lot of detail in setting up an X server, which is still applicable.
48 ftp://ftp.xfree86.org/pub/XFree86/4.2.0/source/X420src-*.tgz
49 This is the 3-part source code for XFree86, uncompress all 3 tarballs
50 from the same location.
52 XFree86 patch from 4.2.0 to 4.2.1:
53 ftp://ftp.xfree86.org/pub/XFree86/4.2.1/patches/4.2.0-4.2.1.diff.gz
54 This will update your source to the bugfixed patch release 4.2.1. This
55 is highly reccomended.
58 ftp://ftp.xfree86.org/pub/XFree86/4.2.1/fixes/4.2.1-mit-shm-security.patch
59 This patch applies to the 4.2.1 tree and fixes a security issue with
60 xdm, X's graphical login.
62 Jim Gifford's bison syntax patch:
63 http://www.jg555.com/cvs/cvsweb.cgi/patches/xfree/xfree-4.2.x.-bison.fixes.patch
64 This fixes some syntax issues in the source code which are only picked
65 up by more recent versions of bison. It is a good idea to use this patch, even
66 if you have an older version of bison.
68 The ttmkfdir tool, soon to be obsoleted in XFree86-4.3
69 http://people.redhat.com/yshao/ttmkfdir2.20021109.tar.bz2
70 This is needed for making a fonts.scale file for TTF fonts.
72 MesaLib and MesaDemos (for glut)
73 http://sourceforge.net/project/showfiles.php?group_id=3
78 Make sure you check all the MD5SUMs against the ones you download. Most trojan
79 attempts of late have failed to do this, and this is therefore our only weapon
80 against such attacks (which is flawed anyway if there is no GPG signature)
81 ad43a8e9e39703322005cd6f7145b77f X420src-1.tgz
82 dae33268a9f2735b9678a81fb23e8d3e X420src-2.tgz
83 560899e175a02ab592185b69756f539e X420src-3.tgz
84 38adc94a4953a6b29e8619c25dda4887 4.2.0-4.2.1.diff.gz
85 18eb56110c7f66895111bd9f3513b54e 4.2.1-mit-shm-security.patch
86 79e0401393c9728865aa73bb2bd68dd4 ttmkfdir2.20021109.tar.bz2
87 ebfac20c7fe7943243bc54a4b755f50d MesaDemos-5.0.tar.bz2
88 df44d99ae97c5c0df631575757a96d86 MesaLib-5.0.tar.bz2
90 Apply all the patches before proceeding
96 This hint will start by showing how to quickly build XFree86, then how to
97 configure the X server and check that it works. Next we set up the font
98 server and add truetype font support and build glut. For those lucky ones
99 out there, we set up graphics acceleration. The graphics acceleration
100 appears in several sections; standard DRI, bleeding edge DRI, bad news about
101 voodoo cards and finally setting up NVidia cards.
107 XFree does not use the standard GNU tools for building and installing. It uses
108 a load of C header files to allow us the power to define the parts which we
109 need to compile... good for future re-compiles. The many options are clear
110 from browsing the files in config/cf. But for most peoples needs, the following
113 You may wish to tailor the DefaultGcc2i386Opt define to reflect your hardware,
114 if you have a different architecture altogether from i*86, use DefaultGcc2AxpOpt
115 or DefaultGcc2PpcOpt to define the optimisation flags for an Alpha or PPC,
116 respectively. Set HasMTRRSupport, HasMMXSupport, HasKatmaiSupport and
117 Has3DNowSupport to YES if you have a CPU capable of those instructions.
118 You can see if your CPU has MTRR, MMX, or Katmai support by looking at the
119 'flags' section of /proc/cpuinfo.
121 This will add support for all graphics cards, feel free to choose only the
122 modules you require if you are sure about your choice. If your card is not
123 supported under DRI (graphics acceleration), then you should say NO to
124 BuildXF86DRI and BuildXF86DRM. Please note this is a C header file not a
125 bash script, so the # are not comments but the /* comments */ are.
127 cat > config/cf/host.def << "EOF"
128 /* LFS HINT XFree86-4.2.1 0.02 */
129 #define DefaultGcc2i386Opt -s -O3 -fomit-frame-pointer
130 #define GccWarningOptions -w -pipe
131 #define TermcapLibrary -lncurses
133 #define HasNCurses YES
134 #define HasMTRRSupport NO /* Also to be enabled in the kernel */
135 #define HasMMXSupport NO /* Any i586 or above */
136 #define HasKatmaiSupport NO /* PIII SSE instuctions */
137 #define Has3DNowSupport NO /* AMD instructions */
138 #define XInputDrivers mouse void
139 /* build all drivers available */
140 #define XF86CardDrivers mga glint nv tga s3 s3virge sis rendition \
141 neomagic i740 tdfx savage cirrus vmware \
142 tseng trident chips apm GlideDriver fbdev \
143 i128 ati AgpGartDrivers DevelDrivers ark \
144 cyrix siliconmotion vesa vga \
145 XF86OSCardDrivers XF86ExtraCardDrivers
146 #define BuildXF86DRI YES
147 #define BuildXF86DRM YES
148 #define DriDrivers gamma tdfx mga i810 i830 r128 radeon sis
149 #define BuildLinuxDocHtml NO
150 #define BuildLinuxDocPS NO
151 #define BuildAllSpecsDocs NO
152 #define BuildHtmlManPages NO
153 #define BuildSpecsDocs NO
154 /* future `update' compiles do not need these, in that case say NO */
155 #define InstallXinitConfig YES
156 #define InstallXdmConfig YES
157 #define InstallFSConfig YES
160 OK.. thats the hard bit out of the way! Now we compile it and have a cuppa!
162 make World >xcompile.stdout 2>xcompile.stderr
164 (some people may prefer to watch the screen tick by, but as the console is
165 a slow device, this will actually slow down the compile, but if you insist
166 then type 'make World 2>&1 | tee World.LOG' instead )
168 For some bizarre reason, if make fails on any file in make World, the
169 compile continues, and problems only manifest themselves in the make install.
170 This is quite annoying as it may lead to an old 'working' X being overwritten
171 by a new 'broken' one. For that reason I suggest anyone with an X install
172 present already, make a backup of /usr/X11R6 at this stage. You could also run
174 grep error xcompile.std*
176 to see if there are any early signs of things going wrong.
177 Once that is all done, type
181 and then (optionally)
185 I recommend you look at the hint on man pages, since default man pages are
186 uncompressed. Unfortunately it is not as simple as typing 'gzip -9 *' to
187 compress the pages as there are symbolic links to consider also.
189 At this stage, you are required to add the line '/usr/X11R6/lib' to
190 /etc/ld.so.conf and run ldconfig. This updates the dynamic linker cache to
191 respect the new X install. You should also add /usr/X11R6/bin to the global
192 variable PATH in /etc/profile.
194 Recent versions of XFree86 (such as this release) no longer require seperate
195 compilation of Mesa or Freetype... which is good news! In fact, as those
196 libraries are entangled into the standard XFree86 package, it is reccomended
197 not to upgrade unless the XFree86 people do, as conflicts have and may still
198 arise! (you have been warned)
201 Configuring and Starting XFree86
202 ================================
204 This is the important stage where you set the configuration file for XFree86,
205 /etc/X11/XF86Config-4. It is quite tricky to get right the first time, and
206 you are recommended to use the file from your host system. If you do not have
207 the luxury of a previous config file, you may generate one called
208 XF86Config.new by typing
212 and after browsing it, test it by typing
214 XFree86 -xf86config /root/XF86Config.new
216 You won't get anything but a flimmering 640 x 480 screen with an
217 annoying pattern and an X-shaped mouse cursor that you can move (if
218 the mouse works). Press Ctrl-Alt-Backspace to exit, then move your
219 config file to its final location
221 mv XF86Config.new /etc/X11/XF86Config-4
223 Congratulations! You have just installed X. Now read the XFree86-HOWTO you get
224 from linuxdoc.org. It will give you an overview of how X is started. Read the
225 scripts /usr/X11R6/bin/startx and /usr/X11R6/lib/X11/xinit/xinitrc which
226 determine what happens when you type 'startx'. You will quickly notice that
227 you may create your own user-custom .xinitrc file.
229 You may also want to type
231 man /usr/X11R6/man/man{1,5,7}/*
233 which will let you read all manpages in a row (just press q to go to the
234 next manpage). Once you're through you know more about X than 99% of the
237 You'll probably want to do some more configuring in XF86Config-4, you
238 should read /usr/X11R6/lib/X11/XF86Config.eg which is a well-commented
241 The mouse setup is very important as incorrect settings result in a crashing
243 [I was once at a conference where the only person who gave their talk using
244 linux had removed their laptop mouse just for that startup...
245 X crashed instantly.]
246 It is most iportant that the Protocol and Device are true for your machine.
247 This setup is for an IMPS/2 mouse. The Device should be /dev/ttyS0 if you
248 have a COM1 style mouse
250 Section "InputDevice"
253 Option "Protocol" "IMPS/2"
254 Option "Device" "/dev/psaux"
255 # uncomment the next line and edit if you want more 'action' from your mouse...
256 # Option "Resolution" "300"
257 # uncomment the next 2 lines to enable the wheel on most mice...
258 # Option "Buttons" "5"
259 # Option "ZAxisMapping" "4 5"
262 Some other things you will surely want to set are
264 Section "InputDevice"
265 Identifier "Keyboard0"
267 Option "XkbModel" "pc102"
268 Option "XkbLayout" "<your layout>"
269 Option "AutoRepeat" "250 30"
275 Identifier "Monitor0"
277 ModelName "VisionMaster 450"
282 Of course you will need to enter the correct values for your monitor. You
283 should check the labels on the back of the monitor if you do not know the
284 exact model, then go to your manufacturer's website and get the Horz/Vert
285 rates. If you set the right values you don't need to fiddle with modelines
286 (what a relief!) because XFree86 will choose an appropriate VESA mode with
287 a high refresh rate. Just specify what mode you want like this:
301 This is all it takes to get a nice screen of 1024x768!
303 After finishing off the X configuration and optional sections, your next
304 task will be finding a Window Manager you like using. XFree86 comes with a
305 standard (and not user friendly) Window Manager called 'twm'. I personally
306 recommend 'blackbox' (http://blackboxwm.sourceforge.net), which is a very
307 light-weight program and is efficient to use. A lot of people prefer a
308 totally integrated Desktop environment, such as KDE or Gnome.
312 X Font Server (optional, recommended)
315 The best way to utilise fonts under XFree86 is with a font server, which
316 handles all the font aliases and matching instead of the actual X server
317 itself. This server should be started in the initscripts, and it is left
318 to your own discression as to when to load the font server.
320 cat > /etc/rc.d/init.d/xfs << "EOF"
323 source /etc/sysconfig/rc
328 echo "Starting X font server..."
329 rm -fr /tmp/.font-unix
330 loadproc /usr/X11R6/bin/xfs -port -1 -daemon
334 echo "Stopping X font server..."
339 echo "Sending reload signal to X font server..."
340 kill -s SIGHUP `pidof xfs`
355 echo "Usage: $0 {start|stop|restart|reload|status}"
360 chmod 755 /etc/rc.d/init.d/xfs
362 Now we setup the font server. The default config files /etc/X11/XftConfig
363 and /etc/X11/fs/config keep all the font configuration. The defaults will work
364 fine with this install, but I invite you to browse those files. It should
365 be obvious how to add extra font directories.
367 To make use of xfs, just add the FontPath line to your X config file something
377 TrueType Fonts (optional)
380 This is trivial to set up, all you require are some ttf fonts, and the tool
381 ttmkfdir. Build and install the ttmkfdir (version 2) tool with:
383 make CXX=$CXX CXXFLAGS="$CXXFLAGS -pedantic \
384 -I/usr/X11R6/include/freetype2" FREETYPE_BASE=/usr/X11R6 \
385 FREETYPE_LIB="-L/usr/X11R6/lib -lfreetype"
386 install ttmkfdir /usr/X11R6/bin/
388 (NOTE: on building, you may get an error related to exceptions, in which case
389 retype the above with -fno-exceptions just after -pedantic). You may now
390 prepare any ttf folder for XFree86 by typing entering it and typing
392 ttmkfdir -o fonts.scale
395 In order to preserve cleanliness, you may wish to lower-case the names of all
396 your ttf fonts. You may lower-case the names of all .ttf/.TTF files in the
397 current directory by typing (use with care)
403 NEWNAME=`echo $A | tr [:upper:] [:lower:]`
405 /bin/mv -i "$A" "$NEWNAME" 2>/dev/null ;
408 Now your fonts should be ready to use. Just make sure your X config has the
409 freetype module loaded, something like
418 Glut (optional, recommended)
421 Unfortunately not everything we need comes with X. Almost all programs that
422 use OpenGL need the glut library as well, so we'll install it. We'll use the
423 version of glut that comes with Mesa, because it has been adapted to work with
424 X. Mesa is a huge download though, especially since we're only using the glut
425 library from it. Once you unpack both the Mesa files, enter the root directory
426 and build _only_ glut by typing
428 ./configure --prefix=/usr/X11R6
434 There are some other useful things included with Mesa, such as the demos. If
435 you want to build them to measure performance, run the following commands to
436 build them, this is an example of how to build the 'gears' program using glut,
437 there are many to choose from, building in a similar fashion:
440 make -f Makefile.X11 CFLAGS="$CFLAGS -L/usr/X11R6/lib" gears
443 Accelerated Graphics [DRI] (optional)
444 ==========================
446 The direct rendering infrastructure, also known as the DRI, is a framework for
447 allowing direct access to graphics hardware in a safe and efficient manner. It
448 includes changes to the X server, to several client libraries, and to the
449 kernel. The first major use for the DRI is to create fast OpenGL implementations.
451 Bleeding edge users may use the latest CVS version of DRI, details at the end,
452 but most will be fine using the more stable XFree86. I have found CVS DRI to be
453 quite buggy. (Although a debug build and gdb hanging around does a world of
454 help for the developers!) You must have AGP compiled into your kernel, and
455 there must be support for your AGP chipset as well as the graphics card itself.
457 This is easy to get running (in theory), just ensure the lines
466 are present in your /etc/X11/XF86Config-4. You may optionally set
472 so that you can control the permissions of DRI to users. The default is root
473 access only, but we obviously want to use it as users.
475 One last very important thing about DRI. Stock linux kernels come only prepared
476 for XFree86-4.1, so we must copy our new kernel module (the DRM) to allow
477 dynamic loading. If you built DRM, all the modules will be in
479 ls programs/Xserver/hw/xfree86/os-support/linux/drm/kernel
481 For example, for a radeon card the relevant file is "radeon.o", this you must
482 copy to your kernel modules directory under kernel/drivers/char/drm/
483 Substitute your requirements for CARD and KERNELVERSION in this command:
485 cp programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/CARD.o \
486 /lib/modules/KERNELVERSION/kernel/drivers/char/drm/
489 If you run 'startx', a quick 'glxinfo' on the command line will show if DRI
490 is working or not, you can see the acceleration in action by typing 'glxgears'
493 DRI-CVS (optional, unstable, and not recommended)
496 This must be downloaded by anonymous CVS.
500 export CVSROOT=:pserver:anonymous@cvs.dri.sourceforge.net:/cvsroot/dri
502 (hit ENTER when prompted for a password)
505 I recommend you make a local tarball of this directory, making use of
506 cvs to update it in the future with
509 export CVSROOT=:pserver:anonymous@cvs.dri.sourceforge.net:/cvsroot/dri
510 cvs -z3 update -dA xc
512 The DRI sources are a cut-down version of the latest XFree86, and we build it
513 in a parallel linked directory, which we make by typing (from the DRI-CVS
519 lndir -silent -ignorelinks ../XFree
522 Observing the original notes about config/cf/host.def, we also build DRI
523 with less harsh optimisations and enable debugging symbols.
525 cat > config/cf/host.def << "EOF"
526 #define DefaultGcc2i386Opt -g -O2
527 #define GccWarningOptions -w -pipe
528 #define BuildServersOnly YES
530 #define HasMTRRSupport NO
531 #define HasMMXSupport NO /* Any i586 or above */
532 #define HasKatmaiSupport NO /* PIII SSE instuctions */
533 #define Has3DNowSupport NO /* AMD instructions */
534 #define XInputDrivers mouse void
535 /* build all drivers available */
536 #define XF86CardDrivers mga glint nv tga s3 s3virge sis rendition\
537 neomagic i740 tdfx savage cirrus vmware\
538 tseng trident chips apm GlideDriver fbdev\
539 i128 ati AgpGartDrivers DevelDrivers ark\
540 cyrix siliconmotion vesa vga\
541 XF86OSCardDrivers XF86ExtraCardDrivers
542 #define BuildXF86DRI YES
543 #define BuildXF86DRM YES
544 #define DriDrivers gamma tdfx mga i810 i830 r128 radeon sis
545 /* the following are to enable the dri tree to have its dependencies built */
546 #define BuildLibrariesForXServers NO
547 #define BuildLibrariesForConfigTools NO
549 #define BuildPexExt NO
550 #define XprtServer NO
553 make World >dricompile.stdout 2>dricompile.stderr
556 copy over the kernel module and thats it!
557 You may check which files have been updated by typing
559 find /usr/X11R6 -cnewer config/cf/host.def
565 If you have a voodoo card, then tough luck as I am afraid support has been
566 dropped. I found this out the hard way!
569 NVIDIA ACCELERATED GRAPHICS (recommended... only for NVidia cards)
570 ===========================
572 NVidia has never released open sourced code for their 'unified' driver. If you
573 have such a graphics card, i pitty you for having to put in proprietory code
574 after you have spent so long building your own LFS. Go to http://www.nvidia.com
575 and foillow the driver links to get the latest linux driver. You should get
576 both the NVIDIA_kernel and NVIDIA_GLX tarballs.
578 Unpack the NVIDIA-kernel file and enter the created directory.
582 This will produce a module called NVdriver. Copy it to the appropriate kernel
583 modules directory, replace KERNELVERSION with your appropriate value
585 cp NVdriver /lib/modules/KERNELVERSION/drivers/char/agp/
587 Add the device in /etc/modules.conf and refresh the modules dependencies.
589 echo alias char-major-195 NVdriver >> /etc/modules.conf
592 Unpack the NVIDIA-GLX tarball and enter the created directory.
596 This will install the Nvidia drivers in the correct locations.
598 You will now edit the /etc/X11/XF86Config-4 file to use the new drivers. Ensure
599 the following are present:
603 Load "dri" # Remove/comment this line
604 Load "glx" # Add this line if not present
609 Driver "nv" # Remove/comment this line
610 Driver "nvidia" # Add this line
614 If you 'startx' and X locks at startup you'll need to edit os-registry.c and
615 check the comments near lines that start something like '#if 0'.
617 If 3D acceleration is just not working, you probably have some Mesa libs lying
618 around in /usr/lib. Remove the following files /usr/lib/libMesa*
619 /usr/X11R6/lib/libMesa* and reinstall the GLX module. If you have 3D apps that
620 require Mesa, you can simply create symlinks to GLX lib (libGL.so.1). You
621 also need to remove /usr/X11R6/lib/libGL.so.1.2 and symlink it to