从Java到嵌入式(三)——交叉编译GTK

  由于需要在Angstrom Linux上开发GUI应用,本想移植QT,但唯恐太麻烦,而且开发板厂商的技术支持太差,所以选择了GTK。首先Google了一下,有人对GTK的评价是依赖的第三方库比较多,配置起来比较麻烦,刚开始还不以为然,上GTK官网看了一下,主要依赖GLib, GdkPixbuf, Pango和ATK,于是乎,开始动手交叉编译。

  交叉编译环境:
   * Ubuntu 9.04
   * arm-none-linux-gnueabi-gcc version 4.4.3

  先Google了一下别人交叉编译GTK的步骤,发现大多数都是基于DirectFB的GTK交叉编译,基于DirectFB是什么也没搞清楚,就照猫画虎着开始配置环境变量,手工编译起来。

  首先从GTK官网FTP上下载最新版的gtk+-3.0.3.tar.bz2,解压后,阅读INSTALL文档,其中有说明编译GTK所需要的库,然后从相应的官网上download,开始照着依赖顺序编译起来,但对着网上别人的编译步骤,发现很多人的编译顺序都不一样,而且依赖的包也大同小异,因为始终没有弄清楚这些个库之间的关系,哪些个库是要交叉编译的,哪些个库是要在本地编译的,在Ubuntu上折腾了整整一周,未果,而且我在两台机器上编译的时候,报的错居然不一样,依赖的包也不一样,这下就傻眼了,一台机器是Ubuntu 9.04,另一台机器是Ubuntu 10.4,一周下来,每天都在Google编译的Error信息,未果。

  面对着Error,几乎快要崩溃的时候,忽然想起了曾经为了安装IEEE1394驱动,在RedHat9上升级内核的经历。当时在Redhat9上直接安装libusb, libraw1394和libdc1394死活编译不过,后来Google到一本英文文档--"Libdc1394-HOWTO",根据文档的说明,似乎需要升级内核才行,于是折腾了整整一个月升级内核,未果。几乎崩溃时,改变思路,换个Linux版本--Fedora9,因为当时买的友善的开发板,他们的手册上的例程是基于Fedora9操作的,本来之前是打算选择用Fedora9来做开发环境的,但是用习惯了Redhat后,改用Fedora很不习惯,于是放弃了它,坚决要用Redhat,但还是以失败而告终,结果勉强用Fedora安装试试,出人意料的是,一次性编译通过!Oh, My God!那我前面一个月的时间岂不是浪费了,不过话又说回来,那一个月,虽然在Redhat上是以失败告终,但也不枉此经历。

  想到这,决定再次拿Fedora试试,于是,在Ubuntu上安装了个VMware,创建个Fedora9虚拟机。之所以看好Fedora的原因在于它安装程序中已经内置了开发所必须的工具,不像Ubuntu Desktop版,很多工具都需要sudo apt-get install或者手工来安装,这样会导致整个编译环境受到污染,可能直接影响到编译结果。Fedora装机就已经自带了这些工具,不用自己安装。这只是一方面的原因,再次是比较一下三台机器之间的编译过程是否一样,因为前面两台Ubuntu机器编译过程中报的错都不一样,依赖的包也有差异,所以根本不知道哪个是正常的;再者,因为这两台Ubuntu机器都经历过sudo apt-get install和手工编译安装过些库到/usr/local下,所以为了避免这些外界环境的影响,选择用一个全新的环境来编译。

  前面在Ubuntu上经历了五天的折腾,写了个shell脚本来实现自动编译,正好把这脚本拿到Fedora用,省得手工tar解压,./configure配置,还要make && make install,很是麻烦,用shell可以一次搞定,这样还能再次学习shell。整个shell脚本差不多600多行,Fedora上一运行,结果Glib编译不过,报错找不到dbus库,好吧,我就先安装dbus,再次编译GLib时,报什么找不到glib-compile-schemas和glib-genmarshal。Google了一下,有人说先本地安装一个glib-devl版本,也就是先在本地安装GLib,于是单独./configure --prefix=/usr/local && make && make install来安装GLib,再次编译GLib,通过了!整个编译过程中,要是遇到类似 Cannot execute test program 这种错的,基本上都是通过cache文件来解决的,再次就是先在本地安装一下,再交叉编译,不过整个编译下来,只有zlib,GLib和libxml2需要先在本地安装,这样交叉编译才能通过。

  最后编译到GTK时,以为可以通过了,结果报错 Cannot find libX11,网上有很多人是编译的GTK+DirectFB版本,而我是GTK+X11版本,所以很多地方不同。看到这个错,我下意识的想到,差libX11库,Google了关天,发现有两种X11,一个是libX11-1.4.x,另一种是X11Rx,我都不知道到底要装哪个库,也不清楚它们之前有什么关系,后来一篇关键性的文章使得我成功编译GTK。 http://git.exherbo.org/summer/packages/x11-libs/gtk+/index.html这个网站很不错,在这里可以查看到哪个库编译和运行时的依赖,以及下载地址,后来终于弄明白X11是一个库的集合,它包含了许多其它的libX库。

  根据上面的GTK的依赖关系,重新改写了shell,顺藤摸瓜,终于理清了依赖关系。后面又加了十几个X11的库,我想这下GTK应该可以编过了吧,结果还是找不到libX11,无语了,难道这些后面加上的x11-libs还是在本地安装不成,于是全部在本地安装到/usr/local,再次编译还是不过。后面在本地安装了libxml2才终于没有报Cannot find libX11,结果报什么Cannot link to Pango,分析config.log,报的错误信息是关于pango和cairo的,我明明成功编译过了Pango,和Cairo而且它们的动态库都在,怎么链接不到呢?根据这一周下来摸索的经验,怀疑是LDFLAGS或LD_LIBRARY_PATH环境变量的问题,Google了一下,发现有人说在编译pango的时候要使用cache文件,内容如下:
  have_cairo=true
  have_cairo_png=true
  have_cairo_freetype=true
