arm的条件执行功能可以避免执行jmp指令,但每条指令都判断一次条件。
和x86对比的汇编代码如下。
C语言代码如下:
int b;
int test(int a) {
if (a>0)
return a+b;
return b;
}
分别用arm gcc 4.3.3 和x86 gcc 4.3.3 加-O2 -S选项 生成汇编代码。
arm的汇编代码如下:
test:
.fnstart
.LFB2:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
cmp r0, #0
ldrgt r3, .L5
ldrle r3, .L5
ldrgt r2, [r3, #0]
ldrle r0, [r3, #0]
addgt r0, r0, r2
bx lr
.L6:
.align 2
.L5:
.word b
x86的汇编代码如下:
test:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
testl %eax, %eax
jle .L2
addl b, %eax
popl %ebp
ret
.p2align 4,,7
.p2align 3
.L2:
movl b, %eax
popl %ebp
ret
.size test, .-test
.comm b,4,4
2009年9月16日星期三
2009年9月15日星期二
directfb显示中文
1. 编译directfb软件栈
需要的软件包:
zlib_1.2.3.3.dfsg.orig.tar.gz, libpng-1.2.38.tar.bz2 , jpegsrc.v7.tar.gz, freetype_2.3.7.orig.tar.gz, directfb_1.2.8.orig.tar.gz
(1) zlib 编译:
tar zxvf ../src/zlib_1.2.3.3.dfsg.orig.tar.gz
cd zlib-1.2.3.3.dfsg
CC=arm-none-linux-gnueabi-gcc ./configure --prefix=/opt
make && make install
cd .. && rm -rf zlib*
(2) libpng 编译:
tar zxvf ../src/jpegsrc.v7.tar.gz
cd jpeg-7/
CC=arm-none-linux-gnueabi-gcc ./configure --host=arm-none-linux-gnueabi \
--prefix=/opt --with-gnu-ld
make && make install
cd .. && rm -rf jpeg*
(4) freetype 编译:
tar zxvf ../src/freetype_2.3.7.orig.tar.gz
cd freetype-2.3.7/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-none-linux-gnueabi-gcc \
CFLAGS=-I/opt/include LDFLAGS=-L/opt/lib ./configure --host=arm-none-linux-gnueabi \
--prefix=/opt --with-gnu-ld
make && make install
cd .. && rm -rf freetype*
(5) directfb 编译:
2. 配置根文件系统
(1) 复制库文件(可根据需要选择,比如帮助文件之类的可以不要, 还可以strip,减少库的占用空间)
cp -avrf /opt/* /mnt/armfs/opt/
(2) 复制字体文件
cp -avf /usr/share/fonts/truetype/wqy/wqy-zenhei.ttc /mnt/armfs/opt/share/directfb-1.2.8/
3. 编译可应用程序 (参考directfb的文本显示例子)
程序代码(我用的是linux系统,所以源代码中输入的中文应该是utf8的):
/**
* text.c
*
* Drawing text
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <directfb.h>
/*
* (Globals)
*/
static IDirectFB *dfb = NULL;
static IDirectFBSurface *primary = NULL;
static int screen_width = 0;
static int screen_height = 0;
#define DFBCHECK(x...) \
{ \
DFBResult err = x; \
\
if (err != DFB_OK) \
{ \
fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
DirectFBErrorFatal( #x, err ); \
} \
}
/*
* The font we will use to draw the text.
*/
static IDirectFBFont *font = NULL;
/*
* The string we will draw. Strings in DirectFB have to UTF-8 encoded.
* For ASCII characters this does not make any difference.
*/
static char *text = "DirectFB rulez!我是中国人";
#define DATADIR "/opt/share/directfb-1.2.8"
int main (int argc, char **argv)
{
int i, width;
/*
* A structure describing font properties.
*/
DFBFontDescription font_dsc;
/*
* (Locals)
*/
DFBSurfaceDescription dsc;
/*
* (Initialize)
*/
DFBCHECK (DirectFBInit (&argc, &argv));
DFBCHECK (DirectFBCreate (&dfb));
DFBCHECK (dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
dsc.flags = DSDESC_CAPS;
dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
DFBCHECK (dfb->CreateSurface( dfb, &dsc, &primary ));
DFBCHECK (primary->GetSize (primary, &screen_width, &screen_height));
/*
* First we need to create a font interface by passing a filename
* and a font description to specify the desired font size. DirectFB will
* find (or not) a suitable font loader.
*/
font_dsc.flags = DFDESC_HEIGHT;
font_dsc.height = 48;
DFBCHECK (dfb->CreateFont (dfb, DATADIR"/wqy-zenhei.ttc", &font_dsc, &font));
/*
* Set the font to the surface we want to draw to.
*/
DFBCHECK (primary->SetFont (primary, font));
/*
* Determine the size of our string when drawn using the loaded font.
* Since we are interested in the full string, we pass -1 as string length.
*/
DFBCHECK (font->GetStringWidth (font, text, -1, &width));
/*
* We want to let the text slide in on the right and slide out on the left.
*/
for (i = screen_width; i > -width; i--)
{
/*
* Clear the screen.
*/
DFBCHECK (primary->SetColor (primary, 0x0, 0x0, 0x0, 0xFF));
DFBCHECK (primary->FillRectangle (primary, 0, 0, screen_width, screen_height));
/*
* Set the color that will be used to draw the text.
*/
DFBCHECK (primary->SetColor (primary, 0x80, 0x0, 0x20, 0xFF));
/*
* Draw the text left aligned with "i" as the X coordinate.
*/
DFBCHECK (primary->DrawString (primary, text, -1, i, screen_height / 2, DSTF_LEFT));
/*
* Flip the front and back buffer, but wait for the vertical retrace to avoid tearing.
*/
DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAITFORSYNC));
}
/*
* Release the font.
*/
font->Release (font);
/*
* (Release)
*/
primary->Release (primary);
dfb->Release (dfb);
return 23;
}
需要的软件包:
zlib_1.2.3.3.dfsg.orig.tar.gz, libpng-1.2.38.tar.bz2 , jpegsrc.v7.tar.gz, freetype_2.3.7.orig.tar.gz, directfb_1.2.8.orig.tar.gz
(1) zlib 编译:
tar zxvf ../src/zlib_1.2.3.3.dfsg.orig.tar.gz
cd zlib-1.2.3.3.dfsg
CC=arm-none-linux-gnueabi-gcc ./configure --prefix=/opt
make && make install
cd .. && rm -rf zlib*
(2) libpng 编译:
tar jxvf ../src/libpng-1.2.38.tar.bz2
cd libpng-1.2.38/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-none-linux-gnueabi-gcc CFLAGS=-I/opt/include \
LDFLAGS=-L/opt/lib ./configure --host=arm-none-linux-gnueabi --prefix=/opt --with-gnu-ld
make && make install
cd .. && rm -rf libpng*
(3) libjpeg 编译:cd libpng-1.2.38/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-none-linux-gnueabi-gcc CFLAGS=-I/opt/include \
LDFLAGS=-L/opt/lib ./configure --host=arm-none-linux-gnueabi --prefix=/opt --with-gnu-ld
make && make install
cd .. && rm -rf libpng*
tar zxvf ../src/jpegsrc.v7.tar.gz
cd jpeg-7/
CC=arm-none-linux-gnueabi-gcc ./configure --host=arm-none-linux-gnueabi \
--prefix=/opt --with-gnu-ld
make && make install
cd .. && rm -rf jpeg*
(4) freetype 编译:
tar zxvf ../src/freetype_2.3.7.orig.tar.gz
cd freetype-2.3.7/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-none-linux-gnueabi-gcc \
CFLAGS=-I/opt/include LDFLAGS=-L/opt/lib ./configure --host=arm-none-linux-gnueabi \
--prefix=/opt --with-gnu-ld
make && make install
cd .. && rm -rf freetype*
(5) directfb 编译:
tar zxvf ../src/directfb_1.2.8.orig.tar.gz
cd directfb-1.2.8
CPPFLAGS="-I/opt/include" CFLAGS="-I/opt/include" LDFLAGS="-L/opt/lib" \
PKG_CONFIG_PATH="/opt/lib/pkgconfig" CC=arm-none-linux-gnueabi-gcc \
./configure --host=arm-none-linux-gnueabi --prefix=/opt --exec-prefix=/opt --enable-zlib --disable-x11 \
--enable-fbdev --disable-sdl --disable-vnc --enable-jpeg --disable-gif \
--enable-text --enable-freetype --enable-text --disable-network --disable-debug-support \
--disable-video4linux --with-gnu-ld
make && make install
cd .. && rm -rf directfb*
cd directfb-1.2.8
CPPFLAGS="-I/opt/include" CFLAGS="-I/opt/include" LDFLAGS="-L/opt/lib" \
PKG_CONFIG_PATH="/opt/lib/pkgconfig" CC=arm-none-linux-gnueabi-gcc \
./configure --host=arm-none-linux-gnueabi --prefix=/opt --exec-prefix=/opt --enable-zlib --disable-x11 \
--enable-fbdev --disable-sdl --disable-vnc --enable-jpeg --disable-gif \
--enable-text --enable-freetype --enable-text --disable-network --disable-debug-support \
--disable-video4linux --with-gnu-ld
make && make install
cd .. && rm -rf directfb*
2. 配置根文件系统
(1) 复制库文件(可根据需要选择,比如帮助文件之类的可以不要, 还可以strip,减少库的占用空间)
cp -avrf /opt/* /mnt/armfs/opt/
(2) 复制字体文件
cp -avf /usr/share/fonts/truetype/wqy/wqy-zenhei.ttc /mnt/armfs/opt/share/directfb-1.2.8/
3. 编译可应用程序 (参考directfb的文本显示例子)
程序代码(我用的是linux系统,所以源代码中输入的中文应该是utf8的):
/**
* text.c
*
* Drawing text
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <directfb.h>
/*
* (Globals)
*/
static IDirectFB *dfb = NULL;
static IDirectFBSurface *primary = NULL;
static int screen_width = 0;
static int screen_height = 0;
#define DFBCHECK(x...) \
{ \
DFBResult err = x; \
\
if (err != DFB_OK) \
{ \
fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
DirectFBErrorFatal( #x, err ); \
} \
}
/*
* The font we will use to draw the text.
*/
static IDirectFBFont *font = NULL;
/*
* The string we will draw. Strings in DirectFB have to UTF-8 encoded.
* For ASCII characters this does not make any difference.
*/
static char *text = "DirectFB rulez!我是中国人";
#define DATADIR "/opt/share/directfb-1.2.8"
int main (int argc, char **argv)
{
int i, width;
/*
* A structure describing font properties.
*/
DFBFontDescription font_dsc;
/*
* (Locals)
*/
DFBSurfaceDescription dsc;
/*
* (Initialize)
*/
DFBCHECK (DirectFBInit (&argc, &argv));
DFBCHECK (DirectFBCreate (&dfb));
DFBCHECK (dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
dsc.flags = DSDESC_CAPS;
dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
DFBCHECK (dfb->CreateSurface( dfb, &dsc, &primary ));
DFBCHECK (primary->GetSize (primary, &screen_width, &screen_height));
/*
* First we need to create a font interface by passing a filename
* and a font description to specify the desired font size. DirectFB will
* find (or not) a suitable font loader.
*/
font_dsc.flags = DFDESC_HEIGHT;
font_dsc.height = 48;
DFBCHECK (dfb->CreateFont (dfb, DATADIR"/wqy-zenhei.ttc", &font_dsc, &font));
/*
* Set the font to the surface we want to draw to.
*/
DFBCHECK (primary->SetFont (primary, font));
/*
* Determine the size of our string when drawn using the loaded font.
* Since we are interested in the full string, we pass -1 as string length.
*/
DFBCHECK (font->GetStringWidth (font, text, -1, &width));
/*
* We want to let the text slide in on the right and slide out on the left.
*/
for (i = screen_width; i > -width; i--)
{
/*
* Clear the screen.
*/
DFBCHECK (primary->SetColor (primary, 0x0, 0x0, 0x0, 0xFF));
DFBCHECK (primary->FillRectangle (primary, 0, 0, screen_width, screen_height));
/*
* Set the color that will be used to draw the text.
*/
DFBCHECK (primary->SetColor (primary, 0x80, 0x0, 0x20, 0xFF));
/*
* Draw the text left aligned with "i" as the X coordinate.
*/
DFBCHECK (primary->DrawString (primary, text, -1, i, screen_height / 2, DSTF_LEFT));
/*
* Flip the front and back buffer, but wait for the vertical retrace to avoid tearing.
*/
DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAITFORSYNC));
}
/*
* Release the font.
*/
font->Release (font);
/*
* (Release)
*/
primary->Release (primary);
dfb->Release (dfb);
return 23;
}
2009年9月6日星期日
gtk directfb arm linux交叉编译过程
#!/usr/bin/bash
#Packages list
#atk-1.26.0.tar.bz2 expat_2.0.1.orig.tar.gz glib-2.21.5.tar.bz2 gtk-doc-1.11.tar.bz2 librsvg-2.22.3.tar.bz2 poppler-0.10.7.tar.gz
#cairo-1.8.2.tar.gz fontconfig-2.5.91.tar.gz gst-plugins-base-0.10.23.tar.bz2 hicolor-icon-theme-0.10.tar.gz libxml2-sources-2.6.31.tar.gz SHA256SUMS-for-bz2
#dbus_1.2.16.orig.tar.gz freetype-2.3.6.tar.bz2 gstreamer-0.10.23.tar.bz2 jpegsrc.v7.tar.gz pango-1.24.5.tar.bz2 tslib_1.0.orig.tar.gz
#DirectFB-1.3.0.tar.gz gettext-0.16.tar.gz gtk+-2.16.6.tar.bz2 libpng-1.2.38.tar.bz2 pixman-0.12.0.tar.gz
# Step 1: Build Glib
#************Important**********************************************#
# you need to check your cross compiling toolchain to find whether
# there is an underscore before symbols, for example:
# cat >test.c <<"EOF"
# int test(){}
# EOF
# arm-linux-gcc -c test.c
# nm test.o
# rm test.c test.o
# then set glib_cv_uscore to "no" or "yes" according to the result of "nm test.o"
#************Important**********************************************#
tar jxvf ../src/glib-2.21.5.tar.bz2
cd glib-2.21.5
cat > config.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
CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/opt --cache-file=config.cache
make
sudo PATH=$PATH:/usr/local/arm/4.2.2-eabi/usr/bin make install
cd .. && rm -rf glib*
# Step 2: Build atk
tar jxvf ../src/atk-1.26.0.tar.bz2
cd atk-1.26.0/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/opt
make && make install
cd .. && rm -rf atk*
# Step 3: png
tar jxvf ../src/libpng-1.2.38.tar.bz2
cd libpng-1.2.38/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/opt
make && make install
cd .. && rm -rf libpng*
# Step 4: jpeg
tar zxvf ../src/jpegsrc.v7.tar.gz
cd jpeg-7/
CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/opt
make && make install
cd .. && rm -rf jpeg*
# Step 5: libxml
tar zxvf ../src/libxml2-sources-2.6.31.tar.gz
cd libxml2-2.6.31/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/opt
make && make install
cd .. && rm -rf libxml*
# Step 6: pixman
tar zxvf ../src/pixman-0.12.0.tar.gz
cd pixman-0.12.0/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-linux-gcc ./configure --host=arm-linux \
--prefix=/opt --disable-gtk
make && make install
cd .. && rm -rf pixman*
# Step 7: freetype
tar jxvf ../src/freetype-2.3.6.tar.bz2
cd freetype-2.3.6/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/opt
make && make install
cd .. && rm -rf freetype*
# Step 8: fontconfig
tar zxvf ../src/fontconfig-2.5.91.tar.gz
cd fontconfig-2.5.91
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-linux-gcc ./configure --host=arm-linux \
--with-arch=arm --prefix=/opt --with-freetype-config=/opt/bin/freetype-config
make && make install
cd .. && rm -rf fontconfig*
# Step 9: directfb
tar zxvf ../src/DirectFB-1.3.0.tar.gz
cd DirectFB-1.3.0/
CPPFLAGS="-I/opt/include" CFLAGS="-I/opt/include" LDFLAGS="-L/opt/lib" \
PKG_CONFIG_PATH="/opt/lib/pkgconfig" \
./configure --host=arm-linux --prefix=/opt --exec-prefix=/opt --enable-zlib --disable-x11 \
--enable-fbdev --disable-sdl --disable-vnc --enable-jpeg --disable-gif --with-gfxdrivers=none
make && make install
cd .. && rm -rf DirectFB*
# Step 10: poppler
tar zxvf ../src/poppler-0.10.7.tar.gz
cd poppler-0.10.7/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-linux-gcc CPPFLAGS="-I/opt/include" \
CFLAGS="-I/opt/include" LDFLAGS="-L/opt/lib" \
./configure --host=arm-linux --enable-libjpeg --without-x --disable-gtk-test \
--disable-utils --disable-splash-output --disable-gdk --prefix=/opt
make && make install
cd .. && rm -rf poppler*
# Step 11: cairo
tar zxvf ../src/cairo-1.8.2.tar.gz
cd cairo-1.8.2/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CPPFLAGS="-I/opt/include" CFLAGS="-I/opt/include" LDFLAGS="-L/opt/lib" \
./configure --without-x --prefix=/opt --enable-directfb --enable-xlib=no --host=arm-linux --enable-ps=yes \
--enable-svg=yes --enable-pdf=yes
make && make install
cd .. && rm -rf cairo*
# Step 12: pango
tar jxvf ../src/pango-1.24.5.tar.bz2
cd pango-1.24.5/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-linux-gcc ./configure --host=arm-linux \
--without-x --prefix=/opt
make && make install
cd .. && rm -rf pango*
# Step 13: gtk+
# There is a "Can't link to Pango " problem, not find a better solution but the following:
# change [ if $PKG_CONFIG uninstalled $PANGO_PACKAGES; then ] to
# ---> [ if $PKG_CONFIG $PANGO_PACKAGES; then ]
#
tar jxvf ../src/gtk+-2.16.6.tar.bz2
cd gtk+-2.16.6/
cat>config.cache<<"EOF"
gio_can_sniff=yes
EOF
CPPFLAGS="-I/opt/include" CFLAGS="-I/opt/include" LDFLAGS="-L/opt/lib" \
PKG_CONFIG_LIBDIR=/opt/lib/pkgconfig CC=arm-linux-gcc ./configure --host=arm-linux \
--without-x --prefix=/opt --without-libtiff --without-libjasper --with-gdktarget=directfb \
--cache-file=config.cache --disable-glibtest --disable-gdiplus --disable-cups
make && make install
cd .. && rm -rf gtk
# Test
# Hello World
# download from:
# http://library.gnome.org/devel/gtk-tutorial/stable/c39.html#SEC-HELLOWORLD
# Makefile
DEBUG=-g
CFLAGS=-Wall -c ${DEBUG}
GTK_CFLAGS=`pkg-config --cflags gtk+-2.0 cairo cairo-ft cairo-directfb directfb freetype2 pangoft2 pangocairo pango pixman-1`
GTK_LIBS=`pkg-config --libs libpng12 libxml-2.0 gtk+-2.0 atk cairo cairo-ft cairo-directfb directfb freetype2 pangoft2 pangocairo pango pixman-1`
GMODULE_LIBS= `pkg-config --libs gmodule-2.0`
CC=arm-linux-gcc
gtkdemo:
${CC} ${GTK_CFLAGS} ${OBJS} -v -o gtkdemo gtkdemo.c ${GTK_LIBS} ${GMODULE_LIBS}
clean:
rm gtkdemo
# Build method
PKG_CONFIG_PATH=/opt/lib/pkgconfig make
# Strip Libs
# decrease libs size
cd /opt/lib
arm-linux-strip -s ./*
cd /opt/bin
arm-linux-strip -s ./*
# rootfile system config
pango-querymodules > '/opt/etc/pango/pango.modules'
# At last you should copy fonts and config them.
#Packages list
#atk-1.26.0.tar.bz2 expat_2.0.1.orig.tar.gz glib-2.21.5.tar.bz2 gtk-doc-1.11.tar.bz2 librsvg-2.22.3.tar.bz2 poppler-0.10.7.tar.gz
#cairo-1.8.2.tar.gz fontconfig-2.5.91.tar.gz gst-plugins-base-0.10.23.tar.bz2 hicolor-icon-theme-0.10.tar.gz libxml2-sources-2.6.31.tar.gz SHA256SUMS-for-bz2
#dbus_1.2.16.orig.tar.gz freetype-2.3.6.tar.bz2 gstreamer-0.10.23.tar.bz2 jpegsrc.v7.tar.gz pango-1.24.5.tar.bz2 tslib_1.0.orig.tar.gz
#DirectFB-1.3.0.tar.gz gettext-0.16.tar.gz gtk+-2.16.6.tar.bz2 libpng-1.2.38.tar.bz2 pixman-0.12.0.tar.gz
# Step 1: Build Glib
#************Important**********************************************#
# you need to check your cross compiling toolchain to find whether
# there is an underscore before symbols, for example:
# cat >test.c <<"EOF"
# int test(){}
# EOF
# arm-linux-gcc -c test.c
# nm test.o
# rm test.c test.o
# then set glib_cv_uscore to "no" or "yes" according to the result of "nm test.o"
#************Important**********************************************#
tar jxvf ../src/glib-2.21.5.tar.bz2
cd glib-2.21.5
cat > config.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
CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/opt --cache-file=config.cache
make
sudo PATH=$PATH:/usr/local/arm/4.2.2-eabi/usr/bin make install
cd .. && rm -rf glib*
# Step 2: Build atk
tar jxvf ../src/atk-1.26.0.tar.bz2
cd atk-1.26.0/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/opt
make && make install
cd .. && rm -rf atk*
# Step 3: png
tar jxvf ../src/libpng-1.2.38.tar.bz2
cd libpng-1.2.38/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/opt
make && make install
cd .. && rm -rf libpng*
# Step 4: jpeg
tar zxvf ../src/jpegsrc.v7.tar.gz
cd jpeg-7/
CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/opt
make && make install
cd .. && rm -rf jpeg*
# Step 5: libxml
tar zxvf ../src/libxml2-sources-2.6.31.tar.gz
cd libxml2-2.6.31/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/opt
make && make install
cd .. && rm -rf libxml*
# Step 6: pixman
tar zxvf ../src/pixman-0.12.0.tar.gz
cd pixman-0.12.0/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-linux-gcc ./configure --host=arm-linux \
--prefix=/opt --disable-gtk
make && make install
cd .. && rm -rf pixman*
# Step 7: freetype
tar jxvf ../src/freetype-2.3.6.tar.bz2
cd freetype-2.3.6/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/opt
make && make install
cd .. && rm -rf freetype*
# Step 8: fontconfig
tar zxvf ../src/fontconfig-2.5.91.tar.gz
cd fontconfig-2.5.91
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-linux-gcc ./configure --host=arm-linux \
--with-arch=arm --prefix=/opt --with-freetype-config=/opt/bin/freetype-config
make && make install
cd .. && rm -rf fontconfig*
# Step 9: directfb
tar zxvf ../src/DirectFB-1.3.0.tar.gz
cd DirectFB-1.3.0/
CPPFLAGS="-I/opt/include" CFLAGS="-I/opt/include" LDFLAGS="-L/opt/lib" \
PKG_CONFIG_PATH="/opt/lib/pkgconfig" \
./configure --host=arm-linux --prefix=/opt --exec-prefix=/opt --enable-zlib --disable-x11 \
--enable-fbdev --disable-sdl --disable-vnc --enable-jpeg --disable-gif --with-gfxdrivers=none
make && make install
cd .. && rm -rf DirectFB*
# Step 10: poppler
tar zxvf ../src/poppler-0.10.7.tar.gz
cd poppler-0.10.7/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-linux-gcc CPPFLAGS="-I/opt/include" \
CFLAGS="-I/opt/include" LDFLAGS="-L/opt/lib" \
./configure --host=arm-linux --enable-libjpeg --without-x --disable-gtk-test \
--disable-utils --disable-splash-output --disable-gdk --prefix=/opt
make && make install
cd .. && rm -rf poppler*
# Step 11: cairo
tar zxvf ../src/cairo-1.8.2.tar.gz
cd cairo-1.8.2/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CPPFLAGS="-I/opt/include" CFLAGS="-I/opt/include" LDFLAGS="-L/opt/lib" \
./configure --without-x --prefix=/opt --enable-directfb --enable-xlib=no --host=arm-linux --enable-ps=yes \
--enable-svg=yes --enable-pdf=yes
make && make install
cd .. && rm -rf cairo*
# Step 12: pango
tar jxvf ../src/pango-1.24.5.tar.bz2
cd pango-1.24.5/
PKG_CONFIG_PATH=/opt/lib/pkgconfig CC=arm-linux-gcc ./configure --host=arm-linux \
--without-x --prefix=/opt
make && make install
cd .. && rm -rf pango*
# Step 13: gtk+
# There is a "Can't link to Pango " problem, not find a better solution but the following:
# change [ if $PKG_CONFIG uninstalled $PANGO_PACKAGES; then ] to
# ---> [ if $PKG_CONFIG $PANGO_PACKAGES; then ]
#
tar jxvf ../src/gtk+-2.16.6.tar.bz2
cd gtk+-2.16.6/
cat>config.cache<<"EOF"
gio_can_sniff=yes
EOF
CPPFLAGS="-I/opt/include" CFLAGS="-I/opt/include" LDFLAGS="-L/opt/lib" \
PKG_CONFIG_LIBDIR=/opt/lib/pkgconfig CC=arm-linux-gcc ./configure --host=arm-linux \
--without-x --prefix=/opt --without-libtiff --without-libjasper --with-gdktarget=directfb \
--cache-file=config.cache --disable-glibtest --disable-gdiplus --disable-cups
make && make install
cd .. && rm -rf gtk
# Test
# Hello World
# download from:
# http://library.gnome.org/devel/gtk-tutorial/stable/c39.html#SEC-HELLOWORLD
# Makefile
DEBUG=-g
CFLAGS=-Wall -c ${DEBUG}
GTK_CFLAGS=`pkg-config --cflags gtk+-2.0 cairo cairo-ft cairo-directfb directfb freetype2 pangoft2 pangocairo pango pixman-1`
GTK_LIBS=`pkg-config --libs libpng12 libxml-2.0 gtk+-2.0 atk cairo cairo-ft cairo-directfb directfb freetype2 pangoft2 pangocairo pango pixman-1`
GMODULE_LIBS= `pkg-config --libs gmodule-2.0`
CC=arm-linux-gcc
gtkdemo:
${CC} ${GTK_CFLAGS} ${OBJS} -v -o gtkdemo gtkdemo.c ${GTK_LIBS} ${GMODULE_LIBS}
clean:
rm gtkdemo
# Build method
PKG_CONFIG_PATH=/opt/lib/pkgconfig make
# Strip Libs
# decrease libs size
cd /opt/lib
arm-linux-strip -s ./*
cd /opt/bin
arm-linux-strip -s ./*
# rootfile system config
pango-querymodules > '/opt/etc/pango/pango.modules'
# At last you should copy fonts and config them.
订阅:
博文 (Atom)