Skip to content

Instantly share code, notes, and snippets.

@AllanZyne
Last active June 30, 2017 06:41
Show Gist options
  • Save AllanZyne/8f7c8fefec1a77048f70 to your computer and use it in GitHub Desktop.
Save AllanZyne/8f7c8fefec1a77048f70 to your computer and use it in GitHub Desktop.

Cross Compiling Xorg

交叉编译依赖文件

i. 配置环境变量

export DISCIMAGE=/usr/local/xorg  # 安装目录
export CROSS_COMPILE=arm-linux-   # 交叉编译工具的前缀

ii. 安装 zlib

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

iii. 安装 libpng

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

iv. 安装 expat

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

v. 安装 openssl(For SHA-1)

 ./Configure dist --prefix=$DISCIMAGE/usr/local
 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

用jhbuid工具编译

i. 安装 jhbuild

 ./autogen.sh
 make -f Makefile.plain install
 
 echo PATH=$PATH:~/.local/bin >> ~/.bashrc
 source ~/.bashrc

ii. jhbuild配置文件样例

#!python
#######################################################################################
# This is a checkout and build configuration for building Xorg
#
# This can be copied to ~/.jhbuildrc  and then run 'jhbuild build xserver'
#
#######################################################################################

moduleset = '/home/allan/Workspace/arm-X11/xorg-7.6.modules'

checkoutroot = '/home/allan/Workspace/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/'

# Enabled 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,' + '/'

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%-}

jhbuild -f jhbuildrc-7.6 build xserver

jhbuild -f jhbuildrc-7.6 build xf86-video-fbdev xf86-input-keyboard xf86-input-mouse xf86-input-void

jhbuild -f jhbuildrc-7.6 buildone xkbutils xkbcomp xinit

-lXaw7 -lXt -lX11 -lXext -lXmu -lXpm -lSM -lxcb -lICE -lXau -l

-lfontconfig -lexpat -lfreetype -lpng16 -lz

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 twm

startx:

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

defaultserverargs="-nolisten tcp"

! DEPEN:

Mesa talloc http://www.samba.org/ftp/talloc/talloc-1.3.0.tar.gz makedepend (x86)

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

 AR=${CROSS_COMPILE}ar CC=${CROSS_COMPILE}gcc RANLIB=${CROSS_COMPILE}ranlib LDFLAGS="-L$DISCIMAGE/lib" CPPFLAGS="-I$DISCIMAGE/include" PKG_CONFIG_PATH="/usr/local/xorg/lib/pkgconfig" ./autogen.sh --prefix=$DISCIMAGE --host=${CROSS_COMPILE%-} --disable-static --without-python --without-crypto --with-libxml-prefix=$DISCIMAGE

libGL MesaLib ftp://ftp.freedesktop.org/pub/mesa/older-versions/7.x/7.9/

mountnfs 192.168.1.2:/home/allan/Workspace/arm-X11/discimage /mnt/nfs

/home/allan/Workspace/arm-X11/discimage/usr/local/bin/makedepend

-lxcb -lXau -lXext -lSM -lICE -lX11 -lXi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment