This article serves as a quick guide to compile Xorg on CentOS 6.x. It should also work on other Linux distros but I only tested on CentOS.
The official guide provides 2 ways to compile, one is using build.sh script, another is using jhbuild. Here I use jhbuild, and you can also refer to the official jhbuild guide.
First you need to install the build tools, the list below is not comprehensive.
yum install @gnome-devel @development-tools gnome-common glib2-devel gnome-doc-utils docbook-style-xsl waf
yum install zlib-devel freetype-devel libxslt-devel libxml2-devel expat-devel gperf libgcrypt-devel
Install python 2.7, pip, then use pip to install mako, lxml, six. mako is needed to compile mesa. lxml and six are needed to compile fontconfig.
yum install centos-release-SCL
scl enable python27 bash
cd /opt/rh/python27/root/usr/bin/ # enter python2.7 directory
./easy_install-2.7 pip
./pip2.7 install requests
pip install mako lxml six
Install new gcc v4.9.2.
yum install devtoolset-3-toolchain
Now we can start compiling. Download jhbuildh, read on for installation.
Note: jhbuild cannot run as root, so create a normal user and add the user to sudoer list.
Run scl enable devtoolset-3 python27 bash
to launch a new shell with new gcc and python 2.7 environment.
All commands below are run as a normal user.
cd # enter user home directory
git clone git://git.gnome.org/jhbuild
cd jhbuild
./autogen.sh
make
make install
jhbuild will be installed to ~/.local/bin
, we need to add that path to $PATH
environment variable. Edit ~/.bashrc
and change $PATH
to export PATH=$PATH:$HOME/.local/bin
. Run . ~/.bashrc
to reload .bashrc.
Now you should be able to run jhbuild, verify with which jhbuild
.
Download jhbuild config files used to build Xorg:
cd # enter user home directory
mkdir -p xorg/util
git clone git://anongit.freedesktop.org/git/xorg/util/modular/ xorg/util/modular
Copy jhbuildrc file to your home directory:
cd
cp xorg/util/modular/jhbuildrc ./jhbuildrc
nano jhbuildrc
jhbuildrc is actually a python script, which is used by jhbuild to figure out parameters for compilation. You can specify which Xorg modules to build, autogen arguments, library search paths, install prefixes and so on, you can even specify module-specific settings.
If you use the default jhbuildrc, it will build the entire X window system, which includes about 255 modules. The prefix will be set to xorg-build folder under your home directory.
Each module is defined in xorg/util/modular/xorg.modules
, which is actually a XML file. It specifies where to obtain source code, what is the git clone URL, and module dependency. You can modify this file to change module version, for example, if you want mesa version 11.1.2, then find out the git tag for version 11.1.2, it could be "mesa-11.1.2", then add attribute tag="mesa-11.1.2"
to branch
XML element. (Use git tag -l
to list git tags.)
Note: CentOS 6.x uses HAL, so when you configure xserver, make sure to use --enable-config-hal --disable-config-udev
, and you must set SUID on the compiled Xorg binary, like so: chmod +s Xorg
.
After editing jhbuildrc, run this command to compile:
jhbuild -f jhbuildrc
The first time you compile, jhbuild will need to download a lot of git repositories, if you don't have fast internet, it may take hours.
Below are some commonly used jhbuild commands, to help speed up re-compilation after changing configs.
Recompile all modules without network, so git repositories are not updated.
jhbuild -f jhbuildrc build --no-network --force
Recompile a single module, xserver in this case, and run make clean before compiling.
jhbuild -f jhbuildrc buildone xserver --force --clean
Resume from a specific module.
jhbuild -f jhbuildrc build --start-at=libX11
During compilation, jhbuild will prompt you if it runs into any errors, so don't walk away from computer.