Compiling enigma2 for the sh4 arch

[Update: A new post that follows-up this one clarifies why compiling enigma2 for this arch may not be sufficient for running it properly]

During the last days I’ve been asked to run enigma2 on the STb7109 cut 3.0 board, also called cocoref MB442, that is part of the sh4 arch family.

Enigma2 is a DVR application that runs on top of Linux and several of the standard Linux subsystems such as the Frame-buffer,  Linux DVB and V4L. It’s similar to applications such as MythTV, but it was designed and developed for running on embedded systems that have  limited resources compared to a Desktop PC.

I discovered that there are two different ways for doing this. The first one is through the use of a Makefile that downloads and compiles everything for you. This seems, of course, the easiest and fastest way for doing it, the only thing is that since it uses OpenEmbedded that takes a lot of time the first time for building the whole project since it downloads several GB of packages; then it compiles everything starting by generating the cross-toolchain; then it compiles all the requirements for enigma2; then it compiles enigma2 and generates a rootfs image ready for download to the target. This is a great procedure that eases your life after the first time, the big issue I had was that the enigma2 source didn’t compile, they gave me several errors.

After waiting several hours for download everything, several GB less on my hard disk and compiling errors, I decided to do it manually: the configure, make, make install way.

——————————————————————————————————-

License

The first issue that I found was that enigma2 has a weird proprietary license that forbids you to modify, compile or do anything with the source code that you can download from here.

The only thing you can do is to take the version you download and derive a version  that will be licensed under the GPLv2.

That said, everything I describe in this procedure was done with a  derived version of the official enigma2 source tree.

——————————————————————————————————-

Download the sources

The official enigma2 source code is obtained through the CVS tree. You can download a snapshot

cvs -z3 -d:pserver:anonymous@dreamboxupdate.com:/cvs co -P enigma2

or a certain release version:

cvs -z3 -d:pserver:anonymous@dreamboxupdate.com:/cvs co -r enigma2_rel24  enigma2

You will end up with a directory called enigma2.

According to the license, you need to derive a version of this directory in order to do whatever you want. I derived a version and start the following procedure.

——————————————————————————————————-

Requirements

Enigma2 needs several packages in order to compile, I describe the installation of the packages I needed. Notice that enigma2 needs some other packages that I already had in my rootfs like libpng. I described the installation of some of those packages here.

  • fribidi-0.10.9
  • id3lib-3.8.3
  • libsigc++-1.2.7
  • libdvbsi++-0.3.3
  • libxslt-1.1.16
  • libxmlccwrap-0.0.12

——————————————————————————————————-

Environment configuration

Suppose that the libraries will be installed in /opt/STM/STLinux-2.2/devkit/sh4/target and that the cross-toolchain (compiler, linker…) is in your path.

Set the following environment variables that will make our life easier:

$ export BUILD=i386-linux
$ export HOST=sh4-linux
$ export PREFIX=/opt/STM/STLinux-2.2/devkit/sh4/target

——————————————————————————————————-
Building enigma2 and its requirements

——————

fribidi

Configure, compile and install:

$ ./configure --build=$BUILD --host=$HOST --prefix=$PREFIX/usr/local
$ make
$ make install

——————

id3tag

Configure, compile and install:

./configure --build=$BUILD --host=$HOST --prefix=$PREFIX/usr/local 
--enable-debug=no
$ make
$ make install

——————

libsigc++

Configure, compile and install:

$ ./configure --build=$BUILD --host=$HOST --prefix=$PREFIX/usr/local
$ make
$ make install

——————

libdvbsi++

Configure, compile and install:

$ ./configure --build=$BUILD --host=$HOST --prefix=$PREFIX/usr/local
$ make
$ make install

——————

libxslt

Edit the configure file:

Before the if() around line 21190:

if ${XML_CONFIG} --libs print > /dev/null 2>&1

set the following variables:

XML_CONFIG=/opt/STM/STLinux-2.2/devkit/sh4/target/usr/bin/xml2-config
LIBXML_CONFIG_PREFIX="/opt/STM/STLinux-2.2/devkit/sh4/target/usr"
LIBXML_src="/opt/enigma/3rd_party/libxml2-2.6.30"

Configure, compile and install:

$ ./configure --build=$BUILD --host=$HOST --prefix=$PREFIX/usr/local 
  --without-debug 
  --without-debugger 
  --without-crypto
$ make
$ make install