于是加上cache文件,然后把usr/local下安装的库全部删掉,整个重新编译一下,看到Make进入gtk+-3.0.3目录时,终于感到全身轻松了。

  附上编译脚本,与大家分享。其中可能有多余的库(纯属猜测)
#!/bin/sh

#-------------------------------------------------------------------------------
# check arguments
#-------------------------------------------------------------------------------
case $1 in
--help|-help|help|\?)
echo Usage: `basename $0` [prefix]
cat << "EOF"

    prefix - install path

EOF
exit
;;
esac

#-------------------------------------------------------------------------------
# check linux issue
#-------------------------------------------------------------------------------
case "`head -1 /etc/issue | awk '{ print $1 }'`" in
Ubuntu)
INSTALL="sudo apt-get install"
;;
Fedora)
INSTALL="sudo yum install"
;;
*)
echo "Unrecoginzed issue"; exit;
;;
esac

#-------------------------------------------------------------------------------
# install automake
#-------------------------------------------------------------------------------
if [ -z "`command -v automake`" ]; then
$INSTALL automake
fi

#-------------------------------------------------------------------------------
# install autoconf
#-------------------------------------------------------------------------------
if [ -z "`command -v autoconf`" ]; then
$INSTALL autoconf
fi

#-------------------------------------------------------------------------------
# install autoheader
#-------------------------------------------------------------------------------
if [ -z "`command -v autoheader`" ]; then
$INSTALL autoheader
fi

#-------------------------------------------------------------------------------
# install aclocal
#-------------------------------------------------------------------------------
if [ -z "`command -v aclocal`" ]; then
$INSTALL aclocal
fi

#-------------------------------------------------------------------------------
# install libtoolize
#-------------------------------------------------------------------------------
if [ -z "`command -v libtoolize`" ]; then
$INSTALL libtoolize
fi

#-------------------------------------------------------------------------------
# install pkg-config
#-------------------------------------------------------------------------------
if [ -z "`command -v pkg-config`" ]; then
$INSTALL pkg-config
fi

#-------------------------------------------------------------------------------
# install GNU make
#-------------------------------------------------------------------------------
if [ -z "`command -v make`" ]; then
$INSTALL make
fi

#-------------------------------------------------------------------------------
# set compile environment variables
#-------------------------------------------------------------------------------
PREFIX=/usr/local

export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig

#-------------------------------------------------------------------------------
# install local zlib
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/zlib.pc ]; then
echo "installing local zlib......"
if [ ! -d zlib-1.2.5 ]; then
if [ ! -e zlib-1.2.5.tar.bz2 ]; then
wget http://www.zlib.net/zlib-1.2.5.tar.bz2
fi
tar -xjf zlib-1.2.5.tar.bz2
fi
cd zlib-1.2.5 && ./configure --prefix=$PREFIX && make && make install && cd .. || exit
fi

#-------------------------------------------------------------------------------
# install local glib
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/glib-2.0.pc ]; then
echo "installing local glib......"
if [ ! -d glib-2.28.3 ]; then
if [ ! -e glib-2.28.3.tar.bz2 ]; then
wget ftp://ftp.gtk.org/pub/glib/2.28/glib-2.28.3.tar.bz2
fi
tar -xjf glib-2.28.3.tar.bz2
fi
cd glib-2.28.3 && ./configure --prefix=$PREFIX && make && make install && cd .. || exit
fi

#-------------------------------------------------------------------------------
# install local libxml2
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/libxml-2.0.pc ]; then
echo "installing local libxml2......"
if [ ! -d libxml2-2.7.8 ]; then
if [ ! -e libxml2-2.7.8.tar.gz  ]; then
wget ftp://www.xmlsoft.org/libxml2/libxml2-2.7.8.tar.gz 
fi
tar -xzf libxml2-2.7.8.tar.gz 
fi
cd libxml2-2.7.8 && ./configure --prefix=$PREFIX && make && make install && cd .. || exit
fi

#-------------------------------------------------------------------------------
# set xcompile environment variables
#-------------------------------------------------------------------------------
if [ ! -z $1 ]; then
  PREFIX=$1
else
  PREFIX=$PWD/gtk+/arm
fi

export PATH=$PATH:$PREFIX/bin
export HOST=arm-linux
export BUILD=i686-pc-linux
export CC=arm-linux-gcc
export LD=arm-linux-ld
export AR=arm-linux-ar
export AS=arm-linux-as
export NM=arm-linux-nm
export CXX=arm-linux-g++
export RANLIB=arm-linux-ranlib
export LD_LIBRARY_PATH=$PREFIX/lib
export LD_RUN_PATH=$LD_LIBRARY_PATH
export CFLAGS="-g -I$PREFIX/include"
export CPPFLAGS=-I$PREFIX/include
export LDFLAGS="-L$LD_LIBRARY_PATH -Wl,-rpath -Wl,$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH=$LD_LIBRARY_PATH/pkgconfig

#-------------------------------------------------------------------------------
# Install tslib
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/tslib-0.0.pc ]; then
echo "installing tslib......"
if [ ! -d tslib ]; then
if [ ! -e tslib-1.4.tar.gz ]; then
wget http://tslib.googlecode.com/files/tslib-1.4.tar.gz
fi
tar -xzf tslib-1.4.tar.gz
fi
cd tslib
./autogen.sh
cat > $HOST.cache << "EOF"
ac_cv_func_malloc_0_nonnull=yes
EOF
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX --cache-file=$HOST.cache && make && make install || exit
cd ..
rm -rf tslib
fi

#-------------------------------------------------------------------------------
# install zlib
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/zlib.pc ]; then
echo "installing zlib......"
if [ ! -d zlib-1.2.5 ]; then
if [ ! -e zlib-1.2.5.tar.bz2 ]; then
wget http://www.zlib.net/zlib-1.2.5.tar.bz2
fi
tar -xjf zlib-1.2.5.tar.bz2
fi
cd zlib-1.2.5
./configure --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf zlib-1.2.5
fi

#-------------------------------------------------------------------------------
# install libxml2
# 
# dependencies: {
#   sys-libs/zlib,
#   sys-devel/libtool,
#   sys-devel/autoconf,
#   sys-devel/automake
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/libxml-2.0.pc ]; then
echo "installing libxml2......"
if [ ! -d libxml2-2.7.8 ]; then
if [ ! -e libxml2-2.7.8.tar.gz  ]; then
wget ftp://www.xmlsoft.org/libxml2/libxml2-2.7.8.tar.gz 
fi
tar -xzf libxml2-2.7.8.tar.gz 
fi
cd libxml2-2.7.8
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf libxml2-2.7.8
fi

#-------------------------------------------------------------------------------
# install expat
#-------------------------------------------------------------------------------
if [ ! -e $PREFIX/lib/libexpat.so ]; then
echo "installing expat......"
if [ ! -d expat-2.0.1 ]; then
if [ ! -e expat-2.0.1.tar.gz ]; then
wget http://nchc.dl.sourceforge.net/project/expat/expat/2.0.1/expat-2.0.1.tar.gz
fi
tar -xzf expat-2.0.1.tar.gz
fi
cd expat-2.0.1
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf expat-2.0.1
fi

#-------------------------------------------------------------------------------
# install dbus
# 
# dependencies: {
#   app-text/docbook-xml-dtd,
#   app-text/xmlto,
#   sys-devel/gettext,
#   dev-util/pkg-config,
#   dev-libs/expat,
#   group/messagebus,
#   user/messagebus,
#   group/plugdev,
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/dbus-1.pc ]; then
echo "installing dbus......"
if [ ! -d dbus-1.4.6 ]; then
if [ ! -e dbus-1.4.6.tar.gz ]; then
wget http://dbus.freedesktop.org/releases/dbus/dbus-1.4.6.tar.gz
fi
tar -xzf dbus-1.4.6.tar.gz
fi
cd dbus-1.4.6
cat > $HOST.cache << "EOF"
ac_cv_have_abstract_sockets=yes
EOF
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX \
--cache-file=$HOST.cache --without-x && make && make install || exit
cd ..
rm -rf dbus-1.4.6
fi

#-------------------------------------------------------------------------------
# install glib
# 
# dependencies: {
#   app-doc/gtk-doc-autotools,
#   sys-devel/gettext,
#   dev-util/pkg-config,
#   dev-doc/gtk-doc,
#   sys-apps/dbus
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/glib-2.0.pc ]; then
echo "installing GLib......"
if [ ! -d glib-2.28.3 ]; then
if [ ! -e glib-2.28.3.tar.bz2 ]; then
wget ftp://ftp.gtk.org/pub/glib/2.28/glib-2.28.3.tar.bz2
fi
tar -xjf glib-2.28.3.tar.bz2
fi
cd glib-2.28.3
cat > $HOST.cache << "EOF"
glib_cv_stack_grows=no
glib_cv_has__inline=yes
glib_cv_working_bcopy=no
glib_cv_uscore=no
ac_cv_func_posix_getpwuid_r=yes
ac_cv_func_posix_getgrgid_r=yes
EOF
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX --cache-file=$HOST.cache && make && make install || exit
cd ..
rm -rf glib-2.28.3
fi

#-------------------------------------------------------------------------------
# install atk
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/atk.pc ]; then
echo "installing atk......"
if [ ! -d atk-1.33.6 ]; then
if [ ! -e atk-1.33.6.tar.bz2 ]; then
wget ftp://ftp.acc.umu.se/pub/gnome/sources/atk/1.33/atk-1.33.6.tar.bz2
fi
tar -xjf atk-1.33.6.tar.bz2
fi
cd atk-1.33.6
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf atk-1.33.6
fi

#-------------------------------------------------------------------------------
# install libpng
# 
# dependencies: {
#   app-arch/xz
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/libpng.pc ]; then
echo "installing libpng......"
if [ ! -d libpng-1.2.44 ]; then
if [ ! -e libpng-1.2.44.tar.bz2 ]; then
wget ftp://ftp.simplesystems.org/pub/png/src/libpng-1.2.44.tar.bz2
#wget http://ncu.dl.sourceforge.net/project/libpng/libpng15/1.5.1/libpng-1.5.1.tar.bz2
fi
tar -xjf libpng-1.2.44.tar.bz2
fi
cd libpng-1.2.44
cat > $HOST.cache << "EOF"
ac_cv_lib_z_zlibVersion=yes
EOF
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX \
--cache-file=$HOST.cache && make && make install || exit
cd ..
rm -rf libpng-1.2.44
fi

#-------------------------------------------------------------------------------
# install jpeg
#-------------------------------------------------------------------------------
if [ ! -e $PREFIX/lib/libjpeg.so ]; then
echo "installing jpeg......"
if [ ! -d jpeg-8c ]; then
if [ ! -e jpegsrc.v8c.tar.gz ]; then
wget http://www.ijg.org/files/jpegsrc.v8c.tar.gz
fi
tar -xzf jpegsrc.v8c.tar.gz
fi
cd jpeg-8c
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf jpeg-8c
fi

#-------------------------------------------------------------------------------
# install tiff
#-------------------------------------------------------------------------------
if [ ! -e $PREFIX/lib/libtiff.so ]; then
echo "installing tiff......"
if [ ! -d tiff-3.7.4 ]; then
if [ ! -e tiff-3.7.4.tar.gz ]; then
wget ftp://ftp.gtk.org/pub/gtk/v2.10/dependencies/tiff-3.7.4.tar.gz
fi
tar -xzf tiff-3.7.4.tar.gz
fi
cd tiff-3.7.4
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX --enable-shared && make && make install || exit
cd ..
rm -rf tiff-3.7.4
fi

#-------------------------------------------------------------------------------
# install pixman
# 
# dependencies: {
#   dev-util/pkg-config
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/pixman-1.pc ]; then
echo "installing pixman......"
if [ ! -d pixman-0.20.2 ]; then
if [ ! -e pixman-0.20.2.tar.gz ]; then
wget http://www.cairographics.org/releases/pixman-0.20.2.tar.gz
fi
tar -xzf pixman-0.20.2.tar.gz
fi
cd pixman-0.20.2
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX --disable-gtk && make && make install || exit
cd ..
rm -rf pixman-0.20.2
fi

#-------------------------------------------------------------------------------
# install freetype
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/freetype2.pc ]; then
echo "installing freetype......"
if [ ! -d freetype-2.4.4 ]; then
if [ ! -e freetype-2.4.4.tar.bz2 ]; then
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.4.tar.bz2
fi
tar -xjf freetype-2.4.4.tar.bz2
fi
cd freetype-2.4.4
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf freetype-2.4.4
fi

#-------------------------------------------------------------------------------
# install fontconfig
# 
# dependencies: {
#   dev-util/pkg-config,
#   dev-libs/expat,
#   media-libs/freetype
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/fontconfig.pc ]; then
echo "installing fontconfig......"
if [ ! -d fontconfig-2.8.0 ]; then
if [ ! -e fontconfig-2.8.0.tar.gz ]; then
wget http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.8.0.tar.gz
fi
tar -xzf fontconfig-2.8.0.tar.gz
fi
cd fontconfig-2.8.0
./configure --host=$HOST --build=$BUILD --with-arch=arm --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf fontconfig-2.8.0
fi

#-------------------------------------------------------------------------------
# install xtrans
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/xtrans.pc ]; then
echo "installing xtrans......"
if [ ! -d xtrans-1.2 ]; then
if [ ! -e xtrans-1.2.tar.bz2 ]; then
wget http://xorg.freedesktop.org/archive/individual/lib/xtrans-1.2.tar.bz2
fi
tar -xjf xtrans-1.2.tar.bz2
fi
cd xtrans-1.2
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf xtrans-1.2
fi

#-------------------------------------------------------------------------------
# install inputproto
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/inputproto.pc ]; then
echo "installing inputproto......"
if [ ! -d inputproto-2.0 ]; then
if [ ! -e inputproto-2.0.tar.bz2 ]; then
wget http://xorg.freedesktop.org/archive/individual/proto/inputproto-2.0.tar.bz2
fi
tar -xjf inputproto-2.0.tar.bz2
fi
cd inputproto-2.0
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf inputproto-2.0
fi

#-------------------------------------------------------------------------------
# install kbproto
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/kbproto.pc ]; then
echo "installing kbproto......"
if [ ! -d kbproto-1.0.5 ]; then
if [ ! -e kbproto-1.0.5.tar.bz2 ]; then
wget http://xorg.freedesktop.org/archive/individual/proto/kbproto-1.0.5.tar.bz2
fi
tar -xjf kbproto-1.0.5.tar.bz2
fi
cd kbproto-1.0.5
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf kbproto-1.0.5
fi

#-------------------------------------------------------------------------------
# install xextproto
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/xextproto.pc ]; then
echo "installing xextproto......"
if [ ! -d xextproto-7.2.0 ]; then
if [ ! -e xextproto-7.2.0.tar.bz2 ]; then
wget http://xorg.freedesktop.org/archive/individual/proto/xextproto-7.2.0.tar.bz2
fi
tar -xjf xextproto-7.2.0.tar.bz2
fi
cd xextproto-7.2.0
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf xextproto-7.2.0
fi

#-------------------------------------------------------------------------------
# install xproto
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/xproto.pc ]; then
echo "installing xproto......"
if [ ! -d xproto-7.0.20 ]; then
if [ ! -e xproto-7.0.20.tar.bz2 ]; then
wget http://xorg.freedesktop.org/archive/individual/proto/xproto-7.0.20.tar.bz2
fi
tar -xjf xproto-7.0.20.tar.bz2
fi
cd xproto-7.0.20
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf xproto-7.0.20
fi

#-------------------------------------------------------------------------------
# install xcb-proto
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/xcb-proto.pc ]; then
echo "installing xcb-proto......"
if [ ! -d xcb-proto-1.6 ]; then
if [ ! -e xcb-proto-1.6.tar.bz2 ]; then
wget http://xcb.freedesktop.org/dist/xcb-proto-1.6.tar.bz2
fi
tar -xjf xcb-proto-1.6.tar.bz2
fi
cd xcb-proto-1.6
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf xcb-proto-1.6
fi

#-------------------------------------------------------------------------------
# install libpthread-stubs
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/pthread-stubs.pc ]; then
echo "installing libpthread-stubs......"
if [ ! -d libpthread-stubs-0.3 ]; then
if [ ! -e libpthread-stubs-0.3.tar.bz2 ]; then
wget http://xcb.freedesktop.org/dist/libpthread-stubs-0.3.tar.bz2
fi
tar -xjf libpthread-stubs-0.3.tar.bz2
fi
cd libpthread-stubs-0.3
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf libpthread-stubs-0.3
fi

#-------------------------------------------------------------------------------
# install libxslt
# 
# dependencies: {
#   dev-libs/libxml2,
#   sys-devel/libtool,
#   sys-devel/autoconf:2.5,
#   sys-devel/automake:1.11 
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/libxslt.pc ]; then
echo "installing libxslt......"
if [ ! -d libxslt-1.1.26 ]; then
if [ ! -e libxslt-1.1.26.tar.gz ]; then
wget ftp://xmlsoft.org/libxslt/libxslt-1.1.26.tar.gz
fi
tar -xzf libxslt-1.1.26.tar.gz
fi
cd libxslt-1.1.26
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && \
make && make install || exit
cd ..
rm -rf libxslt-1.1.26
fi

#-------------------------------------------------------------------------------
# install libXau
# 
# dependencies: {
#   x11-proto/xproto
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/xau.pc ]; then
echo "installing libXau......"
if [ ! -d libXau-1.0.6 ]; then
if [ ! -e libXau-1.0.6.tar.bz2 ]; then
wget http://xorg.freedesktop.org/archive/individual/lib/libXau-1.0.6.tar.bz2
fi
tar -xjf libXau-1.0.6.tar.bz2
fi
cd libXau-1.0.6
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf libXau-1.0.6
fi

#-------------------------------------------------------------------------------
# install libXdmcp
# 
# dependencies: {
#   x11-proto/xproto
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/xdmcp.pc ]; then
echo "installing libXau......"
if [ ! -d libXdmcp-1.1.0 ]; then
if [ ! -e libXdmcp-1.1.0.tar.bz2 ]; then
wget http://xorg.freedesktop.org/archive/individual/lib/libXdmcp-1.1.0.tar.bz2
fi
tar -xjf libXdmcp-1.1.0.tar.bz2
fi
cd libXdmcp-1.1.0
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf libXdmcp-1.1.0
fi

#-------------------------------------------------------------------------------
# install libxcb
# 
# dependencies: {
#   x11-proto/xcb-proto, 
#   dev-libs/libpthread-stubs,
#   dev-libs/libxslt,
#   x11-libs/libXau,
#   x11-libs/libXdmcp
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/xcb.pc ]; then
echo "installing libxcb......"
if [ ! -d libxcb-1.7 ]; then
if [ ! -e libxcb-1.7.tar.bz2 ]; then
wget http://xcb.freedesktop.org/dist/libxcb-1.7.tar.bz2
fi
tar -xjf libxcb-1.7.tar.bz2
fi
cd libxcb-1.7
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf libxcb-1.7
fi

#-------------------------------------------------------------------------------
# install libX11
# 
# dependencies: {
#   x11-libs/xtrans,
#   x11-proto/inputproto,
#   x11-proto/kbproto,
#   x11-proto/xextproto,
#   x11-proto/xproto,
#   x11-libs/libxcb
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/x11.pc ]; then
echo "installing libX11......"
if [ ! -d libX11-1.4.2 ]; then
if [ ! -e libX11-1.4.2.tar.bz2 ]; then
wget http://xorg.freedesktop.org/archive/individual/lib/libX11-1.4.2.tar.bz2
fi
tar -xjf libX11-1.4.2.tar.bz2
fi
cd libX11-1.4.2
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf libX11-1.4.2
fi

#-------------------------------------------------------------------------------
# install compositeproto
# 
# dependencies: {
#   dev-util/pkg-config
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/compositeproto.pc ]; then
echo "installing compositeproto......"
if [ ! -d compositeproto-0.4.2 ]; then
if [ ! -e compositeproto-0.4.2.tar.bz2 ]; then
wget http://xorg.freedesktop.org/archive/individual/proto/compositeproto-0.4.2.tar.bz2
fi
tar -xjf compositeproto-0.4.2.tar.bz2
fi
cd compositeproto-0.4.2
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf compositeproto-0.4.2
fi

