Cross Compiling Xorg

CrossCompilingXorg.md
Markdown

Cross Compiling Xorg

    public

     

    小组成员:曹雪松 李桂林 李祥鑫 罗富中 宋旭鹏 徐文静 吴昊 赵阳

    编译前夕

    i. 配置环境变量

    把下面脚本加入~/.bashrc

    init-crosscompile() {
        export DISCIMAGE=/usr/local/xorg  # 安装目录
        export CROSS_COMPILE=arm-linux-   # 交叉编译工具的前缀
        # ARM-LINUX-GCC 的路径
        export LD_LIBRARY_PATH=~/Application/arm-linux-gcc/4.4.3/lib:$LD_LIBRARY_PATH
        export PATH=~/Application/arm-linux-gcc/4.4.3/bin:~/.local/bin:$PATH
        # pkg-config 的路径
        export PKG_CONFIG_PATH=/usr/local/xorg/lib/pkgconfig:/usr/local/xorg/share/pkgconfig/:$PKG_CONFIG_PATH
    }
    

    然后

    $ source ~/.bashrc
    $ init-crosscompile
    

    ii. 安装 zlib

     AR=${CROSS_COMPILE}ar CC=${CROSS_COMPILE}gcc RANLIB=${CROSS_COMPILE}ranlib ./configure --prefix=$DISCIMAGE
     make
     make install
    

    iii. 安装 libpng

     LDFLAGS="-L$DISCIMAGE/lib" CPPFLAGS="-I$DISCIMAGE/include" ./configure --prefix=$DISCIMAGE --host=${CROSS_COMPILE%-}
     make
     make install
    

    iv. 安装 expat

     AR=${CROSS_COMPILE}ar CC=${CROSS_COMPILE}gcc ./configure --prefix=$DISCIMAGE --host=${CROSS_COMPILE%-}
     make
     make install
    

    v. 安装 openssl(For SHA-1)

     ./Configure dist --prefix=$DISCIMAGE
     make CC="${CROSS_COMPILE}gcc" AR="${CROSS_COMPILE}ar r" RANLIB="${CROSS_COMPILE}ranlib"
     make CC="${CROSS_COMPILE}gcc" AR="${CROSS_COMPILE}ar r" RANLIB="${CROSS_COMPILE}ranlib" install
    

    编译助手

    i. 安装 jhbuild

     ./autogen.sh
     make -f Makefile.plain install
    

    ii. jhbuild脚本样例

    jhbuildrc-7.6-sample

    #-*- coding:utf-8 -*-
    #!python
    #######################################################################################
    #
    # 这是自动下载、编译和安装Xorg的脚本
    # 把它拷贝成文件jhbuldrc-7.6,然后运行`jhbuild -f jhbuildrc-7.6 (modules...)'即可
    #
    #######################################################################################
    
    # moduleset文件的路径
    moduleset = '~/arm-X11/xorg-7.6.modules'
    
    # 下载包的路径
    checkoutroot = '~/arm-X11/xorg-7.6/'
    
    modules = [ 'xorg' ]
    prefix = os.environ['DISCIMAGE']
    
    autogenargs = ' --disable-static'
    autogenargs += ' --disable-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')
    os.environ['PKG_CONFIG_PATH'] = '/usr/local/xorg/lib/pkgconfig:/usr/local/xorg/share/pkgconfig/'
    
    # Disabled debugging for xserver
    os.environ['CFLAGS'] = '-O2'
    os.environ['CPPFLAGS'] = '-O2'
    
    # Setup environment for cross compiling
    
    os.environ['BUILD'] = 'i386-pc-linux'
    os.environ['HOST'] = 'arm-linux'
    os.environ['TARGET'] = 'arm-linux'
    
    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 --enable-xcb --disable-glw --disable-glu --disable-egl --disable-gallium'
    
    module_autogenargs['libXt'] = autogenargs + ' --disable-install-makestrs'
    
    module_autogenargs['xserver'] = autogenargs + ' --disable-glx --disable-unit-tests --enable-dri2 CFLAGS="-O2 -I/usr/local/xorg/include -L/usr/local/xorg/lib -lfontenc -lxcb -lXau -lXext -lSM -lICE -lX11 -lXi"'
    
    module_autogenargs['pixman'] = autogenargs + ' --disable-gtk  --disable-static-testprogs '
    
    module_autogenargs['hal'] = autogenargs + ' --disable-pci-ids'
    
    module_autogenargs['libXfont'] = autogenargs + ' --disable-freetype'
    
    module_autogenargs['libxslt'] = autogenargs + '--without-python --without-crypto --with-libxml-prefix=' + prefix
    
    module_autogenargs['libxml2'] = autogenargs + '--without-python'
    
    module_autogenargs['xkbutils'] = autogenargs + ' CFLAGS="-O2 -I/usr/local/xorg/include -L/usr/local/xorg/lib -lXaw7 -lXt -lX11 -lXext -lXmu -lXpm -lSM -lxcb -lICE -lXau"'
    
    
    # For expat and zlib
    os.environ['CFLAGS'] += ' -I' + os.environ['DISCIMAGE']
    os.environ['CPPFLAGS'] += ' -IHello -I' + os.environ['DISCIMAGE']
    os.environ['LDFLAGS'] = ' -L' + os.environ['DISCIMAGE']
    os.environ['LDFLAGS'] += ' -Wl,--rpath -Wl,' + '/'  #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']
    os.environ['CPPFLAGS'] += ' -I' + os.environ['DISCIMAGE']
    os.environ['LDFLAGS'] += ' -L' + os.environ['DISCIMAGE']
    os.environ['LDFLAGS'] += ' -Wl,--rpath -Wl,' + '/'
    

    xorg-7.6.modules

    编译开始

    i. 安装 xserver

    jhbuild -f jhbuildrc-7.6 build xserver 
    

    在编译过程中可能需要手动解决的依赖关系:

    libxbc
        └── xslt https://git.gnome.org/browse/libxslt/snapshot/libxslt-1.1.28.tar.gz
              └── libxml2 https://git.gnome.org/browse/libxml2/snapshot/libxml2-2.9.1.tar.gz
    
    libGL
        └── MesaLib ftp://ftp.freedesktop.org/pub/mesa/older-versions/7.x/7.9/
                ├── talloc http://www.samba.org/ftp/talloc/talloc-1.3.0.tar.gz
                └── makedepend 重用gcc译成,替换掉arm版
    

    ii. 安装驱动

    jhbuild -f jhbuildrc-7.6 build xf86-video-fbdev xf86-input-mouse xf86-input-void xf86-input-keyboard
    # 键盘的其他组件
    jhbuild -f jhbuildrc-7.6 buildone xkbutils xkbcomp xkeyboard-config
    

    iii. 安装启动程序

    jhbuild -f jhbuildrc-7.6 buildone xinit
    

    在编译过程中可能需要手动解决的依赖关系:

    xinit
      ├── xauth
      ├── mcookie ftp://ftp.kernel.org/pub/linux/utils/util-linux/v2.24/util-linux-2.24.tar.gz
      ├── xterm
      │     └── ncurses
      ├── xclock
      │     ├── libXft
      │     │     ├── freetype
      │     │     └── fontconfig
      │     └── libbz2
      └── twm
    

    其他

    常用编译命令

    AR=${CROSS_COMPILE}ar CC=${CROSS_COMPILE}gcc RANLIB=${CROSS_COMPILE}ranlib LDFLAGS="-L$DISCIMAGE/lib" CPPFLAGS="-I$DISCIMAGE/include" ./autogen.sh --prefix=$DISCIMAGE --host=${CROSS_COMPILE%-}
    
    ./configure --prefix=$DISCIMAGE --host=${CROSS_COMPILE%-} --disable-static
    

    链接库

    -lXaw7 -lXt -lX11 -lXext -lXmu -lXpm -lSM -lxcb -lICE -lXau
    
    -lfontconfig -lexpat -lfreetype -lpng16 -lz
    

    startx

    错误信息:

    _XSERVTransSocketOpenCOTSServer: Unable to open socket for inet6
    _XSERVTransOpen: transport open failed for inet6/urbetter:0
    _XSERVTransMakeAllCOTSServerListeners: failed to open listener for inet6

    编辑startx:

    serverargs="-nolisten tcp"
    

    arm终端下的挂载命令

    mountnfs 192.168.1.2:/home/allan/Workspace/arm-X11/discimage /mnt/nfs
    
    评论 1
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值