——————

libxmlccwrap

Configure:

$ ./configure --build=$BUILD --host=$HOST --prefix=$PREFIX/usr/local

Edit the file xmlccwrap/Makefile

Set the var INCLUDES to the following value:

INCLUDES = -I$(top_srcdir) 
  -I/opt/STM/STLinux-2.2/devkit/sh4/target/usr/include/libxml2 
  -I/opt/STM/STLinux-2.2/devkit/sh4/target/usr/local/include

Set the var LIBS to the following value:

LIBS = /opt/STM/STLinux-2.2/devkit/sh4/target/usr/lib/libxml2.so 
/opt/STM/STLinux-2.2/devkit/sh4/target/usr/local/lib/libxslt.so

Edit the file testlib/Makefile

Set the var INCLUDES to the following value:

INCLUDES = -I$(top_srcdir) -I/opt/STM/STLinux-2.2/devkit/sh4/target/usr/include/libxml2

Set the var LIBS to the following value:

LIBS = /opt/STM/STLinux-2.2/devkit/sh4/target/usr/lib/libxml2.so 
/opt/STM/STLinux-2.2/devkit/sh4/target/usr/local/lib/libxslt.so

Compile and install:

$ make
$ make install

——————

enigma 2

Edit the configure file:

Around line 5339, before the comment

# should allow for checking of python version here...

set the following values:

PYTHON_FLAGS="-I/opt/STM/STLinux-2.2/devkit/sh4/target/usr/include"

and substitute the var name PYTHON_CPPFLAGS by PYTHON_FLAGS inside the for() block.

Around line 5372, before the comment

# Check for Python library path

set the following values:

PYTHON_FLAGS="-L/opt/STM/STLinux-2.2/devkit/sh4/target/usr/lib/python2.4"

and substitute the var name PYTHON_LDFLAGS by PYTHON_FLAGS inside the for() block.

Around line 7710, after the if() block

if test "$HAVE_XMLCCWRAP" = "yes"; then

set the following variable:

HAVE_XMLCCWRAP="yes"

Configure:

$ PYTHON=/usr/bin/python 
  FREETYPE_CFLAGS=-I$PREFIX/usr/include/freetype2 
  FREETYPE_LIBS="-L$PREFIX/usr/lib -lfreetype" 
  MAD_CFLAGS=-I$PREFIX/usr/include 
  MAD_LIBS="-L$PREFIX/usr/lib -lmad" 
  PNG_CFLAGS=-I$PREFIX/usr/include 
  PNG_LIBS="-L$PREFIX/usr/lib -lpng12" 
  XML2_CFLAGS=-I$PREFIX/usr/include/libxml2 
  XML2_LIBS="-L$PREFIX/usr/lib -lxml2" 
  FRIBIDI_CFLAGS=-I$PREFIX/usr/local/include 
  FRIBIDI_LIBS="-L$PREFIX/usr/local/lib -lfribidi" 
  ID3TAG_CFLAGS=-I$PREFIX/usr/local/include 
  ID3TAG_LIBS="-L$PREFIX/usr/local/lib -lid3" 
  SIGC_CFLAGS="-I$PREFIX/usr/local/include/sigc++-1.2 
  -I$PREFIX/usr/local/lib/sigc++-1.2/include" 
  SIGC_LIBS="-L$PREFIX/usr/local/lib -lsigc-1.2" 
  DVBSI_CFLAGS=-I$PREFIX/usr/local/include 
  DVBSI_LIBS="-L$PREFIX/usr/local/lib -ldvbsi++" 
  XMLCCWRAP_LIBS="-L$PREFIX/usr/local/lib -lxmlccwrap" 
  ./configure 
  --build=$BUILD 
  --host=$HOST 
  --prefix=$PREFIX/usr/local 
  --exec_prefix=$PREFIX/usr/local  
  --bindir=$PREFIX/usr/local/bin  
  --sbindir=$PREFIX/usr/local/sbin 
  --libexecdir=$PREFIX/usr/local/libexec  
  --datadir=$PREFIX/usr/local/share  
  --sysconfdir=$PREFIX/local/etc 
  --sharedstatedir=$PREFIX/usr/local/com  
  --localstatedir=$PREFIX/var  
  --libdir=$PREFIX/usr/local/lib 
  --includedir=$PREFIX/usr/local/include  
  --oldincludedir=$PREFIX/usr/local/include 
  --infodir=$PREFIX/usr/local/share/info  
  --mandir=$PREFIX/usr/local/share/man 
  --with-target=native 
  --with-libsdl=no

