- 论坛徽章:
- 0
|
Success after 12 days. It really spends my too much time.
This is the version of the source code:
-rw-r--r-- 1 jiabao jiabao 16245771 2010-01-24 18:10 binutils-2.19.1.tar.bz2
-rw-r--r-- 1 jiabao jiabao 59369954 2010-01-24 18:11 gcc-4.3.3.tar.bz2
-rw-r--r-- 1 jiabao jiabao 15684114 2010-01-24 18:02 glibc-2.11.tar.bz2
-rw-r--r-- 1 jiabao jiabao 599606 2010-01-24 18:02 glibc-ports-2.11.tar.bz2
-rw-r--r-- 1 jiabao jiabao 1710660 2010-01-24 18:09 gmp-4.2.4.tar.bz2
-rw-r--r-- 1 jiabao jiabao 59416602 2010-01-24 18:21 linux-2.6.30.1.tar.bz2
-rw-r--r-- 1 jiabao jiabao 1064281 2010-01-24 19:09 mpfr-2.4.1.tar.bz2
There is the patch:
-rw-r--r-- 1 jiabao jiabao 569269 2010-01-24 18:09 binutils-2.19.1-branch_update-1.patch
-rw-r--r-- 1 jiabao jiabao 3649 2010-01-24 18:09 binutils-2.19.1-posix-1.patch
-rw-r--r-- 1 jiabao jiabao 367968 2010-01-24 18:08 gcc-4.3.3-branch_update-5.patch
-rw-r--r-- 1 jiabao jiabao 14268 2010-01-24 18:08 gcc-4.3.3-posix-1.patch
-rw-r--r-- 1 jiabao jiabao 1446 2010-01-24 19:25 gcc_eh.patch.cross
-rw-r--r-- 1 jiabao jiabao 3720 2010-01-24 18:09 mpfr-2.4.1-branch_update-1.patch
-rw-r--r-- 1 jiabao jiabao 6770 2010-01-24 18:44 mpfr-2.4.1-branch_update-2.patch
Prepare work:
Create the proper directory.
untar all tar packages, use the patches.
Shell file:
#!/bin/sh
export proot=/home/jiabao/embedded
export prefix=/home/jiabao/embedded/cross-tools
export target=arm-linux
export PATH=$prefix/tools/bin:$PATH
export host=i486-cross-linux-gnu
export linux_tar=linux-2.6.30.1
export binutils_tar=binutils-2.19.1
export gcc_tar=gcc-4.3.3
export glibc_tar=glibc-2.11
#assume something:all source&patch have been ready.
#build bintuils
cd $proot/tar/build
mkdir binutils
cd binutils
AR=ar AS=as ../../src/${binutils_tar}/configure --build=$host --host=$host --target=$target --prefix=$prefix/tools --with-sysroot=$prefix --disable-nls --enable-shared --disable-multilib --disable-werror
make all
make install
#install the linux kernel headers
cd $proot/tar/src
cd $linux_tar
mkdir -p $prefix/usr/include
make mrproper
make ARCH=arm headers_check
make ARCH=arm INSTALL_HDR_PATH=dest headers_install
cp -rv dest/include/* ${prefix}/usr/include
find ${prefix}/usr/include -name .install -or -name ..install.cmd | xargs rm -fv
#Build gcc the first time
cd $proot/tar/build
mkdir gcc
cd gcc
AR=ar LDFLAGS="-Wl,-rpath,${prefix}/lib" \
../../src/gcc-4.3.3/configure \
--build=$host \
--host=$host \
--target=$target \
--prefix=$prefix/tools \
--enable-languages=c \
--disable-nls \
--disable-shared \
--disable-threads \
--disable-libmudflap \
--disable-libssp \
--disable-libgomp \
--disable-decimal-float \
--without-headers --with-newlib \
--with-sysroot=$prefix
make
make install
#Build glibc
cd $proot/tar/build
rm -Rf glibc
mkdir glibc
cd glibc
echo "libc_cv_forced_unwind=yes" > config.cache
echo "libc_cv_c_cleanup=yes" >> config.cache
echo "libc_cv_arm_tls=yes" >> config.cache
BUILD_CC="gcc" CC=arm-linux-gcc AR=arm-linux-ar RANLIB=arm-linux-ranlib \
../../src/$glibc_tar/configure \
--build=$host \
--host=arm-linux \
--target=arm-linux \
--prefix=/usr \
--with-tls \
--disable-profile --enable-add-ons \
--enable-kernel=2.6.0 --with-__thread \
--with-binutils=${prefix}/bin \
--with-headers=$prefix/usr/include \
--cache-file=config.cache
make all
make install install_root=$prefix
#Build gcc the second time
cd $proot/tar/build
rm -Rf gcc
mkdir gcc
cd gcc
../../src/gcc-4.3.3/configure \
--build=$host \
--host=$host \
--target=$target \
--prefix=$prefix/tools \
--enable-languages=c,c++ --enable-c99 \
--enable-threads=posix \
--enable-long-long \
--enable-shared \
--enable-__cxa_atexit \
--disable-multilib \
--disable-nls \
--with-sysroot=$prefix
make
make install
After cross-compile, the directory is here:
embedded/
|-- cross-tools
| |-- etc
| |-- lib
| |-- sbin
| |-- tools
| | |-- arm-linux
| | |-- bin
| | |-- i486-cross-linux-gnu
| | |-- include
| | |-- info
| | |-- lib
| | |-- libexec
| | |-- man
| | `-- share
| `-- usr
| |-- bin
| |-- include
| |-- lib
| |-- libexec
| |-- sbin
| `-- share
|-- tar
| |-- build
| | |-- binutils
| | |-- gcc
| | `-- glibc
| |-- patch
| `-- src
| |-- binutils-2.19.1
| |-- gcc-4.3.3
| |-- glibc-2.11
| `-- linux-2.6.30.1
`-- test
using the cross gcc to compile a test app.
arm-linux-gcc -static a.c
Using qemu to verify the result:
qemu-arm a.out
Success show:
Hello, world!
![]()
文件:embedded.tar.gz
大小:967KB
下载:
下载
Shell file and a.out
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/60303/showart_2159276.html |
|