TuX as LLG logo
Driver Suite for Linux
csv2iif.pl suite
convert PayPal transactions to IIF, OFX, QIF
DMX30 Interface
128Ch SPP
DMX43 Interface
2out 2in EPP
LED Hardware
for Linux and Windows
EPROM Sampler
for 8 bits of sound
Linux drivers for MK3/4 PCI
PostgreSQL replication
C exception/signal handling lib
to various software
and small scripts
misc documents
to lighting stuff

XFree86 compilation guide

Updating the XFree86 server can be a tricky task, because of many libraries involved and the official XFree86 archives don't contains the latest and greatest versions of all requiered libs. This guide is meant to help you with some stumbling blocks which hinder you in setting up a decent X server, up to and including XFree86 4.5.0.

You should have a thorough understanding of the unix build processes, the file system and generell usage of headers and libraries in a *nix environment. If you carelessly follow the steps in this guide you may well render your system useless or damage it in a non-predictable way. Please read the guide completely once to get an overview what I recommend to do.

Remember that you can not overwrite your existing X configuration and directories with X running. So make the following steps from a textmode console.

Download the necessary software

  1. XFree86 sources. They are shippen in several .tgz files. Locate the latest release on the Xfree86 ftp server and download all .tgz files.
  2. Freetype2 get the latest version of the 2.1.x releases
  3. Fontconfig 2.3.1
  4. Xft 2.1.2

Compile and Install XFree86

The utils*.tgz archive contains GNU tar and zlib. However I would recommend you check that you have the latest versions already installed on your system and update as necessary from the original sites.

The doctools*.tgz archive contains some utilities used for SGML processing. You should build and install this package.

Now simply unpack all XFree86*.tgz archives. They should all unpack into a xc/ directory. Inside this directory simply issue a make World (if you have a Linux system everything should already be configured). Otherwise look into the INSTALL file for instructions.

Up to this point you could make the build process with a running X. To install the new X shutdown X and work on in the text console. I advise you keep a backup of your current X. A simple rename of the X11R6 tree should do the trick: mv /usr/X11R6 /usr/X11R6.bak. If you have made any modifications to the scripts and ressource files in /etc/X11 you should also make a backup of this directory, as the standard files will get overwritten by the install procedure. You could make a copy of this directory like this: cp -r /etc/X11 /tmp.

Install your compiled X with make install and install the man pages as well: make install.man. Now you have a new XFree86 in /usr/X11R6.

Now would be a good time to check for some bogus X11 header floating around in your system. Please look for directories named /usr/include/X11 and /usr/local/include/X11. If those are symbolic links to /usr/X11R6/include/X11 you can leave them in place, otherwise you should remove them completely, so only the official headers matching your X release are located in /usr/X11R6/include.

Optional: Install Graphics Card drivers

If you have to use any graphic card drivers which are not included with the XFree86 distributions (for example if you have a NVidia card) you should now install those drivers.

After your drivers are installed start X to see if the new X server and drivers are working correctly. If X is not running fix it first before going on.

Fix OpenGL headers

XFree86 often does not include the latest official headers. Furthermore those header files are often overwritten with crippled header files by graphic card drivers (NVidia once again). You should get yourself at least the latest official OpenGL headers and copy them into your include directory. While you are at it you should also look if you have other OpenGL header floating around in your system. Please look for the following directories if they exists, respectively if they contain any files: /usr/include/GL and /usr/local/include/GL. If they are symbolic links to /usr/X11R6/include/GL that is fine, otherwise you should delete them and make sure that only /usr/X11R6/include/GL continas OpenGL headers.

Fix pkg-config path

We have to register the package directory /usr/X11R6/lib/pkgconfig for pkg-config. Add a line like export PKG_CONFIG_PATH=/usr/X11R6/lib/pkgconfig to /etc/profile and restart your current shell.

Fix Truetype rendering

The XFree86 sources contain a version of the Freetype library. However due to patent problems the standard versions of Freetype do not provide the best rendering mode out of the box. You have to compile your own version of the Freetype library to enable them. You should also make sure, that no other versions of the library are available on your system.

As first step you should remove any old freetype files on your harddrive. Unpack the freetype2 archive and configure it with ./configure --prefix=/usr. When configure finishes do make uninstall. Delete the freetype sources and unpack them a second time. Now configure with ./configure --prefix=/usr/local and make uninstall. Then remove the sources again.

Now unpack the new Freetype library (third time) and have a look at the file docs/TRUETYPE. Follow the instructions provided there to patch the configuration header file, which enables the bytecode interpreter. You may risk a patent violation when doing so depending on your contries laws. Now setup, compile and install the library with ./configure --prefix=/usr/X11R6 && make && make install.

Fix fontconfig

XFree86 4.4.0 currently ships with fontconfig 1.0.2, which is heavily outdated. We have to install the new fontconfig 2.3.1. Similar to freetype we install the new version into /usr/X11R6 to overwrite the old version supplied with XFree.

At first we remove any old fontconfig files on our filesystem.

  1. unpack fontconfig
  2. ./configure --prefix=/usr && make uninstall
  3. remove fontconfig directory
  4. unpack fontconfig again
  5. ./configure --prefix=/usr/local && make uninstall
  6. remove fontconfig directory

Now unpack fontconfig a third time and configure it with its config directory as /etc: ./configure --sysconfdir=/etc --prefix=/usr/X11R6. After make && make install you're done with fontconfig.

Fix Xft

You can also install the latest version of the Xft library. Do similar to the freetype and fontconfig libs; first delete old files from /usr and /usr/local then install into /usr/X11R6.

Xft 2.1.2 has a small bug with freetype header inclusing. Use the following patch to fix:

diff -u -U 5 -r --new-file -x *~ -x *.[oa] xft-2.1.2/Xft.h xft-2.1.2.doj/Xft.h
--- xft-2.1.2/Xft.h	Tue May  6 07:37:49 2003
+++ xft-2.1.2.doj/Xft.h	Fri May 28 18:20:02 2004
@@ -36,11 +36,12 @@
 #define XFT_REVISION	2
 #define XFT_VERSION	((XFT_MAJOR * 10000) + (XFT_MINOR * 100) + (XFT_REVISION))
 #define XftVersion	XFT_VERSION

 #include <stdarg.h>
-#include <freetype/freetype.h>
+#include <ft2build.h>
+#include FT_FREETYPE_H
 #include <fontconfig/fontconfig.h>
 #include <X11/extensions/Xrender.h>

 #include <X11/Xfuncproto.h>
 /* #include <X11/Xosdefs.h>*/


Use this shell script to patch and build xfree86, freetype, fontconfig and xft applying the patches. You may have to adjust the filenames and directories depending on the software versions you wish to install.

further stuff

XFree86 also installs a version of the Expat XML Parser. You may have a version of expat already in /usr or /usr/local which you could remove (at least the include files) to prevent confusion of your build environment in the future.

As you have just made a major update to your X system this would be a good point to rebuild other basic parts of the GUI frameworks, like gtk/gnome/wxWidgets, qt/kde or Lesstif so they can use the latest APIs.

This (german) Howto explains how to enable the autohinter in your fonts.conf file.

Questions / Contact

For questions and comments contact Dirk Jagdmann <doj@cubic.org>

http://llg.cubic.org © 2001-2017 by Dirk Jagdmann