blob: 2ba7cb8677b34058c44c19923d80bb560c9267fd [file] [log] [blame]
Brian Paul0b27ace2003-03-08 17:38:57 +00001<HTML>
2
Brian Paul49a3fab2008-12-30 07:57:16 -07003<TITLE>Compiling and Installing</TITLE>
Brian Paul0b27ace2003-03-08 17:38:57 +00004
Brian Paul36da0452005-01-20 03:55:10 +00005<link rel="stylesheet" type="text/css" href="mesa.css"></head>
6
7<BODY>
Brian Paul0b27ace2003-03-08 17:38:57 +00008
Brian Paul5f37abf2003-09-05 14:47:07 +00009
Brian Paul49a3fab2008-12-30 07:57:16 -070010<H1>Compiling and Installing</H1>
Brian Paul5f37abf2003-09-05 14:47:07 +000011
12<ol>
Brian Paul7103a182012-04-19 09:56:36 -060013<li><a href="#prereq-general">Prerequisites for building</a>
Brian Paul49a3fab2008-12-30 07:57:16 -070014 <ul>
Brian Paul7103a182012-04-19 09:56:36 -060015 <li><a href="#prereq-general">General prerequisites</a>
16 <li><a href="#prereq-dri">For DRI and hardware acceleration</a>
Brian Paul49a3fab2008-12-30 07:57:16 -070017 </ul>
Brian Paul7103a182012-04-19 09:56:36 -060018<li><a href="#autoconf">Building with autoconf (Linux/Unix/X11)</a>
19<li><a href="#scons">Building with SCons (Windows)</a>
20<li><a href="#legacy">Building with legacy Makefiles (deprecated)</a>
21<li><a href="#other">Building for other systems</a>
22<li><a href="#libs">Library Information</a>
23<li><a href="#pkg-config">Building OpenGL programs with pkg-config
Brian Paul5f37abf2003-09-05 14:47:07 +000024</ol>
Brian Paul0b27ace2003-03-08 17:38:57 +000025
Brian Paul8bd70a72008-05-27 13:27:57 -060026
Brian Paul32a11e52011-04-04 11:30:46 -060027<a name="prereq-general">
Brian Paul7103a182012-04-19 09:56:36 -060028<h1>1. Prerequisites for building</h1>
Brian Paul32a11e52011-04-04 11:30:46 -060029
Brian Paul7103a182012-04-19 09:56:36 -060030<h2>1.1 General</h2>
Brian Paul32a11e52011-04-04 11:30:46 -060031<ul>
32<li>lex / yacc - for building the GLSL compiler.
33On Linux systems, flex and bison are used.
34Versions 2.5.35 and 2.4.1, respectively, (or later) should work.
Brian Paul4f869e92012-03-05 13:02:59 -070035<br>
36<br>
37On Windows with MinGW, install flex and bison with:
38<pre>mingw-get install msys-flex msys-bison</pre>
Brian Paul32a11e52011-04-04 11:30:46 -060039</li>
40<li>python - Python is needed for building the Gallium components.
41Version 2.6.4 or later should work.
Brian Paul4f869e92012-03-05 13:02:59 -070042<br>
43<br>
44To build OpenGL ES 1.1 and 2.0 you'll also need
45<a href="http://xmlsoft.org/sources/win32/python/libxml2-python-2.7.7.win32-py2.7.exe">libxml2-python</a>.
Brian Paul32a11e52011-04-04 11:30:46 -060046</li>
47</ul>
48
49
50<a name="prereq-dri">
Brian Paul7103a182012-04-19 09:56:36 -060051<h3>1.2 For DRI and hardware acceleration</h3>
Brian Paul5f37abf2003-09-05 14:47:07 +000052
53<p>
Brian Paul90692482009-10-08 20:49:32 -060054The following are required for DRI-based hardware acceleration with Mesa:
Brian Paul8bd70a72008-05-27 13:27:57 -060055</p>
56
Brian Paul49a3fab2008-12-30 07:57:16 -070057<ul>
Brian Paul7103a182012-04-19 09:56:36 -060058<li><a href="http://xorg.freedesktop.org/releases/individual/proto/"
59target="_parent">dri2proto</a> version 2.6 or later
Brian Paul2c56dd72009-01-10 11:52:55 -070060<li><a href="http://dri.freedesktop.org/libdrm/" target="_parent">libDRM</a>
Brian Paul7103a182012-04-19 09:56:36 -060061version 2.4.33 or later
Brian Paul2c56dd72009-01-10 11:52:55 -070062<li>Xorg server version 1.5 or later
Brian Paul7103a182012-04-19 09:56:36 -060063<li>Linux 2.6.28 or later
Brian Paul49a3fab2008-12-30 07:57:16 -070064</ul>
Brian Paul8bd70a72008-05-27 13:27:57 -060065</p>
Alex Hultmanc3fe44c2012-03-16 09:46:42 -060066<p>
67If you're using a fedora distro the following command should install all
68the needed dependencies:
69<pre>
70 sudo yum install flex bison imake libtool xorg-x11-proto-devel libdrm-devel \
71 gcc-c++ xorg-x11-server-devel libXi-devel libXmu-devel libXdamage-devel git \
72 expat-devel llvm-devel
73</pre>
Brian Paul8bd70a72008-05-27 13:27:57 -060074
75
Brian Paul7103a182012-04-19 09:56:36 -060076
Brian Paul49a3fab2008-12-30 07:57:16 -070077<a name="autoconf">
Brian Paul7103a182012-04-19 09:56:36 -060078<H1>2. Building with autoconf (Linux/Unix/X11)</H1>
Brian Paul8bd70a72008-05-27 13:27:57 -060079
80<p>
Brian Paul7103a182012-04-19 09:56:36 -060081The primary method to build Mesa on Unix systems is with autoconf.
82</p>
Brian Paul8bd70a72008-05-27 13:27:57 -060083
84<p>
Brian Paul7103a182012-04-19 09:56:36 -060085The general approach is the standard:
86<pre>
87 ./configure
88 make
89 sudo make install
90</pre>
91But please read the <a href="autoconf.html">detailed autoconf instructions</a>
92for more details.
93</p>
94
95
96
97<a name="scons">
98<H1>3. Building with SCons (Windows)</H1>
99
100<p>
101To build Mesa with SCons on Linux or Windows do
102</p>
103<pre>
104 scons
105</pre>
106<p>
107The build output will be placed in
108build/<i>platform</i>-<i>machine</i>-<i>debug</i>/..., where <i>platform</i> is for
109example linux or windows, <i>machine</i> is x86 or x86_64, optionally followed
110by -debug for debug builds.
111</p>
112
113<p>
114To build Mesa with SCons for Windows on Linux using the MinGW crosscompiler toolchain do
115</p>
116<pre>
117 scons platform=windows toolchain=crossmingw machine=x86 mesagdi libgl-gdi
118</pre>
119<p>
120This will create:
121</p>
122<ul>
123<li>build/windows-x86-debug/mesa/drivers/windows/gdi/opengl32.dll &mdash; Mesa + swrast, binary compatible with Windows's opengl32.dll
124<li>build/windows-x86-debug/gallium/targets/libgl-gdi/opengl32.dll &mdash; Mesa + Gallium + softpipe, binary compatible with Windows's opengl32.dll
125</ul>
126<p>
127Put them all in the same directory to test them.
128</p>
129
130
131
132<a name="legacy">
133<h1>4. Building with legacy Makefiles (deprecated)</h1>
134
135<p>
136The legacy Mesa build system is based on a collection of pre-defined
Brian Paul8bd70a72008-05-27 13:27:57 -0600137system configurations.
Brian Paul7103a182012-04-19 09:56:36 -0600138Some of these might work for older systems not supported by autoconf.
Brian Paul8bd70a72008-05-27 13:27:57 -0600139</p>
140<p>
Brian Paul49a3fab2008-12-30 07:57:16 -0700141To see the list of configurations, just type <code>make</code>.
142Then choose a configuration from the list and type <code>make</code>
143<em>configname</em>.
Brian Paul8bd70a72008-05-27 13:27:57 -0600144</p>
145
146<p>
147Mesa may be built in several different ways using the predefined configurations:
Brian Paul5f37abf2003-09-05 14:47:07 +0000148</p>
Brian Paulf87bb142005-07-21 18:45:44 +0000149<ul>
Brian Paul5dbd0a42006-06-08 23:42:07 +0000150<li><b><em>Stand-alone/Xlib mode</em></b> - Mesa will be compiled as
Brian Paulf87bb142005-07-21 18:45:44 +0000151a software renderer using Xlib to do all rendering.
Brian Paul5dbd0a42006-06-08 23:42:07 +0000152The libGL.so library will be a self-contained rendering library that will
153allow you to run OpenGL/GLX applications on any X server (regardless of
154whether it supports the GLX X server extension).
Brian Pauld9eff8b2006-07-12 20:14:43 +0000155You will <em>not</em> be able to use hardware 3D acceleration.
Brian Paulb0eee792003-03-16 16:43:04 +0000156<p>
Brian Paul49a3fab2008-12-30 07:57:16 -0700157To compile stand-alone Mesa type <code>make</code> in the top-level directory.
Brian Paul0b27ace2003-03-08 17:38:57 +0000158You'll see a list of supported system configurations.
Brian Paul5f37abf2003-09-05 14:47:07 +0000159Choose one from the list (such as linux-x86), and type:
160</p>
161<pre>
162 make linux-x86
163</pre>
Brian Paulf87bb142005-07-21 18:45:44 +0000164<p>This will produce libGL.so and several other libraries</p>
165</li>
166
Brian Paul5dbd0a42006-06-08 23:42:07 +0000167<li><b><em>DRI/accelerated</em></b> - The DRI hardware drivers for
168accelerated OpenGL rendering (for ATI, Intel, Matrox, etc) will be built.
169The libGL.so library will support the GLX extension and will load/use
170the DRI hardware drivers.
171
Brian Paul5dbd0a42006-06-08 23:42:07 +0000172
173<p>
174Build Mesa and the DRI hardware drivers by running
Brian Paulf87bb142005-07-21 18:45:44 +0000175</p>
176<pre>
Brian Paul5dbd0a42006-06-08 23:42:07 +0000177 make linux-dri
Brian Paulf87bb142005-07-21 18:45:44 +0000178</pre>
179<p>
180There are also <code>linux-dri-x86</code>, <code>linux-dri-x86-64</code>,
Brian Paul5dbd0a42006-06-08 23:42:07 +0000181and <code>linux-ppc</code> configurations which are optimized for those
182architectures.
Brian Paulf87bb142005-07-21 18:45:44 +0000183</p>
Brian Paul8bd70a72008-05-27 13:27:57 -0600184<p>
185Make sure you have the prerequisite versions of DRM and Xserver mentioned
186above.
187</p>
Brian Paulf87bb142005-07-21 18:45:44 +0000188
Brian Paulf87bb142005-07-21 18:45:44 +0000189</ul>
190
191
192<p>
193Later, if you want to rebuild for a different configuration run
Brian Paul26f334a2004-03-26 15:20:08 +0000194<code>make realclean</code> before rebuilding.
Brian Paul0b27ace2003-03-08 17:38:57 +0000195</p>
196
Brian Paul26f334a2004-03-26 15:20:08 +0000197
Brian Paul5f37abf2003-09-05 14:47:07 +0000198
Brian Paul49a3fab2008-12-30 07:57:16 -0700199<a name="install">
Brian Paul7103a182012-04-19 09:56:36 -0600200<H2>Installing the header and library files</H2>
Brian Paul0b27ace2003-03-08 17:38:57 +0000201
202<p>
203The standard location for the OpenGL header files on Unix-type systems is
204in <code>/usr/include/GL/</code>.
205The standard location for the libraries is <code>/usr/lib/</code>.
206For more information see, the
207<a href="http://oss.sgi.com/projects/ogl-sample/ABI/" target="_parent">
208Linux/OpenGL ABI specification</a>.
209</p>
210
211<p>
212If you'd like Mesa to co-exist with another implementation of OpenGL that's
213already installed, you'll have to choose different directories, like
214<code>/usr/local/include/GL/</code> and <code>/usr/local/lib/</code>.
215</p>
216
217<p>
Brian Pauld9eff8b2006-07-12 20:14:43 +0000218To install Mesa's headers and libraries, run <code>make install</code>.
219But first, check the Mesa/configs/default file and examine the values
220of the <b>INSTALL_DIR</b> and <b>DRI_DRIVER_INSTALL_DIR</b> variables.
Dan Nicholsonf5557c32007-09-12 09:57:53 -0600221Change them if needed, then run <code>make install</code>.
222</p>
223
224<p>
225The variable
226<b>DESTDIR</b> may also be used to install the contents to a temporary
227staging directory.
228This can be useful for package management.
229For example: <code>make install DESTDIR=/somepath/</code>
Brian Paul0b27ace2003-03-08 17:38:57 +0000230</p>
Brian Paul0b27ace2003-03-08 17:38:57 +0000231
232<p>
Brian Pauld9eff8b2006-07-12 20:14:43 +0000233Note: at runtime you can use the LD_LIBRARY_PATH environment variable
234(on Linux at least) to switch
235between the Mesa libraries and other vendor's libraries whenever you want.
Brian Paul5f37abf2003-09-05 14:47:07 +0000236This is a handy way to compare multiple OpenGL implementations.
Brian Paul0b27ace2003-03-08 17:38:57 +0000237</p>
238
Brian Paul5f37abf2003-09-05 14:47:07 +0000239
Brian Paul7103a182012-04-19 09:56:36 -0600240
241
242<a name="other">
243<H1>5. Building for other systems</H1>
244
245<p>
246Documentation for other environments (some may be very out of date):
247</p>
248
249<UL>
250<li><A HREF="README.VMS">README.VMS</A> - VMS
251<LI><A HREF="README.CYGWIN">README.CYGWIN</A> - Cygwin
252<LI><A HREF="README.WIN32">README.WIN32</A> - Win32
253</UL>
254
255
256
257<a name="libs">
258<H1>6. Library Information</H1>
259
260<p>
261When compilation has finished, look in the top-level <code>lib/</code>
262(or <code>lib64/</code>) directory.
263You'll see a set of library files similar to this:
264</p>
265<pre>
266lrwxrwxrwx 1 brian users 10 Mar 26 07:53 libGL.so -> libGL.so.1*
267lrwxrwxrwx 1 brian users 19 Mar 26 07:53 libGL.so.1 -> libGL.so.1.5.060100*
268-rwxr-xr-x 1 brian users 3375861 Mar 26 07:53 libGL.so.1.5.060100*
269lrwxrwxrwx 1 brian users 11 Mar 26 07:53 libGLU.so -> libGLU.so.1*
270lrwxrwxrwx 1 brian users 20 Mar 26 07:53 libGLU.so.1 -> libGLU.so.1.3.060100*
271-rwxr-xr-x 1 brian users 549269 Mar 26 07:53 libGLU.so.1.3.060100*
272lrwxrwxrwx 1 brian users 14 Mar 26 07:53 libOSMesa.so -> libOSMesa.so.6*
273lrwxrwxrwx 1 brian users 23 Mar 26 07:53 libOSMesa.so.6 -> libOSMesa.so.6.1.060100*
274-rwxr-xr-x 1 brian users 23871 Mar 26 07:53 libOSMesa.so.6.1.060100*
275</pre>
276
277<p>
278<b>libGL</b> is the main OpenGL library (i.e. Mesa).
279<br>
280<b>libGLU</b> is the OpenGL Utility library.
281<br>
282<b>libOSMesa</b> is the OSMesa (Off-Screen) interface library.
283</p>
284
285<p>
286If you built the DRI hardware drivers, you'll also see the DRI drivers:
287</p>
288<pre>
289-rwxr-xr-x 1 brian users 16895413 Jul 21 12:11 i915_dri.so
290-rwxr-xr-x 1 brian users 16895413 Jul 21 12:11 i965_dri.so
291-rwxr-xr-x 1 brian users 11849858 Jul 21 12:12 r200_dri.so
292-rwxr-xr-x 1 brian users 16050488 Jul 21 12:11 r300_dri.so
293-rwxr-xr-x 1 brian users 11757388 Jul 21 12:12 radeon_dri.so
294</pre>
295
296<p>
297If you built with Gallium support, look in lib/gallium/ for Gallium-based
298versions of libGL and device drivers.
299</p>
300
301
Brian Paul49a3fab2008-12-30 07:57:16 -0700302<a name="pkg-config">
Brian Paul7103a182012-04-19 09:56:36 -0600303<H1>7. Building OpenGL programs with pkg-config</H1>
Brian5bba58c2007-09-12 10:11:49 -0600304
305<p>
306Running <code>make install</code> will install package configuration files
307for the pkg-config utility.
308</p>
309
310<p>
311When compiling your OpenGL application you can use pkg-config to determine
312the proper compiler and linker flags.
313</p>
314
315<p>
316For example, compiling and linking a GLUT application can be done with:
317</p>
318<pre>
319 gcc `pkg-config --cflags --libs glut` mydemo.c -o mydemo
320</pre>
321
322<br>
Brian Paul5f37abf2003-09-05 14:47:07 +0000323
Brian Paul5f37abf2003-09-05 14:47:07 +0000324
Brian Paul0b27ace2003-03-08 17:38:57 +0000325</body>
326</html>