summaryrefslogtreecommitdiff
path: root/CrossCompilingXorgJhbuild.mdwn
blob: 1f89f6489d93a30a29791b5726ab1761e9614ab7 (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
Below is a sample `~/.jhbuildrc` file to cross compile build X. Replace arm-none-linux-gnueabi with your toolchain. It assumes that you have export'ed `DISCIMAGE` to where you want to install to.

    #!python
    #######################################################################################
    # This is a checkout and build configuration for building Xorg
    #
    # This can be copied to ~/.jhbuildrc  and then run 'jhbuild build xserver'
    #
    #######################################################################################
    
    moduleset = 'https://gitlab.freedesktop.org/xorg/util/modular/-/raw/master/xorg.modules'
    checkoutroot = '~/sources/xorg/git'
    modules = [ 'xorg' ]
    prefix = os.environ['DISCIMAGE'] +'/usr/local'
    
    autogenargs = ' --disable-static'
    autogenargs += ' --disable-dri2 --with-driver=dri'
    autogenargs += ' --cache-file=' + checkoutroot + '/autoconf-cache'
    # lots of people really like to always look in /var/log, but change if
    # you want the log files out of place
    autogenargs += ' --with-log-dir=/var/log'
    autogenargs += ' --with-mesa-source=' + checkoutroot + '/mesa'
    autogenargs += ' --enable-malloc0returnsnull'
    
    os.environ['ACLOCAL'] = 'aclocal -I ' + prefix + '/share/aclocal/'
    os.environ['INSTALL'] = os.path.expanduser('~/bin/install-check')
    
    # Enabled debugging for xserver
    os.environ['CFLAGS'] = '-g'
    os.environ['CPPFLAGS'] = '-g'
    
    # Setup environment for cross compiling
    
    os.environ['BUILD'] = 'i686-pc-linux-gnuaout'
    os.environ['HOST'] = 'arm-none-linux-gnueabi'
    os.environ['TARGET'] = 'arm-none-linux-gnueabi'
    
    cross_compile_prefix = os.environ['CROSS_COMPILE']
    tools = {'ADDR2LINE': 'addr2line',
    	'AS': 'as', 'CC': 'gcc', 'CPP': 'cpp',
    	'CPPFILT': 'c++filt', 'CXX': 'g++',
    	'GCOV': 'gcov', 'LD': 'ld', 'NM': 'nm',
    	'OBJCOPY': 'objcopy', 'OBJDUMP': 'objdump',
    	'READELF': 'readelf', 'SIZE': 'size',
    	'STRINGS': 'strings', 'AR': 'ar', 
            'RANLIB': 'ranlib', 'STRIP': 'strip'}
    
    tools_args = str()
    for tool in tools.keys():
    	fullpath_tool = cross_compile_prefix + tools[tool]
    	os.environ[tool] = fullpath_tool
    
    autogenargs += ' --build='+os.environ['BUILD']
    autogenargs += ' --host='+os.environ['HOST']
    autogenargs += ' --target='+os.environ['TARGET']
    
    for tool in ('AR', 'RANLIB', 'STRIP', 'AS', 'OBJDUMP', 'NM'):
    	autogenargs += ' '+tool+'="'+os.environ[tool]+'" '
    
    module_autogenargs['libGL'] = autogenargs + ' --without-demos --with-dri-drivers="swrast" --disable-glw'
    module_autogenargs['libXt'] = autogenargs + ' --disable-install-makestrs'
    module_autogenargs['xserver'] = autogenargs + ' --enable-debug'
    module_autogenargs['pixman'] = autogenargs + ' --disable-gtk'
    module_autogenargs['hal'] = autogenargs + ' --disable-pci-ids'
    module_autogenargs['libXfont'] = autogenargs + ' --disable-freetype'
    
    # For expat and zlib
    os.environ['CFLAGS'] += ' -I' + os.environ['DISCIMAGE'] + '/usr/local/include/'
    os.environ['CPPFLAGS'] += ' -IHello -I' + os.environ['DISCIMAGE'] + '/usr/local/include/'
    os.environ['LDFLAGS'] = ' -L' + os.environ['DISCIMAGE'] + '/usr/local/lib/'
    os.environ['LDFLAGS'] += ' -Wl,--rpath -Wl,' + '/usr/local/lib/'  #rpath is relative to where it is run from - DISCIMAGE 
    
    # Just in case zlib or expat were installed here
    os.environ['CFLAGS'] += ' -I' + os.environ['DISCIMAGE'] + '/usr/include/'
    os.environ['CPPFLAGS'] += ' -I' + os.environ['DISCIMAGE'] + '/usr/include/'
    os.environ['LDFLAGS'] += ' -L' + os.environ['DISCIMAGE'] + '/usr/lib/'
    os.environ['LDFLAGS'] += ' -Wl,--rpath -Wl,' + '/usr/lib/'