If you don’t have the same LCD, you will have to edit the file lib/gdi/lcd.cpp
You can comment must of the code using the NO_LCD define and adding it at the
end of the var DEFS in lib/gdi/Makefile

Edit the main/Makefile:

Add at the end of the var enigma2_LDADD the following values:

-lxslt -lutil -lpython2.4

Compile and install:

$ make
$ make install

Now you can connect to your target and happily execute it:

$ enigma2

That’s it.

Compiling a kernel driver that has multiple source files

All the drivers that I had dealt with until today where written in just one source file. But today I had several problems trying to compile a driver for a 2.6 kernel that had several source files. Most of the info I found like in the LKMPG and in LDD3, did not work for me. The problem was with my Makefile that I was writing in this way (the tabs after the all and clean targets were removed due to formatting issues):

PWD = $(shell pwd)
obj-m += modmain.o
modmain-objs += file1.o
all:
make -C /lib/modules/$(shell uname -r)/build SUBDIRS=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build SUBDIRS=$(PWD) clean

The files in my dir were:

$ ls
file1.c  file1.h  Makefile  modmain.c

If you follow the LKMPG or other sources you see that this seems correct: I wanted to compile a couple of files, modmain.c that contains the module init/exit funcs, and file.c that contains funcs used in modmain.c, and generate a driver module modmain.ko..
After compiling and linking without problems, I insmod the module but I didn’t see any of the printk() I wrote, in fact, the driver can be inserted and removed, but it does nothing.
After a while, I use nm to check which symbols were inside the driver and to my surprise the only symbols inside the .ko were

00000000 r __func__.1640
00000020 r __mod_vermagic5
00000000 r __module_depends
00000000 D __this_module
00000000 T init_stuff
U printk

No signs of init_module and friends. At this point I realized that the file modmain.c was not being compiled. In fact, my output from the Makefile was the following:

$ make
make -C /lib/modules/2.6.23.1-42.fc8/build SUBDIRS=/home/piter/code/c modules
make[1]: Entering directory '/usr/src/kernels/2.6.23.1-42.fc8-i686'
CC [M]  /home/piter/code/c/file1.o
LD [M]  /home/piter/code/c/modmain.o
Building modules, stage 2.
MODPOST 1 modules
CC      /home/piter/code/c/modmain.mod.o
LD [M]  /home/piter/code/c/modmain.ko
make[1]: Leaving directory '/usr/src/kernels/2.6.23.1-42.fc8-i686'

modmain.c was not being compiled!

After playing around with the Makefile I got the right file (again, the tabs after the all and clean targets were removed due to formatting issues):

PWD = $(shell pwd)
obj-m += mymod.o
mymod-objs += file1.o modmain.o
all:
make -C /lib/modules/$(shell uname -r)/build SUBDIRS=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build SUBDIRS=$(PWD) clean

Now, the output when compiling and linking is the following:

$ make
make -C /lib/modules/2.6.23.1-42.fc8/build SUBDIRS=/home/piter/code/c modules
make[1]: Entering directory '/usr/src/kernels/2.6.23.1-42.fc8-i686'
CC [M]  /home/piter/code/c/file1.o
CC [M]  /home/piter/code/c/modmain.o
LD [M]  /home/piter/code/c/mymod.o
Building modules, stage 2.
MODPOST 1 modules
CC      /home/piter/code/c/mymod.mod.o
LD [M]  /home/piter/code/c/mymod.ko
make[1]: Leaving directory '/usr/src/kernels/2.6.23.1-42.fc8-i686'

modmain.c is being compiled this time!
And nm says the following:

00000000 r __func__.1640
00000017 r __func__.8988
0000000b r __func__.8993
00000024 r __mod_author6
0000000c r __mod_description7
00000000 r __mod_license8
00000080 r __mod_vermagic5
00000060 r __module_depends
00000000 D __this_module
00000000 T cleanup_module
00000000 T init_module
00000000 T init_stuff
00000000 t my_mod_exit
00000000 t my_mod_init
U printk

The symbols used in modmain.c appear normally.

Conclusion
I changed the final driver name to mymod.ko and the file modmain.c is now part of the mymod-objs variable, in this way I’m sure that it’s compiled. Notice that the final driver name is different from any of the source files, including the file that contains the module_init/exit funcs.

