0fb38352dd5556546f6a1d94cd59ccbb0ffc4f65
[ikiwiki.git] / docs / developer / manually_build_x_and_beyond / index.mdwn
1 # Manually Building X and Beyond
2
3 We try something **ill-advised**, we build a separate version of X.org in another directory, say */opt/xbeta*,
4 on the same machine where we have installed the latext pkgsrc.  We do this because we have no choice but to
5 use the graphics hardware on this machine, but the risk is that it is very easy to link the wrong libraries
6 from pkgsrc.
7
8 ## Disclaimer
9
10 The following notes describe alterations to one's system that may leave the graphical user interface based
11 on X.org unusable.  Use at one's own risk.  Because the risk of damaging one's system is so great, I refuse
12 to provide ready-to-run scripts.
13
14 ## Installing from pkgsrc
15
16 ### GNU m4 1.4.14 and bison 2.4.2
17
18 Patch both *devel/m4* and *devel/bison* using the patch idea from:
19 <http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=43098>
20
21 Unfortunately the problems are in the *work* directories so that one needs the knowledge from
22 <http://www.netbsd.org/docs/pkgsrc/components.html>
23 to even get the patches to be applied.
24
25 Install *pkgtools/pkgdiff*.
26
27 ### gstreamer 0.10
28
29 As of 2010-05-09, I find it necessary on x86_64 to use the following patch for
30 pkgsrc gstreamer0.10, an eventual dependency of the full xfce desktop:
31
32     --- pkgsrc/multimedia/gstreamer0.10/Makefile.orig       2010-03-29 16:04:23 -0700
33     +++ pkgsrc/multimedia/gstreamer0.10/Makefile    2010-03-29 16:09:04 -0700
34     @@ -44,6 +44,11 @@
35  
36      .include "../../mk/bsd.prefs.mk"
37  
38     +# __udivti3 error otherwise
39     +.if ${OPSYS} == "DragonFly" && ${MACHINE_ARCH} == "x86_64"
40     +MAKEFLAGS+=    CCVER=gcc44
41     +.endif
42     +
43      .if ${OPSYS} == "NetBSD"
44      # We must have a glib2 compiled with the RTLD_GLOBAL fix; if not, plugins
45      # won't work at all.
46
47 See for example the following bug report for more details:
48 <http://mail-index.netbsd.org/pkgsrc-bugs/2010/03/30/msg037304.html>
49
50 ### expat and gettext
51
52 We start with installing into */opt/xbeta* [expat 2.0.1](http://sourceforge.net/projects/expat/)
53 and [gettext 0.17](http://www.gnu.org/software/gettext/).
54
55 ### Git repository for most of X.org
56
57 We use the following listing:
58
59 [freedesktop.org git repository browser](http://cgit.freedesktop.org/)
60
61 One can easily script getting, updating, and building the projects listed on that page.
62
63 ### Example of using ldd
64
65     $ ldd ./libXau.so.6          
66     ./libXau.so.6:
67         libc.so.7 => /usr/lib/libc.so.7 (0x800640000)
68     $ ldd ./libXdmcp.so.6        
69     ./libXdmcp.so.6:
70         libc.so.7 => /usr/lib/libc.so.7 (0x800640000)
71
72 ### libxcb problem with Python 2.6 cElementTree
73
74 Library *xcb/libxcb* unfortunately needs to be built early and there is a catch for
75 using pkgsrc Python 2.6.  Unfortunately at the current time not all of
76 *cElementTree* appears to be functional; therefore, one needs a patch similar to
77
78     diff --git a/src/c_client.py b/src/c_client.py
79     index d86d05e..36a7039 100755
80     --- a/src/c_client.py
81     +++ b/src/c_client.py
82     @@ -1,5 +1,5 @@
83      #!/usr/bin/env python
84     -from xml.etree.cElementTree import *
85     +from xml.etree.ElementTree import *
86      from os.path import basename
87      import getopt
88      import sys
89
90 As of May 20, 2010, the situation for libxcb seems to be more complicated.  The latest *xcb/proto* needs
91 to be installed.  If one does not wish to install on top of one's current Python modules,
92 define
93
94     export PYTHONPATH=${PREFIX}/lib/python2.6/site-packages
95
96 and apply a patch similar to below to change from using Python 2.6's *cElementTree* to *ElementTree*
97
98     diff --git a/xcbgen/matcher.py b/xcbgen/matcher.py
99     index e7958fa..16e8273 100644
100     --- a/xcbgen/matcher.py
101     +++ b/xcbgen/matcher.py
102     @@ -7,7 +7,7 @@ we do not create a new type object, we just record the existing one under a new
103      '''
104
105      from os.path import join
106     -from xml.etree.cElementTree import parse
107     +from xml.etree.ElementTree import parse
108
109      import state
110      from xtypes import *
111     diff --git a/xcbgen/state.py b/xcbgen/state.py
112     index 51efc94..e72dc3e 100644
113     --- a/xcbgen/state.py
114     +++ b/xcbgen/state.py
115     @@ -2,7 +2,7 @@
116      This module contains the namespace class and the singleton module class.
117      '''
118      from os.path import dirname, basename
119     -from xml.etree.cElementTree import parse
120     +from xml.etree.ElementTree import parse
121
122      import matcher
123      from error import *
124
125 ### libXext
126
127       CCLD   libXext.la
128     /usr/libexec/binutils217/elf/ld: .libs/extutil.o: relocation R_X86_64_PC32 against `xgeExtRegister' can not be used when making a shared   object; recompile with -fPIC
129     /usr/libexec/binutils217/elf/ld: final link failed: Bad value
130
131 Use the following patch from <http://lists.x.org/archives/xorg-devel/2009-November/003724.html>
132
133     diff --git a/src/Xge.c b/src/Xge.c
134     index 7a583e5..2ea5d27 100644
135     --- a/src/Xge.c
136     +++ b/src/Xge.c
137     @@ -294,7 +294,7 @@ _xgeEventToWire(Display* dpy, XEvent* re, xEvent* event)
138      /*
139       * Extensions need to register callbacks for their events.
140       */
141     -Bool
142     +_X_HIDDEN Bool
143      xgeExtRegister(Display* dpy, int offset, XExtensionHooks* callbacks)
144      {
145          XGEExtNode* newExt;
146
147 ### FreeType 2
148
149 We install [FreeType 2.3.12](http://www.freetype.org/).  It appears that *GNUMAKE=gmake* is required.
150 Most of the X.org projects use *autogen.sh*, but here we use a standard call to *configure* somewhat
151 similar to:
152
153         export ACLOCAL="aclocal -I ${PREFIX}/share/aclocal"
154         export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
155         GNUMAKE=gmake ./configure --prefix=${PREFIX} CPPFLAGS="-I${PREFIX}/include -I${PREFIX}/X11/include" LDFLAGS="-L${PREFIX}/lib -Wl,-rpath -Wl,${PREFIX}/lib -L${PREFIX}/X11/lib -Wl,-rpath -Wl,${PREFIX}/lib/X11"
156
157 where *$PREFIX* is where we install X.org, say */opt/xbeta*,
158 the first two exports of *ACLOCAL* and *PKG_CONFIG_PATH* occur for most X.org projects,
159 *CPPFLAGS* and *LDFLAGS* ensure that the *$PREFIX* include directories and library paths
160 are used, and *-Wl,-rpath ...* is an incantation that ensures that previous built
161 *libtool* libraries can be used.
162
163 ### libXfont
164
165 *autogen.sh* script seems to build easier with
166     --without-xmlto
167 option.
168
169 ### Mesa
170
171 As of 2010-05-09, known problem with GNU m4 pkgsrc on DragonFly
172
173     /usr/pkg/bin/gm4: m4_esyscmd subprocess failed: Operation not permitted
174     /usr/pkg/bin/gm4:configure.ac:8: cannot run command `${MAKE-make} -s -f bin/version.mk version | tr -d '\n'': Operation not permitted
175     configure.ac:8: error: Failed to get the Mesa version from `make -f bin/version.mk version`
176
177 For now just manually run command
178     $ make -f bin/version.mk version
179     7.9.0
180 and substitute it using a patch similar to
181
182     diff --git a/configure.ac b/configure.ac
183     index c40c842..224a858 100644
184     --- a/configure.ac
185     +++ b/configure.ac
186     @@ -4,7 +4,7 @@ AC_PREREQ([2.59])
187  
188      dnl Versioning - scrape the version from configs/default
189      m4_define([mesa_version],
190     -    [m4_esyscmd([${MAKE-make} -s -f bin/version.mk version | tr -d '\n'])])
191     +    [7.9.0])])
192      m4_ifval(mesa_version,,
193          [m4_fatal([Failed to get the Mesa version from `make -f bin/version.mk version`])])
194
195 #### C99 fpclassify()
196
197     diff --git a/src/mesa/main/querymatrix.c b/src/mesa/main/querymatrix.c
198     index ca292aa..a0969f6 100644
199     --- a/src/mesa/main/querymatrix.c
200     +++ b/src/mesa/main/querymatrix.c
201     @@ -71,7 +71,7 @@ fpclassify(double x)
202      }
203
204      #elif defined(__APPLE__) || defined(__CYGWIN__) || defined(__FreeBSD__) || \
205     -     (defined(__sun) && defined(__C99FEATURES__))
206     +     defined(__DragonFly__) || (defined(__sun) && defined(__C99FEATURES__))
207
208      /* fpclassify is available. */
209
210 ### xserver
211
212 If one uses the patches alluded to in the pkgsrc section, one can avoid the following build error:
213
214       YACC   parser.c
215     bison: m4 subprocess failed: Operation not permitted
216     gmake[3]: *** [parser.c] Error 1
217
218 Developer documentation appears to now be enabled by default; therefore, if one is bootstrapping
219 a new tree, one might want to use the option to *autogen.sh* to not build developer documentation:
220
221 I experienced the following build error:
222
223       GEN    Xserver-spec.txt
224     No way to convert HTML to text found.
225
226 Corrected using the *autogen.sh* flag:
227
228     --disable-devel-docs
229
230 ### xinit
231
232     diff --git a/xinit.c b/xinit.c
233     index 313806e..0d31637 100644
234     --- a/xinit.c
235     +++ b/xinit.c
236     @@ -48,6 +48,12 @@ in this Software without prior written authorization from The Open Group.
237      #endif
238      #endif
239  
240     +/* For PRIO_PROCESS and setpriority() */
241     +#ifdef __DragonFly__
242     +#include <sys/time.h>
243     +#include <sys/resource.h>
244     +#endif /* __DragonFly__ */
245     +
246      #include <stdlib.h>
247
248      #ifndef SHELL
249
250 ## Building a Separate Version of GNOME
251
252 ### glib
253
254 See the bug report at <https://bugzilla.gnome.org/show_bug.cgi?id=618754> for an error similar to
255
256     /usr/libexec/binutils217/elf/ld: .libs/gthread.o: relocation R_X86_64_PC32
257     against `_g_mem_thread_init_noprivate_nomessage' can not be used when making a
258     shared object; recompile with -fPIC
259     /usr/libexec/binutils217/elf/ld: final link failed: Bad value
260
261 This bug is especially a problem because it may be related to some interaction with gcc 4.1.2 only on DragonFly.
262
263 The following patch is a complete hack:
264
265     diff --git a/configure.in b/configure.in
266     index 38288c3..51a1c07 100644
267     --- a/configure.in
268     +++ b/configure.in
269     @@ -3033,7 +3033,7 @@ _______EOF
270      #define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
271      #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
272      #define G_GNUC_INTERNAL __hidden
273     -#elif defined (__GNUC__) && defined (G_HAVE_GNUC_VISIBILITY)
274     +#elif defined (__GNUC__) && defined (G_HAVE_GNUC_VISIBILITY) && !defined(__DragonFly__)
275      #define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
276      #else
277      #define G_GNUC_INTERNAL
278
279 ### Graphics Image Formats
280
281 *libpng* <http://www.libpng.org/pub/png/libpng.html> version *1.4.2*
282 can be installed using *autogen.sh* and then *configure*, in contrast to
283 the X.org projects that pass parameters from *autogen.sh* to run *configure* automatically.
284
285 Independent JPEG Group's library <http://www.ijg.org/> version *8b* can be installed
286 using *configure* alone (there is no autogen.sh).
287
288 LibTIFF <http://www.remotesensing.org/libtiff/> has a recommended dependency on jpeg.
289 LibTIFF version 3.9.2 can be installed using *autogen.sh* and then *configure*.
290
291 Running
292     gmake check
293 after building any of the above three projects appears to produce passes tests.
294
295 ### XML
296
297 #### libxml2
298
299 *autogen.sh* calls *configure*
300
301 11 tests fail after *gmake check*
302
303 ### Cairo
304
305 Seems to require
306
307     export LDFLAGS="-L${PREFIX}/lib -Wl,-rpath -Wl,${PREFIX}/lib -L${PREFIX}/lib/X11 -Wl,-rpath -Wl,${PREFIX}/lib/X11"
308     export CPPFLAGS="-I${PREFIX}/include -I${PREFIX}/X11/include"
309
310 When using gcc 4.1.2, *gmake check* gives:
311
312       LINK  check-link
313     ./.libs/libcairo.so: undefined reference to `__umodti3'
314     ./.libs/libcairo.so: undefined reference to `__udivti3'
315
316 When using *CCVER=gcc44* to force gcc 4.4, one obtains the worse:
317
318       CHECK cairo.h
319     cc1: error: unrecognized command line option "-Wlogical-op"
320       CHECK cairo-deprecated.h
321     cc1: error: unrecognized command line option "-Wlogical-op"
322     ...
323
324 The problem is 128-bit division using gcc 4.1.2 as discussed earlier.  One can examine
325 *src/cairo-wideint.c* and see the telltale code enclosed in an if test for *HAVE_UINT128_T*
326 with 128-bit division if defined.
327
328 ### Pango
329
330 Install *gnome-common* first, required.
331
332 If Cairo is not built with *CCVER=gcc44*, obtain build error similar to
333
334       CCLD   pango-view
335     /opt/xcatch/lib/libcairo.so: undefined reference to `__umodti3'
336     /opt/xcatch/lib/libcairo.so: undefined reference to `__udivti3'
337     gmake[3]: *** [pango-view] Error 1
338
339 Following patch corrects an API change not propagated to the test for *gmake check*
340 <https://bugzilla.gnome.org/show_bug.cgi?id=619456>
341
342 Not including patch itself because there are tabs.  But edit file *pango/pangoft2.def*
343 and change
344     pango_fc_font_create_metrics_for_context
345 to
346     pango_fc_font_create_base_metrics_for_context
347
348 ### GObject Introspection
349
350 *cElementTree* is changed to *ElementTree* in files
351 *giscanner/girparser.py*, *giscanner/glibtransformer.py*, and *giscanner/scannermain.py*.
352
353 Using *pkg_alternatives* for a python wrapper fails as a script is generated with
354
355     #! /usr/pkg/bin/python
356
357     import os
358     import sys
359
360 A shell script cannot use another shell script as its interpreter.
361 What works for now is to manually create */usr/pkg/bin/python* as a symlink to */usr/pkg/bin/python2.6*.
362
363 ### gtk+
364
365 *gobject-introspection* is listed as a dependency but can be avoided.
366 Use option *--disable-introspection* to avoid an error
367
368     checking for gobject-introspection... yes
369     ./configure: ${INTROSPECTION_GIRDIR/...}: Bad substitution
370