summaryrefslogtreecommitdiff
path: root/Building.mdwn
blob: 75ab95b5c7fc2f903ccd6925c528bfe7971612f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
**Contents** [[!toc ]] 


# Building the DRI with X.org and Mesa

This is a basic guide to building DRI from source.  This guide **only** covers building the client-side 3D drivers.  Since the transition to the modular X.org build, building an X-server and 2D drivers is beyond the scope of this document.  That information can be found in the [[X.org Modular Developer Guide|http://wiki.x.org/wiki/ModularDevelopersGuide]].  You will most probably need to (re)compile also at least the keyboard and mouse drivers, in addition to a video card 2D driver. 

The 2D drivers with DRI support, server-side GLX support and the GL library capable of loading DRI 3D drivers are developed in X.org's CVS. The 3D drivers, though, live in the Mesa tree, so you will have to check out the Mesa git tree.  You should also get the DRM git tree for up-to-date kernel modules. The following instructions will guide you through the process step by step. 

**Warning:** In case you didn't notice, you are about to compile and install experimental software. This will allow you to test the latest features and bug fixes. It may, however, also introduce new bugs. Be prepared for problems every now and then. 


## Dependencies

You need a current version (7.4, ie. xserver 1.5 as of this writing) of X.org (core and development packages) installed on your system. In particular, you need these X.org components: 

* proto/glproto [[1.4.14|http://xorg.freedesktop.org/releases/individual/proto/glproto-1.4.14.tar.bz2]] or `git://anongit.freedesktop.org/git/xorg/proto/glproto` 
* proto/xf86vidmodeproto `git://anongit.freedesktop.org/git/xorg/proto/xf86vidmodeproto` 
* lib/libXxf86vm `git://anongit.freedesktop.org/git/xorg/lib/libXxf86vm` 
* lib/libXmu `git://anongit.freedesktop.org/git/xorg/lib/libXmu` 
* dri2proto `git://anongit.freedesktop.org/xorg/proto/dri2proto`

## Optional

* libva `git://anongit.freedesktop.org/vaapi/libva`

### On Debian/Ubuntu

If you are using Debian or Ubuntu you can install the packages with: 

    apt-get build-dep libdrm mesa
    apt-get install linux-headers-`uname -r`
    apt-get install libxi-dev libxmu-dev x11proto-xf86vidmode-dev
    apt-get install git autoconf automake libtool

### Getting Mesa

The clean Mesa source tree takes about 32MB of disk space. 

    git clone git://anongit.freedesktop.org/git/mesa/mesa

## Building Mesa 3D drivers

The DRI 3D drivers are now built from the Mesa source. 

    cd mesa
    ./autogen.sh

**Note:** `mesa` installs to `/usr/local/lib` by default.  To install in `/usr/lib` run: 

    ./configure --prefix=/usr

Choose the right configure options depending on the hardware architecture you're compiling for.   
 See [[http://www.mesa3d.org/autoconf.html|http://www.mesa3d.org/autoconf.html]] for more information about configuring mesa or read the output from: 

    ./configure --help

Now you're ready to compile it: 

    make

## Installing the 3D drivers

After compiling the Mesa tree, the 3D drivers can be found in `mesa/lib`. There are two ways of using them: installing them in the destined place, or telling X where to find them. 

1. Install the drivers to `/usr/lib/`: 

Run as root, to install: 

    make install

2. Or set the environment variable LIBGL_DRIVERS_PATH to point to `<path to Mesa>/lib`, and also preload the newly built `libGL.so`: 

    export LIBGL_DRIVERS_PATH=<path to Mesa>/lib
    export LD_PRELOAD=<path to Mesa>/lib/libGL.so.1

To make these settings persistent, you'll have to add them to `.bashrc` or a similar login script.

## Installing to a non-default prefix

Working with "a separate prefix" is working with libraries and binaries (well, anything produced by 'make install' in an autotooled project really) installed in a different directory than the system-wide ones (/usr or even /usr/local that can become quite messy).  lt is the preferred way to hack on a full stack, not pollute your base distribution and has several advantages:

* You can hack on the whole stack without the fear of not being able to run your desktop environment you're working with if something goes wrong.
* More often than not, one needs a relatively recent library that your distribution doesn't ship with (say a recent libdrm). When working with the dependencies in a prefix, it's just a matter of recompiling it.

Let's take an example to make the discussion easier:

* we want to copile libdrm and intel-gpu-tools (because intel-gpu-needs needs a more recent libdrm than the one coming with your distribution).
* we want to use the ~/gfx directory for our work
* git trees with be cloned in ~/gfx/sources
* ~/gfx/install is chosen as the prefix.

First, let's clone the needed git repositories:

    $ mkdir -p ~/gfx/sources ~/gfx/install
    $ git clone git://anongit.freedesktop.org/mesa/drm ~/gfx/sources/libdrm
    $ git clone git://anongit.freedesktop.org/xorg/app/intel-gpu-tools ~/gfx/sources/intel-gpu-tools

Then you need to source a script that will set-up your environment with a few variables to tell the system to use the prefix (both at run-time and compile-time). A minimal version of that script for our example is (I store my per-project setup scripts to source at the root of the project, in our case ~/gfx):

    $ cat ~/gfx/setup-env 
    PROJECT=~/gfx
    export PATH=$PROJECT/install/bin:$PATH
    export LD_LIBRARY_PATH=$PROJECT/install/lib:$LD_LIBRARY_PATH
    export PKG_CONFIG_PATH=$PROJECT/install/lib/pkgconfig:$PKG_CONFIG_PATH
    export ACLOCAL_FLAGS="-I $PROJECT/install/share/aclocal $ACLOCAL_FLAG" 

    $ source ~/gfx/setup-env 

Then it's time to compile libdrm, telling the <code>configure</code> script that we want to install it in in our prefix:

    $ cd ~/gfx/sources/libdrm
    $ ./autogen.sh --prefix=/home/damien/gfx/install
    $ make
    $ make install

Note that you don't need to run "sudo make install" since we'll be installing in our prefix directory that is writeable by the current user.

Now it's time to compile i-g-t:
    $ cd ~/gfx/sources/intel-gpu-tools
    $ ./autogen.sh --prefix=/home/damien/gfx/install
    $ make
    $ make install

The configure script may complain about dependencies (eg. cairo, SWIG,...). Different ways to solve those:

* For dependencies not directly linked with the graphics stack (like SWIG), it's recommended to use the development package provided by the distribution
* For old enough dependencies that don't change very often (like cairo) you can use the distribution development package or compile them in your prefix
* For dependencies more recent than your distribution ones, you need to install them in the chosen prefix. 

### Damien's minimal environment script

    PROJECT=~/gfx
    export PATH=$PROJECT/install/bin:$PATH
    export LD_LIBRARY_PATH=$PROJECT/install/lib:$LD_LIBRARY_PATH
    export PKG_CONFIG_PATH=$PROJECT/install/lib/pkgconfig:$PKG_CONFIG_PATH
    export ACLOCAL_FLAGS="-I $PROJECT/install/share/aclocal $ACLOCAL_FLAG"

### Ville's environment script


    #!/bin/sh
    
    prepend_env ()
    {
        eval ${1}="${2}\${${1}:+:}\$${1}"
    }
    
    append_env ()
    {
        eval ${1}="\$${1}\${${1}:+:}${2}"
    }
    
    PS1="[`basename $PWD`]$PS1"
    PREFIX=$PWD
    LINGUAS="en fi"

    prepend_env PATH $PREFIX/bin
    prepend_env MANPATH $PREFIX/man
    prepend_env MANPATH $PREFIX/share/man
    if [ -n "$MANPATH" ]; then
        MANPATH=$MANPATH:
    fi
    prepend_env LD_LIBRARY_PATH $PREFIX/lib
    prepend_env PKG_CONFIG_PATH $PREFIX/lib/pkgconfig
    prepend_env PERL5LIB $PREFIX/lib/perl
    prepend_env PYTHONDIR $PREFIX/lib/python
    prepend_env GST_PLUGIN_PATH $PREFIX/lib/gstreamer-0.10
    prepend_env LIBGL_DRIVERS_PATH $PREFIX/lib/dri

    export PREFIX
    export LINGUAS
    export PATH
    export MANPATH
    export LD_LIBRARY_PATH
    export PKG_CONFIG_PATH
    export PERL5LIBDIR
    export PYTHONDIR
    export GST_PLUGIN_PATH
    export LIBGL_DRIVERS_PATH