Notice
Since I had the above mentioned issues for compiling a driver that has multiple source files following commonly linux kernel drivers docs and I have seen other people in the same situation, I decided to share the procedure that worked for me, but this does not mean in any way that the references I used were mistaken, most probably I missed something.

Cross-compiling GTK+ over DirectFB

This guide explains how to cross-compile GTK+ over DirectFB.

Intro

This guide is based in the wiki GTK on DirectFB for Embedded Systems from the DirectFB site, but it uses the latest packages available to this date. Since this procedure has some unstable packages and is still experimental, it’s not in the mentioned wiki. Hopefully, once this procedure becomes stable, the wiki will be updated.

I tested this procedure in a STMicroelectronics ST40 processor (SH architecture). If you’re using this processor, this is the configuration I have:

  • Board: STB7109 cut 3.0, also called cocoref_gold_7109
  • Linux distribution: STLinux 2.2
  • ST drivers and API: STFAE A16

Warnings

  1. This documentation assumes you already have DirectFB install in $PREFIX/usr. Change it accordingly to your installation.
  2. This documentation is still a work in progress, some steps of this procedure could be useless, ugly and/or dangerous. In order to make this procedure easier, it might be that there is the need of some patches.
  3. The autotools are not very user-friendly when cross-compiling, thus, several configure files and Makefile (that are generated by the autotools) have to be edited by hand.
  4. This procedure uses unstable or development versions of some packages like Glib and Cairo. However, the procedure should be the same for the latest stable release.
  5. GTK+ and all the packages underneath need a considerable amount of space and processor. If your embedded device provides a hard-drive/compact-flash and supports hardware accelerated graphics you can use GTK+ without problems.

Requirements

Typically, when developing applications for an embedded system a cross-toolchain is needed. If you already have a cross-toolchain you don’t have to worry about building it yourself. Otherwise, a well known resource for building one is http://www.kegel.com/crosstool

When developing for embedded systems, there are very few Linux distributions or packages that contain all the required software for building GTK+, therefore you have to build everything from scratch.

The order in which the packages are compiled is important since some of them won’t compile without the others. The packages, their versions and the order used for building GTK+ are the following:

  • Glib from git repository 15/02/08
  • atk-1.20.0
  • freetype-2.3.5
  • zlib-1.2.3
  • libxml2-2.6.30
  • fontconfig-2.5.0
  • libpng-1.2.24
  • Pixman from git repository 15/02/08
  • Cairo from git repository 15/02/08
  • pango-1.19.2
  • gtk+-2.12.3

Environment configuration

Suppose that the libraries will be installed in /opt/gtkdfb/usr/local (may be /opt/gtkdfb is the root fs of your embedded target) and that the cross-toolchain (compiler, linker…) is in your path.

Set the following environment variables that will make our life easier:

$ export PREFIX=/opt/gtkdfb/usr/local
$ export LD_LIBRARY_PATH=$PREFIX/lib
$ export PKG_CONFIG_PATH=$LD_LIBRARY_PATH/pkgconfig
$ export COMPILER=sh4-linux-gcc
$ export HOST=sh4-linux
$ export BUILD=i386-linux
$ export STRIP=sh4-linux-strip

Building GTK+ and its requirements

Glib

Edit the “configure” file:

Search for the texts “cannot run test program while cross compiling” and “cross-compiling”. Remove the following code that appears a couple of lines below the searched texts:

{ (exit 1); exit 1; };

Compile and install:

$ CC=$COMPILER ./configure --build=$BUILD --host=$HOST 
--prefix=$PREFIX --disable-selinux --disable-fam 
--disable-largefile --enable-debug=no --disable-gtk-doc 
--disable-man
$ make
$ make install

Atk

Compile and install:

$ CC=$COMPILER ./configure --host=$HOST --build=$BUILD 
--prefix=$PREFIX --disable-glibtest --disable-gtk-doc
$ make
$ make install

Freetype

Compile and install:

$ CC=$COMPILER ./configure --host=$HOST --build=$BUILD 
--prefix=$PREFIX
$ make
$ make install

Zlib

Compile and install:

$ CC=$COMPILER ./configure --prefix=$PREFIX --shared
$ make
$ make install

libxml2

Compile and install:

$ CC=$COMPILER ./configure --host=$HOST --build=$BUILD 
--prefix=$PREFIX --without-debug
$ make
$ make install

