Introduction

This page is an attempt to describe the process require to build the modular X.org tree using a crosscompiler. The majority of this document will assume that the reader already has a fully functioning crosscompiler on the build system that can create binaries for the host system. Build and host are the standard terms used by autoconfig to describe the system where the programs will be built (build) and the system where the programs will run (host). It would seem that the system where the programs will run should be called target, but that term carries a different meaning in autoconfig. Target is the system for which a compiler (e.g., your crosscompiler) will generate code. Correct use of this terminology will help the process, trust me!

For crosscompilers targeting Linux systems, crosstool is a good choice.

Additional Requirements

In addition to a crosscompiler, some libraries and headers for the host system must also be available. These can either be crosscompiled or copied from the host system. At a minimum, the following are required:

zlib

libpng

expat

freetype

fontconfig

libdrm

openssl (for SHA1)
For at least libdrm, PKG_CONFIG_PATH will need to be set to the location of that library's .pc file. Some configurations are known to build using the default system pkgconfig and simply over-ride the PKG_CONFIG_PATH. However, it may be necessary in some cases to build a "cross" pkgconfig.

Cross compiling dependencies

The below instructions assume CROSS_COMPILE is set to your toolchain (e.g. export CROSS_COMPILE=arm-none-linux-gnueabi- ) and DISCIMAGE is set to where you want to install. They also assume a Debian/Ubuntu based system - update as appropriate.

Using jhbuild to compile

X should now cross compile. General Jhbuild instructions are given at JhBuildInstructions. Feel free to mention any problems that you've come across here, along with solutions if you have them.

Compiling without JHBuild

This is not necessary if you use JHBuild to build. However if you do not want to, you will have to configure and build manually. Below are some general instructions to help you.

To enable crosscompiling the --host and --build flags must be passed to configure. If the build.sh script is being used, this can be done by setting CONFFLAGS. Both of these flags take a standard autoconfig system description. For example, to build on an x86-64 system running Linux for a PowerPC system running also running Linux, CONFFLAGS should be set to "--build x86_64-unknown-linux-gnu --host powerpc-unknown-linux-gnu". Based on these settings, the configure scripts will assume that the crosscompiler is named powerpc-unknown-linux-gnu-gcc and is in the path. If the compiler named something different, the name must be providied via the CC environment variable. The C++ compiler (CXX), linker (LD), ranlib (RANLIB), and ar (AR) must also be provided in this manner.

Some components need to build and run programs on the build system that generate output used in the build process. For this compnents, CC_FOR_BUILD must be set to the name of the compiler that targets the build system. The majority of these components do not correctly use CC_FOR_BUILD, but there is a patch (see below) available.

A number of steps in the autoconfig process implicitly assume that the build system and the host system are the same. For example, library components want to build and run test programs to determine the behavior of certain host system elements. This is clearly impossible when crosscompiling. To work around these issues, the --enable-malloc0returnsnull (or --disable-malloc0returnsnull, depending on the host system) must be passed to configure.

In addition, the configure scripts for the video drivers use methods for detecting the availability of DRI that are incompatible with crosscompiling. Until a fix is provided, drivers must either be built on the host system or --disable-dri must be provided to their configure scripts. The issue in the drivers' configure scripts does not effect the core X server.

The -h and -b options to build.sh supply the --host and --build options to the configure scripts automatically. In addition, the value passed to -h is used in operation system and processor architecture based determinations of which drivers to build. The modifications to build.sh are based on the build.sh script that I use, but they have not been completely tested. If you encounter problems, please post to the xorg mailing list.