#-------------------------------------------------------------------------------
# install xext
# 
# dependencies: {
#   dev-util/pkg-config,
#   x11-proto/xextproto,
#   x11-proto/xproto,
#   x11-libs/libX11
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/xext.pc ]; then
echo "installing xext......"
if [ ! -d libXext-1.2.0 ]; then
if [ ! -e libXext-1.2.0.tar.bz2 ]; then
wget http://xorg.freedesktop.org/archive/individual/lib/libXext-1.2.0.tar.bz2
fi
tar -xjf libXext-1.2.0.tar.bz2
fi
cd libXext-1.2.0
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf libXext-1.2.0
fi

#-------------------------------------------------------------------------------
# install compositeproto
# 
# dependencies: {
#   dev-util/pkg-config,
#   x11-proto/xextproto
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/fixesproto.pc ]; then
echo "installing fixesproto......"
if [ ! -d fixesproto-5.0 ]; then
if [ ! -e fixesproto-5.0.tar.bz2 ]; then
wget http://xorg.freedesktop.org/archive/individual/proto/fixesproto-5.0.tar.bz2
fi
tar -xjf fixesproto-5.0.tar.bz2
fi
cd fixesproto-5.0
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf fixesproto-5.0
fi

#-------------------------------------------------------------------------------
# install libXfixes
# 
# dependencies: {
#   x11-proto/fixesproto,
#   x11-proto/xextproto,
#   x11-proto/xproto,
#   x11-libs/libX11
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/xfixes.pc ]; then
echo "installing libXfixes......"
if [ ! -d libXfixes-5.0 ]; then
if [ ! -e libXfixes-5.0.tar.bz2 ]; then
wget http://xorg.freedesktop.org/archive/individual/lib/libXfixes-5.0.tar.bz2
fi
tar -xjf libXfixes-5.0.tar.bz2
fi
cd libXfixes-5.0
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf libXfixes-5.0
fi

#-------------------------------------------------------------------------------
# install libXcomposite
# 
# dependencies: {
#   x11-proto/compositeproto,
#   x11-libs/libX11,
#   x11-libs/libXfixes,
#   dev-util/pkg-config
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/xcomposite.pc ]; then
echo "installing libXcomposite......"
if [ ! -d libXcomposite-0.4.3 ]; then
if [ ! -e libXcomposite-0.4.3.tar.bz2 ]; then
wget http://xorg.freedesktop.org/archive/individual/lib/libXcomposite-0.4.3.tar.bz2
fi
tar -xjf libXcomposite-0.4.3.tar.bz2
fi
cd libXcomposite-0.4.3
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf libXcomposite-0.4.3
fi

#-------------------------------------------------------------------------------
# install cairo
# 
# dependencies: {
#   dev-util/pkg-config,
#   media-libs/libpng,
#   x11-dri/mesa,
#   media-libs/freetype,
#   media-libs/fontconfig,
#   x11-libs/pixman,
#   dev-libs/glib,
#}
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/cairo.pc ]; then
echo "installing cairo......"
if [ ! -d cairo-1.10.2 ]; then
if [ ! -e cairo-1.10.2.tar.gz ]; then
wget http://www.cairographics.org/releases/cairo-1.10.2.tar.gz
fi
tar -xzf cairo-1.10.2.tar.gz
fi
cd cairo-1.10.2
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf cairo-1.10.2
fi

#-------------------------------------------------------------------------------
# install pango
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/pango.pc ]; then
echo "installing pango......"
if [ ! -d pango-1.28.3 ]; then
if [ ! -e pango-1.28.3.tar.bz2 ]; then
wget ftp://ftp.gnome.org/pub/GNOME/sources/pango/1.28/pango-1.28.3.tar.bz2
fi
tar -xjf pango-1.28.3.tar.bz2
fi
cd pango-1.28.3
cat > $HOST.cache << "EOF"
have_cairo=true
have_cairo_png=true
have_cairo_freetype=true
EOF
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX \
--cache-file=$HOST.cache --with-x && make && make install || exit
cd ..
rm -rf pango-1.28.3
fi