Fontconfig

Change the value of the flag –with-arch according to your architecture.

Compile and install:

$ CC=$COMPILER ./configure --build=$BUILD --host=$HOST 
--prefix=$PREFIX 
--with-freetype-config=$PREFIX/bin/freetype-config 
--enable-libxml2 --with-arch=sh4 --disable-docs
$ make
$ make install

libpng

Edit the “configure” file:
Set to ‘yes’ the following variable:

ac_cv_lib_z_zlibVersion=yes

Compile and install:

$ CC=$COMPILER ./configure --host=$HOST --build=$BUILD 
--prefix=$PREFIX
$ make
$ make install

Pixman

Compile and install:

$ CC=$COMPILER ./autogen.sh --host=$HOST --build=$BUILD 
--prefix=$PREFIX
$ make
$ make install

Cairo

Compile and install:

$ CC=$COMPILER 
directfb_CFLAGS="-I$PREFIX/../include/directfb" 
directfb_LIBS="$PREFIX/../lib/libdirectfb.so 
$PREFIX/../lib/libdirect.so 
$PREFIX/../lib/libfusion.so" 
png_CFLAGS="-I$PREFIX/include" 
png_LIBS=$PREFIX/lib/libpng12.so 
FONTCONFIG_CFLAGS="-I$PREFIX/include/fontconfig" 
FONTCONFIG_LIBS=$PREFIX/lib/libfontconfig.so 
FREETYPE_CFLAGS="-I$PREFIX/include/freetype2" 
FREETYPE_LIBS=$PREFIX/lib/libfreetype.so 
./configure --host=$HOST --build=$BUILD 
--prefix=$PREFIX --enable-directfb=yes --without-x 
--disable-xlib --disable-xlib-xrender --disable-win32 
--enable-pdf=no --enable-ps=no --enable-png
$ make
$ make install

Pango

Configure:

$ CC=$COMPILER 
GLIB_CFLAGS="-I$PREFIX/include/glib-2.0 
-I$PREFIX/lib/glib-2.0/include" 
GLIB_LIBS="$PREFIX/lib/libglib-2.0.so 
$PREFIX/lib/libgmodule-2.0.so 
$PREFIX/lib/libgobject-2.0.so 
$PREFIX/lib/libfontconfig.so 
$PREFIX/lib/libxml2.so 
$PREFIX/lib/libfreetype.so" 
CAIRO_CFLAGS="-I$PREFIX/include/cairo" 
CAIRO_LIBS=$PREFIX/lib/libcairo.so 
FONTCONFIG_CFLAGS="-I$PREFIX/include/fontconfig" 
FONTCONFIG_LIBS=$PREFIX/lib/libfontconfig.so 
FREETYPE_CFLAGS="-I$PREFIX/include/freetype2" 
FREETYPE_LIBS=$PREFIX/lib/libfreetype.so 
FREETYPE_CONFIG=$PREFIX/bin/freetype-config 
./configure --host=$HOST --build=$BUILD 
--prefix=$PREFIX --without-x

Edit the examples/Makefile:
Add to the GLIB_LIBS variable the following:

/opt/gtkdfb/usr/local/lib/libpng12.so 
/opt/gtkdfb/usr/lib/libdirectfb.so 
/opt/gtkdfb/usr/lib/libdirect.so 
/opt/gtkdfb/usr/lib/libfusion.so

Edit the tests/Makefile:
Set the LIBS variables to the following value:

LIBS = $(GLIB_LIBS)

Compile and install:

$ gmake
$ gmake install

GTK+

Configure:

$ CC=$COMPILER 
BASE_DEPENDENCIES_CFLAGS="-I$PREFIX/include 
-I$PREFIX/lib/glib-2.0/include -I$PREFIX/include/glib-2.0 
-I$PREFIX/include/pango-1.0 
-I$PREFIX/include/cairo 
-I$PREFIX/include/atk-1.0" 
BASE_DEPENDENCIES_LIBS="-L$PREFIX/lib 
$PREFIX/lib/libglib-2.0.so 
$PREFIX/lib/libgobject-2.0.so $PREFIX/lib/libgmodule-2.0.so 
$PREFIX/lib/libfontconfig.so $PREFIX/lib/libxml2.so" 
GLIB_CFLAGS="-I$PREFIX/include 
-I$PREFIX/lib/glib-2.0/include 
-I$PREFIX/include/glib-2.0" 
GLIB_LIBS="-L$PREFIX/lib 
$PREFIX/lib/libglib-2.0.so 
$PREFIX/lib/libgobject-2.0.so 
$PREFIX/lib/libgmodule-2.0.so 
$PREFIX/lib/libfontconfig.so 
$PREFIX/lib/libxml2.so" 
PANGO_CFLAGS="-I$PREFIX/include/pango-1.0" 
PANGO_LIBS="-L$PREFIX/lib 
$PREFIX/lib/libpango-1.0.so 
$PREFIX/lib/libpangoft2-1.0.so 
$PREFIX/lib/libpangocairo-1.0.so" 
GDK_DEP_CFLAGS="-pthread -I$PREFIX/include/glib-2.0 
-I$PREFIX/lib/glib-2.0/include 
-I$PREFIX/include/pango-1.0 
-I$PREFIX/include/cairo 
-I$PREFIX/include 
-D_REENTRANT -D_GNU_SOURCE 
-I$PREFIX/../include 
-I$PREFIX/../include/directfb" 
GDK_DEP_LIBS="-L$PREFIX/lib -lpthread -ldl -lpangocairo-1.0 
-lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lpng12 -lm 
$PREFIX/../lib/libdirectfb.so 
$PREFIX/../lib/libdirect.so 
$PREFIX/../lib/libfusion.so" 
GDK_PIXBUF_DEP_CFLAGS="-pthread -I$PREFIX/include/glib-2.0 
-I$PREFIX/lib/glib-2.0/include 
-I$PREFIX/include 
-I$PREFIX/../include" 
GDK_PIXBUF_DEP_LIBS="-L$PREFIX/lib 
-lgmodule-2.0 -ldl -lgobject-2.0 -lglib-2.0 -lpng12 -lm" 
GTK_DEP_CFLAGS="-pthread -I$PREFIX/include/glib-2.0 
-I$PREFIX/lib/glib-2.0/include 
-I$PREFIX/include/pango-1.0 
-I$PREFIX/include/cairo 
-I$PREFIX/include -D_REENTRANT -D_GNU_SOURCE 
-I$PREFIX/../include/directfb 
-I$PREFIX/include/atk-1.0 
-I$PREFIX/../include" 
GTK_DEP_LIBS="-L$PREFIX/lib 
-lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lgobject-2.0 -lgmodule-2.0 
-ldl -lglib-2.0 -lcairo -lpng12 -lm 
$PREFIX/../lib/libdirectfb.so 
$PREFIX/../lib/libdirect.so 
$PREFIX/../lib/libfusion.so" 
GDK_EXTRA_CFLAGS="-I$PREFIX/../include" 
GDK_EXTRA_LIBS="-L$PREFIX/../lib -lz -lpthread -ldl 
$PREFIX/../lib/libdirectfb.so 
$PREFIX/../lib/libdirect.so 
$PREFIX/../lib/libfusion.so" 
./configure 
--host=$HOST 
--build=$BUILD 
--prefix=$PREFIX 
--with-gdktarget=directfb 
--without-libtiff 
--disable-glibtest 
--disable-largefile 
--disable-modules 
--with-included-loaders=gif,jpeg,png,xpm

Dangerous/ugly step:

GTK needs a cairo-pdf/ps printing support for compiling, but it’s unlikely that PDF/PS will be needed in an embedded system. There is no flag to compile it without this setting. There are some patches in development to solve this issue, meanwhile it was compiled without the cairo-pdf support by doing the following very ugly and dangerous step. If you want to add to add PDF/PS support you can try Poppler.

Edit the files:

  • gtk/gtkprintoperation.c
  • gtk/gtkprintoperation-unix.c
  • modules/printbackends/lpr/gtkprintbackendlpr.c
  • modules/printbackends/file/gtkprintbackendfile.c

Comment the lines in all these files that contains the following includes or function calls:

#include 
#include 
cairo_pdf_surface_set_size()
cairo_pdf_surface_create()
cairo_ps_surface_create_for_stream()

Compile and install:

$ make
$ make install

That’s it.
Keep in mind that this procedure is still experimental and uses unstable versions of Glib and Cairo. In fact, with a stable version of Cairo, there’s no need for compiling Pixman because it’s already included in Cairo.

Any help, suggestions and/or ideas are welcome.