#-------------------------------------------------------------------------------
# install gdk-pixbuf
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/gdk-pixbuf-2.0.pc ]; then
echo "installing gdk-pixbuf......"
if [ ! -d gdk-pixbuf-2.22.1 ]; then
if [ ! -e gdk-pixbuf-2.22.1.tar.bz2 ]; then
wget http://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/2.22/gdk-pixbuf-2.22.1.tar.bz2
fi
tar -xjf gdk-pixbuf-2.22.1.tar.bz2
fi
cd gdk-pixbuf-2.22.1
cat > $HOST.cache << "EOF"
gio_can_sniff=yes
EOF
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX \
--cache-file=$HOST.cache && make && make install || exit
cd ..
rm -rf gdk-pixbuf-2.22.1
fi

#-------------------------------------------------------------------------------
# install xineramaproto
# 
# dependencies: {
#   dev-util/pkg-config
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/xineramaproto.pc ]; then
echo "installing xineramaproto......"
if [ ! -d xineramaproto-1.2.1 ]; then
if [ ! -e xineramaproto-1.2.1.tar.bz2 ]; then
wget http://xorg.freedesktop.org/archive/individual/proto/xineramaproto-1.2.1.tar.bz2
fi
tar -xjf xineramaproto-1.2.1.tar.bz2
fi
cd xineramaproto-1.2.1
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf xineramaproto-1.2.1
fi

#-------------------------------------------------------------------------------
# install libXinerama
# 
# dependencies: {
#   x11-proto/xextproto,
#   x11-proto/xineramaproto,
#   x11-libs/libX11,
#   x11-libs/libXext,
#   dev-util/pkg-config
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/xinerama.pc ]; then
echo "installing libXinerama......"
if [ ! -d libXinerama-1.1.1 ]; then
if [ ! -e libXinerama-1.1.1.tar.bz2 ]; then
wget http://xorg.freedesktop.org/archive/individual/lib/libXinerama-1.1.1.tar.bz2
fi
tar -xjf libXinerama-1.1.1.tar.bz2
fi
cd libXinerama-1.1.1
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf libXinerama-1.1.1
fi

#-------------------------------------------------------------------------------
# install libXi
# 
# dependencies: {
#   x11-proto/xproto,
#   x11-proto/xextproto,
#   x11-proto/xineramaproto,
#   x11-libs/libX11,
#   x11-libs/libXext,
#   dev-util/pkg-config,
#   x11-proto/inputproto
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/xi.pc ]; then
echo "installing libXi......"
if [ ! -d libXi-1.4.1 ]; then
if [ ! -e libXi-1.4.1.tar.bz2 ]; then
wget http://xorg.freedesktop.org/archive/individual/lib/libXi-1.4.1.tar.bz2
fi
tar -xjf libXi-1.4.1.tar.bz2
fi
cd libXi-1.4.1
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX && make && make install || exit
cd ..
rm -rf libXi-1.4.1
fi

#-------------------------------------------------------------------------------
# install GTK+
# 
# dependencies: {
#   sys-devel/gettext,
#   dev-util/pkg-config,
#   dev-libs/glib,
#   dev-libs/atk,
#   x11-libs/pango,
#   x11-libs/cairo,
#   x11-libs/gdk-pixbuf,
#   x11-libs/libXinerama,
#   x11-libs/libXi,
#   x11-libs/libXrandr,
#   x11-libs/libXcursor,
#   x11-libs/libXfixes,
#   x11-libs/libXcomposite,
#   x11-libs/libXdamage,
#   x11-themes/hicolor-icon-theme
# }
#-------------------------------------------------------------------------------
if [ ! -e $PKG_CONFIG_PATH/gtk+.pc ]; then
echo "installing GTK+......"
if [ ! -d gtk+-3.0.3 ]; then
if [ ! -e gtk+-3.0.3.tar.bz2 ]; then
wget ftp://ftp.gtk.org/pub/gtk/3.0/gtk+-3.0.3.tar.bz2
fi
tar -xjf gtk+-3.0.3.tar.bz2
fi
cd gtk+-3.0.3
cat > $HOST.cache << "EOF"
ac_cv_func_XOpenDisplay=yes
ac_cv_func__NSGetEnviron=yes
ac_cv_func_XextFindDisplay=yes
ac_cv_func_XShapeCombineMask=yes
EOF
./configure --host=$HOST --build=$BUILD --prefix=$PREFIX \
--cache-file=$HOST.cache --with-x && make && make install || exit
cd ..
rm -rf gtk+-3.0.3
fi

你可能感兴趣的:(java,linux,cache,ubuntu,嵌入式)